Back to index

php5  5.3.10
Classes | Typedefs | Functions | Variables
mbfl_convert.h File Reference
#include "mbfl_defs.h"
#include "mbfl_encoding.h"
#include "mbfl_memory_device.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _mbfl_convert_filter
struct  mbfl_convert_vtbl

Typedefs

typedef struct _mbfl_convert_filter

Functions

MBFLAPI mbfl_convert_filter * mbfl_convert_filter_new (enum mbfl_no_encoding from, enum mbfl_no_encoding to, int(*output_function)(int, void *), int(*flush_function)(void *), void *data)
MBFLAPI mbfl_convert_filter * mbfl_convert_filter_new2 (const struct mbfl_convert_vtbl *vtbl, int(*output_function)(int, void *), int(*flush_function)(void *), void *data)
MBFLAPI void mbfl_convert_filter_delete (mbfl_convert_filter *filter)
MBFLAPI int mbfl_convert_filter_feed (int c, mbfl_convert_filter *filter)
MBFLAPI int mbfl_convert_filter_flush (mbfl_convert_filter *filter)
MBFLAPI void mbfl_convert_filter_reset (mbfl_convert_filter *filter, enum mbfl_no_encoding from, enum mbfl_no_encoding to)
MBFLAPI void mbfl_convert_filter_copy (mbfl_convert_filter *src, mbfl_convert_filter *dist)
MBFLAPI int mbfl_filt_conv_illegal_output (int c, mbfl_convert_filter *filter)
MBFLAPI struct mbfl_convert_vtblmbfl_convert_filter_get_vtbl (enum mbfl_no_encoding from, enum mbfl_no_encoding to)
MBFLAPI void mbfl_filt_conv_common_ctor (mbfl_convert_filter *filter)
MBFLAPI int mbfl_filt_conv_common_flush (mbfl_convert_filter *filter)
MBFLAPI void mbfl_filt_conv_common_dtor (mbfl_convert_filter *filter)
MBFLAPI int mbfl_convert_filter_devcat (mbfl_convert_filter *filter, mbfl_memory_device *src)
MBFLAPI int mbfl_convert_filter_strcat (mbfl_convert_filter *filter, const unsigned char *p)

Variables

MBFLAPI struct mbfl_convert_vtblmbfl_convert_filter_list []

Class Documentation

struct mbfl_convert_vtbl

Definition at line 59 of file mbfl_convert.h.


Typedef Documentation

typedef struct _mbfl_convert_filter

Definition at line 38 of file mbfl_convert.h.


Function Documentation

MBFLAPI void mbfl_convert_filter_copy ( mbfl_convert_filter *  src,
mbfl_convert_filter *  dist 
)

Definition at line 388 of file mbfl_convert.c.

{
       if (src->filter_copy != NULL) {
              src->filter_copy(src, dest);
              return;
       }

       *dest = *src;
}

Here is the caller graph for this function:

MBFLAPI void mbfl_convert_filter_delete ( mbfl_convert_filter *  filter)

Definition at line 348 of file mbfl_convert.c.

{
       if (filter) {
              (*filter->filter_dtor)(filter);
              mbfl_free((void*)filter);
       }
}

Here is the caller graph for this function:

MBFLAPI int mbfl_convert_filter_devcat ( mbfl_convert_filter *  filter,
mbfl_memory_device src 
)

Definition at line 400 of file mbfl_convert.c.

{
       int n;
       unsigned char *p;

       p = src->buffer;
       n = src->pos;
       while (n > 0) {
              if ((*filter->filter_function)(*p++, filter) < 0) {
                     return -1;
              }
              n--;
       }

       return n;
}

Here is the caller graph for this function:

MBFLAPI int mbfl_convert_filter_feed ( int  c,
mbfl_convert_filter *  filter 
)

Definition at line 357 of file mbfl_convert.c.

{
       return (*filter->filter_function)(c, filter);
}
MBFLAPI int mbfl_convert_filter_flush ( mbfl_convert_filter *  filter)

Definition at line 363 of file mbfl_convert.c.

{
       (*filter->filter_flush)(filter);
       return (filter->flush_function ? (*filter->flush_function)(filter->data) : 0);
}

Here is the caller graph for this function:

Definition at line 534 of file mbfl_convert.c.

