summaryrefslogtreecommitdiffstats
path: root/libcsoap
diff options
context:
space:
mode:
authorGravatar m0gg2006-03-06 13:37:38 +0000
committerGravatar m0gg2006-03-06 13:37:38 +0000
commit52767927889b305fe18b28ddfc5351f08b703d2d (patch)
tree6dbfd60ef92ec9781553ee8cc9c50a5359088b5f /libcsoap
parent45e68a4a2394cf415b157b08a15a5cf8ac0df8f8 (diff)
downloadcsoap-52767927889b305fe18b28ddfc5351f08b703d2d.tar.gz
csoap-52767927889b305fe18b28ddfc5351f08b703d2d.tar.bz2
Various changes see ChangeLog
Diffstat (limited to 'libcsoap')
-rw-r--r--libcsoap/soap-client.c36
-rw-r--r--libcsoap/soap-client.h10
-rwxr-xr-xlibcsoap/soap-ctx.h9
-rw-r--r--libcsoap/soap-env.c232
-rw-r--r--libcsoap/soap-env.h25
-rw-r--r--libcsoap/soap-fault.c10
-rw-r--r--libcsoap/soap-fault.h8
-rw-r--r--libcsoap/soap-router.h10
-rw-r--r--libcsoap/soap-server.c80
-rw-r--r--libcsoap/soap-server.h8
-rw-r--r--libcsoap/soap-service.h16
-rw-r--r--libcsoap/soap-xml.h14
12 files changed, 251 insertions, 207 deletions
diff --git a/libcsoap/soap-client.c b/libcsoap/soap-client.c
index 80f8b3a..5d42ec6 100644
--- a/libcsoap/soap-client.c
+++ b/libcsoap/soap-client.c
@@ -1,5 +1,5 @@
/******************************************************************
-* $Id: soap-client.c,v 1.24 2006/02/25 10:09:28 snowdrop Exp $
+* $Id: soap-client.c,v 1.25 2006/03/06 13:37:38 m0gg Exp $
*
* CSOAP Project: A SOAP client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -37,7 +37,7 @@
#include "soap-client.h"
-static int _block_socket = 0;
+// static int _block_socket = 0;
static herror_t
_soap_client_build_result(hresponse_t * res, SoapEnv ** env)
@@ -55,25 +55,25 @@ _soap_client_build_result(hresponse_t * res, SoapEnv ** env)
if (res->errcode != 200)
return herror_new("_soap_client_build_result",
- GENERAL_INVALID_PARAM, "HTTP code is not 200 OK");
+ GENERAL_INVALID_PARAM, "HTTP code is not OK (%i)", res->errcode);
return soap_env_new_from_stream(res->in, env);
}
-void
-soap_client_block_socket(int block)
-{
- _block_socket = block;
-
- return;
-}
-
-int
-soap_client_get_blockmode(void)
-{
-
- return _block_socket;
-}
+// void
+// soap_client_block_socket(int block)
+// {
+// _block_socket = block;
+//
+// return;
+// }
+//
+// int
+// soap_client_get_blockmode(void)
+// {
+//
+// return _block_socket;
+// }
herror_t
soap_client_init_args(int argc, char *argv[])
@@ -128,7 +128,7 @@ soap_client_invoke(SoapCtx * call, SoapCtx ** response, const char *url,
return herror_new("soap_client_invoke", SOAP_ERROR_CLIENT_INIT,
"Unable to create SOAP client!");
}
- conn->sock.block = soap_client_get_blockmode();
+// conn->sock.block = soap_client_get_blockmode();
/* Set soap action */
if (soap_action != NULL)
diff --git a/libcsoap/soap-client.h b/libcsoap/soap-client.h
index 43d1359..d8bf6ee 100644
--- a/libcsoap/soap-client.h
+++ b/libcsoap/soap-client.h
@@ -1,5 +1,5 @@
/******************************************************************
- * $Id: soap-client.h,v 1.12 2006/01/10 11:29:04 snowdrop Exp $
+ * $Id: soap-client.h,v 1.13 2006/03/06 13:37:38 m0gg Exp $
*
* CSOAP Project: A SOAP client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -29,6 +29,10 @@
#define SOAP_ERROR_CLIENT_INIT 5001
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/**
Initializes the client side soap engine
*/
@@ -69,4 +73,8 @@ herror_t soap_client_invoke(SoapCtx * ctx, SoapCtx ** response,
void soap_client_block_socket(int block);
int soap_client_get_blockmode();
+#ifdef __cplusplus
+}
+#endif
+
#endif
diff --git a/libcsoap/soap-ctx.h b/libcsoap/soap-ctx.h
index a4784f5..d418037 100755
--- a/libcsoap/soap-ctx.h
+++ b/libcsoap/soap-ctx.h
@@ -1,5 +1,5 @@
/******************************************************************
- * $Id: soap-ctx.h,v 1.8 2006/02/18 20:14:36 snowdrop Exp $
+ * $Id: soap-ctx.h,v 1.9 2006/03/06 13:37:38 m0gg Exp $
*
* CSOAP Project: A SOAP client/server library in C
* Copyright (C) 2003-2004 Ferhat Ayaz
@@ -42,6 +42,9 @@ typedef struct _SoapCtx
attachments_t *attachments;
} SoapCtx;
+#ifdef __cplusplus
+extern "C" {
+#endif
SoapCtx *soap_ctx_new(SoapEnv * env); /* should only be used internally */
@@ -71,4 +74,8 @@ given one to the added part.
void soap_ctx_add_files(SoapCtx * ctx, attachments_t * attachments);
void soap_ctx_free(SoapCtx * ctx);
+#ifdef __cplusplus
+}
+#endif
+
#endif
diff --git a/libcsoap/soap-env.c b/libcsoap/soap-env.c
index 8f4df35..590e5f1 100644
--- a/libcsoap/soap-env.c
+++ b/libcsoap/soap-env.c
@@ -1,5 +1,5 @@
/******************************************************************
-* $Id: soap-env.c,v 1.17 2006/02/27 22:26:02 snowdrop Exp $
+* $Id: soap-env.c,v 1.18 2006/03/06 13:37:38 m0gg Exp $
*
* CSOAP Project: A SOAP client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -41,6 +41,7 @@
#include <errno.h>
#endif
+#include "soap-xml.h"
#include "soap-env.h"
#ifdef WIN32
@@ -51,11 +52,6 @@
#include <libxml/xmlstring.h>
#endif
-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
@@ -70,6 +66,7 @@ Parameters:
"<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"%s\" SOAP-ENV:encodingStyle=\"%s\"" \
" xmlns:xsi=\"%s\"" \
" xmlns:xsd=\"%s\">" \
+ " <SOAP-ENV:Header />" \
" <SOAP-ENV:Body>"\
" <m:%s xmlns:m=\"%s\">"\
" </m:%s>" \
@@ -91,6 +88,7 @@ Parameters:
"<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"%s\" SOAP-ENV:encodingStyle=\"%s\"" \
" xmlns:xsi=\"%s\"" \
" xmlns:xsd=\"%s\">" \
+ " <SOAP-ENV:Header />" \
" <SOAP-ENV:Body>"\
" <%s xmlns=\"%s\">"\
" </%s>" \
@@ -106,21 +104,57 @@ struct XmlNodeHolder
xmlNodePtr node;
};
-static
- void xmlbuilder_start_element(const xmlChar * element_name, int attr_count,
- xmlChar ** keys, xmlChar ** values,
- void *userData);
+static void
+xmlbuilder_start_element(const xmlChar * element_name, int attr_count, xmlChar ** keys, xmlChar ** values, void *userData)
+{
+ struct XmlNodeHolder *holder = (struct XmlNodeHolder *) userData;
+ xmlNodePtr parent = NULL;
-static
- void xmlbuilder_characters(const xmlChar * element_name,
- const xmlChar * chars, void *userData);
+ if (holder == NULL)
+ return;
+ parent = holder->node;
+ if (parent == NULL)
+ return;
-static
- void xmlbuilder_end_element(const xmlChar * element_name, void *userData);
+ holder->node = xmlNewChild(parent, NULL, element_name, NULL);
-/* ---------------------------------------------------------------------------- */
+ return;
+}
+static void
+xmlbuilder_characters(const xmlChar * element_name, const xmlChar * chars, void *userData)
+{
+ struct XmlNodeHolder *holder = (struct XmlNodeHolder *) userData;
+ xmlNodePtr parent = NULL;
+ if (holder == NULL)
+ return;
+ parent = holder->node;
+ if (parent == NULL)
+ return;
+
+ xmlNewTextChild(parent, NULL, element_name, chars);
+
+ return;
+}
+
+static void
+xmlbuilder_end_element(const xmlChar * element_name, void *userData)
+{
+
+ struct XmlNodeHolder *holder = (struct XmlNodeHolder *) userData;
+ xmlNodePtr parent = NULL;
+
+ if (holder == NULL)
+ return;
+ parent = holder->node;
+ if (parent == NULL)
+ return;
+
+ holder->node = parent->parent;
+
+ return;
+}
herror_t
soap_env_new_from_doc(xmlDocPtr doc, SoapEnv ** out)
@@ -136,10 +170,9 @@ soap_env_new_from_doc(xmlDocPtr doc, SoapEnv ** out)
"XML Document (xmlDocPtr) is NULL");
}
- node = xmlDocGetRootElement(doc);
- if (node == NULL)
+ if (!(node = xmlDocGetRootElement(doc)))
{
- log_error1("xml document is empty!");
+ log_error1("XML document is empty!");
return herror_new("soap_env_new_from_doc",
XML_ERROR_EMPTY_DOCUMENT, "XML Document is empty!");
}
@@ -150,21 +183,16 @@ soap_env_new_from_doc(xmlDocPtr doc, SoapEnv ** out)
return herror_new("soap_env_from_doc", GENERAL_INVALID_PARAM, "malloc failed");
}
- /* set root */
env->root = node;
-
- /* set method root set call->cur (current node) to <method>. xpath:
- //Envelope/Body/ */
- node = soap_xml_get_children(env->root); /* Check for NULL ! */
- env->cur = soap_xml_get_children(node); /* Check for NULL ! */
+ env->header = soap_env_get_header(env);
+ env->cur = env->body = soap_env_get_body(env);
*out = env;
+
return H_OK;
}
-
-
herror_t
soap_env_new_from_buffer(const char *buffer, SoapEnv ** out)
{
@@ -175,17 +203,14 @@ soap_env_new_from_buffer(const char *buffer, SoapEnv ** out)
return herror_new("soap_env_new_from_buffer",
GENERAL_INVALID_PARAM, "buffer (first param) is NULL");
- doc = xmlParseDoc(BAD_CAST buffer);
- if (doc == NULL)
+ if (!(doc = xmlParseDoc(BAD_CAST buffer)))
return herror_new("soap_env_new_from_buffer",
XML_ERROR_PARSE, "Can not parse xml");
- err = soap_env_new_from_doc(doc, out);
- if (err != H_OK)
+ if ((err = soap_env_new_from_doc(doc, out)) != H_OK)
{
xmlFreeDoc(doc);
}
-
return err;
}
@@ -204,8 +229,7 @@ soap_env_new_with_fault(fault_code_t faultcode,
return herror_new("soap_env_new_with_fault",
XML_ERROR_PARSE, "Can not parse fault xml");
- err = soap_env_new_from_doc(doc, out);
- if (err != H_OK)
+ if ((err = soap_env_new_from_doc(doc, out)) != H_OK)
{
xmlFreeDoc(doc);
}
@@ -250,7 +274,9 @@ soap_env_new_with_response(SoapEnv * request, SoapEnv ** out)
urn = "";
}
- res_method = malloc(strlen(method)+9);
+ if (!(res_method = (char *)malloc(strlen(method)+9)))
+ return herror_new("soap_env_new_with_response", GENERAL_INVALID_PARAM, "malloc failed");
+
sprintf(res_method, "%sResponse", method);
ret = soap_env_new_with_method(urn, res_method, out);
@@ -267,7 +293,6 @@ soap_env_new_with_method(const char *urn, const char *method, SoapEnv ** out)
xmlDocPtr env;
xmlChar buffer[1054];
-
log_verbose2("URN = '%s'", urn);
log_verbose2("Method = '%s'", method);
@@ -297,21 +322,19 @@ soap_env_new_with_method(const char *urn, const char *method, SoapEnv ** out)
}
- env = xmlParseDoc(buffer);
- if (!env)
+ if (!(env = xmlParseDoc(buffer)))
return herror_new("soap_env_new_with_method",
XML_ERROR_PARSE, "Can not parse xml");
return soap_env_new_from_doc(env, out);
-
}
-
static int
_soap_env_xml_io_read(void *ctx, char *buffer, int len)
{
int readed;
+
http_input_stream_t *in = (http_input_stream_t *) ctx;
if (!http_input_stream_is_ready(in))
return 0;
@@ -334,26 +357,24 @@ herror_t
soap_env_new_from_stream(http_input_stream_t * in, SoapEnv ** out)
{
xmlDocPtr doc;
- herror_t err;
doc = xmlReadIO(_soap_env_xml_io_read,
_soap_env_xml_io_close, in, "", NULL, 0);
if (in->err != H_OK)
return in->err;
+
if (doc == NULL)
return herror_new("soap_env_new_from_stream",
XML_ERROR_PARSE, "Trying to parse not valid xml");
- err = soap_env_new_from_doc(doc, out);
- return err;
+
+ return soap_env_new_from_doc(doc, out);
}
xmlNodePtr
-soap_env_add_item(SoapEnv * call, const char *type,
- const char *name, const char *value)
+soap_env_add_item(SoapEnv * call, const char *type, const char *name, const char *value)
{
-
xmlNodePtr newnode;
newnode = xmlNewTextChild(call->cur, NULL, BAD_CAST name, BAD_CAST value);
@@ -377,7 +398,6 @@ soap_env_add_item(SoapEnv * call, const char *type,
}
-
xmlNodePtr
soap_env_add_itemf(SoapEnv * call, const char *type,
const char *name, const char *format, ...)
@@ -395,7 +415,6 @@ soap_env_add_itemf(SoapEnv * call, const char *type,
}
-
xmlNodePtr
soap_env_add_attachment(SoapEnv * call, const char *name, const char *href)
{
@@ -421,9 +440,9 @@ soap_env_add_attachment(SoapEnv * call, const char *name, const char *href)
return newnode;
}
+
void
-soap_env_add_custom(SoapEnv * call, void *obj, XmlSerializerCallback cb,
- const char *type, const char *name)
+soap_env_add_custom(SoapEnv * call, void *obj, XmlSerializerCallback cb, const char *type, const char *name)
{
struct XmlNodeHolder holder;
@@ -433,6 +452,7 @@ soap_env_add_custom(SoapEnv * call, void *obj, XmlSerializerCallback cb,
xmlbuilder_start_element,
xmlbuilder_characters, xmlbuilder_end_element, &holder);
+ return;
}
@@ -442,12 +462,8 @@ soap_env_push_item(SoapEnv * call, const char *type, const char *name)
xmlNodePtr node;
- node = soap_env_add_item(call, type, name, "");
-
- if (node)
- {
+ if ((node = soap_env_add_item(call, type, name, "")))
call->cur = node;
- }
return node;
}
@@ -457,8 +473,11 @@ void
soap_env_pop_item(SoapEnv * call)
{
call->cur = call->cur->parent;
+
+ return;
}
+
void
soap_env_free(SoapEnv * env)
{
@@ -470,6 +489,8 @@ soap_env_free(SoapEnv * env)
}
free(env);
}
+
+ return;
}
@@ -490,16 +511,42 @@ soap_env_get_body(SoapEnv * env)
return NULL;
}
- node = soap_xml_get_children(env->root);
+ for (node = soap_xml_get_children(env->root); node; node = soap_xml_get_next(node))
+ {
+ if (!xmlStrcmp(node->name, BAD_CAST "Body")
+ && !xmlStrcmp(node->ns->href, BAD_CAST soap_env_ns))
+ return node;
+ }
- while (node != NULL)
+ log_error1("Body tag not found!");
+ return NULL;
+}
+
+
+xmlNodePtr
+soap_env_get_header(SoapEnv *env)
+{
+ xmlNodePtr node;
+
+ if (!env)
+ {
+ log_error1("SoapEnv is NULL");
+ return NULL;
+ }
+
+ if (!env->root)
+ {
+ log_error1("SoapEnv contains no document");
+ return NULL;
+ }
+
+ for (node = soap_xml_get_children(env->root); node; node = soap_xml_get_next(node))
{
- if (!xmlStrcmp(node->name, BAD_CAST "Body"))
+ if (!xmlStrcmp(node->name, BAD_CAST "Header")
+ && !xmlStrcmp(node->ns->href, BAD_CAST soap_env_ns))
return node;
- node = soap_xml_get_next(node);
}
- log_error1("Node Body tag found!");
return NULL;
}
@@ -509,7 +556,6 @@ soap_env_get_fault(SoapEnv * env)
{
xmlNodePtr node;
-
node = soap_env_get_body(env);
if (!node)
@@ -530,12 +576,11 @@ soap_env_get_fault(SoapEnv * env)
xmlNodePtr
soap_env_get_method(SoapEnv * env)
{
-
xmlNodePtr body;
- if ((body = soap_env_get_body(env)) == NULL)
+ if (!(body = soap_env_get_body(env)))
{
- log_verbose1("body is NULL");
+ log_verbose1("SoapEnv contains no Body");
return NULL;
}
@@ -544,6 +589,7 @@ soap_env_get_method(SoapEnv * env)
}
+/* XXX: unused function? */
xmlNodePtr
_soap_env_get_body(SoapEnv * env)
{
@@ -553,13 +599,13 @@ _soap_env_get_body(SoapEnv * env)
if (env == NULL)
{
- log_error1("env object is NULL");
+ log_error1("SoapEnv is NULL");
return NULL;
}
if (env->root == NULL)
{
- log_error1("env has no xml");
+ log_error1("SoapEnv contains no XML document");
return NULL;
}
@@ -661,57 +707,3 @@ soap_env_find_methodname(SoapEnv * env)
}
-
-/* ------------------------------------------------------------------ */
-/* XML serializers */
-/* ------------------------------------------------------------------ */
-
-
-static void
-xmlbuilder_start_element(const xmlChar * element_name, int attr_count,
- xmlChar ** keys, xmlChar ** values, void *userData)
-{
- struct XmlNodeHolder *holder = (struct XmlNodeHolder *) userData;
- xmlNodePtr parent = NULL;
-
- if (holder == NULL)
- return;
- parent = holder->node;
- if (parent == NULL)
- return;
-
- holder->node = xmlNewChild(parent, NULL, element_name, NULL);
-
-}
-
-static void
-xmlbuilder_characters(const xmlChar * element_name, const xmlChar * chars,
- void *userData)
-{
- struct XmlNodeHolder *holder = (struct XmlNodeHolder *) userData;
- xmlNodePtr parent = NULL;
-
- if (holder == NULL)
- return;
- parent = holder->node;
- if (parent == NULL)
- return;
-
- xmlNewTextChild(parent, NULL, element_name, chars);
-}
-
-static void
-xmlbuilder_end_element(const xmlChar * element_name, void *userData)
-{
-
- struct XmlNodeHolder *holder = (struct XmlNodeHolder *) userData;
- xmlNodePtr parent = NULL;
-
- if (holder == NULL)
- return;
- parent = holder->node;
- if (parent == NULL)
- return;
-
- holder->node = parent->parent;
-}
diff --git a/libcsoap/soap-env.h b/libcsoap/soap-env.h
index ee53f3a..5440e78 100644
--- a/libcsoap/soap-env.h
+++ b/libcsoap/soap-env.h
@@ -1,5 +1,5 @@
/******************************************************************
- * $Id: soap-env.h,v 1.13 2006/02/18 20:14:36 snowdrop Exp $
+ * $Id: soap-env.h,v 1.14 2006/03/06 13:37:38 m0gg Exp $
*
* CSOAP Project: A SOAP client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -29,16 +29,21 @@
#include <libcsoap/soap-xml.h>
#include <libcsoap/soap-fault.h>
-
/**
The SOAP envelope object.
*/
typedef struct _SoapEnv
{
xmlNodePtr root; /** Pointer to the firts xml element (envelope) */
+ xmlNodePtr header;
+ xmlNodePtr body;
xmlNodePtr cur; /** Pointer to the current xml element. (stack) */
} SoapEnv;
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/* -------------------------------------------------------------- */
/* Envelope creation methods */
@@ -177,11 +182,7 @@ herror_t soap_env_new_from_stream(http_input_stream_t * in, SoapEnv ** out);
/* XML Serializer functions and typedefs */
/* --------------------------------------------------- */
-typedef void (*XmlSerializerCallback) (void * /* obj */ , const xmlChar * /* root_element_name
- */ ,
- void (*OnStartElement) (const xmlChar * element_name, int attr_count, xmlChar ** keys, xmlChar ** values, void *userData), void (*OnCharacters) (const xmlChar * element_name, const xmlChar * chars, void *userData), void (*OnEndElement) (const xmlChar * element_name, void *userData), void * /* userdata
- */ );
-
+typedef void (*XmlSerializerCallback) (void * obj, const xmlChar *root_element_name, void (*OnStartElement) (const xmlChar * element_name, int attr_count, xmlChar ** keys, xmlChar ** values, void *userData), void (*OnCharacters) (const xmlChar * element_name, const xmlChar * chars, void *userData), void (*OnEndElement) (const xmlChar * element_name, void *userData), void *userdata);
/* ------------------------------------------------------ */
/* XML build and stack function */
@@ -279,8 +280,7 @@ soap_env_add_itemf(SoapEnv * env, const char *type,
@see tutorial
*/
-xmlNodePtr
-soap_env_push_item(SoapEnv * env, const char *type, const char *name);
+xmlNodePtr soap_env_push_item(SoapEnv * env, const char *type, const char *name);
/**
Sets the xml pointer 1 level higher.
@@ -330,9 +330,8 @@ xmlNodePtr soap_env_get_header(SoapEnv * env);
char * soap_env_find_urn(SoapEnv * env);
char * soap_env_find_methodname(SoapEnv * env);
-
-
-
-
+#ifdef __cplusplus
+}
+#endif
#endif
diff --git a/libcsoap/soap-fault.c b/libcsoap/soap-fault.c
index edeb688..9de1e2b 100644
--- a/libcsoap/soap-fault.c
+++ b/libcsoap/soap-fault.c
@@ -1,5 +1,5 @@
/******************************************************************
-* $Id: soap-fault.c,v 1.9 2006/02/27 22:26:02 snowdrop Exp $
+* $Id: soap-fault.c,v 1.10 2006/03/06 13:37:38 m0gg Exp $
*
* CSOAP Project: A SOAP client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -32,11 +32,6 @@
#include "soap-fault.h"
#include "soap-xml.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
@@ -52,7 +47,8 @@ Parameters:
"<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"%s\" SOAP-ENV:encoding=\"%s\"" \
" xmlns:xsi=\"%s\"" \
" xmlns:xsd=\"%s\">" \
- " <SOAP-ENV:Body>"\
+ " <SOAP-ENV:Header />" \
+ " <SOAP-ENV:Body>" \
" <SOAP-ENV:Fault>"\
" <faultcode>%s</faultcode>"\
" <faultstring>%s</faultstring>"\
diff --git a/libcsoap/soap-fault.h b/libcsoap/soap-fault.h
index 7f01e9f..5aad5ed 100644
--- a/libcsoap/soap-fault.h
+++ b/libcsoap/soap-fault.h
@@ -1,5 +1,5 @@
/******************************************************************
- * $Id: soap-fault.h,v 1.4 2006/01/10 11:29:04 snowdrop Exp $
+ * $Id: soap-fault.h,v 1.5 2006/03/06 13:37:38 m0gg Exp $
*
* CSOAP Project: A SOAP client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -36,10 +36,16 @@ typedef enum _fault_code
Fault_Server
} fault_code_t;
+#ifdef __cplusplus
+extern "C" {
+#endif
xmlDocPtr soap_fault_build(fault_code_t faultcode,
const char *faultstring,
const char *faultactor, const char *detail);
+#ifdef __cplusplus
+}
+#endif
#endif
diff --git a/libcsoap/soap-router.h b/libcsoap/soap-router.h
index 2a37117..41ea95f 100644
--- a/libcsoap/soap-router.h
+++ b/libcsoap/soap-router.h
@@ -1,5 +1,5 @@
/******************************************************************
- * $Id: soap-router.h,v 1.5 2006/02/18 20:14:36 snowdrop Exp $
+ * $Id: soap-router.h,v 1.6 2006/03/06 13:37:38 m0gg Exp $
*
* CSOAP Project: A SOAP client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -38,6 +38,10 @@ typedef struct _SoapRouter
} SoapRouter;
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/**
Creates a new router object. Create a router if
you are implementing a soap server. Then register
@@ -87,4 +91,8 @@ SoapService *soap_router_find_service(SoapRouter * router,
*/
void soap_router_free(SoapRouter * router);
+#ifdef __cplusplus
+}
+#endif
+
#endif
diff --git a/libcsoap/soap-server.c b/libcsoap/soap-server.c
index eade02a..33e1736 100644
--- a/libcsoap/soap-server.c
+++ b/libcsoap/soap-server.c
@@ -1,5 +1,5 @@
/******************************************************************
-* $Id: soap-server.c,v 1.18 2006/02/27 22:26:02 snowdrop Exp $
+* $Id: soap-server.c,v 1.19 2006/03/06 13:37:38 m0gg Exp $
*
* CSOAP Project: A SOAP client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -29,6 +29,14 @@
#include <string.h>
#endif
+#ifdef HAVE_ERRNO_H
+#include <errno.h>
+#endif
+
+#ifdef WIN32
+#define snprintf(buffer, num, s1, s2) sprintf(buffer, s1,s2)
+#endif
+
#include <nanohttp/nanohttp-server.h>
#include "soap-server.h"
@@ -57,6 +65,7 @@ _soap_server_send_env(http_output_stream_t * out, SoapEnv * env)
(const char *) xmlBufferContent(buffer));
xmlBufferFree(buffer);
+ return;
}
static void
@@ -114,18 +123,18 @@ _soap_server_send_fault(httpd_conn_t * conn, const char *errmsg)
static void
_soap_server_send_ctx(httpd_conn_t * conn, SoapCtx * ctx)
{
- xmlBufferPtr buffer;
static int counter = 1;
- char strbuffer[150];
+ xmlBufferPtr buffer;
+ char strbuffer[32];
part_t *part;
if (ctx->env == NULL || ctx->env->root == NULL)
return;
- buffer = xmlBufferCreate();
-/* xmlIndentTreeOutput = 1;*/
xmlThrDefIndentTreeOutput(1);
/* xmlKeepBlanksDefault(0);*/
+
+ buffer = xmlBufferCreate();
xmlNodeDump(buffer, ctx->env->root->doc, ctx->env->root, 1, 1);
if (ctx->attachments)
@@ -149,13 +158,11 @@ _soap_server_send_ctx(httpd_conn_t * conn, SoapCtx * ctx)
char buflen[100];
xmlXPathContextPtr xpathCtx;
xmlXPathObjectPtr xpathObj;
+
xpathCtx = xmlXPathNewContext(ctx->env->root->doc);
xpathObj = xmlXPathEvalExpression("//Fault", xpathCtx);
-#ifdef WIN32
-#define snprintf(buffer, num, s1, s2) sprintf(buffer, s1,s2)
-#endif
- snprintf(buflen, 100, "%d",
- strlen((const char *) xmlBufferContent(buffer)));
+
+ snprintf(buflen, 100, "%d", strlen((const char *) xmlBufferContent(buffer)));
httpd_set_header(conn, HEADER_CONTENT_LENGTH, buflen);
if ((xpathObj->nodesetval) ? xpathObj->nodesetval->nodeNr : 0)
{
@@ -174,25 +181,29 @@ _soap_server_send_ctx(httpd_conn_t * conn, SoapCtx * ctx)
}
xmlBufferFree(buffer);
+ return;
}
static SoapRouterNode *
router_node_new(SoapRouter * router, const char *context, SoapRouterNode * next)
{
- SoapRouterNode *node;
const char *noname = "/lost_found";
+ SoapRouterNode *node;
+
+ if (!(node = (SoapRouterNode *) malloc(sizeof(SoapRouterNode)))) {
+
+ log_error2("malloc failed (%s)", strerror(errno));
+ return NULL;
+ }
- node = (SoapRouterNode *) malloc(sizeof(SoapRouterNode));
if (context)
{
- node->context = (char *) malloc(strlen(context) + 1);
- strcpy(node->context, context);
+ node->context = strdup(context);
}
else
{
log_warn2("context is null. Using '%s'", noname);
- node->context = (char *) malloc(strlen(noname) + 1);
- strcpy(node->context, noname);
+ node->context = strdup(noname);
}
node->router = router;
@@ -204,13 +215,12 @@ router_node_new(SoapRouter * router, const char *context, SoapRouterNode * next)
static SoapRouter *
router_find(const char *context)
{
- SoapRouterNode *node = head;
+ SoapRouterNode *node;
- while (node != NULL)
+ for (node = head; node; node = node->next)
{
if (!strcmp(node->context, context))
return node->router;
- node = node->next;
}
return NULL;
@@ -232,29 +242,29 @@ soap_server_entry(httpd_conn_t * conn, hrequest_t * req)
{
httpd_send_header(conn, 200, "OK");
- http_output_stream_write_string(conn->out, "<html><head></head><body>");
- http_output_stream_write_string(conn->out, "<h1>Sorry!</h1><hr />");
http_output_stream_write_string(conn->out,
- "I only speak with 'POST' method");
- http_output_stream_write_string(conn->out, "</body></html>");
+ "<html>"
+ "<head>"
+ "</head>"
+ "<body>"
+ "<h1>Sorry!</h1>"
+ "<hr />"
+ "<div>I only speak with 'POST' method </div>"
+ "</body>"
+ "</html>");
return;
}
-
- err = soap_env_new_from_stream(req->in, &env);
- if (err != H_OK)
+ if ((err = soap_env_new_from_stream(req->in, &env)) != H_OK)
{
_soap_server_send_fault(conn, herror_message(err));
herror_release(err);
return;
}
-
if (env == NULL)
{
-
_soap_server_send_fault(conn, "Can not receive POST data!");
-
}
else
{
@@ -269,9 +279,7 @@ soap_server_entry(httpd_conn_t * conn, hrequest_t * req)
if (ctx->env == NULL)
{
-
_soap_server_send_fault(conn, "Can not parse POST data!");
-
}
else
{
@@ -282,9 +290,7 @@ soap_server_entry(httpd_conn_t * conn, hrequest_t * req)
if (router == NULL)
{
-
_soap_server_send_fault(conn, "Can not find router!");
-
}
else
{
@@ -303,7 +309,6 @@ soap_server_entry(httpd_conn_t * conn, hrequest_t * req)
if (!(method=soap_env_find_methodname(ctx->env)))
{
-
_soap_server_send_fault(conn, "No method found!");
soap_ctx_free(ctx);
return;
@@ -398,9 +403,8 @@ soap_server_register_router(SoapRouter * router, const char *context)
return 1;
}
-
herror_t
-soap_server_run()
+soap_server_run(void)
{
return httpd_run();
}
@@ -427,6 +431,6 @@ soap_server_destroy()
node = tmp;
}
httpd_destroy();
-}
-
+ return;
+}
diff --git a/libcsoap/soap-server.h b/libcsoap/soap-server.h
index 4e2db62..89c5dbd 100644
--- a/libcsoap/soap-server.h
+++ b/libcsoap/soap-server.h
@@ -1,5 +1,5 @@
/******************************************************************
- * $Id: soap-server.h,v 1.8 2006/02/08 11:13:14 snowdrop Exp $
+ * $Id: soap-server.h,v 1.9 2006/03/06 13:37:38 m0gg Exp $
*
* CSOAP Project: A SOAP client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -28,6 +28,9 @@
#include <libcsoap/soap-router.h>
#include <libcsoap/soap-ctx.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
/**
Initializes the soap server with commandline arguments.
@@ -77,5 +80,8 @@ int soap_server_get_port(void);
*/
void soap_server_destroy();
+#ifdef __cplusplus
+}
+#endif
#endif
diff --git a/libcsoap/soap-service.h b/libcsoap/soap-service.h
index 798f842..594b994 100644
--- a/libcsoap/soap-service.h
+++ b/libcsoap/soap-service.h
@@ -1,5 +1,5 @@
/******************************************************************
- * $Id: soap-service.h,v 1.5 2006/01/10 11:29:04 snowdrop Exp $
+ * $Id: soap-service.h,v 1.6 2006/03/06 13:37:38 m0gg Exp $
*
* CSOAP Project: A SOAP client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -24,7 +24,6 @@
#ifndef cSOAP_SERVICE_H
#define cSOAP_SERVICE_H
-
#include <libcsoap/soap-env.h>
#include <libcsoap/soap-ctx.h>
@@ -45,13 +44,20 @@ typedef struct _SoapServiceNode
struct _SoapServiceNode *next;
} SoapServiceNode;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
SoapServiceNode *soap_service_node_new(SoapService * service,
SoapServiceNode * next);
-SoapService *soap_service_new(const char *urn, const char *method,
- SoapServiceFunc f);
-void soap_service_free(SoapService * service);
+SoapService *soap_service_new(const char *urn, const char *method, SoapServiceFunc f);
+void soap_service_free(SoapService * service);
+#ifdef __cplusplus
+}
+#endif
#endif
diff --git a/libcsoap/soap-xml.h b/libcsoap/soap-xml.h
index 9ab07ea..ad578b1 100644
--- a/libcsoap/soap-xml.h
+++ b/libcsoap/soap-xml.h
@@ -1,5 +1,5 @@
/******************************************************************
- * $Id: soap-xml.h,v 1.7 2006/01/10 11:29:04 snowdrop Exp $
+ * $Id: soap-xml.h,v 1.8 2006/03/06 13:37:38 m0gg Exp $
*
* CSOAP Project: A SOAP client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -29,8 +29,16 @@
#include <nanohttp/nanohttp-common.h>
+static const char * const soap_env_ns = "http://schemas.xmlsoap.org/soap/envelope/";
+static const char * const soap_env_enc = "http://schemas.xmlsoap.org/soap/encoding/";
+static const char * const soap_xsi_ns = "http://www.w3.org/1999/XMLSchema-instance";
+static const char * const soap_xsd_ns = "http://www.w3.org/1999/XMLSchema";
+
typedef int (*soap_xmlnode_callback) (xmlNodePtr, void *);
+#ifdef __cplusplus
+extern "C" {
+#endif
xmlNodePtr soap_xml_get_children(xmlNodePtr param);
xmlNodePtr soap_xml_get_next(xmlNodePtr param);
@@ -45,4 +53,8 @@ soap_xpath_foreach(xmlDocPtr doc, const char *xpath,
void soap_xml_doc_print(xmlDocPtr doc);
char *soap_xml_get_text(xmlNodePtr node);
+#ifdef __cplusplus
+}
+#endif
+
#endif