From 949a8d0b46d6baa9f42c2f8c3bd5e3bdc3596cbd Mon Sep 17 00:00:00 2001 From: m0gg Date: Sun, 19 Nov 2006 09:40:14 +0000 Subject: nanohttp admin patch; code cleanup --- libcsoap/soap-admin.c | 48 ++++++++++++++++++++++++--------- libcsoap/soap-admin.h | 6 ++++- libcsoap/soap-client.c | 17 ++++++++++-- libcsoap/soap-ctx.c | 14 +++++++++- libcsoap/soap-ctx.h | 5 +--- libcsoap/soap-env.c | 12 ++++++++- libcsoap/soap-router.c | 19 ++++++++++++- libcsoap/soap-router.h | 3 +-- libcsoap/soap-server.c | 21 +++++++++++++-- libcsoap/soap-server.h | 6 ++--- libcsoap/soap-service.c | 72 ++++++++++++++++++++++++++----------------------- 11 files changed, 160 insertions(+), 63 deletions(-) (limited to 'libcsoap') diff --git a/libcsoap/soap-admin.c b/libcsoap/soap-admin.c index 65e07c9..7b2c9e8 100644 --- a/libcsoap/soap-admin.c +++ b/libcsoap/soap-admin.c @@ -1,5 +1,5 @@ /****************************************************************** -* $Id: soap-admin.c,v 1.4 2006/05/15 06:45:07 m0gg Exp $ +* $Id: soap-admin.c,v 1.5 2006/11/19 09:40:14 m0gg Exp $ * * CSOAP Project: A SOAP client/server library in C * Copyright (C) 2003 Ferhat Ayaz @@ -25,16 +25,29 @@ #include #endif +#ifdef HAVE_SYS_TIME_H +#include +#endif + +#ifdef HAVE_STDIO_H +#include +#endif + +#ifdef HAVE_NETINET_IN_H +#include +#endif + +#include +#include +#include +#include #include +#include #include "soap-router.h" #include "soap-server.h" #include "soap-admin.h" -#define SOAP_ADMIN_QUERY_ROUTERS "routers" -#define SOAP_ADMIN_QUERY_ROUTER "router" -#define SOAP_ADMIN_QUERY_SERVICES "services" - static void _soap_admin_send_title(httpd_conn_t *conn, const char *title) { @@ -52,6 +65,8 @@ _soap_admin_send_title(httpd_conn_t *conn, const char *title) "csoap "); http_output_stream_write_string(conn->out, title); http_output_stream_write_string(conn->out, "
"); + + return; } @@ -66,13 +81,15 @@ _soap_admin_list_routers(httpd_conn_t *conn) http_output_stream_write_string(conn->out, "
    "); for (node = soap_server_get_routers(); node; node = node->next) { - sprintf(buffer, "
  • %s - [Service Description]
  • ", - node->context, node->context, node->context); + sprintf(buffer, "
  • %s - [Service Description] - [Statistics]
  • ", + node->context, node->context, node->context, node->context); http_output_stream_write_string(conn->out, buffer); } http_output_stream_write_string(conn->out, "
"); http_output_stream_write_string(conn->out, ""); + + return; } @@ -108,6 +125,8 @@ _soap_admin_list_services(httpd_conn_t *conn, const char *routername) http_output_stream_write_string(conn->out, ""); http_output_stream_write_string(conn->out, ""); + + return; } @@ -128,13 +147,16 @@ _soap_admin_handle_get(httpd_conn_t * conn, hrequest_t * req) { _soap_admin_send_title(conn, "Welcome to the admin site"); - http_output_stream_write_string(conn->out, "
    "); http_output_stream_write_string(conn->out, - "
  • Routers
  • "); - http_output_stream_write_string(conn->out, "
"); + ""); http_output_stream_write_string(conn->out, ""); } + + return; } @@ -151,21 +173,21 @@ _soap_admin_entry(httpd_conn_t * conn, hrequest_t * req) http_output_stream_write_string(conn->out, "" "" - "" - "" + "" + "" "

Sorry!

" "
" "
POST Service is not implemented now. Use your browser
" "" ""); } + return; } herror_t soap_admin_init_args(int argc, char **argv) { - int i; for (i=0; i #endif +#ifdef HAVE_SYS_TIME_H +#include +#endif + #ifdef HAVE_STRING_H #include #endif @@ -33,8 +37,17 @@ #include #endif -#include +#ifdef HAVE_NETINET_IN_H +#include +#endif + +#include +#include +#include +#include +#include #include +#include #include "soap-client.h" diff --git a/libcsoap/soap-ctx.c b/libcsoap/soap-ctx.c index 393dceb..28c779f 100755 --- a/libcsoap/soap-ctx.c +++ b/libcsoap/soap-ctx.c @@ -1,5 +1,5 @@ /****************************************************************** - * $Id: soap-ctx.c,v 1.10 2006/07/09 16:24:19 snowdrop Exp $ + * $Id: soap-ctx.c,v 1.11 2006/11/19 09:40:14 m0gg Exp $ * * CSOAP Project: A SOAP client/server library in C * Copyright (C) 2003-2004 Ferhat Ayaz @@ -25,6 +25,10 @@ #include #endif +#ifdef HAVE_SYS_TIME_H +#include +#endif + #ifdef HAVE_STDIO_H #include #endif @@ -37,6 +41,14 @@ #include #endif +#ifdef HAVE_NETINET_IN_H +#include +#endif + +#include +#include +#include +#include #include #include "soap-ctx.h" diff --git a/libcsoap/soap-ctx.h b/libcsoap/soap-ctx.h index d418037..a70a88f 100755 --- a/libcsoap/soap-ctx.h +++ b/libcsoap/soap-ctx.h @@ -1,5 +1,5 @@ /****************************************************************** - * $Id: soap-ctx.h,v 1.9 2006/03/06 13:37:38 m0gg Exp $ + * $Id: soap-ctx.h,v 1.10 2006/11/19 09:40:14 m0gg Exp $ * * CSOAP Project: A SOAP client/server library in C * Copyright (C) 2003-2004 Ferhat Ayaz @@ -24,9 +24,6 @@ #ifndef cSOAP_CTX_H #define cSOAP_CTX_H -#include -#include - #include #define SOAP_ERROR_NO_FILE_ATTACHED 4001 diff --git a/libcsoap/soap-env.c b/libcsoap/soap-env.c index 0536065..abff67e 100644 --- a/libcsoap/soap-env.c +++ b/libcsoap/soap-env.c @@ -1,5 +1,5 @@ /****************************************************************** -* $Id: soap-env.c,v 1.20 2006/07/09 16:24:19 snowdrop Exp $ +* $Id: soap-env.c,v 1.21 2006/11/19 09:40:14 m0gg Exp $ * * CSOAP Project: A SOAP client/server library in C * Copyright (C) 2003 Ferhat Ayaz @@ -25,6 +25,10 @@ #include #endif +#ifdef HAVE_SYS_TYPES_H +#include +#endif + #ifdef HAVE_STDARG_H #include #endif @@ -41,6 +45,10 @@ #include #endif +#ifdef HAVE_NETINET_IN_H +#include +#endif + #ifdef WIN32 #define USE_XMLSTRING #endif @@ -49,6 +57,8 @@ #include #endif +#include +#include #include #include "soap-xml.h" diff --git a/libcsoap/soap-router.c b/libcsoap/soap-router.c index cd0cca4..9f67460 100644 --- a/libcsoap/soap-router.c +++ b/libcsoap/soap-router.c @@ -1,5 +1,5 @@ /****************************************************************** -* $Id: soap-router.c,v 1.10 2006/07/09 16:24:19 snowdrop Exp $ +* $Id: soap-router.c,v 1.11 2006/11/19 09:40:14 m0gg Exp $ * * CSOAP Project: A SOAP client/server library in C * Copyright (C) 2003 Ferhat Ayaz @@ -25,14 +25,31 @@ #include #endif +#ifdef HAVE_SYS_TIME_H +#include +#endif + +#ifdef HAVE_STDIO_H +#include +#endif + #ifdef HAVE_STRING_H #include #endif +#ifdef HAVE_NETINET_IN_H +#include +#endif + #ifdef HAVE_ERRNO_H #include #endif +#include +#include +#include +#include +#include #include #include "soap-router.h" diff --git a/libcsoap/soap-router.h b/libcsoap/soap-router.h index d75979a..3c8b6f7 100644 --- a/libcsoap/soap-router.h +++ b/libcsoap/soap-router.h @@ -1,5 +1,5 @@ /****************************************************************** - * $Id: soap-router.h,v 1.8 2006/05/15 06:41:34 m0gg Exp $ + * $Id: soap-router.h,v 1.9 2006/11/19 09:40:14 m0gg Exp $ * * CSOAP Project: A SOAP client/server library in C * Copyright (C) 2003 Ferhat Ayaz @@ -39,7 +39,6 @@ typedef struct _SoapRouter xmlDocPtr wsdl; } SoapRouter; - #ifdef __cplusplus extern "C" { #endif diff --git a/libcsoap/soap-server.c b/libcsoap/soap-server.c index 5448de7..e0297b3 100644 --- a/libcsoap/soap-server.c +++ b/libcsoap/soap-server.c @@ -1,5 +1,5 @@ /****************************************************************** -* $Id: soap-server.c,v 1.26 2006/07/09 16:24:19 snowdrop Exp $ +* $Id: soap-server.c,v 1.27 2006/11/19 09:40:14 m0gg Exp $ * * CSOAP Project: A SOAP client/server library in C * Copyright (C) 2003 Ferhat Ayaz @@ -25,6 +25,14 @@ #include #endif +#ifdef HAVE_SYS_TIME_H +#include +#endif + +#ifdef HAVE_STDIO_H +#include +#endif + #ifdef HAVE_STRING_H #include #endif @@ -33,12 +41,21 @@ #include #endif +#ifdef HAVE_NETINET_IN_H +#include +#endif + #ifdef WIN32 #define snprintf(buffer, num, s1, s2) sprintf(buffer, s1,s2) #endif -#include +#include +#include +#include +#include +#include #include +#include #include "soap-admin.h" #include "soap-server.h" diff --git a/libcsoap/soap-server.h b/libcsoap/soap-server.h index 01f3e66..738db1a 100644 --- a/libcsoap/soap-server.h +++ b/libcsoap/soap-server.h @@ -1,5 +1,5 @@ /****************************************************************** - * $Id: soap-server.h,v 1.10 2006/03/29 08:35:56 m0gg Exp $ + * $Id: soap-server.h,v 1.11 2006/11/19 09:40:14 m0gg Exp $ * * CSOAP Project: A SOAP client/server library in C * Copyright (C) 2003 Ferhat Ayaz @@ -82,14 +82,14 @@ SoapRouterNode * soap_server_get_routers(void); Enters the server loop and starts to listen to http requests. */ -herror_t soap_server_run(); +herror_t soap_server_run(void); int soap_server_get_port(void); /** Frees the soap server. */ -void soap_server_destroy(); +void soap_server_destroy(void); #ifdef __cplusplus } diff --git a/libcsoap/soap-service.c b/libcsoap/soap-service.c index e2a486a..dc3a2a5 100644 --- a/libcsoap/soap-service.c +++ b/libcsoap/soap-service.c @@ -1,5 +1,5 @@ /****************************************************************** -* $Id: soap-service.c,v 1.8 2006/07/09 16:24:19 snowdrop Exp $ +* $Id: soap-service.c,v 1.9 2006/11/19 09:40:14 m0gg Exp $ * * CSOAP Project: A SOAP client/server library in C * Copyright (C) 2003 Ferhat Ayaz @@ -25,12 +25,27 @@ #include #endif +#ifdef HAVE_SYS_TIME_H +#include +#endif + +#ifdef HAVE_STDIO_H +#include +#endif + #ifdef HAVE_STRING_H #include #endif -#include +#ifdef HAVE_NETINET_IN_H +#include +#endif + #include +#include +#include +#include +#include #include "soap-service.h" @@ -39,66 +54,57 @@ soap_service_node_new(SoapService * service, SoapServiceNode * next) { SoapServiceNode *node; - node = (SoapServiceNode *) malloc(sizeof(SoapServiceNode)); + if (!(node = (SoapServiceNode *) malloc(sizeof(SoapServiceNode)))) { + + log_error2("malloc failed (%s)", strerror(errno)); + return NULL; + } node->service = service; node->next = next; return node; } - - - SoapService * soap_service_new(const char *urn, const char *method, SoapServiceFunc f) { SoapService *service; + if (!(service = (SoapService *) malloc(sizeof(SoapService)))) { + + log_error2("malloc failed (%s)", strerror(errno)); + return NULL; + } - service = (SoapService *) malloc(sizeof(SoapService)); service->func = f; - if (urn != NULL) - { - service->urn = (char *) malloc(strlen(urn) + 1); - strcpy(service->urn, urn); - } - else - { + if (urn == NULL) { + log_warn1("urn is NULL"); - service->urn = ""; + urn = ""; } + service->urn = strdup(urn); + + if (method == NULL) { - if (method != NULL) - { - service->method = (char *) malloc(strlen(method) + 1); - strcpy(service->method, method); - } - else - { log_warn1("method is NULL"); - service->method = ""; + method = ""; } + service->method = strdup(method); return service; } - - void soap_service_free(SoapService * service) { - log_verbose2("enter: service=%p", service); - if (service == NULL) return; - if (strcmp(service->urn, "")) - free(service->urn); - - if (strcmp(service->method, "")) - free(service->method); + free(service->urn); + free(service->method); free(service); - log_verbose1("leave with success"); + + return; } -- cgit v1.1-32-gdbae