FreeTDS API: include/freetds/iconv.h Source File

FreeTDS API

- Main Page
- Related Pages
- Modules
- Classes
- Files

- File List
- File Members

All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
iconv.h
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 /* $Id: tdsiconv.h,v 1.40 2010-07-25 08:40:19 freddy77 Exp $ */
24
25 #if HAVE_ICONV
26 #include <iconv.h>
27 #else
28 /* Define iconv_t for src/replacements/iconv.c. */
29 #undef iconv_t
30 typedef void *iconv_t;
31 #endif /* HAVE_ICONV */
32
33 #if HAVE_ERRNO_H
34 #include <errno.h>
35 #endif
36
37 #if HAVE_WCHAR_H
38 #include <wchar.h>
39 #endif
40
41 /* The following EILSEQ advice is borrowed verbatim from GNU iconv. */
42 /* Some systems, like SunOS 4, don't have EILSEQ. Some systems, like BSD/OS,
43 have EILSEQ in a different header. On these systems, define EILSEQ
44 ourselves. */
45 #ifndef EILSEQ
46 # define EILSEQ ENOENT
47 #endif
48
49 #if HAVE_STDLIB_H
50 #include <stdlib.h>
51 #endif /* HAVE_STDLIB_H */
52
53 #include <freetds/pushvis.h>
54
55 #ifdef __cplusplus
56 extern "C"
57 {
58 #endif
59
60 #if ! HAVE_ICONV
61 iconv_t tds_sys_iconv_open(const char *tocode, const char *fromcode);
62 size_t tds_sys_iconv(iconv_t cd, const char **inbuf, size_t * inbytesleft, char **outbuf, size_t * outbytesleft);
63 int tds_sys_iconv_close(iconv_t cd);
64 #else
65 #define tds_sys_iconv_open iconv_open
66 #define tds_sys_iconv iconv
67 #define tds_sys_iconv_close iconv_close
68 #endif /* !HAVE_ICONV */
69
70
71 typedef enum
72 { to_server, to_client } TDS_ICONV_DIRECTION;
73
74 typedef struct _character_set_alias
75 {
76 const char *alias;
77 int canonic;
78 } CHARACTER_SET_ALIAS;
79
80 typedef struct tds_errno_message_flags {
81 unsigned int e2big:1;
82 unsigned int eilseq:1;
83 unsigned int einval:1;
84 } TDS_ERRNO_MESSAGE_FLAGS;
85
86 typedef struct tdsiconvdir
87 {
88 TDS_ENCODING charset;
89
90 iconv_t cd;
91 } TDSICONVDIR;
92
93 struct tdsiconvinfo
94 {
95 struct tdsiconvdir to, from;
96
97 #define TDS_ENCODING_MEMCPY 1
98 unsigned int flags;
99
100 /*
101 * Suppress error messages that would otherwise be emitted by tds_iconv().
102 * Functions that process large buffers ask tds_iconv to convert it in "chunks".
103 * We don't want to emit spurious EILSEQ errors or multiple errors for one
104 * buffer. tds_iconv() checks this structure before emiting a message, and
105 * adds to it whenever it emits one. Callers that handle a particular situation themselves
106 * can prepopulate it.
107 */
108 TDS_ERRNO_MESSAGE_FLAGS suppress;
109
110 };
111
112 /* We use ICONV_CONST for tds_iconv(), even if we don't have iconv() */
113 #ifndef ICONV_CONST
114 # define ICONV_CONST const
115 #endif
116
117 size_t tds_iconv(TDSSOCKET * tds, TDSICONV * char_conv, TDS_ICONV_DIRECTION io,
118 const char **inbuf, size_t * inbytesleft, char **outbuf, size_t * outbytesleft);
119 const char *tds_canonical_charset_name(const char *charset_name);
120 TDSICONV *tds_iconv_get(TDSCONNECTION * conn, const char *client_charset, const char *server_charset);
121
122 #ifdef __cplusplus
123 }
124 #endif
125
126 #include <freetds/popvis.h>
127
128 #endif /* _tds_iconv_h_ */
tds_errno_message_flags
Definition: iconv.h:80
_character_set_alias
Definition: iconv.h:74
tds_canonical_charset_name
const char * tds_canonical_charset_name(const char *charset_name)
Determine canonical iconv character set name.
Definition: iconv.c:975
tdsiconvinfo
Definition: iconv.h:93
tds_encoding
Information relevant to libiconv.
Definition: tds.h:611
tds_iconv
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:562
tds_connection
Definition: tds.h:1031
tdsiconvdir
Definition: iconv.h:86
tds_sys_iconv_open
iconv_t tds_sys_iconv_open(const char *tocode, const char *fromcode)
Inputs are FreeTDS canonical names, no other.
Definition: iconv.c:333
tds_socket
Information for a server connection.
Definition: tds.h:1098