1
0

patch-src_main_c 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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. };
  30. +#ifdef HAVE_ICONV
  31. static iconv_t utf8_to_device = (iconv_t) -1;
  32. static iconv_t utf8_to_log = (iconv_t) -1;
  33. static iconv_t fs_to_utf8 = (iconv_t) -1;
  34. +#endif
  35. const char version_etc_copyright[] = "Copyright (C) 2005, 2006 Oskar Liljeblad.";
  36. char *
  37. convert_string_to_device(const char *str)
  38. {
  39. +#ifdef HAVE_ICONV
  40. char *out;
  41. if (utf8_to_device == (iconv_t) -1)
  42. return xstrdup(str);
  43. @@ -107,12 +114,15 @@ convert_string_to_device(const char *str
  44. if (out != NULL)
  45. return out;
  46. warn(_("%s: cannot convert to device character set: %s\n"), quotearg(str), errstr);
  47. +#else
  48. return xstrdup(str);
  49. +#endif
  50. }
  51. char *
  52. convert_string_to_log(const char *str)
  53. {
  54. +#ifdef HAVE_ICONV
  55. char *out;
  56. if (utf8_to_log == (iconv_t) -1)
  57. @@ -121,7 +131,9 @@ convert_string_to_log(const char *str)
  58. if (out != NULL)
  59. return out;
  60. /* Cannot warn here - would deadlock! */
  61. +#else
  62. return xstrdup(str);
  63. +#endif
  64. }
  65. static char *cache_fs_str = NULL;
  66. @@ -129,6 +141,7 @@ static char *cache_fs_str = NULL;
  67. char *
  68. conv_filename(const char *str)
  69. {
  70. +#ifdef HAVE_ICONV
  71. free(cache_fs_str);
  72. if (fs_to_utf8 == (iconv_t) -1) {
  73. cache_fs_str = xstrdup(str);
  74. @@ -140,6 +153,9 @@ conv_filename(const char *str)
  75. }
  76. }
  77. return cache_fs_str;
  78. +#else
  79. + return xstrdup(str);
  80. +#endif
  81. }
  82. static void
  83. @@ -188,8 +204,10 @@ main(int argc, char **argv)
  84. set_program_name(argv[0]);
  85. set_quoting_style(0, escape_quoting_style);
  86. +#ifdef LOCALE
  87. if (setlocale(LC_ALL, "") == NULL)
  88. warn(_("cannot set locale: %s\n"), errstr);
  89. +#endif
  90. #ifdef ENABLE_NLS
  91. if (bindtextdomain(PACKAGE, LOCALEDIR) == NULL)
  92. warn(_("cannot bind message domain: %s\n"), errstr);
  93. @@ -215,6 +233,7 @@ main(int argc, char **argv)
  94. case OPT_DISABLE_TAGS:
  95. tags_enabled = false;
  96. break;
  97. +#ifdef HAVE_ICONV
  98. case OPT_FS_CHARSET:
  99. fs_charset = optarg;
  100. break;
  101. @@ -224,6 +243,7 @@ main(int argc, char **argv)
  102. case OPT_LOG_CHARSET:
  103. log_charset = optarg;
  104. break;
  105. +#endif
  106. case OPT_FRIENDLY_NAME:
  107. if (optarg[0] == '\0')
  108. die(_("friendly name cannot be empty\n"));
  109. @@ -294,9 +314,11 @@ main(int argc, char **argv)
  110. printf(_("Run the UPnP media server.\n\n"));
  111. printf(_(" --friendly-name=NAME set display name for media server\n"));
  112. printf(_(" --disable-tags do not scan files for tags\n"));
  113. +#ifdef HAVE_ICONV
  114. printf(_(" --fs-charset=CHARSET character set used in file names\n"));
  115. printf(_(" --device-charset=CHARSET character set used in the player device\n"));
  116. printf(_(" --log-charset=CHARSET character set used in logs and display\n"));
  117. +#endif
  118. printf(_(" -v, --verbose[=LEVEL] set verbosity level (0-4)\n"));
  119. printf(_(" --pid-file=FILE write pid to FILE when up and running\n"));
  120. printf(_(" -i, --interface=NAME listen on a specific interface\n"));
  121. @@ -371,6 +393,7 @@ main(int argc, char **argv)
  122. if (fs_charset == NULL && getenv("G_BROKEN_FILENAMES") != NULL)
  123. fs_charset = nl_langinfo(CODESET);
  124. #endif
  125. +#ifdef HAVE_ICONV
  126. if (fs_charset != NULL) {
  127. fs_to_utf8 = iconv_open("UTF-8", fs_charset);
  128. if (fs_to_utf8 == (iconv_t) -1)
  129. @@ -395,6 +418,7 @@ main(int argc, char **argv)
  130. die(_("cannot create character set convertor from %s to %s\n"), "UTF-8", quotearg(log_charset));
  131. }
  132. say(4, _("Using log character set %s\n"), quote(log_charset == NULL ? "UTF-8" : log_charset));
  133. +#endif
  134. init_logging(logfilename, timestamp_format);
  135. @@ -478,12 +502,14 @@ main(int argc, char **argv)
  136. finish_logging(true);
  137. +#ifdef HAVE_ICONV
  138. if (fs_to_utf8 != (iconv_t) -1)
  139. iconv_close(fs_to_utf8); /* ignore errors (only EINVAL) */
  140. if (utf8_to_device != (iconv_t) -1)
  141. iconv_close(utf8_to_device); /* ignore errors (only EINVAL) */
  142. if (utf8_to_log != (iconv_t) -1)
  143. iconv_close(utf8_to_log); /* ignore errors (only EINVAL) */
  144. +#endif
  145. free(cache_fs_str);