1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
$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);
|