diff --git a/src/plugins/compat.c b/src/plugins/compat.c index 1012e500..00e6fe4f 100644 --- a/src/plugins/compat.c +++ b/src/plugins/compat.c @@ -441,7 +441,7 @@ char *strsep(char **stringp, const char *delim) { x = strtok_r(NULL, "=", &sp); // x = NULL // s = "abc\0-def\0" */ -char *strtok_r(char *s, const char *delim, char **last) +char *strtok_r(char *s, char *delim, char **last) { char *spanp; int c, sc; diff --git a/src/plugins/rsp.c b/src/plugins/rsp.c index 34a92070..2d9a65ca 100644 --- a/src/plugins/rsp.c +++ b/src/plugins/rsp.c @@ -10,6 +10,7 @@ #include #include +#include "compat.h" #include "mtd-plugins.h" #include "rsp.h" #include "xml-rpc.h" @@ -27,13 +28,19 @@ void rsp_error(WS_CONNINFO *pwsc, DBQUERYINFO *pqi, int eno, char *estr); /* Globals */ PLUGIN_OUTPUT_FN _pofn = { plugin_handler, plugin_auth }; +PLUGIN_REND_INFO _pri[] = { + { "_rsp._tcp", NULL }, + { NULL, NULL } +}; + PLUGIN_INFO _pi = { PLUGIN_VERSION, PLUGIN_OUTPUT, "rsp/" RSP_VERSION, "/rsp/.*", &_pofn, - NULL + NULL, + _pri }; typedef struct tag_response { diff --git a/src/plugins/xml-rpc.c b/src/plugins/xml-rpc.c index 69ff9989..7af9ca2a 100644 --- a/src/plugins/xml-rpc.c +++ b/src/plugins/xml-rpc.c @@ -15,6 +15,7 @@ #include #include +#include "compat.h" #include "mtd-plugins.h" #include "rsp.h" #include "xml-rpc.h" @@ -27,7 +28,6 @@ typedef struct tag_xmlstack { #define XML_STREAM_BLOCK 4096 typedef struct tag_xml_streambuffer { - int fd; z_stream strm; unsigned char *in_buffer; unsigned char *out_buffer; @@ -46,9 +46,9 @@ void xml_set_config(WS_CONNINFO *pwsc); void xml_return_error(WS_CONNINFO *pwsc, int errno, char *errstr); char *xml_entity_encode(char *original); -XML_STREAMBUFFER *xml_stream_open(int fd); -int xml_stream_write(XML_STREAMBUFFER *psb, char *out); -int xml_stream_close(XML_STREAMBUFFER *psb); +XML_STREAMBUFFER *xml_stream_open(void); +int xml_stream_write(XMLSTRUCT *pxml, char *out); +int xml_stream_close(XMLSTRUCT *pxml); void xml_write(XMLSTRUCT *pxml, char *fmt, ...) { char buffer[1024]; @@ -59,8 +59,7 @@ void xml_write(XMLSTRUCT *pxml, char *fmt, ...) { va_end(ap); if(pxml->psb) { - infn->log(E_DBG,"Writing %d bytes to output\n",strlen(buffer)); - xml_stream_write(pxml->psb, buffer); + xml_stream_write(pxml, buffer); } else { infn->ws_writefd(pxml->pwsc,"%s",buffer); } @@ -84,7 +83,7 @@ void xml_return_error(WS_CONNINFO *pwsc, int errno, char *errstr) { /** * open a gzip stream */ -XML_STREAMBUFFER *xml_stream_open(int fd) { +XML_STREAMBUFFER *xml_stream_open(void) { XML_STREAMBUFFER *psb; psb = (XML_STREAMBUFFER*) malloc(sizeof(XML_STREAMBUFFER)); @@ -92,7 +91,6 @@ XML_STREAMBUFFER *xml_stream_open(int fd) { infn->log(E_FATAL,"xml_stream_open: malloc\n"); } - psb->fd = fd; psb->out_buffer = (unsigned char*) malloc(XML_STREAM_BLOCK); psb->in_buffer = (unsigned char*) malloc(XML_STREAM_BLOCK); @@ -115,10 +113,10 @@ XML_STREAMBUFFER *xml_stream_open(int fd) { /** * write a block to the stream */ -int xml_stream_write(XML_STREAMBUFFER *psb, char *out) { - int bytes = strlen(out); +int xml_stream_write(XMLSTRUCT *pxml, char *out) { int done = 0; int result; + XML_STREAMBUFFER *psb = pxml->psb; if((!out)||(!strlen(out))) return TRUE; @@ -126,8 +124,8 @@ int xml_stream_write(XML_STREAMBUFFER *psb, char *out) { if(strlen(out) > 1024) return TRUE; - memcpy(psb->in_buffer,out,strlen(out)); - psb->strm.avail_in = strlen(out); + memcpy(psb->in_buffer,out,(int)strlen(out)); + psb->strm.avail_in = (int)strlen(out); psb->strm.next_in = psb->in_buffer; psb->strm.next_out = psb->out_buffer; psb->strm.avail_out = XML_STREAM_BLOCK; @@ -137,11 +135,7 @@ int xml_stream_write(XML_STREAMBUFFER *psb, char *out) { if(result != Z_OK) { infn->log(E_FATAL,"Error in zlib: %d\n",result); } - /* FIXME: error handling */ - infn->log(E_DBG,"Writing %d bytes compressed info (avail: %d)\n", - XML_STREAM_BLOCK-psb->strm.avail_out, - psb->strm.avail_out); - write(psb->fd,psb->out_buffer,XML_STREAM_BLOCK-psb->strm.avail_out); + infn->ws_writebinary(pxml->pwsc,psb->out_buffer,XML_STREAM_BLOCK-psb->strm.avail_out); if(psb->strm.avail_out != 0) { done=1; } else { @@ -155,8 +149,9 @@ int xml_stream_write(XML_STREAMBUFFER *psb, char *out) { /** * close the stream */ -int xml_stream_close(XML_STREAMBUFFER *psb) { +int xml_stream_close(XMLSTRUCT *pxml) { int done = 0; + XML_STREAMBUFFER *psb = pxml->psb; /* flush what's left */ while(!done) { @@ -166,7 +161,7 @@ int xml_stream_close(XML_STREAMBUFFER *psb) { psb->strm.next_in = psb->in_buffer; deflate(&psb->strm,Z_FINISH); - write(psb->fd,psb->out_buffer,XML_STREAM_BLOCK - psb->strm.avail_out); + infn->ws_writebinary(pxml->pwsc,psb->out_buffer,XML_STREAM_BLOCK - psb->strm.avail_out); if(psb->strm.avail_out != 0) done=1; @@ -179,6 +174,8 @@ int xml_stream_close(XML_STREAMBUFFER *psb) { if(psb->in_buffer != NULL) free(psb->in_buffer); free(psb); + + return TRUE; } /** @@ -209,7 +206,7 @@ XMLSTRUCT *xml_init(WS_CONNINFO *pwsc, int emit_header) { if((!nogzip) && (accept) && (strcasestr(accept,"gzip"))) { infn->log(E_LOG,"Gzipping output\n"); - pxml->psb = xml_stream_open(infn->ws_fd(pwsc)); + pxml->psb = xml_stream_open(); if(pxml->psb) { infn->ws_addresponseheader(pwsc,"Content-Encoding","gzip"); infn->ws_addresponseheader(pwsc,"Vary","Accept-Encoding"); @@ -321,7 +318,7 @@ void xml_deinit(XMLSTRUCT *pxml) { } if(pxml->psb) { - xml_stream_close(pxml->psb); + xml_stream_close(pxml); } free(pxml); diff --git a/win32/mt-daapd.sln b/win32/mt-daapd.sln new file mode 100644 index 00000000..a0864683 --- /dev/null +++ b/win32/mt-daapd.sln @@ -0,0 +1,29 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mt-daapd", "mt-daapd.vcproj", "{CB40C666-11D7-456B-B774-BCA42F675BB5}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "rsp", "rsp.vcproj", "{68CCEA19-503F-4894-8AE3-B1673FDEA920}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {CB40C666-11D7-456B-B774-BCA42F675BB5}.Debug.ActiveCfg = Debug|Win32 + {CB40C666-11D7-456B-B774-BCA42F675BB5}.Debug.Build.0 = Debug|Win32 + {CB40C666-11D7-456B-B774-BCA42F675BB5}.Release.ActiveCfg = Release|Win32 + {CB40C666-11D7-456B-B774-BCA42F675BB5}.Release.Build.0 = Release|Win32 + {68CCEA19-503F-4894-8AE3-B1673FDEA920}.Debug.ActiveCfg = Debug|Win32 + {68CCEA19-503F-4894-8AE3-B1673FDEA920}.Debug.Build.0 = Debug|Win32 + {68CCEA19-503F-4894-8AE3-B1673FDEA920}.Release.ActiveCfg = Release|Win32 + {68CCEA19-503F-4894-8AE3-B1673FDEA920}.Release.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/win32/rsp.def b/win32/rsp.def new file mode 100644 index 00000000..8ff0e27f --- /dev/null +++ b/win32/rsp.def @@ -0,0 +1,5 @@ +LIBRARY rsp + +EXPORTS + plugin_info + diff --git a/win32/rsp.vcproj b/win32/rsp.vcproj new file mode 100644 index 00000000..f9552130 --- /dev/null +++ b/win32/rsp.vcproj @@ -0,0 +1,160 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +