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