diff options
| -rw-r--r-- | libcsoap/iconv.h | 132 | ||||
| -rw-r--r-- | libcsoap/libcsoap.vcproj | 208 | ||||
| -rw-r--r-- | libcsoap/soap-client.c | 163 | ||||
| -rw-r--r-- | libcsoap/soap-env.c | 615 | ||||
| -rw-r--r-- | libcsoap/soap-fault.c | 188 | ||||
| -rw-r--r-- | libcsoap/soap-router.c | 152 | ||||
| -rw-r--r-- | libcsoap/soap-server.c | 342 | ||||
| -rw-r--r-- | libcsoap/soap-service.c | 117 | ||||
| -rw-r--r-- | libcsoap/soap-xml.c | 189 | 
9 files changed, 1221 insertions, 885 deletions
| diff --git a/libcsoap/iconv.h b/libcsoap/iconv.h new file mode 100644 index 0000000..90c173b --- /dev/null +++ b/libcsoap/iconv.h @@ -0,0 +1,132 @@ +/* Copyright (C) 1999-2003 Free Software Foundation, Inc. +   This file is part of the GNU LIBICONV Library. + +   The GNU LIBICONV Library is free software; you can redistribute it +   and/or modify it under the terms of the GNU Library General Public +   License as published by the Free Software Foundation; either version 2 +   of the License, or (at your option) any later version. + +   The GNU LIBICONV Library 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 +   Library General Public License for more details. + +   You should have received a copy of the GNU Library General Public +   License along with the GNU LIBICONV Library; see the file COPYING.LIB. +   If not, write to the Free Software Foundation, Inc., 59 Temple Place - +   Suite 330, Boston, MA 02111-1307, USA.  */ + +/* When installed, this file is called "iconv.h". */ + +#ifndef _LIBICONV_H +#define _LIBICONV_H + +#define _LIBICONV_VERSION 0x0109    /* version number: (major<<8) + minor */ +extern int _libiconv_version;       /* Likewise */ + +/* We would like to #include any system header file which could define +   iconv_t, 1. in order to eliminate the risk that the user gets compilation +   errors because some other system header file includes /usr/include/iconv.h +   which defines iconv_t or declares iconv after this file, 2. when compiling +   for LIBICONV_PLUG, we need the proper iconv_t type in order to produce +   binary compatible code. +   But gcc's #include_next is not portable. Thus, once libiconv's iconv.h +   has been installed in /usr/local/include, there is no way any more to +   include the original /usr/include/iconv.h. We simply have to get away +   without it. +   Ad 1. The risk that a system header file does +   #include "iconv.h"  or  #include_next "iconv.h" +   is small. They all do #include <iconv.h>. +   Ad 2. The iconv_t type is a pointer type in all cases I have seen. (It +   has to be a scalar type because (iconv_t)(-1) is a possible return value +   from iconv_open().) */ + +/* Define iconv_t ourselves. */ +#undef iconv_t +#define iconv_t libiconv_t +typedef void* iconv_t; + +/* Get size_t declaration. */ +#include <stddef.h> + +/* Get errno declaration and values. */ +#include <errno.h> +/* Some systems, like SunOS 4, don't have EILSEQ. Some systems, like BSD/OS, +   have EILSEQ in a different header.  On these systems, define EILSEQ +   ourselves. */ +#ifndef EILSEQ +#define EILSEQ @EILSEQ@ +#endif + + +#ifdef __cplusplus +extern "C" { +#endif + + +/* Allocates descriptor for code conversion from encoding `fromcode' to +   encoding `tocode'. */ +#ifndef LIBICONV_PLUG +#define iconv_open libiconv_open +#endif +extern iconv_t iconv_open (const char* tocode, const char* fromcode); + +/* Converts, using conversion descriptor `cd', at most `*inbytesleft' bytes +   starting at `*inbuf', writing at most `*outbytesleft' bytes starting at +   `*outbuf'. +   Decrements `*inbytesleft' and increments `*inbuf' by the same amount. +   Decrements `*outbytesleft' and increments `*outbuf' by the same amount. */ +#ifndef LIBICONV_PLUG +#define iconv libiconv +#endif +extern size_t iconv (iconv_t cd, const char* * inbuf, size_t *inbytesleft, char* * outbuf, size_t *outbytesleft); + +/* Frees resources allocated for conversion descriptor `cd'. */ +#ifndef LIBICONV_PLUG +#define iconv_close libiconv_close +#endif +extern int iconv_close (iconv_t cd); + + +#ifndef LIBICONV_PLUG + +/* Nonstandard extensions. */ + +/* Control of attributes. */ +#define iconvctl libiconvctl +extern int iconvctl (iconv_t cd, int request, void* argument); + +/* Requests for iconvctl. */ +#define ICONV_TRIVIALP            0  /* int *argument */ +#define ICONV_GET_TRANSLITERATE   1  /* int *argument */ +#define ICONV_SET_TRANSLITERATE   2  /* const int *argument */ +#define ICONV_GET_DISCARD_ILSEQ   3  /* int *argument */ +#define ICONV_SET_DISCARD_ILSEQ   4  /* const int *argument */ + +/* Listing of locale independent encodings. */ +#define iconvlist libiconvlist +extern void iconvlist (int (*do_one) (unsigned int namescount, +                                      const char * const * names, +                                      void* data), +                       void* data); + +/* Support for relocatable packages.  */ + +/* Sets the original and the current installation prefix of the package. +   Relocation simply replaces a pathname starting with the original prefix +   by the corresponding pathname with the current prefix instead.  Both +   prefixes should be directory names without trailing slash (i.e. use "" +   instead of "/").  */ +extern void libiconv_set_relocation_prefix (const char *orig_prefix, +					    const char *curr_prefix); + +#endif + + +#ifdef __cplusplus +} +#endif + + +#endif /* _LIBICONV_H */ + diff --git a/libcsoap/libcsoap.vcproj b/libcsoap/libcsoap.vcproj new file mode 100644 index 0000000..a9a9537 --- /dev/null +++ b/libcsoap/libcsoap.vcproj @@ -0,0 +1,208 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject +	ProjectType="Visual C++" +	Version="7.10" +	Name="libcsoap" +	ProjectGUID="{80806CD0-3D07-43C7-A08A-02CAB634D0CD}" +	Keyword="Win32Proj"> +	<Platforms> +		<Platform +			Name="Win32"/> +	</Platforms> +	<Configurations> +		<Configuration +			Name="Debug|Win32" +			OutputDirectory="Debug" +			IntermediateDirectory="Debug" +			ConfigurationType="4" +			CharacterSet="2"> +			<Tool +				Name="VCCLCompilerTool" +				Optimization="0" +				AdditionalIncludeDirectories="..\,.\" +				PreprocessorDefinitions="WIN32;_DEBUG;_LIB" +				MinimalRebuild="TRUE" +				BasicRuntimeChecks="0" +				RuntimeLibrary="5" +				UsePrecompiledHeader="0" +				WarningLevel="3" +				Detect64BitPortabilityProblems="TRUE" +				DebugInformationFormat="4" +				CompileAs="2"/> +			<Tool +				Name="VCCustomBuildTool"/> +			<Tool +				Name="VCLibrarianTool" +				OutputFile="$(OutDir)/libcsoap.lib" +				AdditionalLibraryDirectories="" +				IgnoreAllDefaultLibraries="TRUE"/> +			<Tool +				Name="VCMIDLTool"/> +			<Tool +				Name="VCPostBuildEventTool"/> +			<Tool +				Name="VCPreBuildEventTool"/> +			<Tool +				Name="VCPreLinkEventTool"/> +			<Tool +				Name="VCResourceCompilerTool"/> +			<Tool +				Name="VCWebServiceProxyGeneratorTool"/> +			<Tool +				Name="VCXMLDataGeneratorTool"/> +			<Tool +				Name="VCManagedWrapperGeneratorTool"/> +			<Tool +				Name="VCAuxiliaryManagedWrapperGeneratorTool"/> +		</Configuration> +		<Configuration +			Name="Release|Win32" +			OutputDirectory="Release" +			IntermediateDirectory="Release" +			ConfigurationType="4" +			CharacterSet="2"> +			<Tool +				Name="VCCLCompilerTool" +				AdditionalIncludeDirectories="..\,.\" +				PreprocessorDefinitions="WIN32;NDEBUG;_LIB" +				RuntimeLibrary="4" +				UsePrecompiledHeader="0" +				WarningLevel="3" +				Detect64BitPortabilityProblems="TRUE" +				DebugInformationFormat="3"/> +			<Tool +				Name="VCCustomBuildTool"/> +			<Tool +				Name="VCLibrarianTool" +				OutputFile="$(OutDir)/libcsoap.lib" +				AdditionalLibraryDirectories="" +				IgnoreAllDefaultLibraries="TRUE"/> +			<Tool +				Name="VCMIDLTool"/> +			<Tool +				Name="VCPostBuildEventTool"/> +			<Tool +				Name="VCPreBuildEventTool"/> +			<Tool +				Name="VCPreLinkEventTool"/> +			<Tool +				Name="VCResourceCompilerTool"/> +			<Tool +				Name="VCWebServiceProxyGeneratorTool"/> +			<Tool +				Name="VCXMLDataGeneratorTool"/> +			<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=".\soap-client.c"> +				<FileConfiguration +					Name="Release|Win32"> +					<Tool +						Name="VCCLCompilerTool" +						CompileAs="2"/> +				</FileConfiguration> +			</File> +			<File +				RelativePath=".\soap-env.c"> +				<FileConfiguration +					Name="Release|Win32"> +					<Tool +						Name="VCCLCompilerTool" +						CompileAs="2"/> +				</FileConfiguration> +			</File> +			<File +				RelativePath=".\soap-fault.c"> +				<FileConfiguration +					Name="Release|Win32"> +					<Tool +						Name="VCCLCompilerTool" +						CompileAs="2"/> +				</FileConfiguration> +			</File> +			<File +				RelativePath=".\soap-router.c"> +				<FileConfiguration +					Name="Release|Win32"> +					<Tool +						Name="VCCLCompilerTool" +						CompileAs="2"/> +				</FileConfiguration> +			</File> +			<File +				RelativePath=".\soap-server.c"> +				<FileConfiguration +					Name="Release|Win32"> +					<Tool +						Name="VCCLCompilerTool" +						CompileAs="2"/> +				</FileConfiguration> +			</File> +			<File +				RelativePath=".\soap-service.c"> +				<FileConfiguration +					Name="Release|Win32"> +					<Tool +						Name="VCCLCompilerTool" +						CompileAs="2"/> +				</FileConfiguration> +			</File> +			<File +				RelativePath=".\soap-xml.c"> +				<FileConfiguration +					Name="Release|Win32"> +					<Tool +						Name="VCCLCompilerTool" +						CompileAs="2"/> +				</FileConfiguration> +			</File> +		</Filter> +		<Filter +			Name="Header Files" +			Filter="h;hpp;hxx;hm;inl;inc;xsd" +			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"> +			<File +				RelativePath=".\soap-client.h"> +			</File> +			<File +				RelativePath=".\soap-env.h"> +			</File> +			<File +				RelativePath=".\soap-fault.h"> +			</File> +			<File +				RelativePath=".\soap-router.h"> +			</File> +			<File +				RelativePath=".\soap-server.h"> +			</File> +			<File +				RelativePath=".\soap-service.h"> +			</File> +			<File +				RelativePath=".\soap-xml.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> +		<File +			RelativePath=".\ReadMe.txt"> +		</File> +	</Files> +	<Globals> +	</Globals> +</VisualStudioProject> diff --git a/libcsoap/soap-client.c b/libcsoap/soap-client.c index f7e4536..46e9192 100644 --- a/libcsoap/soap-client.c +++ b/libcsoap/soap-client.c @@ -1,29 +1,29 @@  /****************************************************************** - *  $Id: soap-client.c,v 1.3 2004/04/14 09:20:36 snowdrop Exp $ - * - * CSOAP Project:  A SOAP client/server library in C - * Copyright (C) 2003  Ferhat Ayaz - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA  02111-1307, USA. - *  - * Email: ayaz@jprogrammer.net - ******************************************************************/ +*  $Id: soap-client.c,v 1.4 2004/08/26 17:06:18 rans Exp $ +* +* CSOAP Project:  A SOAP client/server library in C +* Copyright (C) 2003  Ferhat Ayaz +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Library General Public +* License as published by the Free Software Foundation; either +* version 2 of the License, or (at your option) any later version. +* +* This library 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 +* Library General Public License for more details. +* +* You should have received a copy of the GNU Library General Public +* License along with this library; if not, write to the +* Free Software Foundation, Inc., 59 Temple Place - Suite 330, +* Boston, MA  02111-1307, USA. +*  +* Email: ayaz@jprogrammer.net +******************************************************************/  #include <libcsoap/soap-client.h>  #include <nanohttp/nanohttp-client.h> - +#include <string.h>  /*--------------------------------- */  static SoapEnv *_soap_client_build_result(hresponse_t *res); @@ -33,78 +33,75 @@ static SoapEnv *_soap_client_build_result(hresponse_t *res);  SoapEnv*  soap_client_invoke(SoapEnv *call, const char *url, const char *soap_action)  { -  /* Result document */ -  xmlDocPtr doc; - -  /* Buffer variables*/ -  xmlBufferPtr buffer; -  char *content; - -  /* Transport variables */ -  httpc_conn_t *conn; -  hresponse_t *res; -   -  /* Create buffer */ -  buffer = xmlBufferCreate(); -  xmlNodeDump(buffer, call->root->doc,call->root, 1 ,0); -  content = (char*)xmlBufferContent(buffer); -   -  /* Transport via HTTP */ -  conn = httpc_new(); - -  /* content-type is always 'text/xml' */ -  httpc_set_header(conn, HEADER_CONTENT_TYPE, "text/xml"); - -  if (soap_action != NULL) { -    httpc_set_header(conn, "SoapAction", soap_action); -  } -  res = httpc_post(conn, url, strlen(content), content); - -  /* Free buffer */ -  xmlBufferFree(buffer); - -  /* Build result */ -  /* TODO: If res == NULL, find out where and why it is NULL! */ -  doc = _soap_client_build_result(res);  - -  return doc; +	/* Result document */ +	SoapEnv* doc; + +	/* Buffer variables*/ +	xmlBufferPtr buffer; +	char *content; + +	/* Transport variables */ +	httpc_conn_t *conn; +	hresponse_t *res; + +	/* Create buffer */ +	buffer = xmlBufferCreate(); +	xmlNodeDump(buffer, call->root->doc,call->root, 1 ,0); +	content = (char*)xmlBufferContent(buffer); + +	/* Transport via HTTP */ +	conn = httpc_new(); + +	/* content-type is always 'text/xml' */ +	httpc_set_header(conn, HEADER_CONTENT_TYPE, "text/xml"); + +	if (soap_action != NULL) { +		httpc_set_header(conn, "SoapAction", soap_action); +	} +	res = httpc_post(conn, url, strlen(content), content); + +	/* Free buffer */ +	xmlBufferFree(buffer); + +	/* Build result */ +	/* TODO: If res == NULL, find out where and why it is NULL! */ +	doc = _soap_client_build_result(res);  + +	return doc;  }  static   SoapEnv* _soap_client_build_result(hresponse_t *res)  { -  xmlDocPtr doc; -  SoapEnv *env; +	xmlDocPtr doc; +	SoapEnv *env; -  log_verbose2("Building result (%p)", res); +	log_verbose2("Building result (%p)", res); -  if (res == NULL) -    return soap_env_new_with_fault(Fault_Client,  -			    "Response is NULL","",""); +	if (res == NULL) +		return soap_env_new_with_fault(Fault_Client,  +		"Response is NULL","",""); -  if (res->body == NULL) -    return soap_env_new_with_fault(Fault_Client,  -			    "Empty response from server!","",""); +	if (res->body == NULL) +		return soap_env_new_with_fault(Fault_Client,  +		"Empty response from server!","",""); -   -  doc = xmlParseDoc(res->body); -  if (doc == NULL) { -    return soap_env_new_with_fault(Fault_Client,  -			    "Response is not in XML format!","",""); -  } -  env = soap_env_new_from_doc(doc); - -  if (env == NULL) { -    xmlFreeDoc(doc); -    return soap_env_new_with_fault(Fault_Client,  -			    "Can not create envelope","",""); -  } - -  return env; -} +	doc = xmlParseDoc((xmlChar *)res->body); +	if (doc == NULL) { +		return soap_env_new_with_fault(Fault_Client,  +			"Response is not in XML format!","",""); +	} +	env = soap_env_new_from_doc(doc); +	if (env == NULL) { +		xmlFreeDoc(doc); +		return soap_env_new_with_fault(Fault_Client,  +			"Can not create envelope","",""); +	} +	return env; +}
\ No newline at end of file diff --git a/libcsoap/soap-env.c b/libcsoap/soap-env.c index 1e5c8dc..474e32e 100644 --- a/libcsoap/soap-env.c +++ b/libcsoap/soap-env.c @@ -1,26 +1,26 @@  /****************************************************************** - *  $Id: soap-env.c,v 1.3 2004/06/08 12:54:09 snowdrop Exp $ - * - * CSOAP Project:  A SOAP client/server library in C - * Copyright (C) 2003  Ferhat Ayaz - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA  02111-1307, USA. - *  - * Email: ayaz@jprogrammer.net - ******************************************************************/ +*  $Id: soap-env.c,v 1.4 2004/08/26 17:06:18 rans Exp $ +* +* CSOAP Project:  A SOAP client/server library in C +* Copyright (C) 2003  Ferhat Ayaz +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Library General Public +* License as published by the Free Software Foundation; either +* version 2 of the License, or (at your option) any later version. +* +* This library 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 +* Library General Public License for more details. +* +* You should have received a copy of the GNU Library General Public +* License along with this library; if not, write to the +* Free Software Foundation, Inc., 59 Temple Place - Suite 330, +* Boston, MA  02111-1307, USA. +*  +* Email: ayaz@jprogrammer.net +******************************************************************/  #include <libcsoap/soap-env.h>  #include <stdarg.h>  #include <string.h> @@ -31,24 +31,24 @@ static char *soap_xsi_ns = "http://www.w3.org/1999/XMLSchema-instance";  static char *soap_xsd_ns = "http://www.w3.org/1999/XMLSchema";  /* -  Parameters: -  1- soap_env_ns -  2- soap_env_enc -  3- xsi_ns -  4- xsd_ns -  3- method name -  4- uri -  5- method name(again) - */ +Parameters: +1- soap_env_ns +2- soap_env_enc +3- xsi_ns +4- xsd_ns +3- method name +4- uri +5- method name(again) +*/  #define _SOAP_MSG_TEMPLATE_ \ -  "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"%s\" SOAP-ENV:encoding=\"%s\"" \ -  " xmlns:xsi=\"%s\"" \ -  " xmlns:xsd=\"%s\">" \ -  " <SOAP-ENV:Body>"\ -  "  <m:%s xmlns:m=\"%s\">"\ -  "  </m:%s>" \ -  " </SOAP-ENV:Body>"\ -  "</SOAP-ENV:Envelope>" +	"<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"%s\" SOAP-ENV:encoding=\"%s\"" \ +	" xmlns:xsi=\"%s\"" \ +	" xmlns:xsd=\"%s\">" \ +	" <SOAP-ENV:Body>"\ +	"  <m:%s xmlns:m=\"%s\">"\ +	"  </m:%s>" \ +	" </SOAP-ENV:Body>"\ +	"</SOAP-ENV:Envelope>"  /* ---------------------------------------------------------------------------- */ @@ -58,11 +58,11 @@ struct XmlNodeHolder { xmlNodePtr node; };  static  void xmlbuilder_start_element(const char* element_name, int attr_count,  -  char **keys, char **values, void* userData); +							  char **keys, char **values, void* userData);  static  void xmlbuilder_characters(const char* element_name,  -  const char* chars, void* userData); +						   const char* chars, void* userData);  static  void xmlbuilder_end_element(const char* element_name, void* userData); @@ -70,193 +70,193 @@ void xmlbuilder_end_element(const char* element_name, void* userData);  /* ---------------------------------------------------------------------------- */  SoapEnv *soap_env_new_with_fault(fault_code_t faultcode,  -				 const char *faultstring, -				 const char *faultactor, -				 const char *detail) +								 const char *faultstring, +								 const char *faultactor, +								 const char *detail)  { -  xmlDocPtr doc; -  doc = soap_fault_build(faultcode, faultstring, -			 faultactor, detail); -  if (doc == NULL) return NULL; -  return soap_env_new_from_doc(doc); +	xmlDocPtr doc; +	doc = soap_fault_build(faultcode, faultstring, +		faultactor, detail); +	if (doc == NULL) return NULL; +	return soap_env_new_from_doc(doc);  }  SoapEnv *soap_env_new_with_response(SoapEnv* request)  { -  char urn[100]; -  char methodname[150]; -  char methodname2[150]; - -  if (request == NULL) { -    log_error1("request object is NULL"); -    return NULL; -  } - -  if (request->root == NULL) { -    log_error1("request has no xml"); -    return NULL; -  } - -  if (!soap_env_find_methodname(request, methodname)) { -    return NULL; -  } - -  if (!soap_env_find_urn(request, urn)) { -     -    /* here we have no chance to find out the namespace */ -    /* try to continue without namespace (urn) */ -    urn[0] = '\0'; -  }  - -  sprintf(methodname2, "%sResponse", methodname); -  return soap_env_new_with_method(urn, methodname2); +	char urn[100]; +	char methodname[150]; +	char methodname2[150]; + +	if (request == NULL) { +		log_error1("request object is NULL"); +		return NULL; +	} + +	if (request->root == NULL) { +		log_error1("request has no xml"); +		return NULL; +	} + +	if (!soap_env_find_methodname(request, methodname)) { +		return NULL; +	} + +	if (!soap_env_find_urn(request, urn)) { + +		/* here we have no chance to find out the namespace */ +		/* try to continue without namespace (urn) */ +		urn[0] = '\0'; +	}  + +	sprintf(methodname2, "%sResponse", methodname); +	return soap_env_new_with_method(urn, methodname2);  }  SoapEnv *soap_env_new_with_method(const char *urn, const char *method)  { -  xmlDocPtr env; -  SoapEnv *call; -  char buffer[1054]; +	xmlDocPtr env; +	SoapEnv *call; +	char buffer[1054]; + -   -  log_verbose2("URN = '%s'", urn); -  log_verbose2("Method = '%s'",method); +	log_verbose2("URN = '%s'", urn); +	log_verbose2("Method = '%s'",method); -  sprintf(buffer, _SOAP_MSG_TEMPLATE_,  -	  soap_env_ns, soap_env_enc, soap_xsi_ns,  -	  soap_xsd_ns, method, urn, method); +	sprintf(buffer, _SOAP_MSG_TEMPLATE_,  +		soap_env_ns, soap_env_enc, soap_xsi_ns,  +		soap_xsd_ns, method, urn, method); -  env = xmlParseDoc(buffer); -  call = soap_env_new_from_doc(env); +	env = xmlParseDoc((xmlChar *)buffer); +	call = soap_env_new_from_doc(env); -  return call; +	return call;  }  xmlNodePtr  soap_env_add_item(SoapEnv *call, const char *type,  -		  const char *name, const char *value) +				  const char *name, const char *value)  { -  xmlNodePtr newnode; +	xmlNodePtr newnode; -  newnode = xmlNewTextChild(call->cur, NULL, name, value); +	newnode = xmlNewTextChild(call->cur, NULL, (const xmlChar *)name, (const xmlChar *)value); -  if (newnode == NULL) { -    log_error1("Can not create new xml node"); -    return NULL; -  } +	if (newnode == NULL) { +		log_error1("Can not create new xml node"); +		return NULL; +	} -  if (type) { -    if (!xmlNewProp(newnode, "xsi:type", type)) { -      log_error1("Can not create new xml attribute"); -      return NULL; -    } -  } -   -  return newnode;   +	if (type) { +		if (!xmlNewProp(newnode, (const xmlChar *)"xsi:type", (const xmlChar *)type)) { +			log_error1("Can not create new xml attribute"); +			return NULL; +		} +	} + +	return newnode;    }  xmlNodePtr  soap_env_add_itemf(SoapEnv *call, const char *type, -		    const char *name, const char *format, ...) +				   const char *name, const char *format, ...)  { -  va_list ap; -  char buffer[1054]; -   +	va_list ap; +	char buffer[1054]; + -  va_start(ap, format); -  vsprintf(buffer, format, ap); -  va_end(ap); +	va_start(ap, format); +	vsprintf(buffer, format, ap); +	va_end(ap); -  return soap_env_add_item(call, type, name, buffer); +	return soap_env_add_item(call, type, name, buffer);  }  void  soap_env_add_custom(SoapEnv *call, void *obj, XmlSerializerCallback cb,  -    const char *type, const char *name) +					const char *type, const char *name)  { -  struct XmlNodeHolder holder; +	struct XmlNodeHolder holder; -  holder.node = soap_env_get_method(call); +	holder.node = soap_env_get_method(call); -  cb(obj, name,  -    xmlbuilder_start_element, -    xmlbuilder_characters, -    xmlbuilder_end_element, &holder); +	cb(obj, name,  +		xmlbuilder_start_element, +		xmlbuilder_characters, +		xmlbuilder_end_element, &holder);  }  xmlNodePtr  soap_env_push_item(SoapEnv *call, const char *type, -		   const char *name) +				   const char *name)  { -  xmlNodePtr node; +	xmlNodePtr node; -  node =  soap_env_add_item(call, type, name, ""); +	node =  soap_env_add_item(call, type, name, ""); -  if (node) { -    call->cur = node; -  } +	if (node) { +		call->cur = node; +	} -  return node; +	return node;  }  void  soap_env_pop_item(SoapEnv *call)  { -  call->cur = call->cur->parent; +	call->cur = call->cur->parent;  }  void soap_env_free(SoapEnv *env)  { -  if (env) { -    if (env->root) { -      xmlFreeDoc(env->root->doc); -    } -    free(env); -  } +	if (env) { +		if (env->root) { +			xmlFreeDoc(env->root->doc); +		} +		free(env); +	}  }  SoapEnv *soap_env_new_from_doc(xmlDocPtr doc)  { -  SoapEnv *env; -  xmlNodePtr node; - -  if (doc == NULL) { -    log_error1("Can not create xml document!"); -    return NULL; -  } - -  node = xmlDocGetRootElement(doc); -  if (node == NULL) { -    log_error1("xml document is empty!"); -    return NULL; -  } -   -  env = (SoapEnv*)malloc(sizeof(SoapEnv)); - -  /* set root */ -  env->root = node; - -  /* set method root -     set call->cur (current node) to <method>. -     xpath: //Envelope/Body/ -   */ -  node = soap_xml_get_children(env->root); -  env->cur = soap_xml_get_children(node); - -  return env; +	SoapEnv *env; +	xmlNodePtr node; + +	if (doc == NULL) { +		log_error1("Can not create xml document!"); +		return NULL; +	} + +	node = xmlDocGetRootElement(doc); +	if (node == NULL) { +		log_error1("xml document is empty!"); +		return NULL; +	} + +	env = (SoapEnv*)malloc(sizeof(SoapEnv)); + +	/* set root */ +	env->root = node; + +	/* set method root +	set call->cur (current node) to <method>. +	xpath: //Envelope/Body/ +	*/ +	node = soap_xml_get_children(env->root); +	env->cur = soap_xml_get_children(node); + +	return env;  } @@ -264,175 +264,175 @@ SoapEnv *soap_env_new_from_doc(xmlDocPtr doc)  SoapEnv *soap_env_new_from_buffer(const char* buffer)  { -  xmlDocPtr doc; -  SoapEnv *env; +	xmlDocPtr doc; +	SoapEnv *env; -  if (buffer == NULL) return NULL; +	if (buffer == NULL) return NULL; -  doc = xmlParseDoc((xmlChar*)buffer); -  if (doc == NULL) return NULL; +	doc = xmlParseDoc((xmlChar*)buffer); +	if (doc == NULL) return NULL; -  env = soap_env_new_from_doc(doc); -  if (env == NULL) { -    xmlFreeDoc(doc); -    return NULL; -  } +	env = soap_env_new_from_doc(doc); +	if (env == NULL) { +		xmlFreeDoc(doc); +		return NULL; +	} -  return env; +	return env;  }  xmlNodePtr  soap_env_get_body(SoapEnv* env)  { -  xmlNodePtr node; +	xmlNodePtr node; -  if (env == NULL) { -    log_error1("env object is NULL"); -    return NULL; -  } +	if (env == NULL) { +		log_error1("env object is NULL"); +		return NULL; +	} -  if (env->root == NULL) { -    log_error1("env has no xml"); -    return NULL; -  } +	if (env->root == NULL) { +		log_error1("env has no xml"); +		return NULL; +	} -  node = soap_xml_get_children(env->root); +	node = soap_xml_get_children(env->root); -  while (node != NULL) { -    if (!strcmp(node->name, "Body")) -      return node; -    node = soap_xml_get_next(node); -  } +	while (node != NULL) { +		if (!strcmp((const char*)node->name, "Body")) +			return node; +		node = soap_xml_get_next(node); +	} -  log_error1("Node Body tag found!"); -  return NULL; +	log_error1("Node Body tag found!"); +	return NULL;  }  xmlNodePtr  soap_env_get_method(SoapEnv* env)  { -   -  xmlNodePtr body; - -  body = soap_env_get_body(env); -  if (body == NULL) { -    log_verbose1("body is NULL"); -    return NULL; -  } - - /* mehtod is the first child */ -  return soap_xml_get_children(body); -   + +	xmlNodePtr body; + +	body = soap_env_get_body(env); +	if (body == NULL) { +		log_verbose1("body is NULL"); +		return NULL; +	} + +	/* mehtod is the first child */ +	return soap_xml_get_children(body); +  }  xmlNodePtr  _soap_env_get_body(SoapEnv* env)  { -  xmlNodePtr  body; -  xmlNodeSetPtr nodeset;  -  xmlXPathObjectPtr xpathobj; - -  if (env == NULL) { -    log_error1("env object is NULL"); -    return NULL; -  } - -  if (env->root == NULL) { -    log_error1("env has no xml"); -    return NULL; -  } - -  /*  -     find <Body> tag find out namespace -     xpath: //Envelope/Body/ -   */ -  xpathobj = soap_xpath_eval(env->root->doc, "//Envelope/Body"); - -  if (!xpathobj) { -    log_error1("No Body (xpathobj)!"); -    return NULL; -  } - -  nodeset = xpathobj->nodesetval; -  if (!nodeset) { -    log_error1("No Body (nodeset)!"); -    xmlXPathFreeObject(xpathobj); -    return NULL; -  } - -  if (nodeset->nodeNr < 1) { -    log_error1("No Body (nodeNr)!"); -    xmlXPathFreeNodeSet	(nodeset); -    xmlXPathFreeObject(xpathobj); -    return NULL; -  } - -  body = nodeset->nodeTab[0]; /* body is <Body> */ -  xmlXPathFreeNodeSet	(nodeset); -  xmlXPathFreeObject(xpathobj); -  return body; +	xmlNodePtr  body; +	xmlNodeSetPtr nodeset;  +	xmlXPathObjectPtr xpathobj; + +	if (env == NULL) { +		log_error1("env object is NULL"); +		return NULL; +	} + +	if (env->root == NULL) { +		log_error1("env has no xml"); +		return NULL; +	} + +	/*  +	find <Body> tag find out namespace +	xpath: //Envelope/Body/ +	*/ +	xpathobj = soap_xpath_eval(env->root->doc, "//Envelope/Body"); + +	if (!xpathobj) { +		log_error1("No Body (xpathobj)!"); +		return NULL; +	} + +	nodeset = xpathobj->nodesetval; +	if (!nodeset) { +		log_error1("No Body (nodeset)!"); +		xmlXPathFreeObject(xpathobj); +		return NULL; +	} + +	if (nodeset->nodeNr < 1) { +		log_error1("No Body (nodeNr)!"); +		xmlXPathFreeNodeSet	(nodeset); +		xmlXPathFreeObject(xpathobj); +		return NULL; +	} + +	body = nodeset->nodeTab[0]; /* body is <Body> */ +	xmlXPathFreeNodeSet	(nodeset); +	xmlXPathFreeObject(xpathobj); +	return body;  }  int soap_env_find_urn(SoapEnv *env, char *urn)  { -  xmlNsPtr ns; -  xmlNodePtr body, node; - -  body = soap_env_get_body(env); -  if (body == NULL) { -    log_verbose1("body is NULL"); -    return 0; -  } - - /* node is the first child */ -  node = soap_xml_get_children(body); -   -  if (node == NULL) { -    log_error1("No namespace found"); -    return 0; -  }  - -  if (node->ns && node->ns->prefix) { -    ns = xmlSearchNs(body->doc, node, node->ns->prefix); -    if (ns != NULL) { -      strcpy(urn, (char*)ns->href); -      return 1; /* namesapce found! */ -    } -  } - -  log_error1("No namespace found. Returning 0"); -  return 0; +	xmlNsPtr ns; +	xmlNodePtr body, node; + +	body = soap_env_get_body(env); +	if (body == NULL) { +		log_verbose1("body is NULL"); +		return 0; +	} + +	/* node is the first child */ +	node = soap_xml_get_children(body); + +	if (node == NULL) { +		log_error1("No namespace found"); +		return 0; +	}  + +	if (node->ns && node->ns->prefix) { +		ns = xmlSearchNs(body->doc, node, node->ns->prefix); +		if (ns != NULL) { +			strcpy(urn, (char*)ns->href); +			return 1; /* namesapce found! */ +		} +	} + +	log_error1("No namespace found. Returning 0"); +	return 0;  }  int soap_env_find_methodname(SoapEnv *env, char *method)  { -  xmlNodePtr body, node; +	xmlNodePtr body, node; + +	body = soap_env_get_body(env); +	if (body == NULL) return 0; -  body = soap_env_get_body(env); -  if (body == NULL) return 0; +	node = soap_xml_get_children(body); /* node is the first child */ -  node = soap_xml_get_children(body); /* node is the first child */ -   -  if (node == NULL) { -    log_error1("No method found"); -    return 0; -  }  +	if (node == NULL) { +		log_error1("No method found"); +		return 0; +	}  -  if (node->name == NULL) { -    log_error1("No methodname found"); -    return 0; +	if (node->name == NULL) { +		log_error1("No methodname found"); +		return 0; -  } +	} -  strcpy(method, node->name); -   -  return 1; +	strcpy(method, (const char *)node->name); + +	return 1;  } @@ -445,41 +445,40 @@ int soap_env_find_methodname(SoapEnv *env, char *method)  static  void xmlbuilder_start_element(const char* element_name, int attr_count, char **keys, char **values, void* userData)  { -  struct XmlNodeHolder *holder = (struct XmlNodeHolder*)userData; -  xmlNodePtr parent = NULL; -   -  if (holder == NULL) return; -  parent = holder->node; -  if (parent == NULL) return; +	struct XmlNodeHolder *holder = (struct XmlNodeHolder*)userData; +	xmlNodePtr parent = NULL; + +	if (holder == NULL) return; +	parent = holder->node; +	if (parent == NULL) return; -  holder->node = xmlNewChild(parent, NULL, element_name, NULL); +	holder->node = xmlNewChild(parent, NULL, (const xmlChar *)element_name, NULL);  }  static  void xmlbuilder_characters(const char* element_name, const char* chars, void* userData)  { -  struct XmlNodeHolder *holder = (struct XmlNodeHolder*)userData; -  xmlNodePtr parent = NULL; -   -  if (holder == NULL) return; -  parent = holder->node; -  if (parent == NULL) return; - -  xmlNewTextChild(parent, NULL, element_name, chars); +	struct XmlNodeHolder *holder = (struct XmlNodeHolder*)userData; +	xmlNodePtr parent = NULL; + +	if (holder == NULL) return; +	parent = holder->node; +	if (parent == NULL) return; + +	xmlNewTextChild(parent, NULL, (const xmlChar *)element_name, (const xmlChar *)chars);  }  static  void xmlbuilder_end_element(const char* element_name, void* userData)  { -  struct XmlNodeHolder *holder = (struct XmlNodeHolder*)userData; -  xmlNodePtr parent = NULL; -   -  if (holder == NULL) return; -  parent = holder->node; -  if (parent == NULL) return; +	struct XmlNodeHolder *holder = (struct XmlNodeHolder*)userData; +	xmlNodePtr parent = NULL; -  holder->node = parent->parent; -} +	if (holder == NULL) return; +	parent = holder->node; +	if (parent == NULL) return; +	holder->node = parent->parent; +} diff --git a/libcsoap/soap-fault.c b/libcsoap/soap-fault.c index dfb769e..b002ddc 100644 --- a/libcsoap/soap-fault.c +++ b/libcsoap/soap-fault.c @@ -1,29 +1,29 @@  /****************************************************************** - *  $Id: soap-fault.c,v 1.2 2004/02/03 08:07:36 snowdrop Exp $ - * - * CSOAP Project:  A SOAP client/server library in C - * Copyright (C) 2003  Ferhat Ayaz - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA  02111-1307, USA. - *  - * Email: ayaz@jprogrammer.net - ******************************************************************/ +*  $Id: soap-fault.c,v 1.3 2004/08/26 17:06:18 rans Exp $ +* +* CSOAP Project:  A SOAP client/server library in C +* Copyright (C) 2003  Ferhat Ayaz +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Library General Public +* License as published by the Free Software Foundation; either +* version 2 of the License, or (at your option) any later version. +* +* This library 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 +* Library General Public License for more details. +* +* You should have received a copy of the GNU Library General Public +* License along with this library; if not, write to the +* Free Software Foundation, Inc., 59 Temple Place - Suite 330, +* Boston, MA  02111-1307, USA. +*  +* Email: ayaz@jprogrammer.net +******************************************************************/  #include <libcsoap/soap-fault.h>  #include <libcsoap/soap-xml.h> - +#include <string.h>  static char *soap_env_ns = "http://schemas.xmlsoap.org/soap/envelope/";  static char *soap_env_enc = "http://schemas.xmlsoap.org/soap/encoding/"; @@ -31,29 +31,29 @@ static char *soap_xsi_ns = "http://www.w3.org/1999/XMLSchema-instance";  static char *soap_xsd_ns = "http://www.w3.org/1999/XMLSchema";  /* -  Parameters: -  1- soap_env_ns -  2- soap_env_enc -  3- xsi_ns -  4- xsd_ns -  5- faultcode -  6- faultstring -  7- faultactor -  8- detail - */ +Parameters: +1- soap_env_ns +2- soap_env_enc +3- xsi_ns +4- xsd_ns +5- faultcode +6- faultstring +7- faultactor +8- detail +*/  #define  _SOAP_FAULT_TEMPLATE_ \ -  "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"%s\" SOAP-ENV:encoding=\"%s\"" \ -  " xmlns:xsi=\"%s\"" \ -  " xmlns:xsd=\"%s\">" \ -  " <SOAP-ENV:Body>"\ -  "  <Fault>"\ -  "   <faultcode>%s</faultcode>"\ -  "   <faultstring>%s</faultstring>"\ -  "   <faultactor>%s</faultactor>"\ -  "   <faultdetail>%s</faultdetail>"\ -  "  </Fault>" \ -  " </SOAP-ENV:Body>"\ -  "</SOAP-ENV:Envelope>" +	"<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"%s\" SOAP-ENV:encoding=\"%s\"" \ +	" xmlns:xsi=\"%s\"" \ +	" xmlns:xsd=\"%s\">" \ +	" <SOAP-ENV:Body>"\ +	"  <Fault>"\ +	"   <faultcode>%s</faultcode>"\ +	"   <faultstring>%s</faultstring>"\ +	"   <faultactor>%s</faultactor>"\ +	"   <faultdetail>%s</faultdetail>"\ +	"  </Fault>" \ +	" </SOAP-ENV:Body>"\ +	"</SOAP-ENV:Envelope>" @@ -63,62 +63,62 @@ static char *fault_client = "Client";  static char *fault_server = "Server";  xmlDocPtr soap_fault_build(fault_code_t fcode,  -			   const char *faultstring, -			   const char *faultactor, -			   const char *detail) +						   const char *faultstring, +						   const char *faultactor, +						   const char *detail)  { -  /* variables */ -  char *faultcode; -  int bufferlen = 2000; -  char *buffer; -  xmlDocPtr fault; /* result */ +	/* variables */ +	char *faultcode; +	int bufferlen = 2000; +	char *buffer; +	xmlDocPtr fault; /* result */ -  log_verbose1("Build fault"); +	log_verbose1("Build fault"); -  switch (fcode) { +	switch (fcode) {    case Fault_VersionMismatch: -    faultcode = fault_vm; -    break; +	  faultcode = fault_vm; +	  break;    case Fault_MustUnderstand: -    faultcode = fault_mu; -    break; +	  faultcode = fault_mu; +	  break;    case Fault_Client: -    faultcode = fault_client; -    break; +	  faultcode = fault_client; +	  break;    case Fault_Server: -    faultcode = fault_server; -    break; +	  faultcode = fault_server; +	  break;    default: -    faultcode = fault_client; -  } - -  /* calculate buffer length */ -  if (faultstring) bufferlen += strlen(faultstring); -  if (faultactor) bufferlen += strlen(faultactor); -  if (detail) bufferlen += strlen(detail); - -  log_verbose2("Creating buffer with %d bytes", bufferlen); -  buffer = (char*)malloc(bufferlen); - -  sprintf(buffer,  _SOAP_FAULT_TEMPLATE_, -	  soap_env_ns, soap_env_enc, soap_xsi_ns,  -	  soap_xsd_ns, faultcode, -	  faultstring?faultstring:"error", -	  faultactor?faultactor:"", -	  detail?detail:""); - -  fault = xmlParseDoc(buffer); -  free(buffer); - -  if (fault == NULL) { -    log_error1("Can not create xml document!"); -     -    return soap_fault_build(fcode, "Can not create fault object in xml", -			    "soap_fault_build()", NULL); -  }  - -  log_verbose2("Returning fault (%p)", fault); -  return fault; -    +	  faultcode = fault_client; +	} + +	/* calculate buffer length */ +	if (faultstring) bufferlen += strlen(faultstring); +	if (faultactor) bufferlen += strlen(faultactor); +	if (detail) bufferlen += strlen(detail); + +	log_verbose2("Creating buffer with %d bytes", bufferlen); +	buffer = (char*)malloc(bufferlen); + +	sprintf(buffer,  _SOAP_FAULT_TEMPLATE_, +		soap_env_ns, soap_env_enc, soap_xsi_ns,  +		soap_xsd_ns, faultcode, +		faultstring?faultstring:"error", +		faultactor?faultactor:"", +		detail?detail:""); + +	fault = xmlParseDoc((xmlChar *)buffer); +	free(buffer); + +	if (fault == NULL) { +		log_error1("Can not create xml document!"); + +		return soap_fault_build(fcode, "Can not create fault object in xml", +			"soap_fault_build()", NULL); +	}  + +	log_verbose2("Returning fault (%p)", fault); +	return fault; +  }  diff --git a/libcsoap/soap-router.c b/libcsoap/soap-router.c index 9c409d5..966edad 100644 --- a/libcsoap/soap-router.c +++ b/libcsoap/soap-router.c @@ -1,103 +1,103 @@  /****************************************************************** - *  $Id: soap-router.c,v 1.2 2004/05/12 22:23:30 snowdrop Exp $ - * - * CSOAP Project:  A SOAP client/server library in C - * Copyright (C) 2003  Ferhat Ayaz - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA  02111-1307, USA. - *  - * Email: ayaz@jprogrammer.net - ******************************************************************/ +*  $Id: soap-router.c,v 1.3 2004/08/26 17:06:18 rans Exp $ +* +* CSOAP Project:  A SOAP client/server library in C +* Copyright (C) 2003  Ferhat Ayaz +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Library General Public +* License as published by the Free Software Foundation; either +* version 2 of the License, or (at your option) any later version. +* +* This library 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 +* Library General Public License for more details. +* +* You should have received a copy of the GNU Library General Public +* License along with this library; if not, write to the +* Free Software Foundation, Inc., 59 Temple Place - Suite 330, +* Boston, MA  02111-1307, USA. +*  +* Email: ayaz@jprogrammer.net +******************************************************************/  #include <libcsoap/soap-router.h> - +#include <string.h>  SoapRouter *soap_router_new()  { -  SoapRouter *router; -   -  router = (SoapRouter*)malloc(sizeof(SoapRouter)); -  router->service_head = NULL; -  router->service_tail = NULL; -   -  return router; +	SoapRouter *router; + +	router = (SoapRouter*)malloc(sizeof(SoapRouter)); +	router->service_head = NULL; +	router->service_tail = NULL; + +	return router;  }  void soap_router_register_service(SoapRouter *router, -				  SoapServiceFunc func, -				  const char* method, -				  const char* urn) +								  SoapServiceFunc func, +								  const char* method, +								  const char* urn)  { -  SoapService *service; -   -  service = soap_service_new(urn, method, func); -   -  if (router->service_tail == NULL) { -    router->service_head = -      router->service_tail = soap_service_node_new(service, NULL); -  } else { -    router->service_tail->next =  -      soap_service_node_new(service, NULL); -    router->service_tail = router->service_tail->next; -  } +	SoapService *service; + +	service = soap_service_new(urn, method, func); + +	if (router->service_tail == NULL) { +		router->service_head = +			router->service_tail = soap_service_node_new(service, NULL); +	} else { +		router->service_tail->next =  +			soap_service_node_new(service, NULL); +		router->service_tail = router->service_tail->next; +	}  }  SoapService* soap_router_find_service(SoapRouter *router,  -				      const char* urn, -				      const char* method) +									  const char* urn, +									  const char* method)  { -  SoapServiceNode *node; +	SoapServiceNode *node; + +	if (router == NULL || urn == NULL || method == NULL)  +		return NULL; -  if (router == NULL || urn == NULL || method == NULL)  -    return NULL; +	node = router->service_head; -  node = router->service_head; +	while (node) { +		if (node->service && node->service->urn  +			&& node->service->method) { -  while (node) { -    if (node->service && node->service->urn  -	&& node->service->method) { -       -      if (!strcmp(node->service->urn, urn) -	  && !strcmp(node->service->method, method))  -	return node->service; +				if (!strcmp(node->service->urn, urn) +					&& !strcmp(node->service->method, method))  +					return node->service; -    } +			} -    node = node->next; -  } +			node = node->next; +	} -  return NULL; +	return NULL;  }  void soap_router_free(SoapRouter *router)  { -  SoapServiceNode *node; -  log_verbose2("enter: router=%p", router); -  if (router == NULL) return; - -  while (router->service_head) { -    node = router->service_head->next; -/*   log_verbose2("soap_service_free(%p)\n", router->service_head->service);*/ -    soap_service_free(router->service_head->service); -    free(router->service_head); -    router->service_head = node; -  } - -  free(router); -  log_verbose1("leave with success"); +	SoapServiceNode *node; +	log_verbose2("enter: router=%p", router); +	if (router == NULL) return; + +	while (router->service_head) { +		node = router->service_head->next; +		/*   log_verbose2("soap_service_free(%p)\n", router->service_head->service);*/ +		soap_service_free(router->service_head->service); +		free(router->service_head); +		router->service_head = node; +	} + +	free(router); +	log_verbose1("leave with success");  } diff --git a/libcsoap/soap-server.c b/libcsoap/soap-server.c index ac259e8..e4a5775 100644 --- a/libcsoap/soap-server.c +++ b/libcsoap/soap-server.c @@ -1,36 +1,36 @@  /****************************************************************** - *  $Id: soap-server.c,v 1.2 2004/05/12 22:23:30 snowdrop Exp $ - * - * CSOAP Project:  A SOAP client/server library in C - * Copyright (C) 2003  Ferhat Ayaz - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA  02111-1307, USA. - *  - * Email: ayaz@jprogrammer.net - ******************************************************************/ +*  $Id: soap-server.c,v 1.3 2004/08/26 17:06:18 rans Exp $ +* +* CSOAP Project:  A SOAP client/server library in C +* Copyright (C) 2003  Ferhat Ayaz +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Library General Public +* License as published by the Free Software Foundation; either +* version 2 of the License, or (at your option) any later version. +* +* This library 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 +* Library General Public License for more details. +* +* You should have received a copy of the GNU Library General Public +* License along with this library; if not, write to the +* Free Software Foundation, Inc., 59 Temple Place - Suite 330, +* Boston, MA  02111-1307, USA. +*  +* Email: ayaz@jprogrammer.net +******************************************************************/  #include <libcsoap/soap-server.h>  #include <nanohttp/nanohttp-server.h> - +#include <string.h>  typedef struct _SoapRouterNode  { -  char *context; -  SoapRouter *router; -  struct _SoapRouterNode *next; +	char *context; +	SoapRouter *router; +	struct _SoapRouterNode *next;  }SoapRouterNode; @@ -39,8 +39,8 @@ SoapRouterNode *tail = NULL;  static  SoapRouterNode *router_node_new(SoapRouter *router,  -				const char *context,  -				SoapRouterNode *next); +								const char *context,  +								SoapRouterNode *next);  static  SoapRouter *router_find(const char *context); @@ -51,179 +51,179 @@ static  void _soap_server_send_env(hsocket_t sock, SoapEnv* env);  static  void _soap_server_send_fault(httpd_conn_t *conn, hpair_t *header,  -			     const char* errmsg); +							 const char* errmsg);  /*---------------------------------*/  int soap_server_init_args(int argc, char *argv[])  { -  return !httpd_init(argc, argv); +	return !httpd_init(argc, argv);  }  int soap_server_register_router(SoapRouter *router, const char* context)  { -   -  if (!httpd_register(context, soap_server_entry)) { -    return 0; -  } -   -  if (tail == NULL) { -    head = tail = router_node_new(router, context, NULL); -  } else { -    tail->next =  router_node_new(router, context, NULL); -    tail = tail->next; -  } -   -  return 1; + +	if (!httpd_register(context, soap_server_entry)) { +		return 0; +	} + +	if (tail == NULL) { +		head = tail = router_node_new(router, context, NULL); +	} else { +		tail->next =  router_node_new(router, context, NULL); +		tail = tail->next; +	} + +	return 1;  }  int soap_server_run()  { -  return httpd_run(); +	return httpd_run();  }  void soap_server_destroy()  { -  SoapRouterNode *node = head; -  SoapRouterNode *tmp; - -  while (node != NULL) { -    tmp = node->next; -    log_verbose2("soap_router_free(%p)", node->router); -    soap_router_free(node->router); -    free(node->context); -    free(node); -    node = tmp; -  } +	SoapRouterNode *node = head; +	SoapRouterNode *tmp; + +	while (node != NULL) { +		tmp = node->next; +		log_verbose2("soap_router_free(%p)", node->router); +		soap_router_free(node->router); +		free(node->context); +		free(node); +		node = tmp; +	}  }  void soap_server_entry(httpd_conn_t *conn, hrequest_t *req)  { -  hpair_t *header; -  char *postdata; -  char buffer[1054]; -  char urn[150]; -  char method[150]; -  long received; -  SoapEnv *env, *envres; -  SoapRouter *router; -  SoapService *service; +	hpair_t *header; +	char *postdata; +	char buffer[1054]; +	char urn[150]; +	char method[150]; +	long received; +	SoapEnv *env, *envres; +	SoapRouter *router; +	SoapService *service; + +	if (strcmp(req->method, "POST")) { + +		httpd_send_header(conn, 200, "OK", header); +		hsocket_send(conn->sock, "<html><head></head><body>"); +		hsocket_send(conn->sock, "<h1>Sorry! </h1><hr>"); +		hsocket_send(conn->sock, "I only speak with 'POST' method"); +		hsocket_send(conn->sock, "</body></html>"); +		return; +	} -  if (strcmp(req->method, "POST")) { -     -    httpd_send_header(conn, 200, "OK", header); -    hsocket_send(conn->sock, "<html><head></head><body>"); -    hsocket_send(conn->sock, "<h1>Sorry! </h1><hr>"); -    hsocket_send(conn->sock, "I only speak with 'POST' method"); -    hsocket_send(conn->sock, "</body></html>"); -    return; -  } +	postdata = httpd_get_postdata(conn, req, &received, -1); -  postdata = httpd_get_postdata(conn, req, &received, -1); +	header = hpairnode_new(HEADER_CONTENT_TYPE, "text/xml", NULL); -  header = hpairnode_new(HEADER_CONTENT_TYPE, "text/xml", NULL); +	if (postdata == NULL) { -  if (postdata == NULL) { -     -    _soap_server_send_fault(conn, header,"Can not receive POST data!"); +		_soap_server_send_fault(conn, header,"Can not receive POST data!"); -  } else { +	} else { -    env = soap_env_new_from_buffer(postdata); +		env = soap_env_new_from_buffer(postdata); -    if (env == NULL) { +		if (env == NULL) { -      _soap_server_send_fault(conn, header,"Can not parse POST data!"); -       -    } else { +			_soap_server_send_fault(conn, header,"Can not parse POST data!"); -      /*soap_xml_doc_print(env->root->doc);*/ +		} else { -      router = router_find(req->path); +			/*soap_xml_doc_print(env->root->doc);*/ -      if ( router == NULL) { -	 -	_soap_server_send_fault(conn, header, "Can not find router!"); -       -      } else { +			router = router_find(req->path); -	if (!soap_env_find_urn(env, urn)) { -	   -	  _soap_server_send_fault(conn, header, "No URN found!"); -	  return; -	} else { -	  log_verbose2("urn: '%s'", urn); -	} +			if ( router == NULL) { -	if (!soap_env_find_methodname(env, method)) { -	   -	  _soap_server_send_fault(conn, header, "No method found!"); -	  return; -	}else { -	  log_verbose2("method: '%s'", method); -	} +				_soap_server_send_fault(conn, header, "Can not find router!"); -	service = soap_router_find_service(router, urn, method); +			} else { -	if (service == NULL) { +				if (!soap_env_find_urn(env, urn)) { -	  sprintf(buffer, "URN '%s' not found", urn); -	  _soap_server_send_fault(conn, header, buffer); -	  return; -	} else { +					_soap_server_send_fault(conn, header, "No URN found!"); +					return; +				} else { +					log_verbose2("urn: '%s'", urn); +				} -	  log_verbose2("func: %p", service->func); -	  envres = service->func(env); -	  log_verbose2("func returned: (%p)", envres); -	  if (envres == NULL) { +				if (!soap_env_find_methodname(env, method)) { -	    sprintf(buffer, "Service '%s' returned no envelope", urn); -	    _soap_server_send_fault(conn, header, buffer); -	    return; +					_soap_server_send_fault(conn, header, "No method found!"); +					return; +				}else { +					log_verbose2("method: '%s'", method); +				} -	  } else { -	   -	    httpd_send_header(conn, 200, "OK", header); -	    _soap_server_send_env(conn->sock, envres); -	    /* free envres */ -	  } +				service = soap_router_find_service(router, urn, method); -	} +				if (service == NULL) { + +					sprintf(buffer, "URN '%s' not found", urn); +					_soap_server_send_fault(conn, header, buffer); +					return; +				} else { -      }    -    } -  } +					log_verbose2("func: %p", service->func); +					envres = service->func(env); +					log_verbose2("func returned: (%p)", envres); +					if (envres == NULL) { + +						sprintf(buffer, "Service '%s' returned no envelope", urn); +						_soap_server_send_fault(conn, header, buffer); +						return; + +					} else { + +						httpd_send_header(conn, 200, "OK", header); +						_soap_server_send_env(conn->sock, envres); +						/* free envres */ +					} + +				} + +			}    +		} +	}  }  static  void _soap_server_send_env(hsocket_t sock, SoapEnv* env)  { -  xmlBufferPtr buffer; -  if (env == NULL || env->root == NULL) return; - -  buffer = xmlBufferCreate(); -  xmlNodeDump(buffer, env->root->doc, env->root, 1 ,1); -  hsocket_send(sock,  (const char*)xmlBufferContent(buffer)); -  xmlBufferFree(buffer);   -   +	xmlBufferPtr buffer; +	if (env == NULL || env->root == NULL) return; + +	buffer = xmlBufferCreate(); +	xmlNodeDump(buffer, env->root->doc, env->root, 1 ,1); +	hsocket_send(sock,  (const char*)xmlBufferContent(buffer)); +	xmlBufferFree(buffer);   +  }  static  void _soap_server_send_fault(httpd_conn_t *conn, hpair_t *header,  -			     const char* errmsg) +							 const char* errmsg)  { -  SoapEnv *envres; -  httpd_send_header(conn, 500, "FAILED", header); -  envres = soap_env_new_with_fault(Fault_Server, -				   errmsg?errmsg:"General error", -				   "cSOAP_Server", NULL); -  _soap_server_send_env(conn->sock, envres); +	SoapEnv *envres; +	httpd_send_header(conn, 500, "FAILED", header); +	envres = soap_env_new_with_fault(Fault_Server, +		errmsg?errmsg:"General error", +		"cSOAP_Server", NULL); +	_soap_server_send_env(conn->sock, envres);  } @@ -231,39 +231,39 @@ void _soap_server_send_fault(httpd_conn_t *conn, hpair_t *header,  static   SoapRouterNode *router_node_new(SoapRouter *router,  -				const char *context, -				SoapRouterNode *next) +								const char *context, +								SoapRouterNode *next)  { -  SoapRouterNode *node; -  const char *noname = "/lost_find"; - -  node = (SoapRouterNode*)malloc(sizeof(SoapRouterNode)); -  if (context) { -    node->context = (char*)malloc(strlen(context)+1); -    strcpy(node->context, context); -  } else { -    log_warn2("context is null. Using '%s'", noname); -    node->context = (char*)malloc(strlen(noname)+1); -    strcpy(node->context, noname); -  } - -  node->router = router; -  node->next = next; - -  return node; +	SoapRouterNode *node; +	const char *noname = "/lost_find"; + +	node = (SoapRouterNode*)malloc(sizeof(SoapRouterNode)); +	if (context) { +		node->context = (char*)malloc(strlen(context)+1); +		strcpy(node->context, context); +	} else { +		log_warn2("context is null. Using '%s'", noname); +		node->context = (char*)malloc(strlen(noname)+1); +		strcpy(node->context, noname); +	} + +	node->router = router; +	node->next = next; + +	return node;  }  static  SoapRouter *router_find(const char* context)  { -  SoapRouterNode *node = head; - -  while (node != NULL) { -    if (!strcmp(node->context, context)) -      return node->router; -    node = node->next; -  } -   -  return NULL; +	SoapRouterNode *node = head; + +	while (node != NULL) { +		if (!strcmp(node->context, context)) +			return node->router; +		node = node->next; +	} + +	return NULL;  } diff --git a/libcsoap/soap-service.c b/libcsoap/soap-service.c index 992e91d..8f87fb5 100644 --- a/libcsoap/soap-service.c +++ b/libcsoap/soap-service.c @@ -1,89 +1,88 @@  /****************************************************************** - *  $Id: soap-service.c,v 1.2 2004/05/12 22:23:30 snowdrop Exp $ - * - * CSOAP Project:  A SOAP client/server library in C - * Copyright (C) 2003  Ferhat Ayaz - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA  02111-1307, USA. - *  - * Email: ayaz@jprogrammer.net - ******************************************************************/ +*  $Id: soap-service.c,v 1.3 2004/08/26 17:06:18 rans Exp $ +* +* CSOAP Project:  A SOAP client/server library in C +* Copyright (C) 2003  Ferhat Ayaz +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Library General Public +* License as published by the Free Software Foundation; either +* version 2 of the License, or (at your option) any later version. +* +* This library 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 +* Library General Public License for more details. +* +* You should have received a copy of the GNU Library General Public +* License along with this library; if not, write to the +* Free Software Foundation, Inc., 59 Temple Place - Suite 330, +* Boston, MA  02111-1307, USA. +*  +* Email: ayaz@jprogrammer.net +******************************************************************/  #include <libcsoap/soap-service.h>  #include <nanohttp/nanohttp-common.h> - +#include <string.h>  SoapServiceNode *soap_service_node_new(SoapService *service,  -				       SoapServiceNode *next) +									   SoapServiceNode *next)  { -  SoapServiceNode *node ; +	SoapServiceNode *node ; -  node = (SoapServiceNode*)malloc(sizeof(SoapServiceNode)); -  node->service = service; -  node->next = next; +	node = (SoapServiceNode*)malloc(sizeof(SoapServiceNode)); +	node->service = service; +	node->next = next; -  return node; +	return node;  }  SoapService *soap_service_new(const char* urn,  -			      const char *method, -			      SoapServiceFunc f) +							  const char *method, +							  SoapServiceFunc f)  { -  SoapService *service; +	SoapService *service; -  service = (SoapService*)malloc(sizeof(SoapService)); -  service->func = f; +	service = (SoapService*)malloc(sizeof(SoapService)); +	service->func = f; -  if (urn != NULL) { -    service->urn = (char*)malloc(strlen(urn)+1); -    strcpy(service->urn, urn); -  } else { -    log_warn1("urn is NULL"); -    service->urn = ""; -  } +	if (urn != NULL) { +		service->urn = (char*)malloc(strlen(urn)+1); +		strcpy(service->urn, urn); +	} else { +		log_warn1("urn is NULL"); +		service->urn = ""; +	} -  if (method != NULL) { -    service->method = (char*)malloc(strlen(method)+1); -    strcpy(service->method, method); -  } else { -    log_warn1("method is NULL"); -    service->method = ""; -  } +	if (method != NULL) { +		service->method = (char*)malloc(strlen(method)+1); +		strcpy(service->method, method); +	} else { +		log_warn1("method is NULL"); +		service->method = ""; +	} -  return service; +	return service;  }  void soap_service_free(SoapService *service)  { -  log_verbose2("enter: service=%p", service); -   -  if (service == NULL) return; +	log_verbose2("enter: service=%p", service); -  if (strcmp(service->urn, "")) -    free(service->urn); +	if (service == NULL) return; -  if (strcmp(service->method, "")) -    free(service->method); +	if (strcmp(service->urn, "")) +		free(service->urn); -  free(service); -  log_verbose1("leave with success"); -} +	if (strcmp(service->method, "")) +		free(service->method); +	free(service); +	log_verbose1("leave with success"); +}
\ No newline at end of file diff --git a/libcsoap/soap-xml.c b/libcsoap/soap-xml.c index cbedddd..1cae5b1 100644 --- a/libcsoap/soap-xml.c +++ b/libcsoap/soap-xml.c @@ -1,126 +1,127 @@  /****************************************************************** - *  $Id: soap-xml.c,v 1.3 2004/02/03 08:59:22 snowdrop Exp $ - * - * CSOAP Project:  A SOAP client/server library in C - * Copyright (C) 2003  Ferhat Ayaz - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA  02111-1307, USA. - *  - * Email: ayaz@jprogrammer.net - ******************************************************************/ +*  $Id: soap-xml.c,v 1.4 2004/08/26 17:06:18 rans Exp $ +* +* CSOAP Project:  A SOAP client/server library in C +* Copyright (C) 2003  Ferhat Ayaz +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Library General Public +* License as published by the Free Software Foundation; either +* version 2 of the License, or (at your option) any later version. +* +* This library 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 +* Library General Public License for more details. +* +* You should have received a copy of the GNU Library General Public +* License along with this library; if not, write to the +* Free Software Foundation, Inc., 59 Temple Place - Suite 330, +* Boston, MA  02111-1307, USA. +*  +* Email: ayaz@jprogrammer.net +******************************************************************/  #include <libcsoap/soap-xml.h> +static const char* soap_env_ns = "http://schemas.xmlsoap.org/soap/envelope/";  xmlNodePtr soap_xml_get_children(xmlNodePtr param)  { -  xmlNodePtr children; - -  if (param == NULL) { -    log_error1("Invalid parameter 'param' (null)"); -    return NULL; -  } - -  children = param->xmlChildrenNode; -   while (children != NULL) { -    if (children->type != XML_ELEMENT_NODE) -      children = children->next; -    else break; -  } -   -  return children; +	xmlNodePtr children; + +	if (param == NULL) { +		log_error1("Invalid parameter 'param' (null)"); +		return NULL; +	} + +	children = param->xmlChildrenNode; +	while (children != NULL) { +		if (children->type != XML_ELEMENT_NODE) +			children = children->next; +		else break; +	} + +	return children;  }  xmlNodePtr soap_xml_get_next(xmlNodePtr param)  { -  xmlNodePtr node = param->next; +	xmlNodePtr node = param->next; -  while (node != NULL) { -    if (node->type != XML_ELEMENT_NODE) -      node = node->next; -    else break; -  } +	while (node != NULL) { +		if (node->type != XML_ELEMENT_NODE) +			node = node->next; +		else break; +	} -  return node; +	return node;  }  xmlXPathObjectPtr   soap_xpath_eval(xmlDocPtr doc, const char *xpath)  { -  xmlXPathContextPtr context; -  xmlXPathObjectPtr result; - -  context = xmlXPathNewContext(doc); -  result = xmlXPathEvalExpression((xmlChar*)xpath, context); -  if(xmlXPathNodeSetIsEmpty(result->nodesetval)){ -    /* no result */ -    return NULL; -  } - -  xmlXPathFreeContext(context); -  return result;   +	xmlXPathContextPtr context; +	xmlXPathObjectPtr result; + +	context = xmlXPathNewContext(doc); +	result = xmlXPathEvalExpression((xmlChar*)xpath, context); +	if(xmlXPathNodeSetIsEmpty(result->nodesetval)){ +		/* no result */ +		return NULL; +	} + +	xmlXPathFreeContext(context); +	return result;    }  int  soap_xpath_foreach(xmlDocPtr doc, const char *xpath,  -		   soap_xmlnode_callback cb, void *userdata) +				   soap_xmlnode_callback cb, void *userdata)  { -  int i = 0; -  xmlNodeSetPtr nodeset;  -  xmlXPathObjectPtr xpathobj; -   -  xpathobj = soap_xpath_eval(doc, xpath); - -  if (!xpathobj) return 0; - -  nodeset = xpathobj->nodesetval; -  if (!nodeset) return 0; - -  for (i=0;i < nodeset->nodeNr; i++) { -    if (!cb(nodeset->nodeTab[i], userdata)) -      break; -  } -   -  xmlXPathFreeObject(nodeset); -  return i; +	int i = 0; +	xmlNodeSetPtr nodeset;  +	xmlXPathObjectPtr xpathobj; + +	xpathobj = soap_xpath_eval(doc, xpath); + +	if (!xpathobj) return 0; + +	nodeset = xpathobj->nodesetval; +	if (!nodeset) return 0; + +	for (i=0;i < nodeset->nodeNr; i++) { +		if (!cb(nodeset->nodeTab[i], userdata)) +			break; +	} + +	xmlXPathFreeObject((xmlXPathObjectPtr)nodeset); +	return i;  }  void soap_xml_doc_print(xmlDocPtr doc)  { -  xmlBufferPtr buffer; -  xmlNodePtr root; - -  if (doc == NULL) { -    puts("xmlDocPtr is NULL!"); -    return; -  } - -  root = xmlDocGetRootElement(doc); -  if (root == NULL) { -    puts("Empty document!"); -    return; -  } -   - -  buffer = xmlBufferCreate(); -  xmlNodeDump(buffer, doc, root, 1 ,0); -  puts( (const char*)xmlBufferContent(buffer)); -  xmlBufferFree(buffer);   +	xmlBufferPtr buffer; +	xmlNodePtr root; + +	if (doc == NULL) { +		puts("xmlDocPtr is NULL!"); +		return; +	} + +	root = xmlDocGetRootElement(doc); +	if (root == NULL) { +		puts("Empty document!"); +		return; +	} + + +	buffer = xmlBufferCreate(); +	xmlNodeDump(buffer, doc, root, 1 ,0); +	puts( (const char*)xmlBufferContent(buffer)); +	xmlBufferFree(buffer);    } | 
