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

- File List
- File Members

# include/tdsiconv.h

    00001 /* FreeTDS - Library of routines accessing Sybase and Microsoft databases
    00002  * Copyright (C) 2002, 2003, 2004  Brian Bruns
    00003  *
    00004  * This library is free software; you can redistribute it and/or
    00005  * modify it under the terms of the GNU Library General Public
    00006  * License as published by the Free Software Foundation; either
    00007  * version 2 of the License, or (at your option) any later version.
    00008  *
    00009  * This library is distributed in the hope that it will be useful,
    00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00012  * Library General Public License for more details.
    00013  *
    00014  * You should have received a copy of the GNU Library General Public
    00015  * License along with this library; if not, write to the
    00016  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    00017  * Boston, MA 02111-1307, USA.
    00018  */
    00019
    00020 #ifndef _tds_iconv_h_
    00021 #define _tds_iconv_h_
    00022
    00023 /* $Id: tdsiconv.h,v 1.40 2010-07-25 08:40:19 freddy77 Exp $ */
    00024
    00025 #if HAVE_ICONV
    00026 #include <iconv.h>
    00027 #else
    00028 /* Define iconv_t for src/replacements/iconv.c. */
    00029 #undef iconv_t
    00030 typedef void *iconv_t;
    00031 #endif /* HAVE_ICONV */
    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 /* The following EILSEQ advice is borrowed verbatim from GNU iconv.  */
    00042 /* Some systems, like SunOS 4, don't have EILSEQ. Some systems, like BSD/OS,
    00043    have EILSEQ in a different header.  On these systems, define EILSEQ
    00044    ourselves. */
    00045 #ifndef EILSEQ
    00046 # define EILSEQ ENOENT
    00047 #endif
    00048
    00049 #if HAVE_STDLIB_H
    00050 #include <stdlib.h>
    00051 #endif /* HAVE_STDLIB_H */
    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 /* !HAVE_ICONV */
    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 typedef struct tdsiconvdir
    00089 {
    00090         TDS_ENCODING charset;
    00091
    00092         iconv_t cd;
    00093         iconv_t cd2;
    00094
    00095         unsigned char num_got;
    00096         unsigned char num_left;
    00097         char left[6];
    00098 } TDSICONVDIR;
    00099
    00100 struct tdsiconvinfo
    00101 {
    00102         struct tdsiconvdir to, from;
    00103
    00104 #define TDS_ENCODING_INDIRECT 1
    00105 #define TDS_ENCODING_SWAPBYTE 2
    00106 #define TDS_ENCODING_MEMCPY   4
    00107         unsigned int flags;
    00108
    00109         /*
    00110          * Suppress error messages that would otherwise be emitted by tds_iconv().
    00111          * Functions that process large buffers ask tds_iconv to convert it in "chunks".
    00112          * We don't want to emit spurious EILSEQ errors or multiple errors for one
    00113          * buffer.  tds_iconv() checks this structure before emiting a message, and
    00114          * adds to it whenever it emits one.  Callers that handle a particular situation themselves
    00115          * can prepopulate it.
    00116          */
    00117         TDS_ERRNO_MESSAGE_FLAGS suppress;
    00118
    00119 };
    00120
    00121 /* We use ICONV_CONST for tds_iconv(), even if we don't have iconv() */
    00122 #ifndef ICONV_CONST
    00123 # define ICONV_CONST const
    00124 #endif
    00125
    00126 size_t tds_iconv_fread(TDSSOCKET * tds, TDSICONV * conv, FILE * stream, size_t field_len, size_t term_len, char *outbuf, size_t * outbytesleft);
    00127 size_t tds_iconv(TDSSOCKET * tds, TDSICONV * char_conv, TDS_ICONV_DIRECTION io,
    00128                  const char **inbuf, size_t * inbytesleft, char **outbuf, size_t * outbytesleft);
    00129 const char *tds_canonical_charset_name(const char *charset_name);
    00130 const char *tds_sybase_charset_name(const char *charset_name);
    00131 TDSICONV *tds_iconv_get(TDSSOCKET * tds, const char *client_charset, const char *server_charset);
    00132
    00133 #ifdef __cplusplus
    00134 }
    00135 #endif
    00136
    00137 #if defined(__GNUC__) && __GNUC__ >= 4 && !defined(__MINGW32__)
    00138 #pragma GCC visibility pop
    00139 #endif
    00140
    00141 #endif /* _tds_iconv_h_ */

All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines