<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> <title>FreeTDS API: /usr/local/users/home/jklowden/projects/releases/freetds/0.82/include/tdsiconv.h Source File</title> <link href="doxygen.css" rel="stylesheet" type="text/css"> </head><body> <!-- Generated by Doxygen 1.4.1 --> <div class="qindex"><a class="qindex" href="index.html">Main Page</a> | <a class="qindex" href="modules.html">Modules</a> | <a class="qindex" href="annotated.html">Class List</a> | <a class="qindex" href="dirs.html">Directories</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="functions.html">Class Members</a> | <a class="qindex" href="globals.html">File Members</a> | <a class="qindex" href="pages.html">Related Pages</a></div> <div class="nav"> <a class="el" href="dir_000000.html">include</a></div> <h1>tdsiconv.h</h1><div class="fragment"><pre class="fragment">00001 <span class="comment">/* FreeTDS - Library of routines accessing Sybase and Microsoft databases</span> 00002 <span class="comment"> * Copyright (C) 2002, 2003, 2004 Brian Bruns</span> 00003 <span class="comment"> *</span> 00004 <span class="comment"> * This library is free software; you can redistribute it and/or</span> 00005 <span class="comment"> * modify it under the terms of the GNU Library General Public</span> 00006 <span class="comment"> * License as published by the Free Software Foundation; either</span> 00007 <span class="comment"> * version 2 of the License, or (at your option) any later version.</span> 00008 <span class="comment"> *</span> 00009 <span class="comment"> * This library is distributed in the hope that it will be useful,</span> 00010 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span> 00011 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</span> 00012 <span class="comment"> * Library General Public License for more details.</span> 00013 <span class="comment"> *</span> 00014 <span class="comment"> * You should have received a copy of the GNU Library General Public</span> 00015 <span class="comment"> * License along with this library; if not, write to the</span> 00016 <span class="comment"> * Free Software Foundation, Inc., 59 Temple Place - Suite 330,</span> 00017 <span class="comment"> * Boston, MA 02111-1307, USA.</span> 00018 <span class="comment"> */</span> 00019 00020 <span class="preprocessor">#ifndef _tds_iconv_h_</span> 00021 <span class="preprocessor"></span><span class="preprocessor">#define _tds_iconv_h_</span> 00022 <span class="preprocessor"></span> 00023 <span class="comment">/* $Id: tdsiconv.h,v 1.36 2007/03/12 13:28:50 freddy77 Exp $ */</span> 00024 00025 <span class="preprocessor">#if HAVE_ICONV</span> 00026 <span class="preprocessor"></span><span class="preprocessor">#include <iconv.h></span> 00027 <span class="preprocessor">#else</span> 00028 <span class="preprocessor"></span><span class="comment">/* Define iconv_t for src/replacements/iconv.c. */</span> 00029 <span class="preprocessor">#undef iconv_t</span> 00030 <span class="preprocessor"></span><span class="keyword">typedef</span> <span class="keywordtype">void</span> *iconv_t; 00031 <span class="preprocessor">#endif </span><span class="comment">/* HAVE_ICONV */</span> 00032 00033 <span class="preprocessor">#if HAVE_ERRNO_H</span> 00034 <span class="preprocessor"></span><span class="preprocessor">#include <errno.h></span> 00035 <span class="preprocessor">#endif</span> 00036 <span class="preprocessor"></span> 00037 <span class="preprocessor">#if HAVE_WCHAR_H</span> 00038 <span class="preprocessor"></span><span class="preprocessor">#include <wchar.h></span> 00039 <span class="preprocessor">#endif</span> 00040 <span class="preprocessor"></span> 00041 <span class="comment">/* The following EILSEQ advice is borrowed verbatim from GNU iconv. */</span> 00042 <span class="comment">/* Some systems, like SunOS 4, don't have EILSEQ. Some systems, like BSD/OS,</span> 00043 <span class="comment"> have EILSEQ in a different header. On these systems, define EILSEQ</span> 00044 <span class="comment"> ourselves. */</span> 00045 <span class="preprocessor">#ifndef EILSEQ</span> 00046 <span class="preprocessor"></span><span class="preprocessor"># define EILSEQ ENOENT</span> 00047 <span class="preprocessor"></span><span class="preprocessor">#endif</span> 00048 <span class="preprocessor"></span> 00049 <span class="preprocessor">#if HAVE_STDLIB_H</span> 00050 <span class="preprocessor"></span><span class="preprocessor">#include <stdlib.h></span> 00051 <span class="preprocessor">#endif </span><span class="comment">/* HAVE_STDLIB_H */</span> 00052 00053 <span class="preprocessor">#if defined(__GNUC__) && __GNUC__ >= 4</span> 00054 <span class="preprocessor"></span><span class="preprocessor">#pragma GCC visibility push(hidden)</span> 00055 <span class="preprocessor"></span><span class="preprocessor">#endif</span> 00056 <span class="preprocessor"></span> 00057 <span class="preprocessor">#ifdef __cplusplus</span> 00058 <span class="preprocessor"></span><span class="keyword">extern</span> <span class="stringliteral">"C"</span> 00059 { 00060 <span class="preprocessor">#endif</span> 00061 <span class="preprocessor"></span> 00062 <span class="preprocessor">#if ! HAVE_ICONV</span> 00063 <span class="preprocessor"></span> 00064 <span class="comment">/* FYI, the first 4 entries look like this:</span> 00065 <span class="comment"> * {"ISO-8859-1", 1, 1}, -> 0</span> 00066 <span class="comment"> * {"US-ASCII", 1, 4}, -> 1</span> 00067 <span class="comment"> * {"UCS-2LE", 2, 2}, -> 2</span> 00068 <span class="comment"> * {"UCS-2BE", 2, 2}, -> 3</span> 00069 <span class="comment"> *</span> 00070 <span class="comment"> * These conversions are supplied by src/replacements/iconv.c for the sake of those who don't </span> 00071 <span class="comment"> * have or otherwise need an iconv.</span> 00072 <span class="comment"> */</span> 00073 <span class="keyword">enum</span> ICONV_CD_VALUE 00074 { 00075 Like_to_Like = 0x100 00076 , Latin1_ASCII = 0x01 00077 , ASCII_Latin1 = 0x10 00078 00079 , Latin1_UCS2LE = 0x02 00080 , UCS2LE_Latin1 = 0x20 00081 , ASCII_UCS2LE = 0x12 00082 , UCS2LE_ASCII = 0x21 00083 00084 , Latin1_UTF8 = 0x03 00085 , UTF8_Latin1 = 0x30 00086 , ASCII_UTF8 = 0x13 00087 , UTF8_ASCII = 0x31 00088 , UCS2LE_UTF8 = 0x23 00089 , UTF8_UCS2LE = 0x32 00090 00091 <span class="preprocessor">#ifdef DOS32X</span> 00092 <span class="preprocessor"></span> , WinEE_UCS2LE = 0x42 00093 , UCS2LE_WinEE = 0x24 00094 , WinCYR_UCS2LE = 0x52 00095 , UCS2LE_WinCYR = 0x25 00096 , WinTUR_UCS2LE = 0x62 00097 , UCS2LE_WinTUR = 0x26 00098 , WinARA_UCS2LE = 0x72 00099 , UCS2LE_WinARA = 0x27 00100 <span class="preprocessor">#endif</span> 00101 <span class="preprocessor"></span> <span class="comment">/* these aren't needed </span> 00102 <span class="comment"> * , Latin1_UCS2BE = 0x03</span> 00103 <span class="comment"> * , UCS2BE_Latin1 = 0x30</span> 00104 <span class="comment"> */</span> 00105 }; 00106 00107 iconv_t <a class="code" href="a00288.html#ga0">tds_sys_iconv_open</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *tocode, <span class="keyword">const</span> <span class="keywordtype">char</span> *fromcode); 00108 size_t tds_sys_iconv(iconv_t cd, <span class="keyword">const</span> <span class="keywordtype">char</span> **inbuf, size_t * inbytesleft, <span class="keywordtype">char</span> **outbuf, size_t * outbytesleft); 00109 <span class="keywordtype">int</span> tds_sys_iconv_close(iconv_t cd); 00110 <span class="preprocessor">#else</span> 00111 <span class="preprocessor"></span><span class="preprocessor">#define tds_sys_iconv_open iconv_open</span> 00112 <span class="preprocessor"></span><span class="preprocessor">#define tds_sys_iconv iconv</span> 00113 <span class="preprocessor"></span><span class="preprocessor">#define tds_sys_iconv_close iconv_close</span> 00114 <span class="preprocessor"></span><span class="preprocessor">#endif </span><span class="comment">/* !HAVE_ICONV */</span> 00115 00116 00117 <span class="keyword">typedef</span> <span class="keyword">enum</span> 00118 { to_server, to_client } TDS_ICONV_DIRECTION; 00119 00120 <span class="keyword">typedef</span> <span class="keyword">struct </span>_character_set_alias 00121 { 00122 <span class="keyword">const</span> <span class="keywordtype">char</span> *alias; 00123 <span class="keywordtype">int</span> canonic; 00124 } CHARACTER_SET_ALIAS; 00125 00126 <span class="keyword">typedef</span> <span class="keyword">struct </span>_tds_errno_message_flags { 00127 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> e2big:1; 00128 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> eilseq:1; 00129 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> einval:1; 00130 } TDS_ERRNO_MESSAGE_FLAGS; 00131 00132 <span class="keyword">struct </span>tdsiconvinfo 00133 { 00134 <a class="code" href="a00136.html">TDS_ENCODING</a> client_charset; 00135 <a class="code" href="a00136.html">TDS_ENCODING</a> server_charset; 00136 00137 <span class="preprocessor">#define TDS_ENCODING_INDIRECT 1</span> 00138 <span class="preprocessor"></span><span class="preprocessor">#define TDS_ENCODING_SWAPBYTE 2</span> 00139 <span class="preprocessor"></span><span class="preprocessor">#define TDS_ENCODING_MEMCPY 4</span> 00140 <span class="preprocessor"></span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> flags; 00141 00142 iconv_t to_wire; <span class="comment">/* conversion from client charset to server's format */</span> 00143 iconv_t from_wire; <span class="comment">/* conversion from server's format to client charset */</span> 00144 00145 iconv_t to_wire2; <span class="comment">/* conversion from client charset to server's format - indirect */</span> 00146 iconv_t from_wire2; <span class="comment">/* conversion from server's format to client charset - indirect */</span> 00147 00148 <span class="comment">/* </span> 00149 <span class="comment"> * Suppress error messages that would otherwise be emitted by tds_iconv().</span> 00150 <span class="comment"> * Functions that process large buffers ask tds_iconv to convert it in "chunks".</span> 00151 <span class="comment"> * We don't want to emit spurious EILSEQ errors or multiple errors for one </span> 00152 <span class="comment"> * buffer. tds_iconv() checks this structure before emiting a message, and </span> 00153 <span class="comment"> * adds to it whenever it emits one. Callers that handle a particular situation themselves</span> 00154 <span class="comment"> * can prepopulate it. </span> 00155 <span class="comment"> */</span> 00156 TDS_ERRNO_MESSAGE_FLAGS suppress; 00157 }; 00158 00159 <span class="comment">/* We use ICONV_CONST for tds_iconv(), even if we don't have iconv() */</span> 00160 <span class="preprocessor">#ifndef ICONV_CONST</span> 00161 <span class="preprocessor"></span><span class="preprocessor"># define ICONV_CONST const</span> 00162 <span class="preprocessor"></span><span class="preprocessor">#endif</span> 00163 <span class="preprocessor"></span> 00164 size_t <a class="code" href="a00288.html#ga10">tds_iconv_fread</a>(iconv_t cd, FILE * stream, size_t field_len, size_t term_len, <span class="keywordtype">char</span> *outbuf, size_t * outbytesleft); 00165 size_t <a class="code" href="a00288.html#ga9">tds_iconv</a>(<a class="code" href="a00144.html">TDSSOCKET</a> * tds, <span class="keyword">const</span> TDSICONV * char_conv, TDS_ICONV_DIRECTION io, 00166 <span class="keyword">const</span> <span class="keywordtype">char</span> **inbuf, size_t * inbytesleft, <span class="keywordtype">char</span> **outbuf, size_t * outbytesleft); 00167 <span class="keyword">const</span> <span class="keywordtype">char</span> *<a class="code" href="a00288.html#ga17">tds_canonical_charset_name</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *charset_name); 00168 <span class="keyword">const</span> <span class="keywordtype">char</span> *<a class="code" href="a00288.html#ga18">tds_sybase_charset_name</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *charset_name); 00169 00170 <span class="preprocessor">#ifdef __cplusplus</span> 00171 <span class="preprocessor"></span>} 00172 <span class="preprocessor">#endif</span> 00173 <span class="preprocessor"></span> 00174 <span class="preprocessor">#if defined(__GNUC__) && __GNUC__ >= 4</span> 00175 <span class="preprocessor"></span><span class="preprocessor">#pragma GCC visibility pop</span> 00176 <span class="preprocessor"></span><span class="preprocessor">#endif</span> 00177 <span class="preprocessor"></span> 00178 <span class="preprocessor">#endif </span><span class="comment">/* _tds_iconv_h_ */</span> </pre></div><hr size="1"><address style="align: right;"><small>Generated on Wed May 7 19:22:09 2008 for FreeTDS API by <a href="http://www.doxygen.org/index.html"> <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.1 </small></address> </body> </html>