summaryrefslogtreecommitdiffstats
path: root/libcsoap
diff options
context:
space:
mode:
authorGravatar snowdrop2003-11-12 13:22:58 +0000
committerGravatar snowdrop2003-11-12 13:22:58 +0000
commit15d326912818f8b5080584a5d6a2f4e9d2acfcaa (patch)
tree68d703d9fa6084c011a801de155ec2e88828ff03 /libcsoap
parent04a5ded5af30359ac7fc764d3cc9f9d0176ad81b (diff)
downloadcsoap-15d326912818f8b5080584a5d6a2f4e9d2acfcaa.tar.gz
csoap-15d326912818f8b5080584a5d6a2f4e9d2acfcaa.tar.bz2
moved from src/
Diffstat (limited to 'libcsoap')
-rw-r--r--libcsoap/Makefile.am52
-rw-r--r--libcsoap/csoap.c37
-rw-r--r--libcsoap/csoap.h55
-rw-r--r--libcsoap/csoapbody.c96
-rw-r--r--libcsoap/csoapbody.h58
-rw-r--r--libcsoap/csoapcall.c226
-rw-r--r--libcsoap/csoapcall.h90
-rw-r--r--libcsoap/csoapenv.c168
-rw-r--r--libcsoap/csoapenv.h86
-rw-r--r--libcsoap/csoaperror.h47
-rw-r--r--libcsoap/csoapfault.c140
-rw-r--r--libcsoap/csoapfault.h124
-rw-r--r--libcsoap/csoaphttp.c153
-rw-r--r--libcsoap/csoaphttp.h45
-rw-r--r--libcsoap/csoaplog.c65
-rw-r--r--libcsoap/csoaplog.h26
-rw-r--r--libcsoap/csoapmethod.c70
-rw-r--r--libcsoap/csoapmethod.h56
-rw-r--r--libcsoap/csoapparam.c384
-rw-r--r--libcsoap/csoapparam.h187
-rw-r--r--libcsoap/csoapres.c154
-rw-r--r--libcsoap/csoapres.h90
-rw-r--r--libcsoap/csoapsocket.c149
-rw-r--r--libcsoap/csoapsocket.h109
-rw-r--r--libcsoap/csoaptypes.h33
-rw-r--r--libcsoap/csoapurl.c185
-rw-r--r--libcsoap/csoapurl.h70
-rw-r--r--libcsoap/csoapxml.c151
-rw-r--r--libcsoap/csoapxml.h90
29 files changed, 3196 insertions, 0 deletions
diff --git a/libcsoap/Makefile.am b/libcsoap/Makefile.am
new file mode 100644
index 0000000..d3889e9
--- /dev/null
+++ b/libcsoap/Makefile.am
@@ -0,0 +1,52 @@
+## Source directory
+
+
+h_sources = csoap.h\
+csoapbody.h\
+csoapcall.h\
+csoapenv.h\
+csoaperror.h\
+csoapfault.h\
+csoaphttp.h\
+csoaplog.h\
+csoapmethod.h\
+csoapparam.h\
+csoapres.h\
+csoapsocket.h\
+csoaptypes.h\
+csoapurl.h\
+csoapxml.h
+
+cc_sources = csoap.c\
+csoapbody.c\
+csoapcall.c\
+csoapenv.c\
+csoapfault.c\
+csoaphttp.c\
+csoaplog.c\
+csoapmethod.c\
+csoapparam.c\
+csoapres.c\
+csoapsocket.c\
+csoapurl.c\
+csoapxml.c
+
+library_includedir=$(includedir)/$(GENERIC_LIBRARY_NAME)-$(GENERIC_API_VERSION)/$(GENERIC_LIBRARY_NAME)
+library_include_HEADERS = $(h_sources)
+
+INCLUDES = -I$(top_srcdir) $(LIBXML_CFLAGS)
+
+# GENERIC_API_VERSION is 1.0
+lib_LTLIBRARIES= libcsoap-1.0.la
+libcsoap_1_0_la_SOURCES= $(h_sources) $(cc_sources)
+#libexamplelib_1_0_la_LIBADD= sub/libsub.la
+libcsoap_1_0_la_LDFLAGS= -version-info $(GENERIC_LIBRARY_VERSION) -release $(GENERIC_RELEASE)
+#libcsoap_1_0_la_CFLAGS= @LIBXML_CCFLAGS@
+
+
+
+
+
+
+
+
diff --git a/libcsoap/csoap.c b/libcsoap/csoap.c
new file mode 100644
index 0000000..e876d07
--- /dev/null
+++ b/libcsoap/csoap.c
@@ -0,0 +1,37 @@
+/******************************************************************
+ * $Id: csoap.c,v 1.1 2003/11/12 13:22:58 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
+ ******************************************************************/
+#include "libcsoap/csoap.h"
+
+#include "libcsoap/csoapxml.h"
+
+
+/*-----------------------------------------------------------------
+ FUNCTION: SoapFreeStr
+/-----------------------------------------------------------------*/
+
+void SoapFreeStr(char* str)
+{
+ if (str) xmlFree(str);
+}
+
diff --git a/libcsoap/csoap.h b/libcsoap/csoap.h
new file mode 100644
index 0000000..3df9939
--- /dev/null
+++ b/libcsoap/csoap.h
@@ -0,0 +1,55 @@
+/******************************************************************
+ * $Id: csoap.h,v 1.1 2003/11/12 13:22:58 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
+ ******************************************************************/
+#ifndef CSOAP_H
+#define CSOAP_H
+
+
+/* Include csoap headers */
+#include "libcsoap/csoapcall.h"
+#include "libcsoap/csoapfault.h"
+#include "libcsoap/csoapurl.h"
+#include "libcsoap/csoaptypes.h"
+
+/**
+ * Initialize routine. Must be called before any
+ * other csoap API function.
+ *
+ * @param argc command line parameter
+ * @param argv command line parameter
+ *
+ * @return CSOAP_OK if successfull.
+ */
+int SoapInit(int argc, char *argv[]);
+
+
+/**
+ * Free a string allocated by a csoap
+ * function.
+ *
+ * @param str the string to free
+ */
+void SoapFreeStr(char* str);
+
+
+#endif
diff --git a/libcsoap/csoapbody.c b/libcsoap/csoapbody.c
new file mode 100644
index 0000000..6499837
--- /dev/null
+++ b/libcsoap/csoapbody.c
@@ -0,0 +1,96 @@
+/******************************************************************
+ * $Id: csoapbody.c,v 1.1 2003/11/12 13:22:58 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
+ ******************************************************************/
+#include "libcsoap/csoapbody.h"
+#include "libcsoap/csoaplog.h"
+
+
+/*-----------------------------------------------------------------
+ FUNCTION: SoapBodyGetMethod
+/-----------------------------------------------------------------*/
+
+HSOAPMETHOD SoapBodyGetMethod(HSOAPBODY body, const char* method)
+{
+ HSOAPXML node;
+ const char* FUNC = "SoapBodyGetMethod";
+ SoapTraceEnter(FUNC,"Method = %s", method);
+
+ if (body == NULL) {
+ SoapLog(LOG_ERROR, FUNC,
+ "Invalid body (null)");
+ return NULL;
+ }
+
+ SoapLog(LOG_DEBUG, FUNC, "Searching method '%s'", method);
+
+ node = SoapXmlFindNode((HSOAPXML)body, method);
+ if (node == NULL) {
+ SoapTraceLeaveWithError(FUNC, "Can not find method");
+ return NULL;
+ }
+/*
+ cur = ((xmlNodePtr)body)->xmlChildrenNode;
+ while (cur != NULL) {
+ if (!xmlStrcmp(cur->name, (const xmlChar*)method)) {
+ SoapTraceLeave(FUNC, "Found method (%p)", cur);
+ return (HSOAPMETHOD)cur;
+ }
+ cur = cur->next;
+ }
+*/
+ SoapTraceLeave(FUNC, "Method (%p)", node);
+ return node;
+}
+
+
+/*-----------------------------------------------------------------
+ FUNCTION: SoapBodyGetFault
+/-----------------------------------------------------------------*/
+
+HSOAPFAULT SoapBodyGetFault(HSOAPBODY body)
+{
+ HSOAPXML node;
+ const char* FUNC = "SoapBodyGetFault";
+ SoapTraceEnter(FUNC,"Body (%p)", body);
+
+ if (body == NULL) {
+ SoapLog(LOG_ERROR, FUNC,
+ "Invalid body (null)");
+ return NULL;
+ }
+
+/*
+ cur = ((xmlNodePtr)body)->xmlChildrenNode;
+ while (cur != NULL) {
+ if (!xmlStrcmp(cur->name, (const xmlChar*)"Fault")) {
+ SoapTraceLeave(FUNC, "Found fault (%p)", cur);
+ return (HSOAPFAULT)cur;
+ }
+ cur = cur->next;
+ }
+*/
+
+ node = SoapXmlFindNode((HSOAPXML)body, "Fault");
+ SoapTraceLeave(FUNC, "Fault (%p)", node);
+ return node;
+}
diff --git a/libcsoap/csoapbody.h b/libcsoap/csoapbody.h
new file mode 100644
index 0000000..92d595e
--- /dev/null
+++ b/libcsoap/csoapbody.h
@@ -0,0 +1,58 @@
+/******************************************************************
+ * $Id: csoapbody.h,v 1.1 2003/11/12 13:22:58 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
+ ******************************************************************/
+#ifndef CSOAP_BODY_H
+#define CSOAP_BODY_H
+
+#include "libcsoap/csoapmethod.h"
+#include "libcsoap/csoapfault.h"
+
+typedef HSOAPXML HSOAPBODY;
+
+
+
+/**
+ * Returns the method object assigned to
+ * the given body.
+ *
+ * @param body handle to the body object
+ * @param method the method(operation) name
+ * to call.
+ *
+ * @return a handle to the method object or
+ * NULL if the the method was not found.
+ */
+HSOAPMETHOD SoapBodyGetMethod(HSOAPBODY body, const char *method);
+
+
+/**
+ * Returns the fault object if any exist.
+ *
+ * @param body handle to the body object
+ * @return a handle to a fault object or
+ * NULL if no fault was generated.
+ */
+HSOAPFAULT SoapBodyGetFault(HSOAPBODY body);
+
+
+#endif
diff --git a/libcsoap/csoapcall.c b/libcsoap/csoapcall.c
new file mode 100644
index 0000000..d74b51c
--- /dev/null
+++ b/libcsoap/csoapcall.c
@@ -0,0 +1,226 @@
+/******************************************************************
+ * $Id: csoapcall.c,v 1.1 2003/11/12 13:22:58 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
+ ******************************************************************/
+#include "libcsoap/csoapcall.h"
+#include "libcsoap/csoaplog.h"
+#include "libcsoap/csoaphttp.h"
+
+#include <stdarg.h>
+#include <string.h>
+
+HSOAPCALL SoapCallCreate(
+ const char* url,
+ const char* uri,
+ const char* method)
+{
+ const char *FUNC = "SoapCallCreate";
+ HSOAPCALL call;
+
+ SoapTraceEnter(FUNC, "url=%s;uri=%s;method=%s",
+ url, uri, method);
+ call = (HSOAPCALL)malloc(sizeof(struct SOAPCALL));
+ call->m_method = (char*)malloc(strlen(method)+1);
+
+ call->m_env = SoapEnvCreate(uri, method);
+ call->m_url = SoapUrlCreate(url);
+ strcpy(call->m_method, method);
+
+ SoapTraceLeave(FUNC, "call (%p)", call);
+ return call;
+}
+
+
+HSOAPPARAM SoapCallAddParam(
+ HSOAPCALL call,
+ const char* name,
+ const char* type,
+ const char* format,
+ ...)
+{
+ const char *FUNC = "SoapCallAddParam";
+ HSOAPBODY body;
+ HSOAPMETHOD method;
+ HSOAPPARAM param, result;
+ va_list ap;
+ char buffer[SOAP_MAX_STRING_BUFFER];
+
+ SoapTraceEnter(FUNC, "name=%s;type=%s;format=%s",
+ name, type, format);
+
+ va_start(ap, format);
+ vsprintf(buffer, format, ap);
+ va_end(ap);
+
+ body = SoapEnvGetBody(call->m_env);
+ method = SoapBodyGetMethod(body, call->m_method);
+ param = SoapMethodParamContext(method);
+ result = SoapParamCreate(param, type, NULL, name, "%s", buffer);
+
+ SoapTraceLeave(FUNC, "created param (%p)", result);
+ return result;
+}
+
+
+HSOAPPARAM SoapCallAddStringParam(
+ HSOAPCALL call,
+ const char* name,
+ const char* format,
+ ...)
+{
+ const char *FUNC = "SoapCallAddStringParam";
+ HSOAPBODY body;
+ HSOAPMETHOD method;
+ HSOAPPARAM param, result;
+ va_list ap;
+ char buffer[SOAP_MAX_STRING_BUFFER];
+
+ SoapTraceEnter(FUNC, "name=%s;format=%s",
+ name, format);
+
+ va_start(ap, format);
+ vsprintf(buffer, format, ap);
+ va_end(ap);
+
+ body = SoapEnvGetBody(call->m_env);
+ method = SoapBodyGetMethod(body, call->m_method);
+ param = SoapMethodParamContext(method);
+ result = SoapParamCreateString(param, name, buffer);
+ SoapTraceLeave(FUNC, "created param (%p)", result);
+ return result;
+}
+
+
+HSOAPPARAM SoapCallAddIntParam(
+ HSOAPCALL call,
+ const char* name,
+ int value)
+{
+ const char *FUNC = "SoapCallAddIntParam";
+ HSOAPBODY body;
+ HSOAPMETHOD method;
+ HSOAPPARAM param, result;
+
+ SoapTraceEnter(FUNC, "name=%s;value=%d",
+ name, value);
+
+ body = SoapEnvGetBody(call->m_env);
+ method = SoapBodyGetMethod(body, call->m_method);
+ param = SoapMethodParamContext(method);
+ result = SoapParamCreateInt(param, name, value);
+ SoapTraceLeave(FUNC, "created param (%p)", result);
+ return result;
+}
+
+HSOAPPARAM SoapCallAddDoubleParam(
+ HSOAPCALL call,
+ const char* name,
+ double value)
+{
+ const char *FUNC = "SoapCallAddDoubleParam";
+ HSOAPBODY body;
+ HSOAPMETHOD method;
+ HSOAPPARAM param, result;
+
+ SoapTraceEnter(FUNC, "name=%s;value=%f",
+ name, value);
+
+ body = SoapEnvGetBody(call->m_env);
+ method = SoapBodyGetMethod(body, call->m_method);
+ param = SoapMethodParamContext(method);
+ result = SoapParamCreateDouble(param, name, value);
+ SoapTraceLeave(FUNC, "created param (%p)", result);
+ return result;
+}
+
+
+HSOAPRES SoapCallInvoke(HSOAPCALL call)
+{
+ const char* FUNC = "SoapCallInvoke";
+ const char* filename = "libcsoap/csoap-client.xml";
+ char *buf;
+ CSOAP_STATUS status;
+ HSOAPENV env;
+ HSOAPRES res;
+
+ SoapTraceEnter(FUNC,"%p", call);
+
+ if (!call) {
+ SoapTraceLeaveWithError(FUNC, "Call is null!");
+ return NULL;
+ }
+
+ if (!call->m_env) {
+ SoapTraceLeaveWithError(FUNC, "Invalid envelope!");
+ return NULL;
+ }
+
+ if (!call->m_url) {
+ SoapTraceLeaveWithError(FUNC, "Invalid URL");
+ return NULL;
+ }
+
+/* xmlSaveFormatFile(filename, ((xmlNodePtr)call->m_env)->doc, 1);
+ buffer = xmlBufferCreate();
+ xmlNodeDump(buffer, ((xmlNodePtr)call->m_env)->doc,
+ (xmlNodePtr)call->m_env, 1 ,2);
+ printf("\n%s\n", (const char*)xmlBufferContent(buffer));
+ xmlBufferFree(buffer);
+*/
+
+ printf("Sending ...\n");
+ status = SoapHttpSend(call->m_url, call->m_env, &env);
+ if (status != CSOAP_OK) {
+ printf("can not send. code = %d\n", status);
+ }
+ printf("Sending finished\n");
+ /*
+ printf("Length: %d\nResponse: \n%s\n\n\r", strlen(buf), buf?buf:"null");
+ */
+ SoapEnvDump(env);
+ /* free(buf);*/
+ /* SoapEnvFree(env);*/
+ res = SoapResCreate(env, call->m_method);
+ SoapTraceLeave(FUNC, "res (%p)", res);
+ return res;
+}
+
+
+void SoapCallFree(HSOAPCALL call)
+{
+ const char* FUNC = "SoapCallFree";
+ SoapTraceEnter(FUNC,"%p", call);
+
+ if (!call) {
+ SoapTraceLeave(FUNC, "Call is null!");
+ return;
+ }
+
+ SoapEnvFree(call->m_env);
+
+ if (call->m_url) SoapUrlFree(call->m_url);
+ if (call->m_method) free(call->m_method);
+
+ free(call);
+ SoapTraceLeave(FUNC, "Call destroyed");
+}
+
diff --git a/libcsoap/csoapcall.h b/libcsoap/csoapcall.h
new file mode 100644
index 0000000..bfb15fc
--- /dev/null
+++ b/libcsoap/csoapcall.h
@@ -0,0 +1,90 @@
+/******************************************************************
+ * $Id: csoapcall.h,v 1.1 2003/11/12 13:22:58 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
+ ******************************************************************/
+#ifndef CSOAP_CALL_H
+#define CSOAP_CALL_H
+
+#include "libcsoap/csoapparam.h"
+#include "libcsoap/csoapres.h"
+#include "libcsoap/csoapenv.h"
+#include "libcsoap/csoapurl.h"
+
+typedef struct SOAPCALL* HSOAPCALL;
+
+
+/**
+ * Stores information to
+ * send a soap call
+ */
+struct SOAPCALL
+{
+ HSOAPENV m_env; /* The soap envelope */
+ HSOAPURL m_url; /* The target URL */
+ char* m_method; /* The method to to call */
+};
+
+
+HSOAPCALL SoapCallCreate(
+ const char* url,
+ const char* uri,
+ const char* method
+);
+
+
+HSOAPPARAM SoapCallAddParam(
+ HSOAPCALL call,
+ const char* name,
+ const char* type,
+ const char* format,
+ ...
+);
+
+
+HSOAPPARAM SoapCallAddStringParam(
+ HSOAPCALL call,
+ const char* name,
+ const char* format,
+ ...
+);
+
+
+HSOAPPARAM SoapCallAddIntParam(
+ HSOAPCALL call,
+ const char* name,
+ int value
+);
+
+
+HSOAPPARAM SoapCallAddDoubleParam(
+ HSOAPCALL call,
+ const char* name,
+ double value
+);
+
+
+HSOAPRES SoapCallInvoke(HSOAPCALL call);
+
+void SoapCallFree(HSOAPCALL call);
+
+
+#endif
diff --git a/libcsoap/csoapenv.c b/libcsoap/csoapenv.c
new file mode 100644
index 0000000..47a3872
--- /dev/null
+++ b/libcsoap/csoapenv.c
@@ -0,0 +1,168 @@
+/******************************************************************
+ * $Id: csoapenv.c,v 1.1 2003/11/12 13:22:58 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
+ ******************************************************************/
+#include "libcsoap/csoapenv.h"
+#include "libcsoap/csoaplog.h"
+
+static char *soap_env_ns = "http://schemas.xmlsoap.org/soap/envelope/";
+static char *soap_env_enc = "http://schemas.xmlsoap.org/soap/encoding/";
+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)
+ */
+#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>"
+
+
+
+/*-----------------------------------------------------------------
+ FUNCTION: SoapEnvCreate
+/-----------------------------------------------------------------*/
+
+HSOAPENV SoapEnvCreate(const char *uri, const char *method)
+{
+ xmlDocPtr env;
+ xmlNodePtr node;
+ char buffer[1054];
+
+ const char* FUNC = "SoapEnvCreate";
+
+ SoapTraceEnter( FUNC,
+ "URI = '%s'\nMethod = '%s'",
+ uri, method);
+
+ sprintf(buffer, SOAP_MSG_TEMPLATE,
+ soap_env_ns, soap_env_enc, soap_xsi_ns,
+ soap_xsd_ns, method, uri, method);
+
+ env = xmlParseDoc(buffer);
+ if (env == NULL) {
+ SoapLog(LOG_ERROR, FUNC,
+ "Can not create xml document!");
+ return NULL;
+ }
+
+ node = xmlDocGetRootElement(env);
+ if (node == NULL) {
+ SoapLog(LOG_ERROR, FUNC,
+ "xml document is empty!");
+ return NULL;
+ }
+
+ SoapLog(LOG_DEBUG, FUNC,
+ "Envelope created successfully");
+
+ SoapTraceLeave(FUNC, "Envelope: %p", node);
+
+ return (HSOAPENV)node;
+}
+
+
+/*-----------------------------------------------------------------
+ FUNCTION: SoapEnvGetBody
+/-----------------------------------------------------------------*/
+
+HSOAPBODY SoapEnvGetBody(HSOAPENV envelope)
+{
+ xmlNodePtr cur;
+ const char* FUNC = "SoapEnvGetBody";
+ SoapTraceEnter(FUNC,"");
+
+ if (envelope == NULL) {
+ SoapLog(LOG_ERROR, FUNC,
+ "Invalid envelope (null)");
+ return NULL;
+ }
+
+ cur = ((xmlNodePtr)envelope)->xmlChildrenNode;
+ while (cur != NULL) {
+ if (!xmlStrcmp(cur->name, (const xmlChar*)"Body")) {
+ SoapTraceLeave(FUNC, "Found Body (%p)", cur);
+ return (HSOAPBODY)cur;
+ }
+ cur = cur->next;
+ }
+
+ SoapTraceLeave(FUNC, "No body found!");
+ return NULL;
+}
+
+
+/*-----------------------------------------------------------------
+ FUNCTION: SoapEnvFree
+/-----------------------------------------------------------------*/
+
+void SoapEnvFree(HSOAPENV envelope)
+{
+ const char* FUNC = "SoapEnvFree";
+ SoapTraceEnter(FUNC,"%p", envelope);
+
+ if (!envelope) {
+ SoapTraceLeave(FUNC, "Envelope is null!");
+ return;
+ }
+
+ xmlFreeDoc(((xmlNodePtr)envelope)->doc);
+ SoapTraceLeave(FUNC, "Envelope destroyed");
+}
+
+
+/*-----------------------------------------------------------------
+ FUNCTION: SoapEnvDump
+/-----------------------------------------------------------------*/
+
+void SoapEnvDump(HSOAPENV env)
+{
+ const char *FUNC = "SoapEnvDump";
+
+ xmlBufferPtr buffer;
+ xmlDocPtr doc;
+ char *str;
+
+ SoapTraceEnter(FUNC, "env (%p)", env);
+
+ buffer = xmlBufferCreate();
+ xmlNodeDump(buffer, ((xmlNodePtr)env)->doc, (xmlNodePtr)env, 1 ,1);
+ str = (char*)xmlBufferContent(buffer);
+
+ printf("%s\n", str?str:"null");
+
+ xmlBufferFree(buffer);
+ SoapTraceLeave(FUNC, "Leaving");
+}
diff --git a/libcsoap/csoapenv.h b/libcsoap/csoapenv.h
new file mode 100644
index 0000000..2046fff
--- /dev/null
+++ b/libcsoap/csoapenv.h
@@ -0,0 +1,86 @@
+/******************************************************************
+ * $Id: csoapenv.h,v 1.1 2003/11/12 13:22:58 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@jprogrammet.net
+ ******************************************************************/
+#ifndef CSOAP_ENV_H
+#define CSOAP_ENV_H
+
+#include "libcsoap/csoapxml.h"
+#include "libcsoap/csoapbody.h"
+
+typedef HSOAPXML HSOAPENV;
+
+
+/**
+ * Creates a new soap envelope object
+ *
+ * @param uri the URI
+ * @param method the method name to call
+ *
+ * @return handle to an envelope object if
+ * creation was successfull or NULL otherwise.
+ */
+HSOAPENV SoapEnvCreate(const char *uri, const char *method);
+
+
+/**
+ * Creates a new soap envelope object
+ *
+ * @param uri the URI
+ * @param method the method name to call
+ *
+ * @return handle to an envelope object if
+ * creation was successfull or NULL otherwise.
+ */
+HSOAPENV SoapEnvCreateWithFault(const char *uri, const char *method);
+
+
+/**
+ * Returns the soap body object to
+ * a given envelope object.
+ *
+ * @param envelope the envelope
+ * @return handle to a body object if
+ * any exist or NULL otherwise
+ */
+HSOAPBODY SoapEnvGetBody(HSOAPENV envelope);
+
+
+/**
+ * Free a given envelope object
+ *
+ * @param envelope the envelope object
+ * to free
+ */
+void SoapEnvFree(HSOAPENV envelope);
+
+
+/**
+ * Dumps an envelope object to the stdout.
+ * For debug puposes only.
+ *
+ * @param env the envelope object to dump
+ */
+void SoapEnvDump(HSOAPENV env);
+
+
+#endif
diff --git a/libcsoap/csoaperror.h b/libcsoap/csoaperror.h
new file mode 100644
index 0000000..6ee3b14
--- /dev/null
+++ b/libcsoap/csoaperror.h
@@ -0,0 +1,47 @@
+/******************************************************************
+ * $Id: csoaperror.h,v 1.1 2003/11/12 13:22:58 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
+ ******************************************************************/
+#ifndef CSOAP_ERROR_H
+#define CSOAP_ERROR_H
+
+typedef int CSOAP_STATUS;
+
+/* Ok status */
+#define CSOAP_OK 0
+
+/* Socket related errors */
+#define ERROR_SOCKET_CAN_NOT_GET_HOSTNAME 100001
+#define ERROR_SOCKET_CAN_NOT_CONNECT 100002
+#define ERROR_SOCKET_CAN_NOT_CREATE_SOCKET 100003
+#define ERROR_SOCKET_CAN_NOT_RECEIVE 100004
+#define ERROR_SOCKET_CAN_NOT_SEND 100005
+
+
+/* Generic errors */
+#define ERROR_NO_MEM 110001
+
+
+/* xml related error */
+#define ERROR_XML_CAN_NOT_PARSE 12001
+
+#endif
diff --git a/libcsoap/csoapfault.c b/libcsoap/csoapfault.c
new file mode 100644
index 0000000..6755e7a
--- /dev/null
+++ b/libcsoap/csoapfault.c
@@ -0,0 +1,140 @@
+/******************************************************************
+ * $Id: csoapfault.c,v 1.1 2003/11/12 13:22:58 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
+ ******************************************************************/
+#include "libcsoap/csoapfault.h"
+
+
+
+/*-----------------------------------------------------------------
+ FUNCTION: SoapFaultGetFaultCode
+/-----------------------------------------------------------------*/
+
+char* SoapFaultGetFaultCode(HSOAPFAULT fault)
+{
+ xmlNodePtr node;
+ const char *FUNC = "SoapFaultGetFaultCode";
+
+ SoapTraceEnter(FUNC, "Entering");
+
+ node = SoapXmlFindNode((HSOAPXML)fault, "faultcode");
+ if (node == NULL) {
+ SoapTraceLeaveWithError(FUNC, "Can not find faultcode");
+ return NULL;
+ }
+
+ SoapTraceLeave(FUNC, "Leaving");
+ return SoapXmlGetNodeValueAlloc(node);
+}
+
+
+/*-----------------------------------------------------------------
+ FUNCTION: SoapFaultGetFaultString
+/-----------------------------------------------------------------*/
+
+char* SoapFaultGetFaultString(HSOAPFAULT fault)
+{
+ xmlNodePtr node;
+ const char *FUNC = "SoapFaultGetFaultString";
+
+ SoapTraceEnter(FUNC, "Entering");
+
+ node = SoapXmlFindNode((HSOAPXML)fault, "faultstring");
+ if (node == NULL) {
+ SoapTraceLeaveWithError(FUNC, "Can not find faultstring");
+ return NULL;
+ }
+
+ SoapTraceLeave(FUNC, "Leaving");
+ return SoapXmlGetNodeValueAlloc(node);
+}
+
+
+/*-----------------------------------------------------------------
+ FUNCTION: SoapFaultGetFaultActor
+/-----------------------------------------------------------------*/
+
+char* SoapFaultGetFaultActor(HSOAPFAULT fault)
+{
+ xmlNodePtr node;
+ const char *FUNC = "SoapFaultGetFaultActor";
+
+ SoapTraceEnter(FUNC, "Entering");
+
+ node = SoapXmlFindNode((HSOAPXML)fault, "faultactor");
+ if (node == NULL) {
+ SoapTraceLeaveWithError(FUNC, "Can not find faultactor");
+ return NULL;
+ }
+
+ SoapTraceLeave(FUNC, "Leaving");
+ return SoapXmlGetNodeValueAlloc(node);
+}
+
+
+/*-----------------------------------------------------------------
+ FUNCTION: SoapFaultGetFaultDetail
+/-----------------------------------------------------------------*/
+
+HSOAPPARAM SoapFaultGetDetail(HSOAPFAULT fault)
+{
+ xmlNodePtr node;
+ const char *FUNC = "SoapFaultGetFaultCode";
+
+ SoapTraceEnter(FUNC, "Entering");
+
+ node = SoapXmlFindNode((HSOAPXML)fault, "detail");
+ if (node == NULL) {
+ SoapTraceLeaveWithError(FUNC, "Can not find detail");
+ return NULL;
+ }
+
+ SoapTraceLeave(FUNC, "Leaving");
+ return (HSOAPPARAM)node;
+}
+
+
+/*-----------------------------------------------------------------
+ FUNCTION: SoapFaultPrint
+/-----------------------------------------------------------------*/
+
+void SoapFaultPrint(FILE* f, HSOAPFAULT fault)
+{
+ char *str;
+
+ if (fault == NULL) {
+ fprintf(f, "Fault object is null!.\n");
+ return;
+ }
+
+ str = SoapFaultGetFaultCode(fault);
+ fprintf(f, "FaultCode: %s\n", str?str:"null");
+ SoapFreeStr(str);
+
+ str = SoapFaultGetFaultString(fault);
+ fprintf(f, "FaultString: %s\n", str?str:"null");
+ SoapFreeStr(str);
+
+ str = SoapFaultGetFaultActor(fault);
+ fprintf(f, "FaultActor: %s\n", str?str:"null");
+ SoapFreeStr(str);
+}
diff --git a/libcsoap/csoapfault.h b/libcsoap/csoapfault.h
new file mode 100644
index 0000000..fc706cb
--- /dev/null
+++ b/libcsoap/csoapfault.h
@@ -0,0 +1,124 @@
+/******************************************************************
+ * $Id: csoapfault.h,v 1.1 2003/11/12 13:22:58 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
+ ******************************************************************/
+#ifndef CSOAP_FAULT_H
+#define CSOAP_FAULT_H
+
+
+#include "libcsoap/csoapxml.h"
+#include "libcsoap/csoapparam.h"
+
+typedef HSOAPXML HSOAPFAULT;
+
+
+/**
+ * Returns the [faultcode]
+ *
+ * @param fault handle to a soap fault object
+ * @return an allocated string or NULL
+ * if no [faultcode] was set.
+ */
+char* SoapFaultGetFaultCode(HSOAPFAULT fault);
+
+
+/**
+ * Returns the [faultstring]
+ *
+ * @param fault handle to a soap fault object
+ * @return an allocated string or NULL
+ * if no [faultstring] was set.
+ */
+char* SoapFaultGetFaultString(HSOAPFAULT fault);
+
+
+/**
+ * Returns the [faultactor]
+ *
+ * @param fault handle to a soap fault object
+ * @return an allocated string or NULL
+ * if no [faultactor] was set.
+ */
+char* SoapFaultGetFaultActor(HSOAPFAULT fault);
+
+
+/**
+ * Returns the [detail]
+ *
+ * @param fault handle to a soap fault object
+ * @return handle to a soap param object
+ */
+HSOAPPARAM SoapFaultGetDetail(HSOAPFAULT fault);
+
+
+/**
+ * Sets the a [faultcode] field.
+ * This will be called internally.
+ *
+ * @param fault handle to a soap fault object
+ * @param faultcode the faultcode to set
+ */
+void SoapFaultSetFaultCode(HSOAPFAULT fault, const char* faultCode);
+
+
+/**
+ * Sets the a [faultstring] field.
+ * This will be called internally.
+ *
+ * @param fault handle to a soap fault object
+ * @param faultstring the faultstring to set
+ */
+void SoapFaultSetFaultString(HSOAPFAULT fault, const char* faultString);
+
+
+/**
+ * Sets the a [faultactor] field.
+ * This will be called internally.
+ *
+ * @param fault handle to a soap fault object
+ * @param faultactor the faultactor to set
+ */
+void SoapFaultSetFaultActor(HSOAPFAULT fault, const char* faultActor);
+
+
+/**
+ * Sets the a [faultdetail] field.
+ * This will be called internally.
+ *
+ * @param fault handle to a soap fault object
+ * @param faultcode the detail to set
+ */
+void SoapFaultSetFaultDetail(HSOAPFAULT fault, HSOAPPARAM param);
+
+
+/**
+ * Prints a fault object into the
+ * given file. This is for debug puposes.
+ *
+ * @param f the file to print into
+ * @param fault the fault object to print
+ */
+void SoapFaultPrint(FILE* f, HSOAPFAULT fault);
+
+
+#endif
+
diff --git a/libcsoap/csoaphttp.c b/libcsoap/csoaphttp.c
new file mode 100644
index 0000000..68b6cd3
--- /dev/null
+++ b/libcsoap/csoaphttp.c
@@ -0,0 +1,153 @@
+/******************************************************************
+ * $Id: csoaphttp.c,v 1.1 2003/11/12 13:22:58 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@jprogrammet.net
+ ******************************************************************/
+#include "libcsoap/csoaphttp.h"
+#include "libcsoap/csoaplog.h"
+#include "libcsoap/csoapxml.h"
+
+/*-----------------------------------------------------------------
+ FUNCTION: SoapHttpCreateEnv
+/-----------------------------------------------------------------*/
+
+static
+HSOAPENV SoapHttpCreateEnv(char* httpResponse)
+{
+ const char *FUNC = "SoapHttpCreateEnv";
+ int count = 0;
+ int newline = 0;
+ xmlDocPtr env;
+ xmlNodePtr node;
+ int len;
+ char *tmp;
+
+ SoapTraceEnter(FUNC, "Entering response =\n");
+ while (*(httpResponse+count) != '\0') {
+ if (httpResponse[count]=='\r') {
+ count++;
+ continue;
+ }
+ if (httpResponse[count]=='\n') {
+ if (newline) break;
+ else newline = 1;
+ } else newline = 0;
+
+ count++;
+ }
+
+ len = strlen(httpResponse);
+ SoapLog(LOG_DEBUG, FUNC, "count = %d\n", count);
+ SoapLog(LOG_DEBUG, FUNC, "response length = %d\n", len);
+
+ len = strlen(&httpResponse[count]);
+ SoapLog(LOG_DEBUG, FUNC, "xml response length = %d\n", len);
+
+ while (httpResponse[count] == '\n'
+ || httpResponse[count] == '\r') {
+ count++;
+ }
+
+ SoapLog(LOG_DEBUG, FUNC, "count = %d\n", count);
+
+ SoapLog(LOG_DEBUG, FUNC, "casting\n");
+ tmp = (char*)(&httpResponse[count]);
+ SoapLog(LOG_DEBUG, FUNC, "casting ok\n");
+
+ /* SoapLog(LOG_DEBUG, FUNC, "xml = %s\n",tmp?tmp:"null");
+ */
+ SoapLog(LOG_DEBUG, FUNC, "Starting parsing\n");
+ env = xmlParseMemory((const char*)tmp, len);
+ if (env == NULL) {
+ SoapLog(LOG_ERROR, FUNC,
+ "Can not create xml document!");
+ return NULL;
+ }
+
+ node = xmlDocGetRootElement(env);
+ if (node == NULL) {
+ SoapLog(LOG_ERROR, FUNC,
+ "xml document is empty!");
+ return NULL;
+ }
+
+ SoapLog(LOG_DEBUG, FUNC,
+ "Envelope created successfully");
+
+ SoapTraceLeave(FUNC, "env (%p)", node);
+ return (HSOAPENV)node;
+}
+
+
+/*-----------------------------------------------------------------
+ FUNCTION: SoapHttpSend
+/-----------------------------------------------------------------*/
+
+CSOAP_STATUS SoapHttpSend(HSOAPURL url, HSOAPENV env, HSOAPENV* res)
+{
+ const char *FUNC = "SoapHttpSend";
+ HSOAPSOCKET http;
+ int len;
+ ssize_t size;
+ char *tmp;
+ char *response;
+ char tmp2[1054];
+ CSOAP_STATUS status;
+ xmlBufferPtr buffer;
+ xmlDocPtr doc;
+
+ SoapTraceEnter(FUNC, "env (%p)", env);
+
+ buffer = xmlBufferCreate();
+ xmlNodeDump(buffer, ((xmlNodePtr)env)->doc, (xmlNodePtr)env, 1 ,1);
+ len = strlen((const char*)xmlBufferContent(buffer));
+
+ tmp = (char*)malloc(1054 + len);
+ if (tmp == NULL)
+ return ERROR_NO_MEM;
+
+ status = SoapSocketCreate(url->m_host, url->m_port, &http);
+ if (status != CSOAP_OK) return status;
+
+ /*SoapSocketGetResponse(http);*/
+ sprintf(tmp2, "POST %s HTTP/1.0\n", url->m_context?url->m_context:"/");
+ sprintf(tmp2, "%sContent-Type: text/xml\n", tmp2);
+ sprintf(tmp2, "%sContent-Length: %d\n\n", tmp2, len);
+
+ sprintf(tmp, "%s%s", tmp2, (const char*)xmlBufferContent(buffer));
+
+ SoapLog(LOG_DEBUG, FUNC, "sending request\n");
+ status = SoapSocketSend(http, tmp, &size);
+ if (status != CSOAP_OK) return status;
+
+ status = SoapSocketRecv(http, &response, &size);
+ SoapLog(LOG_DEBUG, FUNC, "response returned status = %d\n", status);
+ if (status != CSOAP_OK) return status;
+
+ *res = SoapHttpCreateEnv(response);
+ free(tmp);
+ free(response);
+ xmlBufferFree(buffer);
+
+ SoapTraceLeave(FUNC, "");
+ return CSOAP_OK;
+}
+
diff --git a/libcsoap/csoaphttp.h b/libcsoap/csoaphttp.h
new file mode 100644
index 0000000..7d8f047
--- /dev/null
+++ b/libcsoap/csoaphttp.h
@@ -0,0 +1,45 @@
+/******************************************************************
+ * $Id: csoaphttp.h,v 1.1 2003/11/12 13:22:58 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@jprogrammet.net
+ ******************************************************************/
+#ifndef CSOAP_HTTP_H
+#define CSOAP_HTTP_H
+
+#include "libcsoap/csoapenv.h"
+#include "libcsoap/csoapsocket.h"
+#include "libcsoap/csoapurl.h"
+
+/**
+ * Sends a soap envelope to the given
+ * host and receives a soap envelope.
+ *
+ * @param url The target url
+ * @param env The soap envelope to send
+ * @param res The destination soap handle to
+ * receive the the envelope.
+ *
+ * @return CSOAP_OK if it was successfull.
+ */
+CSOAP_STATUS SoapHttpSend(HSOAPURL url, HSOAPENV env, HSOAPENV* res);
+
+
+#endif
diff --git a/libcsoap/csoaplog.c b/libcsoap/csoaplog.c
new file mode 100644
index 0000000..3d5b127
--- /dev/null
+++ b/libcsoap/csoaplog.c
@@ -0,0 +1,65 @@
+#include "libcsoap/csoaplog.h"
+
+#include <stdarg.h>
+#include <stdio.h>
+
+static
+void _SoapLogWrite(SoapLogLevel level,
+ const char* function,
+ const char* format,
+ va_list ap)
+{
+ char buffer[1054];
+ char buffer2[1054];
+ sprintf(buffer, "[%s] [%d] %s\n", function, level, format);
+ vsprintf(buffer2, buffer, ap);
+/* printf(buffer2);
+ fflush(stdout);
+*/
+}
+
+
+void SoapTraceEnter(const char* function,
+ const char* format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ _SoapLogWrite(LOG_TRACE, function, format, ap);
+ va_end(ap);
+}
+
+
+void SoapTraceLeave(const char* function,
+ const char* format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ _SoapLogWrite(LOG_TRACE, function, format, ap);
+ va_end(ap);
+}
+
+
+void SoapTraceLeaveWithError(const char* function,
+ const char* format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ _SoapLogWrite(LOG_ERROR, function, format, ap);
+ va_end(ap);
+}
+
+
+void SoapLog(SoapLogLevel level, const char* function,
+ const char* format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ _SoapLogWrite(level, function, format, ap);
+ va_end(ap);
+}
+
+
diff --git a/libcsoap/csoaplog.h b/libcsoap/csoaplog.h
new file mode 100644
index 0000000..6d7edb6
--- /dev/null
+++ b/libcsoap/csoaplog.h
@@ -0,0 +1,26 @@
+#ifndef CSOAP_LOG_H
+#define CSOAP_LOG_H
+
+
+typedef enum tagSoapLogLevel
+{
+ LOG_TRACE,
+ LOG_DEBUG,
+ LOG_INFO,
+ LOG_WARN,
+ LOG_ERROR
+}SoapLogLevel;
+
+void SoapTraceEnter(const char* function,
+ const char* format, ...);
+
+void SoapTraceLeave(const char* function,
+ const char* format, ...);
+void SoapTraceLeaveWithError(const char* function,
+ const char* format, ...);
+
+void SoapLog(SoapLogLevel level, const char* function,
+ const char* format, ...);
+
+#endif
+
diff --git a/libcsoap/csoapmethod.c b/libcsoap/csoapmethod.c
new file mode 100644
index 0000000..9e26ea1
--- /dev/null
+++ b/libcsoap/csoapmethod.c
@@ -0,0 +1,70 @@
+/******************************************************************
+ * $Id: csoapmethod.c,v 1.1 2003/11/12 13:22:58 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@jprogrammet.net
+ ******************************************************************/
+#include "libcsoap/csoapmethod.h"
+#include "libcsoap/csoaplog.h"
+
+
+/*-----------------------------------------------------------------
+ FUNCTION:SoapMethodGetName
+/-----------------------------------------------------------------*/
+
+char* SoapMethodGetName(HSOAPMETHOD method)
+{
+ const char* FUNC = "SoapMethodGetName";
+ char *name;
+ xmlNodePtr node;
+ SoapTraceEnter(FUNC,"");
+
+ if (method == NULL) {
+ SoapLog(LOG_ERROR, FUNC,
+ "Invalid method (null)");
+ return NULL;
+ }
+ node = (xmlNodePtr)method;
+ name = (char*)node->name;
+ SoapTraceLeave(FUNC, "Name = '%s'", name);
+ return name;
+}
+
+
+/*-----------------------------------------------------------------
+ FUNCTION: SoapMethodParamContext
+/-----------------------------------------------------------------*/
+
+HSOAPPARAM SoapMethodParamContext(HSOAPMETHOD method)
+{
+ const char* FUNC = "SoapMethodParamContext";
+ char *name;
+ SoapTraceEnter(FUNC,"");
+
+ if (method == NULL) {
+ SoapLog(LOG_ERROR, FUNC,
+ "Invalid method (null)");
+ return NULL;
+ }
+ SoapTraceLeave(FUNC, "param context = '%p'", method);
+
+ return (xmlNodePtr)method;
+}
+
diff --git a/libcsoap/csoapmethod.h b/libcsoap/csoapmethod.h
new file mode 100644
index 0000000..b839298
--- /dev/null
+++ b/libcsoap/csoapmethod.h
@@ -0,0 +1,56 @@
+/******************************************************************
+ * $Id: csoapmethod.h,v 1.1 2003/11/12 13:22:58 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
+ ******************************************************************/
+#ifndef CSOAP_METHOD_H
+#define CSOAP_METHOD_H
+
+#include "libcsoap/csoapparam.h"
+
+
+typedef HSOAPXML HSOAPMETHOD;
+
+
+/**
+ * Returns the method name
+ *
+ * @param method handle to a soap method object
+ * @return the method name (do not free the string)
+ */
+char* SoapMethodGetName(HSOAPMETHOD method);
+
+
+/**
+ * Returns the param context. Param context is
+ * also a param object. Use the param context
+ * as the parent of the method parameters.
+ *
+ * @param method the method object to get
+ * its param context
+ *
+ * @return The root parameter object if any
+ * exist , NULL otherwise.
+ */
+HSOAPPARAM SoapMethodParamContext(HSOAPMETHOD method);
+
+
+#endif
diff --git a/libcsoap/csoapparam.c b/libcsoap/csoapparam.c
new file mode 100644
index 0000000..27b06e3
--- /dev/null
+++ b/libcsoap/csoapparam.c
@@ -0,0 +1,384 @@
+/******************************************************************
+ * $Id: csoapparam.c,v 1.1 2003/11/12 13:22:58 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
+ ******************************************************************/
+#include "libcsoap/csoapparam.h"
+#include "libcsoap/csoaplog.h"
+#include "libcsoap/csoaptypes.h"
+#include "libcsoap/csoapxml.h"
+
+#include <stdarg.h>
+
+
+/*-----------------------------------------------------------------
+ FUNCTION: SoapParamCreate
+/-----------------------------------------------------------------*/
+
+HSOAPPARAM SoapParamCreate(HSOAPPARAM parent, const char *type,
+ const char *ns, const char *name,
+ const char *format, ...)
+{
+ va_list ap;
+ char buffer[SOAP_MAX_STRING_BUFFER];
+ xmlNodePtr newnode;
+ const char *FUNC = "SoapParamCreate";
+
+ SoapTraceEnter(FUNC,"");
+
+ va_start(ap, format);
+ vsprintf(buffer, format, ap);
+ va_end(ap);
+
+ newnode = xmlNewTextChild(parent, NULL, name, buffer);
+
+ if (newnode == NULL) {
+ SoapTraceLeaveWithError(FUNC,
+ "Can not create new xml node");
+ return NULL;
+ }
+
+ if ( !xmlNewProp(newnode, "xsi:type", type)) {
+ SoapTraceLeaveWithError(FUNC,
+ "Can not create new xml attribute");
+ return NULL;
+ }
+
+ SoapTraceLeave(FUNC, "New xml node (%p)", newnode);
+ return newnode;
+}
+
+
+/*-----------------------------------------------------------------
+ FUNCTION: SoapParamCreateString
+/-----------------------------------------------------------------*/
+
+HSOAPPARAM SoapParamCreateString(HSOAPPARAM parent, const char *name,
+ const char *format, ...)
+{
+ va_list ap;
+ HSOAPPARAM node;
+ char buffer[SOAP_MAX_STRING_BUFFER];
+ const char* FUNC = "SoapParamCreateString";
+ SoapTraceEnter(FUNC,"");
+
+ if (parent == NULL) {
+ SoapTraceLeaveWithError(FUNC,
+ "Invalid parent (null)");
+ return NULL;
+ }
+
+ if (name == NULL) {
+ SoapTraceLeaveWithError(FUNC,
+ "Invalid name (null)");
+ return NULL;
+ }
+
+ if (format == NULL) {
+ SoapTraceLeaveWithError(FUNC,
+ "Invalid format (null)");
+ return NULL;
+ }
+
+ SoapLog(LOG_DEBUG, FUNC,
+ "Creating string parameter\n" \
+ "Name = '%s'" \
+ "Format = %s", name, format);
+
+ va_start(ap, format);
+ vsprintf(buffer, format, ap);
+ va_end(ap);
+
+ node = SoapParamCreate(parent , SOAP_TYPE_STRING,
+ NULL, name, "%s", buffer);
+
+ if (node == NULL) {
+ SoapTraceLeaveWithError(FUNC, "can not create param");
+ return NULL;
+ }
+
+ SoapTraceLeave(FUNC, "New param (%p)", node);
+ return (HSOAPPARAM)node;
+}
+
+
+
+/*-----------------------------------------------------------------
+ FUNCTION: SoapParamCreateInt
+/-----------------------------------------------------------------*/
+
+HSOAPPARAM SoapParamCreateInt(HSOAPPARAM parent, const char *name,
+ int value)
+{
+ HSOAPPARAM node;
+ const char* FUNC = "SoapParamCreateInt";
+ SoapTraceEnter(FUNC,"");
+
+ if (parent == NULL) {
+ SoapTraceLeaveWithError(FUNC,
+ "Invalid parent (null)");
+ return NULL;
+ }
+
+ if (name == NULL) {
+ SoapTraceLeaveWithError(FUNC,
+ "Invalid name (null)");
+ return NULL;
+ }
+
+ node = SoapParamCreate(parent , SOAP_TYPE_INT,
+ NULL, name, "%d", value);
+
+ if (node == NULL) {
+ SoapTraceLeaveWithError(FUNC, "can not create param");
+ return NULL;
+ }
+
+ SoapTraceLeave(FUNC, "New param (%p)", node);
+ return node;
+}
+
+
+/*-----------------------------------------------------------------
+ FUNCTION: SoapParamCreateDouble
+/-----------------------------------------------------------------*/
+
+HSOAPPARAM SoapParamCreateDouble(HSOAPPARAM parent, const char *name,
+ double value)
+{
+ HSOAPPARAM node;
+ const char* FUNC = "SoapParamCreateDouble";
+ SoapTraceEnter(FUNC,"");
+
+ if (parent == NULL) {
+ SoapTraceLeaveWithError(FUNC,
+ "Invalid parent (null)");
+ return NULL;
+ }
+
+ if (name == NULL) {
+ SoapTraceLeaveWithError(FUNC,
+ "Invalid name (null)");
+ return NULL;
+ }
+
+ node = SoapParamCreate(parent, SOAP_TYPE_DOUBLE,
+ NULL, name, "%f", value);
+
+ if (node == NULL) {
+ SoapTraceLeaveWithError(FUNC, "can not create param");
+ return NULL;
+ }
+
+ SoapTraceLeave(FUNC, "New param (%p)", node);
+ return node;
+}
+
+
+/*-----------------------------------------------------------------
+ FUNCTION: SoapParamSetValue
+/-----------------------------------------------------------------*/
+
+void SoapParamSetValue(HSOAPPARAM param, const char* type,
+ const char* format, ...)
+{
+ // Not implemented yet!
+}
+
+
+/*-----------------------------------------------------------------
+ FUNCTION: SoapParamGetString
+/-----------------------------------------------------------------*/
+
+int SoapParamGetString(HSOAPPARAM param, char *dest)
+{
+ char *value;
+ int len;
+ xmlNodePtr xmlNode;
+ const char* FUNC = "SoapParamGetString";
+ SoapTraceEnter(FUNC,"");
+
+ if (param == NULL) {
+ SoapTraceLeaveWithError(FUNC,
+ "Invalid parameter 'param' (null)");
+ return 0;
+ }
+
+ xmlNode = (xmlNodePtr)param;
+ value = (char*)xmlNodeListGetString(xmlNode->doc,
+ xmlNode->xmlChildrenNode,1);
+
+ if (dest)
+ strcpy(dest, value);
+
+ len = strlen(value);
+ xmlFree(value);
+
+ SoapTraceLeave(FUNC, "Value = '%s'\nLength=%d", dest?dest:"null", len);
+ return len;
+}
+
+
+/*-----------------------------------------------------------------
+ FUNCTION: SoapParamGetInt
+/-----------------------------------------------------------------*/
+
+int SoapParamGetInt(HSOAPPARAM param)
+{
+ int value;
+ char buffer[15];
+ const char* FUNC = "SoapParamGetInt";
+ SoapTraceEnter(FUNC,"");
+
+ if (param == NULL) {
+ SoapTraceLeaveWithError(FUNC,
+ "Invalid parameter 'param' (null)");
+ return 0;
+ }
+
+ SoapParamGetString(param, buffer);
+ value = atoi(buffer);
+ SoapTraceLeave(FUNC, "Value = %d", value);
+ return value;
+}
+
+
+/*-----------------------------------------------------------------
+ FUNCTION: SoapParamGetDouble
+/-----------------------------------------------------------------*/
+
+double SoapParamGetDouble(HSOAPPARAM param)
+{
+ double value;
+ char buffer[15];
+ const char* FUNC = "SoapParamGetDouble";
+ SoapTraceEnter(FUNC,"");
+
+ if (param == NULL) {
+ SoapTraceLeaveWithError(FUNC,
+ "Invalid parameter 'param' (null)");
+ return 0.0;
+ }
+
+ SoapParamGetString(param, buffer);
+ value = atof(buffer);
+ SoapTraceLeave(FUNC, "Value = %f", value);
+ return value;
+}
+
+
+/*-----------------------------------------------------------------
+ FUNCTION: SoapParamGetChildren
+/-----------------------------------------------------------------*/
+
+HSOAPPARAM SoapParamGetChildren(HSOAPPARAM param)
+{
+ xmlNodePtr children;
+ const char* FUNC = "SoapParamGetChildren";
+ SoapTraceEnter(FUNC,"");
+
+ if (param == NULL) {
+ SoapTraceLeaveWithError(FUNC,
+ "Invalid parameter 'param' (null)");
+ return NULL;
+ }
+
+ children = ((xmlNodePtr)param)->xmlChildrenNode;
+ while (children != NULL) {
+ if (children->type != XML_ELEMENT_NODE)
+ children = children->next;
+ else break;
+ }
+ SoapTraceLeave(FUNC, "Children node (%p)", children);
+ return (HSOAPPARAM)children;
+}
+
+
+/*-----------------------------------------------------------------
+ FUNCTION: SoapParamGetNext
+/-----------------------------------------------------------------*/
+
+HSOAPPARAM SoapParamGetNext(HSOAPPARAM param)
+{
+ xmlNodePtr children;
+ const char* FUNC = "SoapParamGetNext";
+ xmlNodePtr node = (xmlNodePtr)param;
+ SoapTraceEnter(FUNC,"Enter. node = %s", node?(char*)node->name:"null");
+
+ if (param == NULL) {
+ SoapTraceLeaveWithError(FUNC,
+ "Invalid parameter 'param' (null)");
+ return NULL;
+ }
+
+ children = node->next;
+
+ while (children != NULL) {
+ if (children->type != XML_ELEMENT_NODE)
+ children = children->next;
+ else break;
+ }
+
+ SoapTraceLeave(FUNC, "Children node (%p)", children);
+ return (HSOAPPARAM)children;
+}
+
+
+/*-----------------------------------------------------------------
+ FUNCTION: SoapParamGetType
+/-----------------------------------------------------------------*/
+
+char* SoapParamGetType(HSOAPPARAM param)
+{
+ const char* FUNC = "SoapParamGetType";
+ char *value;
+ xmlNodePtr node = (xmlNodePtr)param;
+ SoapTraceEnter(FUNC,"Enter. node = %s", node?(char*)node->name:"null");
+
+ value = SoapXmlGetAttr(node, NULL, "type");
+
+ SoapTraceLeave(FUNC, "Type = %s", value?value:"(null}");
+ return value;
+}
+
+
+/*-----------------------------------------------------------------
+ FUNCTION: SoapParamTypeIs
+/-----------------------------------------------------------------*/
+
+int SoapParamTypeIs(HSOAPPARAM param, const char* type)
+{
+ const char* FUNC = "SoapParamTypeIs";
+ char *value;
+ SoapTraceEnter(FUNC,"Enter. Type = %s", type?type:"(null)");
+
+ if (type == NULL) {
+ SoapTraceLeaveWithError(FUNC, "type is null");
+ return 0;
+ }
+
+ value = SoapParamGetType(param);
+
+ SoapTraceLeave(FUNC, "Leave");
+ return (!strcmp(value, type));
+}
+
+
diff --git a/libcsoap/csoapparam.h b/libcsoap/csoapparam.h
new file mode 100644
index 0000000..fcc1a4c
--- /dev/null
+++ b/libcsoap/csoapparam.h
@@ -0,0 +1,187 @@
+/******************************************************************
+ * $Id: csoapparam.h,v 1.1 2003/11/12 13:22:58 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@jprogrammet.net
+ ******************************************************************/
+#ifndef CSOAP_PARAM_H
+#define CSOAP_PARAM_H
+
+#include "libcsoap/csoapxml.h"
+
+
+typedef HSOAPXML HSOAPPARAM;
+
+
+#define SOAP_MAX_STRING_BUFFER 1054
+
+
+/**
+ * Creates a string soap parameter
+ *
+ * <LI>Default type: "xsd:string"
+ *
+ * @param parent the parent param object
+ * @param name the parameter name
+ * @param format the parameter value
+ *
+ * @return handle to a parameter object if
+ * the creation was successfull, NULL otherwise
+ */
+HSOAPPARAM SoapParamCreateString( HSOAPPARAM parent, const char *name,
+ const char *format, ...);
+
+
+/**
+ * Creates an integer soap parameter
+ *
+ * <LI>Default type: "xsd:integer"
+ *
+ * @param parent the parent param object
+ * @param name the parameter name
+ * @param value the parameter value
+ *
+ * @return handle to a parameter object if
+ * the creation was successfull, NULL otherwise
+ */
+HSOAPPARAM SoapParamCreateInt( HSOAPPARAM parent, const char *name,
+ int value);
+
+
+/**
+ * Creates a double soap parameter
+ *
+ * <LI>Default type: "xsd:double"
+ *
+ * @param parent the parent param object
+ * @param name the parameter name
+ * @param value the parameter value
+ *
+ * @return handle to a parameter object if
+ * the creation was successfull, NULL otherwise
+ */
+HSOAPPARAM SoapParamCreateDouble( HSOAPPARAM parent, const char *name,
+ double value);
+
+
+/**
+ * Sets the parameter value.
+ *
+ * @param param the parameter object
+ * @param type a custom type name
+ * @param format value of the parameter
+ */
+void SoapParamSetValue(HSOAPPARAM param,const char* type,
+ const char* format, ...);
+
+
+/**
+ * Get the value of a soap parameter
+ * in string format
+ *
+ * @param param the soap parameter object
+ * @param buffer an allocated character buffer
+ * to receive the content. If this is NULL,
+ * this function will return the size only.
+ *
+ * @return size of the content.
+ */
+int SoapParamGetString(HSOAPPARAM param, char *buffer);
+
+
+/**
+ * Get the value of a soap parameter
+ * in integer format
+ *
+ * @param param the soap parameter object
+ * @return the param content as integer
+ */
+int SoapParamGetInt(HSOAPPARAM param);
+
+
+/**
+ * Get the value of a soap parameter
+ * in double format
+ *
+ * @param param the soap parameter object
+ * @return the param content as double
+ */
+double SoapParamGetDouble(HSOAPPARAM param);
+
+
+/**
+ * Get the children parameter nodes.
+ * This acts actually like an xml node.
+ *
+ * @param param the soap parameter object
+ * @return handle to the first child node
+ */
+HSOAPPARAM SoapParamGetChildren(HSOAPPARAM param);
+
+
+/**
+ * Get the next parameter.
+ * This acts actually like an xml node.
+ *
+ * @param param the soap parameter object
+ * @return handle to the next node
+ */
+HSOAPPARAM SoapParamGetNext(HSOAPPARAM param);
+
+
+/**
+ * Checks if the type is equals with
+ * the given one.
+ *
+ * @param param the param to check
+ * @param type the type to check
+ *
+ * @return 0 if the parameter type not equals to 'type'
+ */
+int SoapParamTypeIs(HSOAPPARAM param, const char* type);
+
+
+/**
+ * Returns parameters type.
+ *
+ * @param param the param to return its type
+ *
+ * @return returns parameters type
+ */
+char* SoapParamGetType(HSOAPPARAM param);
+
+
+/**
+ * Creates a new parameter node.
+ * This is used internally.
+ *
+ * @param parent the parent soap parameter object
+ * @param type the parameter type
+ * @param ns the namespace of the parameter
+ * @param name name of the parameter
+ * @param format value of the parameter
+ *
+ * @return A newly created soap parameter object
+ */
+HSOAPPARAM SoapParamCreate(HSOAPPARAM parent, const char *type,
+ const char *ns, const char *name,
+ const char *format, ...);
+
+#endif
diff --git a/libcsoap/csoapres.c b/libcsoap/csoapres.c
new file mode 100644
index 0000000..0531fae
--- /dev/null
+++ b/libcsoap/csoapres.c
@@ -0,0 +1,154 @@
+/******************************************************************
+ * $Id: csoapres.c,v 1.1 2003/11/12 13:22:58 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
+ ******************************************************************/
+#include "libcsoap/csoapres.h"
+#include "libcsoap/csoaplog.h"
+
+
+/*-----------------------------------------------------------------
+ FUNCTION: SoapResCreate
+/-----------------------------------------------------------------*/
+
+HSOAPRES SoapResCreate(HSOAPENV env, const char* methodName)
+{
+ HSOAPRES res = (HSOAPRES)malloc(sizeof(struct SOAPRES));
+ res->m_env = env;
+ res->m_method = (char*)malloc(sizeof(char)*strlen(methodName)+1);
+ strcpy(res->m_method, methodName);
+ return res;
+}
+
+
+/*-----------------------------------------------------------------
+ FUNCTION: SoapResGetFault
+/-----------------------------------------------------------------*/
+
+HSOAPFAULT SoapResGetFault(HSOAPRES res)
+{
+ const char *FUNC = "SoapResGetFault";
+ HSOAPBODY body;
+ HSOAPFAULT fault;
+
+ SoapTraceEnter(FUNC, "Entering");
+
+ if (res == NULL) {
+ SoapTraceLeaveWithError(FUNC, "res is null");
+ return NULL;
+ }
+
+ if (res->m_env == NULL) {
+ SoapTraceLeaveWithError(FUNC, "res->m_env is null");
+ return NULL;
+ }
+
+ if (!(body = SoapEnvGetBody(res->m_env))) {
+ SoapTraceLeaveWithError(FUNC, "can not get body");
+ return NULL;
+ }
+
+ fault = SoapBodyGetFault(body);
+ SoapTraceLeave(FUNC, "Leaving fault (%p)", fault);
+
+ return fault;
+}
+
+/*-----------------------------------------------------------------
+ FUNCTION: SoapResFree
+/-----------------------------------------------------------------*/
+
+void SoapResFree(HSOAPRES res)
+{
+ const char *FUNC = "SoapResFree";
+
+ SoapTraceEnter(FUNC, "Entering");
+
+ if (res == NULL) {
+ SoapTraceLeaveWithError(FUNC, "res is null");
+ return;
+ }
+
+ if (res->m_env == NULL) {
+ SoapTraceLeaveWithError(FUNC, "res->m_env is null");
+ return;
+ }
+
+ SoapEnvFree(res->m_env);
+ free(res);
+
+ SoapTraceLeave(FUNC, "Leaving");
+}
+
+
+/*-----------------------------------------------------------------
+ FUNCTION: SoapResFree
+/-----------------------------------------------------------------*/
+
+HSOAPPARAM SoapResGetParamChildren(HSOAPRES res)
+{
+ const char *FUNC = "SoapResGetParamChildren";
+ HSOAPBODY body;
+ HSOAPMETHOD method;
+ HSOAPPARAM param;
+ char tmp[1054];
+
+ SoapTraceEnter(FUNC, "Entering");
+
+ if (res == NULL) {
+ SoapTraceLeaveWithError(FUNC, "res is null");
+ return NULL;
+ }
+
+ if (res->m_env == NULL) {
+ SoapTraceLeaveWithError(FUNC, "res->m_env is null");
+ return NULL;
+ }
+
+ if (!(body = SoapEnvGetBody(res->m_env))) {
+ SoapTraceLeaveWithError(FUNC, "can not get body");
+ return NULL;
+ }
+
+ sprintf(tmp, "%sResponse", res->m_method);
+ method = SoapBodyGetMethod(body, tmp);
+
+ if (method == NULL) {
+ SoapTraceLeaveWithError(FUNC, "method is null");
+ return NULL;
+ }
+
+ param = SoapMethodParamContext(method);
+
+ if (param == NULL) {
+ SoapTraceLeaveWithError(FUNC, "param is null");
+ return NULL;
+ }
+
+ param = SoapParamGetChildren(method);
+
+ if (param == NULL) {
+ SoapTraceLeaveWithError(FUNC, "child is null");
+ return NULL;
+ }
+
+ return param;
+}
diff --git a/libcsoap/csoapres.h b/libcsoap/csoapres.h
new file mode 100644
index 0000000..3ad38cc
--- /dev/null
+++ b/libcsoap/csoapres.h
@@ -0,0 +1,90 @@
+/******************************************************************
+ * $Id: csoapres.h,v 1.1 2003/11/12 13:22:58 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
+ ******************************************************************/
+#ifndef CSOAP_RES_H
+#define CSOAP_RES_H
+
+#include "libcsoap/csoapxml.h"
+#include "libcsoap/csoapenv.h"
+
+typedef struct SOAPRES* HSOAPRES;
+
+
+/**
+ * The result object. Stores
+ * the response of a soap request.
+ */
+struct SOAPRES
+{
+ HSOAPENV m_env; /* The soap envelope object */
+ char *m_method; /* The called method name */
+};
+
+
+/**
+ * Creates a new soap result object.
+ * This is used actually internally.
+ * To get a soap result see
+ * <B>HSOAPCALL</B>
+ *
+ * @param env the envelope object to use
+ * @param methodName the called method name
+ * @return handle to a soap result object.
+ */
+HSOAPRES SoapResCreate(HSOAPENV env, const char* methodName);
+
+
+/**
+ * Returns a soap fault object
+ * if any exist. This can also be
+ * called to check if any faults
+ * was occured for this result.
+ *
+ * @param res handle to the soap result object
+ * @return handle to a fault object or
+ * NULL if no fault was generated.
+ */
+HSOAPFAULT SoapResGetFault(HSOAPRES res);
+
+
+/**
+ * Returns the first parameter
+ * in the result object if any exist.
+ *
+ * @param res handle to the soap result object
+ * @return handle to a soap param object
+ * NULL if no parameter was received.
+ */
+HSOAPPARAM SoapResGetParamChildren(HSOAPRES res);
+
+
+/**
+ * Free a soap result object.
+ * This must be called after the result
+ * object was used.
+ *
+ * @param res The soap result object to free
+ */
+void SoapResFree(HSOAPRES res);
+
+#endif
diff --git a/libcsoap/csoapsocket.c b/libcsoap/csoapsocket.c
new file mode 100644
index 0000000..519fcab
--- /dev/null
+++ b/libcsoap/csoapsocket.c
@@ -0,0 +1,149 @@
+/******************************************************************
+ * $Id: csoapsocket.c,v 1.1 2003/11/12 13:22:58 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@jprogrammet.net
+ ******************************************************************/
+
+#include "libcsoap/csoapsocket.h"
+#include "libcsoap/csoaperror.h"
+#include "libcsoap/csoaplog.h"
+
+
+
+/*-----------------------------------------------------------------
+ FUNCTION: SoapSocketCreate
+/-----------------------------------------------------------------*/
+
+CSOAP_STATUS SoapSocketCreate(const char* hostname, int port, HSOAPSOCKET* hSock)
+{
+
+ int sock;
+ struct sockaddr_in address;
+ struct hostent* host;
+ int i;
+
+ sock = socket(AF_INET, SOCK_STREAM, 0);
+ if (sock <= 0) return ERROR_SOCKET_CAN_NOT_CREATE_SOCKET;
+
+ /* Get host data */
+ host = gethostbyname(hostname);
+ if (host == NULL) return ERROR_SOCKET_CAN_NOT_GET_HOSTNAME;
+
+ /* set server addresss */
+ address.sin_family = host->h_addrtype;;
+ address.sin_port = htons(port);
+ memcpy((char*)&address.sin_addr.s_addr,
+ host->h_addr_list[0], host->h_length);
+
+ /* connect to the server */
+ if (connect(sock, (struct sockaddr*) &address, sizeof(address)) != 0)
+ return ERROR_SOCKET_CAN_NOT_CONNECT;
+
+ *hSock = sock;
+ return CSOAP_OK;
+}
+
+
+/*-----------------------------------------------------------------
+ FUNCTION: SoapSocketRecv
+/-----------------------------------------------------------------*/
+
+CSOAP_STATUS SoapSocketRecv(HSOAPSOCKET sock, char** buffer, ssize_t* totalSize)
+{
+ const char *FUNC = "SoapSocketRecv";
+ ssize_t size;
+ int chunk=1;
+ char tmp[SOCKET_MAX_BUFSIZE+1];
+
+ SoapTraceEnter( FUNC, "Entering");
+ *totalSize = 0;
+ *buffer = 0;
+
+ do {
+ SoapLog(LOG_DEBUG, FUNC, "Receiving buffer\n");
+ size = recv(sock, tmp, SOCKET_MAX_BUFSIZE, 0);
+ SoapLog(LOG_DEBUG, FUNC, "received = %s\n", tmp);
+ if (size == -1) {
+ printf("Error reading from socket\n");
+ return ERROR_SOCKET_CAN_NOT_RECEIVE;
+ }
+ *totalSize += size;
+ if (*buffer) {
+ SoapLog(LOG_DEBUG, FUNC, "realloc\n");
+ *buffer = (char*)realloc(*buffer, SOCKET_MAX_BUFSIZE*chunk+1);
+ strcat(*buffer, tmp);
+ SoapLog(LOG_DEBUG, FUNC,"realloc ok\n");
+ } else {
+ SoapLog(LOG_DEBUG, FUNC, "alloc\n");
+ *buffer = (char*)realloc(NULL, SOCKET_MAX_BUFSIZE+1);
+ strcpy(*buffer, tmp);
+ SoapLog(LOG_DEBUG, FUNC,"alloc ok\n");
+ }
+
+ SoapLog(LOG_DEBUG, FUNC, "totalSize = %d\n", *totalSize);
+ (*buffer)[*totalSize] = '\0';
+ chunk++;
+ } while (size > 0);
+
+ SoapTraceLeave(FUNC, "totalsize: %d", *totalSize);
+ return CSOAP_OK;
+}
+
+
+/*-----------------------------------------------------------------
+ FUNCTION: SoapSocketSend
+/-----------------------------------------------------------------*/
+
+CSOAP_STATUS SoapSocketSend(HSOAPSOCKET sock, const char* req, ssize_t* sentSize)
+{
+ const char *FUNC = "SoapSocketSend";
+ ssize_t size;
+
+ SoapTraceEnter(FUNC, "");
+
+ size = send(sock, req, strlen(req), 0);
+ if (size == -1)
+ return ERROR_SOCKET_CAN_NOT_SEND;
+
+ *sentSize = size;
+ SoapTraceLeave(FUNC, "");
+ return CSOAP_OK;
+}
+
+
+/*-----------------------------------------------------------------
+ FUNCTION: SoapSocketInitialize
+/-----------------------------------------------------------------*/
+
+CSOAP_STATUS SoapSocketInitialize()
+{
+ const char *FUNC = "SoapSocketInitialize";
+ SoapTraceEnter(FUNC, "");
+
+#ifdef WIN32
+ /* Initialize WinSocket for the Windows version */
+#endif
+
+ SoapTraceLeave(FUNC, "");
+ return CSOAP_OK;
+}
+
+
diff --git a/libcsoap/csoapsocket.h b/libcsoap/csoapsocket.h
new file mode 100644
index 0000000..76f8227
--- /dev/null
+++ b/libcsoap/csoapsocket.h
@@ -0,0 +1,109 @@
+/******************************************************************
+ * $Id: csoapsocket.h,v 1.1 2003/11/12 13:22:58 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
+ ******************************************************************/
+#ifndef CSOAP_SOCKET_H
+#define CSOAP_SOCKET_H
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#ifdef HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+
+#ifdef HAVE_SYS_SOCKET_H
+# include <sys/socket.h>
+#endif
+
+#ifdef HAVE_ARPA_INET_H
+# include <arpa/inet.h>
+#endif
+
+#ifdef HAVE_NETDB_H
+# include <netdb.h>
+#endif
+
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+
+#include <stdio.h>
+#include "libcsoap/csoaperror.h"
+
+typedef int HSOAPSOCKET;
+
+#define SOCKET_MAX_BUFSIZE 1054
+
+
+/**
+ * Initializes the soap socket module.
+ * This is called internally. Before any
+ * socket operation.
+ *
+ * @return CSOAP_OK if it was successfull
+ */
+int SoapSocketInitialize();
+
+
+/**
+ * Creates a new soap compatible socket object.
+ *
+ * @param host the host to connect
+ * @param port the port to connect
+ * @param socket the destination pointer
+ * to receive a connected socket object
+ *
+ * @return CSOAP_OK if it was successfull.
+ */
+CSOAP_STATUS SoapSocketCreate(const char* host, int port, HSOAPSOCKET* socket);
+
+/**
+ * Sends data to the connected socket.
+ *
+ * @param sock A connected socket object
+ * @param req data to send
+ * @param sentSize the size of sent data
+ *
+ * @return CSOAP_OK if it was successfull
+ */
+CSOAP_STATUS SoapSocketSend(HSOAPSOCKET sock, const char* req,ssize_t* sentSize);
+
+
+/**
+ * Receives data from the connected socket.
+ *
+ * @param sock A connected socket object
+ * @param res destination pointer to receive
+ * the data. This will be allocated in this
+ * function. So you have to free it.
+ * @param receivedSize the size of received data
+ *
+ * @return CSOAP_OK if it was successfull
+ */
+CSOAP_STATUS SoapSocketRecv(HSOAPSOCKET sock, char** res,ssize_t* receivedSize);
+
+
+#endif
+
+
diff --git a/libcsoap/csoaptypes.h b/libcsoap/csoaptypes.h
new file mode 100644
index 0000000..042ffa8
--- /dev/null
+++ b/libcsoap/csoaptypes.h
@@ -0,0 +1,33 @@
+/******************************************************************
+ * $Id: csoaptypes.h,v 1.1 2003/11/12 13:22:58 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
+ ******************************************************************/
+#ifndef CSOAP_TYPES_H
+#define CSOAP_TYPES_H
+
+
+#define SOAP_TYPE_STRING "xsd:string"
+#define SOAP_TYPE_INT "xsd:int"
+#define SOAP_TYPE_DOUBLE "xsd:double"
+
+
+#endif
diff --git a/libcsoap/csoapurl.c b/libcsoap/csoapurl.c
new file mode 100644
index 0000000..96928e5
--- /dev/null
+++ b/libcsoap/csoapurl.c
@@ -0,0 +1,185 @@
+/******************************************************************
+ * $Id: csoapurl.c,v 1.1 2003/11/12 13:22:58 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
+ ******************************************************************/
+#include "libcsoap/csoapurl.h"
+#include "libcsoap/csoaplog.h"
+
+#include <stdio.h>
+#include <string.h>
+
+
+static
+HSOAPURL CreateUrlFromIndex(const char* urlstr, int iprotocol, int ihost, int iport)
+{
+ const char *FUNC = "CreateUrlFromIndex";
+ int len, size;
+ char tmp[8];
+ HSOAPURL url;
+
+ SoapTraceEnter(FUNC, "Entering");
+
+ url = (HSOAPURL)malloc(sizeof(struct SOAPURL));
+
+ url->m_protocol = (char*)malloc(sizeof(char)*iprotocol+1);
+ strncpy(url->m_protocol, urlstr, iprotocol);
+
+ size = ihost - iprotocol - 3;
+ url->m_host = (char*)malloc(sizeof(char)*size);
+ strncpy(url->m_host, &urlstr[iprotocol+3], size);
+
+ if (iport > ihost)
+ {
+ size = iport - ihost;
+ strncpy(tmp, &urlstr[ihost+1], size);
+ url->m_port = atoi(tmp);
+ } else {
+ url->m_port = 80;
+ }
+
+ len = strlen(urlstr);
+ if (len > iport )
+ {
+ size = len - iport;
+ url->m_context = (char*)malloc(sizeof(char)*size);
+ strncpy(url->m_context, &urlstr[iport], size);
+ } else {
+ url->m_context = NULL;
+ }
+
+ SoapTraceEnter(FUNC, "Leaving url = %p", url);
+ return url;
+};
+
+
+/*-----------------------------------------------------------------
+ FUNCTION: SoapUrlCreate
+/-----------------------------------------------------------------*/
+
+HSOAPURL SoapUrlCreate(const char* urlstr)
+{
+ const char *FUNC = "SoapUrlCreate";
+ int iprotocol;
+ int ihost;
+ int iport;
+ int len;
+ HSOAPURL url = NULL;
+
+ SoapTraceEnter(FUNC, "Entering. URL = %s", urlstr?urlstr:"null");
+
+ iprotocol = 0;
+ len = strlen(urlstr);
+ printf("len = %d\n", len);
+ /* find protocol */
+ while (urlstr[iprotocol] != ':' && urlstr[iprotocol] != '\0')
+ {
+/* printf("protocol: urlstr[%d] = %c\n",iprotocol, urlstr[iprotocol] );*/
+ iprotocol++;
+ }
+
+ if (iprotocol == 0) {
+ SoapTraceLeaveWithError(FUNC, "no protocol");
+ return NULL;
+ }
+
+ if (iprotocol + 3 >= len) {
+ SoapTraceLeaveWithError(FUNC, "no host");
+ return NULL;
+ }
+
+ if ( urlstr[iprotocol] != ':'
+ && urlstr[iprotocol+1] != '/'
+ && urlstr[iprotocol+2] != '/')
+ {
+ SoapTraceLeaveWithError(FUNC, "no protocol");
+ return NULL;
+ }
+
+ /* find host */
+ ihost = iprotocol + 3;
+ while (urlstr[ihost] != ':'
+ && urlstr[ihost] != '/'
+ && urlstr[ihost] != '\0')
+ {
+/* printf("host: urlstr[%d] = %c\n",ihost, urlstr[ihost] );*/
+ ihost++;
+ }
+
+ if (ihost == iprotocol + 1) {
+ SoapTraceLeaveWithError(FUNC, "no host");
+ return NULL;
+ }
+
+ /* find port */
+ iport = ihost;
+ if (ihost + 1 < len) {
+ if (urlstr[ihost] == ':') {
+ while (urlstr[iport] != '/' && urlstr[iport] != '\0') {
+/* printf("port: urlstr[%d] = %c\n", iport, urlstr[iport] );*/
+ iport++;
+ }
+ }
+ }
+
+/*
+ printf("iprotocol = %d\nihost = %d\niport = %d\nlen = %d\n",
+ iprotocol, ihost, iport, len);
+*/
+ url = CreateUrlFromIndex(urlstr, iprotocol, ihost, iport);
+ SoapTraceLeave(FUNC, "Leaving url (%p)", url);
+ return url;
+}
+
+
+/*-----------------------------------------------------------------
+ FUNCTION: SoapUrlFree
+/-----------------------------------------------------------------*/
+
+void SoapUrlFree(HSOAPURL url)
+{
+ if (url != NULL) {
+ if (url->m_protocol) free(url->m_protocol);
+ if (url->m_host) free(url->m_host);
+ if (url->m_context) free(url->m_context);
+
+ free(url);
+ }
+}
+
+
+/*-----------------------------------------------------------------
+ FUNCTION: SoapUrlDump
+/-----------------------------------------------------------------*/
+
+void SoapUrlDump(HSOAPURL url)
+{
+ if (url == NULL) {
+ printf("(null)\n");
+ return ;
+ }
+
+ printf("PROTOCOL : %s\n", url->m_protocol?url->m_protocol:"(null)");
+ printf(" HOST : %s\n", url->m_host?url->m_host:"(null)");
+ printf(" PORT : %d\n", url->m_port);
+ printf(" CONTEXT : %s\n", url->m_context?url->m_context:"(null)");
+
+}
diff --git a/libcsoap/csoapurl.h b/libcsoap/csoapurl.h
new file mode 100644
index 0000000..191b344
--- /dev/null
+++ b/libcsoap/csoapurl.h
@@ -0,0 +1,70 @@
+/******************************************************************
+ * $Id: csoapurl.h,v 1.1 2003/11/12 13:22:58 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@jprogrammet.net
+ ******************************************************************/
+#ifndef CSOAP_URL_H
+#define CSOAP_URL_H
+
+
+/* Include csoap headers */
+
+
+typedef struct SOAPURL* HSOAPURL;
+
+
+struct SOAPURL
+{
+ char *m_protocol;
+ char *m_host;
+ int m_port;
+ char *m_context;
+};
+
+
+/**
+ * Creates a new url object
+ *
+ * @param url the url string
+ *
+ * @return A soap url object if it was
+ * successfull, NULL otherwise.
+ */
+HSOAPURL SoapUrlCreate(const char* url);
+
+
+/**
+ * Free a url object
+ *
+ * @param url the url to free
+ */
+void SoapUrlFree(HSOAPURL url);
+
+
+/**
+ * Dump the url data (for debugging)
+ *
+ * @param url the url to show its content
+ */
+void SoapUrlDump(HSOAPURL url);
+
+
+#endif
diff --git a/libcsoap/csoapxml.c b/libcsoap/csoapxml.c
new file mode 100644
index 0000000..fa51fdd
--- /dev/null
+++ b/libcsoap/csoapxml.c
@@ -0,0 +1,151 @@
+/******************************************************************
+ * $Id: csoapxml.c,v 1.1 2003/11/12 13:22:58 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
+ ******************************************************************/
+#include "libcsoap/csoapxml.h"
+
+#include "libcsoap/csoaplog.h"
+
+
+/*-----------------------------------------------------------------
+ FUNCTION: SoapXmlFindNode
+/-----------------------------------------------------------------*/
+
+HSOAPXML
+SoapXmlFindNode(HSOAPXML root, const char* nodeName)
+{
+ xmlNodePtr cur;
+ const char* FUNC = "SoapXmlFindNode";
+
+ SoapTraceEnter(FUNC,"root (%p) node (%p)",
+ root, nodeName?nodeName:"null");
+
+ if (root == NULL) {
+ SoapLog(LOG_ERROR, FUNC,
+ "Invalid root node (null)");
+ return NULL;
+ }
+
+ if (nodeName == NULL) {
+ SoapLog(LOG_ERROR, FUNC,
+ "Invalid node name (null)");
+ return NULL;
+ }
+
+ cur = ((xmlNodePtr)root)->xmlChildrenNode;
+ while (cur != NULL) {
+ if (!xmlStrcmp(cur->name, (const xmlChar*)nodeName)) {
+ SoapTraceLeave(FUNC, "Found '%s' (%p)", nodeName, cur);
+ return cur;
+ }
+ cur = cur->next;
+ }
+
+ SoapTraceLeave(FUNC, "No '%s' found!", nodeName);
+ return NULL;
+}
+
+
+/*-----------------------------------------------------------------
+ FUNCTION: SoapXmlGetNodeValue
+/-----------------------------------------------------------------*/
+
+int
+SoapXmlGetNodeValue(HSOAPXML xmlNode, char* dest)
+{
+ char *value;
+ int len;
+ const char* FUNC = "SoapXmlGetNodeValue";
+ SoapTraceEnter(FUNC,"Entering");
+
+
+ if (xmlNode == NULL) {
+ SoapTraceLeaveWithError(FUNC,
+ "Invalid parameter 'xmlNode' (null)");
+ return 0;
+ }
+
+ value = (char*)xmlNodeListGetString(((xmlNodePtr)xmlNode)->doc,
+ ((xmlNodePtr)xmlNode)->xmlChildrenNode,1);
+ strcpy(dest, value);
+ len = strlen(value);
+ xmlFree(value);
+
+ SoapTraceLeave(FUNC, "Value = '%s'\nLength=%d", dest, len);
+ return len;
+
+}
+
+
+/*-----------------------------------------------------------------
+ FUNCTION: SoapXmlGetNodeValueAlloc
+/-----------------------------------------------------------------*/
+
+char*
+SoapXmlGetNodeValueAlloc(HSOAPXML xmlNode)
+{
+ char *value;
+ int len;
+ const char* FUNC = "SoapXmlGetNodeValueAlloc";
+ SoapTraceEnter(FUNC,"Entering");
+
+
+ if (xmlNode == NULL) {
+ SoapTraceLeaveWithError(FUNC,
+ "Invalid parameter 'xmlNode' (null)");
+ return 0;
+ }
+
+ value = (char*)xmlNodeListGetString(((xmlNodePtr)xmlNode)->doc,
+ ((xmlNodePtr)xmlNode)->xmlChildrenNode,1);
+ SoapTraceLeave(FUNC, "Value = '%s'\n", value);
+ return value;
+}
+
+
+/*-----------------------------------------------------------------
+ FUNCTION: SoapXmlGetAttr
+/-----------------------------------------------------------------*/
+
+char* SoapXmlGetAttr(HSOAPXML node, const char* ns, const char* key)
+{
+ char *value;
+ int len;
+ const char* FUNC = "SoapXmlGetAttr";
+ SoapTraceEnter(FUNC,"Entering");
+
+
+ if (node == NULL) {
+ SoapTraceLeaveWithError(FUNC,
+ "Invalid parameter 'node' (null)");
+ return NULL;
+ }
+
+ if (ns == NULL) {
+ value = (char*)xmlGetProp(node, key);
+ } else {
+ value = (char*)xmlGetNsProp(node, key, ns);
+ }
+
+ SoapTraceLeave(FUNC, "Value = '%s'\n", value?value:"(null)");
+ return value;
+}
diff --git a/libcsoap/csoapxml.h b/libcsoap/csoapxml.h
new file mode 100644
index 0000000..7e76df7
--- /dev/null
+++ b/libcsoap/csoapxml.h
@@ -0,0 +1,90 @@
+/******************************************************************
+ * $Id: csoapxml.h,v 1.1 2003/11/12 13:22:58 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
+ ******************************************************************/
+#ifndef CSOAP_XML_H
+#define CSOAP_XML_H
+
+
+#include <libxml/xmlmemory.h>
+#include <libxml/parser.h>
+
+#include "libcsoap/csoaperror.h"
+
+
+typedef xmlNodePtr HSOAPXML;
+
+
+/**
+ * Search for an xml node which
+ * has the name nodeName
+ *
+ * @param root the root xml node to search
+ * the nodeName in its children nodes
+ * @param nodeName the nodeName to find
+ *
+ * @return an xml node if any exist,
+ * NULL otherwise
+ */
+HSOAPXML SoapXmlFindNode(HSOAPXML root, const char* nodeName);
+
+
+/**
+ * Receives the node value
+ *
+ * @param node the xml node to receive
+ * its text node
+ * @param dest the destination string
+ *
+ * @return length of content copied into dest
+ */
+int SoapXmlGetNodeValue(HSOAPXML node, char* dest);
+
+
+/**
+ * Receives the node value.
+ *
+ * @param node the xml node to receive
+ * its text node
+ *
+ * @return An allocated string. You must free
+ * it using <B>SoapFreeStr</B>
+ * @see SoapFreeStr
+ */
+char* SoapXmlGetNodeValueAlloc(HSOAPXML node);
+
+
+/**
+ * Returns the xml attribute
+ *
+ * @param node the xml node to receive its attribute
+ * @param ns namespace of the attribute
+ * @param key key of the attribute
+ *
+ * @return value of the attribute if any found,
+ * NULL otherwise. It's up to the caller to free
+ * the memory with SoapFreeStr().
+ */
+char* SoapXmlGetAttr(HSOAPXML node, const char* ns, const char* key);
+
+#endif
+