diff --git a/.gitignore b/.gitignore index 12e1f48fc84d1..6c6f6b7f38bc4 100644 --- a/.gitignore +++ b/.gitignore @@ -1067,11 +1067,6 @@ lib/cmyth/Makefile /lib/libUPnP/Makefile -# /lib/libXBMS -/lib/libXBMS/Makefile -/lib/libXBMS/libXBMS/Debug -/lib/libXBMS/libXBMS/Release - # /lib/libXDAAP /lib/libXDAAP/Makefile /lib/libXDAAP/libXDAAP_win32/Debug diff --git a/Makefile.in b/Makefile.in index 5efe6cbed7cbf..478a9e1a1bb1a 100644 --- a/Makefile.in +++ b/Makefile.in @@ -55,7 +55,6 @@ BIN_DIRS= \ lib/libRTV \ xbmc/network/libscrobbler \ lib/libUPnP \ - lib/libXBMS \ lib/libXDAAP \ xbmc/dbwrappers \ lib/UnrarXLib \ @@ -329,8 +328,6 @@ lib/libRTV/librtv.a: force $(MAKE) -C lib/libRTV lib/libUPnP/libupnp.a: force $(MAKE) -C lib/libUPnP -lib/libXBMS/libxbms.a: force - $(MAKE) -C lib/libXBMS lib/libXDAAP/libxdaap.a: force $(MAKE) -C lib/libXDAAP lib/jsoncpp/src/lib_json/libjsoncpp.a: force @@ -457,7 +454,6 @@ xcode_depends: \ codecs libs python visualizations screensavers eventclients skins \ lib/libsquish/libsquish.a \ lib/libapetag/.libs/libapetag.a \ - lib/libXBMS/libxbms.a \ lib/libRTV/librtv.a \ lib/libXDAAP/libxdaap.a \ lib/jsoncpp/src/lib_json/libjsoncpp.a @@ -532,7 +528,6 @@ endif ifeq (@HAVE_XBMC_NONFREE@,1) OBJSXBMC+= \ - lib/libXBMS/libxbms.a \ lib/UnrarXLib/UnrarXLib.a endif diff --git a/configure.in b/configure.in index e98e383dfa56b..849a8167a816f 100644 --- a/configure.in +++ b/configure.in @@ -1391,7 +1391,6 @@ OUTPUT_FILES="Makefile \ xbmc/guilib/Makefile \ xbmc/interfaces/Makefile \ xbmc/network/Makefile \ - lib/libXBMS/Makefile \ lib/libRTV/Makefile \ lib/libexif/Makefile \ lib/libXDAAP/Makefile \ diff --git a/lib/libXBMS/Makefile.in b/lib/libXBMS/Makefile.in deleted file mode 100644 index 74b756a65d9a7..0000000000000 --- a/lib/libXBMS/Makefile.in +++ /dev/null @@ -1,8 +0,0 @@ -CFLAGS += -D_LINUX - -LIB=libxbms.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 deleted file mode 100644 index ae55d7fa706af..0000000000000 --- a/lib/libXBMS/ccbuffer.c +++ /dev/null @@ -1,184 +0,0 @@ -// 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 deleted file mode 100644 index bede1a0f0c3c7..0000000000000 --- a/lib/libXBMS/ccbuffer.h +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- 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 deleted file mode 100644 index a6d7ba99b9b97..0000000000000 --- a/lib/libXBMS/ccincludes.h +++ /dev/null @@ -1,79 +0,0 @@ -/* -*- 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 -#include -#include -#include -#include -#include -#include -#include - -#include "ccutil.h" - -#ifdef _XBOX -#include -#elif defined(_LINUX) -#include -#include -#include -#include -#include -#include -#else -#include -#include -#include -#define snprintf _snprintf -#endif /* _XBOX */ - -#if defined(__FreeBSD__) -#include -#endif - -//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 deleted file mode 100644 index 60882d12538e3..0000000000000 --- a/lib/libXBMS/ccutil.c +++ /dev/null @@ -1,110 +0,0 @@ -// 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 deleted file mode 100644 index 14569af2fead1..0000000000000 --- a/lib/libXBMS/ccutil.h +++ /dev/null @@ -1,50 +0,0 @@ -/* -*- 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 deleted file mode 100644 index 52540fc73197a..0000000000000 --- a/lib/libXBMS/ccxclient.c +++ /dev/null @@ -1,1262 +0,0 @@ -// 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 deleted file mode 100644 index 8c5266cdf621e..0000000000000 --- a/lib/libXBMS/ccxclient.h +++ /dev/null @@ -1,219 +0,0 @@ -/* -*- 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 deleted file mode 100644 index 09e293e4ffef3..0000000000000 --- a/lib/libXBMS/ccxclientconnxbox.c +++ /dev/null @@ -1,196 +0,0 @@ -// 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" - -#if !defined(_WIN32) -#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 /* _WIN32 */ -#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 - -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 deleted file mode 100644 index b2502ef108f61..0000000000000 --- a/lib/libXBMS/ccxdiscover.c +++ /dev/null @@ -1,228 +0,0 @@ -// 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 deleted file mode 100644 index 94f8a36d12c88..0000000000000 --- a/lib/libXBMS/ccxencode.c +++ /dev/null @@ -1,181 +0,0 @@ -// 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 deleted file mode 100644 index 18d68b3530926..0000000000000 --- a/lib/libXBMS/ccxencode.h +++ /dev/null @@ -1,50 +0,0 @@ -/* -*- 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 deleted file mode 100644 index ef06dc0ce38fc..0000000000000 --- a/lib/libXBMS/ccxmltrans.c +++ /dev/null @@ -1,161 +0,0 @@ -// 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[] = { - { ">", ">" }, - { "<", "<" }, - { "/", "&slash;" }, - { "\\", "&backslash;" }, - { "\"", "&doublequote;" }, - { "&", "&" }, - { 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 deleted file mode 100644 index c279a79579fd6..0000000000000 --- a/lib/libXBMS/ccxmltrans.h +++ /dev/null @@ -1,37 +0,0 @@ -/* -*- 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 deleted file mode 100644 index aa01dfd02b595..0000000000000 --- a/lib/libXBMS/ccxpacket.h +++ /dev/null @@ -1,81 +0,0 @@ -/* -*- 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 deleted file mode 100644 index 79f6cd08d3a5d..0000000000000 --- a/lib/libXBMS/ccxversion.h +++ /dev/null @@ -1,3 +0,0 @@ -#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 deleted file mode 100644 index e8438ae4f9cf3..0000000000000 --- a/lib/libXBMS/libXBMS/libXBMS.vcproj +++ /dev/null @@ -1,226 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/lib/libXBMS/libXBMS/libXBMS.vcxproj b/lib/libXBMS/libXBMS/libXBMS.vcxproj deleted file mode 100644 index 2d9d4ebe36620..0000000000000 --- a/lib/libXBMS/libXBMS/libXBMS.vcxproj +++ /dev/null @@ -1,100 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {706163E2-5422-4A94-8464-082ADA8C2769} - libXBMS - Win32Proj - - - - StaticLibrary - Unicode - true - - - StaticLibrary - Unicode - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - $(SolutionDir)libs\$(TargetName)\$(Configuration)\ - $(SolutionDir)objs\$(TargetName)\$(Configuration)\ - $(SolutionDir)libs\$(TargetName)\$(Configuration)\ - $(SolutionDir)objs\$(TargetName)\$(Configuration)\ - - - - Disabled - ..\..\..\xbmc\win32\;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - - - Level3 - EditAndContinue - CompileAsC - - - - - Full - true - false - ..\..\..\xbmc\win32\;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE%(PreprocessorDefinitions) - MultiThreaded - true - - - Level3 - ProgramDatabase - CompileAsC - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/lib/libXBMS/libXBMS/libXBMS.vcxproj.filters b/lib/libXBMS/libXBMS/libXBMS.vcxproj.filters deleted file mode 100644 index 31fef6745b79d..0000000000000 --- a/lib/libXBMS/libXBMS/libXBMS.vcxproj.filters +++ /dev/null @@ -1,62 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - \ No newline at end of file diff --git a/xbmc/FileItem.cpp b/xbmc/FileItem.cpp index dbe538f1eb38e..2b2ac5e5867ea 100644 --- a/xbmc/FileItem.cpp +++ b/xbmc/FileItem.cpp @@ -774,11 +774,6 @@ bool CFileItem::IsSmb() const return URIUtils::IsSmb(m_strPath); } -bool CFileItem::IsXBMS() const -{ - return URIUtils::IsXBMS(m_strPath); -} - bool CFileItem::IsURL() const { return URIUtils::IsURL(m_strPath); @@ -1990,13 +1985,10 @@ void CFileItemList::Stack() if (item->m_bIsFolder) { // only check known fast sources? - // xbms included because it supports file existance // NOTES: - // 1. xbms would not have worked previously: item->m_strPath.Left(5).Equals("xbms", false) - // 2. rars and zips may be on slow sources? is this supposed to be allowed? + // 1. rars and zips may be on slow sources? is this supposed to be allowed? if( !item->IsRemote() || item->IsSmb() - || item->IsXBMS() || URIUtils::IsInRAR(item->m_strPath) || URIUtils::IsInZIP(item->m_strPath) ) diff --git a/xbmc/Util.cpp b/xbmc/Util.cpp index 59c58684993c4..5fe222947ad23 100644 --- a/xbmc/Util.cpp +++ b/xbmc/Util.cpp @@ -176,10 +176,6 @@ CStdString CUtil::GetTitleFromPath(const CStdString& strFileNameAndPath, bool bI strFilename = url.GetHostName(); } } - // XBMSP Network - else if (url.GetProtocol() == "xbms" && strFilename.IsEmpty()) - strFilename = "XBMSP Network"; - // iTunes music share (DAAP) else if (url.GetProtocol() == "daap" && strFilename.IsEmpty()) strFilename = g_localizeStrings.Get(20174); diff --git a/xbmc/filesystem/FactoryDirectory.cpp b/xbmc/filesystem/FactoryDirectory.cpp index e1f978878d88b..2e5df7089cb4a 100644 --- a/xbmc/filesystem/FactoryDirectory.cpp +++ b/xbmc/filesystem/FactoryDirectory.cpp @@ -52,9 +52,6 @@ #include "SMBDirectory.h" #endif #endif -#if defined(HAS_FILESYSTEM_CCX) -#include "XBMSDirectory.h" -#endif #ifdef HAS_FILESYSTEM_CDDA #include "CDDADirectory.h" #endif @@ -160,9 +157,6 @@ IDirectory* CFactoryDirectory::Create(const CStdString& strPath) if (strProtocol == "smb") return new CSMBDirectory(); #endif #endif -#ifdef HAS_FILESYSTEM_CCX - if (strProtocol == "xbms") return new CXBMSDirectory(); -#endif #ifdef HAS_FILESYSTEM #ifdef HAS_FILESYSTEM_DAAP if (strProtocol == "daap") return new CDAAPDirectory(); diff --git a/xbmc/filesystem/FileFactory.cpp b/xbmc/filesystem/FileFactory.cpp index 8f004479b7040..337f00eb01e68 100644 --- a/xbmc/filesystem/FileFactory.cpp +++ b/xbmc/filesystem/FileFactory.cpp @@ -37,9 +37,6 @@ #include "FileSmb.h" #endif #endif -#ifdef HAS_FILESYSTEM_CCX -#include "FileXBMSP.h" -#endif #ifdef HAS_FILESYSTEM_CDDA #include "FileCDDA.h" #endif @@ -141,9 +138,6 @@ IFile* CFileFactory::CreateLoader(const CURL& url) else if (strProtocol == "smb") return new CFileSMB(); #endif #endif -#ifdef HAS_FILESYSTEM_CCX - else if (strProtocol == "xbms") return new CFileXBMSP(); -#endif #ifdef HAS_FILESYSTEM #ifdef HAS_FILESYSTEM_RTV else if (strProtocol == "rtv") return new CFileRTV(); diff --git a/xbmc/filesystem/FileXBMSP.cpp b/xbmc/filesystem/FileXBMSP.cpp deleted file mode 100644 index 0ec99f76f2c6d..0000000000000 --- a/xbmc/filesystem/FileXBMSP.cpp +++ /dev/null @@ -1,400 +0,0 @@ -/* -* XBMC Media Center -* Copyright (c) 2002 Frodo -* Portions Copyright (c) by the authors of ffmpeg and xvid -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -#include "FileXBMSP.h" -#include "utils/URIUtils.h" -#include "Directory.h" -#include "SectionLoader.h" -#include "URL.h" -#include "settings/AdvancedSettings.h" -#include "utils/CharsetConverter.h" -#include "utils/log.h" - -#include - -using namespace XFILE; - -namespace XFILE -{ - -static UINT64 strtouint64(const char *s) -{ - UINT64 r = 0; - - while ((*s != 0) && (isspace(*s))) - s++; - if (*s == '+') - s++; - while ((*s != 0) && (isdigit(*s))) - { - r = r * ((UINT64)10); - r += ((UINT64)(*s)) - ((UINT64)'0'); - s++; - } - return r; -} - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -CFileXBMSP::CFileXBMSP() -{ - CSectionLoader::Load("LIBXBMS"); - m_fileSize = 0; - m_bOpened = false; -} - -CFileXBMSP::~CFileXBMSP() -{ - Close(); - CSectionLoader::Unload("LIBXBMS"); -} - -//********************************************************************************************* -bool CFileXBMSP::Open(const CURL& urlUtf8) -{ - CStdString strURL = urlUtf8.Get(); - g_charsetConverter.utf8ToStringCharset(strURL); - - CURL url(strURL); - const char* strUserName = url.GetUserName().c_str(); - const char* strPassword = url.GetPassWord().c_str(); - const char* strHostName = url.GetHostName().c_str(); - const char* strFileName = url.GetFileName().c_str(); - int iport = url.GetPort(); - - char *tmp1, *tmp2, *info; - - if (m_bOpened) Close(); - - m_bOpened = false; - m_fileSize = 0; - m_filePos = 0; - - if (g_advancedSettings.m_logLevel >= LOG_LEVEL_DEBUG_SAMBA) - CLog::Log(LOGDEBUG,"xbms:open: %s",strFileName); - - if (cc_xstream_client_connect(strHostName, - (iport > 0) ? iport : 1400, - &m_connection) != CC_XSTREAM_CLIENT_OK) - { - CLog::Log(LOGDEBUG, "xbms:unable to connect"); - return false; - } - if (cc_xstream_client_version_handshake(m_connection) != CC_XSTREAM_CLIENT_OK) - { - CLog::Log(LOGDEBUG, "xbms:unable handshake"); - cc_xstream_client_disconnect(m_connection); - - return false; - } - - // Authenticate here! - if ((strPassword != NULL) && (strlen(strPassword) > 0)) - { - // We don't check the return value here. If authentication - // step fails, let's try if server lets us log in without - // authentication. - cc_xstream_client_password_authenticate(m_connection, - (strUserName != NULL) ? strUserName : "", - strPassword); - } - - CStdString strFile = URIUtils::GetFileName(strFileName); - - char szPath[1024]; - strcpy(szPath, ""); - if (strFile.size() != strlen(strFileName) ) - { - strncpy(szPath, strFileName, strlen(strFileName) - (strFile.size() + 1) ); - szPath[ strlen(strFileName) - (strFile.size() + 1)] = 0; - } - - - CStdString strDir; - strDir = ""; - - if (g_advancedSettings.m_logLevel >= LOG_LEVEL_DEBUG_SAMBA) - CLog::Log(LOGDEBUG,"xbms:setdir:/"); - - if (cc_xstream_client_setcwd(m_connection, "/") == CC_XSTREAM_CLIENT_OK) - { - CStdString strPath = szPath; - for (int i = 0; i < (int)strPath.size(); ++i) - { - if (strPath[i] == '/' || strPath[i] == '\\') - { - if (strDir != "") - { - if (g_advancedSettings.m_logLevel >= LOG_LEVEL_DEBUG_SAMBA) - CLog::Log(LOGDEBUG,"xbms:setdir: %s",strDir.c_str()); - - if (cc_xstream_client_setcwd(m_connection, strDir.c_str()) != CC_XSTREAM_CLIENT_OK) - { - CLog::Log(LOGDEBUG, "xbms:unable set dir"); - if (m_connection != 0) cc_xstream_client_disconnect(m_connection); - return false; - } - } - strDir = ""; - } - else - { - strDir += strPath[i]; - } - } - } - else - { - CLog::Log(LOGDEBUG, "xbms:unable set dir"); - if (m_connection != 0) cc_xstream_client_disconnect(m_connection); - return false; - } - if (strDir.size() > 0) - { - if (g_advancedSettings.m_logLevel >= LOG_LEVEL_DEBUG_SAMBA) - CLog::Log(LOGDEBUG,"xbms:setdir: %s",strDir.c_str()); - - if (cc_xstream_client_setcwd(m_connection, strDir.c_str()) != CC_XSTREAM_CLIENT_OK) - { - CLog::Log(LOGDEBUG, "xbms:unable set dir"); - if (m_connection != 0) cc_xstream_client_disconnect(m_connection); - return false; - } - } - - if (cc_xstream_client_file_info(m_connection, strFile.c_str(), &info) != CC_XSTREAM_CLIENT_OK) - { - CLog::Log(LOGDEBUG, "xbms:unable to get info for file: %s", strFile.c_str()); - cc_xstream_client_disconnect(m_connection); - return false; - } - - if (strstr(info, "file") != NULL) - { - tmp1 = strstr(info, ""); - tmp2 = strstr(info, ""); - if ((tmp1 != NULL) && (tmp2 != NULL) && (tmp2 > tmp1) && ((tmp2 - tmp1) < 22)) - { - m_fileSize = strtouint64(tmp1 + 6); - } - else - { - m_fileSize = 4000000000U; - } - } - else - { - m_fileSize = 4000000000U; - } - free(info); - - if (cc_xstream_client_file_open(m_connection, strFile.c_str(), &m_handle) != CC_XSTREAM_CLIENT_OK) - { - CLog::Log(LOGDEBUG, "xbms:unable to open file: %s", strFile.c_str()); - cc_xstream_client_disconnect(m_connection); - - return false; - } - m_bOpened = true; - - return true; -} - -bool CFileXBMSP::Exists(const CURL& url) -{ - bool exist(true); - exist = CFileXBMSP::Open(url); - Close(); - return exist; -} - -int CFileXBMSP::Stat(const CURL& url, struct __stat64* buffer) -{ - memset(buffer, 0, sizeof(struct __stat64)); - if (Open(url)) - { - buffer->st_size = this->m_fileSize; - buffer->st_mode = _S_IFREG; - Close(); - errno = 0; - return 0; - } - - int dot = url.GetFileName().rfind('.'); - int slash = url.GetFileName().rfind('/'); - if (dot <= slash) - if (CDirectory::Exists(url.Get())) - { - buffer->st_mode = _S_IFDIR; - return 0; - } - - errno = ENOENT; - return -1; -} - -//********************************************************************************************* -unsigned int CFileXBMSP::Read(void *lpBuf, int64_t uiBufSize) -{ - unsigned char *buf = NULL; - size_t buflen = 0; - size_t readsize; - - if (!m_bOpened) return 0; - - /* ccx has a max read size of 120k */ - if(uiBufSize > 120*1024) - readsize = 120*1024; - else - readsize = (size_t)uiBufSize; - - if (cc_xstream_client_file_read(m_connection, m_handle, readsize, &buf, &buflen) != - CC_XSTREAM_CLIENT_OK) - { - CLog::Log(LOGERROR, "xbms:cc_xstream_client_file_read reported error on read"); - free(buf); - return 0; - } - memcpy(lpBuf, buf, buflen); - m_filePos += buflen; - - free(buf); - - return buflen; -} - -//********************************************************************************************* -void CFileXBMSP::Close() -{ - - if (m_bOpened) - { - cc_xstream_client_close(m_connection, m_handle); - cc_xstream_client_disconnect(m_connection); - } - m_bOpened = false; - m_fileSize = 0; -} - -//********************************************************************************************* -int64_t CFileXBMSP::Seek(int64_t iFilePosition, int iWhence) -{ - UINT64 newpos; - - if (!m_bOpened) return -1; - - switch (iWhence) - { - case SEEK_SET: - // cur = pos - newpos = iFilePosition; - break; - case SEEK_CUR: - // cur += pos - newpos = m_filePos + iFilePosition; - break; - case SEEK_END: - // end += pos - newpos = m_fileSize + iFilePosition; - break; - default: - return -1; - } - - // We can't seek beyond EOF - if (newpos > m_fileSize) return -1; - - if (newpos == m_filePos) return m_filePos; - - if ( newpos == 0 ) - { - // goto beginning - if (cc_xstream_client_file_rewind(m_connection, m_handle) == CC_XSTREAM_CLIENT_OK) - { - m_filePos = newpos; - } - else - { - return -1; - } - } - else if ( newpos == m_fileSize ) - { - // goto end - if (cc_xstream_client_file_end(m_connection, m_handle) == CC_XSTREAM_CLIENT_OK) - { - m_filePos = newpos; - } - else - { - return -1; - } - } - else if (newpos > m_filePos) - { - //Fix for broken seeking when we are at position 0 when using -dvd-device - if (m_filePos == 0) - { - char cBuf[1]; - Read(cBuf, 1); - } - if (newpos == m_filePos) return m_filePos; - if (cc_xstream_client_file_forward(m_connection, m_handle, (size_t)(newpos - m_filePos), 0) == CC_XSTREAM_CLIENT_OK) - { - m_filePos = newpos; - } - else - { - return -1; - } - } - else if (newpos < m_filePos) - { - if (cc_xstream_client_file_backwards(m_connection, m_handle, (size_t)(m_filePos - newpos), 0) == CC_XSTREAM_CLIENT_OK) - { - m_filePos = newpos; - } - else - { - return -1; - } - } - return m_filePos; -} - -//********************************************************************************************* -int64_t CFileXBMSP::GetLength() -{ - if (!m_bOpened) return 0; - return m_fileSize; -} - -//********************************************************************************************* -int64_t CFileXBMSP::GetPosition() -{ - if (!m_bOpened) return 0; - return m_filePos; -} - -} - - diff --git a/xbmc/filesystem/FileXBMSP.h b/xbmc/filesystem/FileXBMSP.h deleted file mode 100644 index 1667c1fbfad80..0000000000000 --- a/xbmc/filesystem/FileXBMSP.h +++ /dev/null @@ -1,71 +0,0 @@ -/* -* XBMC Media Center -* Copyright (c) 2002 Frodo -* Portions Copyright (c) by the authors of ffmpeg and xvid -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ -// FileXBMSP.h: interface for the CFileXBMSP class. -// -////////////////////////////////////////////////////////////////////// - -#if !defined(AFX_FILEXMBMSP_H___INCLUDED_) -#define AFX_FILEXMBMSP_H___INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -#include "IFile.h" - -#ifdef _LINUX -#include "PlatformDefs.h" // SOCKET -#endif - -extern "C" -{ -#include "libXBMS/ccincludes.h" -#include "libXBMS/ccxclient.h" -} - -namespace XFILE -{ - -class CFileXBMSP : public IFile -{ -public: - CFileXBMSP(); - virtual ~CFileXBMSP(); - virtual int64_t GetPosition(); - virtual int64_t GetLength(); - virtual bool Open(const CURL& url); - virtual bool Exists(const CURL& url); - virtual int Stat(const CURL& url, struct __stat64* buffer); - virtual unsigned int Read(void* lpBuf, int64_t uiBufSize); - virtual int64_t Seek(int64_t iFilePosition, int iWhence = SEEK_SET); - virtual void Close(); -protected: - uint64_t m_fileSize; - uint64_t m_filePos; - SOCKET m_socket; -private: - CcXstreamServerConnection m_connection; - unsigned long m_handle; - bool m_bOpened; - -}; -} - -#endif // !defined(AFX_FILEXMBMSP_H___INCLUDED_) diff --git a/xbmc/filesystem/Makefile.in b/xbmc/filesystem/Makefile.in index c4710404375b7..7f636f6042ce6 100644 --- a/xbmc/filesystem/Makefile.in +++ b/xbmc/filesystem/Makefile.in @@ -89,10 +89,8 @@ SRCS=AddonsDirectory.cpp \ ifeq (@HAVE_XBMC_NONFREE@,1) SRCS+=FileRar.cpp \ - FileXBMSP.cpp \ RarDirectory.cpp \ RarManager.cpp \ - XBMSDirectory.cpp \ endif diff --git a/xbmc/filesystem/XBMSDirectory.cpp b/xbmc/filesystem/XBMSDirectory.cpp deleted file mode 100644 index dddb848c63511..0000000000000 --- a/xbmc/filesystem/XBMSDirectory.cpp +++ /dev/null @@ -1,295 +0,0 @@ -/* - * Copyright (C) 2005-2008 Team XBMC - * http://www.xbmc.org - * - * This Program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This Program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with XBMC; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * http://www.gnu.org/copyleft/gpl.html - * - */ - -#include "XBMSDirectory.h" -#include "SectionLoader.h" -#include "URL.h" -#include "FileItem.h" -#include "utils/CharsetConverter.h" -#include "utils/URIUtils.h" - -using namespace XFILE; - -extern "C" -{ -#include "libXBMS/ccincludes.h" -#include "libXBMS/ccbuffer.h" -#include "libXBMS/ccxclient.h" -#include "libXBMS/ccxmltrans.h" -} - - -struct DiscoveryCallbackContext -{ - CFileItemList *items; - const char *username; - const char *password; -}; - -static void DiscoveryCallback(const char *addr, const char *port, const char *version, - const char *comment, void *context); - -CXBMSDirectory::CXBMSDirectory(void) -{ - CSectionLoader::Load("LIBXBMS"); -} - -CXBMSDirectory::~CXBMSDirectory(void) -{ - CSectionLoader::Unload("LIBXBMS"); -} - -bool CXBMSDirectory::GetDirectory(const CStdString& strPathUtf8, CFileItemList &items) -{ - unsigned long handle; - char *filename, *fileinfo; - - CStdString strPath=strPathUtf8; - g_charsetConverter.utf8ToStringCharset(strPath); - - CURL url(strPath); - - CStdString strRoot = strPath; - URIUtils::AddSlashAtEnd(strPath); - - CcXstreamServerConnection conn = 0; - - if (strPath == "xbms://") - { - if (url.GetFileName() == "") - { - int iOldSize=items.Size(); - // Let's do the automatic discovery. - struct DiscoveryCallbackContext dc_context; - CStdString strPassword = url.GetPassWord(); - CStdString strUserName = url.GetUserName(); - - dc_context.items = &items; - dc_context.username = ((strUserName.c_str() != NULL) && (strlen(strUserName.c_str()) > 0)) ? strUserName.c_str() : NULL; - dc_context.password = ((strPassword.c_str() != NULL) && (strlen(strPassword.c_str()) > 0)) ? strPassword.c_str() : NULL; - ccx_client_discover_servers(DiscoveryCallback, (void *)(&dc_context)); - - return (items.Size()>iOldSize); - } - } - - if (cc_xstream_client_connect(url.GetHostName().c_str(), - (url.HasPort()) ? url.GetPort() : 1400, &conn) != CC_XSTREAM_CLIENT_OK) - { - if (conn != 0) cc_xstream_client_disconnect(conn); - - return false; - } - - if (cc_xstream_client_version_handshake(conn) != CC_XSTREAM_CLIENT_OK) - { - if (conn != 0) cc_xstream_client_disconnect(conn); - - return false; - } - - // Authenticate here! - CStdString strPassword = url.GetPassWord(); - CStdString strUserName = url.GetUserName(); - if (strPassword.size() && strUserName.size()) - { - // We don't check the return value here. If authentication - // step fails, let's try if server lets us log in without - // authentication. - cc_xstream_client_password_authenticate(conn, - strUserName.c_str(), - strPassword.c_str() ); - } - CStdString strFileName = url.GetFileName(); - CStdString strDir; - strDir = ""; - if (cc_xstream_client_setcwd(conn, "/") == CC_XSTREAM_CLIENT_OK) - { - CStdString strFile = url.GetFileName(); - for (int i = 0; i < (int)strFile.size(); ++i) - { - if (strFile[i] == '/' || strFile[i] == '\\') - { - if (strDir != "") - { - if (cc_xstream_client_setcwd(conn, strDir.c_str()) != CC_XSTREAM_CLIENT_OK) - { - if (conn != 0) cc_xstream_client_disconnect(conn); - return false; - } - } - strDir = ""; - } - else - { - strDir += strFile[i]; - } - } - } - else - { - if (conn != 0) cc_xstream_client_disconnect(conn); - return false; - } - if (strDir.size() > 0) - { - if (cc_xstream_client_setcwd(conn, strDir.c_str()) != CC_XSTREAM_CLIENT_OK) - { - if (conn != 0) cc_xstream_client_disconnect(conn); - - return false; - } - } - - if (cc_xstream_client_dir_open(conn, &handle) != CC_XSTREAM_CLIENT_OK) - { - if (conn != 0) cc_xstream_client_disconnect(conn); - - return false; - } - - while (cc_xstream_client_dir_read(conn, handle, &filename, &fileinfo) == CC_XSTREAM_CLIENT_OK) - { - if (*filename == '\0') - { - free(filename); - free(fileinfo); - break; - } - bool bIsDirectory = false; - - if (strstr(fileinfo, "directory")) - bIsDirectory = true; - - CStdString strLabel=filename; - g_charsetConverter.unknownToUTF8(strLabel); - CFileItemPtr pItem(new CFileItem(strLabel)); - - char* pstrSizeStart = strstr(fileinfo, ""); - char* pstrSizeEnd = strstr(fileinfo, ""); - if (pstrSizeStart && pstrSizeEnd) - { - char szSize[128]; - pstrSizeStart += strlen(""); - strncpy(szSize, pstrSizeStart, pstrSizeEnd - pstrSizeStart); - szSize[pstrSizeEnd - pstrSizeStart] = 0; - pItem->m_dwSize = _atoi64(szSize); - } - - char* pstrModificationStart = strstr(fileinfo, ""); - char* pstrModificationEnd = strstr(fileinfo, ""); - if (pstrModificationStart && pstrModificationEnd) - { - char szModification[128]; - pstrModificationStart += strlen(""); - strncpy(szModification, pstrModificationStart, pstrModificationEnd - pstrModificationStart); - szModification[pstrModificationEnd - pstrModificationStart] = 0; - int64_t lTimeDate = _atoi64(szModification); - - FILETIME fileTime, localTime; - LONGLONG ll = Int32x32To64(lTimeDate, 10000000) + 116444736000000000LL; - fileTime.dwLowDateTime = (DWORD) (ll & 0xFFFFFFFF); - fileTime.dwHighDateTime = (DWORD)(ll >> 32); - - FileTimeToLocalFileTime(&fileTime, &localTime); - pItem->m_dateTime=localTime; - - } - - - pItem->m_strPath = strRoot; - pItem->m_strPath += filename; - g_charsetConverter.unknownToUTF8(pItem->m_strPath); - pItem->m_bIsFolder = bIsDirectory; - if (pItem->m_bIsFolder) - URIUtils::AddSlashAtEnd(pItem->m_strPath); - - items.Add(pItem); - - free(filename); - free(fileinfo); - } - cc_xstream_client_close_all(conn); - - if (conn != 0) - cc_xstream_client_disconnect(conn); - - return true; -} - -static void DiscoveryCallback(const char *addr, const char *port, const char *version, - const char *comment, void *context) -{ - struct DiscoveryCallbackContext *c = (struct DiscoveryCallbackContext *)context; - - //Construct name - CStdString itemName = "Server: "; - CStdString strPath = "xbms://"; - itemName += addr; - - if (strcmp(port, "1400") != 0) - { - itemName += " Port: "; - itemName += port; - } - if (strlen(comment) > 0) - { - itemName += " ("; - itemName += comment; - itemName += ")"; - } - - // Construct URL - if (c->username != NULL) - { - strPath += c->username; - if (c->password != NULL) - { - strPath += ":"; - strPath += c->password; - } - strPath += "@"; - } - strPath += addr; - strPath += ":"; - strPath += port; - strPath += "/"; - - // Add to items - g_charsetConverter.unknownToUTF8(itemName); - CFileItemPtr pItem(new CFileItem(itemName)); - pItem->m_strPath = strPath; - g_charsetConverter.unknownToUTF8(pItem->m_strPath); - pItem->m_bIsFolder = true; - pItem->m_bIsShareOrDrive = true; - pItem->SetIconImage("DefaultNetwork.png"); - c->items->Add(pItem); -} -bool CXBMSDirectory::Exists(const char* strPath) -{ - CFileItemList items; - CStdString strPath2(strPath); - if (GetDirectory(strPath2,items)) - return true; - - return false; -} - diff --git a/xbmc/filesystem/XBMSDirectory.h b/xbmc/filesystem/XBMSDirectory.h deleted file mode 100644 index 98aac7476f27e..0000000000000 --- a/xbmc/filesystem/XBMSDirectory.h +++ /dev/null @@ -1,36 +0,0 @@ -#pragma once -/* - * Copyright (C) 2005-2008 Team XBMC - * http://www.xbmc.org - * - * This Program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This Program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with XBMC; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * http://www.gnu.org/copyleft/gpl.html - * - */ - -#include "IDirectory.h" - -namespace XFILE -{ -class CXBMSDirectory : - public IDirectory -{ -public: - CXBMSDirectory(void); - virtual ~CXBMSDirectory(void); - virtual bool GetDirectory(const CStdString& strPath, CFileItemList &items); - virtual bool Exists(const char* strPath); -}; -} diff --git a/xbmc/network/GUIDialogNetworkSetup.cpp b/xbmc/network/GUIDialogNetworkSetup.cpp index ef59c5cb21701..3643a4ea56600 100644 --- a/xbmc/network/GUIDialogNetworkSetup.cpp +++ b/xbmc/network/GUIDialogNetworkSetup.cpp @@ -133,7 +133,6 @@ void CGUIDialogNetworkSetup::OnInitWindow() pSpin->AddLabel(g_localizeStrings.Get(20257), NET_PROTOCOL_VTP); pSpin->AddLabel(g_localizeStrings.Get(20258), NET_PROTOCOL_MYTH); pSpin->AddLabel(g_localizeStrings.Get(21331), NET_PROTOCOL_TUXBOX); - pSpin->AddLabel(g_localizeStrings.Get(20172), NET_PROTOCOL_XBMSP); pSpin->AddLabel(g_localizeStrings.Get(20301), NET_PROTOCOL_HTTPS); pSpin->AddLabel(g_localizeStrings.Get(20300), NET_PROTOCOL_HTTP); pSpin->AddLabel(g_localizeStrings.Get(20254), NET_PROTOCOL_DAVS); @@ -198,8 +197,6 @@ void CGUIDialogNetworkSetup::OnProtocolChange() m_port = "80"; else if (m_protocol == NET_PROTOCOL_HTTPS || m_protocol == NET_PROTOCOL_DAVS) m_port = "443"; - else if (m_protocol == NET_PROTOCOL_XBMSP) - m_port = "1400"; else if (m_protocol == NET_PROTOCOL_DAAP) m_port = "3689"; else if (m_protocol == NET_PROTOCOL_HTSP) @@ -224,7 +221,7 @@ void CGUIDialogNetworkSetup::UpdateButtons() { SET_CONTROL_LABEL(CONTROL_SERVER_ADDRESS, 1009); // Server Address } - if (m_protocol == NET_PROTOCOL_XBMSP || m_protocol == NET_PROTOCOL_DAAP) + if (m_protocol == NET_PROTOCOL_DAAP) SendMessage(GUI_MSG_SET_TYPE, CONTROL_SERVER_ADDRESS, CGUIEditControl::INPUT_TYPE_IPADDRESS, 1016); else SendMessage(GUI_MSG_SET_TYPE, CONTROL_SERVER_ADDRESS, CGUIEditControl::INPUT_TYPE_TEXT, 1016); @@ -261,8 +258,7 @@ void CGUIDialogNetworkSetup::UpdateButtons() // port SET_CONTROL_LABEL2(CONTROL_PORT_NUMBER, m_port); - CONTROL_ENABLE_ON_CONDITION(CONTROL_PORT_NUMBER, m_protocol == NET_PROTOCOL_XBMSP || - m_protocol == NET_PROTOCOL_FTP || + CONTROL_ENABLE_ON_CONDITION(CONTROL_PORT_NUMBER, m_protocol == NET_PROTOCOL_FTP || m_protocol == NET_PROTOCOL_HTTP || m_protocol == NET_PROTOCOL_HTTPS || m_protocol == NET_PROTOCOL_DAV || @@ -304,8 +300,6 @@ CStdString CGUIDialogNetworkSetup::ConstructPath() const CURL url; if (m_protocol == NET_PROTOCOL_SMB) url.SetProtocol("smb"); - else if (m_protocol == NET_PROTOCOL_XBMSP) - url.SetProtocol("xbms"); else if (m_protocol == NET_PROTOCOL_FTP) url.SetProtocol("ftp"); else if (m_protocol == NET_PROTOCOL_HTTP) @@ -344,7 +338,6 @@ CStdString CGUIDialogNetworkSetup::ConstructPath() const (m_protocol == NET_PROTOCOL_DAV) || (m_protocol == NET_PROTOCOL_DAVS) || (m_protocol == NET_PROTOCOL_RSS) || - (m_protocol == NET_PROTOCOL_XBMSP && !m_server.IsEmpty()) || (m_protocol == NET_PROTOCOL_DAAP && !m_server.IsEmpty()) || (m_protocol == NET_PROTOCOL_HTSP) || (m_protocol == NET_PROTOCOL_VTP) || @@ -365,8 +358,6 @@ void CGUIDialogNetworkSetup::SetPath(const CStdString &path) const CStdString &protocol = url.GetProtocol(); if (protocol == "smb") m_protocol = NET_PROTOCOL_SMB; - else if (protocol == "xbms") - m_protocol = NET_PROTOCOL_XBMSP; else if (protocol == "ftp") m_protocol = NET_PROTOCOL_FTP; else if (protocol == "http") diff --git a/xbmc/system.h b/xbmc/system.h index 5ecd3164e2b18..014f6e99aa81d 100644 --- a/xbmc/system.h +++ b/xbmc/system.h @@ -71,11 +71,9 @@ #if defined(_LINUX) || defined(__APPLE__) #if defined(HAVE_XBMC_NONFREE) #define HAS_FILESYSTEM_RAR - #define HAS_FILESYSTEM_CCX #endif #else #define HAS_FILESYSTEM_RAR - #define HAS_FILESYSTEM_CCX #endif /***************** diff --git a/xbmc/utils/URIUtils.cpp b/xbmc/utils/URIUtils.cpp index e8c0c89ae07c9..1de51964da897 100644 --- a/xbmc/utils/URIUtils.cpp +++ b/xbmc/utils/URIUtils.cpp @@ -597,16 +597,6 @@ bool URIUtils::IsURL(const CStdString& strFile) return strFile.Find("://") >= 0; } -bool URIUtils::IsXBMS(const CStdString& strFile) -{ - CStdString strFile2(strFile); - - if (IsStack(strFile)) - strFile2 = CStackDirectory::GetFirstStackedFile(strFile); - - return strFile2.Left(5).Equals("xbms:"); -} - bool URIUtils::IsFTP(const CStdString& strFile) { CStdString strFile2(strFile); diff --git a/xbmc/windows/GUIMediaWindow.cpp b/xbmc/windows/GUIMediaWindow.cpp index 748fc3f0cf809..ee50bc0242bdb 100644 --- a/xbmc/windows/GUIMediaWindow.cpp +++ b/xbmc/windows/GUIMediaWindow.cpp @@ -1029,8 +1029,6 @@ void CGUIMediaWindow::ShowShareErrorMessage(CFileItem* pItem) if (pItem->m_iDriveType != CMediaSource::SOURCE_TYPE_REMOTE) // Local shares incl. dvd drive idMessageText=15300; - else if (url.GetProtocol() == "xbms" && strHostName.IsEmpty()) // xbms server discover - idMessageText=15302; else if (url.GetProtocol() == "smb" && strHostName.IsEmpty()) // smb workgroup idMessageText=15303; else // All other remote shares diff --git a/xbmc/windows/GUIWindowFileManager.cpp b/xbmc/windows/GUIWindowFileManager.cpp index 8175d4cf57e61..4f56a7fcead3a 100644 --- a/xbmc/windows/GUIWindowFileManager.cpp +++ b/xbmc/windows/GUIWindowFileManager.cpp @@ -1209,8 +1209,6 @@ void CGUIWindowFileManager::ShowShareErrorMessage(CFileItem* pItem) if (pItem->m_iDriveType!=CMediaSource::SOURCE_TYPE_REMOTE) // Local shares incl. dvd drive idMessageText=15300; - else if (url.GetProtocol()=="xbms" && strHostName.IsEmpty()) // xbms server discover - idMessageText=15302; else if (url.GetProtocol()=="smb" && strHostName.IsEmpty()) // smb workgroup idMessageText=15303; else // All other remote shares