add gmediaserver package
[openwrt.git] / openwrt / package / gmediaserver / patches / no_iconv.patch
1 --- gmediaserver-0.7.0/src/main.c.orig  2005-08-29 21:15:01.000000000 +0200
2 +++ gmediaserver-0.7.0/src/main.c       2005-08-30 12:37:40.000000000 +0200
3 @@ -31,8 +31,10 @@
4  #include <stdarg.h>            /* C89 */
5  #include <stdbool.h>           /* Gnulib, C99 */
6  #include <signal.h>            /* ? */
7 +#ifdef HAVE_ICONV
8  #include <iconv.h>             /* Gnulib, POSIX */
9  #include "iconvme.h"           /* Gnulib */
10 +#endif
11  #ifdef HAVE_NL_LANGINFO
12  #include <langinfo.h>
13  #endif
14 @@ -70,8 +72,10 @@
15  #ifdef HAVE_ID3LIB
16      { "disable-id3", no_argument, NULL, OPT_DISABLE_ID3 },
17  #endif
18 +#ifdef HAVE_ICONV
19      { "in-charset", required_argument, NULL, OPT_IN_CHARSET },
20      { "device-charset", required_argument, NULL, OPT_DEVICE_CHARSET },
21 +#endif
22      { "friendly-name", required_argument, NULL, OPT_FRIENDLY_NAME },
23      { "pid-file", required_argument, NULL, OPT_PIDFILE },
24      { "profile", required_argument, NULL, OPT_PROFILE, },
25 @@ -89,15 +93,21 @@
26      { NULL, 0, NULL, 0 }
27  };
28  
29 +#ifdef HAVE_ICONV
30  iconv_t charset_convert = (iconv_t) -1;
31 +#endif
32  const char version_etc_copyright[] = "Copyright (C) 2005 Oskar Liljeblad.";
33  
34  char *
35  convert_string(const char *str)
36  {
37 +#ifdef HAVE_ICONV
38      if (charset_convert == (iconv_t) -1)
39          return xstrdup(str);
40      return iconv_alloc(charset_convert, str);
41 +#else
42 +    return xstrdup(str);
43 +#endif
44  }
45  
46  static void
47 @@ -139,13 +149,17 @@
48      char *logfilename = NULL;
49      char *timestamp_format = NULL;
50      uint32_t expire_time;
51 +#ifdef HAVE_ICONV
52      char *in_charset = NULL;
53      char *device_charset = NULL;
54 +#endif
55  
56      set_program_name(argv[0]);
57  
58 +#ifdef LOCALE
59      if (setlocale(LC_ALL, "") == NULL)
60          warn(_("cannot set locale: %s\n"), errstr);
61 +#endif
62  #ifdef ENABLE_NLS
63      if (bindtextdomain(PACKAGE, LOCALEDIR) == NULL)
64          warn(_("cannot bind message domain: %s\n"), errstr);
65 @@ -173,12 +187,14 @@
66             id3_enabled = false;
67             break;
68  #endif
69 +#ifdef HAVE_ICONV
70          case OPT_IN_CHARSET:
71              in_charset = optarg;
72              break;
73          case OPT_DEVICE_CHARSET:
74              device_charset = optarg;
75              break;
76 +#endif
77         case OPT_FRIENDLY_NAME:
78             if (optarg[0] == '\0')
79                 die(_("friendly name cannot be empty\n"));
80 @@ -319,6 +335,7 @@
81  
82      init_logging(logfilename, timestamp_format);
83  
84 +#ifdef HAVE_ICONV
85      if (device_charset != NULL) {
86          if (in_charset == NULL) {
87  #ifdef HAVE_NL_LANGINFO
88 @@ -335,6 +352,7 @@
89          if (charset_convert == (iconv_t) -1)
90              die(_("cannot create character set convertor\nTry using another value for --in-charset or --device-charset\n"));
91      }
92 +#endif
93  
94      /* We could write pid before initiating logging too.
95       */
96 @@ -396,8 +414,10 @@
97      if (pidfilename != NULL)
98         unlink(pidfilename); /* ignore errors */
99  
100 +#ifdef HAVE_ICONV
101      if (charset_convert != (iconv_t) -1)
102          iconv_close(charset_convert); /* ignore errors (only EINVAL) */
103 +#endif
104  
105      finish_logging(true);
106