示例#1
0
void UObjectIO::output()
{
   U_INTERNAL_TRACE("UObjectIO::output()")

   U_INTERNAL_ASSERT_POINTER(os)

   buffer_output_len = os->pcount();

   U_INTERNAL_PRINT("os->pcount() = %d", buffer_output_len)

   U_INTERNAL_ASSERT_MINOR(buffer_output_len, buffer_output_sz)

   buffer_output[buffer_output_len] = '\0';

   U_INTERNAL_PRINT("buffer_output = %.*s", U_min(buffer_output_len,128), buffer_output)

#ifdef DEBUG_DEBUG
   off_t pos = os->rdbuf()->pubseekpos(0, U_openmode);
#else
        (void) os->rdbuf()->pubseekpos(0, U_openmode);
#endif

   U_INTERNAL_PRINT("pos = %ld, os->pcount() = %d", pos, os->pcount())
}
示例#2
0
文件: cescape.c 项目: tempbottle/ULib
// ============================================================================

/*
#define DEBUG_DEBUG
*/

#include <ulib/base/utility.h>
#include <ulib/base/coder/escape.h>

uint32_t u_escape_encode(const unsigned char* restrict inptr, uint32_t len, char* restrict out, uint32_t max_output)
{
   const unsigned char* restrict inend  = inptr + len;
                  char* restrict outptr = out;
                  char* restrict outend = out + (max_output - 4);

   U_INTERNAL_TRACE("u_escape_encode(%.*s,%u,%p,%u)", U_min(len,128), inptr, len, out, max_output)

   U_INTERNAL_ASSERT_POINTER(out)
   U_INTERNAL_ASSERT_POINTER(inptr)

   *outptr++ = '"';

   while (inptr < inend)
      {
      outptr += u_sprintc(outptr, *inptr++);

      if (outptr >= outend)
         {
         u_put_unalignedp32(outptr, U_MULTICHAR_CONSTANT32('.','.','.','"'));

         outptr[4] = '\0';
示例#3
0
set generally shouldn't be encoded. The = character itself must be encoded, though; it's encoded as =3D. Also,
space and tab characters at the ends of lines must be encoded (as =20 and =09, respectively); this keeps broken
gateways from eating them. If a line ends with = followed by CR-LF, those characters are ignored; this lets you
continue ("wrap") a long line. Lines must be no more than 76 characters long, not counting the final CR-LF. Longer
lines will be broken when the message is encoded and joined again by decoding.
Quoted-printable text was designed to be (mostly) readable by people with non-MIME mail programs. 
*/

uint32_t u_quoted_printable_encode(const unsigned char* restrict inptr, uint32_t len, unsigned char* restrict out)
{
         int n = 0;
         unsigned char ch, ws  = '\0';
         unsigned char* restrict outptr = out;
   const unsigned char* restrict inend  = inptr + len;

   U_INTERNAL_TRACE("u_quoted_printable_encode(%.*s,%u,%p)", U_min(len,128), inptr, len, out)

   U_INTERNAL_ASSERT_POINTER(inptr)

   while (inptr < inend)
      {
      ch = *inptr++;

      switch (ch)
         {
         case ' ':
         case '\t':
            {
            if (ws)
               {
               *outptr++ = ws;
示例#4
0
文件: chexdump.c 项目: fast01/ULib
//
// ============================================================================

/*
#define DEBUG_DEBUG
*/

#include <ulib/base/utility.h>
#include <ulib/base/coder/hexdump.h>

uint32_t u_hexdump_encode(const unsigned char* restrict input, uint32_t len, unsigned char* restrict result)
{
   uint32_t i;
   unsigned char* restrict r = result;

   U_INTERNAL_TRACE("u_hexdump_encode(%.*s,%u,%p)", U_min(len,128), input, len, result)

   U_INTERNAL_ASSERT_POINTER(input)

   for (i = 0; i < len; ++i)
      {
      unsigned char ch = input[i];

      u_put_unalignedp16(r, U_MULTICHAR_CONSTANT16(u_hex_lower[(ch >> 4) & 0x0F],
                                                   u_hex_lower[(ch     ) & 0x0F]));

      r += 2;
      }

   *r = 0;
示例#5
0
文件: cbase64.c 项目: psfu/ULib
#include <ctype.h>

#define U_PAD '='

int u_base64_errors;
int u_base64_max_columns;

uint32_t u_base64_encode(const unsigned char* restrict input, uint32_t len, unsigned char* restrict result)
{
   int cols = 0;
   bool columns = false;
   uint32_t i = 0, bits;
   unsigned char* restrict r = result;

   U_INTERNAL_TRACE("u_base64_encode(%.*s,%u,%p)", U_min(len,128), input, len, result)

   U_INTERNAL_ASSERT_POINTER(input)

   if (len > 2)
      {
      for (; i < len - 2; i += 3)
         {
         bits = ((((input[i]    << 8) +
                    input[i+1]) << 8) +
                    input[i+2]);

         u_put_unalignedp32(r, U_MULTICHAR_CONSTANT32(u_b64[ bits >> 18],
                                                      u_b64[(bits >> 12) & 0x3f],
                                                      u_b64[(bits >>  6) & 0x3f],
                                                      u_b64[ bits        & 0x3f]));