summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4906ff4)
raw | patch | inline | side by side (parent: 4906ff4)
author | Kalle Wallin <kaw@linux.se> | |
Mon, 22 Mar 2004 12:43:30 +0000 (12:43 +0000) | ||
committer | Kalle Wallin <kaw@linux.se> | |
Mon, 22 Mar 2004 12:43:30 +0000 (12:43 +0000) |
configure.ac | patch | blob | history | |
support.c | patch | blob | history |
diff --git a/configure.ac b/configure.ac
index 1d537c6e98a676d4eef38a89dd00ca30019c1442..6452834cbc447750ce0e346420c1b5fe8c38c686 100644 (file)
--- a/configure.ac
+++ b/configure.ac
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
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
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)],
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)
diff --git a/support.c b/support.c
index d2dc9759c7e173f94a0535dce9dd96807e2efd5e..15f084c1cd84afb006ab604bc6ff55f7255e91d4 100644 (file)
--- a/support.c
+++ b/support.c
#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 *
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) )
int
charset_close(void)
{
-#ifdef ENABLE_CHARACTER_SET_CONVERSION
+#ifdef HAVE_ICONV
if( iconv_from_uft8 == (iconv_t)(-1) )
{
iconv_close(iconv_from_uft8);
char *
utf8_to_locale(char *str)
{
-#ifdef ENABLE_CHARACTER_SET_CONVERSION
+#ifdef HAVE_ICONV
size_t inleft;
size_t retlen;
char *ret;