portable_c.c
Go to the documentation of this file.
1 #if (defined(__APPLE__) || defined(macintosh)) && !defined(DMG_BUILD)
2 #include <AvailabilityMacros.h>
3 // this hack doesn't seem to be needed on El Captain (10.11)
4 #if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_11
5 // define this before including iconv.h to avoid a mapping of
6 // iconv_open and friends to libicon_open (done by mac ports),
7 // while the symbols without 'lib' are linked from /usr/lib/libiconv
8 #define LIBICONV_PLUG
9 #endif
10 #endif
11 #include <iconv.h>
12 
13 // These functions are implemented in a C file, because there are different
14 // versions of the iconv() prototype, some with a const pointer and some
15 // without. In C this is just a warning, but in C++ breaks the compilation.
16 // Looking at the LIBICONV_VERSION is not enough, since for MACOSX the
17 // const and non-const version exist with the same version of the file.
18 
19 void * portable_iconv_open(const char* tocode, const char* fromcode)
20 {
21  return iconv_open(tocode,fromcode);
22 }
23 
24 size_t portable_iconv (void *cd, char** inbuf, size_t *inbytesleft,
25  char** outbuf, size_t *outbytesleft)
26 {
27  return iconv((iconv_t)cd,inbuf,inbytesleft,outbuf,outbytesleft);
28 }
29 
30 int portable_iconv_close (void *cd)
31 {
32  return iconv_close((iconv_t)cd);
33 }
34 
void * iconv_t
Definition: iconv.h:57
LIBICONV_DLL_EXPORTED iconv_t iconv_open(const char *tocode, const char *fromcode)
void * portable_iconv_open(const char *tocode, const char *fromcode)
Definition: portable_c.c:19
int portable_iconv_close(void *cd)
Definition: portable_c.c:30
LIBICONV_DLL_EXPORTED size_t iconv(iconv_t cd, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft)
LIBICONV_DLL_EXPORTED int iconv_close(iconv_t cd)
size_t portable_iconv(void *cd, char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft)
Definition: portable_c.c:24