diff --git a/src/buffer.c b/appl/buffer.cpp similarity index 97% rename from src/buffer.c rename to appl/buffer.cpp index 5aa2024..c74c54b 100644 --- a/src/buffer.c +++ b/appl/buffer.cpp @@ -63,7 +63,7 @@ buffer_append (struct buffer_t *buffer, const char *str) if (len >= buffer->capacity) { buffer->capacity = MAX (len + 1, 2 * buffer->capacity); - buffer->buf = realloc (buffer->buf, buffer->capacity); + buffer->buf = (char*)realloc (buffer->buf, buffer->capacity); } strcat (buffer->buf, str); diff --git a/src/buffer.h b/appl/buffer.h similarity index 100% rename from src/buffer.h rename to appl/buffer.h diff --git a/src/cds.c b/appl/cds.cpp similarity index 98% rename from src/cds.c rename to appl/cds.cpp index bc88b3a..e8e3c0b 100644 --- a/src/cds.c +++ b/appl/cds.cpp @@ -22,6 +22,8 @@ #include #include #include +#include +#include #include "ushare.h" #include "services.h" @@ -271,7 +273,7 @@ didl_add_value (struct buffer_t *out, char *param, off_t value) static void didl_add_item (struct buffer_t *out, int item_id, - int parent_id, char *restricted, char *class, char *title, + int parent_id, char *restricted, char *classPointer, char *title, char *protocol_info, off_t size, char *url, char *filter) { buffer_appendf (out, "<%s", DIDL_ITEM); @@ -280,7 +282,7 @@ didl_add_item (struct buffer_t *out, int item_id, didl_add_param (out, DIDL_ITEM_RESTRICTED, restricted); buffer_append (out, ">"); - didl_add_tag (out, DIDL_ITEM_CLASS, class); + didl_add_tag (out, DIDL_ITEM_CLASS, classPointer); didl_add_tag (out, DIDL_ITEM_TITLE, title); if (filter_has_val (filter, DIDL_RES)) @@ -305,7 +307,7 @@ didl_add_item (struct buffer_t *out, int item_id, static void didl_add_container (struct buffer_t *out, int id, int parent_id, int child_count, char *restricted, char *searchable, - char *title, char *class) + char *title, char *classPointer) { buffer_appendf (out, "<%s", DIDL_CONTAINER); @@ -317,7 +319,7 @@ didl_add_container (struct buffer_t *out, int id, int parent_id, didl_add_param (out, DIDL_CONTAINER_SEARCH, searchable); buffer_append (out, ">"); - didl_add_tag (out, DIDL_CONTAINER_CLASS, class); + didl_add_tag (out, DIDL_CONTAINER_CLASS, classPointer); didl_add_tag (out, DIDL_CONTAINER_TITLE, title); buffer_appendf (out, "", DIDL_CONTAINER); diff --git a/src/cds.h b/appl/cds.h similarity index 100% rename from src/cds.h rename to appl/cds.h diff --git a/src/cfgparser.c b/appl/cfgparser.cpp similarity index 100% rename from src/cfgparser.c rename to appl/cfgparser.cpp diff --git a/src/cfgparser.h b/appl/cfgparser.h similarity index 100% rename from src/cfgparser.h rename to appl/cfgparser.h diff --git a/src/cms.c b/appl/cms.cpp similarity index 98% rename from src/cms.c rename to appl/cms.cpp index 69af1b1..1595476 100644 --- a/src/cms.c +++ b/appl/cms.cpp @@ -22,6 +22,8 @@ #include #include #include +#include +#include #include "ushare.h" #include "services.h" @@ -84,7 +86,6 @@ static bool cms_get_protocol_info (struct action_event_t *event) { - extern struct mime_type_t MIME_Type_List[]; struct mime_type_t *list; char *respText = NULL, *respPtr; size_t respLen = 0, len; @@ -142,7 +143,6 @@ cms_get_current_connection_ids (struct action_event_t *event) static bool cms_get_current_connection_info (struct action_event_t *event) { - extern struct mime_type_t MIME_Type_List[]; struct mime_type_t *list = MIME_Type_List; if (!event) diff --git a/src/cms.h b/appl/cms.h similarity index 100% rename from src/cms.h rename to appl/cms.h diff --git a/src/content.c b/appl/content.cpp similarity index 100% rename from src/content.c rename to appl/content.cpp diff --git a/src/content.h b/appl/content.h similarity index 100% rename from src/content.h rename to appl/content.h diff --git a/src/ctrl_telnet.c b/appl/ctrl_telnet.cpp similarity index 99% rename from src/ctrl_telnet.c rename to appl/ctrl_telnet.cpp index 0849d80..7b571e9 100644 --- a/src/ctrl_telnet.c +++ b/appl/ctrl_telnet.cpp @@ -291,7 +291,7 @@ ctrl_telnet_thread (void *a __attribute__ ((unused))) socklen_t sl_addr; /* Create client object */ - client = malloc (sizeof (ctrl_telnet_client)); + client = (ctrl_telnet_client *)malloc (sizeof (ctrl_telnet_client)); if (!client) { @@ -628,7 +628,7 @@ ctrl_telnet_register (const char *funcname, { telnet_function_list *function; - function = malloc (sizeof (telnet_function_list)); + function = (telnet_function_list *)malloc (sizeof (telnet_function_list)); function->name = strdup (funcname); /* Mayby use strndup...? */ function->description = description ? strdup (description) : NULL; function->function = funcptr; @@ -689,7 +689,7 @@ ctrl_telnet_tokenize (char *raw, int *argc, char ***argv) } /* Create argv */ - *argv = malloc (sizeof (char **) * ((*argc) + 1)); + *argv = (char **)malloc (sizeof (char **) * ((*argc) + 1)); /* (2/3) Parse throu one more time, this time filling argv (Pass 2 / 3) */ i = 0; diff --git a/src/ctrl_telnet.h b/appl/ctrl_telnet.h similarity index 100% rename from src/ctrl_telnet.h rename to appl/ctrl_telnet.h diff --git a/src/gettext.h b/appl/gettext.h similarity index 100% rename from src/gettext.h rename to appl/gettext.h diff --git a/src/http.c b/appl/http.cpp similarity index 94% rename from src/http.c rename to appl/http.cpp index fce24b1..447b85a 100644 --- a/src/http.c +++ b/appl/http.cpp @@ -27,6 +27,8 @@ #include #include #include +#include +#include #include #include @@ -187,10 +189,10 @@ get_file_memory (const char *fullpath, const char *description, { struct web_file_t *file; - file = malloc (sizeof (struct web_file_t)); + file = (struct web_file_t *)malloc (sizeof (struct web_file_t)); file->fullpath = strdup (fullpath); file->pos = 0; - file->type = FILE_MEMORY; + file->type = web_file_t::FILE_MEMORY; file->detail.memory.contents = strdup (description); file->detail.memory.len = length; @@ -241,10 +243,10 @@ http_open (const char *filename, enum UpnpOpenFileMode mode) if (fd < 0) return NULL; - file = malloc (sizeof (struct web_file_t)); + file = (struct web_file_t *)malloc (sizeof (struct web_file_t)); file->fullpath = strdup (entry->fullpath); file->pos = 0; - file->type = FILE_LOCAL; + file->type = web_file_t::FILE_LOCAL; file->detail.local.entry = entry; file->detail.local.fd = fd; @@ -264,11 +266,11 @@ http_read (UpnpWebFileHandle fh, char *buf, size_t buflen) switch (file->type) { - case FILE_LOCAL: + case web_file_t::FILE_LOCAL: log_verbose ("Read local file.\n"); len = read (file->detail.local.fd, buf, buflen); break; - case FILE_MEMORY: + case web_file_t::FILE_MEMORY: log_verbose ("Read file from memory.\n"); len = (size_t) MIN (buflen, file->detail.memory.len - file->pos); memcpy (buf, file->detail.memory.contents + file->pos, (size_t) len); @@ -323,7 +325,7 @@ http_seek (UpnpWebFileHandle fh, off_t offset, int origin) log_verbose ("Attempting to seek by %lld from end (was at %lld) in %s\n", offset, file->pos, file->fullpath); - if (file->type == FILE_LOCAL) + if (file->type == web_file_t::FILE_LOCAL) { struct stat sb; if (stat (file->fullpath, &sb) < 0) @@ -333,15 +335,15 @@ http_seek (UpnpWebFileHandle fh, off_t offset, int origin) return -1; } newpos = sb.st_size + offset; - } - else if (file->type == FILE_MEMORY) + } else if (file->type == web_file_t::FILE_MEMORY) { newpos = file->detail.memory.len + offset; + } break; } switch (file->type) { - case FILE_LOCAL: + case web_file_t::FILE_LOCAL: /* Just make sure we cannot seek before start of file. */ if (newpos < 0) { @@ -357,7 +359,7 @@ http_seek (UpnpWebFileHandle fh, off_t offset, int origin) return -1; } break; - case FILE_MEMORY: + case web_file_t::FILE_MEMORY: if (newpos < 0 || newpos > file->detail.memory.len) { log_verbose ("%s: cannot seek: %s\n", file->fullpath, strerror (EINVAL)); @@ -383,10 +385,10 @@ http_close (UpnpWebFileHandle fh) switch (file->type) { - case FILE_LOCAL: + case web_file_t::FILE_LOCAL: close (file->detail.local.fd); break; - case FILE_MEMORY: + case web_file_t::FILE_MEMORY: /* no close operation */ if (file->detail.memory.contents) free (file->detail.memory.contents); diff --git a/src/http.h b/appl/http.h similarity index 94% rename from src/http.h rename to appl/http.h index 0e329a4..3f5cb6f 100644 --- a/src/http.h +++ b/appl/http.h @@ -25,6 +25,6 @@ #include #include -struct UpnpVirtualDirCallbacks virtual_dir_callbacks; +extern struct UpnpVirtualDirCallbacks virtual_dir_callbacks; #endif /* _HTTP_H_ */ diff --git a/appl/main.cpp b/appl/main.cpp new file mode 100644 index 0000000..e69de29 diff --git a/src/metadata.c b/appl/metadata.cpp similarity index 99% rename from src/metadata.c rename to appl/metadata.cpp index 3a3610c..d928143 100644 --- a/src/metadata.c +++ b/appl/metadata.cpp @@ -26,6 +26,8 @@ #include #include #include +#include +#include #include #include @@ -89,7 +91,7 @@ is_valid_extension (const char *extension) static int get_list_length (void *list) { - void **l = list; + void **l = (void **)list; int n = 0; while (*(l++)) diff --git a/src/metadata.h b/appl/metadata.h similarity index 100% rename from src/metadata.h rename to appl/metadata.h diff --git a/src/mime.c b/appl/mime.cpp similarity index 98% rename from src/mime.c rename to appl/mime.cpp index b0d4294..1a680bf 100644 --- a/src/mime.c +++ b/appl/mime.cpp @@ -21,6 +21,8 @@ #include #include +#include +#include #include "mime.h" #include "ushare.h" @@ -31,7 +33,7 @@ #define UPNP_PLAYLIST "object.item.playlistItem" #define UPNP_TEXT "object.item.textItem" -const struct mime_type_t MIME_Type_List[] = { +struct mime_type_t MIME_Type_List[] = { /* Video files */ { "asf", UPNP_VIDEO, "http-get:*:video/x-ms-asf:"}, { "avc", UPNP_VIDEO, "http-get:*:video/avi:"}, diff --git a/src/mime.h b/appl/mime.h similarity index 96% rename from src/mime.h rename to appl/mime.h index fa6fece..fa77c28 100644 --- a/src/mime.h +++ b/appl/mime.h @@ -29,4 +29,6 @@ struct mime_type_t { char *mime_get_protocol (struct mime_type_t *mime); +extern struct mime_type_t MIME_Type_List[]; + #endif /* _MIME_H */ diff --git a/src/minmax.h b/appl/minmax.h similarity index 100% rename from src/minmax.h rename to appl/minmax.h diff --git a/src/msr.c b/appl/msr.cpp similarity index 98% rename from src/msr.c rename to appl/msr.cpp index e406c32..cd2a3bd 100644 --- a/src/msr.c +++ b/appl/msr.cpp @@ -20,6 +20,8 @@ #include #include +#include +#include #include "ushare.h" #include "services.h" diff --git a/src/msr.h b/appl/msr.h similarity index 100% rename from src/msr.h rename to appl/msr.h diff --git a/src/osdep.c b/appl/osdep.cpp similarity index 98% rename from src/osdep.c rename to appl/osdep.cpp index 67f4f4c..433ea5a 100644 --- a/src/osdep.c +++ b/appl/osdep.cpp @@ -26,6 +26,8 @@ #include #include #include +#include +#include #include "osdep.h" diff --git a/src/osdep.h b/appl/osdep.h similarity index 100% rename from src/osdep.h rename to appl/osdep.h diff --git a/src/presentation.c b/appl/presentation.cpp similarity index 100% rename from src/presentation.c rename to appl/presentation.cpp diff --git a/src/presentation.h b/appl/presentation.h similarity index 100% rename from src/presentation.h rename to appl/presentation.h diff --git a/src/redblack.c b/appl/redblack.cpp similarity index 99% rename from src/redblack.c rename to appl/redblack.cpp index 036e5c9..64f99ca 100644 --- a/src/redblack.c +++ b/appl/redblack.cpp @@ -27,6 +27,8 @@ static char rcsid[]="$Id: redblack.c,v 1.9 2003/10/24 01:31:21 damo Exp $"; #include #include #include +#include +#include #include "redblack.h" #define assert(expr) diff --git a/src/redblack.h b/appl/redblack.h similarity index 100% rename from src/redblack.h rename to appl/redblack.h diff --git a/src/services.c b/appl/services.cpp similarity index 99% rename from src/services.c rename to appl/services.cpp index 9907312..a35f503 100644 --- a/src/services.c +++ b/appl/services.cpp @@ -22,6 +22,8 @@ #include #include #include +#include +#include #include "ushare.h" #include "services.h" diff --git a/src/services.h b/appl/services.h similarity index 100% rename from src/services.h rename to appl/services.h diff --git a/src/trace.c b/appl/trace.cpp similarity index 100% rename from src/trace.c rename to appl/trace.cpp diff --git a/src/trace.h b/appl/trace.h similarity index 100% rename from src/trace.h rename to appl/trace.h diff --git a/src/ushare.1 b/appl/ushare.1 similarity index 100% rename from src/ushare.1 rename to appl/ushare.1 diff --git a/src/ushare.c b/appl/ushare.cpp similarity index 99% rename from src/ushare.c rename to appl/ushare.cpp index d2cc930..c3ce317 100644 --- a/src/ushare.c +++ b/appl/ushare.cpp @@ -27,6 +27,8 @@ #include #include #include +#include +#include #if (defined(BSD) || defined(__FreeBSD__) || defined(__APPLE__)) @@ -783,7 +785,7 @@ main (int argc, char **argv) { char *name; - name = malloc (strlen (XBOX_MODEL_NAME) + strlen (ut->model_name) + 4); + name = (char*)malloc (strlen (XBOX_MODEL_NAME) + strlen (ut->model_name) + 4); sprintf (name, "%s (%s)", XBOX_MODEL_NAME, ut->model_name); free (ut->model_name); ut->model_name = strdup (name); diff --git a/src/ushare.h b/appl/ushare.h similarity index 100% rename from src/ushare.h rename to appl/ushare.h diff --git a/src/util_iconv.c b/appl/util_iconv.cpp similarity index 99% rename from src/util_iconv.c rename to appl/util_iconv.cpp index 0b1e289..6b1abb2 100644 --- a/src/util_iconv.c +++ b/appl/util_iconv.cpp @@ -22,6 +22,8 @@ #include #include #include +#include +#include #include "util_iconv.h" diff --git a/src/util_iconv.h b/appl/util_iconv.h similarity index 100% rename from src/util_iconv.h rename to appl/util_iconv.h diff --git a/lutin_ushare.py b/lutin_ushare.py index d75a3cb..6dd2072 100644 --- a/lutin_ushare.py +++ b/lutin_ushare.py @@ -32,23 +32,23 @@ def create(target, module_name): my_module = module.Module(__file__, module_name, get_type()) my_module.add_extra_compile_flags() my_module.add_src_file([ - 'src/http.c', - 'src/services.c', - 'src/ushare.c', - 'src/content.c', - 'src/trace.c', - 'src/cms.c', - 'src/redblack.c', - 'src/util_iconv.c', - 'src/osdep.c', - 'src/mime.c', - 'src/cfgparser.c', - 'src/metadata.c', - 'src/msr.c', - 'src/cds.c', - 'src/presentation.c', - 'src/buffer.c', - 'src/ctrl_telnet.c' + 'appl/http.cpp', + 'appl/services.cpp', + 'appl/ushare.cpp', + 'appl/content.cpp', + 'appl/trace.cpp', + 'appl/cms.cpp', + 'appl/redblack.cpp', + 'appl/util_iconv.cpp', + 'appl/osdep.cpp', + 'appl/mime.cpp', + 'appl/cfgparser.cpp', + 'appl/metadata.cpp', + 'appl/msr.cpp', + 'appl/cds.cpp', + 'appl/presentation.cpp', + 'appl/buffer.cpp', + 'appl/ctrl_telnet.cpp' ]) my_module.add_path(tools.get_current_path(__file__)) my_module.compile_flags('c', [ diff --git a/src/Makefile b/src/Makefile deleted file mode 100644 index bd933d1..0000000 --- a/src/Makefile +++ /dev/null @@ -1,87 +0,0 @@ -ifeq (,$(wildcard ../config.mak)) -$(error "../config.mak is not present, run configure !") -endif -include ../config.mak - -PROG = ushare - -EXTRADIST = ushare.1 \ - cds.h \ - cms.h \ - msr.h \ - http.h \ - presentation.h \ - metadata.h \ - mime.h \ - services.h \ - buffer.h \ - util_iconv.h \ - content.h \ - cfgparser.h \ - trace.h \ - redblack.h \ - osdep.h \ - ctrl_telnet.h \ - ushare.h \ - gettext.h \ - minmax.h \ - - -SRCS = \ - cds.c \ - cms.c \ - msr.c \ - http.c \ - presentation.c \ - metadata.c \ - mime.c \ - services.c \ - buffer.c \ - util_iconv.c \ - content.c \ - cfgparser.c \ - trace.c \ - redblack.c \ - osdep.c \ - ctrl_telnet.c \ - ushare.c - -OBJS = $(SRCS:.c=.o) - -.SUFFIXES: .c .o - -all: depend $(PROG) - -.c.o: - $(CC) -c $(CFLAGS) $(OPTFLAGS) -o $@ $< - -$(PROG): $(OBJS) - $(CC) $(OBJS) $(LDFLAGS) $(EXTRALIBS) -o $@ - -clean: - -$(RM) -f *.o $(PROG) - -$(RM) -f .depend - -distclean: - -install: $(PROG) - $(INSTALL) -d $(bindir) - $(INSTALL) $(PROG) $(bindir) - $(STRIP) $(INSTALLSTRIP) $(bindir)/$(PROG) - -depend: - $(CC) -I.. -MM $(CFLAGS) $(SRCS) 1>.depend - -.PHONY: clean distclean install depend - -dist-all: - cp $(EXTRADIST) $(SRCS) Makefile $(DIST) - -.PHONY: dist-all - -# -# include dependency files if they exist -# -ifneq ($(wildcard .depend),) -include .depend -endif