aboutsummaryrefslogtreecommitdiff
path: root/lib/libXBMS
diff options
context:
space:
mode:
authortheuni <theuni-nospam-@xbmc.org>2011-01-24 16:05:21 -0500
committertheuni <theuni-nospam-@xbmc.org>2011-01-24 16:05:21 -0500
commitc51b1189e3d5353e842991f5859ddcea0f73e426 (patch)
treeef2cb8a6184699aa614f3655dca4ce661cdc108e /lib/libXBMS
parentbe61ebdc9e897fe40c6f371111724de79ddee8d5 (diff)
Merged cptspiff's code-reshuffle branch.
Squashed commit due to build breakage during code-reshuffle history. Conflicts: xbmc/Util.cpp xbmc/cdrip/CDDARipper.cpp xbmc/filesystem/Directory.cpp xbmc/filesystem/File.cpp
Diffstat (limited to 'lib/libXBMS')
-rw-r--r--lib/libXBMS/Makefile.in8
-rw-r--r--lib/libXBMS/ccbuffer.c184
-rw-r--r--lib/libXBMS/ccbuffer.h59
-rw-r--r--lib/libXBMS/ccincludes.h75
-rw-r--r--lib/libXBMS/ccutil.c110
-rw-r--r--lib/libXBMS/ccutil.h50
-rw-r--r--lib/libXBMS/ccxclient.c1262
-rw-r--r--lib/libXBMS/ccxclient.h219
-rw-r--r--lib/libXBMS/ccxclientconnxbox.c196
-rw-r--r--lib/libXBMS/ccxdiscover.c228
-rw-r--r--lib/libXBMS/ccxencode.c181
-rw-r--r--lib/libXBMS/ccxencode.h50
-rw-r--r--lib/libXBMS/ccxmltrans.c161
-rw-r--r--lib/libXBMS/ccxmltrans.h37
-rw-r--r--lib/libXBMS/ccxpacket.h81
-rw-r--r--lib/libXBMS/ccxversion.h3
-rw-r--r--lib/libXBMS/libXBMS/libXBMS.vcproj226
-rw-r--r--lib/libXBMS/libXBMS/libXBMS.vcxproj100
-rw-r--r--lib/libXBMS/libXBMS/libXBMS.vcxproj.filters62
19 files changed, 3292 insertions, 0 deletions
diff --git a/lib/libXBMS/Makefile.in b/lib/libXBMS/Makefile.in
new file mode 100644
index 0000000000..75d21ddbe3
--- /dev/null
+++ b/lib/libXBMS/Makefile.in
@@ -0,0 +1,8 @@
+CFLAGS += -D_LINUX
+
+LIB=libxbms-@ARCH@.a
+
+SRCS=ccbuffer.c ccutil.c ccxclient.c ccxclientconnxbox.c ccxdiscover.c ccxencode.c ccxmltrans.c
+
+include ../../Makefile.include
+
diff --git a/lib/libXBMS/ccbuffer.c b/lib/libXBMS/ccbuffer.c
new file mode 100644
index 0000000000..ae55d7fa70
--- /dev/null
+++ b/lib/libXBMS/ccbuffer.c
@@ -0,0 +1,184 @@
+// Place the code and data below here into the LIBXBMS section.
+#ifndef __GNUC__
+#pragma code_seg( "LIBXBMS" )
+#pragma data_seg( "LIBXBMS_RW" )
+#pragma bss_seg( "LIBXBMS_RW" )
+#pragma const_seg( "LIBXBMS_RD" )
+#pragma comment(linker, "/merge:LIBXBMS_RW=LIBXBMS")
+#pragma comment(linker, "/merge:LIBXBMS_RD=LIBXBMS")
+#endif
+/* -*- c -*-
+ *
+ * ----------------------------------------------------------------------
+ * Buffer stuff.
+ * ----------------------------------------------------------------------
+ *
+ * Copyright (c) 2002-2003 by PuhPuh
+ *
+ * This code is copyrighted property of the author. It can still
+ * be used for any non-commercial purpose following conditions:
+ *
+ * 1) This copyright notice is not removed.
+ * 2) Source code follows any distribution of the software
+ * if possible.
+ * 3) Copyright notice above is found in the documentation
+ * of the distributed software.
+ *
+ * Any express or implied warranties are disclaimed. Author is
+ * not liable for any direct or indirect damages caused by the use
+ * of this software.
+ *
+ * ----------------------------------------------------------------------
+ *
+ * This code has been integrated into XBMC Media Center.
+ * As such it can me copied, redistributed and modified under
+ * the same conditions as the XBMC itself.
+ *
+ */
+
+
+#include "ccincludes.h"
+#include "ccbuffer.h"
+
+CcBuffer cc_buffer_allocate(void)
+{
+ CcBuffer buffer;
+
+ buffer = cc_xcalloc(1, sizeof (*buffer));
+ return buffer;
+}
+
+void cc_buffer_free(CcBuffer buffer)
+{
+ cc_buffer_uninit(buffer);
+ cc_xfree(buffer);
+}
+
+void cc_buffer_init(CcBuffer buffer)
+{
+ memset(buffer, 0, sizeof (*buffer));
+}
+
+void cc_buffer_uninit(CcBuffer buffer)
+{
+ if (buffer != NULL)
+ cc_xfree(buffer->data);
+ memset(buffer, 0, sizeof (*buffer));
+}
+
+size_t cc_buffer_len(CcBuffer buffer)
+{
+ return buffer->len;
+}
+
+unsigned char *cc_buffer_ptr(CcBuffer buffer)
+{
+ return buffer->data;
+}
+
+void cc_buffer_append(CcBuffer buffer, const unsigned char *data, size_t len)
+{
+ size_t ol;
+
+ ol = cc_buffer_len(buffer);
+ cc_buffer_append_space(buffer, len);
+ memcpy(buffer->data + ol, data, len);
+}
+
+void cc_buffer_prepend(CcBuffer buffer, const unsigned char *data, size_t len)
+{
+ size_t ol;
+
+ ol = cc_buffer_len(buffer);
+ cc_buffer_append_space(buffer, len);
+ memmove(buffer->data + len, buffer->data, ol);
+ memcpy(buffer->data, data, len);
+}
+
+void cc_buffer_append_space(CcBuffer buffer, size_t len)
+{
+ if (len > 0)
+ {
+ if (buffer->data == NULL)
+ {
+ buffer->data = cc_xmalloc(len);
+ buffer->len = 0;
+ }
+ else
+ {
+ buffer->data = cc_xrealloc(buffer->data, buffer->len + len);
+ }
+ buffer->len += len;
+ }
+}
+
+void cc_buffer_append_string(CcBuffer buffer, const char *string)
+{
+ if (*string != '\0')
+ cc_buffer_append(buffer, (const unsigned char *)string, strlen(string));
+}
+
+void cc_buffer_prepend_string(CcBuffer buffer, const char *string)
+{
+ if (*string != '\0')
+ cc_buffer_prepend(buffer, (const unsigned char *)string, strlen(string));
+}
+
+void cc_buffer_consume(CcBuffer buffer, size_t len)
+{
+ if (len > buffer->len)
+ {
+ cc_fatal("Buffer underflow.");
+ }
+ else if (len == 0)
+ {
+ /*NOTHING*/;
+ }
+ else if (len == buffer->len)
+ {
+ buffer->len = 0;
+ }
+ else
+ {
+ memmove(buffer->data, buffer->data + len, buffer->len - len);
+ buffer->len -= len;
+ }
+}
+
+void cc_buffer_consume_end(CcBuffer buffer, size_t len)
+{
+ if (len > buffer->len)
+ {
+ cc_fatal("Buffer underflow.");
+ }
+ else if (len == 0)
+ {
+ /*NOTHING*/;
+ }
+ else if (len == buffer->len)
+ {
+ buffer->len = 0;
+ }
+ else
+ {
+ buffer->len -= len;
+ }
+}
+
+void cc_buffer_clear(CcBuffer buffer)
+{
+ buffer->len = 0;
+}
+
+void cc_buffer_steal(CcBuffer buffer, unsigned char **data, size_t *len)
+{
+ buffer->data = cc_xrealloc(buffer->data, buffer->len + 1);
+ buffer->data[buffer->len] = '\0';
+ *data = buffer->data;
+ if (len != NULL)
+ *len = buffer->len;
+ buffer->data = NULL;
+ buffer->len = 0;
+}
+
+/* eof (ccbuffer.c) */
diff --git a/lib/libXBMS/ccbuffer.h b/lib/libXBMS/ccbuffer.h
new file mode 100644
index 0000000000..bede1a0f0c
--- /dev/null
+++ b/lib/libXBMS/ccbuffer.h
@@ -0,0 +1,59 @@
+/* -*- c -*-
+ *
+ * ----------------------------------------------------------------------
+ * Buffer stuff.
+ * ----------------------------------------------------------------------
+ *
+ * Copyright (c) 2002-2003 by PuhPuh
+ *
+ * This code is copyrighted property of the author. It can still
+ * be used for any non-commercial purpose following conditions:
+ *
+ * 1) This copyright notice is not removed.
+ * 2) Source code follows any distribution of the software
+ * if possible.
+ * 3) Copyright notice above is found in the documentation
+ * of the distributed software.
+ *
+ * Any express or implied warranties are disclaimed. Author is
+ * not liable for any direct or indirect damages caused by the use
+ * of this software.
+ *
+ * ----------------------------------------------------------------------
+ *
+ * This code has been integrated into XBMC Media Center.
+ * As such it can me copied, redistributed and modified under
+ * the same conditions as the XBMC itself.
+ *
+ */
+
+
+#ifndef CCBUFFER_H_INCLUDED
+#define CCBUFFER_H_INCLUDED 1
+
+struct CcBufferRec {
+ unsigned char *data;
+ size_t len;
+};
+
+typedef struct CcBufferRec *CcBuffer;
+typedef struct CcBufferRec CcBufferRec;
+
+CcBuffer cc_buffer_allocate(void);
+void cc_buffer_free(CcBuffer buffer);
+void cc_buffer_init(CcBuffer buffer);
+void cc_buffer_uninit(CcBuffer buffer);
+size_t cc_buffer_len(CcBuffer buffer);
+unsigned char *cc_buffer_ptr(CcBuffer buffer);
+void cc_buffer_append(CcBuffer buffer, const unsigned char *data, size_t len);
+void cc_buffer_append_space(CcBuffer buffer, size_t len);
+void cc_buffer_append_string(CcBuffer buffer, const char *string);
+void cc_buffer_consume(CcBuffer buffer, size_t len);
+void cc_buffer_consume_end(CcBuffer buffer, size_t len);
+void cc_buffer_clear(CcBuffer buffer);
+void cc_buffer_prepend(CcBuffer buffer, const unsigned char *data, size_t len);
+void cc_buffer_prepend_string(CcBuffer buffer, const char *string);
+void cc_buffer_steal(CcBuffer buffer, unsigned char **data, size_t *len);
+
+#endif /* CCBUFFER_H_INCLUDED */
+/* eof (ccbuffer.h) */
diff --git a/lib/libXBMS/ccincludes.h b/lib/libXBMS/ccincludes.h
new file mode 100644
index 0000000000..e7fa8f6419
--- /dev/null
+++ b/lib/libXBMS/ccincludes.h
@@ -0,0 +1,75 @@
+/* -*- c -*-
+ *
+ * ----------------------------------------------------------------------
+ * Misc includes.
+ * ----------------------------------------------------------------------
+ *
+ * Copyright (c) 2002-2003 by PuhPuh
+ *
+ * This code is copyrighted property of the author. It can still
+ * be used for any non-commercial purpose following conditions:
+ *
+ * 1) This copyright notice is not removed.
+ * 2) Source code follows any distribution of the software
+ * if possible.
+ * 3) Copyright notice above is found in the documentation
+ * of the distributed software.
+ *
+ * Any express or implied warranties are disclaimed. Author is
+ * not liable for any direct or indirect damages caused by the use
+ * of this software.
+ *
+ * ----------------------------------------------------------------------
+ *
+ * This code has been integrated into XBMC Media Center.
+ * As such it can me copied, redistributed and modified under
+ * the same conditions as the XBMC itself.
+ *
+ */
+
+
+#ifndef CCINCLUDES_H_INCLUDED
+#define CCINCLUDES_H_INCLUDED 1
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <inttypes.h>
+
+#include "ccutil.h"
+
+#ifdef _XBOX
+#include <xtl.h>
+#elif defined(_LINUX)
+#include <unistd.h>
+#include <arpa/inet.h>
+#include <sys/socket.h>
+#include <sys/time.h>
+#include <inttypes.h>
+#include <netdb.h>
+#else
+#include <windows.h>
+#include <io.h>
+#include <time.h>
+#define snprintf _snprintf
+#endif /* _XBOX */
+
+//extern int errno;
+
+#ifndef PATH_MAX
+#define PATH_MAX 1024
+#endif /* ! PATH_MAX */
+
+#ifdef _LINUX
+#define CC_UINT_64_TYPE_NAME uint64_t
+#else
+#define CC_UINT_64_TYPE_NAME UINT64
+#endif
+#define CC_UINT_64_PRINTF_FORMAT "%lu"
+
+#endif /* CCINCLUDES_H_INCLUDED */
+/* eof (ccincludes.h) */
diff --git a/lib/libXBMS/ccutil.c b/lib/libXBMS/ccutil.c
new file mode 100644
index 0000000000..60882d1253
--- /dev/null
+++ b/lib/libXBMS/ccutil.c
@@ -0,0 +1,110 @@
+// Place the code and data below here into the LIBXBMS section.
+#ifndef __GNUC__
+#pragma code_seg( "LIBXBMS" )
+#pragma data_seg( "LIBXBMS_RW" )
+#pragma bss_seg( "LIBXBMS_RW" )
+#pragma const_seg( "LIBXBMS_RD" )
+#pragma comment(linker, "/merge:LIBXBMS_RW=LIBXBMS")
+#pragma comment(linker, "/merge:LIBXBMS_RD=LIBXBMS")
+#endif
+/* -*- c -*-
+ *
+ * ----------------------------------------------------------------------
+ * Misc utilities.
+ * ----------------------------------------------------------------------
+ *
+ * Copyright (c) 2002-2003 by PuhPuh
+ *
+ * This code is copyrighted property of the author. It can still
+ * be used for any non-commercial purpose following conditions:
+ *
+ * 1) This copyright notice is not removed.
+ * 2) Source code follows any distribution of the software
+ * if possible.
+ * 3) Copyright notice above is found in the documentation
+ * of the distributed software.
+ *
+ * Any express or implied warranties are disclaimed. Author is
+ * not liable for any direct or indirect damages caused by the use
+ * of this software.
+ *
+ * ----------------------------------------------------------------------
+ *
+ * This code has been integrated into XBMC Media Center.
+ * As such it can me copied, redistributed and modified under
+ * the same conditions as the XBMC itself.
+ *
+ */
+
+
+#include "ccincludes.h"
+#include "ccutil.h"
+
+void cc_fatal(const char *m)
+{
+#if 0
+ fprintf(stderr, "FATAL ERROR%s%s\n",
+ (m != NULL) ? ": " : "",
+ (m != NULL) ? m : "");
+#endif
+ exit(-1);
+}
+
+void *cc_xmalloc(size_t n)
+{
+ void *r;
+
+ r = malloc(n);
+ if (r == NULL)
+ cc_fatal("Out of memory");
+ return r;
+}
+
+void *cc_xcalloc(size_t n, size_t s)
+{
+ void *r;
+
+ r = calloc(n, s);
+ if (r == NULL)
+ cc_fatal("Out of memory");
+ return r;
+}
+
+void *cc_xrealloc(void *o, size_t n)
+{
+ void *r;
+
+ r = realloc(o, n);
+ if (r == NULL)
+ cc_fatal("Out of memory");
+ return r;
+}
+
+void *cc_xstrdup(const char *s)
+{
+ char *r;
+
+ r = strdup(s != NULL ? s : "");
+ if (r == NULL)
+ cc_fatal("Out of memory");
+ return r;
+}
+
+void *cc_xmemdup(const void *s, size_t len)
+{
+ unsigned char *r;
+
+ r = cc_xmalloc(len + 1);
+ r[len] = '\0';
+ if (len > 0)
+ memcpy(r, s, len);
+ return (void *)r;
+}
+
+void cc_xfree(void *p)
+{
+ if (p != NULL)
+ free(p);
+}
+
+/* eof (ccutil.c) */
diff --git a/lib/libXBMS/ccutil.h b/lib/libXBMS/ccutil.h
new file mode 100644
index 0000000000..14569af2fe
--- /dev/null
+++ b/lib/libXBMS/ccutil.h
@@ -0,0 +1,50 @@
+/* -*- c -*-
+ *
+ * ----------------------------------------------------------------------
+ * Misc utilities.
+ * ----------------------------------------------------------------------
+ *
+ * Copyright (c) 2002-2003 by PuhPuh
+ *
+ * This code is copyrighted property of the author. It can still
+ * be used for any non-commercial purpose following conditions:
+ *
+ * 1) This copyright notice is not removed.
+ * 2) Source code follows any distribution of the software
+ * if possible.
+ * 3) Copyright notice above is found in the documentation
+ * of the distributed software.
+ *
+ * Any express or implied warranties are disclaimed. Author is
+ * not liable for any direct or indirect damages caused by the use
+ * of this software.
+ *
+ * ----------------------------------------------------------------------
+ *
+ * This code has been integrated into XBMC Media Center.
+ * As such it can me copied, redistributed and modified under
+ * the same conditions as the XBMC itself.
+ *
+ */
+
+
+#ifndef CCUTIL_H_INCLUDED
+#define CCUTIL_H_INCLUDED 1
+
+void cc_fatal(const char *m);
+void *cc_xmalloc(size_t n);
+void *cc_xcalloc(size_t n, size_t s);
+void *cc_xrealloc(void *o, size_t n);
+void *cc_xstrdup(const char *s);
+void *cc_xmemdup(const void *s, size_t len);
+void cc_xfree(void *p);
+
+struct CcStringListRec {
+ char *s;
+ struct CcStringListRec *next;
+};
+
+typedef struct CcStringListRec *CcStringList;
+
+#endif /* CCUTIL_H_INCLUDED */
+/* eof (ccutil.h) */
diff --git a/lib/libXBMS/ccxclient.c b/lib/libXBMS/ccxclient.c
new file mode 100644
index 0000000000..52540fc731
--- /dev/null
+++ b/lib/libXBMS/ccxclient.c
@@ -0,0 +1,1262 @@
+// Place the code and data below here into the LIBXBMS section.
+#ifndef __GNUC__
+#pragma code_seg( "LIBXBMS" )
+#pragma data_seg( "LIBXBMS_RW" )
+#pragma bss_seg( "LIBXBMS_RW" )
+#pragma const_seg( "LIBXBMS_RD" )
+#pragma comment(linker, "/merge:LIBXBMS_RW=LIBXBMS")
+#pragma comment(linker, "/merge:LIBXBMS_RD=LIBXBMS")
+#endif
+/* -*- c -*-
+ *
+ * ----------------------------------------------------------------------
+ * CcXstream Client Library for XBMC Media Center
+ * ----------------------------------------------------------------------
+ *
+ * Copyright (c) 2002-2003 by PuhPuh
+ *
+ * This code is copyrighted property of the author. It can still
+ * be used for any non-commercial purpose following conditions:
+ *
+ * 1) This copyright notice is not removed.
+ * 2) Source code follows any distribution of the software
+ * if possible.
+ * 3) Copyright notice above is found in the documentation
+ * of the distributed software.
+ *
+ * Any express or implied warranties are disclaimed. Author is
+ * not liable for any direct or indirect damages caused by the use
+ * of this software.
+ *
+ * ----------------------------------------------------------------------
+ *
+ * This code has been integrated into XBMC Media Center.
+ * As such it can me copied, redistributed and modified under
+ * the same conditions as the XBMC itself.
+ *
+ */
+
+#include "ccincludes.h"
+#include "ccbuffer.h"
+#include "ccxclient.h"
+#include "ccxencode.h"
+
+#ifndef __GNUC__
+#pragma code_seg()
+#pragma data_seg()
+#pragma bss_seg()
+#pragma const_seg()
+#endif
+
+static unsigned long lNextId = 0;
+unsigned long next_id()
+{
+
+ lNextId = lNextId + 1 % 0xfffff; /* 20 bits in maximum */
+ if (lNextId == 0)
+ lNextId++;
+ return (lNextId << 12); /* Low 12 bits are zero */
+}
+
+#ifndef __GNUC__
+#pragma code_seg( "LIBXBMS" )
+#pragma data_seg( "LIBXBMS_RW" )
+#pragma bss_seg( "LIBXBMS_RW" )
+#pragma const_seg( "LIBXBMS_RD" )
+#pragma comment(linker, "/merge:LIBXBMS_RW=LIBXBMS")
+#pragma comment(linker, "/merge:LIBXBMS_RD=LIBXBMS")
+#endif
+
+CcXstreamClientError cc_xstream_client_version_handshake(CcXstreamServerConnection s)
+{
+ unsigned char *c, x;
+ CcBufferRec buf[1];
+ char *hlp1, *hlp2, *hlp3;
+ int i;
+
+ cc_buffer_init(buf);
+
+ for (i = 0; 1; i++)
+ {
+ if (i > 2048)
+ {
+ cc_buffer_uninit(buf);
+ return CC_XSTREAM_CLIENT_FATAL_ERROR;
+ }
+ c = cc_xstream_client_read_data(s, 1, CCXSTREAM_CLIENT_TIMEOUT_SECONDS * 1000U);
+ if (c == NULL)
+ {
+ cc_buffer_uninit(buf);
+ return CC_XSTREAM_CLIENT_FATAL_ERROR;
+ }
+ x = c[0];
+ cc_xfree(c);
+ if (x == '\n')
+ break;
+ else if (x != '\r')
+ cc_buffer_append(buf, &x, 1);
+ }
+ hlp1 = cc_xmemdup(cc_buffer_ptr(buf), cc_buffer_len(buf));
+ cc_buffer_uninit(buf);
+ /* OK, we parse the version string. Supported versions are between
+ the first and the second space characters in the string.
+ Versions are in the comma separated list. This code is somewhat
+ spaghetti, but it does the trick and ensures that supported
+ versions list contain string CC_XSTREAM_CLIENT_VERSION. The
+ reason for complexity is that it can be the first or last item in
+ the list. It can also be the only item in the list. And of
+ course string we got from the server may be nonstandard and we
+ can't crash because of it. */
+ hlp2 = strchr(hlp1, ' ');
+ if (hlp2 == NULL)
+ {
+ cc_xfree(hlp1);
+ return CC_XSTREAM_CLIENT_FATAL_ERROR;
+ }
+ hlp2++;
+ hlp3 = strchr(hlp2, ' ');
+ if (hlp3 == NULL)
+ {
+ cc_xfree(hlp1);
+ return CC_XSTREAM_CLIENT_FATAL_ERROR;
+ }
+ *hlp3 = '\0';
+ while ((hlp3 = strrchr(hlp2, ',')) != NULL)
+ {
+ *hlp3 = '\0';
+ hlp3++;
+ if (strcmp(hlp3, CC_XSTREAM_CLIENT_VERSION) == 0)
+ break;
+ }
+ if (hlp3 == NULL)
+ {
+ if (strcmp(hlp2, CC_XSTREAM_CLIENT_VERSION) != 0)
+ {
+ cc_xfree(hlp1);
+ return CC_XSTREAM_CLIENT_FATAL_ERROR;
+ }
+ }
+ cc_xfree(hlp1);
+ if (cc_xstream_client_write_data(s, (unsigned char *)CC_XSTREAM_CLIENT_VERSION_STR "\n", strlen(CC_XSTREAM_CLIENT_VERSION_STR "\n"), 0) == 0)
+ return CC_XSTREAM_CLIENT_FATAL_ERROR;
+ return CC_XSTREAM_CLIENT_OK;
+}
+
+unsigned long cc_xstream_client_mkpacket_setcwd(const char *path,
+ unsigned char **p, size_t *p_len)
+{
+ CcBufferRec buf[1];
+ unsigned int r;
+
+ /* Initialize the buffer. */
+ cc_buffer_init(buf);
+ /* Encode packet */
+ cc_xstream_buffer_encode_byte(buf, (unsigned char)CC_XSTREAM_XBMSP_PACKET_SETCWD);
+ r = next_id();
+ cc_xstream_buffer_encode_int(buf, r);
+ cc_xstream_buffer_encode_string(buf, path);
+ cc_xstream_buffer_encode_packet_length(buf);
+ /* Return payload */
+ *p = cc_xmemdup(cc_buffer_ptr(buf), cc_buffer_len(buf));
+ *p_len = cc_buffer_len(buf);
+ /* Free the buffer */
+ cc_buffer_uninit(buf);
+ /* Return the command id. */
+ return r;
+}
+
+unsigned long cc_xstream_client_mkpacket_upcwd(unsigned long levels,
+ unsigned char **p, size_t *p_len)
+{
+ CcBufferRec buf[1];
+ unsigned int r;
+
+ /* Initialize the buffer. */
+ cc_buffer_init(buf);
+ /* Encode packet */
+ cc_xstream_buffer_encode_byte(buf, (unsigned char)CC_XSTREAM_XBMSP_PACKET_UPCWD);
+ r = next_id();
+ cc_xstream_buffer_encode_int(buf, r);
+ cc_xstream_buffer_encode_int(buf, levels);
+ cc_xstream_buffer_encode_packet_length(buf);
+ /* Return payload */
+ *p = cc_xmemdup(cc_buffer_ptr(buf), cc_buffer_len(buf));
+ *p_len = cc_buffer_len(buf);
+ /* Free the buffer */
+ cc_buffer_uninit(buf);
+ /* Return the command id. */
+ return r;
+}
+
+unsigned long cc_xstream_client_mkpacket_filelist_open(unsigned char **p, size_t *p_len)
+{
+ CcBufferRec buf[1];
+ unsigned int r;
+
+ /* Initialize the buffer. */
+ cc_buffer_init(buf);
+ /* Encode packet */
+ cc_xstream_buffer_encode_byte(buf, (unsigned char)CC_XSTREAM_XBMSP_PACKET_FILELIST_OPEN);
+ r = next_id();
+ cc_xstream_buffer_encode_int(buf, r);
+ cc_xstream_buffer_encode_packet_length(buf);
+ /* Return payload */
+ *p = cc_xmemdup(cc_buffer_ptr(buf), cc_buffer_len(buf));
+ *p_len = cc_buffer_len(buf);
+ /* Free the buffer */
+ cc_buffer_uninit(buf);
+ /* Return the command id. */
+ return r;
+}
+
+unsigned long cc_xstream_client_mkpacket_filelist_read(unsigned long handle,
+ unsigned char **p, size_t *p_len)
+{
+ CcBufferRec buf[1];
+ unsigned int r;
+
+ /* Initialize the buffer. */
+ cc_buffer_init(buf);
+ /* Encode packet */
+ cc_xstream_buffer_encode_byte(buf, (unsigned char)CC_XSTREAM_XBMSP_PACKET_FILELIST_READ);
+ r = next_id();
+ cc_xstream_buffer_encode_int(buf, r);
+ cc_xstream_buffer_encode_int(buf, handle);
+ cc_xstream_buffer_encode_packet_length(buf);
+ /* Return payload */
+ *p = cc_xmemdup(cc_buffer_ptr(buf), cc_buffer_len(buf));
+ *p_len = cc_buffer_len(buf);
+ /* Free the buffer */
+ cc_buffer_uninit(buf);
+ /* Return the command id. */
+ return r;
+}
+
+unsigned long cc_xstream_client_mkpacket_file_info(const char *path,
+ unsigned char **p, size_t *p_len)
+{
+ CcBufferRec buf[1];
+ unsigned int r;
+
+ /* Initialize the buffer. */
+ cc_buffer_init(buf);
+ /* Encode packet */
+ cc_xstream_buffer_encode_byte(buf, (unsigned char)CC_XSTREAM_XBMSP_PACKET_FILE_INFO);
+ r = next_id();
+ cc_xstream_buffer_encode_int(buf, r);
+ cc_xstream_buffer_encode_string(buf, path);
+ cc_xstream_buffer_encode_packet_length(buf);
+ /* Return payload */
+ *p = cc_xmemdup(cc_buffer_ptr(buf), cc_buffer_len(buf));
+ *p_len = cc_buffer_len(buf);
+ /* Free the buffer */
+ cc_buffer_uninit(buf);
+ /* Return the command id. */
+ return r;
+}
+
+unsigned long cc_xstream_client_mkpacket_file_open(const char *path,
+ unsigned char **p, size_t *p_len)
+{
+ CcBufferRec buf[1];
+ unsigned int r;
+
+ /* Initialize the buffer. */
+ cc_buffer_init(buf);
+ /* Encode packet */
+ cc_xstream_buffer_encode_byte(buf, (unsigned char)CC_XSTREAM_XBMSP_PACKET_FILE_OPEN);
+ r = next_id();
+ cc_xstream_buffer_encode_int(buf, r);
+ cc_xstream_buffer_encode_string(buf, path);
+ cc_xstream_buffer_encode_packet_length(buf);
+ /* Return payload */
+ *p = cc_xmemdup(cc_buffer_ptr(buf), cc_buffer_len(buf));
+ *p_len = cc_buffer_len(buf);
+ /* Free the buffer */
+ cc_buffer_uninit(buf);
+ /* Return the command id. */
+ return r;
+}
+
+unsigned long cc_xstream_client_mkpacket_file_read(unsigned long handle, size_t len,
+ unsigned char **p, size_t *p_len)
+{
+ CcBufferRec buf[1];
+ unsigned int r;
+
+ /* Initialize the buffer. */
+ cc_buffer_init(buf);
+ /* Encode packet */
+ cc_xstream_buffer_encode_byte(buf, (unsigned char)CC_XSTREAM_XBMSP_PACKET_FILE_READ);
+ r = next_id();
+ cc_xstream_buffer_encode_int(buf, r);
+ cc_xstream_buffer_encode_int(buf, handle);
+ cc_xstream_buffer_encode_int(buf, len);
+ cc_xstream_buffer_encode_packet_length(buf);
+ /* Return payload */
+ *p = cc_xmemdup(cc_buffer_ptr(buf), cc_buffer_len(buf));
+ *p_len = cc_buffer_len(buf);
+ /* Free the buffer */
+ cc_buffer_uninit(buf);
+ /* Return the command id. */
+ return r;
+}
+
+unsigned long cc_xstream_client_mkpacket_seek(unsigned long handle,
+ int seek_type, CC_UINT_64_TYPE_NAME bytes,
+ unsigned char **p, size_t *p_len)
+{
+ CcBufferRec buf[1];
+ unsigned int r;
+
+ /* Initialize the buffer. */
+ cc_buffer_init(buf);
+ /* Encode packet */
+ cc_xstream_buffer_encode_byte(buf, (unsigned char)CC_XSTREAM_XBMSP_PACKET_FILE_SEEK);
+ r = next_id();
+ cc_xstream_buffer_encode_int(buf, r);
+ cc_xstream_buffer_encode_int(buf, handle);
+ cc_xstream_buffer_encode_byte(buf, (unsigned char)seek_type);
+ cc_xstream_buffer_encode_int64(buf, bytes);
+ cc_xstream_buffer_encode_packet_length(buf);
+ /* Return payload */
+ *p = cc_xmemdup(cc_buffer_ptr(buf), cc_buffer_len(buf));
+ *p_len = cc_buffer_len(buf);
+ /* Free the buffer */
+ cc_buffer_uninit(buf);
+ /* Return the command id. */
+ return r;
+}
+
+unsigned long cc_xstream_client_mkpacket_close(unsigned long handle,
+ unsigned char **p, size_t *p_len)
+{
+ CcBufferRec buf[1];
+ unsigned int r;
+
+ /* Initialize the buffer. */
+ cc_buffer_init(buf);
+ /* Encode packet */
+ cc_xstream_buffer_encode_byte(buf, (unsigned char)CC_XSTREAM_XBMSP_PACKET_CLOSE);
+ r = next_id();
+ cc_xstream_buffer_encode_int(buf, r);
+ cc_xstream_buffer_encode_int(buf, handle);
+ cc_xstream_buffer_encode_packet_length(buf);
+ /* Return payload */
+ *p = cc_xmemdup(cc_buffer_ptr(buf), cc_buffer_len(buf));
+ *p_len = cc_buffer_len(buf);
+ /* Free the buffer */
+ cc_buffer_uninit(buf);
+ /* Return the command id. */
+ return r;
+}
+
+unsigned long cc_xstream_client_mkpacket_close_all(unsigned char **p, size_t *p_len)
+{
+ CcBufferRec buf[1];
+ unsigned int r;
+
+ /* Initialize the buffer. */
+ cc_buffer_init(buf);
+ /* Encode packet */
+ cc_xstream_buffer_encode_byte(buf, (unsigned char)CC_XSTREAM_XBMSP_PACKET_CLOSE_ALL);
+ r = next_id();
+ cc_xstream_buffer_encode_int(buf, r);
+ cc_xstream_buffer_encode_packet_length(buf);
+ /* Return payload */
+ *p = cc_xmemdup(cc_buffer_ptr(buf), cc_buffer_len(buf));
+ *p_len = cc_buffer_len(buf);
+ /* Free the buffer */
+ cc_buffer_uninit(buf);
+ /* Return the command id. */
+ return r;
+}
+
+unsigned long cc_xstream_client_mkpacket_setconfoption(const char *option,
+ const char *value,
+ unsigned char **p, size_t *p_len)
+{
+ CcBufferRec buf[1];
+ unsigned int r;
+
+ /* Initialize the buffer. */
+ cc_buffer_init(buf);
+ /* Encode packet */
+ cc_xstream_buffer_encode_byte(buf, (unsigned char)CC_XSTREAM_XBMSP_PACKET_SET_CONFIGURATION_OPTION);
+ r = next_id();
+ cc_xstream_buffer_encode_int(buf, r);
+ cc_xstream_buffer_encode_string(buf, option);
+ cc_xstream_buffer_encode_string(buf, value);
+ cc_xstream_buffer_encode_packet_length(buf);
+ /* Return payload */
+ *p = cc_xmemdup(cc_buffer_ptr(buf), cc_buffer_len(buf));
+ *p_len = cc_buffer_len(buf);
+ /* Free the buffer */
+ cc_buffer_uninit(buf);
+ /* Return the command id. */
+ return r;
+}
+
+unsigned long cc_xstream_client_mkpacket_authentication_init(const char *method,
+ unsigned char **p, size_t *p_len)
+{
+ CcBufferRec buf[1];
+ unsigned int r;
+
+ /* Initialize the buffer. */
+ cc_buffer_init(buf);
+ /* Encode packet */
+ cc_xstream_buffer_encode_byte(buf, (unsigned char)CC_XSTREAM_XBMSP_PACKET_AUTHENTICATION_INIT);
+ r = next_id();
+ cc_xstream_buffer_encode_int(buf, r);
+ cc_xstream_buffer_encode_string(buf, method);
+ cc_xstream_buffer_encode_packet_length(buf);
+ /* Return payload */
+ *p = cc_xmemdup(cc_buffer_ptr(buf), cc_buffer_len(buf));
+ *p_len = cc_buffer_len(buf);
+ /* Free the buffer */
+ cc_buffer_uninit(buf);
+ /* Return the command id. */
+ return r;
+}
+
+unsigned long cc_xstream_client_mkpacket_authenticate_password(unsigned long handle,
+ const char *user_id,
+ const char *password,
+ unsigned char **p, size_t *p_len)
+{
+ CcBufferRec buf[1];
+ unsigned int r;
+
+ /* Initialize the buffer. */
+ cc_buffer_init(buf);
+ /* Encode packet */
+ cc_xstream_buffer_encode_byte(buf, (unsigned char)CC_XSTREAM_XBMSP_PACKET_AUTHENTICATE);
+ r = next_id();
+ cc_xstream_buffer_encode_int(buf, r);
+ cc_xstream_buffer_encode_int(buf, handle);
+ cc_xstream_buffer_encode_string(buf, user_id);
+ cc_xstream_buffer_encode_string(buf, password);
+ cc_xstream_buffer_encode_packet_length(buf);
+ /* Return payload */
+ *p = cc_xmemdup(cc_buffer_ptr(buf), cc_buffer_len(buf));
+ *p_len = cc_buffer_len(buf);
+ /* Free the buffer */
+ cc_buffer_uninit(buf);
+ /* Return the command id. */
+ return r;
+}
+
+unsigned long cc_xstream_client_mkpacket_server_discovery(unsigned char **p, size_t *p_len)
+{
+ CcBufferRec buf[1];
+ unsigned int r;
+
+ /* Initialize the buffer. */
+ cc_buffer_init(buf);
+ /* Encode packet. */
+ cc_xstream_buffer_encode_byte(buf, (unsigned char)CC_XSTREAM_XBMSP_PACKET_SERVER_DISCOVERY_QUERY);
+ r = next_id();
+ cc_xstream_buffer_encode_int(buf, r);
+ cc_xstream_buffer_encode_string(buf, CC_XSTREAM_CLIENT_VERSION_STR);
+ cc_xstream_buffer_encode_packet_length(buf);
+ /* Return payload */
+ *p = cc_xmemdup(cc_buffer_ptr(buf), cc_buffer_len(buf));
+ *p_len = cc_buffer_len(buf);
+ /* Free the buffer */
+ cc_buffer_uninit(buf);
+ /* Return the command id. */
+ return r;
+}
+
+void cc_xstream_client_reply_packet_free(CcXstreamReplyPacket packet)
+{
+ if (packet != NULL)
+ {
+ cc_xfree(packet->string1);
+ cc_xfree(packet->string2);
+ }
+ cc_xfree(packet);
+}
+
+CcXstreamReplyPacket cc_xstream_client_reply_packet_parse(const unsigned char *packet,
+ size_t packet_len)
+{
+ CcXstreamPacket pt;
+ unsigned long id, handle, err;
+ unsigned char *s1, *s2;
+ size_t sl1, sl2;
+ CcXstreamReplyPacket r;
+
+ if (packet_len < 5)
+ return NULL;
+
+ id = cc_xstream_decode_int(packet + 1);
+
+ switch (packet[0])
+ {
+ case CC_XSTREAM_XBMSP_PACKET_OK:
+ if (packet_len != 5)
+ return NULL;
+ pt = CC_XSTREAM_XBMSP_PACKET_OK;
+ s1 = s2 = NULL;
+ sl1 = sl2 = 0;
+ err = handle = 0;
+ break;
+
+ case CC_XSTREAM_XBMSP_PACKET_ERROR:
+ if (packet_len < 10)
+ return NULL;
+ pt = CC_XSTREAM_XBMSP_PACKET_ERROR;
+ err = packet[5];
+ s1 = s2 = NULL;
+ sl1 = sl2 = 0;
+ handle = 0;
+ break;
+
+ case CC_XSTREAM_XBMSP_PACKET_HANDLE:
+ if (packet_len != 9)
+ return NULL;
+ pt = CC_XSTREAM_XBMSP_PACKET_HANDLE;
+ handle = cc_xstream_decode_int(packet + 5);
+ s1 = s2 = NULL;
+ sl1 = sl2 = 0;
+ err = 0;
+ break;
+
+ case CC_XSTREAM_XBMSP_PACKET_FILE_DATA:
+ pt = CC_XSTREAM_XBMSP_PACKET_FILE_DATA;
+ sl1 = cc_xstream_decode_int(packet + 5);
+ if (packet_len < (sl1 + 13))
+ return NULL;
+ sl2 = cc_xstream_decode_int(packet + 9 + sl1);
+ if (packet_len != (13 + sl1 + sl2))
+ return NULL;
+ s1 = cc_xmemdup(packet + 9, sl1);
+ s2 = cc_xmemdup(packet + 13 + sl1, sl2);
+ err = handle = 0;
+ break;
+
+ case CC_XSTREAM_XBMSP_PACKET_FILE_CONTENTS:
+ if (packet_len < 5)
+ return NULL;
+ pt = CC_XSTREAM_XBMSP_PACKET_FILE_CONTENTS;
+ sl1 = cc_xstream_decode_int(packet + 5);
+ if (packet_len != (sl1 + 9))
+ return NULL;
+ s1 = cc_xmemdup(packet + 9, sl1);
+ s2 = NULL;
+ sl2 = 0;
+ err = handle = 0;
+ break;
+
+ default:
+ return NULL;
+ }
+ r = cc_xcalloc(1, sizeof (*r));
+ r->type = pt;
+ r->id = id;
+ r->handle = handle;
+ r->error = err;
+ r->string1 = s1;
+ r->string2 = s2;
+ r->string1_len = sl1;
+ r->string2_len = sl2;
+ return r;
+}
+
+CcXstreamClientError cc_xstream_client_reply_packet_read(CcXstreamServerConnection s,
+ CcXstreamReplyPacket *packet)
+{
+ unsigned char *lb, *pb;
+ size_t len;
+ CcXstreamReplyPacket p;
+
+ if ((lb = cc_xstream_client_read_data(s, 4, CCXSTREAM_CLIENT_TIMEOUT_SECONDS * 1000U)) == NULL)
+ return CC_XSTREAM_CLIENT_FATAL_ERROR;
+ len = cc_xstream_decode_int(lb);
+ cc_xfree(lb);
+ if (len > 0x20000)
+ {
+ fprintf(stderr, "Too long packet (len=%u)\n", (unsigned int)len);
+ return CC_XSTREAM_CLIENT_FATAL_ERROR;
+ }
+ if ((pb = cc_xstream_client_read_data(s, len, CCXSTREAM_CLIENT_TIMEOUT_SECONDS * 1000U)) == NULL)
+ {
+ free(pb);
+ return CC_XSTREAM_CLIENT_FATAL_ERROR;
+ }
+ p = cc_xstream_client_reply_packet_parse(pb, len);
+ cc_xfree(pb);
+ if (p == NULL)
+ return CC_XSTREAM_CLIENT_FATAL_ERROR;
+ *packet = p;
+ return CC_XSTREAM_CLIENT_OK;
+}
+
+CcXstreamClientError cc_xstream_client_setcwd(CcXstreamServerConnection s,
+ const char *path)
+{
+ unsigned char *pb;
+ size_t pb_len;
+ unsigned long id;
+ CcXstreamReplyPacket rp;
+
+ id = cc_xstream_client_mkpacket_setcwd(path, &pb, &pb_len);
+ if (cc_xstream_client_write_data(s, pb, pb_len, 0) == 0)
+ {
+ cc_xfree(pb);
+ return CC_XSTREAM_CLIENT_FATAL_ERROR;
+ }
+ cc_xfree(pb);
+ if (cc_xstream_client_reply_packet_read(s, &rp) != CC_XSTREAM_CLIENT_OK)
+ return CC_XSTREAM_CLIENT_FATAL_ERROR;
+ if (rp->id != id)
+ {
+ cc_xstream_client_reply_packet_free(rp);
+ return CC_XSTREAM_CLIENT_FATAL_ERROR;
+ }
+ else if (rp->type == CC_XSTREAM_XBMSP_PACKET_OK)
+ {
+ cc_xstream_client_reply_packet_free(rp);
+ return CC_XSTREAM_CLIENT_OK;
+ }
+ else if (rp->type == CC_XSTREAM_XBMSP_PACKET_ERROR)
+ {
+ cc_xstream_client_reply_packet_free(rp);
+ return CC_XSTREAM_CLIENT_COMMAND_FAILED;
+ }
+ else
+ {
+ cc_xstream_client_reply_packet_free(rp);
+ return CC_XSTREAM_CLIENT_FATAL_ERROR;
+ }
+ /*NOTREACHED*/
+}
+
+CcXstreamClientError cc_xstream_client_upcwd(CcXstreamServerConnection s,
+ unsigned long levels)
+{
+ unsigned char *pb;
+ size_t pb_len;
+ unsigned long id;
+ CcXstreamReplyPacket rp;
+
+ id = cc_xstream_client_mkpacket_upcwd(levels, &pb, &pb_len);
+ if (cc_xstream_client_write_data(s, pb, pb_len, 0) == 0)
+ {
+ cc_xfree(pb);
+ return CC_XSTREAM_CLIENT_FATAL_ERROR;
+ }
+ cc_xfree(pb);
+ if (cc_xstream_client_reply_packet_read(s, &rp) != CC_XSTREAM_CLIENT_OK)
+ return CC_XSTREAM_CLIENT_FATAL_ERROR;
+ if (rp->id != id)
+ {
+ cc_xstream_client_reply_packet_free(rp);
+ return CC_XSTREAM_CLIENT_FATAL_ERROR;
+ }
+ else if (rp->type == CC_XSTREAM_XBMSP_PACKET_OK)
+ {
+ cc_xstream_client_reply_packet_free(rp);
+ return CC_XSTREAM_CLIENT_OK;
+ }
+ else if (rp->type == CC_XSTREAM_XBMSP_PACKET_ERROR)
+ {
+ cc_xstream_client_reply_packet_free(rp);
+ return CC_XSTREAM_CLIENT_COMMAND_FAILED;
+ }
+ else
+ {
+ cc_xstream_client_reply_packet_free(rp);
+ return CC_XSTREAM_CLIENT_FATAL_ERROR;
+ }
+ /*NOTREACHED*/
+}
+
+
+CcXstreamClientError cc_xstream_client_close(CcXstreamServerConnection s,
+ unsigned long handle)
+{
+ unsigned char *pb;
+ size_t pb_len;
+ unsigned long id;
+ CcXstreamReplyPacket rp;
+
+ id = cc_xstream_client_mkpacket_close(handle, &pb, &pb_len);
+ if (cc_xstream_client_write_data(s, pb, pb_len, 0) == 0)
+ {
+ cc_xfree(pb);
+ return CC_XSTREAM_CLIENT_FATAL_ERROR;
+ }
+ cc_xfree(pb);
+ if (cc_xstream_client_reply_packet_read(s, &rp) != CC_XSTREAM_CLIENT_OK)
+ return CC_XSTREAM_CLIENT_FATAL_ERROR;
+ if (rp->id != id)
+ {
+ cc_xstream_client_reply_packet_free(rp);
+ return CC_XSTREAM_CLIENT_FATAL_ERROR;
+ }
+ else if (rp->type == CC_XSTREAM_XBMSP_PACKET_OK)
+ {
+ cc_xstream_client_reply_packet_free(rp);
+ return CC_XSTREAM_CLIENT_OK;
+ }
+ else if (rp->type == CC_XSTREAM_XBMSP_PACKET_ERROR)
+ {
+ cc_xstream_client_reply_packet_free(rp);
+ return CC_XSTREAM_CLIENT_COMMAND_FAILED;
+ }
+ else
+ {
+ cc_xstream_client_reply_packet_free(rp);
+ return CC_XSTREAM_CLIENT_FATAL_ERROR;
+ }
+ /*NOTREACHED*/
+}
+
+CcXstreamClientError cc_xstream_client_close_all(CcXstreamServerConnection s)
+{
+ unsigned char *pb;
+ size_t pb_len;
+ unsigned long id;
+ CcXstreamReplyPacket rp;
+
+ id = cc_xstream_client_mkpacket_close_all(&pb, &pb_len);
+ if (cc_xstream_client_write_data(s, pb, pb_len, 0) == 0)
+ {
+ cc_xfree(pb);
+ return CC_XSTREAM_CLIENT_FATAL_ERROR;
+ }
+ cc_xfree(pb);
+ if (cc_xstream_client_reply_packet_read(s, &rp) != CC_XSTREAM_CLIENT_OK)
+ return CC_XSTREAM_CLIENT_FATAL_ERROR;
+ if (rp->id != id)
+ {
+ cc_xstream_client_reply_packet_free(rp);
+ return CC_XSTREAM_CLIENT_FATAL_ERROR;
+ }
+ else if (rp->type == CC_XSTREAM_XBMSP_PACKET_OK)
+ {
+ cc_xstream_client_reply_packet_free(rp);
+ return CC_XSTREAM_CLIENT_OK;
+ }
+ else if (rp->type == CC_XSTREAM_XBMSP_PACKET_ERROR)
+ {
+ cc_xstream_client_reply_packet_free(rp);
+ return CC_XSTREAM_CLIENT_COMMAND_FAILED;
+ }
+ else
+ {
+ cc_xstream_client_reply_packet_free(rp);
+ return CC_XSTREAM_CLIENT_FATAL_ERROR;
+ }
+ /*NOTREACHED*/
+}
+
+CcXstreamClientError cc_xstream_client_file_open(CcXstreamServerConnection s,
+ const char *path,
+ unsigned long *handle)
+{
+ unsigned char *pb;
+ size_t pb_len;
+ unsigned long id;
+ CcXstreamReplyPacket rp;
+
+ id = cc_xstream_client_mkpacket_file_open(path, &pb, &pb_len);
+ if (cc_xstream_client_write_data(s, pb, pb_len, 0) == 0)
+ {
+ cc_xfree(pb);
+ return CC_XSTREAM_CLIENT_FATAL_ERROR;
+ }
+ cc_xfree(pb);
+ if (cc_xstream_client_reply_packet_read(s, &rp) != CC_XSTREAM_CLIENT_OK)
+ return CC_XSTREAM_CLIENT_FATAL_ERROR;
+ if (rp->id != id)
+ {
+ cc_xstream_client_reply_packet_free(rp);
+ return CC_XSTREAM_CLIENT_FATAL_ERROR;
+ }
+ else if (rp->type == CC_XSTREAM_XBMSP_PACKET_HANDLE)
+ {
+ *handle = rp->handle;
+ cc_xstream_client_reply_packet_free(rp);
+ return CC_XSTREAM_CLIENT_OK;
+ }
+ else if (rp->type == CC_XSTREAM_XBMSP_PACKET_ERROR)
+ {
+ cc_xstream_client_reply_packet_free(rp);
+ return CC_XSTREAM_CLIENT_COMMAND_FAILED;
+ }
+ else
+ {
+ cc_xstream_client_reply_packet_free(rp);
+ return CC_XSTREAM_CLIENT_FATAL_ERROR;
+ }
+ /*NOTREACHED*/
+}
+
+CcXstreamClientError cc_xstream_client_file_read(CcXstreamServerConnection s,
+ unsigned long handle,
+ size_t len,
+ unsigned char **data,
+ size_t *data_len)
+{
+ unsigned char *pb;
+ size_t pb_len;
+ unsigned long id;
+ CcXstreamReplyPacket rp;
+
+ id = cc_xstream_client_mkpacket_file_read(handle, len, &pb, &pb_len);
+ if (cc_xstream_client_write_data(s, pb, pb_len, 0) == 0)
+ {
+ cc_xfree(pb);
+ return CC_XSTREAM_CLIENT_FATAL_ERROR;
+ }
+ cc_xfree(pb);
+ if (cc_xstream_client_reply_packet_read(s, &rp) != CC_XSTREAM_CLIENT_OK)
+ {
+ return CC_XSTREAM_CLIENT_FATAL_ERROR;
+ }
+ if (rp->id != id)
+ {
+ cc_xstream_client_reply_packet_free(rp);
+ return CC_XSTREAM_CLIENT_FATAL_ERROR;
+ }
+ else if (rp->type == CC_XSTREAM_XBMSP_PACKET_FILE_CONTENTS)
+ {
+ *data = rp->string1;
+ *data_len = rp->string1_len;
+ rp->string1 = NULL;
+ rp->string1_len = 0;
+ cc_xstream_client_reply_packet_free(rp);
+ return CC_XSTREAM_CLIENT_OK;
+ }
+ else if (rp->type == CC_XSTREAM_XBMSP_PACKET_ERROR)
+ {
+ cc_xstream_client_reply_packet_free(rp);
+ return CC_XSTREAM_CLIENT_COMMAND_FAILED;
+ }
+ else
+ {
+ cc_xstream_client_reply_packet_free(rp);
+ return CC_XSTREAM_CLIENT_FATAL_ERROR;
+ }
+ /*NOTREACHED*/
+}
+
+CcXstreamClientError cc_xstream_client_dir_open(CcXstreamServerConnection s,
+ unsigned long *handle)
+{
+ unsigned char *pb;
+ size_t pb_len;
+ unsigned long id;
+ CcXstreamReplyPacket rp;
+
+ id = cc_xstream_client_mkpacket_filelist_open(&pb, &pb_len);
+ if (cc_xstream_client_write_data(s, pb, pb_len, 0) == 0)
+ {
+ cc_xfree(pb);
+ return CC_XSTREAM_CLIENT_FATAL_ERROR;
+ }
+ cc_xfree(pb);
+ if (cc_xstream_client_reply_packet_read(s, &rp) != CC_XSTREAM_CLIENT_OK)
+ return CC_XSTREAM_CLIENT_FATAL_ERROR;
+ if (rp->id != id)
+ {
+ cc_xstream_client_reply_packet_free(rp);
+ return CC_XSTREAM_CLIENT_FATAL_ERROR;
+ }
+ else if (rp->type == CC_XSTREAM_XBMSP_PACKET_HANDLE)
+ {
+ *handle = rp->handle;
+ cc_xstream_client_reply_packet_free(rp);
+ return CC_XSTREAM_CLIENT_OK;
+ }
+ else if (rp->type == CC_XSTREAM_XBMSP_PACKET_ERROR)
+ {
+ cc_xstream_client_reply_packet_free(rp);
+ return CC_XSTREAM_CLIENT_COMMAND_FAILED;
+ }
+ else
+ {
+ cc_xstream_client_reply_packet_free(rp);
+ return CC_XSTREAM_CLIENT_FATAL_ERROR;
+ }
+ /*NOTREACHED*/
+}
+
+CcXstreamClientError cc_xstream_client_dir_read(CcXstreamServerConnection s,
+ unsigned long handle,
+ char **name,
+ char **info)
+{
+ unsigned char *pb;
+ size_t pb_len;
+ unsigned long id;
+ CcXstreamReplyPacket rp;
+
+ id = cc_xstream_client_mkpacket_filelist_read(handle, &pb, &pb_len);
+ if (cc_xstream_client_write_data(s, pb, pb_len, 0) == 0)
+ {
+ cc_xfree(pb);
+ return CC_XSTREAM_CLIENT_FATAL_ERROR;
+ }
+ cc_xfree(pb);
+ if (cc_xstream_client_reply_packet_read(s, &rp) != CC_XSTREAM_CLIENT_OK)
+ return CC_XSTREAM_CLIENT_FATAL_ERROR;
+ if (rp->id != id)
+ {
+ cc_xstream_client_reply_packet_free(rp);
+ return CC_XSTREAM_CLIENT_FATAL_ERROR;
+ }
+ else if (rp->type == CC_XSTREAM_XBMSP_PACKET_FILE_DATA)
+ {
+ *name = (char *)rp->string1;
+ *info = (char *)rp->string2;
+ rp->string1 = NULL;
+ rp->string1_len = 0;
+ rp->string2 = NULL;
+ rp->string2_len = 0;
+ cc_xstream_client_reply_packet_free(rp);
+ return CC_XSTREAM_CLIENT_OK;
+ }
+ else if (rp->type == CC_XSTREAM_XBMSP_PACKET_ERROR)
+ {
+ cc_xstream_client_reply_packet_free(rp);
+ return CC_XSTREAM_CLIENT_COMMAND_FAILED;
+ }
+ else
+ {
+ cc_xstream_client_reply_packet_free(rp);
+ return CC_XSTREAM_CLIENT_FATAL_ERROR;
+ }
+ /*NOTREACHED*/
+}
+
+CcXstreamClientError cc_xstream_client_file_forward(CcXstreamServerConnection s,
+ unsigned long handle,
+ CC_UINT_64_TYPE_NAME bytes,
+ int seek_eof_if_fails)
+{
+ unsigned char *pb;
+ size_t pb_len;
+ unsigned long id;
+ CcXstreamReplyPacket rp;
+
+ id = cc_xstream_client_mkpacket_seek(handle, 2, bytes, &pb, &pb_len);
+ if (cc_xstream_client_write_data(s, pb, pb_len, 0) == 0)
+ {
+ cc_xfree(pb);
+ return CC_XSTREAM_CLIENT_FATAL_ERROR;
+ }
+ cc_xfree(pb);
+ if (cc_xstream_client_reply_packet_read(s, &rp) != CC_XSTREAM_CLIENT_OK)
+ return CC_XSTREAM_CLIENT_FATAL_ERROR;
+ if (rp->id != id)
+ {
+ cc_xstream_client_reply_packet_free(rp);
+ return CC_XSTREAM_CLIENT_FATAL_ERROR;
+ }
+ else if (rp->type == CC_XSTREAM_XBMSP_PACKET_OK)
+ {
+ cc_xstream_client_reply_packet_free(rp);
+ return CC_XSTREAM_CLIENT_OK;
+ }
+ else if (rp->type == CC_XSTREAM_XBMSP_PACKET_ERROR)
+ {
+ cc_xstream_client_reply_packet_free(rp);
+ if (seek_eof_if_fails)
+ return cc_xstream_client_file_end(s, handle);
+ else
+ return CC_XSTREAM_CLIENT_COMMAND_FAILED;
+ }
+ else
+ {
+ cc_xstream_client_reply_packet_free(rp);
+ return CC_XSTREAM_CLIENT_FATAL_ERROR;
+ }
+ /*NOTREACHED*/
+}
+
+CcXstreamClientError cc_xstream_client_file_backwards(CcXstreamServerConnection s,
+ unsigned long handle,
+ CC_UINT_64_TYPE_NAME bytes,
+ int rewind_if_fails)
+{
+ unsigned char *pb;
+ size_t pb_len;
+ unsigned long id;
+ CcXstreamReplyPacket rp;
+
+ id = cc_xstream_client_mkpacket_seek(handle, 3, bytes, &pb, &pb_len);
+ if (cc_xstream_client_write_data(s, pb, pb_len, 0) == 0)
+ {
+ cc_xfree(pb);
+ return CC_XSTREAM_CLIENT_FATAL_ERROR;
+ }
+ cc_xfree(pb);
+ if (cc_xstream_client_reply_packet_read(s, &rp) != CC_XSTREAM_CLIENT_OK)
+ return CC_XSTREAM_CLIENT_FATAL_ERROR;
+ if (rp->id != id)
+ {
+ cc_xstream_client_reply_packet_free(rp);
+ return CC_XSTREAM_CLIENT_FATAL_ERROR;
+ }
+ else if (rp->type == CC_XSTREAM_XBMSP_PACKET_OK)
+ {
+ cc_xstream_client_reply_packet_free(rp);
+ return CC_XSTREAM_CLIENT_OK;
+ }
+ else if (rp->type == CC_XSTREAM_XBMSP_PACKET_ERROR)
+ {
+ cc_xstream_client_reply_packet_free(rp);
+ if (rewind_if_fails)
+ return cc_xstream_client_file_rewind(s, handle);
+ else
+ return CC_XSTREAM_CLIENT_COMMAND_FAILED;
+ }
+ else
+ {
+ cc_xstream_client_reply_packet_free(rp);
+ return CC_XSTREAM_CLIENT_FATAL_ERROR;
+ }
+ /*NOTREACHED*/
+}
+
+CcXstreamClientError cc_xstream_client_file_rewind(CcXstreamServerConnection s,
+ unsigned long handle)
+{
+ unsigned char *pb;
+ size_t pb_len;
+ unsigned long id;
+ CcXstreamReplyPacket rp;
+
+ id = cc_xstream_client_mkpacket_seek(handle, 0, 0, &pb, &pb_len);
+ if (cc_xstream_client_write_data(s, pb, pb_len, 0) == 0)
+ {
+ cc_xfree(pb);
+ return CC_XSTREAM_CLIENT_FATAL_ERROR;
+ }
+ cc_xfree(pb);
+ if (cc_xstream_client_reply_packet_read(s, &rp) != CC_XSTREAM_CLIENT_OK)
+ return CC_XSTREAM_CLIENT_FATAL_ERROR;
+ if (rp->id != id)
+ {
+ cc_xstream_client_reply_packet_free(rp);
+ return CC_XSTREAM_CLIENT_FATAL_ERROR;
+ }
+ else if (rp->type == CC_XSTREAM_XBMSP_PACKET_OK)
+ {
+ cc_xstream_client_reply_packet_free(rp);
+ return CC_XSTREAM_CLIENT_OK;
+ }
+ else if (rp->type == CC_XSTREAM_XBMSP_PACKET_ERROR)
+ {
+ cc_xstream_client_reply_packet_free(rp);
+ return CC_XSTREAM_CLIENT_COMMAND_FAILED;
+ }
+ else
+ {
+ cc_xstream_client_reply_packet_free(rp);
+ return CC_XSTREAM_CLIENT_FATAL_ERROR;
+ }
+ /*NOTREACHED*/
+}
+
+CcXstreamClientError cc_xstream_client_file_end(CcXstreamServerConnection s,
+ unsigned long handle)
+{
+ unsigned char *pb;
+ size_t pb_len;
+ unsigned long id;
+ CcXstreamReplyPacket rp;
+
+ id = cc_xstream_client_mkpacket_seek(handle, 1, 0, &pb, &pb_len);
+ if (cc_xstream_client_write_data(s, pb, pb_len, 0) == 0)
+ {
+ cc_xfree(pb);
+ return CC_XSTREAM_CLIENT_FATAL_ERROR;
+ }
+ cc_xfree(pb);
+ if (cc_xstream_client_reply_packet_read(s, &rp) != CC_XSTREAM_CLIENT_OK)
+ return CC_XSTREAM_CLIENT_FATAL_ERROR;
+ if (rp->id != id)
+ {
+ cc_xstream_client_reply_packet_free(rp);
+ return CC_XSTREAM_CLIENT_FATAL_ERROR;
+ }
+ else if (rp->type == CC_XSTREAM_XBMSP_PACKET_OK)
+ {
+ cc_xstream_client_reply_packet_free(rp);
+ return CC_XSTREAM_CLIENT_OK;
+ }
+ else if (rp->type == CC_XSTREAM_XBMSP_PACKET_ERROR)
+ {
+ cc_xstream_client_reply_packet_free(rp);
+ return CC_XSTREAM_CLIENT_COMMAND_FAILED;
+ }
+ else
+ {
+ cc_xstream_client_reply_packet_free(rp);
+ return CC_XSTREAM_CLIENT_FATAL_ERROR;
+ }
+ /*NOTREACHED*/
+}
+
+CcXstreamClientError cc_xstream_client_file_info(CcXstreamServerConnection s,
+ const char *path,
+ char **info)
+{
+ unsigned char *pb;
+ size_t pb_len;
+ unsigned long id;
+ CcXstreamReplyPacket rp;
+
+ id = cc_xstream_client_mkpacket_file_info(path, &pb, &pb_len);
+ if (cc_xstream_client_write_data(s, pb, pb_len, 0) == 0)
+ {
+ cc_xfree(pb);
+ return CC_XSTREAM_CLIENT_FATAL_ERROR;
+ }
+ cc_xfree(pb);
+ if (cc_xstream_client_reply_packet_read(s, &rp) != CC_XSTREAM_CLIENT_OK)
+ return CC_XSTREAM_CLIENT_FATAL_ERROR;
+ if (rp->id != id)
+ {
+ cc_xstream_client_reply_packet_free(rp);
+ return CC_XSTREAM_CLIENT_FATAL_ERROR;
+ }
+ else if (rp->type == CC_XSTREAM_XBMSP_PACKET_FILE_DATA)
+ {
+ *info = (char *)rp->string2;
+ rp->string2 = NULL;
+ rp->string2_len = 0;
+ cc_xstream_client_reply_packet_free(rp);
+ return CC_XSTREAM_CLIENT_OK;
+ }
+ else if (rp->type == CC_XSTREAM_XBMSP_PACKET_ERROR)
+ {
+ cc_xstream_client_reply_packet_free(rp);
+ return CC_XSTREAM_CLIENT_COMMAND_FAILED;
+ }
+ else
+ {
+ cc_xstream_client_reply_packet_free(rp);
+ return CC_XSTREAM_CLIENT_FATAL_ERROR;
+ }
+ /*NOTREACHED*/
+}
+
+CcXstreamClientError cc_xstream_client_set_configuration_option(CcXstreamServerConnection s,
+ const char *option,
+ const char *value)
+{
+ unsigned char *pb;
+ size_t pb_len;
+ unsigned long id;
+ CcXstreamReplyPacket rp;
+
+ id = cc_xstream_client_mkpacket_setconfoption(option, value, &pb, &pb_len);
+ if (cc_xstream_client_write_data(s, pb, pb_len, 0) == 0)
+ {
+ cc_xfree(pb);
+ return CC_XSTREAM_CLIENT_FATAL_ERROR;
+ }
+ cc_xfree(pb);
+ if (cc_xstream_client_reply_packet_read(s, &rp) != CC_XSTREAM_CLIENT_OK)
+ return CC_XSTREAM_CLIENT_FATAL_ERROR;
+ if (rp->id != id)
+ {
+ cc_xstream_client_reply_packet_free(rp);
+ return CC_XSTREAM_CLIENT_FATAL_ERROR;
+ }
+ else if (rp->type == CC_XSTREAM_XBMSP_PACKET_OK)
+ {
+ cc_xstream_client_reply_packet_free(rp);
+ return CC_XSTREAM_CLIENT_OK;
+ }
+ else if (rp->type == CC_XSTREAM_XBMSP_PACKET_ERROR)
+ {
+ cc_xstream_client_reply_packet_free(rp);
+ return CC_XSTREAM_CLIENT_COMMAND_FAILED;
+ }
+ else
+ {
+ cc_xstream_client_reply_packet_free(rp);
+ return CC_XSTREAM_CLIENT_FATAL_ERROR;
+ }
+ /*NOTREACHED*/
+}
+
+CcXstreamClientError cc_xstream_client_password_authenticate(CcXstreamServerConnection s,
+ const char *user_id,
+ const char *password)
+{
+ unsigned char *pb;
+ size_t pb_len;
+ unsigned long id;
+ CcXstreamReplyPacket rp;
+ unsigned int handle;
+
+ id = cc_xstream_client_mkpacket_authentication_init("password", &pb, &pb_len);
+ if (cc_xstream_client_write_data(s, pb, pb_len, 0) == 0)
+ {
+ cc_xfree(pb);
+ return CC_XSTREAM_CLIENT_FATAL_ERROR;
+ }
+ cc_xfree(pb);
+ if (cc_xstream_client_reply_packet_read(s, &rp) != CC_XSTREAM_CLIENT_OK)
+ {
+ return CC_XSTREAM_CLIENT_FATAL_ERROR;
+ }
+ if (rp->id != id)
+ {
+ cc_xstream_client_reply_packet_free(rp);
+ return CC_XSTREAM_CLIENT_FATAL_ERROR;
+ }
+ else if (rp->type == CC_XSTREAM_XBMSP_PACKET_HANDLE)
+ {
+ handle = rp->handle;
+ cc_xstream_client_reply_packet_free(rp);
+ }
+ else
+ {
+ cc_xstream_client_reply_packet_free(rp);
+ return CC_XSTREAM_CLIENT_FATAL_ERROR;
+ }
+ id = cc_xstream_client_mkpacket_authenticate_password(handle, user_id, password, &pb, &pb_len);
+ if (cc_xstream_client_write_data(s, pb, pb_len, 0) == 0)
+ {
+ cc_xfree(pb);
+ return CC_XSTREAM_CLIENT_FATAL_ERROR;
+ }
+ cc_xfree(pb);
+ if (cc_xstream_client_reply_packet_read(s, &rp) != CC_XSTREAM_CLIENT_OK)
+ {
+ return CC_XSTREAM_CLIENT_FATAL_ERROR;
+ }
+ if (rp->id != id)
+ {
+ cc_xstream_client_reply_packet_free(rp);
+ return CC_XSTREAM_CLIENT_FATAL_ERROR;
+ }
+ else if (rp->type == CC_XSTREAM_XBMSP_PACKET_OK)
+ {
+ cc_xstream_client_reply_packet_free(rp);
+ return CC_XSTREAM_CLIENT_OK;
+ }
+ else if (rp->type == CC_XSTREAM_XBMSP_PACKET_ERROR)
+ {
+ cc_xstream_client_reply_packet_free(rp);
+ return CC_XSTREAM_CLIENT_COMMAND_FAILED;
+ }
+ else
+ {
+ cc_xstream_client_reply_packet_free(rp);
+ return CC_XSTREAM_CLIENT_FATAL_ERROR;
+ }
+ /*NOTREACHED*/
+}
+
+/* eof (ccxclient.c) */
diff --git a/lib/libXBMS/ccxclient.h b/lib/libXBMS/ccxclient.h
new file mode 100644
index 0000000000..8c5266cdf6
--- /dev/null
+++ b/lib/libXBMS/ccxclient.h
@@ -0,0 +1,219 @@
+/* -*- c -*-
+ *
+ * ----------------------------------------------------------------------
+ * CcXstream Client Library for XBMC Media Center
+ * ----------------------------------------------------------------------
+ *
+ * Copyright (c) 2002-2003 by PuhPuh
+ *
+ * This code is copyrighted property of the author. It can still
+ * be used for any non-commercial purpose following conditions:
+ *
+ * 1) This copyright notice is not removed.
+ * 2) Source code follows any distribution of the software
+ * if possible.
+ * 3) Copyright notice above is found in the documentation
+ * of the distributed software.
+ *
+ * Any express or implied warranties are disclaimed. Author is
+ * not liable for any direct or indirect damages caused by the use
+ * of this software.
+ *
+ * ----------------------------------------------------------------------
+ *
+ * This code has been integrated into XBMC Media Center.
+ * As such it can me copied, redistributed and modified under
+ * the same conditions as the XBMC itself.
+ *
+ */
+
+
+#ifndef CC_XCLIENT_H_INCLUDED
+#define CC_XCLIENT_H_INCLUDED 1
+
+#include "ccxversion.h"
+#include "ccxpacket.h"
+
+/* The definition of CcXstreamServerConnection is system dependent.
+ In unix like systems this is simply int that is a file descriptor
+ of the connection socket. */
+#ifdef _XBOX
+typedef SOCKET CcXstreamServerConnection;
+#else /* _XBOX */
+typedef int CcXstreamServerConnection;
+#endif /* _XBOX */
+
+typedef struct CcXstreamReplyPacketRec *CcXstreamReplyPacket;
+
+struct CcXstreamReplyPacketRec {
+ CcXstreamPacket type;
+ unsigned long id;
+ unsigned long handle;
+ unsigned long error;
+ unsigned char *string1;
+ size_t string1_len;
+ unsigned char *string2;
+ size_t string2_len;
+};
+
+typedef enum {
+ /* Command was succesful and session can continue. */
+ CC_XSTREAM_CLIENT_OK = 0,
+ /* Command was failed but session is ok. */
+ CC_XSTREAM_CLIENT_COMMAND_FAILED = 1,
+ /* Command was probably failed and session is broken. */
+ CC_XSTREAM_CLIENT_FATAL_ERROR = 2,
+ /* Server host not found. */
+ CC_XSTREAM_CLIENT_SERVER_NOT_FOUND = 3,
+ /* Server host found but connection attempt failed. */
+ CC_XSTREAM_CLIENT_SERVER_CONNECTION_FAILED = 4
+} CcXstreamClientError;
+
+CcXstreamClientError cc_xstream_client_connect(const char *host,
+ int port,
+ CcXstreamServerConnection *s);
+
+CcXstreamClientError cc_xstream_client_disconnect(CcXstreamServerConnection s);
+
+unsigned char *cc_xstream_client_read_data(CcXstreamServerConnection s,
+ size_t len,
+ unsigned long timeout_ms);
+int cc_xstream_client_write_data(CcXstreamServerConnection s,
+ unsigned char *buf,
+ size_t len,
+ unsigned long timeout_ms);
+
+/* Make a packet that can be sent to the server directly. Return
+ value is an operation identifier that is selecte by the client
+ library and embedded into the packet. Server always returns a
+ packet with same id number. This is a low level interface that may
+ be used, if fully asynchronous client is needed. */
+
+CcXstreamClientError cc_xstream_client_version_handshake(CcXstreamServerConnection s);
+
+unsigned long cc_xstream_client_mkpacket_setcwd(const char *path,
+ unsigned char **p, size_t *p_len);
+
+unsigned long cc_xstream_client_mkpacket_upcwd(unsigned long levels,
+ unsigned char **p, size_t *p_len);
+
+unsigned long cc_xstream_client_mkpacket_filelist_open(unsigned char **p, size_t *p_len);
+
+unsigned long cc_xstream_client_mkpacket_filelost_read(unsigned long handle,
+ unsigned char **p, size_t *p_len);
+
+unsigned long cc_xstream_client_mkpacket_file_info(const char *path,
+ unsigned char **p, size_t *p_len);
+
+unsigned long cc_xstream_client_mkpacket_file_open(const char *path,
+ unsigned char **p, size_t *p_len);
+
+unsigned long cc_xstream_client_mkpacket_file_read(unsigned long handle, size_t len,
+ unsigned char **p, size_t *p_len);
+
+unsigned long cc_xstream_client_mkpacket_seek(unsigned long handle,
+ int seek_type, CC_UINT_64_TYPE_NAME bytes,
+ unsigned char **p, size_t *p_len);
+
+unsigned long cc_xstream_client_mkpacket_close(unsigned long handle,
+ unsigned char **p, size_t *p_len);
+
+unsigned long cc_xstream_client_mkpacket_close_all(unsigned char **p, size_t *p_len);
+
+unsigned long cc_xstream_client_mkpacket_setconfoption(const char *option,
+ const char *value,
+ unsigned char **p, size_t *p_len);
+
+unsigned long cc_xstream_client_mkpacket_authentication_init(const char *method,
+ unsigned char **p, size_t *p_len);
+
+unsigned long cc_xstream_client_mkpacket_authenticate_password(unsigned long handle,
+ const char *user_id,
+ const char *password,
+ unsigned char **p, size_t *p_len);
+
+unsigned long cc_xstream_client_mkpacket_server_discovery(unsigned char **p, size_t *p_len);
+
+
+/* Packet reading and parsing fuctionality is also quite low level.
+ It is mainly needed for applications that implement fully
+ asynchronous protocol session. */
+
+/* Packet is passed to this function without length field. */
+CcXstreamReplyPacket cc_xstream_client_reply_packet_parse(const unsigned char *packet,
+ size_t packet_len);
+
+/* Read a packet from the socket and parse it. */
+CcXstreamClientError cc_xstream_client_reply_packet_read(CcXstreamServerConnection s,
+ CcXstreamReplyPacket *packet);
+
+/* Free the packet. */
+void cc_xstream_client_reply_packet_free(CcXstreamReplyPacket packet);
+
+/* Following interfaces provide a synchronous interface to the server.
+ If this interface is used, the user can't send his own commands
+ directly bypassing this interface. */
+
+CcXstreamClientError cc_xstream_client_setcwd(CcXstreamServerConnection s,
+ const char *path);
+CcXstreamClientError cc_xstream_client_upcwd(CcXstreamServerConnection s,
+ unsigned long levels);
+CcXstreamClientError cc_xstream_client_close_all(CcXstreamServerConnection s);
+CcXstreamClientError cc_xstream_client_file_open(CcXstreamServerConnection s,
+ const char *path,
+ unsigned long *handle);
+CcXstreamClientError cc_xstream_client_file_read(CcXstreamServerConnection s,
+ unsigned long handle,
+ size_t len,
+ unsigned char **data,
+ size_t *data_len);
+CcXstreamClientError cc_xstream_client_dir_open(CcXstreamServerConnection s,
+ unsigned long *handle);
+CcXstreamClientError cc_xstream_client_dir_read(CcXstreamServerConnection s,
+ unsigned long handle,
+ char **name,
+ char **info);
+CcXstreamClientError cc_xstream_client_close(CcXstreamServerConnection s,
+ unsigned long handle);
+CcXstreamClientError cc_xstream_client_file_forward(CcXstreamServerConnection s,
+ unsigned long handle,
+ CC_UINT_64_TYPE_NAME bytes,
+ int seek_eof_if_fails);
+CcXstreamClientError cc_xstream_client_file_backwards(CcXstreamServerConnection s,
+ unsigned long handle,
+ CC_UINT_64_TYPE_NAME bytes,
+ int rewind_if_fails);
+
+CcXstreamClientError cc_xstream_client_file_rewind(CcXstreamServerConnection s,
+ unsigned long handle);
+CcXstreamClientError cc_xstream_client_file_end(CcXstreamServerConnection s,
+ unsigned long handle);
+CcXstreamClientError cc_xstream_client_file_info(CcXstreamServerConnection s,
+ const char *path,
+ char **info);
+CcXstreamClientError cc_xstream_client_set_configuration_option(CcXstreamServerConnection s,
+ const char *option,
+ const char *value);
+CcXstreamClientError cc_xstream_client_password_authenticate(CcXstreamServerConnection s,
+ const char *user_id,
+ const char *password);
+
+/* Server discovery function. May not be supported in all systems. */
+
+typedef void (*CcXstreamServerDiscoveryCB)(const char *addr,
+ const char *port,
+ const char *version,
+ const char *comment,
+ void *context);
+
+CcXstreamClientError ccx_client_discover_servers(CcXstreamServerDiscoveryCB callback, void *context);
+
+
+#define CC_XSTREAM_CLIENT_VERSION_STR "XBMSP-1.0 CcXstream Client Library " CC_XSTREAM_SW_VERSION
+#define CC_XSTREAM_CLIENT_VERSION "1.0"
+
+/* If the server end is inresponsive for 10 seconds, connection will halt. */
+#define CCXSTREAM_CLIENT_TIMEOUT_SECONDS 10
+
+#endif /* CC_XCLIENT_H_INCLUDED */
+/* eof (ccxclient.h) */
diff --git a/lib/libXBMS/ccxclientconnxbox.c b/lib/libXBMS/ccxclientconnxbox.c
new file mode 100644
index 0000000000..18fac062ac
--- /dev/null
+++ b/lib/libXBMS/ccxclientconnxbox.c
@@ -0,0 +1,196 @@
+// Place the code and data below here into the LIBXBMS section.
+#ifndef __GNUC__
+#pragma code_seg( "LIBXBMS" )
+#pragma data_seg( "LIBXBMS_RW" )
+#pragma bss_seg( "LIBXBMS_RW" )
+#pragma const_seg( "LIBXBMS_RD" )
+#pragma comment(linker, "/merge:LIBXBMS_RW=LIBXBMS")
+#pragma comment(linker, "/merge:LIBXBMS_RD=LIBXBMS")
+#endif
+/* -*- c -*-
+ *
+ * ----------------------------------------------------------------------
+ * CcXstream Client Library for XBMC Media Center
+ * ----------------------------------------------------------------------
+ *
+ * Copyright (c) 2002-2003 by PuhPuh
+ *
+ * This code is copyrighted property of the author. It can still
+ * be used for any non-commercial purpose following conditions:
+ *
+ * 1) This copyright notice is not removed.
+ * 2) Source code follows any distribution of the software
+ * if possible.
+ * 3) Copyright notice above is found in the documentation
+ * of the distributed software.
+ *
+ * Any express or implied warranties are disclaimed. Author is
+ * not liable for any direct or indirect damages caused by the use
+ * of this software.
+ *
+ * ----------------------------------------------------------------------
+ *
+ * This code has been integrated into XBMC Media Center.
+ * As such it can me copied, redistributed and modified under
+ * the same conditions as the XBMC itself.
+ *
+ */
+#include "ccincludes.h"
+#include "ccbuffer.h"
+#include "ccxclient.h"
+
+#ifndef _XBOX
+#define CC_XSTREAM_SOCKET_FD_TYPE int
+#define CC_XSTREAM_SOCKET_CLOSE close
+#define CC_XSTREAM_SOCKET_WRITE(s, b, l) write((s), (b), (l))
+#define CC_XSTREAM_SOCKET_READ(s, b, l) read((s), (b), (l))
+#else /* ! _XBOX */
+#define CC_XSTREAM_SOCKET_FD_TYPE SOCKET
+#define CC_XSTREAM_SOCKET_CLOSE closesocket
+#define CC_XSTREAM_SOCKET_WRITE(s, b, l) send((s), (b), (l), 0)
+#define CC_XSTREAM_SOCKET_READ(s, b, l) recv((s), (b), (l), 0)
+#endif /* ! _XBOX */
+
+static void cc_xstream_client_socket_setup(CC_XSTREAM_SOCKET_FD_TYPE sock)
+{
+#ifdef TCP_NODELAY
+ int i;
+
+ i = 1;
+ setsockopt(sock, IPPROTO_TCP,TCP_NODELAY, (char *)(&i), sizeof (i));
+#endif /* TCP_NODELAY */
+}
+
+CcXstreamClientError cc_xstream_client_connect(const char *host,
+ int port,
+ CcXstreamServerConnection *s)
+{
+ CC_XSTREAM_SOCKET_FD_TYPE sock;
+ struct sockaddr_in sa;
+#ifndef _XBOX
+ struct hostent *he;
+#endif /* ! _XBOX */
+
+ memset(&sa, 0, sizeof (sa));
+ sa.sin_port = htons(port);
+ sa.sin_family = AF_INET;
+ if (inet_addr(host) == INADDR_NONE)
+ {
+#ifndef _XBOX
+ he = gethostbyname(host);
+ if ((he == NULL) || (he->h_addrtype != AF_INET) || (he->h_length != 4))
+ return CC_XSTREAM_CLIENT_SERVER_NOT_FOUND;
+ memcpy(&(sa.sin_addr), he->h_addr, 4);
+#else /* ! _XBOX */
+ return CC_XSTREAM_CLIENT_SERVER_NOT_FOUND;
+#endif /* ! _XBOX */
+ }
+ else
+ {
+ sa.sin_addr.s_addr = inet_addr(host);
+ }
+ sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
+ if (sock < 0)
+ return CC_XSTREAM_CLIENT_FATAL_ERROR;
+ if (connect(sock, (struct sockaddr *)&sa, sizeof (sa)) != 0)
+ {
+ CC_XSTREAM_SOCKET_CLOSE(sock);
+ return CC_XSTREAM_CLIENT_SERVER_CONNECTION_FAILED;
+ }
+ cc_xstream_client_socket_setup(sock);
+ *s = (CcXstreamServerConnection)sock;
+ return CC_XSTREAM_CLIENT_OK;
+}
+
+CcXstreamClientError cc_xstream_client_disconnect(CcXstreamServerConnection s)
+{
+ CC_XSTREAM_SOCKET_FD_TYPE sock;
+
+ sock = (CC_XSTREAM_SOCKET_FD_TYPE)s;
+ CC_XSTREAM_SOCKET_CLOSE(s);
+ return CC_XSTREAM_CLIENT_OK;
+}
+
+unsigned char *cc_xstream_client_read_data(CcXstreamServerConnection s,
+ size_t len,
+ unsigned long timeout_ms)
+{
+ unsigned char *buf;
+ size_t done;
+ CC_XSTREAM_SOCKET_FD_TYPE sock;
+ int rv;
+ struct timeval tv;
+ fd_set fds;
+
+ /* Convert the conenction handle to simple file descriptor. */
+ sock = (CC_XSTREAM_SOCKET_FD_TYPE)s;
+
+ /* We terminate incoming buffer just to make code safer.
+ Caller should not count on it anyway. */
+ buf = cc_xmalloc(len + 1);
+ buf[len] = '\0';
+
+ for (done = 0; done < len; /*NOTHING*/)
+ {
+ if (timeout_ms > 0)
+ {
+ tv.tv_sec = timeout_ms / 1000U;
+ tv.tv_usec = (timeout_ms % 1000U) * 1000U;
+ FD_ZERO(&fds);
+ FD_SET(sock, &fds);
+ if (select(sock + 1, &fds, NULL, NULL, &tv) != 1)
+ {
+ /* Timeout or error, we don't really care. */
+ cc_xfree(buf);
+ return NULL;
+ }
+ }
+ rv = CC_XSTREAM_SOCKET_READ(sock, buf + done, len - done);
+ if (rv < 1)
+ {
+ cc_xfree(buf);
+ return NULL;
+ }
+ done += rv;
+ }
+ return buf;
+}
+
+int cc_xstream_client_write_data(CcXstreamServerConnection s,
+ unsigned char *buf,
+ size_t len,
+ unsigned long timeout_ms)
+{
+ size_t done;
+ CC_XSTREAM_SOCKET_FD_TYPE sock;
+ int rv;
+ struct timeval tv;
+ fd_set fds;
+
+ /* Convert the conenction handle to simple file descriptor. */
+ sock = (CC_XSTREAM_SOCKET_FD_TYPE)s;
+
+ for (done = 0; done < len; /*NOTHING*/)
+ {
+ if (timeout_ms > 0)
+ {
+ tv.tv_sec = timeout_ms / 1000U;
+ tv.tv_usec = (timeout_ms % 1000U) * 1000U;
+ FD_ZERO(&fds);
+ FD_SET(sock, &fds);
+ if (select(sock + 1, NULL, &fds, NULL, &tv) != 1)
+ {
+ /* Timeout or error, we don't really care. */
+ cc_xfree(buf);
+ return 0;
+ }
+ }
+ rv = CC_XSTREAM_SOCKET_WRITE(sock, buf + done, len - done);
+ if (rv < 1)
+ return 0;
+ done += rv;
+ }
+ return 1;
+}
+
+/* eof (ccxclientconn.c) */
diff --git a/lib/libXBMS/ccxdiscover.c b/lib/libXBMS/ccxdiscover.c
new file mode 100644
index 0000000000..b2502ef108
--- /dev/null
+++ b/lib/libXBMS/ccxdiscover.c
@@ -0,0 +1,228 @@
+// Place the code and data below here into the LIBXBMS section.
+#ifndef __GNUC__
+#pragma code_seg( "LIBXBMS" )
+#pragma data_seg( "LIBXBMS_RW" )
+#pragma bss_seg( "LIBXBMS_RW" )
+#pragma const_seg( "LIBXBMS_RD" )
+#pragma comment(linker, "/merge:LIBXBMS_RW=LIBXBMS")
+#pragma comment(linker, "/merge:LIBXBMS_RD=LIBXBMS")
+#endif
+/* -*- c -*-
+ *
+ * ----------------------------------------------------------------------
+ * CcXstream Client Library for XBMC Media Center (Server Discovery)
+ * ----------------------------------------------------------------------
+ *
+ * Copyright (c) 2002-2003 by PuhPuh
+ *
+ * This code is copyrighted property of the author. It can still
+ * be used for any non-commercial purpose following conditions:
+ *
+ * 1) This copyright notice is not removed.
+ * 2) Source code follows any distribution of the software
+ * if possible.
+ * 3) Copyright notice above is found in the documentation
+ * of the distributed software.
+ *
+ * Any express or implied warranties are disclaimed. Author is
+ * not liable for any direct or indirect damages caused by the use
+ * of this software.
+ *
+ * ----------------------------------------------------------------------
+ *
+ * This code has been integrated into XBMC Media Center.
+ * As such it can me copied, redistributed and modified under
+ * the same conditions as the XBMC itself.
+ *
+ */
+
+#include "ccincludes.h"
+#include "ccbuffer.h"
+#include "ccxclient.h"
+#include "ccxencode.h"
+
+static unsigned long timeout_start()
+{
+#if defined (__linux__) || defined(__APPLE__) || defined (__NetBSD__) || defined (__FreeBSD__) || defined (__CYGWIN__) || defined (sun)
+ struct timeval tv;
+ unsigned long r;
+
+ gettimeofday(&tv, NULL);
+ r = (((unsigned long)tv.tv_sec) % 200000000U) * 10U;
+ r += ((unsigned long)tv.tv_usec) / 100000U;
+ return r;
+#elif defined (_XBOX)
+ return ((unsigned long)(GetTickCount()) / 100U);
+#else
+ time_t t;
+
+ t = time(NULL);
+ return (((unsigned long)t) % 200000000U) * 10U;
+#endif
+}
+
+static int timeout_exceeded(unsigned long start_time)
+{
+ unsigned long t;
+
+ t = timeout_start();
+ return ((t < start_time) || ((start_time + 9) < t));
+}
+
+CcXstreamClientError ccx_client_discover_servers(CcXstreamServerDiscoveryCB callback, void *context)
+{
+ struct sockaddr_in sa, ra;
+#if defined (_XBOX) || defined (WIN32)
+ size_t sa_len, ra_len;
+#else
+ socklen_t sa_len, ra_len;
+#endif
+ unsigned long handle, p_len, p_handle;
+ unsigned char *packet, ch;
+ size_t packet_len;
+ int found = 0, l, c;
+#if defined (_XBOX) || defined (WIN32)
+ SOCKET sock;
+#else
+ int sock;
+#endif
+ unsigned long t0;
+ fd_set rs;
+ struct timeval tv;
+ CcBufferRec buf[1], seen_buf[1];
+ char *p_address, *p_port, *p_version, *p_comment;
+
+ memset(&sa, 0, sizeof (sa));
+ sa.sin_family = AF_INET;
+ sa.sin_addr.s_addr = htonl(INADDR_BROADCAST);
+ sa.sin_port = htons(CC_XSTREAM_DEFAULT_PORT);
+ sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
+ if (sock < 0)
+ return CC_XSTREAM_CLIENT_COMMAND_FAILED;
+ c = 1;
+ setsockopt(sock, SOL_SOCKET, SO_BROADCAST, (char *)(&c), sizeof (c));
+ handle = cc_xstream_client_mkpacket_server_discovery(&packet, &packet_len);
+ sa_len = sizeof (sa);
+ sendto(sock, packet, packet_len, 0, (struct sockaddr *)(&sa), sa_len);
+ t0 = timeout_start();
+ cc_buffer_init(seen_buf);
+ while (1)
+ {
+ if (timeout_exceeded(t0))
+ {
+ cc_buffer_uninit(seen_buf);
+ break;
+ }
+ FD_ZERO(&rs);
+ FD_SET(sock, &rs);
+ tv.tv_sec = 0;
+ tv.tv_usec = 350000;
+ switch (select(sock + 1, &rs, NULL, NULL, &tv))
+ {
+ case -1:
+#if defined (_XBOX) || defined (WIN32)
+ closesocket(sock);
+#else
+ close(sock);
+#endif
+ cc_buffer_uninit(seen_buf);
+ cc_xfree(packet);
+ return (found > 0) ? CC_XSTREAM_CLIENT_OK : CC_XSTREAM_CLIENT_COMMAND_FAILED;
+ /*NOTREACHED*/
+
+ case 0:
+ /* Resend packet if we got timeout. */
+ sendto(sock, packet, packet_len, 0, (struct sockaddr *)(&sa), sa_len);
+ break;
+
+ default:
+ memset(&ra, 0, sizeof (ra));
+ cc_buffer_init(buf);
+ cc_buffer_append_space(buf, 2000);
+ ra_len = sizeof (ra);
+ l = recvfrom(sock, cc_buffer_ptr(buf), cc_buffer_len(buf), 0, (struct sockaddr *)(&ra), &ra_len);
+ if (l > 0)
+ {
+ cc_buffer_consume_end(buf, cc_buffer_len(buf) - l);
+ if (cc_xstream_buffer_decode_int(buf, &p_len) &&
+ (p_len == cc_buffer_len(buf)) &&
+ cc_xstream_buffer_decode_byte(buf, &ch) &&
+ ((CcXstreamPacket)ch == CC_XSTREAM_XBMSP_PACKET_SERVER_DISCOVERY_REPLY) &&
+ cc_xstream_buffer_decode_int(buf, &p_handle) &&
+ (p_handle == handle) &&
+ cc_xstream_buffer_decode_string(buf, (unsigned char **)(&p_address), NULL) &&
+ cc_xstream_buffer_decode_string(buf, (unsigned char **)(&p_port), NULL) &&
+ cc_xstream_buffer_decode_string(buf, (unsigned char **)(&p_version), NULL) &&
+ cc_xstream_buffer_decode_string(buf, (unsigned char **)(&p_comment), NULL) &&
+ (cc_buffer_len(buf) == 0))
+ {
+ if (strlen(p_address) == 0)
+ {
+ cc_xfree(p_address);
+#ifdef _XBOX
+ {
+ unsigned char *b;
+
+ b = (unsigned char *)(&(ra.sin_addr.s_addr));
+ p_address = cc_xmalloc(32);
+ sprintf(p_address, "%d.%d.%d.%d", (int)(b[0]), (int)(b[1]), (int)(b[2]), (int)(b[3]));
+ }
+#else
+ p_address = cc_xstrdup(inet_ntoa(ra.sin_addr));
+#endif
+ }
+ if (strlen(p_port) == 0)
+ {
+ cc_xfree(p_port);
+ p_port = cc_xmalloc(16);
+#ifdef _XBOX
+ sprintf(p_port, "%d", (int)(ntohs(ra.sin_port)));
+#else
+ snprintf(p_port, 16, "%d", (int)(ntohs(ra.sin_port)));
+#endif
+ }
+ cc_buffer_append_string(buf, ">");
+ cc_buffer_append_string(buf, p_address);
+ cc_buffer_append_string(buf, ":");
+ cc_buffer_append_string(buf, p_port);
+ cc_buffer_append_string(buf, "<");
+ ch = 0;
+ /* Terminate both buffers with '\0' */
+ cc_buffer_append(buf, &ch, 1);
+ cc_buffer_append(seen_buf, &ch, 1);
+ if (strstr((char *)cc_buffer_ptr(seen_buf), (char *)cc_buffer_ptr(buf)) == NULL)
+ {
+ /* Don't forget to remove the terminating '\0' */
+ cc_buffer_consume_end(seen_buf, 1);
+ cc_buffer_append_string(seen_buf, (char *)cc_buffer_ptr(buf));
+ if (callback != NULL)
+ (*callback)(p_address, p_port, p_version, p_comment, context);
+ found++;
+ }
+ else
+ {
+ /* Don't forget to remove the terminating '\0' */
+ cc_buffer_consume_end(seen_buf, 1);
+ }
+ cc_buffer_clear(buf);
+ cc_xfree(p_address);
+ cc_xfree(p_port);
+ cc_xfree(p_version);
+ cc_xfree(p_comment);
+ }
+ }
+ cc_buffer_uninit(buf);
+ break;
+ }
+ }
+#if defined (_XBOX) || defined (WIN32)
+ closesocket(sock);
+#else
+ close(sock);
+#endif
+ cc_xfree(packet);
+
+ return (found > 0) ? CC_XSTREAM_CLIENT_OK : CC_XSTREAM_CLIENT_SERVER_NOT_FOUND;
+}
+
+/* eof (ccxdiscover.c) */
diff --git a/lib/libXBMS/ccxencode.c b/lib/libXBMS/ccxencode.c
new file mode 100644
index 0000000000..94f8a36d12
--- /dev/null
+++ b/lib/libXBMS/ccxencode.c
@@ -0,0 +1,181 @@
+// Place the code and data below here into the LIBXBMS section.
+#ifndef __GNUC__
+#pragma code_seg( "LIBXBMS" )
+#pragma data_seg( "LIBXBMS_RW" )
+#pragma bss_seg( "LIBXBMS_RW" )
+#pragma const_seg( "LIBXBMS_RD" )
+#pragma comment(linker, "/merge:LIBXBMS_RW=LIBXBMS")
+#pragma comment(linker, "/merge:LIBXBMS_RD=LIBXBMS")
+#endif
+/* -*- c -*-
+ *
+ * ----------------------------------------------------------------------
+ * Protocol packet encode/decode for CcXstream Server for XBMC Media Center
+ * ----------------------------------------------------------------------
+ *
+ * Copyright (c) 2002-2003 by PuhPuh
+ *
+ * This code is copyrighted property of the author. It can still
+ * be used for any non-commercial purpose following conditions:
+ *
+ * 1) This copyright notice is not removed.
+ * 2) Source code follows any distribution of the software
+ * if possible.
+ * 3) Copyright notice above is found in the documentation
+ * of the distributed software.
+ *
+ * Any express or implied warranties are disclaimed. Author is
+ * not liable for any direct or indirect damages caused by the use
+ * of this software.
+ *
+ * ----------------------------------------------------------------------
+ *
+ * This code has been integrated into XBMC Media Center.
+ * As such it can me copied, redistributed and modified under
+ * the same conditions as the XBMC itself.
+ *
+ */
+
+#include "ccincludes.h"
+#include "ccbuffer.h"
+#include "ccxencode.h"
+
+void cc_xstream_encode_int(unsigned char *buf, unsigned long x)
+{
+ buf[3] = (unsigned char)(x & 0xff);
+ x >>= 8;
+ buf[2] = (unsigned char)(x & 0xff);
+ x >>= 8;
+ buf[1] = (unsigned char)(x & 0xff);
+ x >>= 8;
+ buf[0] = (unsigned char)(x & 0xff);
+}
+
+void cc_xstream_buffer_encode_int(CcBuffer buf, unsigned long x)
+{
+ cc_buffer_append_space(buf, 4);
+ cc_xstream_encode_int(cc_buffer_ptr(buf) + cc_buffer_len(buf) - 4, x);
+}
+
+void cc_xstream_buffer_encode_int64(CcBuffer buf, CC_UINT_64_TYPE_NAME x)
+{
+ unsigned char nb[8];
+
+ nb[7] = (unsigned char)(x & 0xff);
+ x >>= 8;
+ nb[6] = (unsigned char)(x & 0xff);
+ x >>= 8;
+ nb[5] = (unsigned char)(x & 0xff);
+ x >>= 8;
+ nb[4] = (unsigned char)(x & 0xff);
+ x >>= 8;
+ nb[3] = (unsigned char)(x & 0xff);
+ x >>= 8;
+ nb[2] = (unsigned char)(x & 0xff);
+ x >>= 8;
+ nb[1] = (unsigned char)(x & 0xff);
+ x >>= 8;
+ nb[0] = (unsigned char)(x & 0xff);
+ cc_buffer_append(buf, nb, 8);
+}
+
+void cc_xstream_buffer_encode_byte(CcBuffer buf, unsigned char b)
+{
+ cc_buffer_append(buf, &b, 1);
+}
+
+void cc_xstream_buffer_encode_data_string(CcBuffer buf, const unsigned char *str, size_t str_len)
+{
+ cc_xstream_buffer_encode_int(buf, (unsigned long)str_len);
+ cc_buffer_append(buf, str, str_len);
+}
+
+void cc_xstream_buffer_encode_string(CcBuffer buf, const char *str)
+{
+ size_t str_len;
+
+ str_len = strlen(str);
+ cc_xstream_buffer_encode_int(buf, (unsigned long)str_len);
+ cc_buffer_append(buf, (unsigned char *)str, str_len);
+}
+
+void cc_xstream_buffer_encode_packet_length(CcBuffer buf)
+{
+ unsigned long len;
+ unsigned char hlp[4];
+
+ len = (unsigned long)cc_buffer_len(buf);
+ cc_xstream_encode_int(hlp, len);
+ cc_buffer_prepend(buf, hlp, 4);
+}
+
+
+unsigned long cc_xstream_decode_int(const unsigned char *buf)
+{
+ unsigned long r;
+
+ r = (unsigned long)(buf[0]);
+ r <<= 8;
+ r |= (unsigned long)(buf[1]);
+ r <<= 8;
+ r |= (unsigned long)(buf[2]);
+ r <<= 8;
+ r |= (unsigned long)(buf[3]);
+ return r;
+}
+
+int cc_xstream_buffer_decode_int(CcBuffer buf, unsigned long *x)
+{
+ if (cc_buffer_len(buf) < 4)
+ return 0;
+ *x = cc_xstream_decode_int(cc_buffer_ptr(buf));
+ cc_buffer_consume(buf, 4);
+ return 1;
+}
+
+int cc_xstream_buffer_decode_int64(CcBuffer buf, CC_UINT_64_TYPE_NAME *x)
+{
+ CC_UINT_64_TYPE_NAME r;
+ unsigned char *b;
+ int i;
+
+ if (cc_buffer_len(buf) < 8)
+ return 0;
+ r = 0;
+ for (i = 0; i < 8; i++)
+ {
+ b = cc_buffer_ptr(buf) + i;
+ r = (r << 8) | (CC_UINT_64_TYPE_NAME)(*b);
+ }
+ *x = r;
+ cc_buffer_consume(buf, 8);
+ return 1;
+}
+
+int cc_xstream_buffer_decode_byte(CcBuffer buf, unsigned char *b)
+{
+ if (cc_buffer_len(buf) < 1)
+ return 0;
+ *b = *(cc_buffer_ptr(buf));
+ cc_buffer_consume(buf, 1);
+ return 1;
+}
+
+int cc_xstream_buffer_decode_string(CcBuffer buf, unsigned char **str, size_t *str_len)
+{
+ unsigned long len;
+
+ if (cc_buffer_len(buf) < 4)
+ return 0;
+ len = cc_xstream_decode_int(cc_buffer_ptr(buf));
+ if ((len + 4) > cc_buffer_len(buf))
+ return 0;
+ cc_buffer_consume(buf, 4);
+ if (str_len != NULL)
+ *str_len = (size_t)len;
+ *str = cc_xmemdup(cc_buffer_ptr(buf), len);
+ cc_buffer_consume(buf, len);
+ return 1;
+}
+
+/* eof (ccxencode.c) */
diff --git a/lib/libXBMS/ccxencode.h b/lib/libXBMS/ccxencode.h
new file mode 100644
index 0000000000..18d68b3530
--- /dev/null
+++ b/lib/libXBMS/ccxencode.h
@@ -0,0 +1,50 @@
+/* -*- c -*-
+ *
+ * ----------------------------------------------------------------------
+ * Protocol packet encode/decode for CcXstream Server for XBMC Media Center
+ * ----------------------------------------------------------------------
+ *
+ * Copyright (c) 2002-2003 by PuhPuh
+ *
+ * This code is copyrighted property of the author. It can still
+ * be used for any non-commercial purpose following conditions:
+ *
+ * 1) This copyright notice is not removed.
+ * 2) Source code follows any distribution of the software
+ * if possible.
+ * 3) Copyright notice above is found in the documentation
+ * of the distributed software.
+ *
+ * Any express or implied warranties are disclaimed. Author is
+ * not liable for any direct or indirect damages caused by the use
+ * of this software.
+ *
+ * ----------------------------------------------------------------------
+ *
+ * This code has been integrated into XBMC Media Center.
+ * As such it can me copied, redistributed and modified under
+ * the same conditions as the XBMC itself.
+ *
+ */
+
+#ifndef CC_XENCODE_H_INCLUDED
+#define CC_XENCODE_H_INCLUDED 1
+
+#include "ccbuffer.h"
+
+void cc_xstream_encode_int(unsigned char *buf, unsigned long x);
+void cc_xstream_buffer_encode_int(CcBuffer buf, unsigned long x);
+void cc_xstream_buffer_encode_int64(CcBuffer buf, CC_UINT_64_TYPE_NAME x);
+void cc_xstream_buffer_encode_byte(CcBuffer buf, unsigned char b);
+void cc_xstream_buffer_encode_string(CcBuffer buf, const char *str);
+void cc_xstream_buffer_encode_data_string(CcBuffer buf, const unsigned char *str, size_t str_len);
+void cc_xstream_buffer_encode_packet_length(CcBuffer buf);
+
+unsigned long cc_xstream_decode_int(const unsigned char *buf);
+int cc_xstream_buffer_decode_int(CcBuffer buf, unsigned long *x);
+int cc_xstream_buffer_decode_int64(CcBuffer buf, CC_UINT_64_TYPE_NAME *x);
+int cc_xstream_buffer_decode_byte(CcBuffer buf, unsigned char *b);
+int cc_xstream_buffer_decode_string(CcBuffer buf, unsigned char **str, size_t *str_len);
+
+#endif /* CC_XENCODE_H_INCLUDED */
+/* eof (ccxencode.h) */
diff --git a/lib/libXBMS/ccxmltrans.c b/lib/libXBMS/ccxmltrans.c
new file mode 100644
index 0000000000..ef06dc0ce3
--- /dev/null
+++ b/lib/libXBMS/ccxmltrans.c
@@ -0,0 +1,161 @@
+// Place the code and data below here into the LIBXBMS section.
+#ifndef __GNUC__
+#pragma code_seg( "LIBXBMS" )
+#pragma data_seg( "LIBXBMS_RW" )
+#pragma bss_seg( "LIBXBMS_RW" )
+#pragma const_seg( "LIBXBMS_RD" )
+#pragma comment(linker, "/merge:LIBXBMS_RW=LIBXBMS")
+#pragma comment(linker, "/merge:LIBXBMS_RD=LIBXBMS")
+#endif
+/* -*- c -*-
+ *
+ * ----------------------------------------------------------------------
+ * Translate raw strings so that they can be inserted into xml.
+ * ----------------------------------------------------------------------
+ *
+ * Copyright (c) 2002-2003 by PuhPuh
+ *
+ * This code is copyrighted property of the author. It can still
+ * be used for any non-commercial purpose following conditions:
+ *
+ * 1) This copyright notice is not removed.
+ * 2) Source code follows any distribution of the software
+ * if possible.
+ * 3) Copyright notice above is found in the documentation
+ * of the distributed software.
+ *
+ * Any express or implied warranties are disclaimed. Author is
+ * not liable for any direct or indirect damages caused by the use
+ * of this software.
+ *
+ * ----------------------------------------------------------------------
+ *
+ * This code has been integrated into XBMC Media Center.
+ * As such it can me copied, redistributed and modified under
+ * the same conditions as the XBMC itself.
+ *
+ */
+
+#include "ccincludes.h"
+#include "ccbuffer.h"
+#include "ccxmltrans.h"
+
+typedef struct {
+ char *raw;
+ char *xml;
+} CcXstreamXmlTranslationRec, *CcXstreamXmlTranslation;
+
+#ifndef __GNUC__
+#pragma code_seg()
+#pragma data_seg()
+#pragma bss_seg()
+#pragma const_seg()
+#endif
+
+static CcXstreamXmlTranslationRec cc_xml_translation[] = {
+ { ">", "&gt;" },
+ { "<", "&lt;" },
+ { "/", "&slash;" },
+ { "\\", "&backslash;" },
+ { "\"", "&doublequote;" },
+ { "&", "&amp;" },
+ { NULL, NULL }
+};
+
+#ifndef __GNUC__
+#pragma code_seg( "LIBXBMS" )
+#pragma data_seg( "LIBXBMS_RW" )
+#pragma bss_seg( "LIBXBMS_RW" )
+#pragma const_seg( "LIBXBMS_RD" )
+#pragma comment(linker, "/merge:LIBXBMS_RW=LIBXBMS")
+#pragma comment(linker, "/merge:LIBXBMS_RD=LIBXBMS")
+#endif
+
+char *cc_xstream_xml_encode(const char *raw)
+{
+ CcBufferRec buf[1];
+ const char *tmp;
+ char *r, cb[16];
+ int i;
+ unsigned int x;
+
+ cc_buffer_init(buf);
+ for (tmp = raw; *tmp != '\0'; /*NOTHING*/)
+ {
+ for (i = 0; cc_xml_translation[i].raw != NULL; i++)
+ {
+ if (strncmp(tmp, cc_xml_translation[i].raw, strlen(cc_xml_translation[i].raw)) == 0)
+ {
+ cc_buffer_append_string(buf, cc_xml_translation[i].xml);
+ tmp += strlen(cc_xml_translation[i].raw);
+ break;
+ }
+ }
+ if (cc_xml_translation[i].raw == NULL)
+ {
+ if (isprint(*tmp) && ((! isspace(*tmp)) || (*tmp == ' ')))
+ {
+ cc_buffer_append(buf, (unsigned char *)tmp, 1);
+ }
+ else
+ {
+ x = (unsigned int)(*tmp);
+ sprintf(cb, "&%04x;", x);
+ cc_buffer_append_string(buf, cb);
+ }
+ tmp++;
+ }
+ }
+ r = cc_xmemdup(cc_buffer_ptr(buf), cc_buffer_len(buf));
+ cc_buffer_uninit(buf);
+ return r;
+}
+
+char *cc_xstream_xml_decode(const char *xml)
+{
+ CcBufferRec buf[1];
+ const char *tmp;
+ char *r;
+ unsigned long l;
+ unsigned char c;
+ int i;
+
+ cc_buffer_init(buf);
+ for (tmp = xml; *tmp != '\0'; /*NOTHING*/)
+ {
+ for (i = 0; cc_xml_translation[i].xml != NULL; i++)
+ {
+ if (strncmp(tmp, cc_xml_translation[i].xml, strlen(cc_xml_translation[i].xml)) == 0)
+ {
+ cc_buffer_append_string(buf, cc_xml_translation[i].raw);
+ tmp += strlen(cc_xml_translation[i].xml);
+ break;
+ }
+ }
+ if (cc_xml_translation[i].raw == NULL)
+ {
+ if ((tmp[0] == '&') &&
+ (tmp[1] == '0') &&
+ (tmp[2] == '0') &&
+ (isxdigit(tmp[3])) &&
+ (isxdigit(tmp[4])) &&
+ (tmp[5] == ';'))
+ {
+ l = strtoul(tmp + 1, NULL, 16);
+ c = (unsigned char)l;
+ cc_buffer_append(buf, &c, 1);
+ tmp += 6;
+ }
+ else
+ {
+ cc_buffer_append(buf, (unsigned char *)tmp, 1);
+ tmp++;
+ }
+ }
+ }
+ r = cc_xmemdup(cc_buffer_ptr(buf), cc_buffer_len(buf));
+ cc_buffer_uninit(buf);
+ return r;
+}
+
+/* eof (ccxmltrans.c) */
diff --git a/lib/libXBMS/ccxmltrans.h b/lib/libXBMS/ccxmltrans.h
new file mode 100644
index 0000000000..c279a79579
--- /dev/null
+++ b/lib/libXBMS/ccxmltrans.h
@@ -0,0 +1,37 @@
+/* -*- c -*-
+ *
+ * ----------------------------------------------------------------------
+ * Translate raw strings so that they can be inserted into xml.
+ * ----------------------------------------------------------------------
+ *
+ * Copyright (c) 2002-2003 by PuhPuh
+ *
+ * This code is copyrighted property of the author. It can still
+ * be used for any non-commercial purpose following conditions:
+ *
+ * 1) This copyright notice is not removed.
+ * 2) Source code follows any distribution of the software
+ * if possible.
+ * 3) Copyright notice above is found in the documentation
+ * of the distributed software.
+ *
+ * Any express or implied warranties are disclaimed. Author is
+ * not liable for any direct or indirect damages caused by the use
+ * of this software.
+ *
+ * ----------------------------------------------------------------------
+ *
+ * This code has been integrated into XBMC Media Center.
+ * As such it can me copied, redistributed and modified under
+ * the same conditions as the XBMC itself.
+ *
+ */
+
+#ifndef CC_XMLTRANS_H_INCLUDED
+#define CC_XMLTRANS_H_INCLUDED 1
+
+char *cc_xstream_xml_encode(const char *raw);
+char *cc_xstream_xml_decode(const char *xml);
+
+#endif /* CC_XMLTRANS_H_INCLUDED */
+/* eof (ccxmltrans.h) */
diff --git a/lib/libXBMS/ccxpacket.h b/lib/libXBMS/ccxpacket.h
new file mode 100644
index 0000000000..aa01dfd02b
--- /dev/null
+++ b/lib/libXBMS/ccxpacket.h
@@ -0,0 +1,81 @@
+/* -*- c -*-
+ *
+ * ----------------------------------------------------------------------
+ * Protocol packet definitions for CcXstream Server for XBMC Media Center
+ * ----------------------------------------------------------------------
+ *
+ * Copyright (c) 2002-2003 by PuhPuh
+ *
+ * This code is copyrighted property of the author. It can still
+ * be used for any non-commercial purpose following conditions:
+ *
+ * 1) This copyright notice is not removed.
+ * 2) Source code follows any distribution of the software
+ * if possible.
+ * 3) Copyright notice above is found in the documentation
+ * of the distributed software.
+ *
+ * Any express or implied warranties are disclaimed. Author is
+ * not liable for any direct or indirect damages caused by the use
+ * of this software.
+ *
+ * ----------------------------------------------------------------------
+ *
+ * This code has been integrated into XBMC Media Center.
+ * As such it can me copied, redistributed and modified under
+ * the same conditions as the XBMC itself.
+ *
+ */
+
+#ifndef CC_XPACKET_H_INCLUDED
+#define CC_XPACKET_H_INCLUDED 1
+
+typedef enum {
+ /* Server -> Client */
+ CC_XSTREAM_XBMSP_PACKET_OK = 1,
+ CC_XSTREAM_XBMSP_PACKET_ERROR = 2,
+ CC_XSTREAM_XBMSP_PACKET_HANDLE = 3,
+ CC_XSTREAM_XBMSP_PACKET_FILE_DATA = 4,
+ CC_XSTREAM_XBMSP_PACKET_FILE_CONTENTS = 5,
+ CC_XSTREAM_XBMSP_PACKET_AUTHENTICATION_CONTINUE = 6,
+ /* Client -> Server */
+ CC_XSTREAM_XBMSP_PACKET_NULL = 10,
+ CC_XSTREAM_XBMSP_PACKET_SETCWD = 11,
+ CC_XSTREAM_XBMSP_PACKET_FILELIST_OPEN = 12,
+ CC_XSTREAM_XBMSP_PACKET_FILELIST_READ = 13,
+ CC_XSTREAM_XBMSP_PACKET_FILE_INFO = 14,
+ CC_XSTREAM_XBMSP_PACKET_FILE_OPEN = 15,
+ CC_XSTREAM_XBMSP_PACKET_FILE_READ = 16,
+ CC_XSTREAM_XBMSP_PACKET_FILE_SEEK = 17,
+ CC_XSTREAM_XBMSP_PACKET_CLOSE = 18,
+ CC_XSTREAM_XBMSP_PACKET_CLOSE_ALL = 19,
+ CC_XSTREAM_XBMSP_PACKET_SET_CONFIGURATION_OPTION = 20,
+ CC_XSTREAM_XBMSP_PACKET_AUTHENTICATION_INIT = 21,
+ CC_XSTREAM_XBMSP_PACKET_AUTHENTICATE = 22,
+ CC_XSTREAM_XBMSP_PACKET_UPCWD = 23,
+ /* Server discovery packets */
+ CC_XSTREAM_XBMSP_PACKET_SERVER_DISCOVERY_QUERY = 90,
+ CC_XSTREAM_XBMSP_PACKET_SERVER_DISCOVERY_REPLY = 91
+} CcXstreamPacket;
+
+typedef enum {
+ CC_XSTREAM_XBMSP_ERROR_OK = 0,
+ CC_XSTREAM_XBMSP_ERROR_FAILURE = 1,
+ CC_XSTREAM_XBMSP_ERROR_UNSUPPORTED = 2,
+ CC_XSTREAM_XBMSP_ERROR_NO_SUCH_FILE = 3,
+ CC_XSTREAM_XBMSP_ERROR_INVALID_FILE = 4,
+ CC_XSTREAM_XBMSP_ERROR_INVALID_HANDLE = 5,
+ CC_XSTREAM_XBMSP_ERROR_OPEN_FAILED = 6,
+ CC_XSTREAM_XBMSP_ERROR_TOO_MANY_OPEN_FILES = 7,
+ CC_XSTREAM_XBMSP_ERROR_TOO_LONG_READ = 8,
+ CC_XSTREAM_XBMSP_ERROR_ILLEGAL_SEEK = 9,
+ CC_XSTREAM_XBMSP_ERROR_OPTION_IS_READ_ONLY = 10,
+ CC_XSTREAM_XBMSP_ERROR_INVALID_OPTION_VALUE = 11,
+ CC_XSTREAM_XBMSP_ERROR_AUTHENTICATION_NEEDED = 12,
+ CC_XSTREAM_XBMSP_ERROR_AUTHENTICATION_FAILED = 13
+} CcXstreamError;
+
+#define CC_XSTREAM_DEFAULT_PORT 1400
+
+#endif /* CC_XPACKET_H_INCLUDED */
+/* eof (ccxpacket.h) */
diff --git a/lib/libXBMS/ccxversion.h b/lib/libXBMS/ccxversion.h
new file mode 100644
index 0000000000..79f6cd08d3
--- /dev/null
+++ b/lib/libXBMS/ccxversion.h
@@ -0,0 +1,3 @@
+#ifndef CC_XSTREAM_SW_VERSION
+#define CC_XSTREAM_SW_VERSION "1.0.14 for XBox"
+#endif /* ! CC_XSTREAM_SW_VERSION */
diff --git a/lib/libXBMS/libXBMS/libXBMS.vcproj b/lib/libXBMS/libXBMS/libXBMS.vcproj
new file mode 100644
index 0000000000..e8438ae4f9
--- /dev/null
+++ b/lib/libXBMS/libXBMS/libXBMS.vcproj
@@ -0,0 +1,226 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9,00"
+ Name="libXBMS"
+ ProjectGUID="{706163E2-5422-4A94-8464-082ADA8C2769}"
+ RootNamespace="libXBMS"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="196613"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)libs\$(ProjectName)\$(ConfigurationName)\"
+ IntermediateDirectory="$(SolutionDir)objs\$(ProjectName)\$(ConfigurationName)\"
+ ConfigurationType="4"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="..\..\..\win32\"
+ PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="4"
+ CompileAs="1"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLibrarianTool"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)libs\$(ProjectName)\$(ConfigurationName)\"
+ IntermediateDirectory="$(SolutionDir)objs\$(ProjectName)\$(ConfigurationName)\"
+ ConfigurationType="4"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="3"
+ EnableIntrinsicFunctions="true"
+ WholeProgramOptimization="false"
+ AdditionalIncludeDirectories="..\..\..\win32\"
+ PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE"
+ RuntimeLibrary="0"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ CompileAs="1"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLibrarianTool"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath="..\ccbuffer.c"
+ >
+ </File>
+ <File
+ RelativePath="..\ccutil.c"
+ >
+ </File>
+ <File
+ RelativePath="..\ccxclient.c"
+ >
+ </File>
+ <File
+ RelativePath="..\ccxclientconnxbox.c"
+ >
+ </File>
+ <File
+ RelativePath="..\ccxdiscover.c"
+ >
+ </File>
+ <File
+ RelativePath="..\ccxencode.c"
+ >
+ </File>
+ <File
+ RelativePath="..\ccxmltrans.c"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+ >
+ <File
+ RelativePath="..\ccbuffer.h"
+ >
+ </File>
+ <File
+ RelativePath="..\ccincludes.h"
+ >
+ </File>
+ <File
+ RelativePath="..\ccutil.h"
+ >
+ </File>
+ <File
+ RelativePath="..\ccxclient.h"
+ >
+ </File>
+ <File
+ RelativePath="..\ccxencode.h"
+ >
+ </File>
+ <File
+ RelativePath="..\ccxmltrans.h"
+ >
+ </File>
+ <File
+ RelativePath="..\ccxpacket.h"
+ >
+ </File>
+ <File
+ RelativePath="..\ccxversion.h"
+ >
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/lib/libXBMS/libXBMS/libXBMS.vcxproj b/lib/libXBMS/libXBMS/libXBMS.vcxproj
new file mode 100644
index 0000000000..2d9d4ebe36
--- /dev/null
+++ b/lib/libXBMS/libXBMS/libXBMS.vcxproj
@@ -0,0 +1,100 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{706163E2-5422-4A94-8464-082ADA8C2769}</ProjectGuid>
+ <RootNamespace>libXBMS</RootNamespace>
+ <Keyword>Win32Proj</Keyword>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <CharacterSet>Unicode</CharacterSet>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ <Import Project="..\..\..\project\VS2010Express\XBMC for Windows.props" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ <Import Project="..\..\..\project\VS2010Express\XBMC for Windows.props" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)libs\$(TargetName)\$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)objs\$(TargetName)\$(Configuration)\</IntDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)libs\$(TargetName)\$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)objs\$(TargetName)\$(Configuration)\</IntDir>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>..\..\..\xbmc\win32\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MinimalRebuild>true</MinimalRebuild>
+ <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>EditAndContinue</DebugInformationFormat>
+ <CompileAs>CompileAsC</CompileAs>
+ </ClCompile>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <Optimization>Full</Optimization>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <WholeProgramOptimization>false</WholeProgramOptimization>
+ <AdditionalIncludeDirectories>..\..\..\xbmc\win32\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ <CompileAs>CompileAsC</CompileAs>
+ </ClCompile>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="..\ccbuffer.c" />
+ <ClCompile Include="..\ccutil.c" />
+ <ClCompile Include="..\ccxclient.c" />
+ <ClCompile Include="..\ccxclientconnxbox.c" />
+ <ClCompile Include="..\ccxdiscover.c" />
+ <ClCompile Include="..\ccxencode.c" />
+ <ClCompile Include="..\ccxmltrans.c" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="..\ccbuffer.h" />
+ <ClInclude Include="..\ccincludes.h" />
+ <ClInclude Include="..\ccutil.h" />
+ <ClInclude Include="..\ccxclient.h" />
+ <ClInclude Include="..\ccxencode.h" />
+ <ClInclude Include="..\ccxmltrans.h" />
+ <ClInclude Include="..\ccxpacket.h" />
+ <ClInclude Include="..\ccxversion.h" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/lib/libXBMS/libXBMS/libXBMS.vcxproj.filters b/lib/libXBMS/libXBMS/libXBMS.vcxproj.filters
new file mode 100644
index 0000000000..31fef6745b
--- /dev/null
+++ b/lib/libXBMS/libXBMS/libXBMS.vcxproj.filters
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
+ <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
+ <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="..\ccbuffer.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\ccutil.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\ccxclient.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\ccxclientconnxbox.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\ccxdiscover.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\ccxencode.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\ccxmltrans.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="..\ccbuffer.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\ccincludes.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\ccutil.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\ccxclient.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\ccxencode.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\ccxmltrans.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\ccxpacket.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\ccxversion.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+</Project> \ No newline at end of file