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 static const char rcsid_tds_iconv_h[] = "$Id: tdsiconv.h,v 1.33 2004/10/28 12:42:12 freddy77 Exp $";
00024 static const void *const no_unused_tds_iconv_h_warn[] = { rcsid_tds_iconv_h, no_unused_tds_iconv_h_warn };
00025 
00026 #if HAVE_ICONV
00027 #include <iconv.h>
00028 #else
00029 
00030 #undef iconv_t
00031 typedef void *iconv_t;
00032 #endif 
00033 
00034 #if HAVE_ERRNO_H
00035 #include <errno.h>
00036 #endif
00037 
00038 #if HAVE_WCHAR_H
00039 #include <wchar.h>
00040 #endif
00041 
00042 
00043 
00044 
00045 
00046 #ifndef EILSEQ
00047 # define EILSEQ ENOENT
00048 #endif
00049 
00050 #if HAVE_STDLIB_H
00051 #include <stdlib.h>
00052 #endif 
00053 
00054 #ifdef __cplusplus
00055 extern "C"
00056 {
00057 #endif
00058 
00059 #if ! HAVE_ICONV
00060 
00061         
00062 
00063 
00064 
00065 
00066 
00067 
00068 
00069 
00070 enum ICONV_CD_VALUE
00071 {
00072           Like_to_Like = 0x100
00073         , Latin1_ASCII  = 0x01
00074         , ASCII_Latin1  = 0x10
00075 
00076         , Latin1_UCS2LE = 0x02
00077         , UCS2LE_Latin1 = 0x20
00078         , ASCII_UCS2LE  = 0x12
00079         , UCS2LE_ASCII  = 0x21
00080 
00081         , Latin1_UTF8   = 0x03
00082         , UTF8_Latin1   = 0x30
00083         , ASCII_UTF8    = 0x13
00084         , UTF8_ASCII    = 0x31
00085         , UCS2LE_UTF8   = 0x23
00086         , UTF8_UCS2LE   = 0x32
00087         
00088 
00089 
00090 
00091 };
00092 
00093 iconv_t tds_sys_iconv_open(const char *tocode, const char *fromcode);
00094 size_t tds_sys_iconv(iconv_t cd, const char **inbuf, size_t * inbytesleft, char **outbuf, size_t * outbytesleft);
00095 int tds_sys_iconv_close(iconv_t cd);
00096 #else
00097 #define tds_sys_iconv_open iconv_open
00098 #define tds_sys_iconv iconv
00099 #define tds_sys_iconv_close iconv_close
00100 #endif 
00101 
00102 
00103 typedef enum
00104 { to_server, to_client } TDS_ICONV_DIRECTION;
00105 
00106 typedef struct _character_set_alias
00107 {
00108         const char *alias;
00109         int canonic;
00110 } CHARACTER_SET_ALIAS;
00111 
00112 typedef struct _tds_errno_message_flags {
00113         unsigned int e2big:1;
00114         unsigned int eilseq:1;
00115         unsigned int einval:1;
00116 } TDS_ERRNO_MESSAGE_FLAGS;
00117 
00118 struct tdsiconvinfo
00119 {
00120         TDS_ENCODING client_charset;
00121         TDS_ENCODING server_charset;
00122 
00123 #define TDS_ENCODING_INDIRECT 1
00124 #define TDS_ENCODING_SWAPBYTE 2
00125 #define TDS_ENCODING_MEMCPY   4
00126         unsigned int flags;
00127 
00128         iconv_t to_wire;        
00129         iconv_t from_wire;      
00130 
00131         iconv_t to_wire2;       
00132         iconv_t from_wire2;     
00133         
00134         
00135 
00136 
00137 
00138 
00139 
00140 
00141  
00142         TDS_ERRNO_MESSAGE_FLAGS suppress;
00143 };
00144 
00145 
00146 #ifndef ICONV_CONST
00147 # define ICONV_CONST const
00148 #endif
00149 
00150 size_t tds_iconv_fread(iconv_t cd, FILE * stream, size_t field_len, size_t term_len, char *outbuf, size_t * outbytesleft);
00151 size_t tds_iconv(TDSSOCKET * tds, const TDSICONV * char_conv, TDS_ICONV_DIRECTION io,
00152                  const char **inbuf, size_t * inbytesleft, char **outbuf, size_t * outbytesleft);
00153 const char *tds_canonical_charset_name(const char *charset_name);
00154 const char *tds_sybase_charset_name(const char *charset_name);
00155 
00156 #ifdef __cplusplus
00157 }
00158 #endif
00159 
00160 #endif