+++ /dev/null
-/*\r
- * internal.h - internal header stuff for the charset library.\r
- */\r
-\r
-#ifndef charset_internal_h\r
-#define charset_internal_h\r
-\r
-/* This invariably comes in handy */\r
-#define lenof(x) ( sizeof((x)) / sizeof(*(x)) )\r
-\r
-/* This is an invalid Unicode value used to indicate an error. */\r
-#define ERROR 0xFFFFL /* Unicode value representing error */\r
-\r
-typedef struct charset_spec charset_spec;\r
-typedef struct sbcs_data sbcs_data;\r
-\r
-struct charset_spec {\r
- int charset; /* numeric identifier */\r
-\r
- /*\r
- * A function to read the character set and output Unicode\r
- * characters. The `emit' function expects to get Unicode chars\r
- * passed to it; it should be sent ERROR for any encoding error\r
- * on the input.\r
- */\r
- void (*read)(charset_spec const *charset, long int input_chr,\r
- charset_state *state,\r
- void (*emit)(void *ctx, long int output), void *emitctx);\r
- /*\r
- * A function to read Unicode characters and output in this\r
- * character set. The `emit' function expects to get byte\r
- * values passed to it; it should be sent ERROR for any\r
- * non-representable characters on the input.\r
- */\r
- void (*write)(charset_spec const *charset, long int input_chr,\r
- charset_state *state,\r
- void (*emit)(void *ctx, long int output), void *emitctx);\r
- void const *data;\r
-};\r
-\r
-/*\r
- * This is the format of `data' used by the SBCS read and write\r
- * functions; so it's the format used in all SBCS definitions.\r
- */\r
-struct sbcs_data {\r
- /*\r
- * This is a simple mapping table converting each SBCS position\r
- * to a Unicode code point. Some positions may contain ERROR,\r
- * indicating that that byte value is not defined in the SBCS\r
- * in question and its occurrence in input is an error.\r
- */\r
- unsigned long sbcs2ucs[256];\r
-\r
- /*\r
- * This lookup table is used to convert Unicode back to the\r
- * SBCS. It consists of the valid byte values in the SBCS,\r
- * sorted in order of their Unicode translation. So given a\r
- * Unicode value U, you can do a binary search on this table\r
- * using the above table as a lookup: when testing the Xth\r
- * position in this table, you branch according to whether\r
- * sbcs2ucs[ucs2sbcs[X]] is less than, greater than, or equal\r
- * to U.\r
- * \r
- * Note that since there may be fewer than 256 valid byte\r
- * values in a particular SBCS, we must supply the length of\r
- * this table as well as the contents.\r
- */\r
- unsigned char ucs2sbcs[256];\r
- int nvalid;\r
-};\r
-\r
-/*\r
- * Prototypes for internal library functions.\r
- */\r
-charset_spec const *charset_find_spec(int charset);\r
-void read_sbcs(charset_spec const *charset, long int input_chr,\r
- charset_state *state,\r
- void (*emit)(void *ctx, long int output), void *emitctx);\r
-void write_sbcs(charset_spec const *charset, long int input_chr,\r
- charset_state *state,\r
- void (*emit)(void *ctx, long int output), void *emitctx);\r
-\r
-/*\r
- * Placate compiler warning about unused parameters, of which we\r
- * expect to have some in this library.\r
- */\r
-#define UNUSEDARG(x) ( (x) = (x) )\r
-\r
-#endif /* charset_internal_h */\r