summaryrefslogtreecommitdiffstats
path: root/libcsoap
diff options
context:
space:
mode:
Diffstat (limited to 'libcsoap')
-rwxr-xr-xlibcsoap/soap-ctx.c31
-rw-r--r--libcsoap/soap-env.c26
-rw-r--r--libcsoap/soap-fault.c13
-rw-r--r--libcsoap/soap-router.c10
-rw-r--r--libcsoap/soap-server.c44
-rw-r--r--libcsoap/soap-service.c14
-rw-r--r--libcsoap/soap-xml.c8
7 files changed, 113 insertions, 33 deletions
diff --git a/libcsoap/soap-ctx.c b/libcsoap/soap-ctx.c
index dd68861..a06b897 100755
--- a/libcsoap/soap-ctx.c
+++ b/libcsoap/soap-ctx.c
@@ -1,5 +1,5 @@
/******************************************************************
- * $Id: soap-ctx.c,v 1.8 2006/02/18 20:14:36 snowdrop Exp $
+ * $Id: soap-ctx.c,v 1.9 2006/02/27 22:26:02 snowdrop Exp $
*
* CSOAP Project: A SOAP client/server library in C
* Copyright (C) 2003-2004 Ferhat Ayaz
@@ -21,14 +21,35 @@
*
* Email: ferhatayaz@jprogrammer.net
******************************************************************/
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#ifdef HAVE_STDIO_H
+#include <stdio.h>
+#endif
+
+#ifdef HAVE_STRING_H
#include <string.h>
+#endif
+
+#ifdef HAVE_ERRNO_H
+#include <errno.h>
+#endif
-#include <libcsoap/soap-ctx.h>
+#include "soap-ctx.h"
SoapCtx *
soap_ctx_new(SoapEnv * env) /* should only be used internally */
{
- SoapCtx *ctx = (SoapCtx *) malloc(sizeof(SoapCtx));
+ SoapCtx *ctx;
+
+ if (!(ctx = (SoapCtx *) malloc(sizeof(SoapCtx))))
+ {
+ log_error2("malloc failed (%s)", strerror(errno));
+ return NULL;
+ }
+
ctx->env = env;
ctx->attachments = NULL;
ctx->action = NULL;
@@ -132,12 +153,16 @@ soap_ctx_free(SoapCtx * ctx)
if (ctx->attachments)
attachments_free(ctx->attachments);
+
if (ctx->env)
soap_env_free(ctx->env);
+
if (ctx->action)
free(ctx->action);
free(ctx);
+
+ return;
}
diff --git a/libcsoap/soap-env.c b/libcsoap/soap-env.c
index cb55bd2..8f4df35 100644
--- a/libcsoap/soap-env.c
+++ b/libcsoap/soap-env.c
@@ -1,5 +1,5 @@
/******************************************************************
-* $Id: soap-env.c,v 1.16 2006/02/25 10:09:28 snowdrop Exp $
+* $Id: soap-env.c,v 1.17 2006/02/27 22:26:02 snowdrop Exp $
*
* CSOAP Project: A SOAP client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -21,11 +21,27 @@
*
* Email: ayaz@jprogrammer.net
******************************************************************/
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#ifdef HAVE_STDARG_H
#include <stdarg.h>
+#endif
+
+#ifdef HAVE_STDIO_H
#include <stdio.h>
+#endif
+
+#ifdef HAVE_STRING_H
#include <string.h>
+#endif
+
+#ifdef HAVE_ERRNO_H
+#include <errno.h>
+#endif
-#include <libcsoap/soap-env.h>
+#include "soap-env.h"
#ifdef WIN32
#define USE_XMLSTRING
@@ -128,7 +144,11 @@ soap_env_new_from_doc(xmlDocPtr doc, SoapEnv ** out)
XML_ERROR_EMPTY_DOCUMENT, "XML Document is empty!");
}
- env = (SoapEnv *) malloc(sizeof(SoapEnv));
+ if (!(env = (SoapEnv *) malloc(sizeof(SoapEnv))))
+ {
+ log_error2("malloc failed (%s)", strerror(errno));
+ return herror_new("soap_env_from_doc", GENERAL_INVALID_PARAM, "malloc failed");
+ }
/* set root */
env->root = node;
diff --git a/libcsoap/soap-fault.c b/libcsoap/soap-fault.c
index 1e6cae8..edeb688 100644
--- a/libcsoap/soap-fault.c
+++ b/libcsoap/soap-fault.c
@@ -1,5 +1,5 @@
/******************************************************************
-* $Id: soap-fault.c,v 1.8 2006/01/10 11:29:04 snowdrop Exp $
+* $Id: soap-fault.c,v 1.9 2006/02/27 22:26:02 snowdrop Exp $
*
* CSOAP Project: A SOAP client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -21,9 +21,16 @@
*
* Email: ayaz@jprogrammer.net
******************************************************************/
-#include <libcsoap/soap-fault.h>
-#include <libcsoap/soap-xml.h>
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#ifdef HAVE_STRING_H
#include <string.h>
+#endif
+
+#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/";
diff --git a/libcsoap/soap-router.c b/libcsoap/soap-router.c
index fc26916..7b93b03 100644
--- a/libcsoap/soap-router.c
+++ b/libcsoap/soap-router.c
@@ -1,5 +1,5 @@
/******************************************************************
-* $Id: soap-router.c,v 1.6 2006/02/18 20:14:36 snowdrop Exp $
+* $Id: soap-router.c,v 1.7 2006/02/27 22:26:02 snowdrop Exp $
*
* CSOAP Project: A SOAP client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -21,9 +21,15 @@
*
* Email: ayaz@jprogrammer.net
******************************************************************/
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#ifdef HAVE_STRING_H
#include <string.h>
+#endif
-#include <libcsoap/soap-router.h>
+#include "soap-router.h"
SoapRouter *
soap_router_new(void)
diff --git a/libcsoap/soap-server.c b/libcsoap/soap-server.c
index 68d6f16..eade02a 100644
--- a/libcsoap/soap-server.c
+++ b/libcsoap/soap-server.c
@@ -1,5 +1,5 @@
/******************************************************************
-* $Id: soap-server.c,v 1.17 2006/02/18 20:14:36 snowdrop Exp $
+* $Id: soap-server.c,v 1.18 2006/02/27 22:26:02 snowdrop Exp $
*
* CSOAP Project: A SOAP client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -21,11 +21,17 @@
*
* Email: ayaz@jprogrammer.net
******************************************************************/
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#ifdef HAVE_STRING_H
#include <string.h>
+#endif
#include <nanohttp/nanohttp-server.h>
-#include <libcsoap/soap-server.h>
+#include "soap-server.h"
typedef struct _SoapRouterNode
{
@@ -54,13 +60,15 @@ _soap_server_send_env(http_output_stream_t * out, SoapEnv * env)
}
static void
-_soap_server_send_fault(httpd_conn_t * conn, hpair_t * header,
- const char *errmsg)
+_soap_server_send_fault(httpd_conn_t * conn, const char *errmsg)
{
SoapEnv *envres;
+ hpair_t *header;
herror_t err;
char buffer[45];
+ header = hpairnode_new(HEADER_CONTENT_TYPE, "text/xml", NULL);
+
httpd_set_headers(conn, header);
if ((err = httpd_send_header(conn, 500, "FAILED")) != H_OK)
@@ -92,12 +100,14 @@ _soap_server_send_fault(httpd_conn_t * conn, hpair_t * header,
http_output_stream_write_string(conn->out, "</body></html>");
herror_release(err);
- return;
}
else
{
_soap_server_send_env(conn->out, envres);
}
+
+ hpairnode_free(header);
+
return;
}
@@ -209,7 +219,6 @@ router_find(const char *context)
static void
soap_server_entry(httpd_conn_t * conn, hrequest_t * req)
{
- hpair_t *header = NULL;
char buffer[1054];
char *urn;
char *method;
@@ -232,12 +241,10 @@ soap_server_entry(httpd_conn_t * conn, hrequest_t * req)
}
- header = hpairnode_new(HEADER_CONTENT_TYPE, "text/xml", NULL);
-
err = soap_env_new_from_stream(req->in, &env);
if (err != H_OK)
{
- _soap_server_send_fault(conn, header, herror_message(err));
+ _soap_server_send_fault(conn, herror_message(err));
herror_release(err);
return;
}
@@ -246,7 +253,7 @@ soap_server_entry(httpd_conn_t * conn, hrequest_t * req)
if (env == NULL)
{
- _soap_server_send_fault(conn, header, "Can not receive POST data!");
+ _soap_server_send_fault(conn, "Can not receive POST data!");
}
else
@@ -254,13 +261,16 @@ soap_server_entry(httpd_conn_t * conn, hrequest_t * req)
ctx = soap_ctx_new(env);
ctx->action = hpairnode_get_ignore_case(req->header, "SoapAction");
+ if (ctx->action)
+ ctx->action = strdup(ctx->action);
+
ctx->http = req;
soap_ctx_add_files(ctx, req->attachments);
if (ctx->env == NULL)
{
- _soap_server_send_fault(conn, header, "Can not parse POST data!");
+ _soap_server_send_fault(conn, "Can not parse POST data!");
}
else
@@ -273,7 +283,7 @@ soap_server_entry(httpd_conn_t * conn, hrequest_t * req)
if (router == NULL)
{
- _soap_server_send_fault(conn, header, "Can not find router!");
+ _soap_server_send_fault(conn, "Can not find router!");
}
else
@@ -282,7 +292,7 @@ soap_server_entry(httpd_conn_t * conn, hrequest_t * req)
if (!(urn=soap_env_find_urn(ctx->env)))
{
- _soap_server_send_fault(conn, header, "No URN found!");
+ _soap_server_send_fault(conn, "No URN found!");
soap_ctx_free(ctx);
return;
}
@@ -294,7 +304,7 @@ soap_server_entry(httpd_conn_t * conn, hrequest_t * req)
if (!(method=soap_env_find_methodname(ctx->env)))
{
- _soap_server_send_fault(conn, header, "No method found!");
+ _soap_server_send_fault(conn, "No method found!");
soap_ctx_free(ctx);
return;
}
@@ -309,7 +319,7 @@ soap_server_entry(httpd_conn_t * conn, hrequest_t * req)
{
sprintf(buffer, "URN '%s' not found", urn);
- _soap_server_send_fault(conn, header, buffer);
+ _soap_server_send_fault(conn, buffer);
soap_ctx_free(ctx);
return;
}
@@ -327,7 +337,7 @@ soap_server_entry(httpd_conn_t * conn, hrequest_t * req)
sprintf(buffer, "Service returned following error message: '%s'",
herror_message(err));
herror_release(err);
- _soap_server_send_fault(conn, header, buffer);
+ _soap_server_send_fault(conn, buffer);
soap_ctx_free(ctx);
return;
}
@@ -336,7 +346,7 @@ soap_server_entry(httpd_conn_t * conn, hrequest_t * req)
{
sprintf(buffer, "Service '%s' returned no envelope", urn);
- _soap_server_send_fault(conn, header, buffer);
+ _soap_server_send_fault(conn, buffer);
soap_ctx_free(ctx);
return;
diff --git a/libcsoap/soap-service.c b/libcsoap/soap-service.c
index 376daa7..fd72ce6 100644
--- a/libcsoap/soap-service.c
+++ b/libcsoap/soap-service.c
@@ -1,5 +1,5 @@
/******************************************************************
-* $Id: soap-service.c,v 1.6 2006/01/10 11:29:04 snowdrop Exp $
+* $Id: soap-service.c,v 1.7 2006/02/27 22:26:02 snowdrop Exp $
*
* CSOAP Project: A SOAP client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -21,9 +21,17 @@
*
* Email: ayaz@jprogrammer.net
******************************************************************/
-#include <libcsoap/soap-service.h>
-#include <nanohttp/nanohttp-common.h>
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#ifdef HAVE_STRING_H
#include <string.h>
+#endif
+
+#include <nanohttp/nanohttp-common.h>
+
+#include "soap-service.h"
SoapServiceNode *
soap_service_node_new(SoapService * service, SoapServiceNode * next)
diff --git a/libcsoap/soap-xml.c b/libcsoap/soap-xml.c
index 62b0b7d..37487d3 100644
--- a/libcsoap/soap-xml.c
+++ b/libcsoap/soap-xml.c
@@ -1,5 +1,5 @@
/******************************************************************
-* $Id: soap-xml.c,v 1.9 2006/02/08 11:13:14 snowdrop Exp $
+* $Id: soap-xml.c,v 1.10 2006/02/27 22:26:02 snowdrop Exp $
*
* CSOAP Project: A SOAP client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -21,7 +21,11 @@
*
* Email: ayaz@jprogrammer.net
******************************************************************/
-#include <libcsoap/soap-xml.h>
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "soap-xml.h"
xmlNodePtr
soap_xml_get_children(xmlNodePtr param)