mirror of
https://github.com/znc/znc.git
synced 2026-03-28 17:42:41 +01:00
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:
126
configure
vendored
126
configure
vendored
@@ -558,6 +558,8 @@ ac_subst_vars='LTLIBOBJS
|
||||
LIBOBJS
|
||||
DATADIR
|
||||
MODDIR
|
||||
LIBICONV
|
||||
CHARSET
|
||||
SASL
|
||||
TCL_FLAGS
|
||||
EXTRA
|
||||
@@ -3018,11 +3020,10 @@ pkg_failed=no
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for c_ares" >&5
|
||||
$as_echo_n "checking for c_ares... " >&6; }
|
||||
|
||||
if test -n "$PKG_CONFIG"; then
|
||||
if test -n "$c_ares_CFLAGS"; then
|
||||
pkg_cv_c_ares_CFLAGS="$c_ares_CFLAGS"
|
||||
else
|
||||
if test -n "$PKG_CONFIG" && \
|
||||
if test -n "$c_ares_CFLAGS"; then
|
||||
pkg_cv_c_ares_CFLAGS="$c_ares_CFLAGS"
|
||||
elif test -n "$PKG_CONFIG"; then
|
||||
if test -n "$PKG_CONFIG" && \
|
||||
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libcares\""; } >&5
|
||||
($PKG_CONFIG --exists --print-errors "libcares") 2>&5
|
||||
ac_status=$?
|
||||
@@ -3032,15 +3033,13 @@ if test -n "$PKG_CONFIG"; then
|
||||
else
|
||||
pkg_failed=yes
|
||||
fi
|
||||
fi
|
||||
else
|
||||
pkg_failed=untried
|
||||
else
|
||||
pkg_failed=untried
|
||||
fi
|
||||
if test -n "$PKG_CONFIG"; then
|
||||
if test -n "$c_ares_LIBS"; then
|
||||
pkg_cv_c_ares_LIBS="$c_ares_LIBS"
|
||||
else
|
||||
if test -n "$PKG_CONFIG" && \
|
||||
if test -n "$c_ares_LIBS"; then
|
||||
pkg_cv_c_ares_LIBS="$c_ares_LIBS"
|
||||
elif test -n "$PKG_CONFIG"; then
|
||||
if test -n "$PKG_CONFIG" && \
|
||||
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libcares\""; } >&5
|
||||
($PKG_CONFIG --exists --print-errors "libcares") 2>&5
|
||||
ac_status=$?
|
||||
@@ -3050,9 +3049,8 @@ if test -n "$PKG_CONFIG"; then
|
||||
else
|
||||
pkg_failed=yes
|
||||
fi
|
||||
fi
|
||||
else
|
||||
pkg_failed=untried
|
||||
else
|
||||
pkg_failed=untried
|
||||
fi
|
||||
|
||||
|
||||
@@ -3065,9 +3063,9 @@ else
|
||||
_pkg_short_errors_supported=no
|
||||
fi
|
||||
if test $_pkg_short_errors_supported = yes; then
|
||||
c_ares_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "libcares"`
|
||||
c_ares_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "libcares" 2>&1`
|
||||
else
|
||||
c_ares_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "libcares"`
|
||||
c_ares_PKG_ERRORS=`$PKG_CONFIG --print-errors "libcares" 2>&1`
|
||||
fi
|
||||
# Put the nasty error message in config.log where it belongs
|
||||
echo "$c_ares_PKG_ERRORS" >&5
|
||||
@@ -3559,6 +3557,96 @@ $as_echo "$TCL_FLAGS" >&6; }
|
||||
fi
|
||||
fi
|
||||
|
||||
if test x"$EXTRA" = "xyes"
|
||||
then
|
||||
ac_fn_cxx_check_func "$LINENO" "iconv" "ac_cv_func_iconv"
|
||||
if test "x$ac_cv_func_iconv" = x""yes; then :
|
||||
CHARSET=1
|
||||
fi
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for iconv_open in -liconv" >&5
|
||||
$as_echo_n "checking for iconv_open in -liconv... " >&6; }
|
||||
if test "${ac_cv_lib_iconv_iconv_open+set}" = set; then :
|
||||
$as_echo_n "(cached) " >&6
|
||||
else
|
||||
ac_check_lib_save_LIBS=$LIBS
|
||||
LIBS="-liconv $LIBS"
|
||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
/* end confdefs.h. */
|
||||
|
||||
/* Override any GCC internal prototype to avoid an error.
|
||||
Use char because int might match the return type of a GCC
|
||||
builtin and then its argument prototype would still apply. */
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
#endif
|
||||
char iconv_open ();
|
||||
int
|
||||
main ()
|
||||
{
|
||||
return iconv_open ();
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
_ACEOF
|
||||
if ac_fn_cxx_try_link "$LINENO"; then :
|
||||
ac_cv_lib_iconv_iconv_open=yes
|
||||
else
|
||||
ac_cv_lib_iconv_iconv_open=no
|
||||
fi
|
||||
rm -f core conftest.err conftest.$ac_objext \
|
||||
conftest$ac_exeext conftest.$ac_ext
|
||||
LIBS=$ac_check_lib_save_LIBS
|
||||
fi
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_iconv_iconv_open" >&5
|
||||
$as_echo "$ac_cv_lib_iconv_iconv_open" >&6; }
|
||||
if test "x$ac_cv_lib_iconv_iconv_open" = x""yes; then :
|
||||
LIBICONV=-liconv ; CHARSET=1
|
||||
fi
|
||||
|
||||
if test "x$CHARSET" = "x1"
|
||||
then
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether iconv expects a const second argument" >&5
|
||||
$as_echo_n "checking whether iconv expects a const second argument... " >&6; }
|
||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
/* end confdefs.h. */
|
||||
|
||||
|
||||
#include <iconv.h>
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
|
||||
const char input[] = "X"; const char *inptr = input; size_t inbytes = 1;
|
||||
char buf[1]; char *outptr = buf; size_t outbytes = 1;
|
||||
iconv_t ic = iconv_open("ISO8859-1", "UTF8");
|
||||
iconv(ic, (char**)&inptr, &inbytes, &outptr, &outbytes);
|
||||
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
_ACEOF
|
||||
if ac_fn_cxx_try_compile "$LINENO"; then :
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
|
||||
$as_echo "no" >&6; }
|
||||
appendMod -DICONV_CONST=
|
||||
|
||||
else
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
|
||||
$as_echo "yes" >&6; }
|
||||
appendMod -DICONV_CONST=const
|
||||
|
||||
fi
|
||||
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
|
||||
else
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: libiconv was not found, disabling the charset module" >&5
|
||||
$as_echo "$as_me: WARNING: libiconv was not found, disabling the charset module" >&2;}
|
||||
fi
|
||||
fi
|
||||
|
||||
appendCXX "-D_MODDIR_=\\\"${MODDIR}\\\""
|
||||
appendCXX "-D_DATADIR_=\\\"${DATADIR}\\\""
|
||||
|
||||
@@ -3576,6 +3664,8 @@ appendCXX "-D_DATADIR_=\\\"${DATADIR}\\\""
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ac_config_files="$ac_config_files Makefile"
|
||||
|
||||
ac_config_files="$ac_config_files znc-config"
|
||||
|
||||
29
configure.in
29
configure.in
@@ -306,6 +306,33 @@ then
|
||||
fi
|
||||
fi
|
||||
|
||||
if test x"$EXTRA" = "xyes"
|
||||
then
|
||||
AC_CHECK_FUNC( iconv, CHARSET=1 )
|
||||
AC_CHECK_LIB( iconv, iconv_open, LIBICONV=-liconv ; CHARSET=1 )
|
||||
if test "x$CHARSET" = "x1"
|
||||
then
|
||||
AC_MSG_CHECKING([whether iconv expects a const second argument])
|
||||
AC_COMPILE_IFELSE([
|
||||
AC_LANG_PROGRAM([[
|
||||
#include <iconv.h>
|
||||
]], [[
|
||||
const char input[] = "X"; const char *inptr = input; size_t inbytes = 1;
|
||||
char buf[1]; char *outptr = buf; size_t outbytes = 1;
|
||||
iconv_t ic = iconv_open("ISO8859-1", "UTF8");
|
||||
iconv(ic, (char**)&inptr, &inbytes, &outptr, &outbytes);
|
||||
]])], [
|
||||
AC_MSG_RESULT([no])
|
||||
appendMod -DICONV_CONST=
|
||||
], [
|
||||
AC_MSG_RESULT([yes])
|
||||
appendMod -DICONV_CONST=const
|
||||
])
|
||||
else
|
||||
AC_MSG_WARN([libiconv was not found, disabling the charset module])
|
||||
fi
|
||||
fi
|
||||
|
||||
appendCXX "-D_MODDIR_=\\\"${MODDIR}\\\""
|
||||
appendCXX "-D_DATADIR_=\\\"${DATADIR}\\\""
|
||||
|
||||
@@ -321,6 +348,8 @@ AC_SUBST([NOSSL])
|
||||
AC_SUBST([EXTRA])
|
||||
AC_SUBST([TCL_FLAGS])
|
||||
AC_SUBST([SASL])
|
||||
AC_SUBST([CHARSET])
|
||||
AC_SUBST([LIBICONV])
|
||||
AC_SUBST([MODDIR])
|
||||
AC_SUBST([DATADIR])
|
||||
AC_CONFIG_FILES([Makefile])
|
||||
|
||||
@@ -62,6 +62,11 @@ FILES := $(shell echo $(FILES) | sed -e "s:extra/saslauth::")
|
||||
endif
|
||||
saslauthFLAGS := -lsasl2
|
||||
|
||||
ifeq "@CHARSET@" ""
|
||||
FILES := $(shell echo $(FILES) | sed -e "s:extra/charset::")
|
||||
endif
|
||||
charsetFLAGS := @LIBICONV@
|
||||
|
||||
ifeq "$(TCL_FLAGS)" ""
|
||||
FILES := $(shell echo $(FILES) | sed -e "s:extra/modtcl::")
|
||||
else
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user