00001 /*- 00002 * Copyright (c) 1999,2000 00003 * Konstantin Chuguev. All rights reserved. 00004 * 00005 * Redistribution and use in source and binary forms, with or without 00006 * modification, are permitted provided that the following conditions 00007 * are met: 00008 * 1. Redistributions of source code must retain the above copyright 00009 * notice, this list of conditions and the following disclaimer. 00010 * 2. Redistributions in binary form must reproduce the above copyright 00011 * notice, this list of conditions and the following disclaimer in the 00012 * documentation and/or other materials provided with the distribution. 00013 * 3. All advertising materials mentioning features or use of this software 00014 * must display the following acknowledgement: 00015 * This product includes software developed by Konstantin Chuguev 00016 * and its contributors. 00017 * 00018 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 00019 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00020 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00021 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 00022 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00023 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 00024 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00025 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00026 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 00027 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 00028 * SUCH DAMAGE. 00029 * 00030 */ 00031 00032 #ifndef APR_ICONV_H 00033 #define APR_ICONV_H 00034 00035 /** 00036 * @file apr_iconv.h 00037 * @brief APR-iconv substitute iconv library implementation 00038 */ 00039 00040 #include "apr.h" 00041 #include "apr_pools.h" 00042 #include <stddef.h> 00043 00044 #ifdef __cplusplus 00045 extern "C" { 00046 #endif /* __cplusplus */ 00047 00048 /** 00049 * @defgroup apr_iconv substitute iconv implementation 00050 * @ingroup APR-iconv 00051 * @{ 00052 */ 00053 00054 /** 00055 * API_DECLARE_EXPORT is defined when building the libapriconv dynamic 00056 * library, so that all public symbols are exported. 00057 * 00058 * API_DECLARE_STATIC is defined when including the apriconv public headers, 00059 * to provide static linkage when the dynamic library may be unavailable. 00060 * 00061 * API_DECLARE_STATIC and API_DECLARE_EXPORT are left undefined when 00062 * including the apr-iconv public headers, to import and link the symbols 00063 * from the dynamic libapriconv library and assure appropriate indirection 00064 * and calling conventions at compile time. 00065 */ 00066 00067 #if defined(DOXYGEN) || !defined(WIN32) 00068 /** 00069 * The public apr-iconv functions are declared with API_DECLARE(), so they 00070 * use the most portable calling convention. Public apr-iconv functions 00071 * with variable arguments must use API_DECLARE_NONSTD(). 00072 * 00073 * @deffunc API_DECLARE(rettype) apr_func(args); 00074 */ 00075 #define API_DECLARE(type) type 00076 /** 00077 * The private apr-iconv functions are declared with API_DECLARE_NONSTD(), 00078 * so they use the most optimal C language calling conventions. 00079 * 00080 * @deffunc API_DECLARE(rettype) apr_func(args); 00081 */ 00082 #define API_DECLARE_NONSTD(type) type 00083 /** 00084 * All exported apr-iconv variables are declared with API_DECLARE_DATA 00085 * This assures the appropriate indirection is invoked at compile time. 00086 * 00087 * @deffunc API_DECLARE_DATA type apr_variable; 00088 * @tip extern API_DECLARE_DATA type apr_variable; syntax is required for 00089 * declarations within headers to properly import the variable. 00090 */ 00091 #define API_DECLARE_DATA 00092 #elif defined(API_DECLARE_STATIC) 00093 #define API_DECLARE(type) type __stdcall 00094 #define API_DECLARE_NONSTD(type) type __cdecl 00095 #define API_DECLARE_DATA 00096 #elif defined(API_DECLARE_EXPORT) 00097 #define API_DECLARE(type) __declspec(dllexport) type __stdcall 00098 #define API_DECLARE_NONSTD(type) __declspec(dllexport) type __cdecl 00099 #define API_DECLARE_DATA __declspec(dllexport) 00100 #else 00101 #define API_DECLARE(type) __declspec(dllimport) type __stdcall 00102 #define API_DECLARE_NONSTD(type) __declspec(dllimport) type __cdecl 00103 #define API_DECLARE_DATA __declspec(dllimport) 00104 #endif 00105 00106 /* 00107 * apr_iconv_t: charset conversion descriptor type 00108 */ 00109 typedef void *apr_iconv_t; 00110 00111 /* __BEGIN_DECLS */ 00112 00113 /** 00114 * Create a conversion descriptor. 00115 * @param to name of charset to convert to. 00116 * @param from name of charset of the input bytes. 00117 * @param pool pool to alloc memory. 00118 * @param cd conversion descriptor created in pool. 00119 */ 00120 API_DECLARE(apr_status_t) apr_iconv_open(const char *to, const char *from, 00121 apr_pool_t *pool, apr_iconv_t *cd); 00122 /** 00123 * Perform character set conversion. 00124 * @param cd conversion descriptor created by apr_iconv_open(). 00125 * @param inbuf input buffer. 00126 * @param inbytesleft bytes to convert. 00127 * @param outbuf output buffer. 00128 * @param outbytesleft space (in bytes) available in outbuf. 00129 * @param translated number of input bytes converted. 00130 */ 00131 API_DECLARE(apr_status_t) apr_iconv(apr_iconv_t cd, 00132 const char **inbuf, apr_size_t *inbytesleft, 00133 char **outbuf, apr_size_t *outbytesleft, 00134 apr_size_t *translated); 00135 /** 00136 * Deallocate descriptor for character set conversion. 00137 * @param cd conversion descriptor. 00138 * @param pool pool used in the apr_iconv_open(). 00139 */ 00140 API_DECLARE(apr_status_t) apr_iconv_close(apr_iconv_t cd, apr_pool_t *pool); 00141 00142 /* __END_DECLS */ 00143 00144 /** @} */ 00145 00146 #ifdef __cplusplus 00147 } 00148 #endif 00149 00150 #endif /* APR_ICONV_H */