uclibc-ng-dev: install static archive dummies
[openadk.git] / package / gmediaserver / patches / patch-src_main_c
blob1348a67c8ce501eee1eb770ac1f0e7484d327298
1 $Id: update-patches 24 2008-08-31 14:56:13Z wbx $
2 --- gmediaserver-0.13.0.orig/src/main.c 2007-10-20 11:41:37.000000000 +0200
3 +++ gmediaserver-0.13.0/src/main.c      2008-10-28 12:14:59.000000000 +0100
4 @@ -32,8 +32,10 @@
5  #include <stdbool.h>           /* Gnulib, C99 */
6  #include <signal.h>            /* ? */
7  #include <locale.h>            /* ? */
8 +#ifdef HAVE_ICONV
9  #include <iconv.h>             /* Gnulib, POSIX */
10  #include "striconv.h"          /* Gnulib */
11 +#endif
12  #ifdef HAVE_NL_LANGINFO
13  #include <langinfo.h>
14  #endif
15 @@ -72,9 +74,11 @@ enum {
16  static const char *short_options = "bv::i:o:p:";
17  static struct option long_options[] = {
18      { "disable-tags", no_argument, NULL, OPT_DISABLE_TAGS },
19 +#ifdef HAVE_ICONV
20      { "fs-charset", required_argument, NULL, OPT_FS_CHARSET },
21      { "device-charset", required_argument, NULL, OPT_DEVICE_CHARSET },
22      { "log-charset", required_argument, NULL, OPT_LOG_CHARSET },
23 +#endif
24      { "friendly-name", required_argument, NULL, OPT_FRIENDLY_NAME },
25      { "pid-file", required_argument, NULL, OPT_PIDFILE },
26      { "profile", required_argument, NULL, OPT_PROFILE, },
27 @@ -92,14 +96,17 @@ static struct option long_options[] = {
28      { NULL, 0, NULL, 0 }
29  };
31 +#ifdef HAVE_ICONV
32  static iconv_t utf8_to_device = (iconv_t) -1;
33  static iconv_t utf8_to_log = (iconv_t) -1;
34  static iconv_t fs_to_utf8 = (iconv_t) -1;
35 +#endif
36  const char version_etc_copyright[] = "Copyright (C) 2005, 2006 Oskar Liljeblad.";
38  char *
39  convert_string_to_device(const char *str)
40  {
41 +#ifdef HAVE_ICONV
42      char *out;
43      if (utf8_to_device == (iconv_t) -1)
44          return xstrdup(str);
45 @@ -107,12 +114,15 @@ convert_string_to_device(const char *str
46      if (out != NULL)
47          return out;
48      warn(_("%s: cannot convert to device character set: %s\n"), quotearg(str), errstr);
49 +#else
50      return xstrdup(str);
51 +#endif
52  }
54  char *
55  convert_string_to_log(const char *str)
56  {
57 +#ifdef HAVE_ICONV
58      char *out;
60      if (utf8_to_log == (iconv_t) -1)
61 @@ -121,7 +131,9 @@ convert_string_to_log(const char *str)
62      if (out != NULL)
63          return out;
64      /* Cannot warn here - would deadlock! */
65 +#else
66      return xstrdup(str);
67 +#endif
68  }
70  static char *cache_fs_str = NULL;
71 @@ -129,6 +141,7 @@ static char *cache_fs_str = NULL;
72  char *
73  conv_filename(const char *str)
74  {
75 +#ifdef HAVE_ICONV
76      free(cache_fs_str);
77      if (fs_to_utf8 == (iconv_t) -1) {
78          cache_fs_str = xstrdup(str);
79 @@ -140,6 +153,9 @@ conv_filename(const char *str)
80          }
81      }
82      return cache_fs_str;
83 +#else
84 +    return xstrdup(str);
85 +#endif
86  }
88  static void
89 @@ -188,8 +204,10 @@ main(int argc, char **argv)
90      set_program_name(argv[0]);
91      set_quoting_style(0, escape_quoting_style);
93 +#ifdef LOCALE
94      if (setlocale(LC_ALL, "") == NULL)
95          warn(_("cannot set locale: %s\n"), errstr);
96 +#endif
97  #ifdef ENABLE_NLS
98      if (bindtextdomain(PACKAGE, LOCALEDIR) == NULL)
99          warn(_("cannot bind message domain: %s\n"), errstr);
100 @@ -215,6 +233,7 @@ main(int argc, char **argv)
101         case OPT_DISABLE_TAGS:
102             tags_enabled = false;
103             break;
104 +#ifdef HAVE_ICONV
105          case OPT_FS_CHARSET:
106              fs_charset = optarg;
107              break;
108 @@ -224,6 +243,7 @@ main(int argc, char **argv)
109          case OPT_LOG_CHARSET:
110              log_charset = optarg;
111              break;
112 +#endif
113         case OPT_FRIENDLY_NAME:
114             if (optarg[0] == '\0')
115                 die(_("friendly name cannot be empty\n"));
116 @@ -294,9 +314,11 @@ main(int argc, char **argv)
117              printf(_("Run the UPnP media server.\n\n"));
118             printf(_("      --friendly-name=NAME      set display name for media server\n"));
119             printf(_("      --disable-tags            do not scan files for tags\n"));
120 +#ifdef HAVE_ICONV
121             printf(_("      --fs-charset=CHARSET      character set used in file names\n"));
122             printf(_("      --device-charset=CHARSET  character set used in the player device\n"));
123             printf(_("      --log-charset=CHARSET     character set used in logs and display\n"));
124 +#endif
125             printf(_("  -v, --verbose[=LEVEL]         set verbosity level (0-4)\n"));
126              printf(_("      --pid-file=FILE           write pid to FILE when up and running\n"));
127              printf(_("  -i, --interface=NAME          listen on a specific interface\n"));
128 @@ -371,6 +393,7 @@ main(int argc, char **argv)
129      if (fs_charset == NULL && getenv("G_BROKEN_FILENAMES") != NULL)
130          fs_charset = nl_langinfo(CODESET);
131  #endif
132 +#ifdef HAVE_ICONV
133      if (fs_charset != NULL) {
134          fs_to_utf8 = iconv_open("UTF-8", fs_charset);
135          if (fs_to_utf8 == (iconv_t) -1)
136 @@ -395,6 +418,7 @@ main(int argc, char **argv)
137              die(_("cannot create character set convertor from %s to %s\n"), "UTF-8", quotearg(log_charset));
138      }
139      say(4, _("Using log character set %s\n"), quote(log_charset == NULL ? "UTF-8" : log_charset));
140 +#endif
142      init_logging(logfilename, timestamp_format);
144 @@ -478,12 +502,14 @@ main(int argc, char **argv)
146      finish_logging(true);
148 +#ifdef HAVE_ICONV
149      if (fs_to_utf8 != (iconv_t) -1)
150          iconv_close(fs_to_utf8); /* ignore errors (only EINVAL) */
151      if (utf8_to_device != (iconv_t) -1)
152          iconv_close(utf8_to_device); /* ignore errors (only EINVAL) */
153      if (utf8_to_log != (iconv_t) -1)
154          iconv_close(utf8_to_log); /* ignore errors (only EINVAL) */
155 +#endif
157      free(cache_fs_str);