00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef _tds_iconv_h_
00021 #define _tds_iconv_h_
00022
00023
00024
00025 #if HAVE_ICONV
00026 #include <iconv.h>
00027 #else
00028
00029 #undef iconv_t
00030 typedef void *iconv_t;
00031 #endif
00032
00033 #if HAVE_ERRNO_H
00034 #include <errno.h>
00035 #endif
00036
00037 #if HAVE_WCHAR_H
00038 #include <wchar.h>
00039 #endif
00040
00041
00042
00043
00044
00045 #ifndef EILSEQ
00046 # define EILSEQ ENOENT
00047 #endif
00048
00049 #if HAVE_STDLIB_H
00050 #include <stdlib.h>
00051 #endif
00052
00053 #if defined(__GNUC__) && __GNUC__ >= 4
00054 #pragma GCC visibility push(hidden)
00055 #endif
00056
00057 #ifdef __cplusplus
00058 extern "C"
00059 {
00060 #endif
00061
00062 #if ! HAVE_ICONV
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073 enum ICONV_CD_VALUE
00074 {
00075 Like_to_Like = 0x100
00076 , Latin1_ASCII = 0x01
00077 , ASCII_Latin1 = 0x10
00078
00079 , Latin1_UCS2LE = 0x02
00080 , UCS2LE_Latin1 = 0x20
00081 , ASCII_UCS2LE = 0x12
00082 , UCS2LE_ASCII = 0x21
00083
00084 , Latin1_UTF8 = 0x03
00085 , UTF8_Latin1 = 0x30
00086 , ASCII_UTF8 = 0x13
00087 , UTF8_ASCII = 0x31
00088 , UCS2LE_UTF8 = 0x23
00089 , UTF8_UCS2LE = 0x32
00090
00091 #ifdef DOS32X
00092 , WinEE_UCS2LE = 0x42
00093 , UCS2LE_WinEE = 0x24
00094 , WinCYR_UCS2LE = 0x52
00095 , UCS2LE_WinCYR = 0x25
00096 , WinTUR_UCS2LE = 0x62
00097 , UCS2LE_WinTUR = 0x26
00098 , WinARA_UCS2LE = 0x72
00099 , UCS2LE_WinARA = 0x27
00100 #endif
00101
00102
00103
00104
00105 };
00106
00107 iconv_t tds_sys_iconv_open(const char *tocode, const char *fromcode);
00108 size_t tds_sys_iconv(iconv_t cd, const char **inbuf, size_t * inbytesleft, char **outbuf, size_t * outbytesleft);
00109 int tds_sys_iconv_close(iconv_t cd);
00110 #else
00111 #define tds_sys_iconv_open iconv_open
00112 #define tds_sys_iconv iconv
00113 #define tds_sys_iconv_close iconv_close
00114 #endif
00115
00116
00117 typedef enum
00118 { to_server, to_client } TDS_ICONV_DIRECTION;
00119
00120 typedef struct _character_set_alias
00121 {
00122 const char *alias;
00123 int canonic;
00124 } CHARACTER_SET_ALIAS;
00125
00126 typedef struct _tds_errno_message_flags {
00127 unsigned int e2big:1;
00128 unsigned int eilseq:1;
00129 unsigned int einval:1;
00130 } TDS_ERRNO_MESSAGE_FLAGS;
00131
00132 struct tdsiconvinfo
00133 {
00134 TDS_ENCODING client_charset;
00135 TDS_ENCODING server_charset;
00136
00137 #define TDS_ENCODING_INDIRECT 1
00138 #define TDS_ENCODING_SWAPBYTE 2
00139 #define TDS_ENCODING_MEMCPY 4
00140 unsigned int flags;
00141
00142 iconv_t to_wire;
00143 iconv_t from_wire;
00144
00145 iconv_t to_wire2;
00146 iconv_t from_wire2;
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156 TDS_ERRNO_MESSAGE_FLAGS suppress;
00157 };
00158
00159
00160 #ifndef ICONV_CONST
00161 # define ICONV_CONST const
00162 #endif
00163
00164 size_t tds_iconv_fread(iconv_t cd, FILE * stream, size_t field_len, size_t term_len, char *outbuf, size_t * outbytesleft);
00165 size_t tds_iconv(TDSSOCKET * tds, const TDSICONV * char_conv, TDS_ICONV_DIRECTION io,
00166 const char **inbuf, size_t * inbytesleft, char **outbuf, size_t * outbytesleft);
00167 const char *tds_canonical_charset_name(const char *charset_name);
00168 const char *tds_sybase_charset_name(const char *charset_name);
00169
00170 #ifdef __cplusplus
00171 }
00172 #endif
00173
00174 #if defined(__GNUC__) && __GNUC__ >= 4
00175 #pragma GCC visibility pop
00176 #endif
00177
00178 #endif