Blame src/portable_c.c

Packit 1c1d7e
#if (defined(__APPLE__) || defined(macintosh)) && !defined(DMG_BUILD)
Packit 1c1d7e
#include <AvailabilityMacros.h>
Packit 1c1d7e
// this hack doesn't seem to be needed on El Captain (10.11)
Packit 1c1d7e
#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_11
Packit 1c1d7e
// define this before including iconv.h to avoid a mapping of
Packit 1c1d7e
// iconv_open and friends to libicon_open (done by mac ports),
Packit 1c1d7e
// while the symbols without 'lib' are linked from /usr/lib/libiconv
Packit 1c1d7e
#define LIBICONV_PLUG
Packit 1c1d7e
#endif
Packit 1c1d7e
#endif
Packit 1c1d7e
#include <iconv.h>
Packit 1c1d7e
Packit 1c1d7e
// These functions are implemented in a C file, because there are different
Packit 1c1d7e
// versions of the iconv() prototype, some with a const pointer and some
Packit 1c1d7e
// without. In C this is just a warning, but in C++ breaks the compilation.
Packit 1c1d7e
// Looking at the LIBICONV_VERSION is not enough, since for MACOSX the 
Packit 1c1d7e
// const and non-const version exist with the same version of the file.
Packit 1c1d7e
Packit 1c1d7e
void * portable_iconv_open(const char* tocode, const char* fromcode)
Packit 1c1d7e
{
Packit 1c1d7e
  return iconv_open(tocode,fromcode);
Packit 1c1d7e
}
Packit 1c1d7e
Packit 1c1d7e
size_t portable_iconv (void *cd, char** inbuf,  size_t *inbytesleft, 
Packit 1c1d7e
                                 char** outbuf, size_t *outbytesleft)
Packit 1c1d7e
{
Packit 1c1d7e
  return iconv((iconv_t)cd,inbuf,inbytesleft,outbuf,outbytesleft);
Packit 1c1d7e
}
Packit 1c1d7e
Packit 1c1d7e
int portable_iconv_close (void *cd)
Packit 1c1d7e
{
Packit 1c1d7e
  return iconv_close((iconv_t)cd);
Packit 1c1d7e
}
Packit 1c1d7e