summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/csoap/simpleclient.c8
-rw-r--r--examples/csoap/simpleserver.c28
-rw-r--r--examples/csoap/soapclient.c3
-rw-r--r--libcsoap/soap-addressing.c9
-rw-r--r--libcsoap/soap-admin.c3
-rw-r--r--libcsoap/soap-env.c15
-rw-r--r--libcsoap/soap-nhttp.c19
-rw-r--r--libcsoap/soap-nhttp.h4
-rw-r--r--libcsoap/soap-nudp.c254
-rw-r--r--libcsoap/soap-nudp.h20
-rw-r--r--libcsoap/soap-server.c5
-rw-r--r--libcsoap/soap-transport.c20
-rw-r--r--libcsoap/soap-xml.c28
-rw-r--r--nanohttp/nanohttp-common.h4
-rwxr-xr-xnanohttp/nanohttp-request.h4
-rwxr-xr-xnanohttp/nanohttp-response.h7
-rw-r--r--nanohttp/nanohttp-server.c8
-rw-r--r--nanohttp/nanohttp-socket.c4
-rw-r--r--nanohttp/nanohttp-socket.h4
-rw-r--r--nanohttp/nanohttp-ssl.c6
20 files changed, 368 insertions, 85 deletions
diff --git a/examples/csoap/simpleclient.c b/examples/csoap/simpleclient.c
index 1af42f5..10924d2 100644
--- a/examples/csoap/simpleclient.c
+++ b/examples/csoap/simpleclient.c
@@ -1,5 +1,5 @@
/******************************************************************
- * $Id: simpleclient.c,v 1.17 2006/11/25 17:03:20 m0gg Exp $
+ * $Id: simpleclient.c,v 1.18 2006/11/26 20:13:05 m0gg Exp $
*
* CSOAP Project: CSOAP examples project
* Copyright (C) 2003-2004 Ferhat Ayaz
@@ -47,7 +47,7 @@ main(int argc, char **argv)
err = soap_client_init_args(argc, argv);
if (err != H_OK)
{
- printf("%s():%s [%d]", herror_func(err), herror_message(err), herror_code(err));
+ printf("%s():%s [%d]\n", herror_func(err), herror_message(err), herror_code(err));
herror_release(err);
exit(1);
}
@@ -55,7 +55,7 @@ main(int argc, char **argv)
err = soap_ctx_new_with_method(urn, method, &ctx);
if (err != H_OK)
{
- printf("%s():%s [%d]", herror_func(err), herror_message(err), herror_code(err));
+ printf("%s():%s [%d]\n", herror_func(err), herror_message(err), herror_code(err));
herror_release(err);
exit(1);
}
@@ -71,7 +71,7 @@ main(int argc, char **argv)
if ((err = soap_client_invoke(ctx, &ctx2, url, "")) != H_OK)
{
- printf("[%d] %s(): %s ", herror_code(err), herror_func(err), herror_message(err));
+ printf("[%d] %s(): %s\n", herror_code(err), herror_func(err), herror_message(err));
herror_release(err);
soap_ctx_free(ctx);
exit(1);
diff --git a/examples/csoap/simpleserver.c b/examples/csoap/simpleserver.c
index 03c3c5d..5803a33 100644
--- a/examples/csoap/simpleserver.c
+++ b/examples/csoap/simpleserver.c
@@ -1,5 +1,5 @@
/******************************************************************
- * $Id: simpleserver.c,v 1.25 2006/11/25 17:03:20 m0gg Exp $
+ * $Id: simpleserver.c,v 1.26 2006/11/26 20:13:05 m0gg Exp $
*
* CSOAP Project: CSOAP examples project
* Copyright (C) 2003-2004 Ferhat Ayaz
@@ -45,28 +45,40 @@ say_hello(struct SoapCtx *req, struct SoapCtx *res)
{
herror_t err;
char *name;
+ xmlNodePtr method, node;
- printf("service request");
+ printf("processing service request\n");
- xmlNodePtr method, node;
+ xmlDocFormatDump(stdout, req->env->root->doc, 1);
err = soap_env_new_with_response(req->env, &res->env);
if (err != H_OK)
{
+ printf("soap_env_new_with_response failed (%s)\n", herror_message(err));
return err;
}
+ printf("empty response created\n");
- method = soap_env_get_method(req->env);
- node = soap_xml_get_children(method);
+ if (!(method = soap_env_get_method(req->env)))
+ {
+ printf("soap_env_get_method failed\n");
+ return herror_new("say_hello", 0, "There may be a bug in the library...");
+ }
+ printf("method found\n");
+ printf("adding response content...\n");
+ node = soap_xml_get_children(method);
while (node)
{
name = (char *) xmlNodeListGetString(node->doc, node->xmlChildrenNode, 1);
soap_env_add_itemf(res->env, "xsd:string", "echo", "Hello '%s'", name);
node = soap_xml_get_next(node);
- xmlFree(name);
+ if (name)
+ xmlFree(name);
}
+ printf("service request done\n");
+
return H_OK;
}
@@ -102,7 +114,7 @@ main(int argc, char **argv)
if ((err = soap_server_register_router(router, url)))
{
- printf("%s(): %s [%s]\n", herror_func(err), herror_message(err), herror_code(err));
+ printf("%s(): %s [%d]\n", herror_func(err), herror_message(err), herror_code(err));
herror_release(err);
exit(1);
}
@@ -111,7 +123,7 @@ main(int argc, char **argv)
printf("press ctrl-c to shutdown\n");
if ((err = soap_server_run()) != H_OK)
{
- printf("%s(): %s [%s]\n", herror_func(err), herror_message(err), herror_code(err));
+ printf("%s(): %s [%d]\n", herror_func(err), herror_message(err), herror_code(err));
herror_release(err);
exit(1);
}
diff --git a/examples/csoap/soapclient.c b/examples/csoap/soapclient.c
index e39802a..5b98e91 100644
--- a/examples/csoap/soapclient.c
+++ b/examples/csoap/soapclient.c
@@ -1,5 +1,5 @@
/******************************************************************
- * $Id: soapclient.c,v 1.11 2006/11/25 17:03:20 m0gg Exp $
+ * $Id: soapclient.c,v 1.12 2006/11/26 20:13:05 m0gg Exp $
*
* CSOAP Project: CSOAP examples project
* Copyright (C) 2003-2006 Adrianus Warmehoven
@@ -22,6 +22,7 @@
******************************************************************/
#include <stdio.h>
#include <string.h>
+#include <ctype.h>
#include <libxml/tree.h>
diff --git a/libcsoap/soap-addressing.c b/libcsoap/soap-addressing.c
index 9e89f49..2069bd7 100644
--- a/libcsoap/soap-addressing.c
+++ b/libcsoap/soap-addressing.c
@@ -1,5 +1,5 @@
/******************************************************************
-* $Id: soap-addressing.c,v 1.6 2006/11/25 17:03:20 m0gg Exp $
+* $Id: soap-addressing.c,v 1.7 2006/11/26 20:13:05 m0gg Exp $
*
* CSOAP Project: A SOAP client/server library in C
* Copyright (C) 2006 Heiko Ronsdorf
@@ -41,6 +41,10 @@
#include <stdlib.h>
#endif
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+
#ifdef HAVE_ERRNO_H
#include <errno.h>
#endif
@@ -59,6 +63,7 @@
#include "soap-xml.h"
#include "soap-fault.h"
#include "soap-env.h"
+#include "soap-server.h"
#include "soap-addressing.h"
static const xmlChar *
@@ -189,7 +194,7 @@ _soap_addressing_set_content_uri(xmlNodePtr node, xmlURI *uri)
xmlChar *buf;
if (uri == NULL)
- return;
+ return NULL;
buf = xmlSaveUri(uri);
xmlNodeSetContent(node, buf);
diff --git a/libcsoap/soap-admin.c b/libcsoap/soap-admin.c
index 81310ed..715e3ca 100644
--- a/libcsoap/soap-admin.c
+++ b/libcsoap/soap-admin.c
@@ -1,5 +1,5 @@
/******************************************************************
-* $Id: soap-admin.c,v 1.9 2006/11/25 16:35:57 m0gg Exp $
+* $Id: soap-admin.c,v 1.10 2006/11/26 20:13:05 m0gg Exp $
*
* CSOAP Project: A SOAP client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -46,6 +46,7 @@
#include <nanohttp/nanohttp-error.h>
#include <nanohttp/nanohttp-common.h>
+#include <nanohttp/nanohttp-stream.h>
#include <nanohttp/nanohttp-request.h>
#include <nanohttp/nanohttp-server.h>
#include <nanohttp/nanohttp-admin.h>
diff --git a/libcsoap/soap-env.c b/libcsoap/soap-env.c
index 04146f4..99cf3ba 100644
--- a/libcsoap/soap-env.c
+++ b/libcsoap/soap-env.c
@@ -1,5 +1,5 @@
/******************************************************************
-* $Id: soap-env.c,v 1.26 2006/11/25 15:06:57 m0gg Exp $
+* $Id: soap-env.c,v 1.27 2006/11/26 20:13:05 m0gg Exp $
*
* CSOAP Project: A SOAP client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -167,7 +167,7 @@ xmlbuilder_end_element(const xmlChar * element_name, void *userData)
herror_t
soap_env_new_from_doc(xmlDocPtr doc, struct SoapEnv ** out)
{
- xmlNodePtr node;
+ xmlNodePtr root;
struct SoapEnv *env;
if (doc == NULL)
@@ -178,7 +178,7 @@ soap_env_new_from_doc(xmlDocPtr doc, struct SoapEnv ** out)
"XML Document (xmlDocPtr) is NULL");
}
- if (!(node = xmlDocGetRootElement(doc)))
+ if (!(root = xmlDocGetRootElement(doc)))
{
log_error1("XML document is empty!");
return herror_new("soap_env_new_from_doc",
@@ -191,7 +191,7 @@ soap_env_new_from_doc(xmlDocPtr doc, struct SoapEnv ** out)
return herror_new("soap_env_from_doc", GENERAL_INVALID_PARAM, "malloc failed (%s)", strerror(errno));
}
- env->root = node;
+ env->root = root;
env->header = soap_env_get_header(env);
env->body = soap_env_get_body(env);
env->cur = soap_env_get_method(env);
@@ -201,7 +201,6 @@ soap_env_new_from_doc(xmlDocPtr doc, struct SoapEnv ** out)
return H_OK;
}
-
herror_t
soap_env_new_from_buffer(const char *buffer, struct SoapEnv **out)
{
@@ -446,13 +445,13 @@ soap_env_get_body(struct SoapEnv * env)
if (env == NULL)
{
- log_error1("env object is NULL");
+ log_error1("SOAP envelope is NULL");
return NULL;
}
if (env->root == NULL)
{
- log_error1("env has no xml");
+ log_error1("SOAP envelope contains no XML");
return NULL;
}
@@ -525,7 +524,7 @@ soap_env_get_method(struct SoapEnv * env)
if (!(body = soap_env_get_body(env)))
{
- log_verbose1("SoapEnv contains no Body");
+ log_verbose1("SoapEnv contains no Body element");
return NULL;
}
diff --git a/libcsoap/soap-nhttp.c b/libcsoap/soap-nhttp.c
index ce48394..84a9ddc 100644
--- a/libcsoap/soap-nhttp.c
+++ b/libcsoap/soap-nhttp.c
@@ -1,5 +1,5 @@
/******************************************************************
-* $Id: soap-nhttp.c,v 1.4 2006/11/25 16:35:57 m0gg Exp $
+* $Id: soap-nhttp.c,v 1.5 2006/11/26 20:13:05 m0gg Exp $
*
* CSOAP Project: A SOAP client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -415,25 +415,31 @@ _soap_nhttp_client_invoke(void *unused, struct SoapCtx *request, struct SoapCtx
herror_t
soap_nhttp_client_init_args(int argc, char **argv)
{
+ herror_t status;
+
+ if ((status = httpc_init(argc, argv)) != H_OK)
+ {
+ log_error2("httpc_init failed (%s)", herror_message(status));
+ return status;
+ }
+
soap_transport_add("https", NULL, _soap_nhttp_client_invoke);
soap_transport_add("http", NULL, _soap_nhttp_client_invoke);
- return httpc_init(argc, argv);
+ return H_OK;
}
herror_t
-soap_nhttp_register(const void *data)
+soap_nhttp_register(const char *context)
{
herror_t status;
- const char *context;
-
- context = (char *)data;
if ((status = httpd_register(context, soap_nhttp_process)) != H_OK)
{
log_error2("httpd_register_secure failed (%s)", herror_message(status));
return status;
}
+
return H_OK;
}
@@ -470,4 +476,3 @@ soap_nhttp_get_protocol(void)
{
return httpd_get_protocol();
}
-
diff --git a/libcsoap/soap-nhttp.h b/libcsoap/soap-nhttp.h
index acb5dc3..ebf107d 100644
--- a/libcsoap/soap-nhttp.h
+++ b/libcsoap/soap-nhttp.h
@@ -1,5 +1,5 @@
/******************************************************************
-* $Id: soap-nhttp.h,v 1.2 2006/11/23 15:27:33 m0gg Exp $
+* $Id: soap-nhttp.h,v 1.3 2006/11/26 20:13:05 m0gg Exp $
*
* CSOAP Project: A SOAP client/server library in C
* Copyright (C) 2007 Heiko Ronsdorf
@@ -47,7 +47,7 @@ extern herror_t soap_nhttp_server_init_args(int argc, char **argv);
extern herror_t soap_nhttp_server_run(void);
extern void soap_nhttp_server_destroy(void);
-extern herror_t soap_nhttp_register(const void *data);
+extern herror_t soap_nhttp_register(const char *context);
extern short soap_nhttp_get_port(void);
extern const char *soap_nhttp_get_protocol(void);
diff --git a/libcsoap/soap-nudp.c b/libcsoap/soap-nudp.c
index 61c3169..3c0cf70 100644
--- a/libcsoap/soap-nudp.c
+++ b/libcsoap/soap-nudp.c
@@ -1,8 +1,8 @@
/******************************************************************
-* $Id: soap-nudp.c,v 1.4 2006/11/25 17:03:20 m0gg Exp $
+* $Id: soap-nudp.c,v 1.5 2006/11/26 20:13:05 m0gg Exp $
*
* CSOAP Project: A SOAP client/server library in C
-* Copyright (C) 2003 Ferhat Ayaz
+* Copyright (C) 2006 Heiko Ronsdorf
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -19,20 +19,56 @@
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
-* Email: ayaz@jprogrammer.net
+* Email: hero@persua.de
******************************************************************/
#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_STDLIB_H
+#include <stdlib.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
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#ifdef HAVE_PTHREAD_H
+#include <pthread.h>
+#endif
+
+#ifdef HAVE_NETDB_H
+#include <netdb.h>
+#endif
+
+#ifdef HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif
+
+#ifdef HAVE_ARPA_INET_H
+#include <arpa/inet.h>
+#endif
+
#include <libxml/tree.h>
#include <libxml/uri.h>
@@ -45,11 +81,165 @@
#include "soap-service.h"
#include "soap-router.h"
#include "soap-server.h"
+#include "soap-transport.h"
#include "soap-addressing.h"
+#include "soap-nudp.h"
+
+static short _soap_nudp_port = NUDP_DEFAULT_PORT;
+static int _soap_nudp_socket;
+static pthread_t _soap_nudp_thread;
+static pthread_attr_t _soap_nudp_attr;
+
+static short
+_soap_nudp_server_set_port(void)
+{
+ struct servent *entry;
+
+ if (!(entry = getservbyname("soap", "udp")))
+ {
+ log_warn1("getservbyname returned NULL");
+ _soap_nudp_port = NUDP_DEFAULT_PORT;
+ }
+ else
+ {
+ _soap_nudp_port = entry->s_port;
+ }
+ return _soap_nudp_port;
+}
+
+static void
+_soap_nudp_server_parse_arguments(int argc, char **argv)
+{
+ int i;
+
+ for (i=1; i<argc; i++)
+ {
+ if (!strcmp(argv[i - 1], NUDP_ARG_PORT))
+ {
+ _soap_nudp_port = atoi(argv[i]);
+ }
+ }
+
+ log_verbose2("socket bind to port \"%d\"", _soap_nudp_port);
+
+ return;
+}
+
+static herror_t
+_soap_nudp_send_document(int socket, xmlDocPtr doc, const struct sockaddr *addr, socklen_t addr_len)
+{
+ xmlChar *buf;
+ int size;
+
+ xmlDocDumpMemory(doc, &buf, &size);
+ if (sendto(socket, buf, size, 0, addr, addr_len) < 0)
+ {
+ log_error2("sendto failed (%s)", strerror(errno));
+ return herror_new("soap_nudp_client_invoke", 0, "Cannot send message");
+ }
+ xmlFree(buf);
+
+ return H_OK;
+}
+
+static herror_t
+_soap_nudp_receive_document(int socket, xmlDocPtr *doc, struct sockaddr *addr, socklen_t *addr_len)
+{
+ int cnt;
+ char buf[4096];
+
+ if ((cnt = recvfrom(socket, buf, 4096, 0, addr, addr_len)) < 0)
+ {
+ log_error2("recvfrom failed (%s)", strerror(errno));
+ return herror_new("_soap_nudp_receive_document", 0, "Receiving document failed");
+ }
+
+ if (!(*doc = xmlReadDoc(buf, NULL, NULL, XML_PARSE_NONET)))
+ {
+ log_error1("xmlReadDoc failed");
+ return herror_new("_soap_nudp_receive_document", 0, "Cannot parse received data");
+ }
+
+ return H_OK;
+}
+
+static herror_t
+_soap_nudp_client_invoke(void *unused, struct SoapCtx *req, struct SoapCtx **res)
+{
+ xmlURI *to;
+ xmlDocPtr doc;
+ int sd;
+ herror_t status;
+ struct sockaddr_in addr;
+
+ if (!(to = soap_addressing_get_to_address(req->env)))
+ {
+ log_error1("soap_addressing_get_to_address returned NULL");
+ return herror_new("soap_nudp_client_invoke", 0, "Destination address is missing");
+ }
+
+ bzero(&addr, sizeof(struct sockaddr_in));
+ addr.sin_family = AF_INET;
+ if (to->port == 0)
+ addr.sin_port = htons(NUDP_DEFAULT_PORT);
+ else
+ addr.sin_port = htons(to->port);
+
+ if (inet_pton(AF_INET, "127.0.0.1", &addr.sin_addr) != 1)
+ {
+ log_error2("inet_pton failed (%s)", strerror(errno));
+ return herror_new("soap_nudp_client_invoke", 0, "Cannot resolve destination address");
+ }
+
+ if ((sd = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
+ {
+ log_error2("socket failed (%s)", strerror(errno));
+ return herror_new("soap_nudp_client_invoke", 0, "Cannot create socket");
+ }
+
+ _soap_nudp_send_document(sd, req->env->root->doc, (struct sockaddr *)&addr, sizeof(struct sockaddr_in));
+
+ if ((status = _soap_nudp_receive_document(sd, &doc, NULL, NULL)) != H_OK)
+ {
+ log_error2("_soap_nudp_receive_document failed (%s)", herror_message(status));
+ return status;
+ }
+
+ if ((status = soap_env_new_from_doc(doc, &(*res)->env)) != H_OK)
+ {
+ log_error2("soap_env_new_from_doc failed (%s)", herror_message(status));
+ return status;
+ }
+
+ return H_OK;
+}
herror_t
soap_nudp_server_init_args(int argc, char **argv)
{
+ struct sockaddr_in addr;
+
+ _soap_nudp_server_set_port();
+
+ _soap_nudp_server_parse_arguments(argc, argv);
+
+ if ((_soap_nudp_socket = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
+ {
+ log_error2("socket failed (%s)", strerror(errno));
+ return herror_new("soap_nudp_server_init_args", 0, "Cannot create socket (%s)", strerror(errno));
+ }
+
+ memset(&addr, 0, sizeof(struct sockaddr_in));
+ addr.sin_family = AF_INET;
+ addr.sin_addr.s_addr = htonl(INADDR_ANY);
+ addr.sin_port = htons(_soap_nudp_port);
+
+ if (bind(_soap_nudp_socket, (struct sockaddr *)&addr, sizeof(struct sockaddr_in)) < 0)
+ {
+ log_error2("bind failed (%s)", strerror(errno));
+ return herror_new("soap_nudp_server_init_args", 0, "Cannot bind socket (%s)", strerror(errno));
+ }
+
return H_OK;
}
@@ -59,27 +249,73 @@ soap_nudp_register(const void *data)
return H_OK;
}
+void *
+soap_nudp_server_run(void *unused)
+{
+ xmlDocPtr doc;
+ struct sockaddr addr;
+ socklen_t addr_len;
+ struct SoapCtx *req;
+ struct SoapCtx *res;
+ xmlURI *to;
+
+ for(;;)
+ {
+ _soap_nudp_receive_document(_soap_nudp_socket, &doc, &addr, &addr_len);
+
+ xmlDocFormatDump(stdout, doc, 1);
+
+ req = soap_ctx_new(NULL);
+
+ soap_env_new_from_doc(doc, &(req->env));
+
+ /* only local part is interesting */
+ to = soap_addressing_get_to_address(req->env);
+ soap_addressing_set_to_address_string(req->env, to->path);
+
+ xmlFreeDoc(doc);
+
+ soap_transport_process(req, &res);
+
+ _soap_nudp_send_document(_soap_nudp_socket, res->env->root->doc, &addr, addr_len);
+
+ soap_ctx_free(res);
+
+ soap_ctx_free(req);
+ }
+
+ return NULL;
+}
+
herror_t
-soap_nudp_server_run(void)
+soap_nudp_server_run_threaded(void)
{
+ int err;
+
+ if ((err = pthread_create(&_soap_nudp_thread, &_soap_nudp_attr, soap_nudp_server_run, NULL)) < 0)
+ {
+ log_error2("pthread_create failed (%s)", strerror(err));
+ return herror_new("soap_nudp_server_run_threaded", 0, "pthread_create failed (%s)", strerror(err));
+ }
+
return H_OK;
}
void
soap_nudp_server_destroy(void)
{
+
+ close(_soap_nudp_socket);
+
return;
}
+
herror_t
soap_nudp_client_init_args(int argc, char **argv)
{
- return H_OK;
-}
+ soap_transport_add("soap.udp", NULL, _soap_nudp_client_invoke);
-herror_t
-soap_nudp_client_invoke(struct SoapCtx *req, struct SoapCtx **res)
-{
return H_OK;
}
diff --git a/libcsoap/soap-nudp.h b/libcsoap/soap-nudp.h
index 9b703ae..8978b70 100644
--- a/libcsoap/soap-nudp.h
+++ b/libcsoap/soap-nudp.h
@@ -1,5 +1,5 @@
/******************************************************************
-* $Id: soap-nudp.h,v 1.2 2006/11/23 15:27:33 m0gg Exp $
+* $Id: soap-nudp.h,v 1.3 2006/11/26 20:13:05 m0gg Exp $
*
* CSOAP Project: A SOAP client/server library in C
* Copyright (C) 2007 Heiko Ronsdorf
@@ -21,23 +21,27 @@
*
* Email: hero@persua.de
******************************************************************/
-#ifndef __soap_nudp_h
-#define __soap_nudp_h
+#ifndef __csoap_nudp_h
+#define __csoap_nudp_h
+
+#ifdef __CSOAP_INTERNAL
+
+#define NUDP_ARG_PORT "-NUDPport"
+
+#define NUDP_DEFAULT_PORT 10001
#ifdef __cplusplus
extern "C" {
#endif
extern herror_t soap_nudp_server_init_args(int argc, char **argv);
-extern herror_t soap_nudp_server_run(void);
+extern void *soap_nudp_server_run(void *unused);
+extern herror_t soap_nudp_server_run_threaded(void);
extern void soap_nudp_server_destroy(void);
-#ifdef __CSOAP_INTERNAL
extern herror_t soap_nudp_register(const void *data);
-#endif
extern herror_t soap_nudp_client_init_args(int argc, char **argv);
-extern herror_t soap_nudp_client_invoke(struct SoapCtx *req, struct SoapCtx **res);
extern void soap_nudp_client_destroy(void);
#ifdef __cplusplus
@@ -45,3 +49,5 @@ extern void soap_nudp_client_destroy(void);
#endif
#endif
+
+#endif
diff --git a/libcsoap/soap-server.c b/libcsoap/soap-server.c
index 2f7a0b2..cee9643 100644
--- a/libcsoap/soap-server.c
+++ b/libcsoap/soap-server.c
@@ -1,5 +1,5 @@
/******************************************************************
-* $Id: soap-server.c,v 1.32 2006/11/25 15:06:57 m0gg Exp $
+* $Id: soap-server.c,v 1.33 2006/11/26 20:13:05 m0gg Exp $
*
* CSOAP Project: A SOAP client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -163,6 +163,7 @@ soap_server_process(struct SoapCtx *request, struct SoapCtx **response)
log_verbose2("urn: \"%s\"", urn);
if ((to = soap_addressing_get_to_address_string(request->env)))
{
+ log_verbose2("searching router for \"%s\"", to);
if ((router = soap_server_find_router(to)))
{
log_verbose2("router: %p", router);
@@ -173,7 +174,7 @@ soap_server_process(struct SoapCtx *request, struct SoapCtx **response)
{
if ((*response)->env == NULL)
{
- sprintf(buffer, "Service \"%s\" returned no envelope", urn);
+ sprintf(buffer, "Service for \"%s\" returned no envelope", urn);
_soap_server_env_new_with_fault("Internal service error", buffer, &((*response)->env));
}
}
diff --git a/libcsoap/soap-transport.c b/libcsoap/soap-transport.c
index 6b0444b..3cd46e8 100644
--- a/libcsoap/soap-transport.c
+++ b/libcsoap/soap-transport.c
@@ -1,5 +1,5 @@
/******************************************************************
-* $Id: soap-transport.c,v 1.4 2006/11/25 17:03:20 m0gg Exp $
+* $Id: soap-transport.c,v 1.5 2006/11/26 20:13:05 m0gg Exp $
*
* CSOAP Project: A SOAP client/server library in C
* Copyright (C) 2007 Heiko Ronsdorf
@@ -33,6 +33,10 @@
#include <string.h>
#endif
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
#include <libxml/tree.h>
#include <libxml/uri.h>
@@ -85,7 +89,7 @@ _soap_transport_new(const char *scheme, void *data, msg_exchange invoke)
return ret;
}
-static void *
+/* static void *
_soap_transport_destroy(struct soap_transport *transport)
{
void *ret;
@@ -98,8 +102,7 @@ _soap_transport_destroy(struct soap_transport *transport)
free(transport);
return ret;
-}
-
+} */
herror_t
soap_transport_process(struct SoapCtx *request, struct SoapCtx **response)
@@ -181,15 +184,16 @@ soap_transport_server_run(void)
{
herror_t status;
- if ((status = soap_nhttp_server_run()) != H_OK)
+ if ((status = soap_nudp_server_run_threaded()) != H_OK)
{
- log_error2("soap_nhttp_server_run failed (%s)", herror_message(status));
+ log_error2("soap_nudp_server_run failed (%s)", herror_message(status));
return status;
}
- if ((status = soap_nudp_server_run()) != H_OK)
+ /* nanoHTTP blocks in this call */
+ if ((status = soap_nhttp_server_run()) != H_OK)
{
- log_error2("soap_nudp_server_run failed (%s)", herror_message(status));
+ log_error2("soap_nhttp_server_run failed (%s)", herror_message(status));
return status;
}
diff --git a/libcsoap/soap-xml.c b/libcsoap/soap-xml.c
index e4cc894..f718faf 100644
--- a/libcsoap/soap-xml.c
+++ b/libcsoap/soap-xml.c
@@ -1,5 +1,5 @@
/******************************************************************
-* $Id: soap-xml.c,v 1.12 2006/11/23 15:27:33 m0gg Exp $
+* $Id: soap-xml.c,v 1.13 2006/11/26 20:13:05 m0gg Exp $
*
* CSOAP Project: A SOAP client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -25,6 +25,7 @@
#include <config.h>
#endif
+#include <libxml/tree.h>
#include <libxml/xpath.h>
#include <libxml/xpathInternals.h>
@@ -33,32 +34,35 @@
#include "soap-xml.h"
xmlNodePtr
-soap_xml_get_children(xmlNodePtr param)
+soap_xml_get_children(xmlNodePtr node)
{
- xmlNodePtr children;
+ xmlNodePtr child;
- if (param == NULL)
+ if (node == NULL)
{
- log_error1("Invalid parameter 'param' (null)");
+ log_error1("Invalid node (null)");
return NULL;
}
- children = param->xmlChildrenNode;
- while (children != NULL)
+ for (child = node->children; child; child=child->next)
{
- if (children->type != XML_ELEMENT_NODE)
- children = children->next;
- else
- break;
+ if (child->type == XML_ELEMENT_NODE)
+ return child;
}
- return children;
+ return NULL;
}
xmlNodePtr
soap_xml_get_next(xmlNodePtr param)
{
+ if (param == NULL)
+ {
+ log_error1("Invalid node (null)");
+ return NULL;
+ }
+
xmlNodePtr node = param->next;
while (node != NULL)
diff --git a/nanohttp/nanohttp-common.h b/nanohttp/nanohttp-common.h
index 1afd7d5..ad00750 100644
--- a/nanohttp/nanohttp-common.h
+++ b/nanohttp/nanohttp-common.h
@@ -1,5 +1,5 @@
/******************************************************************
- * $Id: nanohttp-common.h,v 1.37 2006/11/25 17:03:20 m0gg Exp $
+ * $Id: nanohttp-common.h,v 1.38 2006/11/26 20:13:05 m0gg Exp $
*
* CSOAP Project: A http client/server library in C
* Copyright (C) 2003-2004 Ferhat Ayaz
@@ -28,7 +28,7 @@
#define HEADER_CONTENT_TRANSFER_ENCODING "Content-Transfer-Encoding"
#define TRANSFER_ENCODING_CHUNKED "chunked"
-/**
+/** @file
*
* General Header Fields
*
diff --git a/nanohttp/nanohttp-request.h b/nanohttp/nanohttp-request.h
index d1d599b..3f6afba 100755
--- a/nanohttp/nanohttp-request.h
+++ b/nanohttp/nanohttp-request.h
@@ -1,5 +1,5 @@
/******************************************************************
- * $Id: nanohttp-request.h,v 1.11 2006/11/25 15:06:58 m0gg Exp $
+ * $Id: nanohttp-request.h,v 1.12 2006/11/26 20:13:05 m0gg Exp $
*
* CSOAP Project: A http client/server library in C
* Copyright (C) 2003-2004 Ferhat Ayaz
@@ -24,7 +24,7 @@
#ifndef __nhttp_request_h
#define __nhttp_request_h
-/**
+/** @file
*
* Request Header Fields
*
diff --git a/nanohttp/nanohttp-response.h b/nanohttp/nanohttp-response.h
index edc48fc..88f9c4f 100755
--- a/nanohttp/nanohttp-response.h
+++ b/nanohttp/nanohttp-response.h
@@ -1,5 +1,5 @@
/******************************************************************
- * $Id: nanohttp-response.h,v 1.10 2006/11/25 15:06:58 m0gg Exp $
+ * $Id: nanohttp-response.h,v 1.11 2006/11/26 20:13:06 m0gg Exp $
*
* CSOAP Project: A http client/server library in C
* Copyright (C) 2003-2004 Ferhat Ayaz
@@ -24,7 +24,7 @@
#ifndef __nanohttp_response_h
#define __nanohttp_response_h
-/**
+/** @file
*
* Response Header Fields
*
@@ -176,9 +176,10 @@ extern "C" {
#ifdef __NHTTP_INTERNAL
extern herror_t hresponse_new_from_socket(struct hsocket_t *sock, hresponse_t **out);
-extern void hresponse_free(hresponse_t * res);
#endif
+extern void hresponse_free(hresponse_t * res);
+
#ifdef __cplusplus
}
#endif
diff --git a/nanohttp/nanohttp-server.c b/nanohttp/nanohttp-server.c
index c144acf..b0e650d 100644
--- a/nanohttp/nanohttp-server.c
+++ b/nanohttp/nanohttp-server.c
@@ -1,5 +1,5 @@
/******************************************************************
-* $Id: nanohttp-server.c,v 1.68 2006/11/25 16:35:57 m0gg Exp $
+* $Id: nanohttp-server.c,v 1.69 2006/11/26 20:13:06 m0gg Exp $
*
* CSOAP Project: A http client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -145,11 +145,15 @@ static pthread_mutex_t _httpd_connection_lock;
static void _sys_sleep(int secs)
{
Sleep(secs*1000);
+
+ return;
}
#else
static inline void _sys_sleep(int secs)
{
sleep(secs);
+
+ return;
}
#endif
@@ -229,8 +233,6 @@ httpd_init(int argc, char **argv)
return status;
}
- log_verbose2("socket bind to port '%d'", _httpd_port);
-
_httpd_connection_slots_init();
if ((status = _httpd_register_builtin_services(argc, argv)) != H_OK)
diff --git a/nanohttp/nanohttp-socket.c b/nanohttp/nanohttp-socket.c
index c5c4b98..3fd600b 100644
--- a/nanohttp/nanohttp-socket.c
+++ b/nanohttp/nanohttp-socket.c
@@ -1,5 +1,5 @@
/******************************************************************
-* $Id: nanohttp-socket.c,v 1.64 2006/11/25 15:06:58 m0gg Exp $
+* $Id: nanohttp-socket.c,v 1.65 2006/11/26 20:13:06 m0gg Exp $
*
* CSOAP Project: A http client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -85,6 +85,8 @@ typedef int ssize_t;
#include "nanohttp-common.h"
#include "nanohttp-socket.h"
#include "nanohttp-ssl.h"
+#include "nanohttp-request.h"
+#include "nanohttp-server.h"
#ifdef WIN32
static void
diff --git a/nanohttp/nanohttp-socket.h b/nanohttp/nanohttp-socket.h
index d68da0a..db2bf31 100644
--- a/nanohttp/nanohttp-socket.h
+++ b/nanohttp/nanohttp-socket.h
@@ -1,5 +1,5 @@
/******************************************************************
- * $Id: nanohttp-socket.h,v 1.32 2006/11/24 17:28:07 m0gg Exp $
+ * $Id: nanohttp-socket.h,v 1.33 2006/11/26 20:13:06 m0gg Exp $
*
* CSOAP Project: A http client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -191,7 +191,7 @@ extern herror_t hsocket_nsend(struct hsocket_t *sock, const unsigned char *bytes
*/
extern herror_t hsocket_send(struct hsocket_t *sock, const char *str);
-extern int hsocket_select_read(int sock, char *buf, size_t len);
+extern int hsocket_select_recv(int sock, char *buf, size_t len);
/**
*
diff --git a/nanohttp/nanohttp-ssl.c b/nanohttp/nanohttp-ssl.c
index 7967bfb..1a98ed5 100644
--- a/nanohttp/nanohttp-ssl.c
+++ b/nanohttp/nanohttp-ssl.c
@@ -1,5 +1,5 @@
/******************************************************************
-* $Id: nanohttp-ssl.c,v 1.31 2006/11/25 15:06:58 m0gg Exp $
+* $Id: nanohttp-ssl.c,v 1.32 2006/11/26 20:13:06 m0gg Exp $
*
* CSOAP Project: A http client/server library in C
* Copyright (C) 2001-2005 Rochester Institute of Technology
@@ -29,6 +29,10 @@
#include <sys/types.h>
#endif
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/socket.h>
+#endif
+
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif