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 && !defined(__MINGW32__)
00054 #pragma GCC visibility push(hidden)
00055 #endif
00056
00057 #ifdef __cplusplus
00058 extern "C"
00059 {
00060 #endif
00061
00062 #if ! HAVE_ICONV
00063 iconv_t tds_sys_iconv_open(const char *tocode, const char *fromcode);
00064 size_t tds_sys_iconv(iconv_t cd, const char **inbuf, size_t * inbytesleft, char **outbuf, size_t * outbytesleft);
00065 int tds_sys_iconv_close(iconv_t cd);
00066 #else
00067 #define tds_sys_iconv_open iconv_open
00068 #define tds_sys_iconv iconv
00069 #define tds_sys_iconv_close iconv_close
00070 #endif
00071
00072
00073 typedef enum
00074 { to_server, to_client } TDS_ICONV_DIRECTION;
00075
00076 typedef struct _character_set_alias
00077 {
00078 const char *alias;
00079 int canonic;
00080 } CHARACTER_SET_ALIAS;
00081
00082 typedef struct tds_errno_message_flags {
00083 unsigned int e2big:1;
00084 unsigned int eilseq:1;
00085 unsigned int einval:1;
00086 } TDS_ERRNO_MESSAGE_FLAGS;
00087
00088 struct tdsiconvinfo
00089 {
00090 TDS_ENCODING client_charset;
00091 TDS_ENCODING server_charset;
00092
00093 #define TDS_ENCODING_INDIRECT 1
00094 #define TDS_ENCODING_SWAPBYTE 2
00095 #define TDS_ENCODING_MEMCPY 4
00096 unsigned int flags;
00097
00098 iconv_t to_wire;
00099 iconv_t from_wire;
00100
00101 iconv_t to_wire2;
00102 iconv_t from_wire2;
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112 TDS_ERRNO_MESSAGE_FLAGS suppress;
00113 };
00114
00115
00116 #ifndef ICONV_CONST
00117 # define ICONV_CONST const
00118 #endif
00119
00120 size_t tds_iconv_fread(iconv_t cd, FILE * stream, size_t field_len, size_t term_len, char *outbuf, size_t * outbytesleft);
00121 size_t tds_iconv(TDSSOCKET * tds, const TDSICONV * char_conv, TDS_ICONV_DIRECTION io,
00122 const char **inbuf, size_t * inbytesleft, char **outbuf, size_t * outbytesleft);
00123 const char *tds_canonical_charset_name(const char *charset_name);
00124 const char *tds_sybase_charset_name(const char *charset_name);
00125 TDSICONV *tds_iconv_get(TDSSOCKET * tds, const char *client_charset, const char *server_charset);
00126
00127 #ifdef __cplusplus
00128 }
00129 #endif
00130
00131 #if defined(__GNUC__) && __GNUC__ >= 4 && !defined(__MINGW32__)
00132 #pragma GCC visibility pop
00133 #endif
00134
00135 #endif