Added the necessary checks for (lib)iconv in order to enable

the charset module from extra to do its thing. This has been
a pain in the ass and I'd like to thank psychon who made most
of the autofoo happen and BrianC for finding out that BSD sucks
and for testing! Yay!


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1947 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
cflakes
2010-04-27 15:40:24 +00:00
parent 5f1a1d0153
commit dee94a0bb8
4 changed files with 151 additions and 20 deletions
+9 -2
View File
@@ -9,6 +9,13 @@
#include "Modules.h"
#include <iconv.h>
#ifndef ICONV_CONST
/* configure is supposed to define this, depending on whether the second
argument to iconv is const char** or just char**, but if it isn't defined,
we default to GNU/Linux which is non-const. */
#define ICONV_CONST
#endif
class CCharsetMod : public CModule
{
private:
@@ -32,7 +39,7 @@ private:
bBreak = (uInLen < 1);
if(iconv(ic, // this is ugly, but keeps the code short:
(uInLen < 1 ? NULL : const_cast<char**>(&pIn)),
(uInLen < 1 ? NULL : (ICONV_CONST char**)&pIn),
(uInLen < 1 ? NULL : &uInLen),
&pOut, &uBufSize) == (size_t)-1)
// explanation: iconv needs a last call with input = NULL to
@@ -82,7 +89,7 @@ private:
const char* pIn = sData.c_str();
size_t uInLen = sData.size();
size_t uResult = iconv(ic, const_cast<char**>(&pIn), &uInLen, &pResultWalker, &uResultBufSize);
size_t uResult = iconv(ic, (ICONV_CONST char**)&pIn, &uInLen, &pResultWalker, &uResultBufSize);
iconv_close(ic);