| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 | $Id: update-patches 24 2008-08-31 14:56:13Z wbx $--- gmediaserver-0.13.0.orig/src/main.c	2007-10-20 11:41:37.000000000 +0200+++ gmediaserver-0.13.0/src/main.c	2008-10-28 12:14:59.000000000 +0100@@ -32,8 +32,10 @@ #include <stdbool.h>		/* Gnulib, C99 */ #include <signal.h>		/* ? */ #include <locale.h>		/* ? */+#ifdef HAVE_ICONV #include <iconv.h>		/* Gnulib, POSIX */ #include "striconv.h"		/* Gnulib */+#endif #ifdef HAVE_NL_LANGINFO #include <langinfo.h> #endif@@ -72,9 +74,11 @@ enum { static const char *short_options = "bv::i:o:p:"; static struct option long_options[] = {     { "disable-tags", no_argument, NULL, OPT_DISABLE_TAGS },+#ifdef HAVE_ICONV     { "fs-charset", required_argument, NULL, OPT_FS_CHARSET },     { "device-charset", required_argument, NULL, OPT_DEVICE_CHARSET },     { "log-charset", required_argument, NULL, OPT_LOG_CHARSET },+#endif     { "friendly-name", required_argument, NULL, OPT_FRIENDLY_NAME },     { "pid-file", required_argument, NULL, OPT_PIDFILE },     { "profile", required_argument, NULL, OPT_PROFILE, },@@ -92,14 +96,17 @@ static struct option long_options[] = {     { NULL, 0, NULL, 0 } }; +#ifdef HAVE_ICONV static iconv_t utf8_to_device = (iconv_t) -1; static iconv_t utf8_to_log = (iconv_t) -1; static iconv_t fs_to_utf8 = (iconv_t) -1;+#endif const char version_etc_copyright[] = "Copyright (C) 2005, 2006 Oskar Liljeblad.";  char * convert_string_to_device(const char *str) {+#ifdef HAVE_ICONV     char *out;     if (utf8_to_device == (iconv_t) -1)         return xstrdup(str);@@ -107,12 +114,15 @@ convert_string_to_device(const char *str     if (out != NULL)         return out;     warn(_("%s: cannot convert to device character set: %s\n"), quotearg(str), errstr);+#else     return xstrdup(str);+#endif }  char * convert_string_to_log(const char *str) {+#ifdef HAVE_ICONV     char *out;      if (utf8_to_log == (iconv_t) -1)@@ -121,7 +131,9 @@ convert_string_to_log(const char *str)     if (out != NULL)         return out;     /* Cannot warn here - would deadlock! */+#else     return xstrdup(str);+#endif }  static char *cache_fs_str = NULL;@@ -129,6 +141,7 @@ static char *cache_fs_str = NULL; char * conv_filename(const char *str) {+#ifdef HAVE_ICONV     free(cache_fs_str);     if (fs_to_utf8 == (iconv_t) -1) {         cache_fs_str = xstrdup(str);@@ -140,6 +153,9 @@ conv_filename(const char *str)         }     }     return cache_fs_str;+#else+    return xstrdup(str);+#endif }  static void@@ -188,8 +204,10 @@ main(int argc, char **argv)     set_program_name(argv[0]);     set_quoting_style(0, escape_quoting_style); +#ifdef LOCALE     if (setlocale(LC_ALL, "") == NULL)         warn(_("cannot set locale: %s\n"), errstr);+#endif #ifdef ENABLE_NLS     if (bindtextdomain(PACKAGE, LOCALEDIR) == NULL)         warn(_("cannot bind message domain: %s\n"), errstr);@@ -215,6 +233,7 @@ main(int argc, char **argv) 	case OPT_DISABLE_TAGS: 	    tags_enabled = false; 	    break;+#ifdef HAVE_ICONV         case OPT_FS_CHARSET:             fs_charset = optarg;             break;@@ -224,6 +243,7 @@ main(int argc, char **argv)         case OPT_LOG_CHARSET:             log_charset = optarg;             break;+#endif 	case OPT_FRIENDLY_NAME: 	    if (optarg[0] == '\0') 		die(_("friendly name cannot be empty\n"));@@ -294,9 +314,11 @@ main(int argc, char **argv)             printf(_("Run the UPnP media server.\n\n")); 	    printf(_("      --friendly-name=NAME      set display name for media server\n")); 	    printf(_("      --disable-tags            do not scan files for tags\n"));+#ifdef HAVE_ICONV 	    printf(_("      --fs-charset=CHARSET      character set used in file names\n")); 	    printf(_("      --device-charset=CHARSET  character set used in the player device\n")); 	    printf(_("      --log-charset=CHARSET     character set used in logs and display\n"));+#endif 	    printf(_("  -v, --verbose[=LEVEL]         set verbosity level (0-4)\n"));             printf(_("      --pid-file=FILE           write pid to FILE when up and running\n"));             printf(_("  -i, --interface=NAME          listen on a specific interface\n"));@@ -371,6 +393,7 @@ main(int argc, char **argv)     if (fs_charset == NULL && getenv("G_BROKEN_FILENAMES") != NULL)         fs_charset = nl_langinfo(CODESET); #endif+#ifdef HAVE_ICONV     if (fs_charset != NULL) {         fs_to_utf8 = iconv_open("UTF-8", fs_charset);         if (fs_to_utf8 == (iconv_t) -1)@@ -395,6 +418,7 @@ main(int argc, char **argv)             die(_("cannot create character set convertor from %s to %s\n"), "UTF-8", quotearg(log_charset));     }     say(4, _("Using log character set %s\n"), quote(log_charset == NULL ? "UTF-8" : log_charset));+#endif      init_logging(logfilename, timestamp_format); @@ -478,12 +502,14 @@ main(int argc, char **argv)      finish_logging(true); +#ifdef HAVE_ICONV     if (fs_to_utf8 != (iconv_t) -1)         iconv_close(fs_to_utf8); /* ignore errors (only EINVAL) */     if (utf8_to_device != (iconv_t) -1)         iconv_close(utf8_to_device); /* ignore errors (only EINVAL) */     if (utf8_to_log != (iconv_t) -1)         iconv_close(utf8_to_log); /* ignore errors (only EINVAL) */+#endif      free(cache_fs_str); 
 |