10 #include <upnp/upnptools.h>
22 @@ -77,8 +78,7 @@ set_info_file (struct File_Info *info, c
23 info->content_type = ixmlCloneDOMString (content_type);
27 -http_get_info (const char *filename, struct File_Info *info)
28 +int http_get_info (const char *filename, struct File_Info *info)
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);
36 -static UpnpWebFileHandle
37 -http_open (const char *filename, enum UpnpOpenFileMode mode)
38 +UpnpWebFileHandle http_open (const char *filename, enum UpnpOpenFileMode mode)
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);
47 -http_read (UpnpWebFileHandle fh, char *buf, size_t buflen)
48 +int http_read (UpnpWebFileHandle fh, char *buf, size_t buflen)
50 struct web_file_t *file = (struct web_file_t *) fh;
52 @@ -286,8 +284,7 @@ http_read (UpnpWebFileHandle fh, char *b
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)))
62 @@ -296,8 +293,7 @@ http_write (UpnpWebFileHandle fh __attri
67 -http_seek (UpnpWebFileHandle fh, off_t offset, int origin)
68 +int http_seek (UpnpWebFileHandle fh, off_t offset, int origin)
70 struct web_file_t *file = (struct web_file_t *) fh;
72 @@ -371,8 +367,7 @@ http_seek (UpnpWebFileHandle fh, off_t o
77 -http_close (UpnpWebFileHandle fh)
78 +int http_close (UpnpWebFileHandle fh)
80 struct web_file_t *file = (struct web_file_t *) fh;
82 @@ -402,13 +397,3 @@ http_close (UpnpWebFileHandle fh)
87 -struct UpnpVirtualDirCallbacks virtual_dir_callbacks =
99 #include <upnp/upnp.h>
100 #include <upnp/upnptools.h>
102 -struct UpnpVirtualDirCallbacks virtual_dir_callbacks;
103 +int http_get_info (const char *filename, struct File_Info *info);
105 +UpnpWebFileHandle http_open (const char *filename, enum UpnpOpenFileMode mode);
107 +int http_read (UpnpWebFileHandle fh, char *buf, size_t buflen);
109 +int http_seek (UpnpWebFileHandle fh, off_t offset, int origin);
111 +int http_write (UpnpWebFileHandle fh __attribute__((unused)),
112 + char *buf __attribute__((unused)),
113 + size_t buflen __attribute__((unused)));
115 +int http_close (UpnpWebFileHandle fh);
117 #endif /* _HTTP_H_ */
120 @@ -188,7 +188,7 @@ handle_action_request (struct Upnp_Actio
121 if (strcmp (request->DevUDN + 5, ut->udn))
124 - ip = request->CtrlPtIPAddr.s_addr;
125 + ip = (*(struct sockaddr_in *)&request->CtrlPtIPAddr).sin_addr.s_addr;
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)
131 UpnpEnableWebserver (TRUE);
133 - res = UpnpSetVirtualDirCallbacks (&virtual_dir_callbacks);
134 - if (res != UPNP_E_SUCCESS)
136 - log_error (_("Cannot set virtual directory callbacks\n"));
137 - free (description);
140 +#define upnp_set_callback(cb, func) \
142 + res = UpnpVirtualDir_set_##cb##Callback(func); \
143 + if (res != UPNP_E_SUCCESS) \
145 + log_error (_("Cannot set virtual directory callbacks\n")); \
146 + free (description); \
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);
158 res = UpnpAddVirtualDir (VIRTUAL_DIR);
159 if (res != UPNP_E_SUCCESS)
168 #include <upnp/upnp.h>
169 #include <upnp/upnptools.h>
181 --- a/src/presentation.c
182 +++ b/src/presentation.c
190 #if HAVE_LANGINFO_CODESET
191 # include <langinfo.h>
200 #include <upnp/upnp.h>
201 #include <upnp/upnptools.h>