Back to index

php5  5.3.10
Functions | Variables
mbfilter_qprint.h File Reference
#include "mbfilter.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int mbfl_filt_conv_qprintenc (int c, mbfl_convert_filter *filter)
int mbfl_filt_conv_qprintenc_flush (mbfl_convert_filter *filter)
int mbfl_filt_conv_qprintdec (int c, mbfl_convert_filter *filter)
int mbfl_filt_conv_qprintdec_flush (mbfl_convert_filter *filter)

Variables

const mbfl_encoding mbfl_encoding_qprint

Function Documentation

int mbfl_filt_conv_qprintdec ( int  c,
mbfl_convert_filter *  filter 
)

Definition at line 156 of file mbfilter_qprint.c.

{
       int n, m;

       static int hex2code_map[] = {
              -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
              -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
              -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
               0,  1,  2,  3,  4,  5,  6,  7,  8,  9, -1, -1, -1, -1, -1, -1,
              -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1,
              -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
              -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1,
              -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
              -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
              -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
              -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
              -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
              -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
              -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
              -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
              -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
       };

       switch (filter->status) {
       case 1:
              if (hex2code_map[c & 0xff] >= 0) {
                     filter->cache = c;
                     filter->status = 2;
              } else if (c == 0x0d) {     /* soft line feed */
                     filter->status = 3;
              } else if (c == 0x0a) {     /* soft line feed */
                     filter->status = 0;
              } else {
                     CK((*filter->output_function)(0x3d, filter->data));            /* '=' */
                     CK((*filter->output_function)(c, filter->data));
                     filter->status = 0;
              }
              break;
       case 2:
              m = hex2code_map[c & 0xff];
              if (m < 0) {
                     CK((*filter->output_function)(0x3d, filter->data));            /* '=' */
                     CK((*filter->output_function)(filter->cache, filter->data));
                     n = c;
              } else {
                     n = hex2code_map[filter->cache] << 4 | m;
              }
              CK((*filter->output_function)(n, filter->data));
              filter->status = 0;
              break;
       case 3:
              if (c != 0x0a) {            /* LF */
                     CK((*filter->output_function)(c, filter->data));
              }
              filter->status = 0;
              break;
       default:
              if (c == 0x3d) {            /* '=' */
                     filter->status = 1;
              } else {
                     CK((*filter->output_function)(c, filter->data));
              }
              break;
       }

       return c;
}
int mbfl_filt_conv_qprintdec_flush ( mbfl_convert_filter *  filter)

Definition at line 224 of file mbfilter_qprint.c.

{
       int status, cache;

       status = filter->status;
       cache = filter->cache;
       filter->status = 0;
       filter->cache = 0;
       /* flush fragments */
       if (status == 1) {
              CK((*filter->output_function)(0x3d, filter->data));            /* '=' */
       } else if (status == 2) {
              CK((*filter->output_function)(0x3d, filter->data));            /* '=' */
              CK((*filter->output_function)(cache, filter->data));
       }

       return 0;
}
int mbfl_filt_conv_qprintenc ( int  c,
mbfl_convert_filter *  filter 
)

Definition at line 72 of file mbfilter_qprint.c.

{
       int s, n;

       switch (filter->status & 0xff) {
       case 0:
              filter->cache = c;
              filter->status++;
              break;
       default:
              s = filter->cache;
              filter->cache = c;
              n = (filter->status & 0xff00) >> 8;

              if (s == 0) {        /* null */
                     CK((*filter->output_function)(s, filter->data));
                     filter->status &= ~0xff00;
                     break;
              }

              if ((filter->status & MBFL_QPRINT_STS_MIME_HEADER) == 0) {
                     if (s == 0x0a || (s == 0x0d && c != 0x0a)) {     /* line feed */
                            CK((*filter->output_function)(0x0d, filter->data));            /* CR */
                            CK((*filter->output_function)(0x0a, filter->data));            /* LF */
                            filter->status &= ~0xff00;
                            break;
                     } else if (s == 0x0d) {
                            break;
                     }
              }

              if ((filter->status & MBFL_QPRINT_STS_MIME_HEADER) == 0  && n >= 72) {       /* soft line feed */
                     CK((*filter->output_function)(0x3d, filter->data));            /* '=' */
                     CK((*filter->output_function)(0x0d, filter->data));            /* CR */
                     CK((*filter->output_function)(0x0a, filter->data));            /* LF */
                     filter->status &= ~0xff00;
              }

              if (s <= 0 || s >= 0x80 || s == 0x3d             /* not ASCII or '=' */
                 || ((filter->status & MBFL_QPRINT_STS_MIME_HEADER) != 0 && 
                     (mbfl_charprop_table[s] & MBFL_CHP_MMHQENC) != 0)) {
                     /* hex-octet */
                     CK((*filter->output_function)(0x3d, filter->data));            /* '=' */
                     n = (s >> 4) & 0xf;
                     if (n < 10) {
                            n += 48;             /* '0' */
                     } else {
                            n += 55;             /* 'A' - 10 */
                     }
                     CK((*filter->output_function)(n, filter->data));
                     n = s & 0xf;
                     if (n < 10) {
                            n += 48;
                     } else {
                            n += 55;
                     }
                     CK((*filter->output_function)(n, filter->data));
                     if ((filter->status & MBFL_QPRINT_STS_MIME_HEADER) == 0) {
                            filter->status += 0x300;
                     }
              } else {
                     CK((*filter->output_function)(s, filter->data));
                     if ((filter->status & MBFL_QPRINT_STS_MIME_HEADER) == 0) {
                            filter->status += 0x100;
                     }
              }
              break;
       }

       return c;
}
int mbfl_filt_conv_qprintenc_flush ( mbfl_convert_filter *  filter)

Definition at line 144 of file mbfilter_qprint.c.

{
       /* flush filter cache */
       (*filter->filter_function)('\0', filter);
       filter->status &= ~0xffff;
       filter->cache = 0;
       return 0;
}

Variable Documentation

Definition at line 40 of file mbfilter_qprint.c.