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