{
       const struct mbfl_convert_vtbl *vtbl;
       int i;

       if (to == mbfl_no_encoding_base64 ||
           to == mbfl_no_encoding_qprint ||
           to == mbfl_no_encoding_7bit) {
              from = mbfl_no_encoding_8bit;
       } else if (from == mbfl_no_encoding_base64 ||
                        from == mbfl_no_encoding_qprint ||
                        from == mbfl_no_encoding_uuencode) {
              to = mbfl_no_encoding_8bit;
       }

       i = 0;
       while ((vtbl = mbfl_convert_filter_list[i++]) != NULL){
              if (vtbl->from == from && vtbl->to == to) {
                     return vtbl;
              }
       }

       return NULL;
}

Here is the caller graph for this function:

MBFLAPI mbfl_convert_filter* mbfl_convert_filter_new ( enum mbfl_no_encoding  from,
enum mbfl_no_encoding  to,
int(*)(int, void *)  output_function,
int(*)(void *)  flush_function,
void *  data 
)

Definition at line 288 of file mbfl_convert.c.

{
       mbfl_convert_filter * filter;
       const struct mbfl_convert_vtbl *vtbl;

       vtbl = mbfl_convert_filter_get_vtbl(from, to);

       if (vtbl == NULL) {
              vtbl = &vtbl_pass;
       }

       /* allocate */
       filter = (mbfl_convert_filter *)mbfl_malloc(sizeof(mbfl_convert_filter));
       if (filter == NULL) {
              return NULL;
       }

       if (mbfl_convert_filter_common_init(filter, from, to, vtbl,
                     output_function, flush_function, data)) {
              mbfl_free(filter);
              return NULL;
       }

       return filter;
}

Here is the call graph for this function:

Here is the caller graph for this function:

MBFLAPI mbfl_convert_filter* mbfl_convert_filter_new2 ( const struct mbfl_convert_vtbl vtbl,
int(*)(int, void *)  output_function,
int(*)(void *)  flush_function,
void *  data 
)

Definition at line 320 of file mbfl_convert.c.

{
       mbfl_convert_filter * filter;

       if (vtbl == NULL) {
              vtbl = &vtbl_pass;
       }

       /* allocate */
       filter = (mbfl_convert_filter *)mbfl_malloc(sizeof(mbfl_convert_filter));
       if (filter == NULL) {
              return NULL;
       }

       if (mbfl_convert_filter_common_init(filter, vtbl->from, vtbl->to, vtbl,
                     output_function, flush_function, data)) {
              mbfl_free(filter);
              return NULL;
       }

       return filter;
}

Here is the call graph for this function:

Here is the caller graph for this function:

MBFLAPI void mbfl_convert_filter_reset ( mbfl_convert_filter *  filter,
enum mbfl_no_encoding  from,
enum mbfl_no_encoding  to 
)

Definition at line 369 of file mbfl_convert.c.

{
       const struct mbfl_convert_vtbl *vtbl;

       /* destruct old filter */
       (*filter->filter_dtor)(filter);

       vtbl = mbfl_convert_filter_get_vtbl(from, to);

       if (vtbl == NULL) {
              vtbl = &vtbl_pass;
       }

       mbfl_convert_filter_common_init(filter, from, to, vtbl,
                     filter->output_function, filter->flush_function, filter->data);
}

Here is the call graph for this function:

Here is the caller graph for this function:

MBFLAPI int mbfl_convert_filter_strcat ( mbfl_convert_filter *  filter,
const unsigned char *  p 
)

Definition at line 417 of file mbfl_convert.c.

{
       int c;

       while ((c = *p++) != '\0') {
              if ((*filter->filter_function)(c, filter) < 0) {
                     return -1;
              }
       }

       return 0;
}

Here is the caller graph for this function:

MBFLAPI void mbfl_filt_conv_common_ctor ( mbfl_convert_filter *  filter)

Definition at line 562 of file mbfl_convert.c.

{
       filter->status = 0;
       filter->cache = 0;
}

Here is the caller graph for this function:

MBFLAPI void mbfl_filt_conv_common_dtor ( mbfl_convert_filter *  filter)

Definition at line 579 of file mbfl_convert.c.

{
       filter->status = 0;
       filter->cache = 0;
}

Here is the caller graph for this function:

MBFLAPI int mbfl_filt_conv_common_flush ( mbfl_convert_filter *  filter)

