package/dhcp/S80dhcp-server: allow empty INTERFACES
[buildroot-gz.git] / package / ushare / 0001-compile-fixes.patch
blobcfdf5e3404e1721f763871185accc418997f4fe3
1 Patch nixed from OpenWRT svn to fix build breakage.
3 Signed-off-by: Gustavo Zacarias <gustavo@zacarias.com.ar>
5 --- a/src/cds.c
6 +++ b/src/cds.c
7 @@ -20,6 +20,8 @@
8 */
10 #include <stdlib.h>
11 +#include <stdio.h>
12 +#include <string.h>
13 #include <upnp/upnp.h>
14 #include <upnp/upnptools.h>
16 --- a/src/http.c
17 +++ b/src/http.c
18 @@ -25,6 +25,7 @@
19 #include <errno.h>
20 #include <stdio.h>
21 #include <stdlib.h>
22 +#include <string.h>
23 #include <unistd.h>
24 #include <errno.h>
26 @@ -77,8 +78,7 @@ set_info_file (struct File_Info *info, c
27 info->content_type = ixmlCloneDOMString (content_type);
30 -static int
31 -http_get_info (const char *filename, struct File_Info *info)
32 +int http_get_info (const char *filename, struct File_Info *info)
34 extern struct ushare_t *ut;
35 struct upnp_entry_t *entry = NULL;
36 @@ -197,8 +197,7 @@ get_file_memory (const char *fullpath, c
37 return ((UpnpWebFileHandle) file);
40 -static UpnpWebFileHandle
41 -http_open (const char *filename, enum UpnpOpenFileMode mode)
42 +UpnpWebFileHandle http_open (const char *filename, enum UpnpOpenFileMode mode)
44 extern struct ushare_t *ut;
45 struct upnp_entry_t *entry = NULL;
46 @@ -251,8 +250,7 @@ http_open (const char *filename, enum Up
47 return ((UpnpWebFileHandle) file);
50 -static int
51 -http_read (UpnpWebFileHandle fh, char *buf, size_t buflen)
52 +int http_read (UpnpWebFileHandle fh, char *buf, size_t buflen)
54 struct web_file_t *file = (struct web_file_t *) fh;
55 ssize_t len = -1;
56 @@ -286,8 +284,7 @@ http_read (UpnpWebFileHandle fh, char *b
57 return len;
60 -static int
61 -http_write (UpnpWebFileHandle fh __attribute__((unused)),
62 +int http_write (UpnpWebFileHandle fh __attribute__((unused)),
63 char *buf __attribute__((unused)),
64 size_t buflen __attribute__((unused)))
66 @@ -296,8 +293,7 @@ http_write (UpnpWebFileHandle fh __attri
67 return 0;
70 -static int
71 -http_seek (UpnpWebFileHandle fh, off_t offset, int origin)
72 +int http_seek (UpnpWebFileHandle fh, off_t offset, int origin)
74 struct web_file_t *file = (struct web_file_t *) fh;
75 off_t newpos = -1;
76 @@ -371,8 +367,7 @@ http_seek (UpnpWebFileHandle fh, off_t o
77 return 0;
80 -static int
81 -http_close (UpnpWebFileHandle fh)
82 +int http_close (UpnpWebFileHandle fh)
84 struct web_file_t *file = (struct web_file_t *) fh;
86 @@ -402,13 +397,3 @@ http_close (UpnpWebFileHandle fh)
88 return 0;
91 -struct UpnpVirtualDirCallbacks virtual_dir_callbacks =
92 - {
93 - http_get_info,
94 - http_open,
95 - http_read,
96 - http_write,
97 - http_seek,
98 - http_close
99 - };
100 --- a/src/http.h
101 +++ b/src/http.h
102 @@ -25,6 +25,18 @@
103 #include <upnp/upnp.h>
104 #include <upnp/upnptools.h>
106 -struct UpnpVirtualDirCallbacks virtual_dir_callbacks;
107 +int http_get_info (const char *filename, struct File_Info *info);
109 +UpnpWebFileHandle http_open (const char *filename, enum UpnpOpenFileMode mode);
111 +int http_read (UpnpWebFileHandle fh, char *buf, size_t buflen);
113 +int http_seek (UpnpWebFileHandle fh, off_t offset, int origin);
115 +int http_write (UpnpWebFileHandle fh __attribute__((unused)),
116 + char *buf __attribute__((unused)),
117 + size_t buflen __attribute__((unused)));
119 +int http_close (UpnpWebFileHandle fh);
121 #endif /* _HTTP_H_ */
122 --- a/src/ushare.c
123 +++ b/src/ushare.c
124 @@ -188,7 +188,7 @@ handle_action_request (struct Upnp_Actio
125 if (strcmp (request->DevUDN + 5, ut->udn))
126 return;
128 - ip = request->CtrlPtIPAddr.s_addr;
129 + ip = (*(struct sockaddr_in *)&request->CtrlPtIPAddr).sin_addr.s_addr;
130 ip = ntohl (ip);
131 sprintf (val, "%d.%d.%d.%d",
132 (ip >> 24) & 0xFF, (ip >> 16) & 0xFF, (ip >> 8) & 0xFF, ip & 0xFF);
133 @@ -348,13 +348,23 @@ init_upnp (struct ushare_t *ut)
135 UpnpEnableWebserver (TRUE);
137 - res = UpnpSetVirtualDirCallbacks (&virtual_dir_callbacks);
138 - if (res != UPNP_E_SUCCESS)
140 - log_error (_("Cannot set virtual directory callbacks\n"));
141 - free (description);
142 - return -1;
144 +#define upnp_set_callback(cb, func) \
145 + do { \
146 + res = UpnpVirtualDir_set_##cb##Callback(func); \
147 + if (res != UPNP_E_SUCCESS) \
148 + { \
149 + log_error (_("Cannot set virtual directory callbacks\n")); \
150 + free (description); \
151 + return -1; \
152 + } \
153 + } while(0)
155 + upnp_set_callback(GetInfo, http_get_info);
156 + upnp_set_callback(Open, http_open);
157 + upnp_set_callback(Read, http_read);
158 + upnp_set_callback(Seek, http_seek);
159 + upnp_set_callback(Write, http_write);
160 + upnp_set_callback(Close, http_close);
162 res = UpnpAddVirtualDir (VIRTUAL_DIR);
163 if (res != UPNP_E_SUCCESS)
164 --- a/src/cms.c
165 +++ b/src/cms.c
166 @@ -20,6 +20,8 @@
169 #include <stdlib.h>
170 +#include <stdio.h>
171 +#include <string.h>
172 #include <upnp/upnp.h>
173 #include <upnp/upnptools.h>
175 --- a/src/mime.c
176 +++ b/src/mime.c
177 @@ -20,6 +20,7 @@
180 #include <stdlib.h>
181 +#include <stdio.h>
182 #include <string.h>
184 #include "mime.h"
185 --- a/src/presentation.c
186 +++ b/src/presentation.c
187 @@ -19,6 +19,8 @@
190 #include <stdlib.h>
191 +#include <stdio.h>
192 +#include <string.h>
194 #if HAVE_LANGINFO_CODESET
195 # include <langinfo.h>
196 --- a/src/services.c
197 +++ b/src/services.c
198 @@ -20,6 +20,8 @@
201 #include <stdlib.h>
202 +#include <stdio.h>
203 +#include <string.h>
204 #include <upnp/upnp.h>
205 #include <upnp/upnptools.h>