#include "define.h"
Go to the source code of this file.
Defines | |
#define | ASSERT(x,...) { if( !(x) ) DIE(( __VA_ARGS__)); } |
Functions | |
static void | pst_vbresize (pst_vbuf *vb, size_t len) |
DESTRUCTIVELY grow or shrink buffer. | |
static size_t | pst_vbavail (pst_vbuf *vb) |
static void | open_targets (const char *charset) |
static size_t | sbcs_conversion (pst_vbuf *dest, const char *inbuf, int iblen, iconv_t conversion) |
static void | pst_unicode_close () |
static int | utf16_is_terminated (const char *str, int length) |
pst_vbuf * | pst_vballoc (size_t len) |
void | pst_vbgrow (pst_vbuf *vb, size_t len) |
out: vbavail(vb) >= len, data are preserved | |
void | pst_vbset (pst_vbuf *vb, void *b, size_t len) |
set vbuf b size=len, resize if necessary, relen = how much to over-allocate | |
void | pst_vbappend (pst_vbuf *vb, void *b, size_t len) |
append len bytes of b to vb, resize if necessary | |
void | pst_unicode_init () |
size_t | pst_vb_utf16to8 (pst_vbuf *dest, const char *inbuf, int iblen) |
size_t | pst_vb_utf8to8bit (pst_vbuf *dest, const char *inbuf, int iblen, const char *charset) |
size_t | pst_vb_8bit2utf8 (pst_vbuf *dest, const char *inbuf, int iblen, const char *charset) |
Variables | |
static int | unicode_up = 0 |
static iconv_t | i16to8 |
static const char * | target_charset = NULL |
static int | target_open_from = 0 |
static int | target_open_to = 0 |
static iconv_t | i8totarget = (iconv_t)-1 |
static iconv_t | target2i8 = (iconv_t)-1 |
static void open_targets | ( | const char * | charset | ) | [static] |
Definition at line 42 of file vbuf.c.
References DEBUG_WARN, i8totarget, target2i8, target_charset, target_open_from, and target_open_to.
Referenced by pst_vb_8bit2utf8(), and pst_vb_utf8to8bit().
static void pst_unicode_close | ( | ) | [static] |
Definition at line 98 of file vbuf.c.
References i16to8, i8totarget, target2i8, target_charset, target_open_from, target_open_to, and unicode_up.
Referenced by pst_unicode_init().
void pst_unicode_init | ( | ) |
Definition at line 202 of file vbuf.c.
References DEBUG_WARN, i16to8, pst_unicode_close(), and unicode_up.
Referenced by pst_open(), pst_vb_utf16to8(), and sbcs_conversion().
size_t pst_vb_8bit2utf8 | ( | pst_vbuf * | dest, | |
const char * | inbuf, | |||
int | iblen, | |||
const char * | charset | |||
) |
Definition at line 254 of file vbuf.c.
References open_targets(), sbcs_conversion(), target2i8, and target_open_to.
Referenced by pst_convert_utf8().
size_t pst_vb_utf16to8 | ( | pst_vbuf * | dest, | |
const char * | inbuf, | |||
int | iblen | |||
) |
Definition at line 213 of file vbuf.c.
References pst_varbuf::b, pst_varbuf::blen, DEBUG_WARN, pst_varbuf::dlen, i16to8, ICONV_CONST, pst_unicode_init(), pst_vbgrow(), pst_vbresize(), unicode_up, and utf16_is_terminated().
Referenced by pst_parse_block().
size_t pst_vb_utf8to8bit | ( | pst_vbuf * | dest, | |
const char * | inbuf, | |||
int | iblen, | |||
const char * | charset | |||
) |
Definition at line 246 of file vbuf.c.
References i8totarget, open_targets(), sbcs_conversion(), and target_open_from.
Referenced by convert_8bit(), and write_body_part().
pst_vbuf* pst_vballoc | ( | size_t | len | ) |
Definition at line 130 of file vbuf.c.
References pst_varbuf::blen, pst_varbuf::buf, DIE, pst_varbuf::dlen, pst_malloc(), and pst_vbresize().
Referenced by convert_8bit(), pst_convert_utf8(), pst_parse_block(), and write_body_part().
void pst_vbappend | ( | pst_vbuf * | vb, | |
void * | b, | |||
size_t | len | |||
) |
append len bytes of b to vb, resize if necessary
Definition at line 190 of file vbuf.c.
References pst_varbuf::b, pst_varbuf::dlen, pst_vbgrow(), and pst_vbset().
Referenced by pst_parse_block().
static size_t pst_vbavail | ( | pst_vbuf * | vb | ) | [static] |
Definition at line 35 of file vbuf.c.
References pst_varbuf::b, pst_varbuf::blen, pst_varbuf::buf, and pst_varbuf::dlen.
Referenced by pst_vbgrow().
void pst_vbgrow | ( | pst_vbuf * | vb, | |
size_t | len | |||
) |
out: vbavail(vb) >= len, data are preserved
Definition at line 146 of file vbuf.c.
References ASSERT, pst_varbuf::b, pst_varbuf::blen, pst_varbuf::buf, DIE, pst_varbuf::dlen, pst_malloc(), pst_vbavail(), and pst_vbresize().
Referenced by convert_8bit(), pst_vb_utf16to8(), pst_vbappend(), sbcs_conversion(), and write_body_part().
static void pst_vbresize | ( | pst_vbuf * | vb, | |
size_t | len | |||
) | [static] |
DESTRUCTIVELY grow or shrink buffer.
Definition at line 19 of file vbuf.c.
References pst_varbuf::b, pst_varbuf::blen, pst_varbuf::buf, and pst_varbuf::dlen.
Referenced by pst_vb_utf16to8(), pst_vballoc(), pst_vbgrow(), pst_vbset(), and sbcs_conversion().
void pst_vbset | ( | pst_vbuf * | vb, | |
void * | b, | |||
size_t | len | |||
) |
set vbuf b size=len, resize if necessary, relen = how much to over-allocate
Definition at line 180 of file vbuf.c.
References pst_varbuf::b, pst_varbuf::dlen, and pst_vbresize().
Referenced by pst_parse_block(), and pst_vbappend().
static size_t sbcs_conversion | ( | pst_vbuf * | dest, | |
const char * | inbuf, | |||
int | iblen, | |||
iconv_t | conversion | |||
) | [static] |
Definition at line 66 of file vbuf.c.
References pst_varbuf::b, pst_varbuf::blen, DEBUG_ENT, DEBUG_RET, DEBUG_WARN, pst_varbuf::dlen, ICONV_CONST, pst_unicode_init(), pst_vbgrow(), and pst_vbresize().
Referenced by pst_vb_8bit2utf8(), and pst_vb_utf8to8bit().
static int utf16_is_terminated | ( | const char * | str, | |
int | length | |||
) | [static] |
iconv_t i16to8 [static] |
Definition at line 5 of file vbuf.c.
Referenced by pst_unicode_close(), pst_unicode_init(), and pst_vb_utf16to8().
iconv_t i8totarget = (iconv_t)-1 [static] |
Definition at line 9 of file vbuf.c.
Referenced by open_targets(), pst_unicode_close(), and pst_vb_utf8to8bit().
iconv_t target2i8 = (iconv_t)-1 [static] |
Definition at line 10 of file vbuf.c.
Referenced by open_targets(), pst_unicode_close(), and pst_vb_8bit2utf8().
const char* target_charset = NULL [static] |
Definition at line 6 of file vbuf.c.
Referenced by open_targets(), and pst_unicode_close().
int target_open_from = 0 [static] |
Definition at line 7 of file vbuf.c.
Referenced by open_targets(), pst_unicode_close(), and pst_vb_utf8to8bit().
int target_open_to = 0 [static] |
Definition at line 8 of file vbuf.c.
Referenced by open_targets(), pst_unicode_close(), and pst_vb_8bit2utf8().
int unicode_up = 0 [static] |
Definition at line 4 of file vbuf.c.
Referenced by pst_unicode_close(), pst_unicode_init(), and pst_vb_utf16to8().