summaryrefslogtreecommitdiffstats
path: root/Modules/cjkcodecs/multibytecodec.h
diff options
context:
space:
mode:
authorHye-Shik Chang <hyeshik@gmail.com>2004-07-18 03:06:29 (GMT)
committerHye-Shik Chang <hyeshik@gmail.com>2004-07-18 03:06:29 (GMT)
commit2bb146f2f4fd52b03cfa7ae739adb35d2b9f5421 (patch)
treeebd4c873cfc841dc978053941b2859d4efbd9082 /Modules/cjkcodecs/multibytecodec.h
parent264c659197bcd2fc3e22776fc711f31b953daae5 (diff)
downloadcpython-2bb146f2f4fd52b03cfa7ae739adb35d2b9f5421.zip
cpython-2bb146f2f4fd52b03cfa7ae739adb35d2b9f5421.tar.gz
cpython-2bb146f2f4fd52b03cfa7ae739adb35d2b9f5421.tar.bz2
Bring CJKCodecs 1.1 into trunk. This completely reorganizes source
and installed layouts to make maintenance simple and easy. And it also adds four new codecs; big5hkscs, euc-jis-2004, shift-jis-2004 and iso2022-jp-2004.
Diffstat (limited to 'Modules/cjkcodecs/multibytecodec.h')
-rw-r--r--Modules/cjkcodecs/multibytecodec.h116
1 files changed, 67 insertions, 49 deletions
diff --git a/Modules/cjkcodecs/multibytecodec.h b/Modules/cjkcodecs/multibytecodec.h
index 9cc1c6b..9435e0c 100644
--- a/Modules/cjkcodecs/multibytecodec.h
+++ b/Modules/cjkcodecs/multibytecodec.h
@@ -2,7 +2,7 @@
* multibytecodec.h: Common Multibyte Codec Implementation
*
* Written by Hye-Shik Chang <perky@FreeBSD.org>
- * $CJKCodecs: multibytecodec.h,v 1.2 2003/12/31 05:46:55 perky Exp $
+ * $CJKCodecs: multibytecodec.h,v 1.7 2004/06/27 10:39:28 perky Exp $
*/
#ifndef _PYTHON_MULTIBYTECODEC_H_
@@ -11,76 +11,94 @@
extern "C" {
#endif
-#include "cjkcommon.h"
+#ifdef uint32_t
+typedef uint32_t ucs4_t;
+#else
+typedef unsigned int ucs4_t;
+#endif
+
+#ifdef uint16_t
+typedef uint16_t ucs2_t, DBCHAR;
+#else
+typedef unsigned short ucs2_t, DBCHAR;
+#endif
typedef union {
- void *p;
- int i;
- unsigned char c[8];
- ucs2_t u2[4];
- ucs4_t u4[2];
+ void *p;
+ int i;
+ unsigned char c[8];
+ ucs2_t u2[4];
+ ucs4_t u4[2];
} MultibyteCodec_State;
-typedef int (*mbencode_func)(MultibyteCodec_State *state,
- const Py_UNICODE **inbuf, size_t inleft,
- unsigned char **outbuf, size_t outleft,
- int flags);
-typedef int (*mbencodeinit_func)(MultibyteCodec_State *state);
+typedef int (*mbcodec_init)(const void *config);
+typedef int (*mbencode_func)(MultibyteCodec_State *state, const void *config,
+ const Py_UNICODE **inbuf, size_t inleft,
+ unsigned char **outbuf, size_t outleft,
+ int flags);
+typedef int (*mbencodeinit_func)(MultibyteCodec_State *state,
+ const void *config);
typedef int (*mbencodereset_func)(MultibyteCodec_State *state,
- unsigned char **outbuf, size_t outleft);
+ const void *config,
+ unsigned char **outbuf, size_t outleft);
typedef int (*mbdecode_func)(MultibyteCodec_State *state,
- const unsigned char **inbuf, size_t inleft,
- Py_UNICODE **outbuf, size_t outleft);
-typedef int (*mbdecodeinit_func)(MultibyteCodec_State *state);
-typedef int (*mbdecodereset_func)(MultibyteCodec_State *state);
+ const void *config,
+ const unsigned char **inbuf, size_t inleft,
+ Py_UNICODE **outbuf, size_t outleft);
+typedef int (*mbdecodeinit_func)(MultibyteCodec_State *state,
+ const void *config);
+typedef int (*mbdecodereset_func)(MultibyteCodec_State *state,
+ const void *config);
typedef struct {
- const char *encoding;
- mbencode_func encode;
- mbencodeinit_func encinit;
- mbencodereset_func encreset;
- mbdecode_func decode;
- mbdecodeinit_func decinit;
- mbdecodereset_func decreset;
+ const char *encoding;
+ const void *config;
+ mbcodec_init codecinit;
+ mbencode_func encode;
+ mbencodeinit_func encinit;
+ mbencodereset_func encreset;
+ mbdecode_func decode;
+ mbdecodeinit_func decinit;
+ mbdecodereset_func decreset;
} MultibyteCodec;
typedef struct {
- PyObject_HEAD
- MultibyteCodec *codec;
+ PyObject_HEAD
+ MultibyteCodec *codec;
} MultibyteCodecObject;
-#define MAXDECPENDING 8
+#define MAXDECPENDING 8
typedef struct {
- PyObject_HEAD
- MultibyteCodec *codec;
- MultibyteCodec_State state;
- unsigned char pending[MAXDECPENDING];
- int pendingsize;
- PyObject *stream, *errors;
+ PyObject_HEAD
+ MultibyteCodec *codec;
+ MultibyteCodec_State state;
+ unsigned char pending[MAXDECPENDING];
+ int pendingsize;
+ PyObject *stream, *errors;
} MultibyteStreamReaderObject;
-#define MAXENCPENDING 2
+#define MAXENCPENDING 2
typedef struct {
- PyObject_HEAD
- MultibyteCodec *codec;
- MultibyteCodec_State state;
- Py_UNICODE pending[MAXENCPENDING];
- int pendingsize;
- PyObject *stream, *errors;
+ PyObject_HEAD
+ MultibyteCodec *codec;
+ MultibyteCodec_State state;
+ Py_UNICODE pending[MAXENCPENDING];
+ int pendingsize;
+ PyObject *stream, *errors;
} MultibyteStreamWriterObject;
/* positive values for illegal sequences */
-#define MBERR_TOOSMALL (-1) /* insufficient output buffer space */
-#define MBERR_TOOFEW (-2) /* incomplete input buffer */
-#define MBERR_INTERNAL (-3) /* internal runtime error */
+#define MBERR_TOOSMALL (-1) /* insufficient output buffer space */
+#define MBERR_TOOFEW (-2) /* incomplete input buffer */
+#define MBERR_INTERNAL (-3) /* internal runtime error */
-#define ERROR_STRICT (PyObject *)(1)
-#define ERROR_IGNORE (PyObject *)(2)
-#define ERROR_REPLACE (PyObject *)(3)
-#define ERROR_MAX ERROR_REPLACE
+#define ERROR_STRICT (PyObject *)(1)
+#define ERROR_IGNORE (PyObject *)(2)
+#define ERROR_REPLACE (PyObject *)(3)
+#define ERROR_MAX ERROR_REPLACE
-#define MBENC_FLUSH 0x0001 /* encode all characters encodable */
-#define MBENC_MAX MBENC_FLUSH
+#define MBENC_FLUSH 0x0001 /* encode all characters encodable */
+#define MBENC_MAX MBENC_FLUSH
#ifdef __cplusplus
}