Blame src/portable_c.c

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