NCBI C++ ToolKit
iconv.h
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* FreeTDS - Library of routines accessing Sybase and Microsoft databases
2  * Copyright (C) 2002, 2003, 2004 Brian Bruns
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19 
20 #ifndef _tds_iconv_h_
21 #define _tds_iconv_h_
22 
23 #if HAVE_ICONV
24 #include <iconv.h>
25 #else
26 /* Define iconv_t for src/replacements/iconv.c. */
27 #undef iconv_t
28 typedef void *iconv_t;
29 #endif /* HAVE_ICONV */
30 
31 #if HAVE_ERRNO_H
32 #include <errno.h>
33 #endif
34 
35 #if HAVE_WCHAR_H
36 #include <wchar.h>
37 #endif
38 
39 /* The following EILSEQ advice is borrowed verbatim from GNU iconv. */
40 /* Some systems, like SunOS 4, don't have EILSEQ. Some systems, like BSD/OS,
41  have EILSEQ in a different header. On these systems, define EILSEQ
42  ourselves. */
43 #ifndef EILSEQ
44 # define EILSEQ ENOENT
45 #endif
46 
47 #if HAVE_STDLIB_H
48 #include <stdlib.h>
49 #endif /* HAVE_STDLIB_H */
50 
51 #include <freetds/pushvis.h>
52 
53 #ifdef __cplusplus
54 extern "C"
55 {
56 #endif
57 
58 #if ! HAVE_ICONV
59 iconv_t tds_sys_iconv_open(const char *tocode, const char *fromcode);
60 size_t tds_sys_iconv(iconv_t cd, const char **inbuf, size_t * inbytesleft, char **outbuf, size_t * outbytesleft);
62 #else
63 #define tds_sys_iconv_open iconv_open
64 #define tds_sys_iconv iconv
65 #define tds_sys_iconv_close iconv_close
66 #endif /* !HAVE_ICONV */
67 
68 
69 typedef enum
71 
72 typedef struct _character_set_alias
73 {
74  const char *alias;
75  int canonic;
77 
78 typedef struct tds_errno_message_flags {
79  unsigned int e2big:1;
80  unsigned int eilseq:1;
81  unsigned int einval:1;
83 
84 typedef struct tdsiconvdir
85 {
87 
90 
92 {
93  struct tdsiconvdir to, from;
94 
95 #define TDS_ENCODING_MEMCPY 1
96  unsigned int flags;
97 
98  /*
99  * Suppress error messages that would otherwise be emitted by tds_iconv().
100  * Functions that process large buffers ask tds_iconv to convert it in "chunks".
101  * We don't want to emit spurious EILSEQ errors or multiple errors for one
102  * buffer. tds_iconv() checks this structure before emiting a message, and
103  * adds to it whenever it emits one. Callers that handle a particular situation themselves
104  * can prepopulate it.
105  */
107 
108 };
109 
110 /* We use ICONV_CONST for tds_iconv(), even if we don't have iconv() */
111 #ifndef ICONV_CONST
112 # define ICONV_CONST const
113 #endif
114 
115 size_t tds_iconv(TDSSOCKET * tds, TDSICONV * char_conv, TDS_ICONV_DIRECTION io,
116  const char **inbuf, size_t * inbytesleft, char **outbuf, size_t * outbytesleft);
117 const char *tds_canonical_charset_name(const char *charset_name);
118 TDSICONV *tds_iconv_get(TDSCONNECTION * conn, const char *client_charset, const char *server_charset);
119 
120 #ifdef __cplusplus
121 }
122 #endif
123 
124 #include <freetds/popvis.h>
125 
126 #endif /* _tds_iconv_h_ */
static CS_CONNECTION * conn
Definition: ct_dynamic.c:25
TDS_ICONV_DIRECTION
Definition: iconv.h:70
@ to_client
Definition: iconv.h:70
@ to_server
Definition: iconv.h:70
struct tdsiconvdir TDSICONVDIR
struct _character_set_alias CHARACTER_SET_ALIAS
void * iconv_t
Definition: iconv.h:28
struct tds_errno_message_flags TDS_ERRNO_MESSAGE_FLAGS
static TDSSOCKET * tds
Definition: collations.c:37
const char * tds_canonical_charset_name(const char *charset_name)
Determine canonical iconv character set name.
Definition: iconv.c:993
size_t tds_sys_iconv(iconv_t cd, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft)
Definition: iconv.c:406
size_t tds_iconv(TDSSOCKET *tds, TDSICONV *char_conv, TDS_ICONV_DIRECTION io, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft)
Wrapper around iconv(3).
Definition: iconv.c:600
iconv_t tds_sys_iconv_open(const char *tocode, const char *fromcode)
Inputs are FreeTDS canonical names, no other.
Definition: iconv.c:345
TDSICONV * tds_iconv_get(TDSCONNECTION *conn, const char *client_charset, const char *server_charset)
Definition: iconv.c:812
int tds_sys_iconv_close(iconv_t cd)
Definition: iconv.c:400
const char * alias
Definition: iconv.h:74
Information relevant to libiconv.
Definition: tds.h:683
unsigned int einval
Definition: iconv.h:81
unsigned int eilseq
Definition: iconv.h:80
unsigned int e2big
Definition: iconv.h:79
Information for a server connection.
Definition: tds.h:1211
TDS_ENCODING charset
Definition: iconv.h:86
iconv_t cd
Definition: iconv.h:88
unsigned int flags
Definition: iconv.h:96
struct tdsiconvdir to from
Definition: iconv.h:93
TDS_ERRNO_MESSAGE_FLAGS suppress
Definition: iconv.h:106
uchar inbuf[1000000]
Definition: unzcrash.c:40
uchar outbuf[(1000000+1000000)]
Definition: unzcrash.c:41
Modified on Fri Sep 20 14:57:07 2024 by modify_doxy.py rev. 669887