Update rsp to latest version, integrate rsp build with standard win32 build

This commit is contained in:
Ron Pedde 2006-05-01 03:14:15 +00:00
parent 4d938a6f93
commit 465b1258a3
6 changed files with 221 additions and 23 deletions

View File

@ -441,7 +441,7 @@ char *strsep(char **stringp, const char *delim) {
x = strtok_r(NULL, "=", &sp); // x = NULL x = strtok_r(NULL, "=", &sp); // x = NULL
// s = "abc\0-def\0" // 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; char *spanp;
int c, sc; int c, sc;

View File

@ -10,6 +10,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "compat.h"
#include "mtd-plugins.h" #include "mtd-plugins.h"
#include "rsp.h" #include "rsp.h"
#include "xml-rpc.h" #include "xml-rpc.h"
@ -27,13 +28,19 @@ void rsp_error(WS_CONNINFO *pwsc, DBQUERYINFO *pqi, int eno, char *estr);
/* Globals */ /* Globals */
PLUGIN_OUTPUT_FN _pofn = { plugin_handler, plugin_auth }; PLUGIN_OUTPUT_FN _pofn = { plugin_handler, plugin_auth };
PLUGIN_REND_INFO _pri[] = {
{ "_rsp._tcp", NULL },
{ NULL, NULL }
};
PLUGIN_INFO _pi = { PLUGIN_INFO _pi = {
PLUGIN_VERSION, PLUGIN_VERSION,
PLUGIN_OUTPUT, PLUGIN_OUTPUT,
"rsp/" RSP_VERSION, "rsp/" RSP_VERSION,
"/rsp/.*", "/rsp/.*",
&_pofn, &_pofn,
NULL NULL,
_pri
}; };
typedef struct tag_response { typedef struct tag_response {

View File

@ -15,6 +15,7 @@
#include <time.h> #include <time.h>
#include <zlib.h> #include <zlib.h>
#include "compat.h"
#include "mtd-plugins.h" #include "mtd-plugins.h"
#include "rsp.h" #include "rsp.h"
#include "xml-rpc.h" #include "xml-rpc.h"
@ -27,7 +28,6 @@ typedef struct tag_xmlstack {
#define XML_STREAM_BLOCK 4096 #define XML_STREAM_BLOCK 4096
typedef struct tag_xml_streambuffer { typedef struct tag_xml_streambuffer {
int fd;
z_stream strm; z_stream strm;
unsigned char *in_buffer; unsigned char *in_buffer;
unsigned char *out_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); void xml_return_error(WS_CONNINFO *pwsc, int errno, char *errstr);
char *xml_entity_encode(char *original); char *xml_entity_encode(char *original);
XML_STREAMBUFFER *xml_stream_open(int fd); XML_STREAMBUFFER *xml_stream_open(void);
int xml_stream_write(XML_STREAMBUFFER *psb, char *out); int xml_stream_write(XMLSTRUCT *pxml, char *out);
int xml_stream_close(XML_STREAMBUFFER *psb); int xml_stream_close(XMLSTRUCT *pxml);
void xml_write(XMLSTRUCT *pxml, char *fmt, ...) { void xml_write(XMLSTRUCT *pxml, char *fmt, ...) {
char buffer[1024]; char buffer[1024];
@ -59,8 +59,7 @@ void xml_write(XMLSTRUCT *pxml, char *fmt, ...) {
va_end(ap); va_end(ap);
if(pxml->psb) { if(pxml->psb) {
infn->log(E_DBG,"Writing %d bytes to output\n",strlen(buffer)); xml_stream_write(pxml, buffer);
xml_stream_write(pxml->psb, buffer);
} else { } else {
infn->ws_writefd(pxml->pwsc,"%s",buffer); 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 * open a gzip stream
*/ */
XML_STREAMBUFFER *xml_stream_open(int fd) { XML_STREAMBUFFER *xml_stream_open(void) {
XML_STREAMBUFFER *psb; XML_STREAMBUFFER *psb;
psb = (XML_STREAMBUFFER*) malloc(sizeof(XML_STREAMBUFFER)); 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"); infn->log(E_FATAL,"xml_stream_open: malloc\n");
} }
psb->fd = fd;
psb->out_buffer = (unsigned char*) malloc(XML_STREAM_BLOCK); psb->out_buffer = (unsigned char*) malloc(XML_STREAM_BLOCK);
psb->in_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 * write a block to the stream
*/ */
int xml_stream_write(XML_STREAMBUFFER *psb, char *out) { int xml_stream_write(XMLSTRUCT *pxml, char *out) {
int bytes = strlen(out);
int done = 0; int done = 0;
int result; int result;
XML_STREAMBUFFER *psb = pxml->psb;
if((!out)||(!strlen(out))) if((!out)||(!strlen(out)))
return TRUE; return TRUE;
@ -126,8 +124,8 @@ int xml_stream_write(XML_STREAMBUFFER *psb, char *out) {
if(strlen(out) > 1024) if(strlen(out) > 1024)
return TRUE; return TRUE;
memcpy(psb->in_buffer,out,strlen(out)); memcpy(psb->in_buffer,out,(int)strlen(out));
psb->strm.avail_in = strlen(out); psb->strm.avail_in = (int)strlen(out);
psb->strm.next_in = psb->in_buffer; psb->strm.next_in = psb->in_buffer;
psb->strm.next_out = psb->out_buffer; psb->strm.next_out = psb->out_buffer;
psb->strm.avail_out = XML_STREAM_BLOCK; psb->strm.avail_out = XML_STREAM_BLOCK;
@ -137,11 +135,7 @@ int xml_stream_write(XML_STREAMBUFFER *psb, char *out) {
if(result != Z_OK) { if(result != Z_OK) {
infn->log(E_FATAL,"Error in zlib: %d\n",result); infn->log(E_FATAL,"Error in zlib: %d\n",result);
} }
/* FIXME: error handling */ infn->ws_writebinary(pxml->pwsc,psb->out_buffer,XML_STREAM_BLOCK-psb->strm.avail_out);
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);
if(psb->strm.avail_out != 0) { if(psb->strm.avail_out != 0) {
done=1; done=1;
} else { } else {
@ -155,8 +149,9 @@ int xml_stream_write(XML_STREAMBUFFER *psb, char *out) {
/** /**
* close the stream * close the stream
*/ */
int xml_stream_close(XML_STREAMBUFFER *psb) { int xml_stream_close(XMLSTRUCT *pxml) {
int done = 0; int done = 0;
XML_STREAMBUFFER *psb = pxml->psb;
/* flush what's left */ /* flush what's left */
while(!done) { while(!done) {
@ -166,7 +161,7 @@ int xml_stream_close(XML_STREAMBUFFER *psb) {
psb->strm.next_in = psb->in_buffer; psb->strm.next_in = psb->in_buffer;
deflate(&psb->strm,Z_FINISH); 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) if(psb->strm.avail_out != 0)
done=1; done=1;
@ -179,6 +174,8 @@ int xml_stream_close(XML_STREAMBUFFER *psb) {
if(psb->in_buffer != NULL) if(psb->in_buffer != NULL)
free(psb->in_buffer); free(psb->in_buffer);
free(psb); free(psb);
return TRUE;
} }
/** /**
@ -209,7 +206,7 @@ XMLSTRUCT *xml_init(WS_CONNINFO *pwsc, int emit_header) {
if((!nogzip) && (accept) && (strcasestr(accept,"gzip"))) { if((!nogzip) && (accept) && (strcasestr(accept,"gzip"))) {
infn->log(E_LOG,"Gzipping output\n"); infn->log(E_LOG,"Gzipping output\n");
pxml->psb = xml_stream_open(infn->ws_fd(pwsc)); pxml->psb = xml_stream_open();
if(pxml->psb) { if(pxml->psb) {
infn->ws_addresponseheader(pwsc,"Content-Encoding","gzip"); infn->ws_addresponseheader(pwsc,"Content-Encoding","gzip");
infn->ws_addresponseheader(pwsc,"Vary","Accept-Encoding"); infn->ws_addresponseheader(pwsc,"Vary","Accept-Encoding");
@ -321,7 +318,7 @@ void xml_deinit(XMLSTRUCT *pxml) {
} }
if(pxml->psb) { if(pxml->psb) {
xml_stream_close(pxml->psb); xml_stream_close(pxml);
} }
free(pxml); free(pxml);

29
win32/mt-daapd.sln Normal file
View File

@ -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

5
win32/rsp.def Normal file
View File

@ -0,0 +1,5 @@
LIBRARY rsp
EXPORTS
plugin_info

160
win32/rsp.vcproj Normal file
View File

@ -0,0 +1,160 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="rsp"
ProjectGUID="{68CCEA19-503F-4894-8AE3-B1673FDEA920}"
Keyword="Win32Proj">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="Debug"
IntermediateDirectory="rsp_Debug"
ConfigurationType="2"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\win32;.;..\src"
PreprocessorDefinitions="_WIN32;HAVE_CONFIG_H;ZLIB_DLL"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="4"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="zdll.lib"
OutputFile="$(OutDir)/rsp.dll"
LinkIncremental="2"
IgnoreAllDefaultLibraries="FALSE"
ModuleDefinitionFile="rsp.def"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="$(OutDir)/rsp.pdb"
SubSystem="2"
ImportLibrary="$(OutDir)/rsp.lib"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="Release"
IntermediateDirectory="rsp_Release"
ConfigurationType="2"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="..\win32;.;..\src"
PreprocessorDefinitions="_WIN32;HAVE_CONFIG_H;ZLIB_DLL"
RuntimeLibrary="0"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="3"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="zdll.lib"
OutputFile="$(OutDir)/rsp.dll"
LinkIncremental="1"
IgnoreAllDefaultLibraries="FALSE"
ModuleDefinitionFile="rsp.def"
GenerateDebugInformation="TRUE"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
ImportLibrary="$(OutDir)/rsp.lib"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
<File
RelativePath="..\src\plugins\compat.c">
</File>
<File
RelativePath="..\src\plugins\rsp.c">
</File>
<File
RelativePath=".\rsp.def">
</File>
<File
RelativePath="..\src\plugins\xml-rpc.c">
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
<File
RelativePath="..\src\plugins\compat.h">
</File>
<File
RelativePath="..\src\plugins\rsp.h">
</File>
<File
RelativePath="..\src\plugins\xml-rpc.h">
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>