diff options
Diffstat (limited to '')
-rw-r--r-- | configure.ac | 64 | ||||
-rw-r--r-- | support.c | 43 |
2 files changed, 62 insertions, 45 deletions
diff --git a/configure.ac b/configure.ac index 1d537c6e9..6452834cb 100644 --- a/configure.ac +++ b/configure.ac @@ -17,24 +17,6 @@ dnl ======================================================= set -- $CFLAGS CFLAGS="-Wall $CFLAGS" - - -dnl -dnl Check for libaries -dnl - -dnl ncurses -AC_CHECK_LIB(ncurses, initscr,, [AC_MSG_ERROR(ncurses library is required)]) - -dnl glib-2.0 -AM_PATH_GLIB_2_0(, , [AC_MSG_ERROR(glib-2.x is required)], glib) - -dnl popt -AC_CHECK_LIB(popt, - poptGetArg, - LIBS="$LIBS -lpopt", - AC_MSG_ERROR(Missing popt command line parsing library)) - dnl dnl Check for types dnl @@ -42,24 +24,41 @@ AC_CHECK_TYPE(socklen_t, AC_DEFINE(HAVE_SOCKLEN_T, 1, socklen_t defined in sys/socket.h), ) + dnl dnl Check for headers dnl -AM_ICONV - -AC_CHECK_HEADER(langinfo.h, - AC_DEFINE(HAVE_LANGINFO_H, 1, langinfo.h), +AC_CHECK_HEADER(libgen.h, + AC_DEFINE(HAVE_LIBGEN_H, 1, glibc - libgen.h), ,) AC_CHECK_HEADER(locale.h, - AC_DEFINE(HAVE_LOCALE_H, 1, locale.h), + AC_DEFINE(HAVE_LOCALE_H, 1, locale.h), ,) -AC_CHECK_HEADER(libgen.h, - AC_DEFINE(HAVE_LIBGEN_H, 1, glibc - libgen.h), - ,) +dnl +dnl Check for libaries +dnl + +dnl iconv +AM_ICONV + +dnl nl_langinfo() +AM_LANGINFO_CODESET + +dnl ncurses +AC_CHECK_LIB(ncurses, initscr,, [AC_MSG_ERROR(ncurses library is required)]) + +dnl glib-2.0 +AM_PATH_GLIB_2_0(, , [AC_MSG_ERROR(glib-2.x is required)], glib) + +dnl popt +AC_CHECK_LIB(popt, + poptGetArg, + LIBS="$LIBS -lpopt", + AC_MSG_ERROR(Missing popt command line parsing library)) dnl dnl X11 @@ -76,6 +75,12 @@ if test "$enable_debug" = yes; then CFLAGS="$CFLAGS -g -DDEBUG" fi +dnl Default charset +AC_ARG_WITH(default-charset, + [ --with-default-charset=ARG Default charset (ISO-8859-1)], + DEFAULT_CHARSET="$withval", + DEFAULT_CHARSET="ISO-8859-1") + dnl Default host AC_ARG_WITH(default-host, [ --with-default-host=HOST Default host (localhost)], @@ -94,9 +99,10 @@ LIBS="$LIBS $GLIB_LIBS -lncurses" dnl Autoheader -AC_DEFINE_UNQUOTED(DEFAULT_PORT, $DEFAULT_PORT, Default MPD port) -AC_DEFINE_UNQUOTED(DEFAULT_PORT_STR, "$DEFAULT_PORT", Default MPD port) -AC_DEFINE_UNQUOTED(DEFAULT_HOST, "$DEFAULT_HOST", Default MPD host) +AC_DEFINE_UNQUOTED(DEFAULT_PORT, $DEFAULT_PORT, Default MPD port) +AC_DEFINE_UNQUOTED(DEFAULT_PORT_STR, "$DEFAULT_PORT", Default MPD port) +AC_DEFINE_UNQUOTED(DEFAULT_HOST, "$DEFAULT_HOST", Default MPD host) +AC_DEFINE_UNQUOTED(DEFAULT_CHARSET, "$DEFAULT_CHARSET", Default charset) AM_CONFIG_HEADER(config.h) @@ -5,31 +5,35 @@ #include <glib.h> #include "config.h" +#include "support.h" #ifdef HAVE_LOCALE_H -#ifdef HAVE_LANGINFO_H -#ifdef HAVE_ICONV #include <locale.h> -#include <langinfo.h> -#include <iconv.h> -#define ENABLE_CHARACTER_SET_CONVERSION -#endif #endif + +#ifdef HAVE_ICONV +#include <iconv.h> #endif -#include "support.h" +#ifdef HAVE_LANGINFO_CODESET +#include <langinfo.h> +#endif #define BUFSIZE 1024 -#ifdef ENABLE_CHARACTER_SET_CONVERSION -static char *locale = NULL; + static char *charset = NULL; + +#ifdef HAVE_LOCALE_H +static char *locale = NULL; +#endif + +#ifdef HAVE_ICONV iconv_t iconv_from_uft8 = (iconv_t)(-1); iconv_t iconv_to_uft8 = (iconv_t)(-1); #endif - #ifndef HAVE_LIBGEN_H char * @@ -71,21 +75,28 @@ basename(char *path) int charset_init(void) { -#ifdef ENABLE_CHARACTER_SET_CONVERSION +#ifdef HAVE_LOCALE_H /* get current locale */ if( (locale=setlocale(LC_CTYPE,"")) == NULL ) { fprintf(stderr,"setlocale() - failed!\n"); return -1; } +#endif +#ifdef HAVE_LANGINFO_CODESET /* get charset */ if( (charset=nl_langinfo(CODESET)) == NULL ) { - fprintf(stderr,"nl_langinfo() - failed!\n"); - return -1; + fprintf(stderr, + "nl_langinfo() failed using default:" DEFAULT_CHARSET "\n"); } - +#endif + + if( charset==NULL ) + charset = DEFAULT_CHARSET; + +#ifdef HAVE_ICONV /* allocate descriptor for character set conversion */ iconv_from_uft8 = iconv_open(charset, "UTF-8"); if( iconv_from_uft8 == (iconv_t)(-1) ) @@ -101,7 +112,7 @@ charset_init(void) int charset_close(void) { -#ifdef ENABLE_CHARACTER_SET_CONVERSION +#ifdef HAVE_ICONV if( iconv_from_uft8 == (iconv_t)(-1) ) { iconv_close(iconv_from_uft8); @@ -121,7 +132,7 @@ charset_close(void) char * utf8_to_locale(char *str) { -#ifdef ENABLE_CHARACTER_SET_CONVERSION +#ifdef HAVE_ICONV size_t inleft; size_t retlen; char *ret; |