0001-compile-fixes.patch 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. Patch nixed from OpenWRT svn to fix build breakage.
  2. Signed-off-by: Gustavo Zacarias <gustavo@zacarias.com.ar>
  3. --- a/src/cds.c
  4. +++ b/src/cds.c
  5. @@ -20,6 +20,8 @@
  6. */
  7. #include <stdlib.h>
  8. +#include <stdio.h>
  9. +#include <string.h>
  10. #include <upnp/upnp.h>
  11. #include <upnp/upnptools.h>
  12. --- a/src/http.c
  13. +++ b/src/http.c
  14. @@ -25,6 +25,7 @@
  15. #include <errno.h>
  16. #include <stdio.h>
  17. #include <stdlib.h>
  18. +#include <string.h>
  19. #include <unistd.h>
  20. #include <errno.h>
  21. @@ -77,8 +78,7 @@ set_info_file (struct File_Info *info, c
  22. info->content_type = ixmlCloneDOMString (content_type);
  23. }
  24. -static int
  25. -http_get_info (const char *filename, struct File_Info *info)
  26. +int http_get_info (const char *filename, struct File_Info *info)
  27. {
  28. extern struct ushare_t *ut;
  29. struct upnp_entry_t *entry = NULL;
  30. @@ -197,8 +197,7 @@ get_file_memory (const char *fullpath, c
  31. return ((UpnpWebFileHandle) file);
  32. }
  33. -static UpnpWebFileHandle
  34. -http_open (const char *filename, enum UpnpOpenFileMode mode)
  35. +UpnpWebFileHandle http_open (const char *filename, enum UpnpOpenFileMode mode)
  36. {
  37. extern struct ushare_t *ut;
  38. struct upnp_entry_t *entry = NULL;
  39. @@ -251,8 +250,7 @@ http_open (const char *filename, enum Up
  40. return ((UpnpWebFileHandle) file);
  41. }
  42. -static int
  43. -http_read (UpnpWebFileHandle fh, char *buf, size_t buflen)
  44. +int http_read (UpnpWebFileHandle fh, char *buf, size_t buflen)
  45. {
  46. struct web_file_t *file = (struct web_file_t *) fh;
  47. ssize_t len = -1;
  48. @@ -286,8 +284,7 @@ http_read (UpnpWebFileHandle fh, char *b
  49. return len;
  50. }
  51. -static int
  52. -http_write (UpnpWebFileHandle fh __attribute__((unused)),
  53. +int http_write (UpnpWebFileHandle fh __attribute__((unused)),
  54. char *buf __attribute__((unused)),
  55. size_t buflen __attribute__((unused)))
  56. {
  57. @@ -296,8 +293,7 @@ http_write (UpnpWebFileHandle fh __attri
  58. return 0;
  59. }
  60. -static int
  61. -http_seek (UpnpWebFileHandle fh, off_t offset, int origin)
  62. +int http_seek (UpnpWebFileHandle fh, off_t offset, int origin)
  63. {
  64. struct web_file_t *file = (struct web_file_t *) fh;
  65. off_t newpos = -1;
  66. @@ -371,8 +367,7 @@ http_seek (UpnpWebFileHandle fh, off_t o
  67. return 0;
  68. }
  69. -static int
  70. -http_close (UpnpWebFileHandle fh)
  71. +int http_close (UpnpWebFileHandle fh)
  72. {
  73. struct web_file_t *file = (struct web_file_t *) fh;
  74. @@ -402,13 +397,3 @@ http_close (UpnpWebFileHandle fh)
  75. return 0;
  76. }
  77. -
  78. -struct UpnpVirtualDirCallbacks virtual_dir_callbacks =
  79. - {
  80. - http_get_info,
  81. - http_open,
  82. - http_read,
  83. - http_write,
  84. - http_seek,
  85. - http_close
  86. - };
  87. --- a/src/http.h
  88. +++ b/src/http.h
  89. @@ -25,6 +25,18 @@
  90. #include <upnp/upnp.h>
  91. #include <upnp/upnptools.h>
  92. -struct UpnpVirtualDirCallbacks virtual_dir_callbacks;
  93. +int http_get_info (const char *filename, struct File_Info *info);
  94. +
  95. +UpnpWebFileHandle http_open (const char *filename, enum UpnpOpenFileMode mode);
  96. +
  97. +int http_read (UpnpWebFileHandle fh, char *buf, size_t buflen);
  98. +
  99. +int http_seek (UpnpWebFileHandle fh, off_t offset, int origin);
  100. +
  101. +int http_write (UpnpWebFileHandle fh __attribute__((unused)),
  102. + char *buf __attribute__((unused)),
  103. + size_t buflen __attribute__((unused)));
  104. +
  105. +int http_close (UpnpWebFileHandle fh);
  106. #endif /* _HTTP_H_ */
  107. --- a/src/ushare.c
  108. +++ b/src/ushare.c
  109. @@ -188,7 +188,7 @@ handle_action_request (struct Upnp_Actio
  110. if (strcmp (request->DevUDN + 5, ut->udn))
  111. return;
  112. - ip = request->CtrlPtIPAddr.s_addr;
  113. + ip = (*(struct sockaddr_in *)&request->CtrlPtIPAddr).sin_addr.s_addr;
  114. ip = ntohl (ip);
  115. sprintf (val, "%d.%d.%d.%d",
  116. (ip >> 24) & 0xFF, (ip >> 16) & 0xFF, (ip >> 8) & 0xFF, ip & 0xFF);
  117. @@ -348,13 +348,23 @@ init_upnp (struct ushare_t *ut)
  118. UpnpEnableWebserver (TRUE);
  119. - res = UpnpSetVirtualDirCallbacks (&virtual_dir_callbacks);
  120. - if (res != UPNP_E_SUCCESS)
  121. - {
  122. - log_error (_("Cannot set virtual directory callbacks\n"));
  123. - free (description);
  124. - return -1;
  125. - }
  126. +#define upnp_set_callback(cb, func) \
  127. + do { \
  128. + res = UpnpVirtualDir_set_##cb##Callback(func); \
  129. + if (res != UPNP_E_SUCCESS) \
  130. + { \
  131. + log_error (_("Cannot set virtual directory callbacks\n")); \
  132. + free (description); \
  133. + return -1; \
  134. + } \
  135. + } while(0)
  136. +
  137. + upnp_set_callback(GetInfo, http_get_info);
  138. + upnp_set_callback(Open, http_open);
  139. + upnp_set_callback(Read, http_read);
  140. + upnp_set_callback(Seek, http_seek);
  141. + upnp_set_callback(Write, http_write);
  142. + upnp_set_callback(Close, http_close);
  143. res = UpnpAddVirtualDir (VIRTUAL_DIR);
  144. if (res != UPNP_E_SUCCESS)
  145. --- a/src/cms.c
  146. +++ b/src/cms.c
  147. @@ -20,6 +20,8 @@
  148. */
  149. #include <stdlib.h>
  150. +#include <stdio.h>
  151. +#include <string.h>
  152. #include <upnp/upnp.h>
  153. #include <upnp/upnptools.h>
  154. --- a/src/mime.c
  155. +++ b/src/mime.c
  156. @@ -20,6 +20,7 @@
  157. */
  158. #include <stdlib.h>
  159. +#include <stdio.h>
  160. #include <string.h>
  161. #include "mime.h"
  162. --- a/src/presentation.c
  163. +++ b/src/presentation.c
  164. @@ -19,6 +19,8 @@
  165. */
  166. #include <stdlib.h>
  167. +#include <stdio.h>
  168. +#include <string.h>
  169. #if HAVE_LANGINFO_CODESET
  170. # include <langinfo.h>
  171. --- a/src/services.c
  172. +++ b/src/services.c
  173. @@ -20,6 +20,8 @@
  174. */
  175. #include <stdlib.h>
  176. +#include <stdio.h>
  177. +#include <string.h>
  178. #include <upnp/upnp.h>
  179. #include <upnp/upnptools.h>