Definition at line 568 of file mbfl_convert.c.

{
       filter->status = 0;
       filter->cache = 0;

       if (filter->flush_function != NULL) {
              (*filter->flush_function)(filter->data);
       }
       return 0;
}
MBFLAPI int mbfl_filt_conv_illegal_output ( int  c,
mbfl_convert_filter *  filter 
)

Definition at line 432 of file mbfl_convert.c.

{
       int mode_backup, ret, n, m, r;

       ret = 0;
       mode_backup = filter->illegal_mode;
       filter->illegal_mode = MBFL_OUTPUTFILTER_ILLEGAL_MODE_NONE;
       switch (mode_backup) {
       case MBFL_OUTPUTFILTER_ILLEGAL_MODE_CHAR:
              ret = (*filter->filter_function)(filter->illegal_substchar, filter);
              break;
       case MBFL_OUTPUTFILTER_ILLEGAL_MODE_LONG:
              if (c >= 0) {
                     if (c < MBFL_WCSGROUP_UCS4MAX) {   /* unicode */
                            ret = mbfl_convert_filter_strcat(filter, (const unsigned char *)"U+");
                     } else {
                            if (c < MBFL_WCSGROUP_WCHARMAX) {
                                   m = c & ~MBFL_WCSPLANE_MASK;
                                   switch (m) {
                                   case MBFL_WCSPLANE_JIS0208:
                                          ret = mbfl_convert_filter_strcat(filter, (const unsigned char *)"JIS+");
                                          break;
                                   case MBFL_WCSPLANE_JIS0212:
                                          ret = mbfl_convert_filter_strcat(filter, (const unsigned char *)"JIS2+");
                                          break;
                                   case MBFL_WCSPLANE_WINCP932:
                                          ret = mbfl_convert_filter_strcat(filter, (const unsigned char *)"W932+");
                                          break;
                                   case MBFL_WCSPLANE_8859_1:
                                          ret = mbfl_convert_filter_strcat(filter, (const unsigned char *)"I8859_1+");
                                          break;
                                   default:
                                          ret = mbfl_convert_filter_strcat(filter, (const unsigned char *)"?+");
                                          break;
                                   }
                                   c &= MBFL_WCSPLANE_MASK;
                            } else {
                                   ret = mbfl_convert_filter_strcat(filter, (const unsigned char *)"BAD+");
                                   c &= MBFL_WCSGROUP_MASK;
                            }
                     }
                     if (ret >= 0) {
                            m = 0;
                            r = 28;
                            while (r >= 0) {
                                   n = (c >> r) & 0xf;
                                   if (n || m) {
                                          m = 1;
                                          ret = (*filter->filter_function)(mbfl_hexchar_table[n], filter);
                                          if (ret < 0) {
                                                 break;
                                          }
                                   }
                                   r -= 4;
                            }
                            if (m == 0 && ret >= 0) {
                                   ret = (*filter->filter_function)(mbfl_hexchar_table[0], filter);
                            }
                     }
              }
              break;
       case MBFL_OUTPUTFILTER_ILLEGAL_MODE_ENTITY:
              if (c >= 0) {
                     if (c < MBFL_WCSGROUP_UCS4MAX) {   /* unicode */
                            ret = mbfl_convert_filter_strcat(filter, (const unsigned char *)"&#x");
                            if (ret < 0)
                                   break;

                            m = 0;
                            r = 28;
                            while (r >= 0) {
                                   n = (c >> r) & 0xf;
                                   if (n || m) {
                                          m = 1;
                                          ret = (*filter->filter_function)(mbfl_hexchar_table[n], filter);
                                          if (ret < 0) {
                                                 break;
                                          }
                                   }
                                   r -= 4;
                            }
                            if (ret < 0) {
                                   break;
                            }
                            if (m == 0) {
                                   ret = (*filter->filter_function)(mbfl_hexchar_table[0], filter);
                            }
                            ret = mbfl_convert_filter_strcat(filter, (const unsigned char *)";");
                     } else {
                            ret = (*filter->filter_function)(filter->illegal_substchar, filter);
                     }
              }
              break;
       default:
              break;
       }
       filter->illegal_mode = mode_backup;
       filter->num_illegalchar++;

       return ret;
}

Here is the call graph for this function:


Variable Documentation

Definition at line 105 of file mbfl_convert.c.