From 8a6946b18003fae6400a137389f0cb13d0ac4bd6 Mon Sep 17 00:00:00 2001 From: m0gg Date: Sat, 3 Nov 2007 22:40:09 +0000 Subject: Split nanoHTTP and cSOAP logging --- Makefile.in | 2 +- TODO | 8 +- config.h.in | 3 + configure.ac | 2 +- examples/csoap/Makefile.in | 2 +- examples/csoap/echoattachments-server.c | 4 +- examples/csoap/simpleserver.c | 4 +- examples/nanohttp/Makefile.in | 2 +- examples/nanohttp/http_client.c | 5 +- examples/nanohttp/http_server.c | 7 +- examples/nanohttp/mime_client.c | 6 +- libcsoap/Makefile.am | 40 +++- libcsoap/Makefile.in | 171 ++++++++------- libcsoap/soap-addressing.c | 20 +- libcsoap/soap-admin.c | 74 +++---- libcsoap/soap-admin.h | 24 ++- libcsoap/soap-client.c | 34 +-- libcsoap/soap-ctx.c | 6 +- libcsoap/soap-env.c | 120 +++-------- libcsoap/soap-fault.c | 18 +- libcsoap/soap-logging.c | 150 +++++++++++++ libcsoap/soap-logging.h | 150 +++++++++++++ libcsoap/soap-nhttp.c | 33 +-- libcsoap/soap-nudp.c | 34 +-- libcsoap/soap-router.c | 26 +-- libcsoap/soap-server.c | 36 ++-- libcsoap/soap-server.h | 83 ++++---- libcsoap/soap-service.c | 12 +- libcsoap/soap-transport.c | 42 ++-- libcsoap/soap-transport.h | 6 +- libcsoap/soap-xml.c | 33 +-- libcsoap/soap-xml.h | 20 +- libcsoap/soap-xmlsec.c | 116 +++++----- libcsoap/soap-xmlsec.h | 170 +++++++-------- nanohttp/Makefile.am | 34 ++- nanohttp/Makefile.in | 142 ++++++------- nanohttp/nanohttp-admin.c | 124 +++++++++-- nanohttp/nanohttp-admin.h | 100 +++++---- nanohttp/nanohttp-base64.c | 5 +- nanohttp/nanohttp-base64.h | 44 ++-- nanohttp/nanohttp-client.c | 45 ++-- nanohttp/nanohttp-client.h | 13 +- nanohttp/nanohttp-common.c | 23 +- nanohttp/nanohttp-common.h | 366 +++++++++++--------------------- nanohttp/nanohttp-error.c | 11 +- nanohttp/nanohttp-error.h | 39 ++-- nanohttp/nanohttp-logging.c | 209 ++++++++---------- nanohttp/nanohttp-logging.h | 162 +++++++------- nanohttp/nanohttp-mime.c | 45 ++-- nanohttp/nanohttp-mime.h | 25 ++- nanohttp/nanohttp-request.c | 15 +- nanohttp/nanohttp-request.h | 25 ++- nanohttp/nanohttp-response.c | 15 +- nanohttp/nanohttp-response.h | 44 ++-- nanohttp/nanohttp-server.c | 107 +++++----- nanohttp/nanohttp-server.h | 177 +++++++++------ nanohttp/nanohttp-socket.c | 39 ++-- nanohttp/nanohttp-socket.h | 127 ++++------- nanohttp/nanohttp-ssl.c | 57 ++--- nanohttp/nanohttp-ssl.h | 99 ++++----- nanohttp/nanohttp-stream.c | 29 +-- nanohttp/nanohttp-stream.h | 158 +++++--------- nanohttp/nanohttp-url.c | 27 +-- nanohttp/nanohttp-url.h | 87 +++----- wsdl2c/Makefile.in | 2 +- 65 files changed, 2012 insertions(+), 1846 deletions(-) create mode 100644 libcsoap/soap-logging.c create mode 100644 libcsoap/soap-logging.h diff --git a/Makefile.in b/Makefile.in index 53739b8..0c32702 100644 --- a/Makefile.in +++ b/Makefile.in @@ -15,7 +15,7 @@ @SET_MAKE@ # -# $Revision: 1.1 $ +# $Revision: 1.2 $ # diff --git a/TODO b/TODO index abe2b30..291cb0b 100644 --- a/TODO +++ b/TODO @@ -1,4 +1,4 @@ -$Id: TODO,v 1.18 2007/01/03 13:41:52 m0gg Exp $ +$Id: TODO,v 1.19 2007/11/03 22:40:09 m0gg Exp $ =============================================================================== Things to do _before_ 1.2 release: @@ -7,6 +7,8 @@ Things to do _before_ 1.2 release: nanohttp: --------- - improve error handling!!!! + - write tests (for each??) error case + - trigger tests after build - cleanup/improve nanohttp request parsing - "GET http://fdqn/service HTTP/1.1" segfaults - Check portability to Win32/MaxOS (only tested on FreeBSD/Solaris/Linux) @@ -44,14 +46,14 @@ Additional things that could be done: ===================================== nanohttp: ---------- +========= - add DIME attachments (SOAP MTOM) - add BASE64 decoding for MIME attachments (?) - cleanup circular module dependencies - e.g. nanohttp-stream should hide hsocket, hssl csoap: ------- +====== - add examples from http://www.xmethods.org (Google, UDDI) - soap-nudp.c one thread per request (see soap_nudp_server_run) - http://www.ws-i.org/Profiles/BasicProfile-1.0.html conformance testing diff --git a/config.h.in b/config.h.in index 4353094..70e5ae5 100644 --- a/config.h.in +++ b/config.h.in @@ -133,6 +133,9 @@ /* Define to 1 if you have the `strtol' function. */ #undef HAVE_STRTOL +/* Define to 1 if you have the header file. */ +#undef HAVE_SYSLOG_H + /* Define to 1 if you have the header file. */ #undef HAVE_SYS_SELECT_H diff --git a/configure.ac b/configure.ac index 45e4b9a..7c00430 100644 --- a/configure.ac +++ b/configure.ac @@ -43,7 +43,7 @@ dnl checks for headers dnl AC_HEADER_STDC AC_HEADER_TIME -AC_CHECK_HEADERS([arpa/inet.h fcntl.h inttypes.h malloc.h netdb.h netinet/in.h stdint.h stdlib.h signal.h pthread.h string.h sys/socket.h sys/wait.h time.h sys/time.h unistd.h io.h stdio.h stdarg.h errno.h ctype.h openssl/ssl.h openssl/rand.h openssl/err.h]) +AC_CHECK_HEADERS([arpa/inet.h fcntl.h inttypes.h malloc.h netdb.h netinet/in.h stdint.h stdlib.h signal.h pthread.h string.h sys/socket.h sys/wait.h time.h sys/time.h unistd.h io.h stdio.h stdarg.h errno.h ctype.h openssl/ssl.h openssl/rand.h openssl/err.h syslog.h]) dnl dnl Checks for typedefs, structures, and compiler characteristics. diff --git a/examples/csoap/Makefile.in b/examples/csoap/Makefile.in index a2d9fa9..2d4062b 100644 --- a/examples/csoap/Makefile.in +++ b/examples/csoap/Makefile.in @@ -219,7 +219,7 @@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ # -# $Revision: 1.1 $ +# $Revision: 1.2 $ # LDADD = ../../nanohttp/libnanohttp.la ../../libcsoap/libcsoap.la INCLUDES = -I${top_srcdir} diff --git a/examples/csoap/echoattachments-server.c b/examples/csoap/echoattachments-server.c index e6b4872..7bda226 100755 --- a/examples/csoap/echoattachments-server.c +++ b/examples/csoap/echoattachments-server.c @@ -1,5 +1,5 @@ /****************************************************************** - * $Id: echoattachments-server.c,v 1.13 2007/01/01 22:54:46 m0gg Exp $ + * $Id: echoattachments-server.c,v 1.14 2007/11/03 22:40:09 m0gg Exp $ * * CSOAP Project: CSOAP examples project * Copyright (C) 2003-2004 Ferhat Ayaz @@ -72,7 +72,7 @@ main(int argc, char **argv) herror_t err; struct SoapRouter *router; - hlog_set_level(HLOG_VERBOSE); + nanohttp_log_set_loglevel(NANOHTTP_LOG_VERBOSE); err = soap_server_init_args(argc, argv); if (err != H_OK) diff --git a/examples/csoap/simpleserver.c b/examples/csoap/simpleserver.c index 0bd7341..6c6b154 100644 --- a/examples/csoap/simpleserver.c +++ b/examples/csoap/simpleserver.c @@ -1,5 +1,5 @@ /****************************************************************** - * $Id: simpleserver.c,v 1.29 2007/01/01 18:58:05 m0gg Exp $ + * $Id: simpleserver.c,v 1.30 2007/11/03 22:40:09 m0gg Exp $ * * CSOAP Project: CSOAP examples project * Copyright (C) 2003-2004 Ferhat Ayaz @@ -74,7 +74,7 @@ say_hello(struct SoapCtx *req, struct SoapCtx *res) soap_env_add_itemf(res->env, "xsd:string", "echo", "Hello '%s'", name); if (name) xmlFree(name); - node = soap_xml_get_next(node); + node = soap_xml_get_next_element(node); } printf("service request done\n"); diff --git a/examples/nanohttp/Makefile.in b/examples/nanohttp/Makefile.in index f918782..9f2aabe 100644 --- a/examples/nanohttp/Makefile.in +++ b/examples/nanohttp/Makefile.in @@ -200,7 +200,7 @@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ # -# $Revision: 1.1 $ +# $Revision: 1.2 $ # LDADD = ../../nanohttp/libnanohttp.la INCLUDES = -I${top_srcdir} diff --git a/examples/nanohttp/http_client.c b/examples/nanohttp/http_client.c index 1b9c912..adcd199 100644 --- a/examples/nanohttp/http_client.c +++ b/examples/nanohttp/http_client.c @@ -1,5 +1,5 @@ /****************************************************************** -* $Id: http_client.c,v 1.9 2006/12/10 19:21:06 m0gg Exp $ +* $Id: http_client.c,v 1.10 2007/11/03 22:40:09 m0gg Exp $ * * CSOAP Project: A http client/server library in C (example) * Copyright (C) 2003-2004 Ferhat Ayaz @@ -25,6 +25,7 @@ #include #include +#include #include #define MAX_BUFFER_SIZE 1024 @@ -105,7 +106,7 @@ int main(int argc, char **argv) } /* Set log level to see more information written by the library */ - hlog_set_level(HLOG_INFO); + nanohttp_log_set_loglevel(NANOHTTP_LOG_INFO); /* Initialize httpc module */ if (httpc_init(argc, argv)) diff --git a/examples/nanohttp/http_server.c b/examples/nanohttp/http_server.c index eb98d33..5daad9a 100644 --- a/examples/nanohttp/http_server.c +++ b/examples/nanohttp/http_server.c @@ -1,5 +1,5 @@ /****************************************************************** -* $Id: http_server.c,v 1.14 2007/01/05 09:02:50 m0gg Exp $ +* $Id: http_server.c,v 1.15 2007/11/03 22:40:09 m0gg Exp $ * * CSOAP Project: A http client/server library in C (example) * Copyright (C) 2003 Ferhat Ayaz @@ -25,6 +25,7 @@ #include #include +#include #include static int @@ -142,12 +143,12 @@ int main(int argc, char **argv) { herror_t status; - hlog_set_level(HLOG_INFO); + + nanohttp_log_set_loglevel(NANOHTTP_LOG_INFO); if (httpd_init(argc, argv)) { fprintf(stderr, "Cannot init httpd\n"); - httpd_destroy(); exit(1); } diff --git a/examples/nanohttp/mime_client.c b/examples/nanohttp/mime_client.c index e4d50ba..ffa8de7 100755 --- a/examples/nanohttp/mime_client.c +++ b/examples/nanohttp/mime_client.c @@ -1,5 +1,5 @@ /****************************************************************** -* $Id: mime_client.c,v 1.1 2007/01/03 21:31:44 m0gg Exp $ +* $Id: mime_client.c,v 1.2 2007/11/03 22:40:09 m0gg Exp $ * * CSOAP Project: A http client/server library in C (example) * Copyright (C) 2003 Ferhat Ayaz @@ -122,7 +122,7 @@ int main(int argc, char **argv) } /* Set log level to see more information written by the library */ - // log_set_level(HLOG_VERBOSE); + // log_set_level(NANOHTTP_LOG_VERBOSE); /* Initialize httpc module */ if ((status = httpc_init(argc, argv)) != H_OK) @@ -142,7 +142,7 @@ int main(int argc, char **argv) */ if ((status = httpc_mime_begin(conn, argv[1], argv[3], "", argv[4])) != H_OK) { - log_error2("Can not start MIME: %s\n", herror_message(status)); + fprintf(stderr, "Can not start MIME: %s\n", herror_message(status)); herror_release(status); exit(1); } diff --git a/libcsoap/Makefile.am b/libcsoap/Makefile.am index abcde74..a19775f 100644 --- a/libcsoap/Makefile.am +++ b/libcsoap/Makefile.am @@ -1,19 +1,41 @@ # -# $Revision: 1.15 $ +# $Revision: 1.16 $ # lib_LTLIBRARIES=libcsoap.la libcsoap_ladir=$(includedir)/libcsoap-@csoap_release@/libcsoap -libcsoap_la_SOURCES=soap-xml.c soap-fault.c soap-env.c soap-service.c \ - soap-router.c soap-client.c soap-server.c soap-ctx.c \ - soap-admin.c soap-addressing.c soap-transport.c \ - soap-nudp.c soap-nhttp.c soap-wsil.c +libcsoap_la_SOURCES=soap-addressing.c \ + soap-admin.c \ + soap-client.c \ + soap-ctx.c \ + soap-env.c \ + soap-fault.c \ + soap-logging.c \ + soap-nhttp.c \ + soap-nudp.c \ + soap-router.c \ + soap-service.c \ + soap-server.c \ + soap-transport.c \ + soap-wsil.c \ + soap-xml.c -libcsoap_la_HEADERS=soap-fault.h soap-env.h soap-service.h soap-router.h \ - soap-client.h soap-server.h soap-ctx.h soap-addressing.h \ - soap-transport.h soap-admin.h soap-wsil.h soap-nudp.h \ - soap-nhttp.h soap-xml.h +libcsoap_la_HEADERS=soap-addressing.h \ + soap-admin.h \ + soap-client.h \ + soap-ctx.h \ + soap-env.h \ + soap-fault.h \ + soap-logging.h \ + soap-nhttp.h \ + soap-nudp.h \ + soap-router.h \ + soap-service.h \ + soap-server.h \ + soap-transport.h \ + soap-wsil.h \ + soap-xml.h if BUILD_WITH_XMLSEC1 libcsoap_la_SOURCES+=soap-xmlsec.c diff --git a/libcsoap/Makefile.in b/libcsoap/Makefile.in index 093f5f6..1408cbb 100644 --- a/libcsoap/Makefile.in +++ b/libcsoap/Makefile.in @@ -59,19 +59,21 @@ am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(libcsoap_ladir)" libLTLIBRARIES_INSTALL = $(INSTALL) LTLIBRARIES = $(lib_LTLIBRARIES) libcsoap_la_LIBADD = -am__libcsoap_la_SOURCES_DIST = soap-xml.c soap-fault.c soap-env.c \ - soap-service.c soap-router.c soap-client.c soap-server.c \ - soap-ctx.c soap-admin.c soap-addressing.c soap-transport.c \ - soap-nudp.c soap-nhttp.c soap-wsil.c soap-xmlsec.c +am__libcsoap_la_SOURCES_DIST = soap-addressing.c soap-admin.c \ + soap-client.c soap-ctx.c soap-env.c soap-fault.c \ + soap-logging.c soap-nhttp.c soap-nudp.c soap-router.c \ + soap-service.c soap-server.c soap-transport.c soap-wsil.c \ + soap-xml.c soap-xmlsec.c @BUILD_WITH_XMLSEC1_TRUE@am__objects_1 = libcsoap_la-soap-xmlsec.lo -am_libcsoap_la_OBJECTS = libcsoap_la-soap-xml.lo \ - libcsoap_la-soap-fault.lo libcsoap_la-soap-env.lo \ - libcsoap_la-soap-service.lo libcsoap_la-soap-router.lo \ - libcsoap_la-soap-client.lo libcsoap_la-soap-server.lo \ - libcsoap_la-soap-ctx.lo libcsoap_la-soap-admin.lo \ - libcsoap_la-soap-addressing.lo libcsoap_la-soap-transport.lo \ - libcsoap_la-soap-nudp.lo libcsoap_la-soap-nhttp.lo \ - libcsoap_la-soap-wsil.lo $(am__objects_1) +am_libcsoap_la_OBJECTS = libcsoap_la-soap-addressing.lo \ + libcsoap_la-soap-admin.lo libcsoap_la-soap-client.lo \ + libcsoap_la-soap-ctx.lo libcsoap_la-soap-env.lo \ + libcsoap_la-soap-fault.lo libcsoap_la-soap-logging.lo \ + libcsoap_la-soap-nhttp.lo libcsoap_la-soap-nudp.lo \ + libcsoap_la-soap-router.lo libcsoap_la-soap-service.lo \ + libcsoap_la-soap-server.lo libcsoap_la-soap-transport.lo \ + libcsoap_la-soap-wsil.lo libcsoap_la-soap-xml.lo \ + $(am__objects_1) libcsoap_la_OBJECTS = $(am_libcsoap_la_OBJECTS) DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp @@ -86,10 +88,11 @@ LINK = $(LIBTOOL) --tag=CC --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ SOURCES = $(libcsoap_la_SOURCES) DIST_SOURCES = $(am__libcsoap_la_SOURCES_DIST) -am__libcsoap_la_HEADERS_DIST = soap-fault.h soap-env.h soap-service.h \ - soap-router.h soap-client.h soap-server.h soap-ctx.h \ - soap-addressing.h soap-transport.h soap-admin.h soap-wsil.h \ - soap-nudp.h soap-nhttp.h soap-xml.h soap-xmlsec.h +am__libcsoap_la_HEADERS_DIST = soap-addressing.h soap-admin.h \ + soap-client.h soap-ctx.h soap-env.h soap-fault.h \ + soap-logging.h soap-nhttp.h soap-nudp.h soap-router.h \ + soap-service.h soap-server.h soap-transport.h soap-wsil.h \ + soap-xml.h soap-xmlsec.h libcsoap_laHEADERS_INSTALL = $(INSTALL_HEADER) HEADERS = $(libcsoap_la_HEADERS) ETAGS = etags @@ -217,18 +220,18 @@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ # -# $Revision: 1.1 $ +# $Revision: 1.2 $ # lib_LTLIBRARIES = libcsoap.la libcsoap_ladir = $(includedir)/libcsoap-@csoap_release@/libcsoap -libcsoap_la_SOURCES = soap-xml.c soap-fault.c soap-env.c \ - soap-service.c soap-router.c soap-client.c soap-server.c \ - soap-ctx.c soap-admin.c soap-addressing.c soap-transport.c \ - soap-nudp.c soap-nhttp.c soap-wsil.c $(am__append_1) -libcsoap_la_HEADERS = soap-fault.h soap-env.h soap-service.h \ - soap-router.h soap-client.h soap-server.h soap-ctx.h \ - soap-addressing.h soap-transport.h soap-admin.h soap-wsil.h \ - soap-nudp.h soap-nhttp.h soap-xml.h $(am__append_2) +libcsoap_la_SOURCES = soap-addressing.c soap-admin.c soap-client.c \ + soap-ctx.c soap-env.c soap-fault.c soap-logging.c soap-nhttp.c \ + soap-nudp.c soap-router.c soap-service.c soap-server.c \ + soap-transport.c soap-wsil.c soap-xml.c $(am__append_1) +libcsoap_la_HEADERS = soap-addressing.h soap-admin.h soap-client.h \ + soap-ctx.h soap-env.h soap-fault.h soap-logging.h soap-nhttp.h \ + soap-nudp.h soap-router.h soap-service.h soap-server.h \ + soap-transport.h soap-wsil.h soap-xml.h $(am__append_2) libcsoap_la_LDFLAGS = -version-info @csoap_version@ -release @csoap_release@ libcsoap_la_CFLAGS = -I${top_srcdir} -D__CSOAP_INTERNAL=1 all: all-am @@ -306,6 +309,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcsoap_la-soap-ctx.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcsoap_la-soap-env.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcsoap_la-soap-fault.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcsoap_la-soap-logging.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcsoap_la-soap-nhttp.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcsoap_la-soap-nudp.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcsoap_la-soap-router.Plo@am__quote@ @@ -337,19 +341,33 @@ distclean-compile: @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< -libcsoap_la-soap-xml.lo: soap-xml.c -@am__fastdepCC_TRUE@ if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcsoap_la_CFLAGS) $(CFLAGS) -MT libcsoap_la-soap-xml.lo -MD -MP -MF "$(DEPDIR)/libcsoap_la-soap-xml.Tpo" -c -o libcsoap_la-soap-xml.lo `test -f 'soap-xml.c' || echo '$(srcdir)/'`soap-xml.c; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libcsoap_la-soap-xml.Tpo" "$(DEPDIR)/libcsoap_la-soap-xml.Plo"; else rm -f "$(DEPDIR)/libcsoap_la-soap-xml.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='soap-xml.c' object='libcsoap_la-soap-xml.lo' libtool=yes @AMDEPBACKSLASH@ +libcsoap_la-soap-addressing.lo: soap-addressing.c +@am__fastdepCC_TRUE@ if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcsoap_la_CFLAGS) $(CFLAGS) -MT libcsoap_la-soap-addressing.lo -MD -MP -MF "$(DEPDIR)/libcsoap_la-soap-addressing.Tpo" -c -o libcsoap_la-soap-addressing.lo `test -f 'soap-addressing.c' || echo '$(srcdir)/'`soap-addressing.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libcsoap_la-soap-addressing.Tpo" "$(DEPDIR)/libcsoap_la-soap-addressing.Plo"; else rm -f "$(DEPDIR)/libcsoap_la-soap-addressing.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='soap-addressing.c' object='libcsoap_la-soap-addressing.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcsoap_la_CFLAGS) $(CFLAGS) -c -o libcsoap_la-soap-xml.lo `test -f 'soap-xml.c' || echo '$(srcdir)/'`soap-xml.c +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcsoap_la_CFLAGS) $(CFLAGS) -c -o libcsoap_la-soap-addressing.lo `test -f 'soap-addressing.c' || echo '$(srcdir)/'`soap-addressing.c -libcsoap_la-soap-fault.lo: soap-fault.c -@am__fastdepCC_TRUE@ if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcsoap_la_CFLAGS) $(CFLAGS) -MT libcsoap_la-soap-fault.lo -MD -MP -MF "$(DEPDIR)/libcsoap_la-soap-fault.Tpo" -c -o libcsoap_la-soap-fault.lo `test -f 'soap-fault.c' || echo '$(srcdir)/'`soap-fault.c; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libcsoap_la-soap-fault.Tpo" "$(DEPDIR)/libcsoap_la-soap-fault.Plo"; else rm -f "$(DEPDIR)/libcsoap_la-soap-fault.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='soap-fault.c' object='libcsoap_la-soap-fault.lo' libtool=yes @AMDEPBACKSLASH@ +libcsoap_la-soap-admin.lo: soap-admin.c +@am__fastdepCC_TRUE@ if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcsoap_la_CFLAGS) $(CFLAGS) -MT libcsoap_la-soap-admin.lo -MD -MP -MF "$(DEPDIR)/libcsoap_la-soap-admin.Tpo" -c -o libcsoap_la-soap-admin.lo `test -f 'soap-admin.c' || echo '$(srcdir)/'`soap-admin.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libcsoap_la-soap-admin.Tpo" "$(DEPDIR)/libcsoap_la-soap-admin.Plo"; else rm -f "$(DEPDIR)/libcsoap_la-soap-admin.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='soap-admin.c' object='libcsoap_la-soap-admin.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcsoap_la_CFLAGS) $(CFLAGS) -c -o libcsoap_la-soap-fault.lo `test -f 'soap-fault.c' || echo '$(srcdir)/'`soap-fault.c +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcsoap_la_CFLAGS) $(CFLAGS) -c -o libcsoap_la-soap-admin.lo `test -f 'soap-admin.c' || echo '$(srcdir)/'`soap-admin.c + +libcsoap_la-soap-client.lo: soap-client.c +@am__fastdepCC_TRUE@ if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcsoap_la_CFLAGS) $(CFLAGS) -MT libcsoap_la-soap-client.lo -MD -MP -MF "$(DEPDIR)/libcsoap_la-soap-client.Tpo" -c -o libcsoap_la-soap-client.lo `test -f 'soap-client.c' || echo '$(srcdir)/'`soap-client.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libcsoap_la-soap-client.Tpo" "$(DEPDIR)/libcsoap_la-soap-client.Plo"; else rm -f "$(DEPDIR)/libcsoap_la-soap-client.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='soap-client.c' object='libcsoap_la-soap-client.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcsoap_la_CFLAGS) $(CFLAGS) -c -o libcsoap_la-soap-client.lo `test -f 'soap-client.c' || echo '$(srcdir)/'`soap-client.c + +libcsoap_la-soap-ctx.lo: soap-ctx.c +@am__fastdepCC_TRUE@ if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcsoap_la_CFLAGS) $(CFLAGS) -MT libcsoap_la-soap-ctx.lo -MD -MP -MF "$(DEPDIR)/libcsoap_la-soap-ctx.Tpo" -c -o libcsoap_la-soap-ctx.lo `test -f 'soap-ctx.c' || echo '$(srcdir)/'`soap-ctx.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libcsoap_la-soap-ctx.Tpo" "$(DEPDIR)/libcsoap_la-soap-ctx.Plo"; else rm -f "$(DEPDIR)/libcsoap_la-soap-ctx.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='soap-ctx.c' object='libcsoap_la-soap-ctx.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcsoap_la_CFLAGS) $(CFLAGS) -c -o libcsoap_la-soap-ctx.lo `test -f 'soap-ctx.c' || echo '$(srcdir)/'`soap-ctx.c libcsoap_la-soap-env.lo: soap-env.c @am__fastdepCC_TRUE@ if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcsoap_la_CFLAGS) $(CFLAGS) -MT libcsoap_la-soap-env.lo -MD -MP -MF "$(DEPDIR)/libcsoap_la-soap-env.Tpo" -c -o libcsoap_la-soap-env.lo `test -f 'soap-env.c' || echo '$(srcdir)/'`soap-env.c; \ @@ -358,12 +376,33 @@ libcsoap_la-soap-env.lo: soap-env.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcsoap_la_CFLAGS) $(CFLAGS) -c -o libcsoap_la-soap-env.lo `test -f 'soap-env.c' || echo '$(srcdir)/'`soap-env.c -libcsoap_la-soap-service.lo: soap-service.c -@am__fastdepCC_TRUE@ if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcsoap_la_CFLAGS) $(CFLAGS) -MT libcsoap_la-soap-service.lo -MD -MP -MF "$(DEPDIR)/libcsoap_la-soap-service.Tpo" -c -o libcsoap_la-soap-service.lo `test -f 'soap-service.c' || echo '$(srcdir)/'`soap-service.c; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libcsoap_la-soap-service.Tpo" "$(DEPDIR)/libcsoap_la-soap-service.Plo"; else rm -f "$(DEPDIR)/libcsoap_la-soap-service.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='soap-service.c' object='libcsoap_la-soap-service.lo' libtool=yes @AMDEPBACKSLASH@ +libcsoap_la-soap-fault.lo: soap-fault.c +@am__fastdepCC_TRUE@ if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcsoap_la_CFLAGS) $(CFLAGS) -MT libcsoap_la-soap-fault.lo -MD -MP -MF "$(DEPDIR)/libcsoap_la-soap-fault.Tpo" -c -o libcsoap_la-soap-fault.lo `test -f 'soap-fault.c' || echo '$(srcdir)/'`soap-fault.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libcsoap_la-soap-fault.Tpo" "$(DEPDIR)/libcsoap_la-soap-fault.Plo"; else rm -f "$(DEPDIR)/libcsoap_la-soap-fault.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='soap-fault.c' object='libcsoap_la-soap-fault.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcsoap_la_CFLAGS) $(CFLAGS) -c -o libcsoap_la-soap-service.lo `test -f 'soap-service.c' || echo '$(srcdir)/'`soap-service.c +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcsoap_la_CFLAGS) $(CFLAGS) -c -o libcsoap_la-soap-fault.lo `test -f 'soap-fault.c' || echo '$(srcdir)/'`soap-fault.c + +libcsoap_la-soap-logging.lo: soap-logging.c +@am__fastdepCC_TRUE@ if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcsoap_la_CFLAGS) $(CFLAGS) -MT libcsoap_la-soap-logging.lo -MD -MP -MF "$(DEPDIR)/libcsoap_la-soap-logging.Tpo" -c -o libcsoap_la-soap-logging.lo `test -f 'soap-logging.c' || echo '$(srcdir)/'`soap-logging.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libcsoap_la-soap-logging.Tpo" "$(DEPDIR)/libcsoap_la-soap-logging.Plo"; else rm -f "$(DEPDIR)/libcsoap_la-soap-logging.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='soap-logging.c' object='libcsoap_la-soap-logging.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcsoap_la_CFLAGS) $(CFLAGS) -c -o libcsoap_la-soap-logging.lo `test -f 'soap-logging.c' || echo '$(srcdir)/'`soap-logging.c + +libcsoap_la-soap-nhttp.lo: soap-nhttp.c +@am__fastdepCC_TRUE@ if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcsoap_la_CFLAGS) $(CFLAGS) -MT libcsoap_la-soap-nhttp.lo -MD -MP -MF "$(DEPDIR)/libcsoap_la-soap-nhttp.Tpo" -c -o libcsoap_la-soap-nhttp.lo `test -f 'soap-nhttp.c' || echo '$(srcdir)/'`soap-nhttp.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libcsoap_la-soap-nhttp.Tpo" "$(DEPDIR)/libcsoap_la-soap-nhttp.Plo"; else rm -f "$(DEPDIR)/libcsoap_la-soap-nhttp.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='soap-nhttp.c' object='libcsoap_la-soap-nhttp.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcsoap_la_CFLAGS) $(CFLAGS) -c -o libcsoap_la-soap-nhttp.lo `test -f 'soap-nhttp.c' || echo '$(srcdir)/'`soap-nhttp.c + +libcsoap_la-soap-nudp.lo: soap-nudp.c +@am__fastdepCC_TRUE@ if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcsoap_la_CFLAGS) $(CFLAGS) -MT libcsoap_la-soap-nudp.lo -MD -MP -MF "$(DEPDIR)/libcsoap_la-soap-nudp.Tpo" -c -o libcsoap_la-soap-nudp.lo `test -f 'soap-nudp.c' || echo '$(srcdir)/'`soap-nudp.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libcsoap_la-soap-nudp.Tpo" "$(DEPDIR)/libcsoap_la-soap-nudp.Plo"; else rm -f "$(DEPDIR)/libcsoap_la-soap-nudp.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='soap-nudp.c' object='libcsoap_la-soap-nudp.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcsoap_la_CFLAGS) $(CFLAGS) -c -o libcsoap_la-soap-nudp.lo `test -f 'soap-nudp.c' || echo '$(srcdir)/'`soap-nudp.c libcsoap_la-soap-router.lo: soap-router.c @am__fastdepCC_TRUE@ if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcsoap_la_CFLAGS) $(CFLAGS) -MT libcsoap_la-soap-router.lo -MD -MP -MF "$(DEPDIR)/libcsoap_la-soap-router.Tpo" -c -o libcsoap_la-soap-router.lo `test -f 'soap-router.c' || echo '$(srcdir)/'`soap-router.c; \ @@ -372,12 +411,12 @@ libcsoap_la-soap-router.lo: soap-router.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcsoap_la_CFLAGS) $(CFLAGS) -c -o libcsoap_la-soap-router.lo `test -f 'soap-router.c' || echo '$(srcdir)/'`soap-router.c -libcsoap_la-soap-client.lo: soap-client.c -@am__fastdepCC_TRUE@ if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcsoap_la_CFLAGS) $(CFLAGS) -MT libcsoap_la-soap-client.lo -MD -MP -MF "$(DEPDIR)/libcsoap_la-soap-client.Tpo" -c -o libcsoap_la-soap-client.lo `test -f 'soap-client.c' || echo '$(srcdir)/'`soap-client.c; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libcsoap_la-soap-client.Tpo" "$(DEPDIR)/libcsoap_la-soap-client.Plo"; else rm -f "$(DEPDIR)/libcsoap_la-soap-client.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='soap-client.c' object='libcsoap_la-soap-client.lo' libtool=yes @AMDEPBACKSLASH@ +libcsoap_la-soap-service.lo: soap-service.c +@am__fastdepCC_TRUE@ if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcsoap_la_CFLAGS) $(CFLAGS) -MT libcsoap_la-soap-service.lo -MD -MP -MF "$(DEPDIR)/libcsoap_la-soap-service.Tpo" -c -o libcsoap_la-soap-service.lo `test -f 'soap-service.c' || echo '$(srcdir)/'`soap-service.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libcsoap_la-soap-service.Tpo" "$(DEPDIR)/libcsoap_la-soap-service.Plo"; else rm -f "$(DEPDIR)/libcsoap_la-soap-service.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='soap-service.c' object='libcsoap_la-soap-service.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcsoap_la_CFLAGS) $(CFLAGS) -c -o libcsoap_la-soap-client.lo `test -f 'soap-client.c' || echo '$(srcdir)/'`soap-client.c +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcsoap_la_CFLAGS) $(CFLAGS) -c -o libcsoap_la-soap-service.lo `test -f 'soap-service.c' || echo '$(srcdir)/'`soap-service.c libcsoap_la-soap-server.lo: soap-server.c @am__fastdepCC_TRUE@ if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcsoap_la_CFLAGS) $(CFLAGS) -MT libcsoap_la-soap-server.lo -MD -MP -MF "$(DEPDIR)/libcsoap_la-soap-server.Tpo" -c -o libcsoap_la-soap-server.lo `test -f 'soap-server.c' || echo '$(srcdir)/'`soap-server.c; \ @@ -386,27 +425,6 @@ libcsoap_la-soap-server.lo: soap-server.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcsoap_la_CFLAGS) $(CFLAGS) -c -o libcsoap_la-soap-server.lo `test -f 'soap-server.c' || echo '$(srcdir)/'`soap-server.c -libcsoap_la-soap-ctx.lo: soap-ctx.c -@am__fastdepCC_TRUE@ if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcsoap_la_CFLAGS) $(CFLAGS) -MT libcsoap_la-soap-ctx.lo -MD -MP -MF "$(DEPDIR)/libcsoap_la-soap-ctx.Tpo" -c -o libcsoap_la-soap-ctx.lo `test -f 'soap-ctx.c' || echo '$(srcdir)/'`soap-ctx.c; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libcsoap_la-soap-ctx.Tpo" "$(DEPDIR)/libcsoap_la-soap-ctx.Plo"; else rm -f "$(DEPDIR)/libcsoap_la-soap-ctx.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='soap-ctx.c' object='libcsoap_la-soap-ctx.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcsoap_la_CFLAGS) $(CFLAGS) -c -o libcsoap_la-soap-ctx.lo `test -f 'soap-ctx.c' || echo '$(srcdir)/'`soap-ctx.c - -libcsoap_la-soap-admin.lo: soap-admin.c -@am__fastdepCC_TRUE@ if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcsoap_la_CFLAGS) $(CFLAGS) -MT libcsoap_la-soap-admin.lo -MD -MP -MF "$(DEPDIR)/libcsoap_la-soap-admin.Tpo" -c -o libcsoap_la-soap-admin.lo `test -f 'soap-admin.c' || echo '$(srcdir)/'`soap-admin.c; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libcsoap_la-soap-admin.Tpo" "$(DEPDIR)/libcsoap_la-soap-admin.Plo"; else rm -f "$(DEPDIR)/libcsoap_la-soap-admin.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='soap-admin.c' object='libcsoap_la-soap-admin.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcsoap_la_CFLAGS) $(CFLAGS) -c -o libcsoap_la-soap-admin.lo `test -f 'soap-admin.c' || echo '$(srcdir)/'`soap-admin.c - -libcsoap_la-soap-addressing.lo: soap-addressing.c -@am__fastdepCC_TRUE@ if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcsoap_la_CFLAGS) $(CFLAGS) -MT libcsoap_la-soap-addressing.lo -MD -MP -MF "$(DEPDIR)/libcsoap_la-soap-addressing.Tpo" -c -o libcsoap_la-soap-addressing.lo `test -f 'soap-addressing.c' || echo '$(srcdir)/'`soap-addressing.c; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libcsoap_la-soap-addressing.Tpo" "$(DEPDIR)/libcsoap_la-soap-addressing.Plo"; else rm -f "$(DEPDIR)/libcsoap_la-soap-addressing.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='soap-addressing.c' object='libcsoap_la-soap-addressing.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcsoap_la_CFLAGS) $(CFLAGS) -c -o libcsoap_la-soap-addressing.lo `test -f 'soap-addressing.c' || echo '$(srcdir)/'`soap-addressing.c - libcsoap_la-soap-transport.lo: soap-transport.c @am__fastdepCC_TRUE@ if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcsoap_la_CFLAGS) $(CFLAGS) -MT libcsoap_la-soap-transport.lo -MD -MP -MF "$(DEPDIR)/libcsoap_la-soap-transport.Tpo" -c -o libcsoap_la-soap-transport.lo `test -f 'soap-transport.c' || echo '$(srcdir)/'`soap-transport.c; \ @am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libcsoap_la-soap-transport.Tpo" "$(DEPDIR)/libcsoap_la-soap-transport.Plo"; else rm -f "$(DEPDIR)/libcsoap_la-soap-transport.Tpo"; exit 1; fi @@ -414,20 +432,6 @@ libcsoap_la-soap-transport.lo: soap-transport.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcsoap_la_CFLAGS) $(CFLAGS) -c -o libcsoap_la-soap-transport.lo `test -f 'soap-transport.c' || echo '$(srcdir)/'`soap-transport.c -libcsoap_la-soap-nudp.lo: soap-nudp.c -@am__fastdepCC_TRUE@ if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcsoap_la_CFLAGS) $(CFLAGS) -MT libcsoap_la-soap-nudp.lo -MD -MP -MF "$(DEPDIR)/libcsoap_la-soap-nudp.Tpo" -c -o libcsoap_la-soap-nudp.lo `test -f 'soap-nudp.c' || echo '$(srcdir)/'`soap-nudp.c; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libcsoap_la-soap-nudp.Tpo" "$(DEPDIR)/libcsoap_la-soap-nudp.Plo"; else rm -f "$(DEPDIR)/libcsoap_la-soap-nudp.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='soap-nudp.c' object='libcsoap_la-soap-nudp.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcsoap_la_CFLAGS) $(CFLAGS) -c -o libcsoap_la-soap-nudp.lo `test -f 'soap-nudp.c' || echo '$(srcdir)/'`soap-nudp.c - -libcsoap_la-soap-nhttp.lo: soap-nhttp.c -@am__fastdepCC_TRUE@ if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcsoap_la_CFLAGS) $(CFLAGS) -MT libcsoap_la-soap-nhttp.lo -MD -MP -MF "$(DEPDIR)/libcsoap_la-soap-nhttp.Tpo" -c -o libcsoap_la-soap-nhttp.lo `test -f 'soap-nhttp.c' || echo '$(srcdir)/'`soap-nhttp.c; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libcsoap_la-soap-nhttp.Tpo" "$(DEPDIR)/libcsoap_la-soap-nhttp.Plo"; else rm -f "$(DEPDIR)/libcsoap_la-soap-nhttp.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='soap-nhttp.c' object='libcsoap_la-soap-nhttp.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcsoap_la_CFLAGS) $(CFLAGS) -c -o libcsoap_la-soap-nhttp.lo `test -f 'soap-nhttp.c' || echo '$(srcdir)/'`soap-nhttp.c - libcsoap_la-soap-wsil.lo: soap-wsil.c @am__fastdepCC_TRUE@ if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcsoap_la_CFLAGS) $(CFLAGS) -MT libcsoap_la-soap-wsil.lo -MD -MP -MF "$(DEPDIR)/libcsoap_la-soap-wsil.Tpo" -c -o libcsoap_la-soap-wsil.lo `test -f 'soap-wsil.c' || echo '$(srcdir)/'`soap-wsil.c; \ @am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libcsoap_la-soap-wsil.Tpo" "$(DEPDIR)/libcsoap_la-soap-wsil.Plo"; else rm -f "$(DEPDIR)/libcsoap_la-soap-wsil.Tpo"; exit 1; fi @@ -435,6 +439,13 @@ libcsoap_la-soap-wsil.lo: soap-wsil.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcsoap_la_CFLAGS) $(CFLAGS) -c -o libcsoap_la-soap-wsil.lo `test -f 'soap-wsil.c' || echo '$(srcdir)/'`soap-wsil.c +libcsoap_la-soap-xml.lo: soap-xml.c +@am__fastdepCC_TRUE@ if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcsoap_la_CFLAGS) $(CFLAGS) -MT libcsoap_la-soap-xml.lo -MD -MP -MF "$(DEPDIR)/libcsoap_la-soap-xml.Tpo" -c -o libcsoap_la-soap-xml.lo `test -f 'soap-xml.c' || echo '$(srcdir)/'`soap-xml.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libcsoap_la-soap-xml.Tpo" "$(DEPDIR)/libcsoap_la-soap-xml.Plo"; else rm -f "$(DEPDIR)/libcsoap_la-soap-xml.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='soap-xml.c' object='libcsoap_la-soap-xml.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcsoap_la_CFLAGS) $(CFLAGS) -c -o libcsoap_la-soap-xml.lo `test -f 'soap-xml.c' || echo '$(srcdir)/'`soap-xml.c + libcsoap_la-soap-xmlsec.lo: soap-xmlsec.c @am__fastdepCC_TRUE@ if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcsoap_la_CFLAGS) $(CFLAGS) -MT libcsoap_la-soap-xmlsec.lo -MD -MP -MF "$(DEPDIR)/libcsoap_la-soap-xmlsec.Tpo" -c -o libcsoap_la-soap-xmlsec.lo `test -f 'soap-xmlsec.c' || echo '$(srcdir)/'`soap-xmlsec.c; \ @am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libcsoap_la-soap-xmlsec.Tpo" "$(DEPDIR)/libcsoap_la-soap-xmlsec.Plo"; else rm -f "$(DEPDIR)/libcsoap_la-soap-xmlsec.Tpo"; exit 1; fi diff --git a/libcsoap/soap-addressing.c b/libcsoap/soap-addressing.c index 6e894f1..53ec0b4 100644 --- a/libcsoap/soap-addressing.c +++ b/libcsoap/soap-addressing.c @@ -1,5 +1,5 @@ /****************************************************************** -* $Id: soap-addressing.c,v 1.11 2006/12/14 19:39:05 m0gg Exp $ +* $Id: soap-addressing.c,v 1.12 2007/11/03 22:40:09 m0gg Exp $ * * CSOAP Project: A SOAP client/server library in C * Copyright (C) 2006 Heiko Ronsdorf @@ -58,15 +58,15 @@ #endif #include -#include #include #include -#include +#include "soap-logging.h" #include "soap-xml.h" #include "soap-fault.h" #include "soap-env.h" +#include "soap-ctx.h" #include "soap-server.h" #include "soap-addressing.h" @@ -81,7 +81,7 @@ _soap_addressing_uuid_error(uint32_t status) case uuid_s_invalid_string_uuid: return "The string representation of an UUID is not valid"; case uuid_s_no_memory: - /* XXX: From FreeBSD 6.2 UUID(3) ??? */ + /** @todo: From FreeBSD 6.2 UUID(3), replace with app. msg! */ return "The meaning of the code escaped the writers mind"; default: return "Unkown error during UUID creation"; @@ -98,20 +98,20 @@ _soap_addressing_generate_id(void) uuid_create(&uuid, &status); if (status != uuid_s_ok) { - log_error2("uuidcreate failed (%s)", _soap_addressing_uuid_error(status)); + log_error("uuidcreate failed (%s)", _soap_addressing_uuid_error(status)); return NULL; } uuid_to_string(&uuid, &buf, &status); if (status != uuid_s_ok) { - log_error2("uuid_to_string failed (%s)", _soap_addressing_uuid_error(status)); + log_error("uuid_to_string failed (%s)", _soap_addressing_uuid_error(status)); return NULL; } if (!(ret = (char *)malloc(128))) { - log_error2("malloc failed (%s)", strerror(errno)); + log_error("malloc failed (%s)", strerror(errno)); free(buf); return NULL; } @@ -132,7 +132,7 @@ _soap_addressing_generate_id(void) if (!(ret = (char *)malloc(128))) { - log_error2("malloc failed (%s)", strerror(errno)); + log_error("malloc failed (%s)", strerror(errno)); return NULL; } @@ -192,7 +192,7 @@ _soap_addressing_get_child_element(xmlNodePtr parent, const xmlChar *name) { xmlNodePtr walker; - for (walker = soap_xml_get_children(parent); walker; walker = soap_xml_get_next(walker)) + for (walker = soap_xml_get_children(parent); walker; walker = soap_xml_get_next_element(walker)) { if (!xmlStrcmp(walker->name, name) && !xmlStrcmp(walker->ns->href, WSA_NAMESPACE)) return walker; @@ -338,7 +338,7 @@ soap_addressing_set_message_id_string(struct SoapEnv *envelope, xmlChar *id) else tmp = id; - log_verbose2("setting message id = \"%s\"", tmp); + log_verbose("setting message id = \"%s\"", tmp); node = _soap_addressing_get_child_element(envelope->header, WSA_MESSAGE_ID); if (node == NULL) diff --git a/libcsoap/soap-admin.c b/libcsoap/soap-admin.c index efc9651..2e6853d 100644 --- a/libcsoap/soap-admin.c +++ b/libcsoap/soap-admin.c @@ -1,5 +1,6 @@ +/** @file soap-admin.c SOAP administrator application */ /****************************************************************** -* $Id: soap-admin.c,v 1.11 2006/12/31 17:24:22 m0gg Exp $ +* $Id: soap-admin.c,v 1.12 2007/11/03 22:40:09 m0gg Exp $ * * CSOAP Project: A SOAP client/server library in C * Copyright (C) 2003 Ferhat Ayaz @@ -44,8 +45,8 @@ #include #include -#include #include +#include #include #include #include @@ -68,31 +69,31 @@ _soap_admin_send_title(httpd_conn_t *conn, const char *title) ""); http_output_stream_write_string(conn->out, - ""); + "" + "" + "" + "csoap "); - http_output_stream_write_string(conn->out, - "" - "" - "csoap "); http_output_stream_write_string(conn->out, title); http_output_stream_write_string(conn->out, "
"); - - return; } static inline void _soap_admin_send_footer(httpd_conn_t *conn) { - http_output_stream_write_string(conn->out, ""); - - return; + http_output_stream_write_string(conn->out, + "
" + "Admin page " + "cSOAP Home" + "" + ""); } static void @@ -118,8 +119,6 @@ _soap_admin_list_routers(httpd_conn_t *conn) http_output_stream_write_string(conn->out, ""); _soap_admin_send_footer(conn); - - return; } static void @@ -136,7 +135,7 @@ _soap_admin_list_services(httpd_conn_t *conn, const char *routername) if (!router) { http_output_stream_write_string(conn->out, "Router not found!"); - http_output_stream_write_string(conn->out, ""); + _soap_admin_send_footer(conn); return; } @@ -174,8 +173,6 @@ _soap_admin_list_services(httpd_conn_t *conn, const char *routername) http_output_stream_write_string(conn->out, ""); _soap_admin_send_footer(conn); - - return; } static void @@ -211,16 +208,13 @@ _soap_admin_handle_get(httpd_conn_t * conn, struct hrequest_t * req) ""); _soap_admin_send_footer(conn); } - - return; } - static void _soap_admin_entry(httpd_conn_t * conn, struct hrequest_t * req) { @@ -232,21 +226,18 @@ _soap_admin_entry(httpd_conn_t * conn, struct hrequest_t * req) { httpd_send_header(conn, 200, HTTP_STATUS_200_REASON_PHRASE); http_output_stream_write_string(conn->out, - "" - "" - "" - "" - "

Sorry!

" - "
" - "
POST Service is not implemented now. Use your browser
" - "" - ""); + "" + "" + "" + "" + "

Sorry!

" + "
" + "
Only GET method is implemented now. Use your browser.
" + "" + ""); } - - return; } - herror_t soap_admin_init_args(int argc, char **argv) { @@ -256,10 +247,9 @@ soap_admin_init_args(int argc, char **argv) if (!strcmp(argv[i], CSOAP_ENABLE_ADMIN)) { - httpd_register("/csoap", _soap_admin_entry); + httpd_register(CSOAP_ADMIN_CONTEXT, _soap_admin_entry); break; } } - return H_OK; } diff --git a/libcsoap/soap-admin.h b/libcsoap/soap-admin.h index 2e0ca80..838a75b 100644 --- a/libcsoap/soap-admin.h +++ b/libcsoap/soap-admin.h @@ -1,8 +1,9 @@ /****************************************************************** - * $Id: soap-admin.h,v 1.5 2006/12/31 17:24:22 m0gg Exp $ + * $Id: soap-admin.h,v 1.6 2007/11/03 22:40:09 m0gg Exp $ * * CSOAP Project: A SOAP client/server library in C - * Copyright (C) 2003 Ferhat Ayaz + * Copyright (C) 2003-2006 Ferhat Ayaz + * Copyright (C) 2007 Heiko Ronsdorf * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -24,6 +25,13 @@ #ifndef __csoap_admin_h #define __csoap_admin_h +/** @file soap-admin.h HTTP administrator interface + * + * @defgroup CSOAP_ADMIN + * @ingroup CSOAP + */ +/**@{*/ + #define CSOAP_ENABLE_ADMIN "-CSOAPadmin" #define CSOAP_ADMIN_QUERY_ROUTERS "routers" @@ -36,19 +44,19 @@ #define CSOAP_ADMIN_URN "urn" #define CSOAP_ADMIN_METHOD "method" +#define CSOAP_ADMIN_CONTEXT "csoap" + #ifdef __cplusplus extern "C" { #endif -/** - * - * Initializes the soap admin HTTP interface with commandline arguments. +/** This function initializes the cSOAP admin HTTP interface with + * commandline arguments. * * @param argc commandline arg count * @param argv commandline arg vector * - * @returns 1 if success, 0 otherwise - * + * @returns H_OK on success. */ extern herror_t soap_admin_init_args(int argc, char **argv); @@ -56,4 +64,6 @@ extern herror_t soap_admin_init_args(int argc, char **argv); } #endif +/**@}*/ + #endif diff --git a/libcsoap/soap-client.c b/libcsoap/soap-client.c index cf2479f..65e21f4 100644 --- a/libcsoap/soap-client.c +++ b/libcsoap/soap-client.c @@ -1,5 +1,5 @@ /****************************************************************** -* $Id: soap-client.c,v 1.33 2006/11/29 11:04:24 m0gg Exp $ +* $Id: soap-client.c,v 1.34 2007/11/03 22:40:09 m0gg Exp $ * * CSOAP Project: A SOAP client/server library in C * Copyright (C) 2003 Ferhat Ayaz @@ -33,8 +33,8 @@ #include #include -#include +#include "soap-logging.h" #include "soap-fault.h" #include "soap-env.h" #include "soap-ctx.h" @@ -91,14 +91,14 @@ soap_client_init_args(int argc, char **argv) if ((status = soap_xmlsec_client_init_args(argc, argv)) != H_OK) { - log_error2("soap_xmlsec_client_init_args failed (%s)", herror_message(status)); + log_error("soap_xmlsec_client_init_args failed (%s)", herror_message(status)); return status; } #endif if ((status = soap_transport_client_init_args(argc, argv)) != H_OK) { - log_error2("soap_transport_client_init_args failed (%s)", herror_message(status)); + log_error("soap_transport_client_init_args failed (%s)", herror_message(status)); return status; } @@ -119,71 +119,71 @@ soap_client_invoke(struct SoapCtx *req, struct SoapCtx **res, const char *url, c herror_t status; char *id; - log_verbose2("action = \"%s\"", action); + log_verbose("action = \"%s\"", action); soap_addressing_set_action_string(req->env, action); - log_verbose2("url = \"%s\"", url); + log_verbose("url = \"%s\"", url); soap_addressing_set_to_address_string(req->env, url); - log_verbose2("from = \"%s\"", soap_transport_get_name()); + log_verbose("from = \"%s\"", soap_transport_get_name()); soap_addressing_set_from_address_string(req->env, soap_transport_get_name()); soap_addressing_set_message_id_string(req->env, NULL); id = soap_addressing_get_message_id_string(req->env); - log_verbose2("generated message id = \"%s\"", id); + log_verbose("generated message id = \"%s\"", id); free(id); #ifdef HAVE_XMLSEC1 if ((status = soap_xmlsec_encrypt(req)) != H_OK) { - log_error2("soap_xmlsec_encrypt failed (%s)", herror_message(status)); + log_error("soap_xmlsec_encrypt failed (%s)", herror_message(status)); if (_soap_client_force_encrypt) return status; } else { - log_verbose1("soap_xmlsec_encrypt succeed"); + log_verbose("soap_xmlsec_encrypt succeed"); } if ((status = soap_xmlsec_sign(req)) != H_OK) { - log_error2("soap_xmlsec_sign failed (%s)", herror_message(status)); + log_error("soap_xmlsec_sign failed (%s)", herror_message(status)); if (_soap_client_force_sign) return status; } else { - log_verbose1("soap_xmlsec_encrypt succeed"); + log_verbose("soap_xmlsec_encrypt succeed"); } #endif if ((status = soap_transport_client_invoke(req, res)) != H_OK) { - log_error2("soap_transport_client_invoke failed (%s)", herror_message(status)); + log_error("soap_transport_client_invoke failed (%s)", herror_message(status)); return status; } #ifdef HAVE_XMLSEC1 if ((status = soap_xmlsec_verify(*res)) != H_OK) { - log_error2("soap_xmlsec_verify failed (%s)", herror_message(status)); + log_error("soap_xmlsec_verify failed (%s)", herror_message(status)); if (_soap_client_force_verify) return status; } else { - log_verbose1("soap_xmlsec_verify succeed"); + log_verbose("soap_xmlsec_verify succeed"); } if ((status = soap_xmlsec_decrypt(*res)) != H_OK) { - log_error2("soap_xmlsec_decrypt failed (%s)", herror_message(status)); + log_error("soap_xmlsec_decrypt failed (%s)", herror_message(status)); if (_soap_client_force_decrypt) return status; } else { - log_verbose1("soap_xmlsec_decrypt succeed"); + log_verbose("soap_xmlsec_decrypt succeed"); } #endif diff --git a/libcsoap/soap-ctx.c b/libcsoap/soap-ctx.c index 4d595f4..3adbc5e 100755 --- a/libcsoap/soap-ctx.c +++ b/libcsoap/soap-ctx.c @@ -1,5 +1,5 @@ /****************************************************************** - * $Id: soap-ctx.c,v 1.14 2006/11/25 15:06:57 m0gg Exp $ + * $Id: soap-ctx.c,v 1.15 2007/11/03 22:40:09 m0gg Exp $ * * CSOAP Project: A SOAP client/server library in C * Copyright (C) 2003-2004 Ferhat Ayaz @@ -45,8 +45,8 @@ #include #include -#include +#include "soap-logging.h" #include "soap-fault.h" #include "soap-env.h" #include "soap-ctx.h" @@ -58,7 +58,7 @@ soap_ctx_new(struct SoapEnv * env) /* should only be used internally */ if (!(ctx = (struct SoapCtx *) malloc(sizeof(struct SoapCtx)))) { - log_error2("malloc failed (%s)", strerror(errno)); + log_error("malloc failed (%s)", strerror(errno)); return NULL; } diff --git a/libcsoap/soap-env.c b/libcsoap/soap-env.c index 99cf3ba..09386c4 100644 --- a/libcsoap/soap-env.c +++ b/libcsoap/soap-env.c @@ -1,5 +1,5 @@ /****************************************************************** -* $Id: soap-env.c,v 1.27 2006/11/26 20:13:05 m0gg Exp $ +* $Id: soap-env.c,v 1.28 2007/11/03 22:40:09 m0gg Exp $ * * CSOAP Project: A SOAP client/server library in C * Copyright (C) 2003 Ferhat Ayaz @@ -50,12 +50,11 @@ #endif #include -#include #include #include -#include +#include "soap-logging.h" #include "soap-xml.h" #include "soap-fault.h" #include "soap-env.h" @@ -172,7 +171,7 @@ soap_env_new_from_doc(xmlDocPtr doc, struct SoapEnv ** out) if (doc == NULL) { - log_error1("Cannot create XML document!"); + log_error("Cannot create XML document!"); return herror_new("soap_env_new_from_doc", GENERAL_INVALID_PARAM, "XML Document (xmlDocPtr) is NULL"); @@ -180,14 +179,14 @@ soap_env_new_from_doc(xmlDocPtr doc, struct SoapEnv ** out) if (!(root = xmlDocGetRootElement(doc))) { - log_error1("XML document is empty!"); + log_error("XML document is empty!"); return herror_new("soap_env_new_from_doc", XML_ERROR_EMPTY_DOCUMENT, "XML Document is empty!"); } if (!(env = (struct SoapEnv *) malloc(sizeof(struct SoapEnv)))) { - log_error2("malloc failed (%s)", strerror(errno)); + log_error("malloc failed (%s)", strerror(errno)); return herror_new("soap_env_from_doc", GENERAL_INVALID_PARAM, "malloc failed (%s)", strerror(errno)); } @@ -294,8 +293,8 @@ soap_env_new_with_method(const char *urn, const char *method, struct SoapEnv ** xmlDocPtr env; xmlChar buffer[1054]; - log_verbose2("URN = '%s'", urn); - log_verbose2("Method = '%s'", method); + log_verbose("URN = '%s'", urn); + log_verbose("Method = '%s'", method); if (!strcmp(urn, "")) { @@ -327,7 +326,7 @@ soap_env_add_item(struct SoapEnv * call, const char *type, const char *name, con if (newNode == NULL) { - log_error1("Can not create new XML node"); + log_error("Can not create new XML node"); return NULL; } @@ -335,7 +334,7 @@ soap_env_add_item(struct SoapEnv * call, const char *type, const char *name, con { if (!xmlNewProp(newNode, BAD_CAST "xsi:type", BAD_CAST type)) { - log_error1("Can not create new XML attribute"); + log_error("Can not create new XML attribute"); return NULL; } } @@ -368,7 +367,7 @@ soap_env_add_attachment(struct SoapEnv * call, const char *name, const char *hre if (newNode == NULL) { - log_error1("Can not create new xml node"); + log_error("Can not create new xml node"); return NULL; } @@ -376,7 +375,7 @@ soap_env_add_attachment(struct SoapEnv * call, const char *name, const char *hre { if (!xmlNewProp(newNode, BAD_CAST "href", BAD_CAST href)) { - log_error1("Can not create new xml attribute"); + log_error("Can not create new xml attribute"); return NULL; } } @@ -437,7 +436,6 @@ soap_env_free(struct SoapEnv * env) return; } - xmlNodePtr soap_env_get_body(struct SoapEnv * env) { @@ -445,24 +443,24 @@ soap_env_get_body(struct SoapEnv * env) if (env == NULL) { - log_error1("SOAP envelope is NULL"); + log_error("SOAP envelope is NULL"); return NULL; } if (env->root == NULL) { - log_error1("SOAP envelope contains no XML"); + log_error("SOAP envelope contains no XML"); return NULL; } - for (node = soap_xml_get_children(env->root); node; node = soap_xml_get_next(node)) + for (node = soap_xml_get_children(env->root); node; node = soap_xml_get_next_element(node)) { if (!xmlStrcmp(node->name, BAD_CAST "Body") && !xmlStrcmp(node->ns->href, BAD_CAST soap_env_ns)) return node; } - log_error1("Body tag not found!"); + log_error("Body tag not found!"); return NULL; } @@ -474,17 +472,17 @@ soap_env_get_header(struct SoapEnv *env) if (!env) { - log_error1("SoapEnv is NULL"); + log_error("SoapEnv is NULL"); return NULL; } if (!env->root) { - log_error1("SoapEnv contains no document"); + log_error("SoapEnv contains no document"); return NULL; } - for (node = soap_xml_get_children(env->root); node; node = soap_xml_get_next(node)) + for (node = soap_xml_get_children(env->root); node; node = soap_xml_get_next_element(node)) { if (!xmlStrcmp(node->name, BAD_CAST "Header") && !xmlStrcmp(node->ns->href, BAD_CAST soap_env_ns)) @@ -500,19 +498,19 @@ soap_env_get_fault(struct SoapEnv * env) { xmlNodePtr node; - node = soap_env_get_body(env); - - if (!node) + if (!(node = soap_env_get_body(env))) + { return NULL; + } while (node != NULL) { if (!xmlStrcmp(node->name, BAD_CAST "Fault")) return node; - node = soap_xml_get_next(node); + node = soap_xml_get_next_element(node); } -/* log_warn1 ("Node Fault tag found!");*/ +/* log_warn("Node Fault tag found!");*/ return NULL; } @@ -524,65 +522,15 @@ soap_env_get_method(struct SoapEnv * env) if (!(body = soap_env_get_body(env))) { - log_verbose1("SoapEnv contains no Body element"); + log_verbose("SoapEnv contains no Body element"); return NULL; } - /* method is the first child */ + /* The method element has to be the first child element */ return soap_xml_get_children(body); } -/* XXX: unused function? */ -xmlNodePtr -_soap_env_get_body(struct SoapEnv * env) -{ - xmlNodePtr body; - xmlNodeSetPtr nodeset; - xmlXPathObjectPtr xpathobj; - - if (env == NULL) - { - log_error1("struct SoapEnv is NULL"); - return NULL; - } - - if (env->root == NULL) - { - log_error1("struct SoapEnv contains no XML document"); - return NULL; - } - - /* - find tag find out namespace xpath: //Envelope/Body/ */ - xpathobj = soap_xpath_eval(env->root->doc, "//Envelope/Body"); - - if (!xpathobj) - { - log_error1("No Body (xpathobj)!"); - return NULL; - } - - if (!(nodeset = xpathobj->nodesetval)) - { - log_error1("No Body (nodeset)!"); - xmlXPathFreeObject(xpathobj); - return NULL; - } - - if (nodeset->nodeNr < 1) - { - log_error1("No Body (nodeNr)!"); - xmlXPathFreeObject(xpathobj); - return NULL; - } - - body = nodeset->nodeTab[0]; /* body is */ - xmlXPathFreeObject(xpathobj); - return body; -} - - const char * soap_env_find_urn(struct SoapEnv * env) { @@ -591,14 +539,14 @@ soap_env_find_urn(struct SoapEnv * env) if (!(body = soap_env_get_body(env))) { - log_verbose1("body is NULL"); + log_verbose("body is NULL"); return NULL; } /* node is the first child */ if (!(node = soap_xml_get_children(body))) { - log_error1("No namespace found"); + log_error("No namespace found"); return NULL; } @@ -613,8 +561,8 @@ soap_env_find_urn(struct SoapEnv * env) } else { - static char *empty = ""; - log_warn1("No namespace found"); + static const char *empty = ""; + log_warn("No namespace found"); return(empty); } @@ -630,19 +578,17 @@ soap_env_find_methodname(struct SoapEnv * env) if (!(body = soap_env_get_body(env))) return NULL; - node = soap_xml_get_children(body); /* node is the first child */ - - if (node == NULL) + /* node is the first child */ + if (!(node = soap_xml_get_children(body))) { - log_error1("No method found"); + log_error("No method found"); return NULL; } if (node->name == NULL) { - log_error1("No methodname found"); + log_error("No methodname found"); return NULL; - } return ((char *) node->name); diff --git a/libcsoap/soap-fault.c b/libcsoap/soap-fault.c index 3341f7a..ab56979 100644 --- a/libcsoap/soap-fault.c +++ b/libcsoap/soap-fault.c @@ -1,5 +1,5 @@ /****************************************************************** -* $Id: soap-fault.c,v 1.16 2006/12/14 19:36:49 m0gg Exp $ +* $Id: soap-fault.c,v 1.17 2007/11/03 22:40:09 m0gg Exp $ * * CSOAP Project: A SOAP client/server library in C * Copyright (C) 2003 Ferhat Ayaz @@ -33,11 +33,11 @@ #include #endif -#include - #include -#include +#include + +#include "soap-logging.h" #include "soap-xml.h" #include "soap-env.h" #include "soap-ctx.h" @@ -91,7 +91,7 @@ soap_fault_build(int fault_code, const char *fault_string, const char *fault_act char *buffer; xmlDocPtr fault; /* result */ - log_verbose1("Build fault"); + log_verbose("Build fault"); switch (fault_code) { @@ -121,10 +121,10 @@ soap_fault_build(int fault_code, const char *fault_string, const char *fault_act if (detail) bufferlen += strlen(detail); - log_verbose2("Creating buffer with %d bytes", bufferlen); + log_verbose("Creating buffer with %d bytes", bufferlen); if (!(buffer = (char *) malloc(bufferlen))) { - log_error2("malloc failed (%s)", errno); + log_error("malloc failed (%s)", errno); return NULL; } @@ -139,11 +139,11 @@ soap_fault_build(int fault_code, const char *fault_string, const char *fault_act if (fault == NULL) { - log_error1("Cannot create XML document!"); + log_error("Cannot create XML document!"); return soap_fault_build(fault_code, "Cannot create fault object in XML", soap_server_get_name(), NULL); } - log_verbose2("Returning fault (%p)", fault); + log_verbose("Returning fault (%p)", fault); return fault; } diff --git a/libcsoap/soap-logging.c b/libcsoap/soap-logging.c new file mode 100644 index 0000000..1fd0eef --- /dev/null +++ b/libcsoap/soap-logging.c @@ -0,0 +1,150 @@ +/****************************************************************** +* $Id: soap-logging.c,v 1.1 2007/11/03 22:40:09 m0gg Exp $ +* +* CSOAP Project: A http 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 +******************************************************************/ +#ifdef HAVE_CONFIG_H +#include +#endif + +#ifdef HAVE_STDIO_H +#include +#endif + +#ifdef HAVE_STDLIB_H +#include +#endif + +#ifdef HAVE_STDARG_H +#include +#endif + +#ifdef HAVE_SYSLOG_H +#include +#endif + +#include "soap-logging.h" + +static int _soap_logtype = SOAP_LOG_FOREGROUND; +static soap_loglevel_t _soap_loglevel = SOAP_LOG_DEBUG; +static char *_soap_log_logfile = NULL; + +soap_loglevel_t +soap_log_set_loglevel(soap_loglevel_t level) +{ + soap_loglevel_t old = _soap_loglevel; + _soap_loglevel = level; + return old; +} + +soap_loglevel_t +soap_log_get_loglevel(void) +{ + return _soap_loglevel; +} + +int +soap_log_set_logtype(int type) +{ + int old; + + old = _soap_logtype; + _soap_logtype = type; + + return old; +} + +const char * +soap_log_get_logfile(void) +{ + return _soap_log_logfile; +} + +void +soap_log_set_logfile(const char *filename) +{ + if (_soap_log_logfile) + free(_soap_log_logfile); + + if (filename) + _soap_log_logfile = strdup(filename); +} + +void +_soap_log_printf(soap_loglevel_t level, const char *format, ...) +{ + const char *filename; + va_list ap; + + if (level < _soap_loglevel) + return; + + va_start(ap, format); + + if (_soap_logtype & SOAP_LOG_FOREGROUND) + vfprintf(stdout, format, ap); + +#ifdef HAVE_SYSLOG_H + if (_nanohttp_logtype & SOAP_LOG_SYSLOG) + { + int syslog_level; + + switch (level) + { + case SOAP_LOGLEVEL_VERBOSE: + case SOAP_LOGLEVEL_DEBUG: + syslog_level = LOG_DEBUG; + break; + case SOAP_LOGLEVEL_INFO: + syslog_level = LOG_INFO; + break; + case SOAP_LOGLEVEL_WARN: + syslog_level = LOG_WARNING; + break; + case SOAP_LOGLEVEL_ERROR: + syslog_level = LOG_ERR; + break; + case SOAP_LOGLEVEL_FATAL: + syslog_level = LOG_CRIT; + break; + } + vsyslog(syslog_level, format, ap); + } +#endif + + if ((filename = soap_log_get_logfile())) + { + FILE *fp; + + if (!(fp = fopen(filename, "a"))) + fp = fopen(filename, "w"); + + if (fp) + { + vfprintf(fp, format, ap); + fflush(fp); + fclose(fp); + } + } + + va_end(ap); +} + diff --git a/libcsoap/soap-logging.h b/libcsoap/soap-logging.h new file mode 100644 index 0000000..68c9728 --- /dev/null +++ b/libcsoap/soap-logging.h @@ -0,0 +1,150 @@ +/****************************************************************** + * $Id: soap-logging.h,v 1.1 2007/11/03 22:40:09 m0gg Exp $ + * + * CSOAP Project: A http client/server library in C + * Copyright (C) 2003-2006 Ferhat Ayaz + * Copyright (C) 2007 Heiko Ronsdorf + * + * 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: hero@persua.de + ******************************************************************/ +#ifndef __soap_logging_h +#define __soap_logging_h + +/** @file soap-logging.h Logging definitions and prototypes + * + * @defgrpoup CSOAP_LOGGING Logging interface + * @ingroup CSOAP + */ +/**@{*/ + +/** @defgroup CSOAP_CDMLINE_LOGGING Commandline flags + * @ingroup CSOAP_CMDLINE + */ +/**@{*/ +#define CSOAP_ARG_LOGFILE "-CSOAPlog" +#define CSOAP_ARG_LOGLEVEL "-CSOAPloglevel" +/**@}*/ + +/** Loglevel definition */ +typedef enum soap_loglevel +{ + SOAP_LOG_OFF, /**< Logging completely turned off (use at your own + risk). */ + SOAP_LOG_VERBOSE, /**< Debugging messages thath may overlfow the + log */ + SOAP_LOG_DEBUG, /**< Messages that contain information normallu of + use only when debugging the library. */ + SOAP_LOG_INFO, /**< Infmormational messages */ + SOAP_LOG_WARN, /**< Warning messages. */ + SOAP_LOG_ERROR, /**< A condition that should be corrected + immediately, such as a broken network + connection. */ + SOAP_LOG_FATAL /**< A panic condition. */ +} soap_loglevel_t; + +#define SOAP_LOG_LEVEL_OFF_STRING "OFF" +#define SOAP_LOG_LEVEL_VERBOSE_STRING "VERBOSE" +#define SOAP_LOG_LEVEL_DEBUG_STRING "DEBUG" +#define SOAP_LOG_LEVEL_INFO_STRING "INFO" +#define SOAP_LOG_LEVEL_WARN_STRING "WARN" +#define SOAP_LOG_LEVEL_ERROR_STRING "ERROR" +#define SOAP_LOG_LEVEL_FATAL_STRING "FATAL" +#define SOAP_LOG_LEVEL_UNKNOWN_STRING "UNKNWON" + +#ifdef __cplusplus +extern "C" { +#endif + +/** Set the loglevel. + * + * @param level The new loglevel. + * + * @return The old loglevel. + */ +extern soap_loglevel_t soap_set_loglevel(soap_loglevel_t loglevel); + +/** Get the loglevel. + * + * @return The current loglevel. + */ +extern soap_loglevel_t soap_get_loglevel(void); + +/** Set the logfile. + * + * @param filename The filename of the logfile. + */ +extern void soap_set_logfile(const char *filename); + +/** Get the filename of the logfile. + * + * @return Pointer to the filename or null otherwise. + */ +extern char *soap_get_logfile(void); + +#define SOAP_LOG_DISABLED 0x00 /**< Logging disabled */ +#define SOAP_LOG_FOREGROUND 0x01 /**< Logging to stdout enabled */ +#define SOAP_LOG_SYSLOG 0x02 /**< Syslog logging enabled */ + +/** This function sets the type of logging. + * + * @return The old logtype. + * + * @see - SOAP_LOG_DISABLED + * - SOAP_LOG_FOREGROUND + * - SOAP_LOG_SYSLOG + */ +extern int soap_log_set_logtype(int type); + +#ifdef WIN32 +#if defined(_MSC_VER) && _MSC_VER <= 1200 +extern char *VisualC_funcname(const char *file, int line); /* not thread safe! */ +#define __FUNCTION__ VisualC_funcname(__FILE__, __LINE__) +#endif +#endif + +#ifdef __cplusplus +} +#endif + +#define log_verbose(fmt, ...) _nanohttp_log_printf(SOAP_LOG_VERBOSE, \ + SOAP_LOG_LEVEL_VERBOSE_STRING " %s: " fmt "\n", \ + __FUNCTION__, ## __VA_ARGS__) + +#define log_debug(fmt, ...) _nanohttp_log_printf(SOAP_LOG_DEBUG, \ + SOAP_LOG_LEVEL_DEBUG_STRING " %s: " fmt "\n", \ + __FUNCTION__, ## __VA_ARGS__) + +#define log_info(fmt, ...) _nanohttp_log_printf(SOAP_LOG_INFO, \ + SOAP_LOG_LEVEL_INFO_STRING " %s: " fmt "\n", \ + __FUNCTION__, ## __VA_ARGS__) + +#define log_warn(fmt, ...) _nanohttp_log_printf(SOAP_LOG_WARN, \ + SOAP_LOG_LEVEL_WARN_STRING " %s: " fmt "\n", \ + __FUNCTION__, ## __VA_ARGS__) + +#define log_error(fmt, ...) _nanohttp_log_printf(SOAP_LOG_ERROR, \ + SOAP_LOG_LEVEL_ERROR_STRING " %s: " fmt "\n", \ + __FUNCTION__, ## __VA_ARGS__) + +#define log_fatal(fmt, ...) _nanohttp_log_printf(SOAP_LOG_FATAL, \ + SOAP_LOG_LEVEL_FATAL_STRING " %s: " fmt "\n", \ + __FUNCTION__, ## __VA_ARGS__) + +/**@}*/ + +#endif diff --git a/libcsoap/soap-nhttp.c b/libcsoap/soap-nhttp.c index 833b78f..1637754 100644 --- a/libcsoap/soap-nhttp.c +++ b/libcsoap/soap-nhttp.c @@ -1,5 +1,5 @@ /****************************************************************** -* $Id: soap-nhttp.c,v 1.12 2007/01/01 18:58:05 m0gg Exp $ +* $Id: soap-nhttp.c,v 1.13 2007/11/03 22:40:09 m0gg Exp $ * * CSOAP Project: A SOAP client/server library in C * Copyright (C) 2003 Ferhat Ayaz @@ -19,7 +19,7 @@ * 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 @@ -39,11 +39,9 @@ #include #include -#include #include #include -#include #include #include #include @@ -51,6 +49,7 @@ #include #include +#include "soap-logging.h" #include "soap-fault.h" #include "soap-env.h" #include "soap-ctx.h" @@ -109,10 +108,14 @@ _soap_nhttp_xml_io_read(void *ctx, char *buffer, int len) in = (struct http_input_stream_t *)ctx; if (!http_input_stream_is_ready(in)) + { return 0; + } if ((ret = http_input_stream_read(in, buffer, len)) == -1) + { return 0; + } return ret; } @@ -211,19 +214,19 @@ soap_nhttp_server_init_args(int argc, char **argv) if ((err = httpd_init(argc, argv)) != H_OK) { - log_error2("httpd_init failed (%s)", herror_message(err)); + log_error("httpd_init failed (%s)", herror_message(err)); return err; } if ((err = soap_wsil_init_args(argc, argv)) != H_OK) { - log_error2("soap_wsil_init_args failed (%s)", herror_message(err)); + log_error("soap_wsil_init_args failed (%s)", herror_message(err)); return err; } if ((err = soap_admin_init_args(argc, argv)) != H_OK) { - log_error2("soap_admin_init_args failed (%s)", herror_message(err)); + log_error("soap_admin_init_args failed (%s)", herror_message(err)); return err; } @@ -233,7 +236,7 @@ soap_nhttp_server_init_args(int argc, char **argv) static herror_t _soap_nhttp_client_build_result(hresponse_t * res, struct SoapEnv ** env) { - log_verbose2("Building result (%p)", res); + log_verbose("Building result (%p)", res); if (res == NULL) return herror_new("_soap_client_build_result", @@ -275,7 +278,7 @@ _soap_nhttp_client_invoke(void *unused, struct SoapCtx *request, struct SoapCtx /* for copy attachments */ char href[MAX_HREF_SIZE]; - /* log_verbose1("nanohttp client"); */ + /* log_verbose("nanohttp client"); */ xmlDocDumpMemory(request->env->root->doc, &buffer, &size); @@ -291,14 +294,14 @@ _soap_nhttp_client_invoke(void *unused, struct SoapCtx *request, struct SoapCtx httpc_set_header(conn, SOAP_NHTTP_SOAP_ACTION, action); else httpc_set_header(conn, SOAP_NHTTP_SOAP_ACTION, ""); - log_verbose2("action is \"%s\"", action); + log_verbose("action is \"%s\"", action); free(action); httpc_set_header(conn, HEADER_CONNECTION, "Close"); if (!(url = soap_addressing_get_to_address_string(request->env))) return herror_new("soap_nhttp_client_invoke", 0, "Missing client URL"); - log_verbose2("url is \"%s\"", url); + log_verbose("url is \"%s\"", url); if (!request->attachments) { @@ -359,7 +362,7 @@ _soap_nhttp_client_invoke(void *unused, struct SoapCtx *request, struct SoapCtx { if ((status = httpc_mime_send_file(conn, part->id, part->content_type, part->transfer_encoding, part->filename)) != H_OK) { - log_error2("httpc_mime_send_file failed (%s)", herror_message(status)); + log_error("httpc_mime_send_file failed (%s)", herror_message(status)); httpc_close_free(conn); xmlFree(buffer); return status; @@ -401,7 +404,7 @@ _soap_nhttp_client_invoke(void *unused, struct SoapCtx *request, struct SoapCtx hresponse_free(res); httpc_close_free(conn); - /* log_verbose1("done"); */ + /* log_verbose("done"); */ return H_OK; } @@ -413,7 +416,7 @@ soap_nhttp_client_init_args(int argc, char **argv) if ((status = httpc_init(argc, argv)) != H_OK) { - log_error2("httpc_init failed (%s)", herror_message(status)); + log_error("httpc_init failed (%s)", herror_message(status)); return status; } @@ -430,7 +433,7 @@ soap_nhttp_register(const char *context) if ((status = httpd_register(context, soap_nhttp_process)) != H_OK) { - log_error2("httpd_register_secure failed (%s)", herror_message(status)); + log_error("httpd_register_secure failed (%s)", herror_message(status)); return status; } diff --git a/libcsoap/soap-nudp.c b/libcsoap/soap-nudp.c index e7f4dc1..2e5ab83 100644 --- a/libcsoap/soap-nudp.c +++ b/libcsoap/soap-nudp.c @@ -1,5 +1,5 @@ /****************************************************************** -* $Id: soap-nudp.c,v 1.9 2006/12/16 15:55:24 m0gg Exp $ +* $Id: soap-nudp.c,v 1.10 2007/11/03 22:40:09 m0gg Exp $ * * CSOAP Project: A SOAP client/server library in C * Copyright (C) 2006 Heiko Ronsdorf @@ -73,8 +73,8 @@ #include #include -#include +#include "soap-logging.h" #include "soap-fault.h" #include "soap-env.h" #include "soap-ctx.h" @@ -98,7 +98,7 @@ _soap_nudp_server_set_port(void) if (!(entry = getservbyname("soap", "udp"))) { - log_warn1("getservbyname(\"soap\", \"udp\") returned NULL, please edit services database"); + log_warn("getservbyname(\"soap\", \"udp\") returned NULL, please edit services database"); _soap_nudp_port = NUDP_DEFAULT_PORT; } else @@ -121,7 +121,7 @@ _soap_nudp_server_parse_arguments(int argc, char **argv) } } - log_verbose2("socket bind to port \"%d\"", _soap_nudp_port); + log_verbose("socket bind to port \"%d\"", _soap_nudp_port); return; } @@ -139,7 +139,7 @@ _soap_nudp_send_document(int socket, xmlDocPtr doc, const struct sockaddr *addr, xmlDocDumpMemory(doc, &buf, &size); if ((sent = sendto(socket, buf, size, 0, addr, addr_len)) == -1) { - log_error2("sendto failed (%s)", strerror(errno)); + log_error("sendto failed (%s)", strerror(errno)); ret = herror_new("soap_nudp_client_invoke", 0, "Cannot send message"); } @@ -157,14 +157,14 @@ _soap_nudp_receive_document(int socket, xmlDocPtr *doc, struct sockaddr *addr, s /** @todo: use a timeout ??? */ if ((cnt = recvfrom(socket, buf, 4095, 0, addr, addr_len)) < 0) { - log_error2("recvfrom failed (%s)", strerror(errno)); + log_error("recvfrom failed (%s)", strerror(errno)); return herror_new("_soap_nudp_receive_document", 0, "Receiving document failed"); } buf[cnt] = '\0'; if (!(*doc = xmlReadDoc(buf, NULL, NULL, XML_PARSE_NONET))) { - log_error1("xmlReadDoc failed"); + log_error("xmlReadDoc failed"); return herror_new("_soap_nudp_receive_document", 0, "Cannot parse received data"); } @@ -184,7 +184,7 @@ _soap_nudp_client_invoke(void *unused, struct SoapCtx *request, struct SoapCtx * if (!(to = soap_addressing_get_to_address(request->env))) { - log_error1("soap_addressing_get_to_address returned NULL"); + log_error("soap_addressing_get_to_address returned NULL"); return herror_new("soap_nudp_client_invoke", 0, "Destination address is missing"); } @@ -197,13 +197,13 @@ _soap_nudp_client_invoke(void *unused, struct SoapCtx *request, struct SoapCtx * if (inet_pton(AF_INET, "127.0.0.1", &addr.sin_addr) != 1) { - log_error2("inet_pton failed (%s)", strerror(errno)); + log_error("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)); + log_error("socket failed (%s)", strerror(errno)); return herror_new("soap_nudp_client_invoke", 0, "Cannot create socket"); } @@ -212,14 +212,14 @@ _soap_nudp_client_invoke(void *unused, struct SoapCtx *request, struct SoapCtx * saddr_len = sizeof(struct sockaddr); if ((status = _soap_nudp_receive_document(sd, &doc, &saddr, &saddr_len)) != H_OK) { - log_error2("_soap_nudp_receive_document failed (%s)", herror_message(status)); + log_error("_soap_nudp_receive_document failed (%s)", herror_message(status)); return status; } *response = soap_ctx_new(NULL); if ((status = soap_env_new_from_doc(doc, &(*response)->env)) != H_OK) { - log_error2("soap_env_new_from_doc failed (%s)", herror_message(status)); + log_error("soap_env_new_from_doc failed (%s)", herror_message(status)); return status; } @@ -239,7 +239,7 @@ soap_nudp_server_init_args(int argc, char **argv) if ((_soap_nudp_socket = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { - log_error2("socket failed (%s)", strerror(errno)); + log_error("socket failed (%s)", strerror(errno)); return herror_new("soap_nudp_server_init_args", 0, "Cannot create socket (%s)", strerror(errno)); } @@ -250,7 +250,7 @@ soap_nudp_server_init_args(int argc, char **argv) if (bind(_soap_nudp_socket, (struct sockaddr *)&addr, sizeof(struct sockaddr_in)) < 0) { - log_error2("bind failed (%s)", strerror(errno)); + log_error("bind failed (%s)", strerror(errno)); return herror_new("soap_nudp_server_init_args", 0, "Cannot bind socket (%s)", strerror(errno)); } @@ -281,12 +281,12 @@ soap_nudp_server_run(void *unused) addr_len = sizeof(struct sockaddr); if (_soap_nudp_receive_document(_soap_nudp_socket, &doc, &addr, &addr_len) != H_OK) { - log_error2("_soap_nudp_receive_document failed (%s)", herror_message(status)); + log_error("_soap_nudp_receive_document failed (%s)", herror_message(status)); herror_release(status); continue; } - /* log_error1(__FUNCTION__); + /* log_error(__FUNCTION__); xmlDocFormatDump(stdout, doc, 1); */ req = soap_ctx_new(NULL); @@ -324,7 +324,7 @@ soap_nudp_server_run_threaded(void) if ((err = pthread_create(&_soap_nudp_thread, &_soap_nudp_attr, soap_nudp_server_run, NULL)) < 0) { - log_error2("pthread_create failed (%s)", strerror(err)); + log_error("pthread_create failed (%s)", strerror(err)); return herror_new("soap_nudp_server_run_threaded", 0, "pthread_create failed (%s)", strerror(err)); } diff --git a/libcsoap/soap-router.c b/libcsoap/soap-router.c index cc443ca..1d1be64 100644 --- a/libcsoap/soap-router.c +++ b/libcsoap/soap-router.c @@ -1,5 +1,5 @@ /****************************************************************** -* $Id: soap-router.c,v 1.14 2006/11/25 15:06:57 m0gg Exp $ +* $Id: soap-router.c,v 1.15 2007/11/03 22:40:09 m0gg Exp $ * * CSOAP Project: A SOAP client/server library in C * Copyright (C) 2003 Ferhat Ayaz @@ -40,8 +40,8 @@ #include #include -#include +#include "soap-logging.h" #include "soap-fault.h" #include "soap-ctx.h" #include "soap-service.h" @@ -55,7 +55,7 @@ soap_router_new(void) if (!(router = (struct SoapRouter *) malloc(sizeof(struct SoapRouter)))) { - log_error2("malloc failed (%s)", strerror(errno)); + log_error("malloc failed (%s)", strerror(errno)); return NULL; } memset(router, 0, sizeof(struct SoapRouter)); @@ -68,7 +68,7 @@ soap_router_register_service(struct SoapRouter *router, SoapServiceFunc func, co { SoapService *service; - log_verbose4("registering service (router=%p, method=\"%s\", urn=\"%s\")", router, method, urn); + log_verbose("registering service (router=%p, method=\"%s\", urn=\"%s\")", router, method, urn); if (!(service = soap_service_new(urn, method, func))) return herror_new("soap_router_register_service", 0, "soap_service_new failed"); @@ -136,24 +136,24 @@ soap_router_find_service(struct SoapRouter *router, const char *urn, const char if (router == NULL) { - log_verbose1("router is null"); + log_verbose("router is null"); return NULL; } if (urn == NULL) { - log_verbose1("URN is null"); + log_verbose("URN is null"); return NULL; } if (method == NULL) { - log_verbose1("method is null"); + log_verbose("method is null"); return NULL; } - log_verbose2("router = %p", router); - log_verbose2("router->service_head = %p", router->service_head); + log_verbose("router = %p", router); + log_verbose("router->service_head = %p", router->service_head); node = router->service_head; @@ -161,7 +161,7 @@ soap_router_find_service(struct SoapRouter *router, const char *urn, const char { if (node->service && node->service->urn && node->service->method) { - log_verbose4("checking service (node=%p, method=\"%s\", urn=\"%s\")", node->service, node->service->method, node->service->urn); + log_verbose("checking service (node=%p, method=\"%s\", urn=\"%s\")", node->service, node->service->method, node->service->urn); if (!strcmp(node->service->urn, urn) && !strcmp(node->service->method, method)) return node->service; } @@ -174,7 +174,7 @@ void soap_router_free(struct SoapRouter * router) { SoapServiceNode *node; - log_verbose2("enter: router=%p", router); + log_verbose("enter: router=%p", router); if (!router) return; @@ -182,7 +182,7 @@ soap_router_free(struct SoapRouter * router) while (router->service_head) { node = router->service_head->next; - /* log_verbose2("soap_service_free(%p)\n", + /* log_verbose("soap_service_free(%p)\n", router->service_head->service); */ soap_service_free(router->service_head->service); free(router->service_head); @@ -192,7 +192,7 @@ soap_router_free(struct SoapRouter * router) xmlFreeDoc(router->description); free(router); - log_verbose1("leave with success"); + log_verbose("leave with success"); return; } diff --git a/libcsoap/soap-server.c b/libcsoap/soap-server.c index 34b053f..5b23b8c 100644 --- a/libcsoap/soap-server.c +++ b/libcsoap/soap-server.c @@ -1,5 +1,5 @@ /****************************************************************** -* $Id: soap-server.c,v 1.36 2006/12/31 17:24:22 m0gg Exp $ +* $Id: soap-server.c,v 1.37 2007/11/03 22:40:09 m0gg Exp $ * * CSOAP Project: A SOAP client/server library in C * Copyright (C) 2003 Ferhat Ayaz @@ -41,8 +41,8 @@ #include #include -#include +#include "soap-logging.h" #include "soap-fault.h" #include "soap-env.h" #include "soap-ctx.h" @@ -66,7 +66,7 @@ router_node_new(struct SoapRouter * router, const char *context, SoapRouterNode if (!(node = (SoapRouterNode *) malloc(sizeof(SoapRouterNode)))) { - log_error2("malloc failed (%s)", strerror(errno)); + log_error("malloc failed (%s)", strerror(errno)); return NULL; } @@ -76,7 +76,7 @@ router_node_new(struct SoapRouter * router, const char *context, SoapRouterNode } else { - log_warn2("context is null, using '%s'", noname); + log_warn("context is null, using '%s'", noname); node->context = strdup(noname); } @@ -97,7 +97,7 @@ _soap_server_fillup_header(struct SoapEnv *envelope) { xmlURI *uri; - log_verbose1(__FUNCTION__); + log_verbose(""); if (!(uri = soap_addressing_get_message_id(envelope))) soap_addressing_set_message_id_string(envelope, NULL); @@ -139,16 +139,16 @@ soap_server_process(struct SoapCtx *request, struct SoapCtx **response) SoapService *service; herror_t err; - log_verbose1("**** processing ****"); + log_verbose("**** processing ****"); xmlDocDump(stdout, request->env->root->doc); - log_verbose1("********************"); + log_verbose("********************"); *response = soap_ctx_new(NULL); #ifdef HAVE_XMLSEC1 if ((err = soap_xmlsec_verify(request)) != H_OK) { - log_error2("soap_xmlsec_verify failed (%s)", herror_message(err)); + log_error("soap_xmlsec_verify failed (%s)", herror_message(err)); sprintf(buffer, "Verification of message signature failed (%s)", herror_message(err)); _soap_server_env_new_with_fault("Internal server error", buffer, &((*response)->env)); @@ -157,7 +157,7 @@ soap_server_process(struct SoapCtx *request, struct SoapCtx **response) if ((err = soap_xmlsec_decrypt(request)) != H_OK) { - log_error2("soap_xmlsec_decrypt failed (%s)", herror_message(err)); + log_error("soap_xmlsec_decrypt failed (%s)", herror_message(err)); sprintf(buffer, "Decryption of message body failed (%s)", herror_message(err)); _soap_server_env_new_with_fault("Internal server error", buffer, &((*response)->env)); return H_OK; @@ -166,19 +166,19 @@ soap_server_process(struct SoapCtx *request, struct SoapCtx **response) if ((method = soap_env_find_methodname(request->env))) { - log_verbose2("method: \"%s\"", method); + log_verbose("method: \"%s\"", method); if ((urn = soap_env_find_urn(request->env))) { - log_verbose2("urn: \"%s\"", urn); + log_verbose("urn: \"%s\"", urn); if ((uri = soap_addressing_get_to_address(request->env))) { - log_verbose2("searching router for \"%s\"", uri->path); + log_verbose("searching router for \"%s\"", uri->path); if ((router = soap_server_find_router(uri->path))) { - log_verbose2("router: %p", router); + log_verbose("router: %p", router); if ((service = soap_router_find_service(router, urn, method))) { - log_verbose3("service (%p) found, function (%p)", service, service->func); + log_verbose("service (%p) found, function (%p)", service, service->func); switch (service->status) { case CSOAP_SERVICE_UP: @@ -251,14 +251,14 @@ soap_server_init_args(int argc, char **argv) if ((status = soap_transport_server_init_args(argc, argv)) != H_OK) { - log_error2("soap_transport_server_init_args failed (%s)", herror_message(status)); + log_error("soap_transport_server_init_args failed (%s)", herror_message(status)); return status; } #ifdef HAVE_XMLSEC1 if ((status = soap_xmlsec_server_init_args(argc, argv)) != H_OK) { - log_error2("soap_xmlsec_server_init_args failed (%s)", herror_message(status)); + log_error("soap_xmlsec_server_init_args failed (%s)", herror_message(status)); return status; } #endif @@ -279,7 +279,7 @@ soap_server_register_router(struct SoapRouter *router, const char *context) if ((status = soap_transport_register(context)) != H_OK) { - log_error2("soap_transport_register failed (%s)", herror_message(status)); + log_error("soap_transport_register failed (%s)", herror_message(status)); return status; } @@ -322,7 +322,7 @@ soap_server_destroy(void) while (node != NULL) { tmp = node->next; - log_verbose2("soap_router_free(%p)", node->router); + log_verbose("soap_router_free(%p)", node->router); soap_router_free(node->router); free(node->context); free(node); diff --git a/libcsoap/soap-server.h b/libcsoap/soap-server.h index a97da1c..f2cebe5 100644 --- a/libcsoap/soap-server.h +++ b/libcsoap/soap-server.h @@ -1,5 +1,5 @@ /****************************************************************** - * $Id: soap-server.h,v 1.27 2007/01/25 10:28:30 m0gg Exp $ + * $Id: soap-server.h,v 1.28 2007/11/03 22:40:09 m0gg Exp $ * * CSOAP Project: A SOAP client/server library in C * Copyright (C) 2003 Ferhat Ayaz @@ -279,80 +279,79 @@ * */ +/** @file soap-server.h SOAP server interface + * + * @defgroup CSOAP cSOAP + */ + +/** @defgroup CSOAP_SERVER Server + * @ingroup CSOAP */ +/**@{*/ + +typedef struct _SoapRouterNode +{ + char *context; + struct SoapRouter *router; + struct _SoapRouterNode *next; + +} SoapRouterNode; + #ifdef __cplusplus extern "C" { #endif -/** - * - * Initializes the soap server with commandline arguments. +/** This function initializes the soap server with commandline + * arguments. * * @param argc commandline arg count * @param argv commandline arg vector * - * @returns H_OK on success - * - * @see httpd_init_args - * @see udpd_init_args + * @return H_OK on success. * + * @see httpd_init_args() + * @see udpd_init_args() */ herror_t soap_server_init_args(int argc, char **argv); -/** +/** This function registers a router to the SOAP server. * - * Register a router to the SOAP server. - * - *

scheme://host:port/[context] + @verbatim + scheme://host:port/[context] + @endverbatim * * @param router The router to register * @param context the url context * - * @returns H_OK on success + * @return H_OK on success. * - * @see soap_router_new - * @see soap_router_register_service - * + * @see soap_router_new() + * @see soap_router_register_service() */ extern herror_t soap_server_register_router(struct SoapRouter * router, const char *context); -/** - * - * Returns an URI name of the server. - * +/** This function returns an URI name of the server. */ extern const char *soap_server_get_name(void); -/** - * - * Enters the server loop and starts to listen to incoming requests. - * - * @see httpd_run - * @see udpd_run - * @see smptd_run +/** This function enters the server loop and starts to listen to + * incoming requests. * + * @see httpd_run() + * @see udpd_run() + * @see smptd_run() */ extern herror_t soap_server_run(void); -/** - * - * Frees the SOAP server. - * - * @see httpd_destroy - * @see udpd_destroy +/** This function frees the SOAP server. * + * @see httpd_destroy() + * @see udpd_destroy() + * @see smtpd_destroy() */ extern void soap_server_destroy(void); #ifdef __CSOAP_INTERNAL -typedef struct _SoapRouterNode -{ - char *context; - struct SoapRouter *router; - struct _SoapRouterNode *next; - -} SoapRouterNode; - extern struct SoapRouter *soap_server_find_router(const char *context); extern SoapRouterNode * soap_server_get_routers(void); @@ -365,4 +364,6 @@ extern herror_t soap_server_process(struct SoapCtx *request, struct SoapCtx **re } #endif +/**@}*/ + #endif diff --git a/libcsoap/soap-service.c b/libcsoap/soap-service.c index b731d76..813ca5b 100644 --- a/libcsoap/soap-service.c +++ b/libcsoap/soap-service.c @@ -1,5 +1,5 @@ /****************************************************************** -* $Id: soap-service.c,v 1.13 2006/12/31 17:24:22 m0gg Exp $ +* $Id: soap-service.c,v 1.14 2007/11/03 22:40:09 m0gg Exp $ * * CSOAP Project: A SOAP client/server library in C * Copyright (C) 2003 Ferhat Ayaz @@ -49,8 +49,8 @@ #include #include -#include +#include "soap-logging.h" #include "soap-fault.h" #include "soap-env.h" #include "soap-ctx.h" @@ -64,7 +64,7 @@ soap_service_node_new(SoapService * service, SoapServiceNode * next) if (!(node = (SoapServiceNode *) malloc(sizeof(SoapServiceNode)))) { - log_error2("malloc failed (%s)", strerror(errno)); + log_error("malloc failed (%s)", strerror(errno)); return NULL; } node->service = service; @@ -80,7 +80,7 @@ soap_service_new(const char *urn, const char *method, SoapServiceFunc f) if (!(service = (SoapService *) malloc(sizeof(SoapService)))) { - log_error2("malloc failed (%s)", strerror(errno)); + log_error("malloc failed (%s)", strerror(errno)); return NULL; } @@ -88,14 +88,14 @@ soap_service_new(const char *urn, const char *method, SoapServiceFunc f) if (urn == NULL) { - log_warn1("urn is NULL"); + log_warn("urn is NULL"); urn = ""; } service->urn = strdup(urn); if (method == NULL) { - log_warn1("method is NULL"); + log_warn("method is NULL"); method = ""; } service->method = strdup(method); diff --git a/libcsoap/soap-transport.c b/libcsoap/soap-transport.c index 765fa8f..cce1272 100644 --- a/libcsoap/soap-transport.c +++ b/libcsoap/soap-transport.c @@ -1,5 +1,5 @@ /****************************************************************** -* $Id: soap-transport.c,v 1.9 2006/12/14 19:36:49 m0gg Exp $ +* $Id: soap-transport.c,v 1.10 2007/11/03 22:40:09 m0gg Exp $ * * CSOAP Project: A SOAP client/server library in C * Copyright (C) 2007 Heiko Ronsdorf @@ -45,8 +45,8 @@ #include #include -#include +#include "soap-logging.h" #include "soap-fault.h" #include "soap-env.h" #include "soap-ctx.h" @@ -78,7 +78,7 @@ _soap_transport_new(const char *scheme, void *data, msg_exchange invoke) if (!(ret = (struct soap_transport *)malloc(sizeof(struct soap_transport)))) { - log_error2("malloc failed (%s)", strerror(errno)); + log_error("malloc failed (%s)", strerror(errno)); return NULL; } @@ -88,7 +88,7 @@ _soap_transport_new(const char *scheme, void *data, msg_exchange invoke) ret->data = data; ret->invoke = invoke; - log_verbose4("scheme=\"%s\", data=%p, invoke=%p", ret->scheme, ret->data, ret->invoke); + log_verbose("scheme=\"%s\", data=%p, invoke=%p", ret->scheme, ret->data, ret->invoke); return ret; } @@ -138,19 +138,19 @@ soap_transport_server_init_args(int argc, char **argv) if ((status = soap_nhttp_server_init_args(argc, argv)) != H_OK) { - log_error2("soap_nhttp_server_init_args failed (%s)", herror_message(status)); + log_error("soap_nhttp_server_init_args failed (%s)", herror_message(status)); return status; } if ((status = soap_nudp_server_init_args(argc, argv)) != H_OK) { - log_error2("soap_nudp_server_init_args failed (%s)", herror_message(status)); + log_error("soap_nudp_server_init_args failed (%s)", herror_message(status)); return status; } if ((status = _soap_transport_set_name()) != H_OK) { - log_error2("_soap_transport_set_name failed (%s)", herror_message(status)); + log_error("_soap_transport_set_name failed (%s)", herror_message(status)); return status; } @@ -164,13 +164,13 @@ soap_transport_register(const void *data) if ((status = soap_nhttp_register(data)) != H_OK) { - log_error2("soap_nhttp_register failed (%s)", herror_message(status)); + log_error("soap_nhttp_register failed (%s)", herror_message(status)); return status; } if ((status = soap_nudp_register(data)) != H_OK) { - log_error2("soap_nudp_register failed (%s)", herror_message(status)); + log_error("soap_nudp_register failed (%s)", herror_message(status)); return status; } @@ -185,7 +185,7 @@ soap_transport_add(const char *scheme, void *data, msg_exchange invoke) if (!(transport = _soap_transport_new(scheme, data, invoke))) { - log_error1("_soap_transport_new failed"); + log_error("_soap_transport_new failed"); return herror_new("soap_transport_add", 0, "_soap_transport_new failed"); } @@ -209,14 +209,14 @@ soap_transport_server_run(void) if ((status = soap_nudp_server_run_threaded()) != H_OK) { - log_error2("soap_nudp_server_run failed (%s)", herror_message(status)); + log_error("soap_nudp_server_run failed (%s)", herror_message(status)); return status; } /* nanoHTTP blocks in this call */ if ((status = soap_nhttp_server_run()) != H_OK) { - log_error2("soap_nhttp_server_run failed (%s)", herror_message(status)); + log_error("soap_nhttp_server_run failed (%s)", herror_message(status)); return status; } @@ -246,19 +246,19 @@ soap_transport_client_init_args(int argc, char **argv) if ((status = soap_nhttp_client_init_args(argc, argv)) != H_OK) { - log_error2("soap_nhttp_client_init_args failed (%s)", herror_message(status)); + log_error("soap_nhttp_client_init_args failed (%s)", herror_message(status)); return status; } if ((status = soap_nudp_client_init_args(argc, argv)) != H_OK) { - log_error2("soap_nudp_client_init_args failed (%s)", herror_message(status)); + log_error("soap_nudp_client_init_args failed (%s)", herror_message(status)); return status; } if ((status = _soap_transport_set_name()) != H_OK) { - log_error2("_soap_transport_set_name failed (%s)", herror_message(status)); + log_error("_soap_transport_set_name failed (%s)", herror_message(status)); return status; } @@ -272,29 +272,29 @@ soap_transport_client_invoke(struct SoapCtx *request, struct SoapCtx **response) herror_t ret; xmlURI *dest; - /* log_verbose1(__FUNCTION__); + /* log_verbose(__FUNCTION__); xmlDocFormatDump(stdout, request->env->root->doc, 1); */ if (!(dest = soap_addressing_get_to_address(request->env))) { - log_verbose1("soap_addressing_get_to_address failed"); + log_verbose("soap_addressing_get_to_address failed"); return herror_new("soap_transport_client_invoke", 0, "cannot find to address in SOAP envelope"); } if (!dest->scheme) { - log_verbose1("missing scheme (protocol) in to address"); + log_verbose("missing scheme (protocol) in to address"); return herror_new("soap_transport_client_invoke", 0, "cannot find protocol in destination address"); } - log_verbose2("trying to contact \"%s\"", soap_addressing_get_to_address_string(request->env)); + log_verbose("trying to contact \"%s\"", soap_addressing_get_to_address_string(request->env)); for (walker=head; walker; walker=walker->next) { - log_verbose3("testing transport server \"%s\" for \"%s\"", walker->scheme, dest->scheme); + log_verbose("testing transport server \"%s\" for \"%s\"", walker->scheme, dest->scheme); if (!strcmp(walker->scheme, dest->scheme)) { - log_verbose3("found transport layer for \"%s\" (%p)", dest->scheme, walker->invoke); + log_verbose("found transport layer for \"%s\" (%p)", dest->scheme, walker->invoke); ret = walker->invoke(walker->data, request, response); xmlFreeURI(dest); return ret; diff --git a/libcsoap/soap-transport.h b/libcsoap/soap-transport.h index 5cc3e68..18501fa 100644 --- a/libcsoap/soap-transport.h +++ b/libcsoap/soap-transport.h @@ -1,5 +1,5 @@ /****************************************************************** -* $Id: soap-transport.h,v 1.2 2006/11/23 15:27:33 m0gg Exp $ +* $Id: soap-transport.h,v 1.3 2007/11/03 22:40:09 m0gg Exp $ * * CSOAP Project: A SOAP client/server library in C * Copyright (C) 2007 Heiko Ronsdorf @@ -24,6 +24,10 @@ #ifndef __csoap_transport_h #define __csoap_transport_h +#ifdef __CSOAP_INTERNAL +#pragma You should not include this file... +#endif + #ifdef __CSOAP_INTERNAL typedef herror_t (*msg_exchange)(void *data, struct SoapCtx *request, struct SoapCtx **response); diff --git a/libcsoap/soap-xml.c b/libcsoap/soap-xml.c index f718faf..ffbfbec 100644 --- a/libcsoap/soap-xml.c +++ b/libcsoap/soap-xml.c @@ -1,5 +1,5 @@ /****************************************************************** -* $Id: soap-xml.c,v 1.13 2006/11/26 20:13:05 m0gg Exp $ +* $Id: soap-xml.c,v 1.14 2007/11/03 22:40:10 m0gg Exp $ * * CSOAP Project: A SOAP client/server library in C * Copyright (C) 2003 Ferhat Ayaz @@ -26,11 +26,8 @@ #endif #include -#include -#include - -#include +#include "soap-logging.h" #include "soap-xml.h" xmlNodePtr @@ -40,26 +37,28 @@ soap_xml_get_children(xmlNodePtr node) if (node == NULL) { - log_error1("Invalid node (null)"); + log_error("Invalid node (null)"); return NULL; } for (child = node->children; child; child=child->next) { if (child->type == XML_ELEMENT_NODE) + { return child; + } } return NULL; } xmlNodePtr -soap_xml_get_next(xmlNodePtr param) +soap_xml_get_next_element(xmlNodePtr param) { if (param == NULL) { - log_error1("Invalid node (null)"); + log_error("Invalid node (null)"); return NULL; } @@ -76,24 +75,6 @@ soap_xml_get_next(xmlNodePtr param) return node; } -xmlXPathObjectPtr -soap_xpath_eval(xmlDocPtr doc, const char *xpath) -{ - xmlXPathContextPtr context; - xmlXPathObjectPtr result; - - context = xmlXPathNewContext(doc); - result = xmlXPathEvalExpression(BAD_CAST xpath, context); - if (xmlXPathNodeSetIsEmpty(result->nodesetval)) - { - /* no result */ - return NULL; - } - - xmlXPathFreeContext(context); - return result; -} - char * soap_xml_get_text(xmlNodePtr node) { diff --git a/libcsoap/soap-xml.h b/libcsoap/soap-xml.h index c03c6ea..1136e38 100644 --- a/libcsoap/soap-xml.h +++ b/libcsoap/soap-xml.h @@ -1,5 +1,5 @@ /****************************************************************** - * $Id: soap-xml.h,v 1.12 2006/12/03 17:30:57 m0gg Exp $ + * $Id: soap-xml.h,v 1.13 2007/11/03 22:40:10 m0gg Exp $ * * CSOAP Project: A SOAP client/server library in C * Copyright (C) 2003 Ferhat Ayaz @@ -24,14 +24,21 @@ #ifndef __csoap_xml_h #define __csoap_xml_h -/** - * - * XML Errors +/** @file soap-xml.h SOAP XML functions * + * @defgroup CSOAP_XML XML handling + * @ingroup CSOAP + */ +/**@{*/ + +/** @defgroup CSOAP_XML_ERRORS XML errors + * @ingroup CSOAP_ERRORS */ +/**@{*/ #define XML_ERROR 1600 #define XML_ERROR_EMPTY_DOCUMENT (XML_ERROR + 1) #define XML_ERROR_PARSE (XML_ERROR + 2) +/**@}*/ 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"; @@ -42,9 +49,8 @@ extern "C" { #endif extern xmlNodePtr soap_xml_get_children(xmlNodePtr param); -extern xmlNodePtr soap_xml_get_next(xmlNodePtr param); -extern xmlXPathObjectPtr soap_xpath_eval(xmlDocPtr doc, const char *xpath); +extern xmlNodePtr soap_xml_get_next_element(xmlNodePtr param); extern char *soap_xml_get_text(xmlNodePtr node); @@ -52,4 +58,6 @@ extern char *soap_xml_get_text(xmlNodePtr node); } #endif +/**@}*/ + #endif diff --git a/libcsoap/soap-xmlsec.c b/libcsoap/soap-xmlsec.c index 01e5ae0..df04e28 100644 --- a/libcsoap/soap-xmlsec.c +++ b/libcsoap/soap-xmlsec.c @@ -1,5 +1,5 @@ /****************************************************************** -* $Id: soap-xmlsec.c,v 1.8 2006/12/14 19:36:49 m0gg Exp $ +* $Id: soap-xmlsec.c,v 1.9 2007/11/03 22:40:10 m0gg Exp $ * * CSOAP Project: A SOAP client/server library in C * Copyright (C) 2003 Ferhat Ayaz @@ -70,8 +70,6 @@ #include #include #include -#include -#include #ifndef XMLSEC_NO_XSLT #include @@ -85,7 +83,6 @@ #include #include -#include #include #include #include @@ -94,6 +91,7 @@ #include #include +#include "soap-logging.h" #include "soap-env.h" #include "soap-ctx.h" #include "soap-service.h" @@ -115,7 +113,7 @@ static xmlSecKeyPtr _soap_xmlsec_key = NULL; static void _soap_xmlsec_error_callback(const char *file, int line, const char *func, const char *errorObject, const char *errorSubject, int reason, const char *msg) { - log_error5("xmlsec error func=\"%s\" obj=\"%s\" sub=\"%s\" %s", func, errorObject, errorSubject, msg); + log_error("xmlsec error func=\"%s\" obj=\"%s\" sub=\"%s\" %s", func, errorObject, errorSubject, msg); return; } @@ -139,7 +137,7 @@ _soap_xmlsec_files_keys_store_find_key(xmlSecKeyStorePtr store, const xmlChar * xmlURI *uri; char *file; - log_verbose2("trying to find key \"%s\"\n", name); + log_verbose("trying to find key \"%s\"\n", name); /* * it's possible to do not have the key name or desired key type but we could @@ -205,7 +203,7 @@ _soap_xmlsec_files_keys_store_find_key(xmlSecKeyStorePtr store, const xmlChar * if ((status = (httpc_get(conn, &res, name))) != H_OK) { - log_error2("httpc_get failed (%s)", herror_message(status)); + log_error("httpc_get failed (%s)", herror_message(status)); herror_release(status); return NULL; } @@ -254,7 +252,7 @@ _soap_xmlsec_files_keys_store_find_key(xmlSecKeyStorePtr store, const xmlChar * if (unlink(file) < 0) { - log_error2("unlink file failed (%s)", strerror(errno)); + log_error("unlink file failed (%s)", strerror(errno)); } free(file); @@ -289,14 +287,14 @@ _soap_xmlsec_create_key_manager(void) keysStore = xmlSecKeyStoreCreate(_soap_xmlsec_files_keys_store_get_klass()); if (keysStore == NULL) { - log_error1("failed to create keys store"); + log_error("failed to create keys store"); return herror_new("_soap_xmlxec_create_key_manager", XMLSEC_ERROR_KEYSTORE, "failed to create keys store"); } /* create keys manager */ if ((_soap_xmlsec_key_manager = xmlSecKeysMngrCreate()) == NULL) { - log_error1("failed to create keys manager"); + log_error("failed to create keys manager"); xmlSecKeyStoreDestroy(keysStore); return herror_new("_soap_xmlsec_key_manager", XMLSEC_ERROR_KEYMANAGER, "failed to create keys manager"); } @@ -307,7 +305,7 @@ _soap_xmlsec_create_key_manager(void) */ if (xmlSecKeysMngrAdoptKeysStore(_soap_xmlsec_key_manager, keysStore) < 0) { - log_error1("failed to add keys store to keys manager"); + log_error("failed to add keys store to keys manager"); xmlSecKeyStoreDestroy(keysStore); xmlSecKeysMngrDestroy(_soap_xmlsec_key_manager); _soap_xmlsec_key_manager = NULL; @@ -317,7 +315,7 @@ _soap_xmlsec_create_key_manager(void) /* initialize crypto library specific data in keys manager */ if (xmlSecCryptoKeysMngrInit(_soap_xmlsec_key_manager) < 0) { - log_error1("failed to initialize crypto data in keys manager"); + log_error("failed to initialize crypto data in keys manager"); xmlSecKeysMngrDestroy(_soap_xmlsec_key_manager); _soap_xmlsec_key_manager = NULL; return herror_new("_soap_xmlsec_create_key_manager", XMLSEC_ERROR_KEYMANAGER, "failed to initialize crypto data in keys manager"); @@ -337,7 +335,7 @@ _soap_xmlsec_load_key(void) if ((_soap_xmlsec_key = xmlSecCryptoAppKeyLoad(_soap_xmlsec_keyfile, xmlSecKeyDataFormatPem, _soap_xmlsec_password, NULL, NULL)) == NULL) { - log_error2("xmlSecCryptoAppKeyLoad(\"%s\") failed", _soap_xmlsec_keyfile); + log_error("xmlSecCryptoAppKeyLoad(\"%s\") failed", _soap_xmlsec_keyfile); return herror_new("_soap_xmlsec_load_key", XMLSEC_ERROR_KEY, "xmlSecCryptoAppKeyLoad(\"%s\") failed", _soap_xmlsec_keyfile); } @@ -345,18 +343,18 @@ _soap_xmlsec_load_key(void) { if (xmlSecCryptoAppKeyCertLoad(_soap_xmlsec_key, _soap_xmlsec_certfile, xmlSecKeyDataFormatPem) < 0) { - log_error2("xmlSecCryptoAppKeyCertLoad(\"%s\") failed", _soap_xmlsec_certfile); + log_error("xmlSecCryptoAppKeyCertLoad(\"%s\") failed", _soap_xmlsec_certfile); xmlSecKeyDestroy(_soap_xmlsec_key); return herror_new("_soap_xmlsec_load_key", XMLSEC_ERROR_CERTIFICATE, "xmlSecCryptoAppKeyCertLoad(\"%s\") failed", _soap_xmlsec_certfile); } } xmlStrPrintf(keyName, 256, "%s/key.pem", soap_server_get_name()); - log_error2("keyName is \"%s\"", keyName); + log_error("keyName is \"%s\"", keyName); if ((err = xmlSecKeySetName(_soap_xmlsec_key, keyName)) < 0) { xmlSecKeyDestroy(_soap_xmlsec_key); - log_error3("xmlSecKeySetName(\"%s\") failed (%i)", keyName, err); + log_error("xmlSecKeySetName(\"%s\") failed (%i)", keyName, err); return herror_new("_soap_xmlsec_load_key", XMLSEC_ERROR_KEY, "xmlSecKeySetName(\"%s\") failed (%i)", keyName, err); } @@ -397,7 +395,7 @@ _soap_xmlsec_publish_key(void) if ((status = httpd_register("/key.pem", _soap_xmlsec_key_service)) != H_OK) { - log_error2("Cannot register key service (%s)", herror_message(status)); + log_error("Cannot register key service (%s)", herror_message(status)); return status; } @@ -441,59 +439,59 @@ _soap_xmlsec_init(void) if (initialized) return H_OK; - log_info1("initializing xmlsec1"); + log_info("initializing xmlsec1"); xmlSecErrorsDefaultCallbackEnableOutput(1); xmlSecErrorsSetCallback(_soap_xmlsec_error_callback); if (xmlSecInit() < 0) { - log_error1("xmlSecInit failed"); + log_error("xmlSecInit failed"); return herror_new("soap_xmlsec_init", XMLSEC_ERROR_INIT, "xmlSecInit failed"); } if (xmlSecCheckVersion() != 1) { - log_error1("xmlSecCheckVersion failed, wrong xmlsec version"); + log_error("xmlSecCheckVersion failed, wrong xmlsec version"); return herror_new("soap_xmlsec_init", XMLSEC_ERROR_VERSION, "Wrong xmlsec version"); } #ifdef XMLSEC_CRYPTO_DYNAMIC_LOADING - log_verbose2("loading \"%s\" dynamic", XMLSEC_CRYPTO); + log_verbose("loading \"%s\" dynamic", XMLSEC_CRYPTO); if (xmlSecCryptoDLLoadLibrary(BAD_CAST XMLSEC_CRYPTO) < 0) { - log_error1("xmlSecCryptoDLLoadLibrary failed"); + log_error("xmlSecCryptoDLLoadLibrary failed"); return herror_new("soap_xmlsec_init", XMLSEC_ERROR_DLLOAD, "xmlSecCryptoDLLoadLibrary failed"); } #endif if (xmlSecCryptoAppInit(NULL) < 0) { - log_error1("xmlSecCryptoAppInit failed"); + log_error("xmlSecCryptoAppInit failed"); return herror_new("soap_xmlsec_init", XMLSEC_ERROR_INIT, "xmlSecCryptoAppInit failed"); } if (xmlSecCryptoInit() < 0) { - log_error1("xmlSecCryptoInit failed"); + log_error("xmlSecCryptoInit failed"); return herror_new("soap_xmlsec_init", XMLSEC_ERROR_INIT, "xmlSecCryptoInit failed"); } if ((status = _soap_xmlsec_create_key_manager()) != H_OK) { - log_error2("_soap_xmlsec_create_key_manager failed (%s)", herror_message(status)); + log_error("_soap_xmlsec_create_key_manager failed (%s)", herror_message(status)); return status; } if ((err = pthread_mutex_init(&_soap_xmlsec_lock, NULL)) < 0) { - log_error2("pthread_mutex_init failed (%s)", strerror(err)); + log_error("pthread_mutex_init failed (%s)", strerror(err)); return herror_new("soap_xmlsec_init", XMLSEC_ERROR_INIT, "pthread_mutex_init failed (%s)", strerror(err)); } if ((status = _soap_xmlsec_load_key()) != H_OK) { - log_error2("_soap_xmlsec_load_key failed (%s)", herror_message(status)); + log_error("_soap_xmlsec_load_key failed (%s)", herror_message(status)); return status; } @@ -525,13 +523,13 @@ soap_xmlsec_server_init_args(int argc, char **argv) if ((status = _soap_xmlsec_init()) != H_OK) { - log_error2("_soap_xmlsec_init failed (%s)", herror_message(status)); + log_error("_soap_xmlsec_init failed (%s)", herror_message(status)); return status; } if ((status = _soap_xmlsec_publish_key()) != H_OK) { - log_error2("_soap_xmlsec_publish_key failed (%s)", herror_message(status)); + log_error("_soap_xmlsec_publish_key failed (%s)", herror_message(status)); return status; } @@ -560,7 +558,7 @@ herror_t soap_xmlsec_sign(struct SoapCtx *context) if (!(signNode = xmlSecTmplSignatureCreate(envelope->root->doc, xmlSecTransformExclC14NId, xmlSecTransformRsaSha1Id, NULL))) { - log_error1("xmlSecTmplSignatureCreate failed"); + log_error("xmlSecTmplSignatureCreate failed"); ret = herror_new("soap_xmlsec_sign", XMLSEC_ERROR_SIGN_INIT, "xmlSecTmplSignatureCreate failed"); goto out; } @@ -578,28 +576,28 @@ herror_t soap_xmlsec_sign(struct SoapCtx *context) if (!(refNode = xmlSecTmplSignatureAddReference(signNode, xmlSecTransformSha1Id, "#Body", NULL, NULL))) { - log_error1("xmlSecTmplSignatureAddReference failed"); + log_error("xmlSecTmplSignatureAddReference failed"); ret = herror_new("soap_xmlsec_sign", XMLSEC_ERROR_SIGN_INIT, "xmlSecTmplSignatureAddReference failed"); goto out; } if (!(keyInfoNode = xmlSecTmplSignatureEnsureKeyInfo(signNode, NULL))) { - log_error1("xmlSecTmplSignatureEnsureKeyInfo failed"); + log_error("xmlSecTmplSignatureEnsureKeyInfo failed"); ret = herror_new("soap_xmlsec_sign", XMLSEC_ERROR_SIGN_INIT, "xmlSecTmplSignatureEnsureKeyInfo failed"); goto out; } if (xmlSecTmplKeyInfoAddKeyName(keyInfoNode, soap_server_get_name()) == NULL) { - log_error1("xmlSecTmplKeyInfoAddKeyName failed"); + log_error("xmlSecTmplKeyInfoAddKeyName failed"); ret = herror_new("soap_xmlsec_sign", XMLSEC_ERROR_SIGN_INIT, "xmlSecTmplKeyInfoAddKeyName failed"); goto out; } if (!(dsigCtx = xmlSecDSigCtxCreate(_soap_xmlsec_key_manager))) { - log_error1("xmlSecDSigCtxCreate failed"); + log_error("xmlSecDSigCtxCreate failed"); ret = herror_new("soap_xmlsec_sign", XMLSEC_ERROR_SIGN_INIT, "xmlSecDSigCtxCreate failed"); goto out; } @@ -608,7 +606,7 @@ herror_t soap_xmlsec_sign(struct SoapCtx *context) if (xmlSecDSigCtxSign(dsigCtx, signNode) < 0) { - log_error1("xmlSecDSigCtxSign failed"); + log_error("xmlSecDSigCtxSign failed"); ret = herror_new("soap_xmlsec_sign", XMLSEC_ERROR_SIGN, "xmlSecDSigCtxSign failed"); goto out; } @@ -651,14 +649,14 @@ herror_t soap_xmlsec_encrypt(struct SoapCtx *context) encDataNode = xmlSecTmplEncDataCreate(doc, xmlSecTransformDes3CbcId, NULL, xmlSecTypeEncElement, NULL, NULL); if (encDataNode == NULL) { - log_error1("xmlSecTmplEnvDataCreate failed"); + log_error("xmlSecTmplEnvDataCreate failed"); ret = herror_new("soap_xmlsec_encrypt", XMLSEC_ERROR_ENCRYPT_INIT, "xmlSecTmplEnvDataCreate failed"); goto out; } if (xmlSecTmplEncDataEnsureCipherValue(encDataNode) == NULL) { - log_error1("failed to add CipherValue node"); + log_error("failed to add CipherValue node"); ret = herror_new("soap_xmlsec_encrypt", XMLSEC_ERROR_ENCRYPT_INIT, "failed to add CipherValue node"); goto out; } @@ -666,7 +664,7 @@ herror_t soap_xmlsec_encrypt(struct SoapCtx *context) keyInfoNode = xmlSecTmplEncDataEnsureKeyInfo(encDataNode, NULL); if (keyInfoNode == NULL) { - log_error1("failed to add KeyInfo node"); + log_error("failed to add KeyInfo node"); ret = herror_new("soap_xmlsec_encrypt", XMLSEC_ERROR_ENCRYPT_INIT, "failed to add KeyInfo node"); goto out; } @@ -674,14 +672,14 @@ herror_t soap_xmlsec_encrypt(struct SoapCtx *context) encKeyNode = xmlSecTmplKeyInfoAddEncryptedKey(keyInfoNode, xmlSecTransformRsaOaepId, NULL, NULL, NULL); if (encKeyNode == NULL) { - log_error1("failed to add KeyInfo"); + log_error("failed to add KeyInfo"); ret = herror_new("soap_xmlsec_encrypt", XMLSEC_ERROR_ENCRYPT_INIT, "failed to add KeyInfo"); goto out; } if (xmlSecTmplEncDataEnsureCipherValue(encKeyNode) == NULL) { - log_error1("failed to add CipherValue node"); + log_error("failed to add CipherValue node"); ret = herror_new("soap_xmlsec_encrypt", XMLSEC_ERROR_ENCRYPT_INIT, "failed to add CipherValue node"); goto out; } @@ -689,24 +687,24 @@ herror_t soap_xmlsec_encrypt(struct SoapCtx *context) keyInfoNode2 = xmlSecTmplEncDataEnsureKeyInfo(encKeyNode, NULL); if (keyInfoNode2 == NULL) { - log_error1("failed to add key info (2)\n"); + log_error("failed to add key info (2)\n"); ret = herror_new("soap_xmlsec_encrypt", XMLSEC_ERROR_ENCRYPT_INIT, "failed to add key info (2)"); goto out; } if (!(to = soap_addressing_get_to_address(envelope))) { - log_error1("cannot get to address"); + log_error("cannot get to address"); ret = herror_new("soap_xmlsec_encrypt", XMLSEC_ERROR_ENCRYPT, "cannot get to address"); goto out; } xmlStrPrintf(buf, 256, "http://%s:%i/key.pem", to->server, to->port); - log_error2("adding key \"%s\"", buf); + log_error("adding key \"%s\"", buf); xmlFreeURI(to); if (xmlSecTmplKeyInfoAddKeyName(keyInfoNode2, buf) == NULL) { - log_error2("failed to add key name \"%s\"", buf); + log_error("failed to add key name \"%s\"", buf); ret = herror_new("soap_xmlsec_encrypt", XMLSEC_ERROR_ENCRYPT_INIT, "failed to add key name \"%s\"", buf); goto out; } @@ -714,7 +712,7 @@ herror_t soap_xmlsec_encrypt(struct SoapCtx *context) encCtx = xmlSecEncCtxCreate(_soap_xmlsec_key_manager); if (encCtx == NULL) { - log_error1("failed to create encryption context"); + log_error("failed to create encryption context"); ret = herror_new("soap_xmlsec_encrypt", XMLSEC_ERROR_ENCRYPT_INIT, "failed to create encryption context"); goto out; } @@ -722,7 +720,7 @@ herror_t soap_xmlsec_encrypt(struct SoapCtx *context) encCtx->encKey = xmlSecKeyGenerate(xmlSecKeyDataDesId, 192, xmlSecKeyDataTypeSession); if (encCtx->encKey == NULL) { - log_error1("failed to generate session key"); + log_error("failed to generate session key"); ret = herror_new("soap_xmlsec_encrypt", XMLSEC_ERROR_ENCRYPT_INIT, "failed to generate session key"); goto out; } @@ -733,7 +731,7 @@ herror_t soap_xmlsec_encrypt(struct SoapCtx *context) if (xmlSecEncCtxXmlEncrypt(encCtx, encDataNode, soap_env_get_method(envelope)) < 0) { - log_error1("encryption failed"); + log_error("encryption failed"); ret = herror_new("soap_xmlsec_encrypt", XMLSEC_ERROR_ENCRYPT, "encryption failed"); goto out; } @@ -772,19 +770,19 @@ herror_t soap_xmlsec_decrypt(struct SoapCtx *context) if (!(method = soap_env_get_method(envelope))) { - log_error1("cannot find messages method"); + log_error("cannot find messages method"); return herror_new("soap_xmlsec_decrypt", 0, "cannot find message method"); } if (xmlStrcmp(method->name, BAD_CAST "EncryptedData")) { - log_error2("message doesn't contain encrypted data (%s)", method->name); + log_error("message doesn't contain encrypted data (%s)", method->name); return H_OK; } if (xmlStrcmp(method->ns->href, "http://www.w3.org/2001/04/xmlenc#")) { - log_error2("message encryption isn't understood (%s)", method->ns->href); + log_error("message encryption isn't understood (%s)", method->ns->href); return herror_new("soap_xmlsec_decrypt", 0, "message encryption isn't understood (%s)", method->ns->href); } @@ -794,7 +792,7 @@ herror_t soap_xmlsec_decrypt(struct SoapCtx *context) node = xmlSecFindNode(envelope->root, xmlSecNodeEncryptedData, xmlSecEncNs); if (node == NULL) { - log_error1("start node not found"); + log_error("start node not found"); ret = herror_new("soap_xmlsec_decrypt", 0, "start node not found"); goto done; } @@ -803,7 +801,7 @@ herror_t soap_xmlsec_decrypt(struct SoapCtx *context) encCtx = xmlSecEncCtxCreate(_soap_xmlsec_key_manager); if (encCtx == NULL) { - log_error1("failed to create encryption context"); + log_error("failed to create encryption context"); ret = herror_new("soap_xmlsec_decrypt", 0, "failed to create encryption context"); goto done; } @@ -811,7 +809,7 @@ herror_t soap_xmlsec_decrypt(struct SoapCtx *context) /* decrypt the data */ if ((xmlSecEncCtxDecrypt(encCtx, node) < 0) || (encCtx->result == NULL)) { - log_error1("decryption failed"); + log_error("decryption failed"); ret = herror_new("soap_xmlsec_decrypt", 0, "decryption failed"); goto done; } @@ -855,7 +853,7 @@ herror_t soap_xmlsec_verify(struct SoapCtx *context) if (!envelope->header) { - log_error1("message doesn't contain a SOAP header"); + log_error("message doesn't contain a SOAP header"); return herror_new("soap_xmlsec_verify", 0, "message doesn't contain a SOAP header"); } @@ -873,20 +871,20 @@ herror_t soap_xmlsec_verify(struct SoapCtx *context) node = xmlSecFindNode(envelope->root, xmlSecNodeSignature, xmlSecDSigNs); if (node == NULL) { - log_error1("cannot find message signature"); + log_error("cannot find message signature"); return herror_new("soap_xmlsec_verify", 0, "message signature wasn't found"); } dsigCtx = xmlSecDSigCtxCreate(_soap_xmlsec_key_manager); if (dsigCtx == NULL) { - log_error1("cannot create signature context"); + log_error("cannot create signature context"); return herror_new("soap_xmlsec_verify", 0, "cannot create signatur context"); } if (xmlSecDSigCtxVerify(dsigCtx, node) < 0) { - log_error1("xmlsecDSigCtxVerify failed"); + log_error("xmlsecDSigCtxVerify failed"); return herror_new("soap_xmlsec_verify", 0, "verification failed"); } @@ -896,13 +894,13 @@ herror_t soap_xmlsec_verify(struct SoapCtx *context) } else { - log_error1("signature invalid"); + log_error("signature invalid"); return herror_new("soap_xmlsec_verify", 0, "signature invalid"); } } else { - log_error2("message signature isn't understood (%s)", walker->ns->href); + log_error("message signature isn't understood (%s)", walker->ns->href); return herror_new("soap_xmlsec_verify", 0, "message signature isn't understood (%s)", walker->ns->href); } } diff --git a/libcsoap/soap-xmlsec.h b/libcsoap/soap-xmlsec.h index 2952368..89b00e7 100644 --- a/libcsoap/soap-xmlsec.h +++ b/libcsoap/soap-xmlsec.h @@ -1,5 +1,5 @@ /****************************************************************** - * $Id: soap-xmlsec.h,v 1.9 2007/01/25 10:28:30 m0gg Exp $ + * $Id: soap-xmlsec.h,v 1.10 2007/11/03 22:40:10 m0gg Exp $ * * CSOAP Project: A SOAP client/server library in C * Copyright (C) 2006 Heiko Ronsdorf @@ -49,57 +49,48 @@ * * @see nanohttp_ssl_page * @see http://www.aleksey.com/xmlsec/ - * */ -/** @file +/** @file soap-xmlsec.h xmlsec wrapper + * + * @defgroup CSOAP_WSS Web Service Security + * @ingroup CSOAP * * @section soap_wss_sec Web Services Security * * This module is implemented using the xmlsec1 library. * * @author H. Ronsdorf - * @version $Revision: 1.9 $ + * @version $Revision: 1.10 $ * * @see http://www.w3.org/TR/SOAP-dsig/ * @see http://www.oasis-open.org/committees/tc_home.php?wg_abbrev=wss * @see http://www.aleksey.com/xmlsec/ - * */ +/**@{*/ #define SOAP_SECURITY_NAMESPACE "http://schemas.xmlsoap.org/soap/security/2000-12" #define SOAP_SECURITY_PREFIX "SOAP-SEC" -/** - * - * Commandline argument to enable WS-Security. - * +/** Commandline argument to enable WS-Security. */ #define CSOAP_ENABLE_XMLSEC "-CSOAPxmlsec" -/** - * - * Commandline argument to set the keyfile. If this argument is not specified, a - * random key will be used. - * +/** Commandline argument to set the keyfile. If this argument is not + * specified, a random key will be used. */ #define CSOAP_XMLSEC_KEYFILE "-CSOAPkeyfile" -/** - * - * Commandline argument to set the password of the key. - * +/** Commandline argument to set the password of the key. */ #define CSOAP_XMLSEC_PASSWORD "-CSOAPpassword" -/** - * - * Commandline argument to set a file of certificates. - * +/** Commandline argument to set a file of certificates. */ #define CSOAP_XMLSEC_CERTFILE "-CSOAPcertfile" -/** @defgroup xmlsec_errors XML-security errors +/** @defgroup CSOAP_XMLSEC_ERRORS XML-security errors + * @ingroup CSOAP_ERRORS * * Various errors related to XML-security * @@ -124,123 +115,116 @@ extern "C" { #endif -/** - * - * Initializes the WS-Security subsystem. +/** This function initializes the WS-Security subsystem for a SOAP + * server. * * @param argc commandline arg count * @param argv commandline arg vector * - * @return H_OK on success + * @return H_OK on success. * + * @see soap_xmlsec_destroy() */ extern herror_t soap_xmlsec_server_init_args(int argc, char **argv); -/** - * - * Initializes the WS-Security subsystem. +/** This function initializes the WS-Security subsystem for a SOAP + * client. * * @param argc commandline arg count * @param argv commandline arg vector * - * @return H_OK on success + * @return H_OK on success. * + * @see soap_xmlsec_destroy() */ extern herror_t soap_xmlsec_client_init_args(int argc, char **argv); -/** - * - * Sign a XML document contained in a SOAP Envelope with the key specified on - * the commandline. Our way to create a header entry is as - * follows: - * - * - Prepare the target SOAP Envelope with the body and necessary headers. - * - Create a template of a element. The template is assumed to - * contain empty contents for or elements, - * but contains appropriate values for the elements such as - * and required to calculate them. - * - Create a new header entry and add the template to this - * entry. +/** This function signs an XML document contained in a SOAP Envelope + * with the key specified on the commandline. Our way to create a + * header entry is as follows: + * + * - Prepare the target SOAP Envelope with the body and necessary + * headers. + * - Create a template of a element. The template is + * assumed to contain empty contents for or + * elements, but contains appropriate values for + * the elements such as and + * required to calculate them. + * - Create a new header entry and add the + * template to this entry. * - Add the header entry to the SOAP Header. - * - Add the SOAP "actor" and "mustUnderstand" attributes to the entry, if - * necessary. - * - Calculate the and elements according - * to the core generation of the XML-Signature specification. - * - * XPath filtering can be used to specify objects to be signed, as described in - * the XML-Signature specification. However, since the SOAP message exchange - * model allows intermediate applications to modify the Envelope (add or delete - * a header entry, for example), XPath filtering does not always result in the - * same objects after message delivery. Care should be taken in using XPath - * filtering so that there is no subsequent validation failure due to such - * modifications. - * - * The transform http://www.w3.org/2000/09/xmldsig#enveloped-signature defined - * in the XML-Signature specification may be useful when signing the entire - * Envelope including other header entries, if any. + * - Add the SOAP "actor" and "mustUnderstand" attributes to the entry, + * if necessary. + * - Calculate the and elements + * according to the core generation of the XML-Signature specification. + * + * XPath filtering can be used to specify objects to be signed, as + * described in the XML-Signature specification. However, since the SOAP + * message exchange model allows intermediate applications to modify the + * Envelope (add or delete a header entry, for example), XPath filtering + * does not always result in the same objects after message delivery. + * Care should be taken in using XPath filtering so that there is no + * subsequent validation failure due to such modifications. + * + * The transform http://www.w3.org/2000/09/xmldsig#enveloped-signature + * defined in the XML-Signature specification may be useful when + * signing the entire Envelope including other header entries, if any. * * @param context The SOAP context to be signed. * - * @return H_OK on success + * @return H_OK on success. * * @see http://www.w3.org/TR/SOAP-dsig/ * @see http://www.w3.org/TR/xmldsig-core/ - * */ extern herror_t soap_xmlsec_sign(struct SoapCtx *context); -/** - * - * Verify a XML documents signature contained in a SOAP Envelope. The validation - * of a header entry fails if: - * - * - The syntax of the content of the header entry does not conform to SOAP - * Security Extensions: Digital Signature specification, or - * - The validation of the signature contained in the header entry fails - * according to the core validation of the XML-Signature specification, or - * - The receiving application program rejects the signature for some reason - * (e.g., the signature is created by an untrusted key). - * - * If the validation of the signature header entry fails, applications MAY report - * the failure to the sender. It is out of the scope of this library how to deal - * with it. +/** This function verifies an XML documents signature contained in a + * SOAP Envelope. The validation of a header entry + * fails if: + * - The syntax of the content of the header entry does not conform to + * SOAP Security Extensions: Digital Signature specification, or + * - the validation of the signature contained in the header entry fails + * according to the core validation of the XML-Signature + * specification, or + * - the receiving application program rejects the signature for some + * reason (e.g., the signature is created by an untrusted key). + * + * If the validation of the signature header entry fails, applications + * MAY report the failure to the sender. It is out of the scope of this + * library how to deal with it. * * @param context The SOAP context to be verified. * - * @return H_OK on success + * @return H_OK on success. * * @see http://www.w3.org/TR/SOAP-dsig/ * @see http://www.w3.org/TR/xmldsig-core/ - * */ extern herror_t soap_xmlsec_verify(struct SoapCtx *context); -/** - * - * Encrypt a XML document contained in a SOAP envelope. +/** This function encrypts an XML document contained in a SOAP + * envelope. * * @param context The SOAP context to be encrypted. * - * @return H_OK on success - * + * @return H_OK on success. */ extern herror_t soap_xmlsec_encrypt(struct SoapCtx *context); -/** - * - * Decrupt a XML document contained in a SOAP envelope. +/** This function decrypts an XML document contained in a SOAP + * envelope. * * @param context The SOAP context to be decrypted. * - * @return H_OK on success - * + * @return H_OK on success. */ extern herror_t soap_xmlsec_decrypt(struct SoapCtx *context); -/** - * - * Frees the resources needed by the XML security subsystem. +/** This function frees the resources needed by the XML security + * subsystem. * + * @see soap_xmlsec_init() */ extern void soap_xmlsec_destroy(void); @@ -248,4 +232,6 @@ extern void soap_xmlsec_destroy(void); } #endif +/**@}*/ + #endif diff --git a/nanohttp/Makefile.am b/nanohttp/Makefile.am index 04933d3..a82cd00 100644 --- a/nanohttp/Makefile.am +++ b/nanohttp/Makefile.am @@ -1,20 +1,36 @@ # -# $Revision: 1.16 $ +# $Revision: 1.17 $ # lib_LTLIBRARIES=libnanohttp.la libnanohttp_ladir=$(includedir)/nanohttp-@nanohttp_release@/nanohttp -libnanohttp_la_SOURCES=nanohttp-common.c nanohttp-socket.c nanohttp-client.c \ - nanohttp-server.c nanohttp-stream.c nanohttp-mime.c \ - nanohttp-request.c nanohttp-response.c nanohttp-base64.c \ - nanohttp-logging.c nanohttp-admin.c nanohttp-error.c \ +libnanohttp_la_SOURCES=nanohttp-admin.c \ + nanohttp-base64.c \ + nanohttp-client.c \ + nanohttp-common.c \ + nanohttp-error.c \ + nanohttp-logging.c \ + nanohttp-mime.c \ + nanohttp-request.c \ + nanohttp-response.c \ + nanohttp-server.c \ + nanohttp-socket.c \ + nanohttp-stream.c \ nanohttp-url.c -libnanohttp_la_HEADERS=nanohttp-common.h nanohttp-socket.h nanohttp-client.h \ - nanohttp-server.h nanohttp-stream.h nanohttp-mime.h \ - nanohttp-request.h nanohttp-response.h nanohttp-logging.h \ - nanohttp-error.h nanohttp-base64.h nanohttp-admin.h \ +libnanohttp_la_HEADERS=nanohttp-admin.h \ + nanohttp-base64.h \ + nanohttp-client.h \ + nanohttp-common.h \ + nanohttp-error.h \ + nanohttp-logging.h \ + nanohttp-mime.h \ + nanohttp-request.h \ + nanohttp-response.h \ + nanohttp-server.h \ + nanohttp-socket.h \ + nanohttp-stream.h \ nanohttp-url.h if BUILD_WITH_SSL diff --git a/nanohttp/Makefile.in b/nanohttp/Makefile.in index c09d8b4..6545e07 100644 --- a/nanohttp/Makefile.in +++ b/nanohttp/Makefile.in @@ -60,24 +60,24 @@ am__installdirs = "$(DESTDIR)$(libdir)" \ libLTLIBRARIES_INSTALL = $(INSTALL) LTLIBRARIES = $(lib_LTLIBRARIES) libnanohttp_la_LIBADD = -am__libnanohttp_la_SOURCES_DIST = nanohttp-common.c nanohttp-socket.c \ - nanohttp-client.c nanohttp-server.c nanohttp-stream.c \ - nanohttp-mime.c nanohttp-request.c nanohttp-response.c \ - nanohttp-base64.c nanohttp-logging.c nanohttp-admin.c \ - nanohttp-error.c nanohttp-url.c nanohttp-ssl.c +am__libnanohttp_la_SOURCES_DIST = nanohttp-admin.c nanohttp-base64.c \ + nanohttp-client.c nanohttp-common.c nanohttp-error.c \ + nanohttp-logging.c nanohttp-mime.c nanohttp-request.c \ + nanohttp-response.c nanohttp-server.c nanohttp-socket.c \ + nanohttp-stream.c nanohttp-url.c nanohttp-ssl.c @BUILD_WITH_SSL_TRUE@am__objects_1 = libnanohttp_la-nanohttp-ssl.lo -am_libnanohttp_la_OBJECTS = libnanohttp_la-nanohttp-common.lo \ - libnanohttp_la-nanohttp-socket.lo \ +am_libnanohttp_la_OBJECTS = libnanohttp_la-nanohttp-admin.lo \ + libnanohttp_la-nanohttp-base64.lo \ libnanohttp_la-nanohttp-client.lo \ - libnanohttp_la-nanohttp-server.lo \ - libnanohttp_la-nanohttp-stream.lo \ + libnanohttp_la-nanohttp-common.lo \ + libnanohttp_la-nanohttp-error.lo \ + libnanohttp_la-nanohttp-logging.lo \ libnanohttp_la-nanohttp-mime.lo \ libnanohttp_la-nanohttp-request.lo \ libnanohttp_la-nanohttp-response.lo \ - libnanohttp_la-nanohttp-base64.lo \ - libnanohttp_la-nanohttp-logging.lo \ - libnanohttp_la-nanohttp-admin.lo \ - libnanohttp_la-nanohttp-error.lo \ + libnanohttp_la-nanohttp-server.lo \ + libnanohttp_la-nanohttp-socket.lo \ + libnanohttp_la-nanohttp-stream.lo \ libnanohttp_la-nanohttp-url.lo $(am__objects_1) libnanohttp_la_OBJECTS = $(am_libnanohttp_la_OBJECTS) DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) @@ -93,11 +93,11 @@ LINK = $(LIBTOOL) --tag=CC --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ SOURCES = $(libnanohttp_la_SOURCES) DIST_SOURCES = $(am__libnanohttp_la_SOURCES_DIST) -am__libnanohttp_la_HEADERS_DIST = nanohttp-common.h nanohttp-socket.h \ - nanohttp-client.h nanohttp-server.h nanohttp-stream.h \ - nanohttp-mime.h nanohttp-request.h nanohttp-response.h \ - nanohttp-logging.h nanohttp-error.h nanohttp-base64.h \ - nanohttp-admin.h nanohttp-url.h nanohttp-ssl.h +am__libnanohttp_la_HEADERS_DIST = nanohttp-admin.h nanohttp-base64.h \ + nanohttp-client.h nanohttp-common.h nanohttp-error.h \ + nanohttp-logging.h nanohttp-mime.h nanohttp-request.h \ + nanohttp-response.h nanohttp-server.h nanohttp-socket.h \ + nanohttp-stream.h nanohttp-url.h nanohttp-ssl.h libnanohttp_laHEADERS_INSTALL = $(INSTALL_HEADER) HEADERS = $(libnanohttp_la_HEADERS) ETAGS = etags @@ -225,20 +225,20 @@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ # -# $Revision: 1.1 $ +# $Revision: 1.2 $ # lib_LTLIBRARIES = libnanohttp.la libnanohttp_ladir = $(includedir)/nanohttp-@nanohttp_release@/nanohttp -libnanohttp_la_SOURCES = nanohttp-common.c nanohttp-socket.c \ - nanohttp-client.c nanohttp-server.c nanohttp-stream.c \ - nanohttp-mime.c nanohttp-request.c nanohttp-response.c \ - nanohttp-base64.c nanohttp-logging.c nanohttp-admin.c \ - nanohttp-error.c nanohttp-url.c $(am__append_1) -libnanohttp_la_HEADERS = nanohttp-common.h nanohttp-socket.h \ - nanohttp-client.h nanohttp-server.h nanohttp-stream.h \ - nanohttp-mime.h nanohttp-request.h nanohttp-response.h \ - nanohttp-logging.h nanohttp-error.h nanohttp-base64.h \ - nanohttp-admin.h nanohttp-url.h $(am__append_2) +libnanohttp_la_SOURCES = nanohttp-admin.c nanohttp-base64.c \ + nanohttp-client.c nanohttp-common.c nanohttp-error.c \ + nanohttp-logging.c nanohttp-mime.c nanohttp-request.c \ + nanohttp-response.c nanohttp-server.c nanohttp-socket.c \ + nanohttp-stream.c nanohttp-url.c $(am__append_1) +libnanohttp_la_HEADERS = nanohttp-admin.h nanohttp-base64.h \ + nanohttp-client.h nanohttp-common.h nanohttp-error.h \ + nanohttp-logging.h nanohttp-mime.h nanohttp-request.h \ + nanohttp-response.h nanohttp-server.h nanohttp-socket.h \ + nanohttp-stream.h nanohttp-url.h $(am__append_2) libnanohttp_la_LDFLAGS = -version-info @nanohttp_version@ -release @nanohttp_release@ libnanohttp_la_CFLAGS = -I${top_srcdir} -D__NHTTP_INTERNAL=1 all: all-am @@ -346,19 +346,19 @@ distclean-compile: @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< -libnanohttp_la-nanohttp-common.lo: nanohttp-common.c -@am__fastdepCC_TRUE@ if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanohttp_la_CFLAGS) $(CFLAGS) -MT libnanohttp_la-nanohttp-common.lo -MD -MP -MF "$(DEPDIR)/libnanohttp_la-nanohttp-common.Tpo" -c -o libnanohttp_la-nanohttp-common.lo `test -f 'nanohttp-common.c' || echo '$(srcdir)/'`nanohttp-common.c; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libnanohttp_la-nanohttp-common.Tpo" "$(DEPDIR)/libnanohttp_la-nanohttp-common.Plo"; else rm -f "$(DEPDIR)/libnanohttp_la-nanohttp-common.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nanohttp-common.c' object='libnanohttp_la-nanohttp-common.lo' libtool=yes @AMDEPBACKSLASH@ +libnanohttp_la-nanohttp-admin.lo: nanohttp-admin.c +@am__fastdepCC_TRUE@ if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanohttp_la_CFLAGS) $(CFLAGS) -MT libnanohttp_la-nanohttp-admin.lo -MD -MP -MF "$(DEPDIR)/libnanohttp_la-nanohttp-admin.Tpo" -c -o libnanohttp_la-nanohttp-admin.lo `test -f 'nanohttp-admin.c' || echo '$(srcdir)/'`nanohttp-admin.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libnanohttp_la-nanohttp-admin.Tpo" "$(DEPDIR)/libnanohttp_la-nanohttp-admin.Plo"; else rm -f "$(DEPDIR)/libnanohttp_la-nanohttp-admin.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nanohttp-admin.c' object='libnanohttp_la-nanohttp-admin.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanohttp_la_CFLAGS) $(CFLAGS) -c -o libnanohttp_la-nanohttp-common.lo `test -f 'nanohttp-common.c' || echo '$(srcdir)/'`nanohttp-common.c +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanohttp_la_CFLAGS) $(CFLAGS) -c -o libnanohttp_la-nanohttp-admin.lo `test -f 'nanohttp-admin.c' || echo '$(srcdir)/'`nanohttp-admin.c -libnanohttp_la-nanohttp-socket.lo: nanohttp-socket.c -@am__fastdepCC_TRUE@ if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanohttp_la_CFLAGS) $(CFLAGS) -MT libnanohttp_la-nanohttp-socket.lo -MD -MP -MF "$(DEPDIR)/libnanohttp_la-nanohttp-socket.Tpo" -c -o libnanohttp_la-nanohttp-socket.lo `test -f 'nanohttp-socket.c' || echo '$(srcdir)/'`nanohttp-socket.c; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libnanohttp_la-nanohttp-socket.Tpo" "$(DEPDIR)/libnanohttp_la-nanohttp-socket.Plo"; else rm -f "$(DEPDIR)/libnanohttp_la-nanohttp-socket.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nanohttp-socket.c' object='libnanohttp_la-nanohttp-socket.lo' libtool=yes @AMDEPBACKSLASH@ +libnanohttp_la-nanohttp-base64.lo: nanohttp-base64.c +@am__fastdepCC_TRUE@ if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanohttp_la_CFLAGS) $(CFLAGS) -MT libnanohttp_la-nanohttp-base64.lo -MD -MP -MF "$(DEPDIR)/libnanohttp_la-nanohttp-base64.Tpo" -c -o libnanohttp_la-nanohttp-base64.lo `test -f 'nanohttp-base64.c' || echo '$(srcdir)/'`nanohttp-base64.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libnanohttp_la-nanohttp-base64.Tpo" "$(DEPDIR)/libnanohttp_la-nanohttp-base64.Plo"; else rm -f "$(DEPDIR)/libnanohttp_la-nanohttp-base64.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nanohttp-base64.c' object='libnanohttp_la-nanohttp-base64.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanohttp_la_CFLAGS) $(CFLAGS) -c -o libnanohttp_la-nanohttp-socket.lo `test -f 'nanohttp-socket.c' || echo '$(srcdir)/'`nanohttp-socket.c +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanohttp_la_CFLAGS) $(CFLAGS) -c -o libnanohttp_la-nanohttp-base64.lo `test -f 'nanohttp-base64.c' || echo '$(srcdir)/'`nanohttp-base64.c libnanohttp_la-nanohttp-client.lo: nanohttp-client.c @am__fastdepCC_TRUE@ if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanohttp_la_CFLAGS) $(CFLAGS) -MT libnanohttp_la-nanohttp-client.lo -MD -MP -MF "$(DEPDIR)/libnanohttp_la-nanohttp-client.Tpo" -c -o libnanohttp_la-nanohttp-client.lo `test -f 'nanohttp-client.c' || echo '$(srcdir)/'`nanohttp-client.c; \ @@ -367,19 +367,26 @@ libnanohttp_la-nanohttp-client.lo: nanohttp-client.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanohttp_la_CFLAGS) $(CFLAGS) -c -o libnanohttp_la-nanohttp-client.lo `test -f 'nanohttp-client.c' || echo '$(srcdir)/'`nanohttp-client.c -libnanohttp_la-nanohttp-server.lo: nanohttp-server.c -@am__fastdepCC_TRUE@ if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanohttp_la_CFLAGS) $(CFLAGS) -MT libnanohttp_la-nanohttp-server.lo -MD -MP -MF "$(DEPDIR)/libnanohttp_la-nanohttp-server.Tpo" -c -o libnanohttp_la-nanohttp-server.lo `test -f 'nanohttp-server.c' || echo '$(srcdir)/'`nanohttp-server.c; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libnanohttp_la-nanohttp-server.Tpo" "$(DEPDIR)/libnanohttp_la-nanohttp-server.Plo"; else rm -f "$(DEPDIR)/libnanohttp_la-nanohttp-server.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nanohttp-server.c' object='libnanohttp_la-nanohttp-server.lo' libtool=yes @AMDEPBACKSLASH@ +libnanohttp_la-nanohttp-common.lo: nanohttp-common.c +@am__fastdepCC_TRUE@ if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanohttp_la_CFLAGS) $(CFLAGS) -MT libnanohttp_la-nanohttp-common.lo -MD -MP -MF "$(DEPDIR)/libnanohttp_la-nanohttp-common.Tpo" -c -o libnanohttp_la-nanohttp-common.lo `test -f 'nanohttp-common.c' || echo '$(srcdir)/'`nanohttp-common.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libnanohttp_la-nanohttp-common.Tpo" "$(DEPDIR)/libnanohttp_la-nanohttp-common.Plo"; else rm -f "$(DEPDIR)/libnanohttp_la-nanohttp-common.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nanohttp-common.c' object='libnanohttp_la-nanohttp-common.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanohttp_la_CFLAGS) $(CFLAGS) -c -o libnanohttp_la-nanohttp-server.lo `test -f 'nanohttp-server.c' || echo '$(srcdir)/'`nanohttp-server.c +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanohttp_la_CFLAGS) $(CFLAGS) -c -o libnanohttp_la-nanohttp-common.lo `test -f 'nanohttp-common.c' || echo '$(srcdir)/'`nanohttp-common.c -libnanohttp_la-nanohttp-stream.lo: nanohttp-stream.c -@am__fastdepCC_TRUE@ if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanohttp_la_CFLAGS) $(CFLAGS) -MT libnanohttp_la-nanohttp-stream.lo -MD -MP -MF "$(DEPDIR)/libnanohttp_la-nanohttp-stream.Tpo" -c -o libnanohttp_la-nanohttp-stream.lo `test -f 'nanohttp-stream.c' || echo '$(srcdir)/'`nanohttp-stream.c; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libnanohttp_la-nanohttp-stream.Tpo" "$(DEPDIR)/libnanohttp_la-nanohttp-stream.Plo"; else rm -f "$(DEPDIR)/libnanohttp_la-nanohttp-stream.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nanohttp-stream.c' object='libnanohttp_la-nanohttp-stream.lo' libtool=yes @AMDEPBACKSLASH@ +libnanohttp_la-nanohttp-error.lo: nanohttp-error.c +@am__fastdepCC_TRUE@ if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanohttp_la_CFLAGS) $(CFLAGS) -MT libnanohttp_la-nanohttp-error.lo -MD -MP -MF "$(DEPDIR)/libnanohttp_la-nanohttp-error.Tpo" -c -o libnanohttp_la-nanohttp-error.lo `test -f 'nanohttp-error.c' || echo '$(srcdir)/'`nanohttp-error.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libnanohttp_la-nanohttp-error.Tpo" "$(DEPDIR)/libnanohttp_la-nanohttp-error.Plo"; else rm -f "$(DEPDIR)/libnanohttp_la-nanohttp-error.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nanohttp-error.c' object='libnanohttp_la-nanohttp-error.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanohttp_la_CFLAGS) $(CFLAGS) -c -o libnanohttp_la-nanohttp-stream.lo `test -f 'nanohttp-stream.c' || echo '$(srcdir)/'`nanohttp-stream.c +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanohttp_la_CFLAGS) $(CFLAGS) -c -o libnanohttp_la-nanohttp-error.lo `test -f 'nanohttp-error.c' || echo '$(srcdir)/'`nanohttp-error.c + +libnanohttp_la-nanohttp-logging.lo: nanohttp-logging.c +@am__fastdepCC_TRUE@ if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanohttp_la_CFLAGS) $(CFLAGS) -MT libnanohttp_la-nanohttp-logging.lo -MD -MP -MF "$(DEPDIR)/libnanohttp_la-nanohttp-logging.Tpo" -c -o libnanohttp_la-nanohttp-logging.lo `test -f 'nanohttp-logging.c' || echo '$(srcdir)/'`nanohttp-logging.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libnanohttp_la-nanohttp-logging.Tpo" "$(DEPDIR)/libnanohttp_la-nanohttp-logging.Plo"; else rm -f "$(DEPDIR)/libnanohttp_la-nanohttp-logging.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nanohttp-logging.c' object='libnanohttp_la-nanohttp-logging.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanohttp_la_CFLAGS) $(CFLAGS) -c -o libnanohttp_la-nanohttp-logging.lo `test -f 'nanohttp-logging.c' || echo '$(srcdir)/'`nanohttp-logging.c libnanohttp_la-nanohttp-mime.lo: nanohttp-mime.c @am__fastdepCC_TRUE@ if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanohttp_la_CFLAGS) $(CFLAGS) -MT libnanohttp_la-nanohttp-mime.lo -MD -MP -MF "$(DEPDIR)/libnanohttp_la-nanohttp-mime.Tpo" -c -o libnanohttp_la-nanohttp-mime.lo `test -f 'nanohttp-mime.c' || echo '$(srcdir)/'`nanohttp-mime.c; \ @@ -402,33 +409,26 @@ libnanohttp_la-nanohttp-response.lo: nanohttp-response.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanohttp_la_CFLAGS) $(CFLAGS) -c -o libnanohttp_la-nanohttp-response.lo `test -f 'nanohttp-response.c' || echo '$(srcdir)/'`nanohttp-response.c -libnanohttp_la-nanohttp-base64.lo: nanohttp-base64.c -@am__fastdepCC_TRUE@ if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanohttp_la_CFLAGS) $(CFLAGS) -MT libnanohttp_la-nanohttp-base64.lo -MD -MP -MF "$(DEPDIR)/libnanohttp_la-nanohttp-base64.Tpo" -c -o libnanohttp_la-nanohttp-base64.lo `test -f 'nanohttp-base64.c' || echo '$(srcdir)/'`nanohttp-base64.c; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libnanohttp_la-nanohttp-base64.Tpo" "$(DEPDIR)/libnanohttp_la-nanohttp-base64.Plo"; else rm -f "$(DEPDIR)/libnanohttp_la-nanohttp-base64.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nanohttp-base64.c' object='libnanohttp_la-nanohttp-base64.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanohttp_la_CFLAGS) $(CFLAGS) -c -o libnanohttp_la-nanohttp-base64.lo `test -f 'nanohttp-base64.c' || echo '$(srcdir)/'`nanohttp-base64.c - -libnanohttp_la-nanohttp-logging.lo: nanohttp-logging.c -@am__fastdepCC_TRUE@ if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanohttp_la_CFLAGS) $(CFLAGS) -MT libnanohttp_la-nanohttp-logging.lo -MD -MP -MF "$(DEPDIR)/libnanohttp_la-nanohttp-logging.Tpo" -c -o libnanohttp_la-nanohttp-logging.lo `test -f 'nanohttp-logging.c' || echo '$(srcdir)/'`nanohttp-logging.c; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libnanohttp_la-nanohttp-logging.Tpo" "$(DEPDIR)/libnanohttp_la-nanohttp-logging.Plo"; else rm -f "$(DEPDIR)/libnanohttp_la-nanohttp-logging.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nanohttp-logging.c' object='libnanohttp_la-nanohttp-logging.lo' libtool=yes @AMDEPBACKSLASH@ +libnanohttp_la-nanohttp-server.lo: nanohttp-server.c +@am__fastdepCC_TRUE@ if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanohttp_la_CFLAGS) $(CFLAGS) -MT libnanohttp_la-nanohttp-server.lo -MD -MP -MF "$(DEPDIR)/libnanohttp_la-nanohttp-server.Tpo" -c -o libnanohttp_la-nanohttp-server.lo `test -f 'nanohttp-server.c' || echo '$(srcdir)/'`nanohttp-server.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libnanohttp_la-nanohttp-server.Tpo" "$(DEPDIR)/libnanohttp_la-nanohttp-server.Plo"; else rm -f "$(DEPDIR)/libnanohttp_la-nanohttp-server.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nanohttp-server.c' object='libnanohttp_la-nanohttp-server.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanohttp_la_CFLAGS) $(CFLAGS) -c -o libnanohttp_la-nanohttp-logging.lo `test -f 'nanohttp-logging.c' || echo '$(srcdir)/'`nanohttp-logging.c +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanohttp_la_CFLAGS) $(CFLAGS) -c -o libnanohttp_la-nanohttp-server.lo `test -f 'nanohttp-server.c' || echo '$(srcdir)/'`nanohttp-server.c -libnanohttp_la-nanohttp-admin.lo: nanohttp-admin.c -@am__fastdepCC_TRUE@ if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanohttp_la_CFLAGS) $(CFLAGS) -MT libnanohttp_la-nanohttp-admin.lo -MD -MP -MF "$(DEPDIR)/libnanohttp_la-nanohttp-admin.Tpo" -c -o libnanohttp_la-nanohttp-admin.lo `test -f 'nanohttp-admin.c' || echo '$(srcdir)/'`nanohttp-admin.c; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libnanohttp_la-nanohttp-admin.Tpo" "$(DEPDIR)/libnanohttp_la-nanohttp-admin.Plo"; else rm -f "$(DEPDIR)/libnanohttp_la-nanohttp-admin.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nanohttp-admin.c' object='libnanohttp_la-nanohttp-admin.lo' libtool=yes @AMDEPBACKSLASH@ +libnanohttp_la-nanohttp-socket.lo: nanohttp-socket.c +@am__fastdepCC_TRUE@ if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanohttp_la_CFLAGS) $(CFLAGS) -MT libnanohttp_la-nanohttp-socket.lo -MD -MP -MF "$(DEPDIR)/libnanohttp_la-nanohttp-socket.Tpo" -c -o libnanohttp_la-nanohttp-socket.lo `test -f 'nanohttp-socket.c' || echo '$(srcdir)/'`nanohttp-socket.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libnanohttp_la-nanohttp-socket.Tpo" "$(DEPDIR)/libnanohttp_la-nanohttp-socket.Plo"; else rm -f "$(DEPDIR)/libnanohttp_la-nanohttp-socket.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nanohttp-socket.c' object='libnanohttp_la-nanohttp-socket.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanohttp_la_CFLAGS) $(CFLAGS) -c -o libnanohttp_la-nanohttp-admin.lo `test -f 'nanohttp-admin.c' || echo '$(srcdir)/'`nanohttp-admin.c +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanohttp_la_CFLAGS) $(CFLAGS) -c -o libnanohttp_la-nanohttp-socket.lo `test -f 'nanohttp-socket.c' || echo '$(srcdir)/'`nanohttp-socket.c -libnanohttp_la-nanohttp-error.lo: nanohttp-error.c -@am__fastdepCC_TRUE@ if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanohttp_la_CFLAGS) $(CFLAGS) -MT libnanohttp_la-nanohttp-error.lo -MD -MP -MF "$(DEPDIR)/libnanohttp_la-nanohttp-error.Tpo" -c -o libnanohttp_la-nanohttp-error.lo `test -f 'nanohttp-error.c' || echo '$(srcdir)/'`nanohttp-error.c; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libnanohttp_la-nanohttp-error.Tpo" "$(DEPDIR)/libnanohttp_la-nanohttp-error.Plo"; else rm -f "$(DEPDIR)/libnanohttp_la-nanohttp-error.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nanohttp-error.c' object='libnanohttp_la-nanohttp-error.lo' libtool=yes @AMDEPBACKSLASH@ +libnanohttp_la-nanohttp-stream.lo: nanohttp-stream.c +@am__fastdepCC_TRUE@ if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanohttp_la_CFLAGS) $(CFLAGS) -MT libnanohttp_la-nanohttp-stream.lo -MD -MP -MF "$(DEPDIR)/libnanohttp_la-nanohttp-stream.Tpo" -c -o libnanohttp_la-nanohttp-stream.lo `test -f 'nanohttp-stream.c' || echo '$(srcdir)/'`nanohttp-stream.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libnanohttp_la-nanohttp-stream.Tpo" "$(DEPDIR)/libnanohttp_la-nanohttp-stream.Plo"; else rm -f "$(DEPDIR)/libnanohttp_la-nanohttp-stream.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nanohttp-stream.c' object='libnanohttp_la-nanohttp-stream.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanohttp_la_CFLAGS) $(CFLAGS) -c -o libnanohttp_la-nanohttp-error.lo `test -f 'nanohttp-error.c' || echo '$(srcdir)/'`nanohttp-error.c +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanohttp_la_CFLAGS) $(CFLAGS) -c -o libnanohttp_la-nanohttp-stream.lo `test -f 'nanohttp-stream.c' || echo '$(srcdir)/'`nanohttp-stream.c libnanohttp_la-nanohttp-url.lo: nanohttp-url.c @am__fastdepCC_TRUE@ if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanohttp_la_CFLAGS) $(CFLAGS) -MT libnanohttp_la-nanohttp-url.lo -MD -MP -MF "$(DEPDIR)/libnanohttp_la-nanohttp-url.Tpo" -c -o libnanohttp_la-nanohttp-url.lo `test -f 'nanohttp-url.c' || echo '$(srcdir)/'`nanohttp-url.c; \ diff --git a/nanohttp/nanohttp-admin.c b/nanohttp/nanohttp-admin.c index 060cbb8..91ad0f0 100644 --- a/nanohttp/nanohttp-admin.c +++ b/nanohttp/nanohttp-admin.c @@ -1,5 +1,6 @@ +/** @file nanohttp-admin.c Administrator application */ /****************************************************************** -* $Id: nanohttp-admin.c,v 1.12 2007/01/01 22:54:46 m0gg Exp $ +* $Id: nanohttp-admin.c,v 1.13 2007/11/03 22:40:10 m0gg Exp $ * * CSOAP Project: A SOAP client/server library in C * Copyright (C) 2003 Ferhat Ayaz @@ -21,6 +22,7 @@ * * Email: ayaz@jprogrammer.net ******************************************************************/ + #ifdef HAVE_CONFIG_H #include #endif @@ -42,6 +44,7 @@ #endif #include "nanohttp-error.h" +#include "nanohttp-logging.h" #include "nanohttp-common.h" #include "nanohttp-stream.h" #include "nanohttp-request.h" @@ -73,18 +76,17 @@ _httpd_admin_send_title(httpd_conn_t *conn, const char *title) "nhttpd "); http_output_stream_write_string(conn->out, title); http_output_stream_write_string(conn->out, "


"); - - return; } static inline void _httpd_admin_send_footer(httpd_conn_t *conn) { http_output_stream_write_string(conn->out, + "
" + "Admin page " + "cSOAP Home" "" ""); - - return; } static void @@ -125,8 +127,6 @@ _httpd_admin_list_services(httpd_conn_t *conn) http_output_stream_write_string(conn->out, ""); _httpd_admin_send_footer(conn); - - return; } static void @@ -135,10 +135,12 @@ _httpd_admin_list_statistics(httpd_conn_t *conn, const char *service_name) char buffer[1024]; hservice_t *service; + log_verbose("Client requested statistics for \"%s\"", service_name); + sprintf(buffer, "Listing statistics for service %s", service_name); _httpd_admin_send_title(conn, buffer); - if (!(service = httpd_find_service(service_name))) + if (!service_name || !(service = httpd_find_service(service_name))) { http_output_stream_write_string(conn->out, "

" @@ -154,7 +156,7 @@ _httpd_admin_list_statistics(httpd_conn_t *conn, const char *service_name) "

  • Bytes read: %lu
  • " "
  • Bytes sent: %lu
  • " "
  • Time used: %li.%li sec
  • " - "
      ", + "
    ", service->statistics->requests, service->statistics->bytes_received, service->statistics->bytes_transmitted, @@ -165,8 +167,6 @@ _httpd_admin_list_statistics(httpd_conn_t *conn, const char *service_name) http_output_stream_write_string(conn->out, buffer); _httpd_admin_send_footer(conn); - - return; } static void @@ -197,8 +197,6 @@ _httpd_admin_enable_service(httpd_conn_t *conn, const char *service_name) "

    "); _httpd_admin_send_footer(conn); - - return; } static void @@ -227,8 +225,84 @@ _httpd_admin_disable_service(httpd_conn_t *conn, const char *service_name) "Service is down" "

    "); _httpd_admin_send_footer(conn); +} + +static void +_httpd_admin_set_loglevel(httpd_conn_t *conn, const char *loglevel) +{ + nanohttp_loglevel_t old; + char buffer[256]; + char *tmp; - return; + if (strcmp(loglevel, NANOHTTP_LOG_LEVEL_OFF_STRING) == 0) + { + old = nanohttp_log_set_loglevel(NANOHTTP_LOG_OFF); + } + else if (strcmp(loglevel, NANOHTTP_LOG_LEVEL_VERBOSE_STRING) == 0) + { + old = nanohttp_log_set_loglevel(NANOHTTP_LOG_VERBOSE); + } + else if (strcmp(loglevel, NANOHTTP_LOG_LEVEL_DEBUG_STRING) == 0) + { + old = nanohttp_log_set_loglevel(NANOHTTP_LOG_DEBUG); + } + else if (strcmp(loglevel, NANOHTTP_LOG_LEVEL_INFO_STRING) == 0) + { + old = nanohttp_log_set_loglevel(NANOHTTP_LOG_INFO); + } + else if (strcmp(loglevel, NANOHTTP_LOG_LEVEL_WARN_STRING) == 0) + { + old = nanohttp_log_set_loglevel(NANOHTTP_LOG_WARN); + } + else if (strcmp(loglevel, NANOHTTP_LOG_LEVEL_ERROR_STRING) == 0) + { + old = nanohttp_log_set_loglevel(NANOHTTP_LOG_ERROR); + } + else if (strcmp(loglevel, NANOHTTP_LOG_LEVEL_FATAL_STRING) == 0) + { + old = nanohttp_log_set_loglevel(NANOHTTP_LOG_FATAL); + } + else + { + old = nanohttp_log_get_loglevel(); + loglevel = NANOHTTP_LOG_LEVEL_UNKNOWN_STRING; + log_error("unknown loglevel requested"); + } + + switch (old) + { + case NANOHTTP_LOG_OFF: + tmp = NANOHTTP_LOG_LEVEL_OFF_STRING; + break; + case NANOHTTP_LOG_VERBOSE: + tmp = NANOHTTP_LOG_LEVEL_VERBOSE_STRING; + break; + case NANOHTTP_LOG_DEBUG: + tmp = NANOHTTP_LOG_LEVEL_DEBUG_STRING; + break; + case NANOHTTP_LOG_INFO: + tmp = NANOHTTP_LOG_LEVEL_INFO_STRING; + break; + case NANOHTTP_LOG_WARN: + tmp = NANOHTTP_LOG_LEVEL_WARN_STRING; + break; + case NANOHTTP_LOG_ERROR: + tmp = NANOHTTP_LOG_LEVEL_ERROR_STRING; + break; + case NANOHTTP_LOG_FATAL: + tmp = NANOHTTP_LOG_LEVEL_FATAL_STRING; + break; + default: + tmp = NANOHTTP_LOG_LEVEL_UNKNOWN_STRING; + break; + } + + _httpd_admin_send_title(conn, "Adjusting loglevel"); + + sprintf(buffer, "

    Switching from %s to %s

    ", tmp, loglevel); + http_output_stream_write_string(conn->out, buffer); + + _httpd_admin_send_footer(conn); } static void @@ -252,9 +326,13 @@ _httpd_admin_handle_get(httpd_conn_t * conn, struct hrequest_t *req) { _httpd_admin_disable_service(conn, param); } + else if ((param = hpairnode_get_ignore_case(req->query, NHTTPD_ADMIN_QUERY_SET_LOGLEVEL))) + { + _httpd_admin_set_loglevel(conn, param); + } else { - _httpd_admin_send_title(conn, "Welcome to the admin site"); + _httpd_admin_send_title(conn, "Welcome to the admin page"); http_output_stream_write_string(conn->out, ""); _httpd_admin_send_footer(conn); } - - return; } static void @@ -289,11 +374,10 @@ _httpd_admin_entry(httpd_conn_t * conn, struct hrequest_t *req) "" "

    Sorry!

    " "
    " - "
    POST Service is not implemented now. Use your browser.
    " + "
    Only GET method is implemented now. Use your browser.
    " "" ""); } - return; } herror_t @@ -305,7 +389,7 @@ httpd_admin_init_args(int argc, char **argv) { if (!strcmp(argv[i], NHTTPD_ARG_ENABLE_ADMIN)) { - httpd_register("/nhttp", _httpd_admin_entry); + httpd_register(NHTTPD_ADMIN_CONTEXT, _httpd_admin_entry); break; } } diff --git a/nanohttp/nanohttp-admin.h b/nanohttp/nanohttp-admin.h index bbbc0e2..0d90dcd 100644 --- a/nanohttp/nanohttp-admin.h +++ b/nanohttp/nanohttp-admin.h @@ -1,5 +1,5 @@ /****************************************************************** - * $Id: nanohttp-admin.h,v 1.6 2006/12/19 08:55:17 m0gg Exp $ + * $Id: nanohttp-admin.h,v 1.7 2007/11/03 22:40:10 m0gg Exp $ * * CSOAP Project: A SOAP client/server library in C * Copyright (C) 2003 Ferhat Ayaz @@ -24,93 +24,90 @@ #ifndef __nanohttp_admin_h #define __nanohttp_admin_h -/** +/** @file nanohttp-admin.h Administrator application * - * Commandline argument to enabled the nanoHTTP admin interface. This service - * will be reachable via the NHTTPD_ADMIN_CONTEXT. + * @defgroup NANOHTTP_ADMIN Administrator application + * @ingroup NANOHTTP_SERVER + */ +/**@{*/ + +/** @defgrup NANOHTTP_ADMIN_CMDLINE_FLAGS Command line flags + */ +/**@{*/ +/** Commandline argument to enabled the nanoHTTP admin interface. + * This service will be reachable via the NHTTPD_ADMIN_CONTEXT. * * @see NHTTPD_ADMIN_CONTEXT - * */ #define NHTTPD_ARG_ENABLE_ADMIN "-NHTTPDadmin" -/** - * - * Context of the nanoHTTP admin interface. +/**@}*/ + +/** Context of the nanoHTTP admin interface. * * Example query: - * - * @code - * http://localhost:10000/nhttp - * @endcode + @verbatim + GET http://localhost:10000/nhttp + @endverbatim * * @see httpd_register - * */ #define NHTTPD_ADMIN_CONTEXT "/nhttp" -/** - * - * Query parameter for services. +/** Query parameter for services. * * Example query: - * - * @code - * http://localhost:10000/nhttp?services=list - * @endcode - * + @verbatim + GET http://localhost:10000/nhttp?services=list + @endverbatim */ #define NHTTPD_ADMIN_QUERY_SERVICES "services" -/** - * - * Parameter to query service statistics. +/** Parameter to query service statistics. * * Example query: - * - * @code - * http://localhost:10000/nhttp?statistics=SERVICE_CONTEXT - * @endcode - * + @verbatim + GET http://localhost:10000/nhttp?statistics=SERVICE_CONTEXT + @endverbatim */ #define NHTTPD_ADMIN_QUERY_STATISTICS "statistics" -/** - * - * Parameter to enable a server. +/** Parameter to enable a server. * * Example query: - * - * @code - * http://localhost:10000/nhttp?activate=SERVICE_CONTEXT - * @endcode - * + @verbatim + GET http://localhost:10000/nhttp?activate=SERVICE_CONTEXT + @endverbatim */ #define NHTTPD_ADMIN_QUERY_ACTIVATE_SERVICE "activate" -/** - * - * Parameter to disable a service. +/** Parameter to disable a service. * * Example query: - * - * @code - * http://localhost:10000/nhttp?passivate=SERVICE_CONTEXT - * @endcode - * + @verbatim + GET http://localhost:10000/nhttp?passivate=SERVICE_CONTEXT + @endverbatim */ #define NHTTPD_ADMIN_QUERY_PASSIVATE_SERVICE "passivate" +/** Parameter to switch loglevels. + * + * Example query: + @verbatim + GET http://localhost:10000/nhttp?loglevel=OFF + @endverbatim + */ +#define NHTTPD_ADMIN_QUERY_SET_LOGLEVEL "loglevel" + #ifdef __cplusplus extern "C" { #endif -/** - * - * Initializes the nanoHTTP admin interface with commandline arguments, if - * NHTTPD_ARG_ENABLED_ADMIN was specified in the commandline arguments. This - * service will be reachable via the NHTTP_ADMIN_CONTEXT of the nanohttp server. +/** This function initializes the nanoHTTP admin interface with + * commandline arguments, if NHTTPD_ARG_ENABLED_ADMIN was specified + * on the commandline. This service will be reachable via the + * NHTTP_ADMIN_CONTEXT of the nanohttp server. * * @param argc commandline arg count * @param argv commandline arg vector @@ -119,7 +116,6 @@ extern "C" { * * @see NHTTPD_ADMIN_CONTEXT * @see NHTTPD_ARG_ENABLE_ADMIN - * */ extern herror_t httpd_admin_init_args(int argc, char **argv); @@ -127,4 +123,6 @@ extern herror_t httpd_admin_init_args(int argc, char **argv); } #endif +/**@}*/ + #endif diff --git a/nanohttp/nanohttp-base64.c b/nanohttp/nanohttp-base64.c index a0f4bec..7de9327 100644 --- a/nanohttp/nanohttp-base64.c +++ b/nanohttp/nanohttp-base64.c @@ -1,5 +1,6 @@ +/** @file nanohttp-base64.c Base64 data encoding/decoding */ /****************************************************************** -* $Id: nanohttp-base64.c,v 1.4 2006/12/11 08:13:19 m0gg Exp $ +* $Id: nanohttp-base64.c,v 1.5 2007/11/03 22:40:10 m0gg Exp $ * * CSOAP Project: A http client/server library in C * Copyright (C) 2003 Ferhat Ayaz @@ -87,7 +88,9 @@ static void _decodeblock(unsigned char in[4], unsigned char out[3]) } /** + * * decode a base64 encoded string (maybe broken...) + * */ void base64_decode_string(const unsigned char *instr, unsigned char *outstr) { diff --git a/nanohttp/nanohttp-base64.h b/nanohttp/nanohttp-base64.h index 03301ff..c24c96c 100644 --- a/nanohttp/nanohttp-base64.h +++ b/nanohttp/nanohttp-base64.h @@ -1,5 +1,5 @@ /****************************************************************** -* $Id: nanohttp-base64.h,v 1.4 2006/12/13 08:18:53 m0gg Exp $ +* $Id: nanohttp-base64.h,v 1.5 2007/11/03 22:40:10 m0gg Exp $ * * CSOAP Project: A http client/server library in C * Copyright (C) 2003 Ferhat Ayaz @@ -24,56 +24,50 @@ #ifndef __nanohttp_base64_h #define __nanohttp_base64_h -/** @file +/** @file nanohttp-base64.h Base64 data encoding/decoding * - * \section base64_data_enc_sec Base64 data encoding + * @section base64_data_enc_sec Base64 data encoding/decoding * - * Base encoding of data is used in many situations to store or transfer data in - * environments that, perhaps for legacy reasons, are restricted to US-ASCII - * data. Base64 encoding can also be used in new applications that do not have - * legacy restrictions, simply because it makes it possible to manipulate objects - * with text editors. + * Base encoding of data is used in many situations to store or + * transfer data in environments that, perhaps for legacy reasons, + * are restricted to US-ASCII data. Base64 encoding can also be used + * in new applications that do not have legacy restrictions, simply + * because it makes it possible to manipulate objects with text + * editors. * - * In the past, different applications have had different requirements and thus - * sometimes implemented base encodings in slightly different ways. Today, - * protocol specifications sometimes use base encodings in general, and "base64" - * in particular, without a precise description or reference. Multipurpose - * Internet Mail Extensions (MIME) is often used as a reference for base64 - * without considering the consequences for line-wrapping or non-alphabet - * characters. + * In the past, different applications have had different requirements + * and thus sometimes implemented base encodings in slightly different + * ways. Today, protocol specifications sometimes use base encodings + * in general, and "base64" in particular, without a precise + * description or reference. Multipurpose Internet Mail Extensions + * (MIME) is often used as a reference for base64 without considering + * the consequences for line-wrapping or non-alphabet characters. * * @author H. Ronsdorf - * @version $Revision: 1.4 $ + * @version $Revision: 1.5 $ * * @see http://www.ietf.org/rfc/rfc4648.txt - * */ #ifdef __cplusplus extern "C" { #endif -/** - * - * Base64 encodes a NUL terminated array of characters. +/** Base64 encodes a NUL terminated array of characters. * * @param instr Pointer to the input string. * @param outstr Pointer to the output destination. * * @see base64_decode_string - * */ extern void base64_encode_string(const unsigned char *instr, unsigned char *outstr); -/** - * - * Base64 decodes a NUL terminated array of characters. +/** Base64 decodes a NUL terminated array of characters. * * @param instr Pointer to the input string. * @param outstr Pointer to the output destination. * * @see base64_encode_string - * */ extern void base64_decode_string(const unsigned char *instr, unsigned char *outstr); diff --git a/nanohttp/nanohttp-client.c b/nanohttp/nanohttp-client.c index 472c58f..84c2676 100644 --- a/nanohttp/nanohttp-client.c +++ b/nanohttp/nanohttp-client.c @@ -1,5 +1,6 @@ +/** @file nanohttp-client.c nanoHTTP client interface */ /****************************************************************** -* $Id: nanohttp-client.c,v 1.53 2007/01/01 22:54:46 m0gg Exp $ +* $Id: nanohttp-client.c,v 1.54 2007/11/03 22:40:10 m0gg Exp $ * * CSOAP Project: A http client/server library in C * Copyright (C) 2003 Ferhat Ayaz @@ -99,20 +100,20 @@ httpc_new(void) if (!(res = (httpc_conn_t *) malloc(sizeof(httpc_conn_t)))) { - log_error2("malloc failed (%s)", strerror(errno)); + log_error("malloc failed (%s)", strerror(errno)); return NULL; } if (!(res->sock = (struct hsocket_t *)malloc(sizeof(struct hsocket_t)))) { - log_error2("malloc failed (%s)", strerror(errno)); + log_error("malloc failed (%s)", strerror(errno)); free(res); return NULL; } if (!(res->url = (struct hurl_t *)malloc(sizeof(struct hurl_t)))) { - log_error2("malloc failed (%s)", strerror(errno)); + log_error("malloc failed (%s)", strerror(errno)); free(res->sock); free(res); return NULL; @@ -120,7 +121,7 @@ httpc_new(void) if ((status = hsocket_init(res->sock)) != H_OK) { - log_warn2("hsocket_init failed (%s)", herror_message(status)); + log_warn("hsocket_init failed (%s)", herror_message(status)); hurl_free(res->url); free(res->sock); free(res); @@ -183,7 +184,7 @@ httpc_add_header(httpc_conn_t *conn, const char *key, const char *value) { if (!conn) { - log_warn1("Connection object is NULL"); + log_warn("Connection object is NULL"); return -1; } @@ -197,7 +198,7 @@ httpc_add_headers(httpc_conn_t *conn, const hpair_t *values) { if (conn == NULL) { - log_warn1("Connection object is NULL"); + log_warn("Connection object is NULL"); return; } @@ -220,7 +221,7 @@ httpc_set_header(httpc_conn_t *conn, const char *key, const char *value) if (conn == NULL) { - log_warn1("Connection object is NULL"); + log_warn("Connection object is NULL"); return 0; } @@ -381,7 +382,7 @@ _httpc_talk_to_server(hreq_method_t method, httpc_conn_t * conn, const char *url if ((status = hurl_parse(conn->url, urlstr)) != H_OK) { - log_error2("Cannot parse URL \"%s\"", SAVE_STR(urlstr)); + log_error("Cannot parse URL \"%s\"", SAVE_STR(urlstr)); return status; } /* TODO (#1#): Check for HTTP protocol in URL */ @@ -390,12 +391,12 @@ _httpc_talk_to_server(hreq_method_t method, httpc_conn_t * conn, const char *url httpc_set_header(conn, HEADER_HOST, conn->url->host); ssl = conn->url->protocol == PROTOCOL_HTTPS ? 1 : 0; - log_verbose4("ssl = %i (%i %i)", ssl, conn->url->protocol, PROTOCOL_HTTPS); + log_verbose("ssl = %i (%i %i)", ssl, conn->url->protocol, PROTOCOL_HTTPS); /* Open connection */ if ((status = hsocket_open(conn->sock, conn->url->host, conn->url->port, ssl)) != H_OK) { - log_error2("hsocket_open failed (%s)", herror_message(status)); + log_error("hsocket_open failed (%s)", herror_message(status)); return status; } @@ -416,24 +417,24 @@ _httpc_talk_to_server(hreq_method_t method, httpc_conn_t * conn, const char *url break; default: - log_error1("Unknown method type!"); + log_error("Unknown method type!"); return herror_new("httpc_talk_to_server", GENERAL_INVALID_PARAM, "hreq_method_t must be HTTP_REQUEST_GET or HTTP_REQUEST_POST"); } - log_verbose1("Sending request..."); + log_verbose("Sending request..."); if ((status = hsocket_send(conn->sock, buffer, len)) != H_OK) { - log_error2("Cannot send request (%s)", herror_message(status)); + log_error("Cannot send request (%s)", herror_message(status)); hsocket_close(conn->sock); return status; } - log_verbose1("Sending header..."); + log_verbose("Sending header..."); if ((status = httpc_send_header(conn)) != H_OK) { - log_error2("Cannot send header (%s)", herror_message(status)); + log_error("Cannot send header (%s)", herror_message(status)); hsocket_close(conn->sock); return status; } @@ -448,13 +449,13 @@ httpc_get(httpc_conn_t *conn, hresponse_t **out, const char *urlstr) if ((status = _httpc_talk_to_server(HTTP_REQUEST_GET, conn, urlstr)) != H_OK) { - log_error2("_httpc_talk_to_server failed (%s)", herror_message(status)); + log_error("_httpc_talk_to_server failed (%s)", herror_message(status)); return status; } if ((status = hresponse_new_from_socket(conn->sock, out)) != H_OK) { - log_error2("hresponse_new_from_socket failed (%s)", herror_message(status)); + log_error("hresponse_new_from_socket failed (%s)", herror_message(status)); return status; } @@ -468,7 +469,7 @@ httpc_post_begin(httpc_conn_t * conn, const char *url) if ((status = _httpc_talk_to_server(HTTP_REQUEST_POST, conn, url)) != H_OK) { - log_error2("_httpc_talk_to_server failed (%s)", herror_message(status)); + log_error("_httpc_talk_to_server failed (%s)", herror_message(status)); return status; } @@ -504,7 +505,7 @@ static void _httpc_mime_get_boundary(httpc_conn_t * conn, char *dest) { sprintf(dest, "---=.Part_NH_%d", conn->id); - log_verbose2("boundary= \"%s\"", dest); + log_verbose("boundary= \"%s\"", dest); return; } @@ -617,7 +618,7 @@ httpc_mime_send_file(httpc_conn_t * conn, const char *content_id, const char *co if ((fd = fopen(filename, "rb")) == NULL) { - log_error2("fopen failed (%s)", strerror(errno)); + log_error("fopen failed (%s)", strerror(errno)); return herror_new("httpc_mime_send_file", FILE_ERROR_OPEN, "Can not open file \"%s\" (%s)", filename, strerror(errno)); } @@ -652,7 +653,7 @@ httpc_mime_send_file(httpc_conn_t * conn, const char *content_id, const char *co } fclose(fd); - log_verbose1("file sent!"); + log_verbose("file sent!"); return H_OK; } diff --git a/nanohttp/nanohttp-client.h b/nanohttp/nanohttp-client.h index 41c812a..a181354 100644 --- a/nanohttp/nanohttp-client.h +++ b/nanohttp/nanohttp-client.h @@ -1,5 +1,5 @@ /****************************************************************** - * $Id: nanohttp-client.h,v 1.39 2007/01/03 08:33:44 m0gg Exp $ + * $Id: nanohttp-client.h,v 1.40 2007/11/03 22:40:10 m0gg Exp $ * * CSOAP Project: A http client/server library in C * Copyright (C) 2003 Ferhat Ayaz @@ -31,7 +31,6 @@ #include #include #include -#include #endif /** @page nanohttp_client_page Howto write an HTTP client @@ -196,6 +195,14 @@ * */ +/** @file nanohttp-client.h nanoHTTP client interface + * + * @defgroup NANOHTTP_CLIENT Client + * @ingroup NANOHTTP + * + */ +/**@{*/ + typedef struct httpc_conn { struct hsocket_t *sock; @@ -437,4 +444,6 @@ extern herror_t httpc_mime_send_file(httpc_conn_t * conn, } #endif +/**@}*/ + #endif diff --git a/nanohttp/nanohttp-common.c b/nanohttp/nanohttp-common.c index de17bfe..d19554b 100644 --- a/nanohttp/nanohttp-common.c +++ b/nanohttp/nanohttp-common.c @@ -1,5 +1,6 @@ +/** @file nanohttp-common.c Common functions and definitions */ /****************************************************************** -* $Id: nanohttp-common.c,v 1.38 2007/01/01 22:54:46 m0gg Exp $ +* $Id: nanohttp-common.c,v 1.39 2007/11/03 22:40:10 m0gg Exp $ * * CSOAP Project: A http client/server library in C * Copyright (C) 2003 Ferhat Ayaz @@ -62,10 +63,10 @@ hpairnode_new(const char *key, const char *value, hpair_t * next) { hpair_t *pair; - log_verbose3("new pair ('%s','%s')", SAVE_STR(key), SAVE_STR(value)); + log_verbose("new pair ('%s','%s')", SAVE_STR(key), SAVE_STR(value)); if (!(pair = (hpair_t *) malloc(sizeof(hpair_t)))) { - log_error2("malloc failed (%s)", strerror(errno)); + log_error("malloc failed (%s)", strerror(errno)); return NULL; } @@ -159,10 +160,10 @@ hpairnode_dump(const hpair_t * pair) { if (pair == NULL) { - log_verbose1("(NULL)[]"); + log_verbose("(NULL)[]"); return; } - log_verbose5("(%p)['%s','%s','%p']", pair, + log_verbose("(%p)['%s','%s','%p']", pair, SAVE_STR(pair->key), SAVE_STR(pair->value), pair->next); return; @@ -173,12 +174,12 @@ hpairnode_dump_deep(const hpair_t * pairs) { const hpair_t *p; - log_verbose1("-- BEGIN dump_deep hpair_t --"); + log_verbose("-- BEGIN dump_deep hpair_t --"); for (p = pairs; p != NULL; p = p->next) { hpairnode_dump(p); } - log_verbose1("-- END dump_deep hpair_t --\n"); + log_verbose("-- END dump_deep hpair_t --\n"); return; } @@ -221,7 +222,7 @@ hpairnode_get_ignore_case(hpair_t * pair, const char *key) { if (key == NULL) { - log_error1("key is NULL"); + log_error("key is NULL"); return NULL; } @@ -245,7 +246,7 @@ hpairnode_get(hpair_t * pair, const char *key) { if (key == NULL) { - log_error1("key is NULL"); + log_error("key is NULL"); return NULL; } while (pair != NULL) @@ -369,7 +370,7 @@ part_new(const char *id, const char *filename, const char *content_type, const c if (!(part = (struct part_t *) malloc(sizeof(struct part_t)))) { - log_error2("malloc failed (%s)", strerror(errno)); + log_error("malloc failed (%s)", strerror(errno)); return NULL; } @@ -426,7 +427,7 @@ attachments_new(void) /* should be used internally */ if (!(attachments = (struct attachments_t *) malloc(sizeof(struct attachments_t)))) { - log_error2("malloc failed (%s)", strerror(errno)); + log_error("malloc failed (%s)", strerror(errno)); return NULL; } diff --git a/nanohttp/nanohttp-common.h b/nanohttp/nanohttp-common.h index 1e3d042..d3d725a 100644 --- a/nanohttp/nanohttp-common.h +++ b/nanohttp/nanohttp-common.h @@ -1,5 +1,5 @@ /****************************************************************** - * $Id: nanohttp-common.h,v 1.48 2007/01/03 08:33:44 m0gg Exp $ + * $Id: nanohttp-common.h,v 1.49 2007/11/03 22:40:10 m0gg Exp $ * * CSOAP Project: A http client/server library in C * Copyright (C) 2003-2004 Ferhat Ayaz @@ -28,7 +28,15 @@ #define HEADER_CONTENT_TRANSFER_ENCODING "Content-Transfer-Encoding" #define TRANSFER_ENCODING_CHUNKED "chunked" -/** @defgroup http_general_header_fields General Header Fields +/** @file nanohttp-common.h Common definitions and functions + * + * @defgroup NANOHTTP_COMMON Common stuff + * @ingroup NANOHTTP + */ +/**@{*/ + +/** @defgroup HTTP_HEADER_FIELDS Header Fields + * @ingroup NANOHTTP * * There are a few header fields which have general applicability for both * request and response messages, but which do not apply to the entity being @@ -40,20 +48,17 @@ * entity-header fields. * * @see http://www.ietf.org/rfc/rfc2616.txt - * */ /*@{*/ -/** - * - * The Cache-Control general-header field is used to specify directives that MUST - * be obeyed by all caching mechanisms along the request/response chain. The - * directives specify behavior intended to prevent caches from adversely - * interfering with the request or response. These directives typically override - * the default caching algorithms. Cache directives are unidirectional in that - * the presence of a directive in a request does not imply that the same - * directive is to be given in the response. - * +/** The Cache-Control general-header field is used to specify + * directives that MUST be obeyed by all caching mechanisms along the + * request/response chain. The directives specify behavior intended to + * prevent caches from adversely interfering with the request or + * response. These directives typically override the default caching + * algorithms. Cache directives are unidirectional in that the presence + * of a directive in a request does not imply that the same directive + * is to be given in the response. */ #define HEADER_CACHE_CONTROL "Cache-Control" @@ -323,18 +328,15 @@ typedef enum _http_version } http_version_t; -/** - * - * Object representation of the content-type field in a HTTP header: +/** Object representation of the content-type field in a HTTP header: * * Example: * - * @code - * Content-Type: text/xml; key="value" key2="value2' ... - * @endcode + * @verbatim + Content-Type: text/xml; key="value" key2="value2' ... + * @endverbatim * * @see HEADER_CONTENT_TYPE - * */ typedef struct _content_type { @@ -342,11 +344,9 @@ typedef struct _content_type hpair_t *params; } content_type_t; -/** - * - * The set of common methods for HTTP/1.1 is defined below. Although this set - * can be expanded, additional methods cannot be assumed to share the same - * semantics for separately extended clients and servers. +/** The set of common methods for HTTP/1.1 is defined below. Although + * this set can be expanded, additional methods cannot be assumed to + * share the same semantics for separately extended clients and servers. * * The Host request-header field MUST accompany all HTTP/1.1 requests. * @@ -356,7 +356,6 @@ typedef struct _content_type typedef enum _hreq_method { /** - * * The POST method is used to request that the origin server accept the entity * enclosed in the request as a new subordinate of the resource identified by * the Request-URI in the Request-Line. POST is designed to allow a uniform @@ -367,32 +366,26 @@ typedef enum _hreq_method * - Providing a block of data, such as the result of submitting a form, to a * data-handling process; * - Extending a database through an append operation. - * */ HTTP_REQUEST_POST, /** - * * The GET method means retrieve whatever information (in the form of an entity) * is identified by the Request-URI. If the Request-URI refers to a * data-producing process, it is the produced data which shall be returned as * the entity in the response and not the source text of the process, unless * that text happens to be the output of the process. - * */ HTTP_REQUEST_GET, /** - * * The OPTIONS method represents a request for information about the * communication options available on the request/response chain identified by * the Request-URI. This method allows the client to determine the options * and/or requirements associated with a resource, or the capabilities of a * server, without implying a resource action or initiating a resource * retrieval. - * */ HTTP_REQUEST_OPTIONS, /** - * * The HEAD method is identical to GET except that the server MUST NOT return * a message-body in the response. The metainformation contained in the HTTP * headers in response to a HEAD request SHOULD be identical to the information @@ -400,11 +393,9 @@ typedef enum _hreq_method * metainformation about the entity implied by the request without transferring * the entity-body itself. This method is often used for testing hypertext * links for validity, accessibility, and recent modification. - * */ HTTP_REQUEST_HEAD, /** - * * The PUT method requests that the enclosed entity be stored under the * supplied Request-URI. If the Request-URI refers to an already existing * resource, the enclosed entity SHOULD be considered as a modified version of @@ -420,11 +411,9 @@ typedef enum _hreq_method * problem. The recipient of the entity MUST NOT ignore any Content-* (e.g. * Content-Range) headers that it does not understand or implement and MUST * return a 501 (Not Implemented) response in such cases. - * */ HTTP_REQUEST_PUT, /** - * * The DELETE method requests that the origin server delete the resource * identified by the Request-URI. This method MAY be overridden by human * intervention (or other means) on the origin server. The client cannot be @@ -433,31 +422,27 @@ typedef enum _hreq_method * successfully. However, the server SHOULD NOT indicate success unless, at the * time the response is given, it intends to delete the resource or move it to * an inaccessible location. - * */ HTTP_REQUEST_DELETE, /** - * * The TRACE method is used to invoke a remote, application-layer loop-back of * the request message. The final recipient of the request SHOULD reflect the * message received back to the client as the entity-body of a 200 (OK) * response. The final recipient is either the origin server or the first proxy * or gateway to receive a Max-Forwards value of zero (0) in the request (see * section 14.31). A TRACE request MUST NOT include an entity. - * */ HTTP_REQUEST_TRACE, /** - * * This specification reserves the method name CONNECT for use with a proxy * that can dynamically switch to being a tunnel (e.g. SSL tunneling [44]). - * */ HTTP_REQUEST_CONNECT, HTTP_REQUEST_UNKOWN } hreq_method_t; -/** @defgroup http_status_codes HTTP status-codes +/** @defgroup HTTP_STATUS_CODES HTTP status-codes + * @ingroup NANOHTTP * * The Status-Code element is a 3-digit integer result code of the attempt to * understand and satisfy the request. These codes are fully defined in section @@ -563,113 +548,95 @@ typedef enum _hreq_method */ /*@{*/ -/** - * - * The client SHOULD continue with its request. This interim response is used to - * inform the client that the initial part of the request has been received and - * has not yet been rejected by the server. The client SHOULD continue by sending - * the remainder of the request or, if the request has already been completed, - * ignore this response. The server MUST send a final response after the request - * has been completed. See RFC 2616 section 8.2.3 for detailed discussion of the +/** The client SHOULD continue with its request. This interim response + * is used to inform the client that the initial part of the request + * has been received and has not yet been rejected by the server. The + * client SHOULD continue by sending the remainder of the request or, + * if the request has already been completed, ignore this response. The + * server MUST send a final response after the request has been + * completed. See RFC 2616 section 8.2.3 for detailed discussion of the * use and handling of this status code. * * @see http://www.ietf.org/rfc/rfc2616.txt - * */ #define HTTP_STATUS_100_REASON_PHRASE "Continue" -/** - * - * The server understands and is willing to comply with the client's request, - * via the Upgrade message header field (RFC 2616 section 14.42), for a change - * in the application protocol being used on this connection. The server will - * switch protocols to those defined by the response's Upgrade header field - * immediately after the empty line which terminates the 101 response. - * - * The protocol SHOULD be switched only when it is advantageous to do so. For - * example, switching to a newer version of HTTP is advantageous over older - * versions, and switching to a real-time, synchronous protocol might be - * advantageous when delivering resources that use such features. +/** The server understands and is willing to comply with the client's + * request, via the Upgrade message header field (RFC 2616 section 14.42), + * for a change in the application protocol being used on this + * connection. The server will switch protocols to those defined by + * the response's Upgrade header field immediately after the empty line + * which terminates the 101 response. * + * The protocol SHOULD be switched only when it is advantageous to do + * so. For example, switching to a newer version of HTTP is + * advantageous over older versions, and switching to a real-time, + * synchronous protocol might be advantageous when delivering resources + * that use such features. */ #define HTTP_STATUS_101_REASON_PHRASE "Switching Protocols" -/** - * - * The request has succeeded. The information returned with the response is - * dependent on the method used in the request, for example: +/** The request has succeeded. The information returned with the response + * is dependent on the method used in the request, for example: * - * GET an entity corresponding to the requested resource is sent in - * the response; - * - * HEAD the entity-header fields corresponding to the requested + * - GET an entity corresponding to the requested resource is sent in + * the response; + * - HEAD the entity-header fields corresponding to the requested * resource are sent in the response without any message-body; - * - * POST an entity describing or containing the result of the action; - * - * TRACE an entity containing the request message as received by the - * end server. - * + * - POST an entity describing or containing the result of the action; + * - TRACE an entity containing the request message as received by the + * end server. */ #define HTTP_STATUS_200_REASON_PHRASE "OK" -/** - * - * The request has been fulfilled and resulted in a new resource being created. - * The newly created resource can be referenced by the URI(s) returned in the - * entity of the response, with the most specific URI for the resource given by - * a Location header field. The response SHOULD include an entity containing a - * list of resource characteristics and location(s) from which the user or user - * agent can choose the one most appropriate. The entity format is specified by - * the media type given in the Content-Type header field. The origin server MUST - * create the resource before returning the 201 status code. If the action cannot - * be carried out immediately, the server SHOULD respond with 202 (Accepted) - * response instead. - * - * A 201 response MAY contain an ETag response header field indicating the - * current value of the entity tag for the requested variant just created, see - * RFC 2616 section 14.19. +/** The request has been fulfilled and resulted in a new resource being + * created. The newly created resource can be referenced by the URI(s) + * returned in the entity of the response, with the most specific URI + * for the resource given by a Location header field. The response + * SHOULD include an entity containing a list of resource + * characteristics and location(s) from which the user or user agent + * can choose the one most appropriate. The entity format is specified + * by the media type given in the Content-Type header field. The origin + * server MUST create the resource before returning the 201 status code. + * If the action cannot be carried out immediately, the server SHOULD + * respond with 202 (Accepted) response instead. + * + * A 201 response MAY contain an ETag response header field indicating + * the current value of the entity tag for the requested variant just + * created, see RFC 2616 section 14.19. * * @see http://www.ietf.org/rfc/rfc2616.txt - * */ #define HTTP_STATUS_201_REASON_PHRASE "Created" -/** - * - * The request has been accepted for processing, but the processing has not been - * completed. The request might or might not eventually be acted upon, as it - * might be disallowed when processing actually takes place. There is no - * facility for re-sending a status code from an asynchronous operation such as - * this. - * - * The 202 response is intentionally non-committal. Its purpose is to allow a - * server to accept a request for some other process (perhaps a batch-oriented - * process that is only run once per day) without requiring that the user - * agent's connection to the server persist until the process is completed. The - * entity returned with this response SHOULD include an indication of the - * request's current status and either a pointer to a status monitor or some - * estimate of when the user can expect the request to be fulfilled. - * +/** The request has been accepted for processing, but the processing + * has not been completed. The request might or might not eventually be + * acted upon, as it might be disallowed when processing actually takes + * place. There is no facility for re-sending a status code from an + * asynchronous operation such as this. + * + * The 202 response is intentionally non-committal. Its purpose is to + * allow a server to accept a request for some other process (perhaps a + * batch-oriented process that is only run once per day) without + * requiring that the user agent's connection to the server persist + * until the process is completed. The entity returned with this + * response SHOULD include an indication of the request's current + * status and either a pointer to a status monitor or some estimate of + * when the user can expect the request to be fulfilled. */ #define HTTP_STATUS_202_REASON_PHRASE "Accepted" -/** - * - * The returned metainformation in the entity-header is not the definitive set +/** The returned metainformation in the entity-header is not the definitive set * as available from the origin server, but is gathered from a local or a * third-party copy. The set presented MAY be a subset or superset of the * original version. For example, including local annotation information about * the resource might result in a superset of the metainformation known by the * origin server. Use of this response code is not required and is only * appropriate when the response would otherwise be 200 (OK). - * */ #define HTTP_STATUS_203_REASON_PHRASE "Non-Authoritative Information" -/** - * - * The server has fulfilled the request but does not need to return an +/** The server has fulfilled the request but does not need to return an * entity-body, and might want to return updated metainformation. The response * MAY include new or updated metainformation in the form of entity-headers, * which if present SHOULD be associated with the requested variant. @@ -682,25 +649,19 @@ typedef enum _hreq_method * * The 204 response MUST NOT include a message-body, and thus is always * terminated by the first empty line after the header fields. - * */ #define HTTP_STATUS_204_REASON_PHRASE "No Content" -/** - * - * The server has fulfilled the request and the user agent SHOULD reset the +/** The server has fulfilled the request and the user agent SHOULD reset the * document view which caused the request to be sent. This response is primarily * intended to allow input for actions to take place via user input, followed by * a clearing of the form in which the input is given so that the user can * easily initiate another input action. The response MUST NOT include an * entity. - * */ #define HTTP_STATUS_205_REASON_PHRASE "Reset Content" -/** - * - * The server has fulfilled the partial GET request for the resource. The request +/** The server has fulfilled the partial GET request for the resource. The request * MUST have included a Range header field (RFC 2616 section 14.35) indicating * the desired range, and MAY have included an If-Range header field (RFC 2616 * section 14.27) to make the request conditional. @@ -733,13 +694,10 @@ typedef enum _hreq_method * * A cache that does not support the Range and Content-Range headers MUST NOT * cache 206 (Partial) responses. - * */ #define HTTP_STATUS_206_REASON_PHRASE "Partial Content" -/** - * - * The requested resource corresponds to any one of a set of representations, +/** The requested resource corresponds to any one of a set of representations, * each with its own specific location, and agent-driven negotiation information * (RFC 2616 section 12) is being provided so that the user (or user agent) can * select a preferred representation and redirect its request to that location. @@ -756,13 +714,10 @@ typedef enum _hreq_method * specific URI for that representation in the Location field; user agents MAY * use the Location field value for automatic redirection. This response is * cacheable unless indicated otherwise. - * */ #define HTTP_STATUS_300_REASON_PHRASE "Multiple Choices" -/** - * - * The requested resource has been assigned a new permanent URI and any future +/** The requested resource has been assigned a new permanent URI and any future * references to this resource SHOULD use one of the returned URIs. Clients * with link editing capabilities ought to automatically re-link references to * the Request-URI to one or more of the new references returned by the server, @@ -776,13 +731,10 @@ typedef enum _hreq_method * HEAD, the user agent MUST NOT automatically redirect the request unless it can * be confirmed by the user, since this might change the conditions under which * the request was issued. - * */ #define HTTP_STATUS_301_REASON_PHRASE "Moved Permanently" -/** - * - * The requested resource resides temporarily under a different URI. Since the +/** The requested resource resides temporarily under a different URI. Since the * redirection might be altered on occasion, the client SHOULD continue to use * the Request-URI for future requests. This response is only cacheable if * indicated by a Cache-Control or Expires header field. @@ -806,9 +758,7 @@ typedef enum _hreq_method */ #define HTTP_STATUS_302_REASON_PHRASE "Found" -/** - * - * The response to the request can be found under a different URI and SHOULD be +/** The response to the request can be found under a different URI and SHOULD be * retrieved using a GET method on that resource. This method exists primarily to * allow the output of a POST-activated script to redirect the user agent to a * selected resource. The new URI is not a substitute reference for the @@ -823,13 +773,10 @@ typedef enum _hreq_method * interoperability with such clients is a concern, the 302 status code may be * used instead, since most user agents react to a 302 response as described * here for 303. - * */ #define HTTP_STATUS_303_REASON_PHRASE "See Other" -/** - * - * If the client has performed a conditional GET request and access is allowed, +/** If the client has performed a conditional GET request and access is allowed, * but the document has not been modified, the server SHOULD respond with this * status code. The 304 response MUST NOT contain a message-body, and thus is * always terminated by the first empty line after the header fields. @@ -858,13 +805,10 @@ typedef enum _hreq_method * * If a cache uses a received 304 response to update a cache entry, the cache * MUST update the entry to reflect any new field values given in the response. - * */ #define HTTP_STATUS_304_REASON_PHRASE "Not Modified" -/** - * - * The requested resource MUST be accessed through the proxy given by the +/** The requested resource MUST be accessed through the proxy given by the * Location field. The Location field gives the URI of the proxy. The recipient * is expected to repeat this single request via the proxy. 305 responses MUST * only be generated by origin servers. @@ -872,13 +816,10 @@ typedef enum _hreq_method * Note: RFC 2068 was not clear that 305 was intended to redirect a single * request, and to be generated by origin servers only. Not observing these * limitations has significant security consequences. - * */ #define HTTP_STATUS_305_REASON_PHRASE "Use Proxy" -/** - * - * The requested resource resides temporarily under a different URI. Since the +/** The requested resource resides temporarily under a different URI. Since the * redirection MAY be altered on occasion, the client SHOULD continue to use the * Request-URI for future requests. This response is only cacheable if indicated * by a Cache-Control or Expires header field. @@ -894,21 +835,15 @@ typedef enum _hreq_method * HEAD, the user agent MUST NOT automatically redirect the request unless it can * be confirmed by the user, since this might change the conditions under which * the request was issued. - * */ #define HTTP_STATUS_307_REASON_PHRASE "Temporary Redirect" -/** - * - * The request could not be understood by the server due to malformed syntax. +/** The request could not be understood by the server due to malformed syntax. * The client SHOULD NOT repeat the request without modifications. - * */ #define HTTP_STATUS_400_REASON_PHRASE "Bad Request" -/** - * - * The request requires user authentication. The response MUST include a +/** The request requires user authentication. The response MUST include a * WWW-Authenticate header field (RFC 2616 section 14.47) containing a challenge * applicable to the requested resource. The client MAY repeat the request with * a suitable Authorization header field (RFC 2616 section 14.8). If the request @@ -923,54 +858,39 @@ typedef enum _hreq_method * * @see http://www.ietf.org/rfc/rfc2616.txt * @see http://www.ietf.org/rfc/rfc2617.txt - * */ #define HTTP_STATUS_401_REASON_PHRASE "Unauthorized" -/** - * - * This code is reserved for future use. - * +/** This code is reserved for future use. */ #define HTTP_STATUS_402_REASON_PHRASE "Payment Required" -/** - * - * The server understood the request, but is refusing to fulfill it. +/** The server understood the request, but is refusing to fulfill it. * Authorization will not help and the request SHOULD NOT be repeated. If the * request method was not HEAD and the server wishes to make public why the * request has not been fulfilled, it SHOULD describe the reason for the refusal * in the entity. If the server does not wish to make this information * available to the client, the status code 404 (Not Found) can be used instead. - * */ #define HTTP_STATUS_403_REASON_PHRASE "Forbidden" -/** - * - * The server has not found anything matching the Request-URI. No indication is +/** The server has not found anything matching the Request-URI. No indication is * given of whether the condition is temporary or permanent. The 410 (Gone) * status code SHOULD be used if the server knows, through some internally * configurable mechanism, that an old resource is permanently unavailable and * has no forwarding address. This status code is commonly used when the server * does not wish to reveal exactly why the request has been refused, or when no * other response is applicable. - * */ #define HTTP_STATUS_404_REASON_PHRASE "Not Found" -/** - * - * The method specified in the Request-Line is not allowed for the resource +/** The method specified in the Request-Line is not allowed for the resource * identified by the Request-URI. The response MUST include an Allow header * containing a list of valid methods for the requested resource. - * */ #define HTTP_STATUS_405_REASON_PHRASE "Method Not Allowed" -/** - * - * The resource identified by the request is only capable of generating response +/** The resource identified by the request is only capable of generating response * entities which have content characteristics not acceptable according to the * accept headers sent in the request. * @@ -990,13 +910,10 @@ typedef enum _hreq_method * * If the response could be unacceptable, a user agent SHOULD temporarily stop * receipt of more data and query the user for a decision on further actions. - * */ #define HTTP_STATUS_406_REASON_PHRASE "Not Acceptable" -/** - * - * This code is similar to 401 (Unauthorized), but indicates that the client +/** This code is similar to 401 (Unauthorized), but indicates that the client * must first authenticate itself with the proxy. The proxy MUST return a * Proxy-Authenticate header field (RFC 2616 section 14.33) containing a * challenge applicable to the proxy for the requested resource. The client MAY @@ -1006,22 +923,17 @@ typedef enum _hreq_method * * @see http://www.ietf.org/rfc/rfc2616.txt * @see http://www.ietf.org/rfc/rfc2617.txt - * */ #define HTTP_STATUS_407_REASON_PHRASE "Proxy Authentication Required" -/** - * - * The client did not produce a request within the time that the server was +/** The client did not produce a request within the time that the server was * prepared to wait. The client MAY repeat the request without modifications at * any later time. * */ #define HTTP_STATUS_408_REASON_PHRASE "Request Time-out" -/** - * - * The request could not be completed due to a conflict with the current state +/** The request could not be completed due to a conflict with the current state * of the resource. This code is only allowed in situations where it is expected * that the user might be able to resolve the conflict and resubmit the request. * The response body SHOULD include enough information for the user to recognize @@ -1036,13 +948,10 @@ typedef enum _hreq_method * request. In this case, the response entity would likely contain a list of the * differences between the two versions in a format defined by the response * Content-Type. - * */ #define HTTP_STATUS_409_REASON_PHRASE "Conflict" -/** - * - * The requested resource is no longer available at the server and no forwarding +/** The requested resource is no longer available at the server and no forwarding * address is known. This condition is expected to be considered permanent. * Clients with link editing capabilities SHOULD delete references to the * Request-URI after user approval. If the server does not know, or has no @@ -1058,46 +967,34 @@ typedef enum _hreq_method * is not necessary to mark all permanently unavailable resources as "gone" or to * keep the mark for any length of time -- that is left to the discretion of the * server owner. - * */ #define HTTP_STATUS_410_REASON_PHRASE "Gone" -/** - * - * The server refuses to accept the request without a defined Content- Length. +/** The server refuses to accept the request without a defined Content- Length. * The client MAY repeat the request if it adds a valid Content-Length header * field containing the length of the message-body in the request message. - * */ #define HTTP_STATUS_411_REASON_PHRASE "Length Required" -/** - * - * The precondition given in one or more of the request-header fields evaluated +/** The precondition given in one or more of the request-header fields evaluated * to false when it was tested on the server. This response code allows the * client to place preconditions on the current resource metainformation (header * field data) and thus prevent the requested method from being applied to a * resource other than the one intended. - * */ #define HTTP_STATUS_412_REASON_PHRASE "Precondition Failed" -/** - * - * The server is refusing to process a request because the request entity is +/** The server is refusing to process a request because the request entity is * larger than the server is willing or able to process. The server MAY close * the connection to prevent the client from continuing the request. * * If the condition is temporary, the server SHOULD include a Retry-After header * field to indicate that it is temporary and after what time the client MAY try * again. - * */ #define HTTP_STATUS_413_REASON_PHRASE "Request Entity Too Large" -/** - * - * The server is refusing to service the request because the Request-URI is +/** The server is refusing to service the request because the Request-URI is * longer than the server is willing to interpret. This rare condition is only * likely to occur when a client has improperly converted a POST request to a * GET request with long query information, when the client has descended into a @@ -1109,18 +1006,13 @@ typedef enum _hreq_method */ #define HTTP_STATUS_414_REASON_PHRASE "Request-URI Too Large" -/** - * - * The server is refusing to service the request because the entity of the +/** The server is refusing to service the request because the entity of the * request is in a format not supported by the requested resource for the * requested method. - * */ #define HTTP_STATUS_415_REASON_PHRASE "Unsupported Media Type" -/** - * - * A server SHOULD return a response with this status code if a request included +/** A server SHOULD return a response with this status code if a request included * a Range request-header field (RFC 2616 section 14.35), and none of the * range-specifier values in this field overlap the current extent of the * selected resource, and the request did not include an If-Range request-header @@ -1132,48 +1024,33 @@ typedef enum _hreq_method * SHOULD include a Content-Range entity-header field specifying the current * length of the selected resource (see RFC 2616 section 14.16). This response * MUST NOT use the multipart/byteranges content-type. - * */ #define HTTP_STATUS_416_REASON_PHRASE "Requested range not satisfiable" -/** - * - * The expectation given in an Expect request-header field (see RFC 2616 section +/** The expectation given in an Expect request-header field (see RFC 2616 section * 14.20) could not be met by this server, or, if the server is a proxy, the * server has unambiguous evidence that the request could not be met by the * next-hop server. - * */ #define HTTP_STATUS_417_REASON_PHRASE "Expectation Failed" -/** - * - * The server encountered an unexpected condition which prevented it from +/** The server encountered an unexpected condition which prevented it from * fulfilling the request. - * */ #define HTTP_STATUS_500_REASON_PHRASE "Internal Server Error" -/** - * - * The server does not support the functionality required to fulfill the request. +/** The server does not support the functionality required to fulfill the request. * This is the appropriate response when the server does not recognize the * request method and is not capable of supporting it for any resource. - * */ #define HTTP_STATUS_501_REASON_PHRASE "Not Implemented" -/** - * - * The server, while acting as a gateway or proxy, received an invalid response +/** The server, while acting as a gateway or proxy, received an invalid response * from the upstream server it accessed in attempting to fulfill the request. - * */ #define HTTP_STATUS_502_REASON_PHRASE "Bad Gateway" -/** - * - * The server is currently unable to handle the request due to a temporary +/** The server is currently unable to handle the request due to a temporary * overloading or maintenance of the server. The implication is that this is a * temporary condition which will be alleviated after some delay. If known, the * length of the delay MAY be indicated in a Retry-After header. If no @@ -1183,32 +1060,25 @@ typedef enum _hreq_method * Note: The existence of the 503 status code does not imply that a server must * use it when becoming overloaded. Some servers may wish to simply refuse the * connection. - * */ #define HTTP_STATUS_503_REASON_PHRASE "Service Unavailable" -/** - * - * The server, while acting as a gateway or proxy, did not receive a timely +/** The server, while acting as a gateway or proxy, did not receive a timely * response from the upstream server specified by the URI (e.g. HTTP, FTP, LDAP) * or some other auxiliary server (e.g. DNS) it needed to access in attempting * to complete the request. * * Note: Note to implementors: some deployed proxies are known to return 400 or * 500 when DNS lookups time out. - * */ #define HTTP_STATUS_504_REASON_PHRASE "Gateway Time-out" -/** - * - * The server does not support, or refuses to support, the HTTP protocol version +/** The server does not support, or refuses to support, the HTTP protocol version * that was used in the request message. The server is indicating that it is * unable or unwilling to complete the request using the same major version as * the client, as described in RFC 2616 section 3.1, other than with this error * message. The response SHOULD contain an entity describing why that version is * not supported and what other protocols are supported by that server. - * */ #define HTTP_STATUS_505_REASON_PHRASE "HTTP Version not supported" @@ -1416,4 +1286,6 @@ extern void attachments_add_part(struct attachments_t * attachments, struct part } #endif +/**@}*/ + #endif diff --git a/nanohttp/nanohttp-error.c b/nanohttp/nanohttp-error.c index a556af8..d2f48d7 100644 --- a/nanohttp/nanohttp-error.c +++ b/nanohttp/nanohttp-error.c @@ -1,5 +1,6 @@ +/** @file nanohttp-error.c Error handling */ /****************************************************************** -* $Id: nanohttp-error.c,v 1.1 2006/12/09 09:36:57 m0gg Exp $ +* $Id: nanohttp-error.c,v 1.2 2007/11/03 22:40:11 m0gg Exp $ * * CSOAP Project: A http client/server library in C * Copyright (C) 2003 Ferhat Ayaz @@ -63,16 +64,12 @@ herror_new(const char *func, int errcode, const char *format, ...) if (!(impl = (herror_impl_t *) malloc(sizeof(herror_impl_t)))) { - log_error2("malloc failed (%s)", strerror(errno)); + log_error("malloc failed (%s)", strerror(errno)); return NULL; } impl->errcode = errcode; - - if (func) - impl->func = strdup(func); - else - func = NULL; + impl->func = func ? strdup(func) : NULL; va_start(ap, format); vsprintf(impl->message, format, ap); diff --git a/nanohttp/nanohttp-error.h b/nanohttp/nanohttp-error.h index 77e5721..775f079 100644 --- a/nanohttp/nanohttp-error.h +++ b/nanohttp/nanohttp-error.h @@ -1,5 +1,5 @@ /****************************************************************** - * $Id: nanohttp-error.h,v 1.4 2006/12/10 19:21:06 m0gg Exp $ + * $Id: nanohttp-error.h,v 1.5 2007/11/03 22:40:11 m0gg Exp $ * * CSOAP Project: A http client/server library in C * Copyright (C) 2003-2004 Ferhat Ayaz @@ -24,7 +24,7 @@ #ifndef __nanohttp_error_h #define __nanohttp_error_h -/** @file +/** @file nanohttp-error.h Error handling * * nanoHTTP error handling * @@ -55,38 +55,37 @@ * */ -/** - * - * Success flag - * +/** @defgroup NANOHTTP_ERRORS nanoHTTP errors + * @ingroup NANOHTTP */ -#define H_OK 0 +/**@{*/ -/** - * - * General errors - * +/** @defgroup NANOHTTP_GENERAL_ERROS General errors */ +/**@{*/ +#define H_OK 0 /**< Success flag */ + #define GENERAL_ERROR 1400 #define GENERAL_INVALID_PARAM (GENERAL_ERROR + 1) #define GENERAL_HEADER_PARSE_ERROR (GENERAL_ERROR + 2) +/**@}*/ -/** - * - * Thread errors - * +/** @defgroup NANOHTTP_THREAD_ERRORS Thread errors */ +/**@{*/ #define THREAD_ERROR 1500 #define THREAD_BEGIN_ERROR (THREAD_ERROR) +/**@}*/ -/** - * - * File errors - * +/** @defgroup NANOHTTP_FILE_ERRORS File errors */ +/**@{*/ #define FILE_ERROR 8000 #define FILE_ERROR_OPEN (FILE_ERROR + 1) #define FILE_ERROR_READ (FILE_ERROR + 2) +/**@}*/ + +/**@}*/ /** * @@ -119,7 +118,7 @@ extern int herror_code(herror_t err); /** * - * Returns the name of the function, where the error was produced. + * @return The name of the function, where the error was produced. * */ extern const char *herror_func(herror_t err); diff --git a/nanohttp/nanohttp-logging.c b/nanohttp/nanohttp-logging.c index 5e1244d..45fc01a 100644 --- a/nanohttp/nanohttp-logging.c +++ b/nanohttp/nanohttp-logging.c @@ -1,8 +1,9 @@ +/** @file nanohttp-logging.c Logging functions */ /****************************************************************** -* $Id: nanohttp-logging.c,v 1.2 2006/11/25 17:03:20 m0gg Exp $ +* $Id: nanohttp-logging.c,v 1.3 2007/11/03 22:40:11 m0gg Exp $ * * CSOAP Project: A http client/server library in C -* Copyright (C) 2003 Ferhat Ayaz +* Copyright (C) 2007 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,12 +20,15 @@ * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. * -* Email: ayaz@jprogrammer.net ******************************************************************/ #ifdef HAVE_CONFIG_H #include #endif +#ifdef HAVE_CTYPE_H +#include +#endif + #ifdef HAVE_STDIO_H #include #endif @@ -41,169 +45,130 @@ #include #endif -#ifdef HAVE_CTYPE_H -#include -#endif - -#ifdef HAVE_PTHREAD_H -#include +#ifdef HAVE_SYSLOG_H +#include #endif #include "nanohttp-logging.h" -#ifdef WIN32 -#ifndef __MINGW32__ +static int _nanohttp_logtype = NANOHTTP_LOG_FOREGROUND; +static nanohttp_loglevel_t _nanohttp_log_loglevel = NANOHTTP_LOG_DEBUG; +static char *_nanohttp_log_logfile = NULL; -/* not thread safe!*/ +#if defined WIN32 && defined __MINGW32__ char * VisualC_funcname(const char *file, int line) { static char buffer[256]; - int i = strlen(file) - 1; - while (i > 0 && file[i] != '\\') - i--; + int i; + + for (i = strlen(file) - 1; i > 0 && file[i] != '\\'; i--) + /* nothing */ ; sprintf(buffer, "%s:%d", (file[i] != '\\') ? file : (file + i + 1), line); return buffer; } - #endif -#endif - -static log_level_t loglevel = HLOG_DEBUG; -static char logfile[75] = { '\0' }; -static int log_background = 0; -log_level_t -hlog_set_level(log_level_t level) +nanohttp_loglevel_t +nanohttp_log_set_loglevel(nanohttp_loglevel_t loglevel) { - log_level_t old = loglevel; - loglevel = level; + nanohttp_loglevel_t old; + + old = _nanohttp_log_loglevel; + _nanohttp_log_loglevel = loglevel; + return old; } -log_level_t -hlog_get_level(void) +nanohttp_loglevel_t +nanohttp_log_get_loglevel(void) { - return loglevel; + return _nanohttp_log_loglevel; } -void -hlog_set_file(const char *filename) +int +nanohttp_log_set_logtype(int type) { - if (filename) - strncpy(logfile, filename, 75); - else - logfile[0] = '\0'; + int old; - return; -} - -void -hlog_set_background(int state) -{ - log_background = state; + old = _nanohttp_logtype; + _nanohttp_logtype = type; - return; -} - -char * -hlog_get_file(void) -{ - if (logfile[0] == '\0') - return NULL; - return logfile; + return old; } -static void -_log_write(log_level_t level, const char *prefix, - const char *func, const char *format, va_list ap) +const char * +nanohttp_log_get_logfile(void) { - char buffer[1054]; - char buffer2[1054]; - FILE *f; - - if (level < loglevel) - return; - - if (!log_background || hlog_get_file()) - { -#ifdef WIN32 - sprintf(buffer, "*%s*: [%s] %s\n", prefix, func, format); -#else - sprintf(buffer, "*%s*:(%ld) [%s] %s\n", - prefix, pthread_self(), func, format); -#endif - vsprintf(buffer2, buffer, ap); - if (!log_background) - { - printf(buffer2); - fflush(stdout); - } - - if (hlog_get_file()) - { - f = fopen(hlog_get_file(), "a"); - if (!f) - f = fopen(hlog_get_file(), "w"); - if (f) - { - fprintf(f, buffer2); - fflush(f); - fclose(f); - } - } - } - - return; + return _nanohttp_log_logfile; } void -hlog_verbose(const char *FUNC, const char *format, ...) +nanohttp_log_set_logfile(const char *filename) { - va_list ap; + if (_nanohttp_log_logfile) + free(_nanohttp_log_logfile); - va_start(ap, format); - _log_write(HLOG_VERBOSE, "VERBOSE", FUNC, format, ap); - va_end(ap); + if (filename) + _nanohttp_log_logfile = strdup(filename); } void -hlog_debug(const char *FUNC, const char *format, ...) +_nanohttp_log_printf(nanohttp_loglevel_t level, const char *format, ...) { + const char *filename; va_list ap; + if (level < _nanohttp_log_loglevel) + return; + va_start(ap, format); - _log_write(HLOG_DEBUG, "DEBUG", FUNC, format, ap); - va_end(ap); -} -void -hlog_info(const char *FUNC, const char *format, ...) -{ - va_list ap; + if (_nanohttp_logtype & NANOHTTP_LOG_FOREGROUND) + vfprintf(stdout, format, ap); - va_start(ap, format); - _log_write(HLOG_INFO, "INFO", FUNC, format, ap); - va_end(ap); -} +#ifdef HAVE_SYSLOG_H + if (_nanohttp_logtype & NANOHTTP_LOG_SYSLOG) + { + int syslog_level; -void -hlog_warn(const char *FUNC, const char *format, ...) -{ - va_list ap; + switch (level) + { + case NANOHTTP_LOGLEVEL_VERBOSE: + case NANOHTTP_LOGLEVEL_DEBUG: + syslog_level = LOG_DEBUG; + break; + case NANOHTTP_LOGLEVEL_INFO: + syslog_level = LOG_INFO; + break; + case NANOHTTP_LOGLEVEL_WARN: + syslog_level = LOG_WARNING; + break; + case NANOHTTP_LOGLEVEL_ERROR: + syslog_level = LOG_ERR; + break; + case NANOHTTP_LOGLEVEL_FATAL: + syslog_level = LOG_CRIT; + break; + } + vsyslog(syslog_level, format, ap); + } +#endif - va_start(ap, format); - _log_write(HLOG_WARN, "WARN", FUNC, format, ap); - va_end(ap); -} + if ((filename = nanohttp_log_get_logfile())) + { + FILE *fp; -void -hlog_error(const char *FUNC, const char *format, ...) -{ - va_list ap; + if (!(fp = fopen(filename, "a"))) + fp = fopen(filename, "w"); + + if (fp) + { + vfprintf(fp, format, ap); + fflush(fp); + fclose(fp); + } + } - va_start(ap, format); - _log_write(HLOG_ERROR, "ERROR", FUNC, format, ap); va_end(ap); } - diff --git a/nanohttp/nanohttp-logging.h b/nanohttp/nanohttp-logging.h index cf1fe3f..2ead973 100644 --- a/nanohttp/nanohttp-logging.h +++ b/nanohttp/nanohttp-logging.h @@ -1,8 +1,8 @@ /****************************************************************** - * $Id: nanohttp-logging.h,v 1.5 2006/12/10 19:21:06 m0gg Exp $ + * $Id: nanohttp-logging.h,v 1.6 2007/11/03 22:40:11 m0gg Exp $ * * CSOAP Project: A http client/server library in C - * Copyright (C) 2003-2006 Ferhat Ayaz + * Copyright (C) 2007 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,122 +19,130 @@ * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. * - * Email: hero@persua.de ******************************************************************/ #ifndef __nanohttp_logging_h #define __nanohttp_logging_h +/** @file nanohttp-logging.h Logging definitions and prototypes + * + * @defgroup NANOHTTP_LOGGING Logging interface + * @ingroup NANOHTTP + */ +/**@{*/ + +/** @defgroup NANOHTTP_CMDLINE_LOGGING Commandline flags + * @ingroup NANOHTTP_CMDLINE + */ +/**@{*/ #define NHTTP_ARG_LOGFILE "-NHTTPlog" #define NHTTP_ARG_LOGLEVEL "-NHTTPloglevel" +/**@}*/ -/* logging stuff */ -typedef enum log_level +/** Loglevel definition */ +typedef enum nanohttp_loglevel { - HLOG_VERBOSE, - HLOG_DEBUG, - HLOG_INFO, - HLOG_WARN, - HLOG_ERROR, - HLOG_FATAL, - HLOG_OFF -} log_level_t; - + NANOHTTP_LOG_OFF, /**< Logging completely turned off (use at your + own risk). */ + NANOHTTP_LOG_VERBOSE, /**< Debugging messages that may overflow the + log */ + NANOHTTP_LOG_DEBUG, /**< Message that contain information normally + of use only when debugging the library */ + NANOHTTP_LOG_INFO, /**< Informaional messages */ + NANOHTTP_LOG_WARN, /**< Warning messages */ + NANOHTTP_LOG_ERROR, /**< A condition that should be corrected + immediately, such as a broken network + connection */ + NANOHTTP_LOG_FATAL /**< A panic condition */ +} nanohttp_loglevel_t; + +#define NANOHTTP_LOG_LEVEL_OFF_STRING "OFF" +#define NANOHTTP_LOG_LEVEL_VERBOSE_STRING "VERBOSE" +#define NANOHTTP_LOG_LEVEL_DEBUG_STRING "DEBUG" +#define NANOHTTP_LOG_LEVEL_INFO_STRING "INFO" +#define NANOHTTP_LOG_LEVEL_WARN_STRING "WARN" +#define NANOHTTP_LOG_LEVEL_ERROR_STRING "ERROR" +#define NANOHTTP_LOG_LEVEL_FATAL_STRING "FATAL" +#define NANOHTTP_LOG_LEVEL_UNKNOWN_STRING "UNKNOWN" #ifdef __cplusplus extern "C" { #endif -/** - * - * Set the loglevel. +/** This function sets a new the loglevel and returns the previous + * one. * * @param level The new loglevel. * * @return The old loglevel. - * */ -extern log_level_t hlog_set_level(log_level_t level); +extern nanohttp_loglevel_t nanohttp_log_set_loglevel(nanohttp_loglevel_t level); -/** - * - * Get the loglevel. +/** This function returns the current loglevel. * * @return The current loglevel. - * */ -extern log_level_t hlog_get_level(void); +extern nanohttp_loglevel_t nanohttp_log_get_loglevel(void); -/** - * - * Set the logfile. +/** This function set the name of a logfile. * * @param filename The filename of the logfile. - * */ -extern void hlog_set_file(const char *filename); +extern void nanohttp_log_set_logfile(const char *filename); -/** +/** This function returns the filename of the current logfile. * - * Get the filename of the logfile. + * @return Pointer to the filename or NULL otherwise. + */ +extern const char *nanohttp_log_get_logfile(void); + +#define NANOHTTP_LOG_DISABLED 0x00 /**< Logging disabled */ +#define NANOHTTP_LOG_FOREGROUND 0x01 /**< Logging to stdout enabled */ +#define NANOHTTP_LOG_SYSLOG 0x02 /**< Syslog logging enabled */ + +/** This function sets the type of logging * - * @return Pointer to the filename or null otherwise. + * @return The old logtype. * + * @see - NANOHTTP_LOG_DISABLED + * - NANOHTTP_LOG_FOREGROUND + * - NANOHTTP_LOG_SYSLOG */ -extern char *hlog_get_file(void); +extern int nanohttp_log_set_logtype(int type); #ifdef WIN32 #if defined(_MSC_VER) && _MSC_VER <= 1200 -char *VisualC_funcname(const char *file, int line); /* not thread safe! */ +extern char *VisualC_funcname(const char *file, int line); /* not thread safe! */ #define __FUNCTION__ VisualC_funcname(__FILE__, __LINE__) #endif #endif -extern void hlog_verbose(const char *FUNC, const char *format, ...); -extern void hlog_debug(const char *FUNC, const char *format, ...); -extern void hlog_info(const char *FUNC, const char *format, ...); -extern void hlog_warn(const char *FUNC, const char *format, ...); -extern void hlog_error(const char *FUNC, const char *format, ...); - #ifdef __cplusplus } #endif -/** - * - * @todo This isn't the "right" way - * - * #define log_debug(fmt, ...) fprintf(stderr, "EMERGENCY: %s: " fmt "\n", \ - * __FUNCTION__, ## __VA_ARGS__) - * - */ -#define log_verbose1(a1) hlog_verbose(__FUNCTION__, a1) -#define log_verbose2(a1,a2) hlog_verbose(__FUNCTION__, a1,a2) -#define log_verbose3(a1,a2,a3) hlog_verbose(__FUNCTION__, a1,a2,a3) -#define log_verbose4(a1,a2,a3,a4) hlog_verbose(__FUNCTION__, a1,a2,a3,a4) -#define log_verbose5(a1,a2,a3,a4,a5) hlog_verbose(__FUNCTION__, a1,a2,a3,a4,a5) - -#define log_debug1(a1) hlog_debug(__FUNCTION__, a1) -#define log_debug2(a1,a2) hlog_debug(__FUNCTION__, a1,a2) -#define log_debug3(a1,a2,a3) hlog_debug(__FUNCTION__, a1,a2,a3) -#define log_debug4(a1,a2,a3,a4) hlog_debug(__FUNCTION__, a1,a2,a3,a4) -#define log_debug5(a1,a2,a3,a4,a5) hlog_debug(__FUNCTION__, a1,a2,a3,a4,a5) - -#define log_info1(a1) hlog_info(__FUNCTION__, a1) -#define log_info2(a1,a2) hlog_info(__FUNCTION__, a1,a2) -#define log_info3(a1,a2,a3) hlog_info(__FUNCTION__, a1,a2,a3) -#define log_info4(a1,a2,a3,a4) hlog_info(__FUNCTION__, a1,a2,a3,a4) -#define log_info5(a1,a2,a3,a4,a5) hlog_info(__FUNCTION__, a1,a2,a3,a4,a5) - -#define log_warn1(a1) hlog_warn(__FUNCTION__, a1) -#define log_warn2(a1,a2) hlog_warn(__FUNCTION__, a1,a2) -#define log_warn3(a1,a2,a3) hlog_warn(__FUNCTION__, a1,a2,a3) -#define log_warn4(a1,a2,a3,a4) hlog_warn(__FUNCTION__, a1,a2,a3,a4) -#define log_warn5(a1,a2,a3,a4,a5) hlog_warn(__FUNCTION__, a1,a2,a3,a4,a5) - -#define log_error1(a1) hlog_error(__FUNCTION__, a1) -#define log_error2(a1,a2) hlog_error(__FUNCTION__, a1,a2) -#define log_error3(a1,a2,a3) hlog_error(__FUNCTION__, a1,a2,a3) -#define log_error4(a1,a2,a3,a4) hlog_error(__FUNCTION__, a1,a2,a3,a4) -#define log_error5(a1,a2,a3,a4,a5) hlog_error(__FUNCTION__, a1,a2,a3,a4,a5) +#define log_verbose(fmt, ...) _nanohttp_log_printf(NANOHTTP_LOG_VERBOSE, \ + NANOHTTP_LOG_LEVEL_VERBOSE_STRING " %s: " fmt "\n", \ + __FUNCTION__, ## __VA_ARGS__) + +#define log_debug(fmt, ...) _nanohttp_log_printf(NANOHTTP_LOG_DEBUG, \ + NANOHTTP_LOG_LEVEL_DEBUG_STRING " %s: " fmt "\n", \ + __FUNCTION__, ## __VA_ARGS__) + +#define log_info(fmt, ...) _nanohttp_log_printf(NANOHTTP_LOG_INFO, \ + NANOHTTP_LOG_LEVEL_INFO_STRING " %s: " fmt "\n", \ + __FUNCTION__, ## __VA_ARGS__) + +#define log_warn(fmt, ...) _nanohttp_log_printf(NANOHTTP_LOG_WARN, \ + NANOHTTP_LOG_LEVEL_WARN_STRING " %s: " fmt "\n", \ + __FUNCTION__, ## __VA_ARGS__) + +#define log_error(fmt, ...) _nanohttp_log_printf(NANOHTTP_LOG_ERROR, \ + NANOHTTP_LOG_LEVEL_ERROR_STRING " %s: " fmt "\n", \ + __FUNCTION__, ## __VA_ARGS__) + +#define log_fatal(fmt, ...) _nanohttp_log_printf(NANOHTTP_LOG_FATAL, \ + NANOHTTP_LOG_LEVEL_FATAL_STRING " %s: " fmt "\n", \ + __FUNCTION__, ## __VA_ARGS__) +/**@}*/ #endif diff --git a/nanohttp/nanohttp-mime.c b/nanohttp/nanohttp-mime.c index 4798bf4..81b3387 100755 --- a/nanohttp/nanohttp-mime.c +++ b/nanohttp/nanohttp-mime.c @@ -1,9 +1,10 @@ +/** @file nanohttp-mime.c MIME handling */ /****************************************************************** * _ _ _ _ _ __ * | \/ | | | | \/ | | _/ * |_''_| |_| |_''_| |_'/ PARSER * -* $Id: nanohttp-mime.c,v 1.19 2006/12/16 15:55:24 m0gg Exp $ +* $Id: nanohttp-mime.c,v 1.20 2007/11/03 22:40:11 m0gg Exp $ * * CSOAP Project: A http client/server library in C * Copyright (C) 2003-2004 Ferhat Ayaz @@ -526,10 +527,10 @@ mime_streamreader_function(void *userdata, unsigned char *dest, int *size) len = http_input_stream_read(in, dest, *size); /* - log_info1("http_input_stream_read() returned 0"); */ + log_info("http_input_stream_read() returned 0"); */ if (len == -1) { - log_error4("[%d] %s():%s ", herror_code(in->err), herror_func(in->err), + log_error("[%d] %s():%s ", herror_code(in->err), herror_func(in->err), herror_message(in->err)); } @@ -551,7 +552,7 @@ _mime_parse_begin(void *data) /* Nothing to do mime_callback_data_t *cbdata = (mime_callback_data_t)data; */ - log_verbose2("Begin parse (%p)", data); + log_verbose("Begin parse (%p)", data); return; } @@ -563,7 +564,7 @@ _mime_parse_end(void *data) /* Nothing to do mime_callback_data_t *cbdata = (mime_callback_data_t)data; */ - log_verbose2("End parse (%p)", data); + log_verbose("End parse (%p)", data); return; } @@ -577,10 +578,10 @@ _mime_part_begin(void *data) mime_callback_data_t *cbdata; cbdata = (mime_callback_data_t *) data; - log_verbose2("Begin Part (%p)", data); + log_verbose("Begin Part (%p)", data); if (!(part = (struct part_t *) malloc(sizeof(struct part_t)))) { - log_error2("malloc failed (%s)", strerror(errno)); + log_error("malloc failed (%s)", strerror(errno)); return; } part->next = NULL; @@ -606,13 +607,13 @@ _mime_part_begin(void *data) cbdata, cbdata->part_id++); #endif -/* log_info2("Creating FILE ('%s') deleteOnExit=1", buffer);*/ +/* log_info("Creating FILE ('%s') deleteOnExit=1", buffer);*/ part->deleteOnExit = 1; cbdata->current_fd = fopen(buffer, "wb"); if (cbdata->current_fd) strcpy(cbdata->current_part->filename, buffer); else - log_error2("Can not open file for write '%s'", buffer); + log_error("Can not open file for write '%s'", buffer); } @@ -620,7 +621,7 @@ static void _mime_part_end(void *data) { mime_callback_data_t *cbdata = (mime_callback_data_t *) data; - log_verbose2("End Part (%p)", data); + log_verbose("End Part (%p)", data); if (cbdata->current_fd) { fclose(cbdata->current_fd); @@ -694,17 +695,17 @@ _mime_received_bytes(void *data, const unsigned char *bytes, int size) if (!cbdata) { - log_error1 + log_error ("MIME transport error Called without initializing\n"); return; } if (!cbdata->current_part) { - log_error1 + log_error ("MIME transport error Called without initializing\n"); return; } -/* log_verbose4("Received %d bytes (%p), header_search = %d", +/* log_verbose("Received %d bytes (%p), header_search = %d", size, data, cbdata->header_search); */ if (cbdata->header_search < 4) @@ -824,7 +825,7 @@ mime_message_parse(struct http_input_stream_t * in, const char *root_id, if (!(cbdata = (mime_callback_data_t *) malloc(sizeof(mime_callback_data_t)))) { - log_error2("malloc failed (%s)", strerror(errno)); + log_error("malloc failed (%s)", strerror(errno)); return NULL; } @@ -839,7 +840,7 @@ mime_message_parse(struct http_input_stream_t * in, const char *root_id, if (!(message = (struct attachments_t *) malloc(sizeof(struct attachments_t)))) { - log_error2("malloc failed (%s)", strerror(errno)); + log_error("malloc failed (%s)", strerror(errno)); free(cbdata); return NULL; } @@ -863,7 +864,7 @@ mime_message_parse(struct http_input_stream_t * in, const char *root_id, } else { - log_error2("MIME parser error '%s'!", + log_error("MIME parser error '%s'!", status == MIME_PARSER_READ_ERROR ? "read error" : "Incomplete message"); return NULL; @@ -882,7 +883,7 @@ mime_message_parse_from_file(FILE * in, const char *root_id, if (!(cbdata = (mime_callback_data_t *) malloc(sizeof(mime_callback_data_t)))) { - log_error2("malloc failed (%s)", strerror(errno)); + log_error("malloc failed (%s)", strerror(errno)); return NULL; } @@ -897,7 +898,7 @@ mime_message_parse_from_file(FILE * in, const char *root_id, if (!(message = (struct attachments_t *) malloc(sizeof(struct attachments_t)))) { - log_error2("malloc failed (%s)", strerror(errno)); + log_error("malloc failed (%s)", strerror(errno)); free(cbdata); return NULL; } @@ -924,7 +925,7 @@ mime_message_parse_from_file(FILE * in, const char *root_id, { /* TODO (#1#): Free objects */ - log_error2("MIME parser error '%s'!", + log_error("MIME parser error '%s'!", status == MIME_PARSER_READ_ERROR ? "general error" : "Incomplete message"); @@ -951,7 +952,7 @@ mime_get_attachments(content_type_t * ctype, struct http_input_stream_t * in, if (boundary == NULL) { /* TODO (#1#): Handle Error in http form */ - log_error1("'boundary' not set for multipart/related"); + log_error("'boundary' not set for multipart/related"); return herror_new("mime_get_attachments", MIME_ERROR_NO_BOUNDARY_PARAM, "'boundary' not set for multipart/related"); } @@ -959,7 +960,7 @@ mime_get_attachments(content_type_t * ctype, struct http_input_stream_t * in, if (root_id == NULL) { /* TODO (#1#): Handle Error in http form */ - log_error1("'start' not set for multipart/related"); + log_error("'start' not set for multipart/related"); return herror_new("mime_get_attachments", MIME_ERROR_NO_START_PARAM, "'start' not set for multipart/related"); } @@ -968,7 +969,7 @@ mime_get_attachments(content_type_t * ctype, struct http_input_stream_t * in, if (mimeMessage == NULL) { /* TODO (#1#): Handle Error in http form */ - log_error1("MIME Parse Error"); + log_error("MIME Parse Error"); return herror_new("mime_get_attachments", MIME_ERROR_PARSE_ERROR, "MIME Parse Error"); } diff --git a/nanohttp/nanohttp-mime.h b/nanohttp/nanohttp-mime.h index 5ec1489..592559f 100755 --- a/nanohttp/nanohttp-mime.h +++ b/nanohttp/nanohttp-mime.h @@ -3,7 +3,7 @@ * | \/ | | | | \/ | | _/ * |_''_| |_| |_''_| |_'/ PARSER * -* $Id: nanohttp-mime.h,v 1.17 2007/01/03 08:33:44 m0gg Exp $ +* $Id: nanohttp-mime.h,v 1.18 2007/11/03 22:40:11 m0gg Exp $ * * CSOAP Project: A http client/server library in C * Copyright (C) 2003-2004 Ferhat Ayaz @@ -74,39 +74,46 @@ * @subsection nanohttp_mime_server_cleanup_sec Server cleanup * * @author Ferhat Ayaz - * @version $Revision: 1.17 $ + * @version $Revision: 1.18 $ * * @see http://www.ietf.org/rfc/rfc2045.txt * @see http://www.ietf.org/rfc/rfc2046.txt * @see http://www.ietf.org/rfc/rfc4288.txt * @see http://www.ietf.org/rfc/rfc4289.txt - * */ -/** +/** @file nanohttp-mime.h MIME handling * - * MIME errors + * @defgroup NANOHTTP_MIME MIME handling + * @ingroup NANOHTTP * */ +/**@{*/ + +/** @defgroup NANOHTTP_MIME_ERRORS MIME errors + */ +/**@{*/ #define MIME_ERROR 1300 #define MIME_ERROR_NO_BOUNDARY_PARAM (MIME_ERROR + 1) #define MIME_ERROR_NO_START_PARAM (MIME_ERROR + 2) #define MIME_ERROR_PARSE_ERROR (MIME_ERROR + 3) #define MIME_ERROR_NO_ROOT_PART (MIME_ERROR + 4) #define MIME_ERROR_NOT_MIME_MESSAGE (MIME_ERROR + 5) +/**@}*/ #ifdef __cplusplus extern "C" { #endif -/* ------------------------------------------------------------------ - "multipart/related" MIME Message Builder - ------------------------------------------------------------------*/ - +/** "multipart/related" MIME Message Builder + * + */ extern herror_t mime_get_attachments(content_type_t * ctype, struct http_input_stream_t * in, struct attachments_t ** dest); #ifdef __cplusplus } #endif +/**@}*/ + #endif diff --git a/nanohttp/nanohttp-request.c b/nanohttp/nanohttp-request.c index f7bd307..7a6745d 100755 --- a/nanohttp/nanohttp-request.c +++ b/nanohttp/nanohttp-request.c @@ -1,5 +1,6 @@ +/** @file nanohttp-request.c HTTP request handling */ /****************************************************************** -* $Id: nanohttp-request.c,v 1.20 2006/12/01 10:56:00 m0gg Exp $ +* $Id: nanohttp-request.c,v 1.21 2007/11/03 22:40:11 m0gg Exp $ * * CSOAP Project: A http client/server library in C * Copyright (C) 2003 Ferhat Ayaz @@ -64,19 +65,19 @@ hrequest_new(void) if (!(req = (struct hrequest_t *) malloc(sizeof(struct hrequest_t)))) { - log_error2("malloc failed (%s)", strerror(errno)); + log_error("malloc failed (%s)", strerror(errno)); return NULL; } if (!(req->statistics = (struct request_statistics *)malloc(sizeof(struct request_statistics)))) { - log_error2("malloc failed (%s)", strerror(errno)); + log_error("malloc failed (%s)", strerror(errno)); free(req); return NULL; } if (gettimeofday(&(req->statistics->time), NULL) < 0) - log_error2("gettimeofday failed (%s)", strerror(errno)); + log_error("gettimeofday failed (%s)", strerror(errno)); req->method = HTTP_REQUEST_GET; req->version = HTTP_1_1; @@ -197,7 +198,7 @@ _hrequest_parse_header(char *data) { if (!(tmppair = (hpair_t *) malloc(sizeof(hpair_t)))) { - log_error2("malloc failed (%s)", strerror(errno)); + log_error("malloc failed (%s)", strerror(errno)); return NULL; } @@ -284,13 +285,13 @@ hrequest_new_from_socket(struct hsocket_t *sock, struct hrequest_t ** out) { if ((status = hsocket_recv(sock, &(buffer[i]), 1, 1, &readed)) != H_OK) { - log_error2("hsocket_recv failed (%s)", herror_message(status)); + log_error("hsocket_recv failed (%s)", herror_message(status)); return status; } buffer[i + 1] = '\0'; /* for strmp */ -/* log_error2("buffer=\"%s\"", buffer); */ +/* log_error("buffer=\"%s\"", buffer); */ if (i > 3) { diff --git a/nanohttp/nanohttp-request.h b/nanohttp/nanohttp-request.h index 95a89a0..90a4041 100755 --- a/nanohttp/nanohttp-request.h +++ b/nanohttp/nanohttp-request.h @@ -1,5 +1,5 @@ /****************************************************************** - * $Id: nanohttp-request.h,v 1.15 2007/01/03 08:33:44 m0gg Exp $ + * $Id: nanohttp-request.h,v 1.16 2007/11/03 22:40:11 m0gg Exp $ * * CSOAP Project: A http client/server library in C * Copyright (C) 2003-2004 Ferhat Ayaz @@ -24,15 +24,24 @@ #ifndef __nhttp_request_h #define __nhttp_request_h -/** @defgroup http_request_header_fields Request Header Fields +/** @file nanohttp-request.h HTTP request handling * - * The request-header fields allow the client to pass additional information - * about the request, and about the client itself, to the server. These fields - * act as request modifiers, with semantics equivalent to the parameters on a - * programming language method invocation. + * @defgroup NANOHTTP_REQUEST HTTP request handling + * @ingroup NANOHTTP_SERVER * - * @see http://www.ietf.org/rfc/rfc2616.txt + */ +/**@{*/ + +/** @defgroup HTTP_REQUEST_HEADER_FIELDS Request Header Fields + * @ingroup HTTP_HEADER_FIELDS * + * The request-header fields allow the client to pass additional + * information about the request, and about the client itself, to the + * server. These fields act as request modifiers, with semantics + * equivalent to the parameters on a programming language method + * invocation. + * + * @see http://www.ietf.org/rfc/rfc2616.txt */ /*@{*/ @@ -298,4 +307,6 @@ extern void hrequest_free(struct hrequest_t *req); } #endif +/**@}*/ + #endif diff --git a/nanohttp/nanohttp-response.c b/nanohttp/nanohttp-response.c index ec35c40..54c05dc 100755 --- a/nanohttp/nanohttp-response.c +++ b/nanohttp/nanohttp-response.c @@ -1,5 +1,6 @@ +/** @file nanohttp-response.c HTTP response handling */ /****************************************************************** -* $Id: nanohttp-response.c,v 1.18 2006/12/16 15:55:24 m0gg Exp $ +* $Id: nanohttp-response.c,v 1.19 2007/11/03 22:40:11 m0gg Exp $ * * CSOAP Project: A http client/server library in C * Copyright (C) 2003-2004 Ferhat Ayaz @@ -60,7 +61,7 @@ _hresponse_new(void) if (!(res = (hresponse_t *) malloc(sizeof(hresponse_t)))) { - log_error2("malloc failed (%s)", strerror(errno)); + log_error("malloc failed (%s)", strerror(errno)); return NULL; } @@ -92,7 +93,7 @@ _hresponse_parse_header(const char *buffer) s1 = s2; if (str == NULL) { - log_error1("Parse error reading HTTP spec"); + log_error("Parse error reading HTTP spec"); return NULL; } @@ -106,7 +107,7 @@ _hresponse_parse_header(const char *buffer) s1 = s2; if (str == NULL) { - log_error1("Parse error reading HTTP code"); + log_error("Parse error reading HTTP code"); return NULL; } res->errcode = atoi(str); @@ -116,7 +117,7 @@ _hresponse_parse_header(const char *buffer) s1 = s2; if (str == NULL) { - log_error1("Parse error reading HTTP description"); + log_error("Parse error reading HTTP description"); return NULL; } /* res->desc = (char *) malloc(strlen(str) + 1);*/ @@ -168,7 +169,7 @@ read_header: /* for errorcode: 100 (continue) */ { if ((status = hsocket_recv(sock, &(buffer[i]), 1, 1, &count)) != H_OK) { - log_error1("Socket read error"); + log_error("Socket read error"); return status; } @@ -187,7 +188,7 @@ read_header: /* for errorcode: 100 (continue) */ res = _hresponse_parse_header(buffer); if (res == NULL) { - log_error1("Header parse error"); + log_error("Header parse error"); return herror_new("hresponse_new_from_socket", GENERAL_HEADER_PARSE_ERROR, "Can not parse response header"); diff --git a/nanohttp/nanohttp-response.h b/nanohttp/nanohttp-response.h index ddbee78..37f7486 100755 --- a/nanohttp/nanohttp-response.h +++ b/nanohttp/nanohttp-response.h @@ -1,5 +1,5 @@ /****************************************************************** - * $Id: nanohttp-response.h,v 1.15 2007/01/03 08:33:44 m0gg Exp $ + * $Id: nanohttp-response.h,v 1.16 2007/11/03 22:40:11 m0gg Exp $ * * CSOAP Project: A http client/server library in C * Copyright (C) 2003-2004 Ferhat Ayaz @@ -24,7 +24,15 @@ #ifndef __nanohttp_response_h #define __nanohttp_response_h -/** @defgroup http_response_header_fields Response Header Fields +/** @file nanohttp-response.h HTTP response handling + * + * @defgroup NANOHTTP_RESPONSE HTTP response handling + * @ingroup NANOHTTP_RESPONSE + */ +/**@{*/ + +/** @defgroup HTTP_RESPONSE_HEADER_FIELDS Response Header Fields + * @ingroup HTTP_HEADER_FIELDS * * The response-header fields allow the server to pass additional information * about the response which cannot be placed in the Status-Line. These header @@ -32,7 +40,6 @@ * resource identified by the Request-URI. (see RFC 2616) * * @see http://www.ietf.org/rfc/rfc2616.txt - * */ /*@{*/ @@ -129,24 +136,25 @@ */ #define HEADER_VARY "Vary" -/** - * - * The WWW-Authenticate response-header field MUST be included in 401 - * (Unauthorized) response messages. The field value consists of at least one - * challenge that indicates the authentication scheme(s) and parameters - * applicable to the Request-URI. +/** The WWW-Authenticate response-header field MUST be included in 401 + * Unauthorized response messages (@ref HTTP_STATUS_401_REASON_PHRASE). + * The field value consists of at least one challenge that indicates + * the authentication scheme(s) and parameters applicable to the + * Request-URI. * - * WWW-Authenticate = "WWW-Authenticate" ":" 1#challenge + @verbatim + WWW-Authenticate = "WWW-Authenticate" ":" 1#challenge + @endverbatim * - * The HTTP access authentication process is described in "HTTP Authentication: - * Basic and Digest Access Authentication" [43]. User agents are advised to take - * special care in parsing the WWW-Authenticate field value as it might contain - * more than one challenge, or if more than one WWW-Authenticate header field is - * provided, the contents of a challenge itself can contain a comma-separated - * list of authentication parameters. + * The HTTP access authentication process is described in "HTTP + * Authentication: Basic and Digest Access Authentication". User agents + * are advised to take special care in parsing the WWW-Authenticate + * field value as it might contain more than one challenge, or if more + * than one WWW-Authenticate header field is provided, the contents of + * a challenge itself can contain a comma-separated list of + * authentication parameters. * * @see http://www.ietf.org/rfc/rfc2617.txt - * */ #define HEADER_WWW_AUTHENTICATE "WWW-Authenticate" @@ -185,4 +193,6 @@ extern void hresponse_free(hresponse_t * res); } #endif +/**@}*/ + #endif diff --git a/nanohttp/nanohttp-server.c b/nanohttp/nanohttp-server.c index e7fe6d6..fee63fc 100644 --- a/nanohttp/nanohttp-server.c +++ b/nanohttp/nanohttp-server.c @@ -1,5 +1,6 @@ +/** @file nanohttp-server.c HTTP server */ /****************************************************************** -* $Id: nanohttp-server.c,v 1.80 2007/01/01 22:54:46 m0gg Exp $ +* $Id: nanohttp-server.c,v 1.81 2007/11/03 22:40:12 m0gg Exp $ * * CSOAP Project: A http client/server library in C * Copyright (C) 2003 Ferhat Ayaz @@ -170,7 +171,7 @@ static pthread_mutex_t _httpd_connection_lock; BOOL WINAPI _httpd_term(DWORD sig) { - /* log_debug2 ("Got signal %d", sig); */ + /* log_debug ("Got signal %d", sig); */ if (sig == _httpd_terminate_signal) _httpd_run = 0; @@ -187,7 +188,7 @@ static void _httpd_sys_sleep(int secs) static void _httpd_term(int sig) { - log_debug2("Got signal %d", sig); + log_debug("Got signal %d", sig); if (sig == _httpd_terminate_signal) _httpd_run = 0; @@ -228,7 +229,7 @@ _httpd_parse_arguments(int argc, char **argv) } } - log_verbose2("socket bind to port '%d'", _httpd_port); + log_verbose("socket bind to port '%d'", _httpd_port); return; } @@ -259,7 +260,7 @@ _httpd_register_builtin_services(int argc, char **argv) if ((status = httpd_admin_init_args(argc, argv)) != H_OK) { - log_error2("httpd_admin_init_args failed (%s)", herror_message(status)); + log_error("httpd_admin_init_args failed (%s)", herror_message(status)); return status; } @@ -275,7 +276,7 @@ httpd_init(int argc, char **argv) if ((status = hsocket_module_init(argc, argv)) != H_OK) { - log_error2("hsocket_modeule_init failed (%s)", herror_message(status)); + log_error("hsocket_modeule_init failed (%s)", herror_message(status)); return status; } @@ -283,19 +284,19 @@ httpd_init(int argc, char **argv) if ((status = _httpd_register_builtin_services(argc, argv)) != H_OK) { - log_error2("_httpd_register_builtin_services failed (%s)", herror_message(status)); + log_error("_httpd_register_builtin_services failed (%s)", herror_message(status)); return status; } if ((status = hsocket_init(&_httpd_socket)) != H_OK) { - log_error2("hsocket_init failed (%s)", herror_message(status)); + log_error("hsocket_init failed (%s)", herror_message(status)); return status; } if ((status = hsocket_bind(&_httpd_socket, _httpd_port)) != H_OK) { - log_error2("hsocket_bind failed (%s)", herror_message(status)); + log_error("hsocket_bind failed (%s)", herror_message(status)); return status; } @@ -309,13 +310,13 @@ httpd_register_secure(const char *context, httpd_service func, httpd_auth auth) if (!(service = (hservice_t *) malloc(sizeof(hservice_t)))) { - log_error2("malloc failed (%s)", strerror(errno)); + log_error("malloc failed (%s)", strerror(errno)); return herror_new("httpd_register_secure", 0, "malloc failed (%s)", strerror(errno)); } if (!(service->statistics = (struct service_statistics *)malloc(sizeof(struct service_statistics)))) { - log_error2("malloc failed (%s)", strerror(errno)); + log_error("malloc failed (%s)", strerror(errno)); free(service); return herror_new("httpd_register_secure", 0, "malloc failed (%s)", strerror(errno)); } @@ -330,7 +331,7 @@ httpd_register_secure(const char *context, httpd_service func, httpd_auth auth) service->status = NHTTPD_SERVICE_UP; service->context = strdup(context); - log_verbose3("register service (%p) for \"%s\"", service, context); + log_verbose("register service (%p) for \"%s\"", service, context); if (_httpd_services_head == NULL) { _httpd_services_head = _httpd_services_tail = service; @@ -588,22 +589,22 @@ _httpd_request_print(struct hrequest_t * req) { hpair_t *pair; - log_verbose1("++++++ Request +++++++++"); - log_verbose2(" Method : '%s'", + log_verbose("++++++ Request +++++++++"); + log_verbose(" Method : '%s'", (req->method == HTTP_REQUEST_POST) ? "POST" : "GET"); - log_verbose2(" Path : '%s'", req->path); - log_verbose2(" Spec : '%s'", + log_verbose(" Path : '%s'", req->path); + log_verbose(" Spec : '%s'", (req->version == HTTP_1_0) ? "HTTP/1.0" : "HTTP/1.1"); - log_verbose1(" Parsed query string :"); + log_verbose(" Parsed query string :"); for (pair = req->query; pair; pair = pair->next) - log_verbose3(" %s = '%s'", pair->key, pair->value); + log_verbose(" %s = '%s'", pair->key, pair->value); - log_verbose1(" Parsed header :"); + log_verbose(" Parsed header :"); for (pair = req->header; pair; pair = pair->next) - log_verbose3(" %s = '%s'", pair->key, pair->value); + log_verbose(" %s = '%s'", pair->key, pair->value); - log_verbose1("++++++++++++++++++++++++"); + log_verbose("++++++++++++++++++++++++"); return; } @@ -615,7 +616,7 @@ httpd_new(struct hsocket_t * sock) if (!(conn = (httpd_conn_t *) malloc(sizeof(httpd_conn_t)))) { - log_error2("malloc failed (%s)", strerror(errno)); + log_error("malloc failed (%s)", strerror(errno)); return NULL; } conn->sock = sock; @@ -652,17 +653,17 @@ _httpd_decode_authorization(const char *value, char **user, char **pass) len = strlen(value) * 2; if (!(tmp = (char *) calloc(1, len))) { - log_error2("calloc failed (%s)", strerror(errno)); + log_error("calloc failed (%s)", strerror(errno)); return -1; } value = strstr(value, " ") + 1; - log_verbose2("Authorization (base64) = \"%s\"", value); + log_verbose("Authorization (base64) = \"%s\"", value); base64_decode_string(value, tmp); - log_verbose2("Authorization (ascii) = \"%s\"", tmp); + log_verbose("Authorization (ascii) = \"%s\"", tmp); if ((tmp2 = strstr(tmp, ":"))) { @@ -692,20 +693,20 @@ _httpd_authenticate_request(struct hrequest_t * req, httpd_auth auth) if (!(authorization = hpairnode_get_ignore_case(req->header, HEADER_AUTHORIZATION))) { - log_debug2("\"%s\" header not set", HEADER_AUTHORIZATION); + log_debug("\"%s\" header not set", HEADER_AUTHORIZATION); return 0; } if (_httpd_decode_authorization(authorization, &user, &pass)) { - log_error1("httpd_base64_decode_failed"); + log_error("httpd_base64_decode_failed"); return 0; } if ((ret = auth(req, user, pass))) - log_debug2("Access granted for user=\"%s\"", user); + log_debug("Access granted for user=\"%s\"", user); else - log_info2("Authentication failed for user=\"%s\"", user); + log_info("Authentication failed for user=\"%s\"", user); free(user); free(pass); @@ -730,18 +731,18 @@ httpd_session_main(void *data) int done; if (gettimeofday(&start, NULL) == -1) - log_error2("gettimeofday failed (%s)", strerror(errno)); + log_error("gettimeofday failed (%s)", strerror(errno)); conn = (conndata_t *) data; - log_verbose2("starting new httpd session on socket %d", conn->sock); + log_verbose("starting new httpd session on socket %d", conn->sock); rconn = httpd_new(&(conn->sock)); done = 0; while (!done) { - log_verbose3("starting HTTP request on socket %d (%p)", conn->sock, conn->sock.sock); + log_verbose("starting HTTP request on socket %d (%p)", conn->sock, conn->sock.sock); if ((status = hrequest_new_from_socket(&(conn->sock), &req)) != H_OK) { @@ -749,9 +750,9 @@ httpd_session_main(void *data) switch ((code = herror_code(status))) { - case HSOCKET_ERROR_SSLCLOSE: + case HSSL_ERROR_SSLCLOSE: case HSOCKET_ERROR_RECEIVE: - log_error2("hrequest_new_from_socket failed (%s)", herror_message(status)); + log_error("hrequest_new_from_socket failed (%s)", herror_message(status)); break; default: httpd_send_bad_request(rconn, herror_message(status)); @@ -775,7 +776,7 @@ httpd_session_main(void *data) if ((service = httpd_find_service(req->path))) { - log_verbose3("service '%s' for '%s' found", service->context, req->path); + log_verbose("service '%s' for '%s' found", service->context, req->path); if (service->status == NHTTPD_SERVICE_UP) { @@ -790,7 +791,7 @@ httpd_session_main(void *data) service->func(rconn, req); if (gettimeofday(&end, NULL) == -1) - log_error2("gettimeofday failed (%s)", strerror(errno)); + log_error("gettimeofday failed (%s)", strerror(errno)); timersub(&end, &start, &duration); pthread_rwlock_wrlock(&(service->statistics->lock)); @@ -801,7 +802,7 @@ httpd_session_main(void *data) if (rconn->out && rconn->out->type == HTTP_TRANSFER_CONNECTION_CLOSE) { - log_verbose1("Connection close requested"); + log_verbose("Connection close requested"); done = 1; } } @@ -810,7 +811,7 @@ httpd_session_main(void *data) char buffer[256]; snprintf(buffer, 256, "service '%s' is not registered properly (service function is NULL)", req->path); - log_verbose1(buffer); + log_verbose("%s", buffer); httpd_send_not_implemented(rconn, buffer); } } @@ -825,7 +826,7 @@ httpd_session_main(void *data) char buffer[256]; sprintf(buffer, "service for '%s' is disabled", req->path); - log_verbose1(buffer); + log_verbose("%s", buffer); httpd_send_internal_error(rconn, buffer); } } @@ -833,7 +834,7 @@ httpd_session_main(void *data) { char buffer[256]; sprintf(buffer, "no service for '%s' found", req->path); - log_verbose1(buffer); + log_verbose("%s", buffer); httpd_send_not_implemented(rconn, buffer); done = 1; } @@ -869,7 +870,7 @@ httpd_set_header(httpd_conn_t * conn, const char *key, const char *value) if (conn == NULL) { - log_warn1("Connection object is NULL"); + log_warn("Connection object is NULL"); return 0; } @@ -904,7 +905,7 @@ httpd_add_header(httpd_conn_t * conn, const char *key, const char *value) { if (!conn) { - log_warn1("Connection object is NULL"); + log_warn("Connection object is NULL"); return 0; } @@ -918,7 +919,7 @@ httpd_add_headers(httpd_conn_t * conn, const hpair_t * values) { if (!conn) { - log_warn1("Connection object is NULL"); + log_warn("Connection object is NULL"); return; } @@ -944,12 +945,12 @@ _httpd_register_signal_handler(void) sigaddset(&thrsigset, SIGALRM); #endif - log_verbose2("registering termination signal handler (SIGNAL:%d)", + log_verbose("registering termination signal handler (SIGNAL:%d)", _httpd_terminate_signal); #ifdef WIN32 if (SetConsoleCtrlHandler((PHANDLER_ROUTINE) _httpd_term, TRUE) == FALSE) { - log_error1("Unable to install console event handler!"); + log_error("Unable to install console event handler!"); } #else @@ -1021,7 +1022,7 @@ _httpd_start_thread(conndata_t * conn) pthread_sigmask(SIG_BLOCK, &thrsigset, NULL); if ((err = pthread_create(&(conn->tid), &(conn->attr), httpd_session_main, conn))) - log_error2("pthread_create failed (%s)", strerror(err)); + log_error("pthread_create failed (%s)", strerror(err)); #endif return; @@ -1035,13 +1036,13 @@ httpd_run(void) herror_t err; fd_set fds; - log_verbose1("starting run routine"); + log_verbose("starting run routine"); _httpd_register_signal_handler(); if ((err = hsocket_listen(&_httpd_socket)) != H_OK) { - log_error2("hsocket_listen failed (%s)", herror_message(err)); + log_error("hsocket_listen failed (%s)", herror_message(err)); return err; } @@ -1088,7 +1089,7 @@ httpd_run(void) if ((err = hsocket_accept(&_httpd_socket, &(conn->sock))) != H_OK) { - log_error2("hsocket_accept failed (%s)", herror_message(err)); + log_error("hsocket_accept failed (%s)", herror_message(err)); hsocket_close(&(conn->sock)); @@ -1139,7 +1140,7 @@ httpd_get_postdata(httpd_conn_t * conn, struct hrequest_t * req, long *received, } else { - log_warn1("Not a POST method"); + log_warn("Not a POST method"); return NULL; } @@ -1152,7 +1153,7 @@ httpd_get_postdata(httpd_conn_t * conn, struct hrequest_t * req, long *received, if (!(postdata = (char *) malloc(1))) { - log_error2("malloc failed (%s)", strerror(errno)); + log_error("malloc failed (%s)", strerror(errno)); return NULL; } postdata[0] = '\0'; @@ -1160,7 +1161,7 @@ httpd_get_postdata(httpd_conn_t * conn, struct hrequest_t * req, long *received, } if (!(postdata = (unsigned char *) malloc(content_length + 1))) { - log_error2("malloc failed (%)", strerror(errno)); + log_error("malloc failed (%)", strerror(errno)); return NULL; } if (http_input_stream_read(req->in, postdata, (int) content_length) > 0) @@ -1182,7 +1183,7 @@ static void _httpd_mime_get_boundary(httpd_conn_t * conn, char *dest) { sprintf(dest, "---=.Part_NH_%p", conn); - log_verbose2("boundary= \"%s\"", dest); + log_verbose("boundary= \"%s\"", dest); return; } diff --git a/nanohttp/nanohttp-server.h b/nanohttp/nanohttp-server.h index f9fed91..8c5fc32 100644 --- a/nanohttp/nanohttp-server.h +++ b/nanohttp/nanohttp-server.h @@ -1,5 +1,5 @@ /****************************************************************** - * $Id: nanohttp-server.h,v 1.38 2007/01/25 10:24:10 m0gg Exp $ + * $Id: nanohttp-server.h,v 1.39 2007/11/03 22:40:14 m0gg Exp $ * * CSOAP Project: A http client/server library in C * Copyright (C) 2003 Ferhat Ayaz @@ -31,11 +31,9 @@ #include #include #include -#include #endif /** - * * @page nanohttp_page nanoHTTP * * @section nanohttp_sec nanoHTTP @@ -61,7 +59,6 @@ * @author Heiko Ronsdorf * * @version 1.2 - * */ /** @page nanohttp_server_page Howto write an HTTP server @@ -80,7 +77,7 @@ * int main(int argc, char **argv) * { * herror_t status; - * hlog_set_level(HLOG_INFO); + * nanohttp_set_level(NANOHTTP_LOG_INFO); * * if (httpd_init(argc, argv)) * { @@ -189,15 +186,32 @@ * */ -/** - * - * nanoHTTP command line flags +/** @file nanohttp-server.h HTTP server interface * + * @defgroup NANOHTTP nanoHTTP */ -#define NHTTPD_ARG_PORT "-NHTTPport" -#define NHTTPD_ARG_TERMSIG "-NHTTPtsig" -#define NHTTPD_ARG_MAXCONN "-NHTTPmaxconn" -#define NHTTPD_ARG_TIMEOUT "-NHTTPtimeout" +/**@{*/ + +/** @defgroup NAONHTTP_CMDLINE_FLAGS Command line flags + */ +/**@{*/ +/** @defgroup NANOHTTP_SERVER_CMDLINE_FLAGS Server command line flags + */ +/**@{*/ +#define NHTTPD_ARG_PORT "-NHTTPport" /**< Port the server is + listening on */ +#define NHTTPD_ARG_TERMSIG "-NHTTPtsig" /**< Signal which may used + to terminate the server */ +#define NHTTPD_ARG_MAXCONN "-NHTTPmaxconn" /**< Maximum number of + simultanous connections */ +#define NHTTPD_ARG_TIMEOUT "-NHTTPtimeout" /**< Timeout on reads */ +/**@}*/ +/**@}*/ + +/** @defgroup NANOHTTP_CLIENT Client */ + +/** @defgroup NANOHTTP_SERVER Server */ +/**@{*/ typedef struct httpd_conn { @@ -208,26 +222,14 @@ typedef struct httpd_conn } httpd_conn_t; -/** - * - * Service callback function for a nanoHTTP service. - * - */ +/** Service callback function for a nanoHTTP service. */ typedef void (*httpd_service) (httpd_conn_t *conn, struct hrequest_t *req); -/** - * - * Authentication callback function for a nanoHTTP service. - * - */ +/** Authentication callback function for a nanoHTTP service. */ typedef int (*httpd_auth) (struct hrequest_t *req, const char *user, const char *pass); #ifdef __NHTTP_INTERNAL -/** - * - * Service statistics per nanoHTTP service. - * - */ +/** Service statistics per nanoHTTP service. */ struct service_statistics { unsigned long requests; @@ -238,35 +240,33 @@ struct service_statistics }; #endif +/** @defgroup NANOHTTP_SERVICE_STATUS Service status + */ +/**@{*/ + /** - * * @see hservice_t * @see http://www.w3.org/TR/wslc/ - * */ #define NHTTPD_SERVICE_DOWN 0 /** - * * @see hservice_t * @see http://www.w3.org/TR/wslc/ - * */ #define NHTTPD_SERVICE_UP 1 +/**@}*/ -/** - * - * Service representation object - * +/** Service representation object */ typedef struct tag_hservice { - char *context; - int status; - httpd_service func; - httpd_auth auth; - struct tag_hservice *next; - struct service_statistics *statistics; + char *context; /**< Path where service is connected */ + int status; /**< Current status of this service */ + httpd_service func; /**< Service function */ + httpd_auth auth; /**< Authentication function */ + struct tag_hservice *next; /**< Next service in service list */ + struct service_statistics *statistics; /**< Service statistics */ } hservice_t; @@ -275,34 +275,76 @@ extern "C" { #endif -/** - * - * Initialize the nanoHTTP server. +/** This function initializes the nanoHTTP server. * + * @see httpd_destroy() */ extern herror_t httpd_init(int argc, char *argv[]); -/** - * - * @see httpd_init +/** This function destroys the nanoHTTP server. * + * @see httpd_init() */ extern void httpd_destroy(void); - +/** This function executes the nanoHTTP server in an endless loop. + * + * @return H_OK on success. + */ extern herror_t httpd_run(void); +/** This function registers a service routine. + * + * @return H_OK on success. + */ extern herror_t httpd_register(const char *context, httpd_service service); + +/** This function registers a service routing which is secured by + * a password (HTTP basic authentication). + * + * @return H_OK on success. + */ extern herror_t httpd_register_secure(const char *context, httpd_service service, httpd_auth auth); +/** This function registers a service routing which is executed if + * no matching service is found. + * + * @return H_OK on success. + */ extern herror_t httpd_register_default(const char *context, httpd_service service); + +/** This function registers a serivce routing which is executed if + * no matching service is found, it is protected by a password. + * + * @return H_OK on success. + */ extern herror_t httpd_register_default_secure(const char *context, httpd_service service, httpd_auth auth); +/** This function returns the port the service is listening on. + * + * @return The port the service is listening on. + */ extern short httpd_get_port(void); + +/** This function returns the timeout which is used for read's. + * + * @return The read timeout used. + */ extern int httpd_get_timeout(void); + +/** This function sets the timeout which is used for read. + */ extern void httpd_set_timeout(int secs); +/** This function returns a string representation of the underlying + * protocol used. + * + * @return "http" or "https" + */ extern const char *httpd_get_protocol(void); + +/** This function returns the actual connection count. + */ extern int httpd_get_conncount(void); extern hservice_t *httpd_get_services(void); @@ -349,57 +391,54 @@ extern herror_t httpd_mime_next(httpd_conn_t * conn, const char *content_id, con */ extern herror_t httpd_mime_send_file(httpd_conn_t * conn, const char *content_id, const char *content_type, const char *transfer_encoding, const char *filename); -/** - * - * Finish MIME request - * - * @return H_OK on success or error flag +/** This function finishes a MIME request. * + * @return H_OK on success. */ extern herror_t httpd_mime_end(httpd_conn_t * conn); -/** - * - * Send a minimalistic HTML error document with HTTP status 400. +/** This function sends a minimalistic HTML error document with HTTP + * status 400. * * @see HTTP_STATUS_400_REASON_PHRASE * + * @return H_OK on success. */ extern herror_t httpd_send_bad_request(httpd_conn_t *conn, const char *msg); -/** - * - * Send a minimalistc HTML error document with HTTP status 401. +/** This function sends a minimalistc HTML error document with HTTP + * status 401. * * @see HTTP_STATUS_401_REASON_PHRASE * + * @return H_OK on success. */ extern herror_t httpd_send_unauthorized(httpd_conn_t *conn, const char *realm); -/** - * - * Send a minimalistic HTML error document with HTTP status 404. +/** This function sends a minimalistic HTML error document with HTTP + * status 404. * * @see HTTP_STATUS_404_REASON_PHRASE * + * @return H_OK on success. */ extern herror_t httpd_send_not_found(httpd_conn_t *conn, const char *msg); -/** - * - * Send a minimalistic HTML error document with HTTP status 500. +/** This function sends a minimalistic HTML error document with HTTP + * status 500. * * @see HTTP_STATUS_500_REASON_PHRASE * + * @return H_OK on success. */ extern herror_t httpd_send_internal_error(httpd_conn_t * conn, const char *msg); -/** - * - * Send a minimalistic HTML error document with HTTP status 501. +/** This functions sends a minimalistic HTML error document with HTTP + * status 501. * * @see HTTP_STATUS_501_REASON_PHRASE * + * @return H_OK on success. */ extern herror_t httpd_send_not_implemented(httpd_conn_t *conn, const char *msg); @@ -407,4 +446,6 @@ extern herror_t httpd_send_not_implemented(httpd_conn_t *conn, const char *msg); } #endif +/**@}*/ + #endif diff --git a/nanohttp/nanohttp-socket.c b/nanohttp/nanohttp-socket.c index b5279aa..693b0cb 100644 --- a/nanohttp/nanohttp-socket.c +++ b/nanohttp/nanohttp-socket.c @@ -1,5 +1,6 @@ +/** @file nanohttp-socket.c Socket wrapper */ /****************************************************************** -* $Id: nanohttp-socket.c,v 1.70 2007/01/23 23:21:47 m0gg Exp $ +* $Id: nanohttp-socket.c,v 1.71 2007/11/03 22:40:14 m0gg Exp $ * * CSOAP Project: A http client/server library in C * Copyright (C) 2003 Ferhat Ayaz @@ -179,7 +180,7 @@ _hsocket_sys_accept(struct hsocket_t * sock, struct hsocket_t * dest) if ((dest->sock = accept(sock->sock, (struct sockaddr *) &(dest->addr), &len)) == -1) { - log_warn2("accept failed (%s)", strerror(errno)); + log_warn("accept failed (%s)", strerror(errno)); return herror_new("hsocket_accept", HSOCKET_ERROR_ACCEPT, "Cannot accept network connection (%s)", strerror(errno)); } @@ -209,7 +210,7 @@ hsocket_module_init(int argc, char **argv) #ifdef HAVE_SSL if ((status = hssl_module_init(argc, argv)) != H_OK) { - log_error2("hssl_module_init failed (%s)", herror_message(status)); + log_error("hssl_module_init failed (%s)", herror_message(status)); return status; } #endif @@ -265,7 +266,7 @@ hsocket_open(struct hsocket_t * dsock, const char *hostname, int port, int ssl) address.sin_family = host->h_addrtype; address.sin_port = htons((unsigned short) port); - log_verbose4("Opening %s://%s:%i", ssl ? "https" : "http", hostname, port); + log_verbose("Opening %s://%s:%i", ssl ? "https" : "http", hostname, port); /* connect to the server */ if (connect(dsock->sock, (struct sockaddr *) &address, sizeof(address)) != 0) @@ -278,7 +279,7 @@ hsocket_open(struct hsocket_t * dsock, const char *hostname, int port, int ssl) if ((status = hssl_client_ssl(dsock)) != H_OK) { - log_error2("hssl_client_ssl failed (%s)", herror_message(status)); + log_error("hssl_client_ssl failed (%s)", herror_message(status)); return status; } #else @@ -298,7 +299,7 @@ hsocket_bind(struct hsocket_t *dsock, unsigned short port) /* create socket */ if ((sock.sock = socket(AF_INET, SOCK_STREAM, 0)) == -1) { - log_error2("Cannot create socket (%s)", strerror(errno)); + log_error("Cannot create socket (%s)", strerror(errno)); return herror_new("hsocket_bind", HSOCKET_ERROR_CREATE, "Socket error (%s)", strerror(errno)); } @@ -312,7 +313,7 @@ hsocket_bind(struct hsocket_t *dsock, unsigned short port) if (bind(sock.sock, (struct sockaddr *) &addr, sizeof(struct sockaddr)) == -1) { - log_error2("Cannot bind socket (%s)", strerror(errno)); + log_error("Cannot bind socket (%s)", strerror(errno)); return herror_new("hsocket_bind", HSOCKET_ERROR_BIND, "Socket error (%s)", strerror(errno)); } @@ -335,12 +336,12 @@ hsocket_accept(struct hsocket_t * sock, struct hsocket_t * dest) #ifdef HAVE_SSL if ((status = hssl_server_ssl(dest)) != H_OK) { - log_warn2("SSL startup failed (%s)", herror_message(status)); + log_warn("SSL startup failed (%s)", herror_message(status)); return status; } #endif - log_verbose3("accepting connection from '%s' socket=%d", + log_verbose("accepting connection from '%s' socket=%d", SAVE_STR(((char *) inet_ntoa(dest->addr.sin_addr))), dest->sock); @@ -356,7 +357,7 @@ hsocket_listen(struct hsocket_t * sock) if (listen(sock->sock, 15) == -1) { - log_error2("listen failed (%s)", strerror(errno)); + log_error("listen failed (%s)", strerror(errno)); return herror_new("hsocket_listen", HSOCKET_ERROR_LISTEN, "Cannot listen on this socket (%s)", strerror(errno)); } @@ -367,7 +368,7 @@ hsocket_listen(struct hsocket_t * sock) void hsocket_close(struct hsocket_t * sock) { - log_verbose3("closing socket %p (%d)...", sock, sock->sock); + log_verbose("closing socket %p (%d)...", sock, sock->sock); #ifdef HAVE_SSL hssl_cleanup(sock); @@ -378,7 +379,7 @@ hsocket_close(struct hsocket_t * sock) sock->bytes_received = 0; sock->bytes_transmitted = 0; - log_verbose1("socket closed"); + log_verbose("socket closed"); return; } @@ -396,14 +397,14 @@ hsocket_send(struct hsocket_t * sock, const unsigned char * bytes, int n) return herror_new("hsocket_send", HSOCKET_ERROR_NOT_INITIALIZED, "hsocket not initialized"); - /* log_verbose2( "SENDING %s", bytes ); */ + /* log_verbose( "SENDING %s", bytes ); */ while (1) { #ifdef HAVE_SSL if ((status = hssl_write(sock, bytes + total, n, &size)) != H_OK) { - log_warn2("hssl_write failed (%s)", herror_message(status)); + log_warn("hssl_write failed (%s)", herror_message(status)); return status; } #else @@ -442,7 +443,7 @@ hsocket_select_recv(int sock, char *buf, size_t len) if (select(sock + 1, &fds, NULL, NULL, &timeout) == 0) { errno = ETIMEDOUT; - log_verbose2("Socket %d timed out", sock); + log_verbose("Socket %d timed out", sock); return -1; } @@ -456,7 +457,7 @@ hsocket_recv(struct hsocket_t * sock, unsigned char * buffer, int total, int for size_t totalRead; size_t count; -/* log_verbose3("Entering hsocket_recv(total=%d,force=%d)", total, force); */ +/* log_verbose("Entering hsocket_recv(total=%d,force=%d)", total, force); */ totalRead = 0; do @@ -465,7 +466,7 @@ hsocket_recv(struct hsocket_t * sock, unsigned char * buffer, int total, int for #ifdef HAVE_SSL if ((status = hssl_read(sock, buffer + totalRead, (size_t) total - totalRead, &count)) != H_OK) { - log_warn2("hssl_read failed (%s)", herror_message(status)); + log_warn("hssl_read failed (%s)", herror_message(status)); return status; } #else @@ -476,7 +477,7 @@ hsocket_recv(struct hsocket_t * sock, unsigned char * buffer, int total, int for if (!force) { - /* log_verbose3("Leaving !force (received=%d)(status=%d)", *received, + /* log_verbose("Leaving !force (received=%d)(status=%d)", *received, status); */ *received = count; return H_OK; @@ -488,7 +489,7 @@ hsocket_recv(struct hsocket_t * sock, unsigned char * buffer, int total, int for { *received = totalRead; /* - log_verbose4("Leaving totalRead == total + log_verbose("Leaving totalRead == total (received=%d)(status=%d)(totalRead=%d)", *received, status, totalRead); */ return H_OK; diff --git a/nanohttp/nanohttp-socket.h b/nanohttp/nanohttp-socket.h index 115defe..c4f2188 100644 --- a/nanohttp/nanohttp-socket.h +++ b/nanohttp/nanohttp-socket.h @@ -1,5 +1,5 @@ /****************************************************************** - * $Id: nanohttp-socket.h,v 1.38 2006/12/11 08:13:19 m0gg Exp $ + * $Id: nanohttp-socket.h,v 1.39 2007/11/03 22:40:15 m0gg Exp $ * * CSOAP Project: A http client/server library in C * Copyright (C) 2003 Ferhat Ayaz @@ -24,16 +24,19 @@ #ifndef __nanohttp_socket_h #define __nanohttp_socket_h -/** @defgroup socket_errors Socket errors +/** @file nanohttp-socket.h Socket wrapper + * + * @defgroup NANOHTTP_SOCKET Socket wrapper + * @ingroup NANOHTTP * */ -/*@{*/ +/**@{*/ -/** - * - * Generic socket error +/** @defgroup NANOHTTP_SOCKET_ERRORS Generic socket errors + * @ingroup NANOHTTP_ERRORS * */ +/**@{*/ #define HSOCKET_ERROR 1000 #define HSOCKET_ERROR_CREATE (HSOCKET_ERROR + 1) #define HSOCKET_ERROR_GET_HOSTNAME (HSOCKET_ERROR + 2) @@ -45,23 +48,9 @@ #define HSOCKET_ERROR_ACCEPT (HSOCKET_ERROR + 8) #define HSOCKET_ERROR_NOT_INITIALIZED (HSOCKET_ERROR + 9) #define HSOCKET_ERROR_IOCTL (HSOCKET_ERROR + 10) - /*@}*/ -/** - * - * @todo move the next two items to nanohttp-ssl.h - * - */ -#define HSOCKET_ERROR_SSLCLOSE (HSOCKET_ERROR + 11) -#define HSOCKET_ERROR_SSLCTX (HSOCKET_ERROR + 11) - -/*}*/ - -/** - * - * Socket definition - * +/** Socket definition */ struct hsocket_t { @@ -81,54 +70,42 @@ extern "C" { #endif -/** - * - * Initializes the socket modul. This should be called only once for an - * application. +/** This function iitializes the socket modul. This should be called + * only once for an application. * * @return This function should always return H_OK. * + * @see hssl_module_destroy() */ extern herror_t hsocket_module_init(int argc, char **argv); - -/** - * - * Destroys the socket modul. This should be called after finishing an - * application. - * - * @see hssl_module_destroy +/** This function destroys the socket modul. This should be called + * after finishing an application. * + * @see hssl_module_init() */ extern void hsocket_module_destroy(void); -/** - * - * Initializes a given socket object. This function (or hsokcet_init_ssl) should - * be called for every socket before using it. +/** This function initializes a given socket object. This function + * (or hsokcet_init_ssl) should be called for every socket before + * using it. * * @param sock the destination socket to initialize. * * @return This function should always return H_OK. * - * @see hssl_module_init - * + * @see hssl_module_init() */ extern herror_t hsocket_init(struct hsocket_t * sock); -/** - * - * Destroys and releases a given socket. +/** This function destroys and releases a given socket. * * @param sock the socket to destroy - * */ extern void hsocket_free(struct hsocket_t * sock); -/** - * - * Connects to a given host. The hostname can be an IP number or a humen - * readable hostname. +/** This function connects to a given host. The hostname can be an IP + * number or a humen readable hostname. * * @param sock the destonation socket object to use * @param host hostname @@ -143,19 +120,14 @@ extern void hsocket_free(struct hsocket_t * sock); */ extern herror_t hsocket_open(struct hsocket_t *sock, const char *host, int port, int ssl); -/** - e - * Close a socket connection. +/** This function closes a socket connection. * * @param sock the socket to close - * */ extern void hsocket_close(struct hsocket_t *sock); -/** - * - * Binds a socket to a given port number. After bind you can call - * hsocket_listen() to listen to the port. +/** This function binds a socket to a given port number. After bind you + * can call hsocket_listen() to listen to the port. * * @param sock socket to use. * @param port port number to bind to @@ -164,29 +136,24 @@ extern void hsocket_close(struct hsocket_t *sock); * - HSOCKET_ERROR_CREATE * - HSOCKET_ERROR_BIND * - * @see hsocket_listen - * + * @see hsocket_listen() */ extern herror_t hsocket_bind(struct hsocket_t *sock, unsigned short port); -/** - * - * Set the socket to the listen mode. You must bind the socket to a port with - * hsocket_bind() before you can listen to the port. +/** This function sets the socket to the listen mode. You must bind the + * socket to a port with hsocket_bind() before you can listen to the + * port. * * @param sock the socket to use * * @return H_OK if success. One of the followings if fails:< * - HSOCKET_ERROR_NOT_INITIALIZED * - HSOCKET_ERROR_LISTEN - * */ extern herror_t hsocket_listen(struct hsocket_t *sock); -/** - * - * Accepts an incoming socket request. Note that this function - * will not return until a socket connection is ready. +/** This function accepts an incoming socket request. Note that this + * function will not return until a socket connection is ready. * * @param sock the socket which listents to a port * @param dest the destination socket which will be created @@ -197,9 +164,7 @@ extern herror_t hsocket_listen(struct hsocket_t *sock); */ extern herror_t hsocket_accept(struct hsocket_t *sock, struct hsocket_t *dest); -/** - * - * Sends data throught the socket. +/** This function sends data throught the socket. * * @param sock the socket to use to send the data * @param bytes bytes to send @@ -211,9 +176,7 @@ extern herror_t hsocket_accept(struct hsocket_t *sock, struct hsocket_t *dest); */ extern herror_t hsocket_send(struct hsocket_t *sock, const unsigned char *bytes, int size); -/** - * - * Sends a string throught the socket +/** This function sends a string throught the socket * * @param sock the socket to use to send the data * @param str the null terminated string to sent @@ -221,15 +184,12 @@ extern herror_t hsocket_send(struct hsocket_t *sock, const unsigned char *bytes, * @return H_OK on success. One of the followings if fails: * - HSOCKET_ERROR_NOT_INITIALIZED * - HSOCKET_ERROR_SEND - * */ extern herror_t hsocket_send_string(struct hsocket_t *sock, const char *str); extern int hsocket_select_recv(int sock, char *buf, size_t len); -/** - * - * Reads data from the socket. +/** This function reads data from the socket. * * @param sock the socket to read data from * @param buffer the buffer to use to save the readed bytes @@ -240,29 +200,22 @@ extern int hsocket_select_recv(int sock, char *buf, size_t len); * * @return This function will return -1 if an read error was occured. Otherwise * the return value is the size of bytes readed from the socket. - * */ extern herror_t hsocket_recv(struct hsocket_t * sock, unsigned char *buffer, int size, int force, int *len); -/** - * - * Get the socket read/write timeout. +/** This function gets the socket read/write timeout. * * @return The socket timeout in seconds. * - * @see hsocket_set_timeout - * + * @see hsocket_set_timeout() */ extern int hsocket_get_timeout(void); -/** - * - * Set the socket read/write timeout. +/** This function sets the socket read/write timeout. * * @param secs Timeout in seconds. * - * @see hsocket_get_timeout - * + * @see hsocket_get_timeout() */ extern void hsocket_set_timeout(int secs); @@ -270,4 +223,6 @@ extern void hsocket_set_timeout(int secs); } #endif +/**@}*/ + #endif diff --git a/nanohttp/nanohttp-ssl.c b/nanohttp/nanohttp-ssl.c index 4d3cb2c..8b0f9ff 100644 --- a/nanohttp/nanohttp-ssl.c +++ b/nanohttp/nanohttp-ssl.c @@ -1,5 +1,6 @@ +/** @file nanohttp-ssl.c SSL wrapper */ /****************************************************************** -* $Id: nanohttp-ssl.c,v 1.37 2006/12/11 08:13:19 m0gg Exp $ +* $Id: nanohttp-ssl.c,v 1.38 2007/11/03 22:40:15 m0gg Exp $ * * CSOAP Project: A http client/server library in C * Copyright (C) 2001-2005 Rochester Institute of Technology @@ -100,7 +101,7 @@ _hssl_dummy_verify_cert(X509 * cert) /* connect to anyone */ - log_verbose1("_Not_ validating certificate."); + log_verbose("_Not_ validating certificate."); return 1; } @@ -112,18 +113,18 @@ _hssl_cert_verify_callback(int prev_ok, X509_STORE_CTX * ctx) /* if ((X509_STORE_CTX_get_error(ctx) = X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN)) { - log_verbose1("Self signed cert in chain"); + log_verbose("Self signed cert in chain"); return 1; } */ - log_verbose2("Cert depth = %d", X509_STORE_CTX_get_error_depth(ctx)); + log_verbose("Cert depth = %d", X509_STORE_CTX_get_error_depth(ctx)); if (X509_STORE_CTX_get_error_depth(ctx) == 0) { return _hssl_verify_cert(X509_STORE_CTX_get_current_cert(ctx)); } else { - log_verbose1("Cert ok (prev)"); + log_verbose("Cert ok (prev)"); return prev_ok; } } @@ -300,7 +301,7 @@ _hssl_library_init(void) if (!initialized) { - log_verbose1("Initializing library"); + log_verbose("Initializing library"); SSL_library_init(); @@ -318,21 +319,21 @@ _hssl_library_init(void) static herror_t _hssl_server_context_init(void) { - log_verbose3("enabled=%i, certificate=%p", _hssl_enabled, _hssl_certificate); + log_verbose("enabled=%i, certificate=%p", _hssl_enabled, _hssl_certificate); if (!_hssl_enabled || !_hssl_certificate) return H_OK; if (!(_hssl_context = SSL_CTX_new(SSLv23_method()))) { - log_error1("Cannot create SSL context"); + log_error("Cannot create SSL context"); return herror_new("_hssl_server_context_init", HSSL_ERROR_CONTEXT, "Unable to create SSL context"); } if (!(SSL_CTX_use_certificate_file(_hssl_context, _hssl_certificate, SSL_FILETYPE_PEM))) { - log_error2("Cannot read certificate file: \"%s\"", _hssl_certificate); + log_error("Cannot read certificate file: \"%s\"", _hssl_certificate); SSL_CTX_free(_hssl_context); return herror_new("_hssl_server_context_init", HSSL_ERROR_CERTIFICATE, "Unable to use SSL certificate \"%s\"", _hssl_certificate); @@ -342,7 +343,7 @@ _hssl_server_context_init(void) if (!(SSL_CTX_use_PrivateKey_file(_hssl_context, _hssl_certificate, SSL_FILETYPE_PEM))) { - log_error2("Cannot read key file: \"%s\"", _hssl_certificate); + log_error("Cannot read key file: \"%s\"", _hssl_certificate); SSL_CTX_free(_hssl_context); return herror_new("_hssl_server_context_init", HSSL_ERROR_PEM, "Unable to use private key"); @@ -353,18 +354,18 @@ _hssl_server_context_init(void) if (!(SSL_CTX_load_verify_locations(_hssl_context, _hssl_ca_list, NULL))) { SSL_CTX_free(_hssl_context); - log_error2("Cannot read CA list: \"%s\"", _hssl_ca_list); + log_error("Cannot read CA list: \"%s\"", _hssl_ca_list); return herror_new("_hssl_server_context_init", HSSL_ERROR_CA_LIST, "Unable to read certification authorities \"%s\""); } SSL_CTX_set_client_CA_list(_hssl_context, SSL_load_client_CA_file(_hssl_ca_list)); - log_verbose1("Certification authority contacted"); + log_verbose("Certification authority contacted"); } SSL_CTX_set_verify(_hssl_context, SSL_VERIFY_PEER | SSL_VERIFY_CLIENT_ONCE, _hssl_cert_verify_callback); - log_verbose1("Certificate verification callback registered"); + log_verbose("Certificate verification callback registered"); SSL_CTX_set_mode(_hssl_context, SSL_MODE_AUTO_RETRY); @@ -394,11 +395,11 @@ hssl_module_init(int argc, char **argv) if (_hssl_enabled) { _hssl_library_init(); - log_verbose1("SSL enabled"); + log_verbose("SSL enabled"); } else { - log_verbose1("SSL _not_ enabled"); + log_verbose("SSL _not_ enabled"); } return _hssl_server_context_init(); @@ -443,19 +444,19 @@ hssl_client_ssl(struct hsocket_t * sock) SSL *ssl; int ret; - log_verbose1("Starting SSL client initialization"); + log_verbose("Starting SSL client initialization"); _hssl_library_init(); if (!(ctx = SSL_CTX_new(SSLv23_method()))) { - log_error2("SSL_CTX_new failed (ctx == %p)", ctx); + log_error("SSL_CTX_new failed (ctx == %p)", ctx); return herror_new("hssl_client_ssl", HSSL_ERROR_CONTEXT, "Cannot create SSL client context"); } if (!(ssl = SSL_new(ctx))) { - log_error1("Cannot create new SSL object"); + log_error("Cannot create new SSL object"); return herror_new("hssl_client_ssl", HSSL_ERROR_CLIENT, "SSL_new failed"); } @@ -465,7 +466,7 @@ hssl_client_ssl(struct hsocket_t * sock) { herror_t err; - log_error2("SSL connect error (%s)", _hssl_get_error(ssl, -1)); + log_error("SSL connect error (%s)", _hssl_get_error(ssl, -1)); err = herror_new("hssl_client_ssl", HSSL_ERROR_CONNECT, "SSL_connect failed (%s)", _hssl_get_error(ssl, ret)); @@ -474,15 +475,15 @@ hssl_client_ssl(struct hsocket_t * sock) } /* SSL_connect should take care of this for us. if - (SSL_get_peer_certificate(ssl) == NULL) { log_error1("No certificate + (SSL_get_peer_certificate(ssl) == NULL) { log_error("No certificate provided"); SSL_free(ssl); return herror_new("hssl_client_ssl", HSSL_ERROR_CERTIFICATE, "No certificate provided"); } - if (SSL_get_verify_result(ssl) != X509_V_OK) { log_error1("Certificate + if (SSL_get_verify_result(ssl) != X509_V_OK) { log_error("Certificate did not verify"); SSL_free(ssl); return herror_new("hssl_client_ssl", HSSL_ERROR_CERTIFICATE, "Verfiy certificate failed"); } */ - log_verbose1("SSL client initialization completed"); + log_verbose("SSL client initialization completed"); sock->ssl = ssl; @@ -505,11 +506,11 @@ hssl_server_ssl(struct hsocket_t *sock) if (!_hssl_enabled) return H_OK; - log_verbose2("Starting SSL initialization for socket %d", sock->sock); + log_verbose("Starting SSL initialization for socket %d", sock->sock); if (!(ssl = SSL_new(_hssl_context))) { - log_warn1("SSL_new failed"); + log_warn("SSL_new failed"); return herror_new("hssl_server_ssl", HSSL_ERROR_SERVER, "Cannot create SSL object"); } @@ -519,7 +520,7 @@ hssl_server_ssl(struct hsocket_t *sock) if (sbio == NULL) { - log_error1("BIO_new_socket failed"); + log_error("BIO_new_socket failed"); return NULL; } /* BIO_set_callback(sbio, hssl_bio_cb); */ @@ -530,7 +531,7 @@ hssl_server_ssl(struct hsocket_t *sock) { herror_t err; - log_error2("SSL_accept failed (%s)", _hssl_get_error(ssl, ret)); + log_error("SSL_accept failed (%s)", _hssl_get_error(ssl, ret)); err = herror_new("hssl_server_ssl", HSSL_ERROR_SERVER, "SSL_accept failed (%s)", _hssl_get_error(ssl, ret)); SSL_free(ssl); @@ -561,7 +562,7 @@ hssl_read(struct hsocket_t * sock, char *buf, size_t len, size_t * received) { int count; -/* log_verbose4("sock->sock=%d sock->ssl=%p, len=%li", sock->sock, sock->ssl, len); */ +/* log_verbose("sock->sock=%d sock->ssl=%p, len=%li", sock->sock, sock->ssl, len); */ if (sock->ssl) { @@ -587,7 +588,7 @@ hssl_write(struct hsocket_t * sock, const char *buf, size_t len, size_t * sent) { int count; -/* log_verbose4("sock->sock=%d, sock->ssl=%p, len=%li", sock->sock, sock->ssl, len); */ +/* log_verbose("sock->sock=%d, sock->ssl=%p, len=%li", sock->sock, sock->ssl, len); */ if (sock->ssl) { diff --git a/nanohttp/nanohttp-ssl.h b/nanohttp/nanohttp-ssl.h index e4b7058..008c23a 100644 --- a/nanohttp/nanohttp-ssl.h +++ b/nanohttp/nanohttp-ssl.h @@ -1,5 +1,5 @@ /****************************************************************** -* $Id: nanohttp-ssl.h,v 1.30 2007/01/25 10:24:10 m0gg Exp $ +* $Id: nanohttp-ssl.h,v 1.31 2007/11/03 22:40:15 m0gg Exp $ * * CSOAP Project: A http client/server library in C * Copyright (C) 2001-2005 Rochester Institute of Technology @@ -223,19 +223,25 @@ * */ -/** +/** @file nanohttp-ssl.h SSL wrapper * - * Commandline argument to enabled SSL in the nanoHTTP server. + * @defgroup NANOHTTP_SSL SSL wrapper + * @ingroup NANOHTTP * */ -#define NHTTPD_ARG_HTTPS "-NHTTPS" +/**@{*/ /** * - * @defgroup ssl_errors_group SSL Errors + * Commandline argument to enabled SSL in the nanoHTTP server. * */ -/*@{*/ +#define NHTTPD_ARG_HTTPS "-NHTTPS" + +/** @defgroup NANOHTTP_SSL_ERRORS SSL Errors + * @ingroup NANOHTTP_ERRORS + */ +/**@{*/ #define HSSL_ERROR 1700 #define HSSL_ERROR_CA_LIST (HSSL_ERROR + 10) @@ -246,92 +252,75 @@ #define HSSL_ERROR_SERVER (HSSL_ERROR + 60) #define HSSL_ERROR_CONNECT (HSSL_ERROR + 70) -/*@}*/ +#define HSSL_ERROR_SSLCLOSE (HSSL_ERROR + 80) +#define HSSL_ERROR_SSLCTX (HSSL_ERROR + 90) + +/**@}*/ #ifdef __cplusplus extern "C" { #endif -/** - * - * Initialization of the SSL module +/** This function initializes the SSL module. * * @return H_OK on success * + * @see hss_module_destroy() */ extern herror_t hssl_module_init(int argc, char **argv); -/** - * - * Shutdown of the SSL module. +/** This functions destroys the SSL module. * + * @see hssl_module_init() */ extern void hssl_module_destroy(void); -/** - * - * Sets the SSL certificate to be used. - * +/** This function sets the SSL certificate to be used. */ extern void hssl_set_certificate(const char *filename); -/** - * - * Sets the password for the SSL certificate. - * - * @see hssl_set_certificate +/** This function sets the password for the SSL certificate. * + * @see hssl_set_certificate() */ extern void hssl_set_certpass(const char *password); -/** - * - * Sets the filename for a certification authority list. - * +/** This function sets the filename for a certification authority + * list. */ extern void hssl_set_ca_list(const char *filename); -/** - * - * Enabled SSL in the nanoHTTP server. You have to call this function before - * calling httpd_run. - * - * @see httpd_run - * +/** This function enables SSL in the nanoHTTP server. You have to + * call this function before calling httpd_run(). */ extern void hssl_enable(void); -/** - * - * Check if SSL is enabled in the nanoHTTP server. - * - * @return 1 if enabled, 0 if disabled. +/** This function returns if SSL is enabled in the nanoHTTP server. * + * @return 1 if enabled, 0 otherwise. */ extern int hssl_enabled(void); -/** - * - * SSL client socket initialization. +/** This function initializes an SSL client socket. * * @return H_OK on success. * + * @see hsl_cleanup() */ extern herror_t hssl_client_ssl(struct hsocket_t * sock); -/** - * - * SSL server socket initialization. +/** This function initializes an SSL server socket. * * @return H_OK on success. * + * @see hssl_cleanup() */ extern herror_t hssl_server_ssl(struct hsocket_t * sock); -/** - * - * SSL socket cleanup. +/** This function cleans up an SSL socket. * + * @see hssl_client_ssl + * @see httl_server_ssl */ extern void hssl_cleanup(struct hsocket_t * sock); @@ -350,21 +339,15 @@ extern int verify_sn(X509 * cert, int who, int nid, char *str); */ extern void hssl_set_user_verify(int func(X509 * cert)); -/** - * - * Read from a SSL socket. - * - * @see hsocket_read +/** This function reads from an SSL socket. * + * @see hsocket_read() */ extern herror_t hssl_read(struct hsocket_t * sock, char *buf, size_t len, size_t * received); -/** - * - * Write to a SSL socket. - * - * @see hsocket_write +/** This function writes to an SSL socket. * + * @see hsocket_write() */ extern herror_t hssl_write(struct hsocket_t * sock, const char *buf, size_t len, size_t * sent); @@ -372,4 +355,6 @@ extern herror_t hssl_write(struct hsocket_t * sock, const char *buf, size_t len, } #endif +/**@}*/ + #endif diff --git a/nanohttp/nanohttp-stream.c b/nanohttp/nanohttp-stream.c index 8899c7e..64c066c 100755 --- a/nanohttp/nanohttp-stream.c +++ b/nanohttp/nanohttp-stream.c @@ -1,5 +1,6 @@ +/** @file nanohttp-stream.c Stream handling */ /****************************************************************** -* $Id: nanohttp-stream.c,v 1.19 2006/12/01 10:56:00 m0gg Exp $ +* $Id: nanohttp-stream.c,v 1.20 2007/11/03 22:40:15 m0gg Exp $ * * CSOAP Project: A http client/server library in C * Copyright (C) 2003-2004 Ferhat Ayaz @@ -88,7 +89,7 @@ http_input_stream_new(struct hsocket_t *sock, hpair_t * header) if (!(result = (struct http_input_stream_t *) malloc(sizeof(struct http_input_stream_t)))) { - log_error2("malloc failed (%s)", strerror(errno)); + log_error("malloc failed (%s)", strerror(errno)); return NULL; } @@ -100,7 +101,7 @@ http_input_stream_new(struct hsocket_t *sock, hpair_t * header) /* Check if Content-type */ if (_http_stream_is_content_length(header)) { - log_verbose1("Stream transfer with 'Content-length'"); + log_verbose("Stream transfer with 'Content-length'"); content_length = hpairnode_get_ignore_case(header, HEADER_CONTENT_LENGTH); result->content_length = atoi(content_length); result->received = 0; @@ -109,7 +110,7 @@ http_input_stream_new(struct hsocket_t *sock, hpair_t * header) /* Check if Chunked */ else if (_http_stream_is_chunked(header)) { - log_verbose1("Stream transfer with 'chunked'"); + log_verbose("Stream transfer with 'chunked'"); result->type = HTTP_TRANSFER_CHUNKED; result->chunk_size = -1; result->received = -1; @@ -117,7 +118,7 @@ http_input_stream_new(struct hsocket_t *sock, hpair_t * header) /* Assume connection close */ else { - log_verbose1("Stream transfer with 'Connection: close'"); + log_verbose("Stream transfer with 'Connection: close'"); result->type = HTTP_TRANSFER_CONNECTION_CLOSE; result->connection_closed = 0; result->received = 0; @@ -138,14 +139,14 @@ http_input_stream_new_from_file(const char *filename) if (!(fd = fopen(filename, "rb"))) { - log_error2("fopen failed (%s)", strerror(errno)); + log_error("fopen failed (%s)", strerror(errno)); return NULL; } /* Create object */ if (!(result = (struct http_input_stream_t *) malloc(sizeof(struct http_input_stream_t)))) { - log_error2("malloc failed (%s)", strerror(errno)); + log_error("malloc failed (%s)", strerror(errno)); fclose(fd); return NULL; } @@ -165,7 +166,7 @@ http_input_stream_free(struct http_input_stream_t * stream) { fclose(stream->fd); if (stream->deleteOnExit) - log_info2("Removing '%s'", stream->filename); + log_info("Removing '%s'", stream->filename); /* remove(stream->filename); */ } @@ -238,7 +239,7 @@ _http_input_stream_chunked_read_chunk_size(struct http_input_stream_t * stream) if (err != H_OK) { - log_error4("[%d] %s(): %s ", herror_code(err), herror_func(err), + log_error("[%d] %s(): %s ", herror_code(err), herror_func(err), herror_message(err)); stream->err = err; @@ -254,7 +255,7 @@ _http_input_stream_chunked_read_chunk_size(struct http_input_stream_t * stream) chunk[i] = '\0'; /* double check */ chunk_size = strtol(chunk, (char **) NULL, 16); /* hex to dec */ /* - log_verbose3("chunk_size: '%s' as dec: '%d'", chunk, chunk_size); */ + log_verbose("chunk_size: '%s' as dec: '%d'", chunk, chunk_size); */ return chunk_size; } @@ -512,7 +513,7 @@ http_output_stream_new(struct hsocket_t *sock, hpair_t * header) /* Create object */ if (!(result = (struct http_output_stream_t *) malloc(sizeof(struct http_output_stream_t)))) { - log_error2("malloc failed (%s)", strerror(errno)); + log_error("malloc failed (%s)", strerror(errno)); return NULL; } @@ -524,7 +525,7 @@ http_output_stream_new(struct hsocket_t *sock, hpair_t * header) /* Check if Content-type */ if (_http_stream_is_content_length(header)) { - log_verbose1("Stream transfer with 'Content-length'"); + log_verbose("Stream transfer with 'Content-length'"); content_length = hpairnode_get_ignore_case(header, HEADER_CONTENT_LENGTH); result->content_length = atoi(content_length); result->type = HTTP_TRANSFER_CONTENT_LENGTH; @@ -532,13 +533,13 @@ http_output_stream_new(struct hsocket_t *sock, hpair_t * header) /* Check if Chunked */ else if (_http_stream_is_chunked(header)) { - log_verbose1("Stream transfer with 'chunked'"); + log_verbose("Stream transfer with 'chunked'"); result->type = HTTP_TRANSFER_CHUNKED; } /* Assume connection close */ else { - log_verbose1("Stream transfer with 'Connection: close'"); + log_verbose("Stream transfer with 'Connection: close'"); result->type = HTTP_TRANSFER_CONNECTION_CLOSE; } diff --git a/nanohttp/nanohttp-stream.h b/nanohttp/nanohttp-stream.h index 7846df5..40d415e 100755 --- a/nanohttp/nanohttp-stream.h +++ b/nanohttp/nanohttp-stream.h @@ -1,5 +1,5 @@ /****************************************************************** - * $Id: nanohttp-stream.h,v 1.15 2006/12/11 08:35:58 m0gg Exp $ + * $Id: nanohttp-stream.h,v 1.16 2007/11/03 22:40:15 m0gg Exp $ * * CSOAP Project: A http client/server library in C * Copyright (C) 2003-2004 Ferhat Ayaz @@ -24,7 +24,7 @@ #ifndef __nanohttp_stream_h #define __nanohttp_stream_h -/** @file +/** @file nanohttp-stream.h Stream handling * * @section HTTP Stream modul * @@ -46,55 +46,36 @@ * * A stream will start sending/receiving data "after" sending/receiving header * information. (After )" - * */ +/**{@*/ -/** @defgroup stream_errors_group Stream errors - * +/** @defgroup NANOHTTP_STREAM_ERRORS Stream errors + * @ingroup NANOHTTP_ERRORS */ /*@{*/ - -/** - * - * Generic stream error. - * - */ #define STREAM_ERROR 1200 #define STREAM_ERROR_INVALID_TYPE (STREAM_ERROR + 1) #define STREAM_ERROR_SOCKET_ERROR (STREAM_ERROR + 2) #define STREAM_ERROR_NO_CHUNK_SIZE (STREAM_ERROR + 3) #define STREAM_ERROR_WRONG_CHUNK_SIZE (STREAM_ERROR + 4) - /*@}*/ -/** - * - * Transfer types supported while - * sending/receiving data. - * - */ +/** Transfer types supported while sending/receiving data. */ typedef enum http_transfer_type { - /** The stream cares about Content-length */ - HTTP_TRANSFER_CONTENT_LENGTH, - - /** The stream sends/receives chunked data */ - HTTP_TRANSFER_CHUNKED, - - /** The stream sends/receives data until connection is closed */ - HTTP_TRANSFER_CONNECTION_CLOSE, - - /** This transfer style will be used by MIME support and for debug purposes.*/ - HTTP_TRANSFER_FILE + HTTP_TRANSFER_CONTENT_LENGTH, /**< The stream cares about + Content-length */ + HTTP_TRANSFER_CHUNKED, /**< The stream sends/receives + chunked data */ + HTTP_TRANSFER_CONNECTION_CLOSE, /**< The stream sends/receives + data until connection is closed */ + HTTP_TRANSFER_FILE /**< This transfer style will be used + by MIME support and for debug + purposes. */ } http_transfer_type_t; - -/** - * - * HTTP INPUT STREAM. Receives data from a socket/file - * and cares about the transfer style. - * - */ +/** HTTP INPUT STREAM. Receives data from a socket/file and cares + * about the transfer style. */ struct http_input_stream_t { struct hsocket_t *sock; @@ -111,12 +92,8 @@ struct http_input_stream_t int deleteOnExit; /* default is 0 */ }; -/** - * - * HTTP OUTPUT STREAM. Sends data to a socket - * and cares about the transfer style. - * - */ +/** HTTP OUTPUT STREAM. Sends data to a socket and cares about the + * transfer style. */ struct http_output_stream_t { struct hsocket_t *sock; @@ -125,15 +102,12 @@ struct http_output_stream_t int sent; }; - #ifdef __cplusplus extern "C" { #endif -/** - * - * Creates a new input stream. The transfer style will be choosen from the given - * header. +/** This function creates a new input stream. The transfer style will + * be choosen from the given header. * * @param sock the socket to receive data from * @param header the http header. This must be received before creating a @@ -143,38 +117,31 @@ extern "C" { * found in the header, HTTP_TRANSFER_CONNECTION_CLOSE will be used as * default. * - * @see http_input_stream_free - * + * @see http_input_stream_free() */ extern struct http_input_stream_t *http_input_stream_new(struct hsocket_t *sock, hpair_t *header); -/** - * - * Creates a new input stream from file. This function was added for MIME - * messages and for debugging. The transfer style is always HTTP_TRANSFER_FILE. +/** This function creates a new input stream from file. It was added + * for MIME messages and for debugging purposes. The transfer style + * is always HTTP_TRANSFER_FILE. * * @param filename the name of the file to open and read. * - * @return The return value is a http_input_stream_t object if the file exists - * and could be opened. NULL otherwise. - * - * @see http_input_stream_free + * @return The return value is a http_input_stream_t object if the file + * exists and could be opened. NULL otherwise. * + * @see http_input_stream_free() */ extern struct http_input_stream_t *http_input_stream_new_from_file(const char *filename); -/** - * - * Free input stream. Note that the socket will not be closed by this functions. +/** Free input stream. Note that the socket will not be closed by this + * functions. * * @param stream the input stream to free. - * */ extern void http_input_stream_free(struct http_input_stream_t * stream); -/** - * - * Returns the actual status of the stream. +/** This function returns the actual status of the stream. * * @param stream the stream to check its status * @@ -183,15 +150,13 @@ extern void http_input_stream_free(struct http_input_stream_t * stream); */ extern int http_input_stream_is_ready(struct http_input_stream_t * stream); -/** - * - * Tries to read 'size' bytes from the stream. Check always with - * http_input_stream_is_ready() if there are some data to read. If it returns 0, - * no more data is available on stream. +/** This function tries to read 'size' bytes from the stream. Check + * always with http_input_stream_is_ready() if there are some data to + * read. If it returns 0, no more data is available on stream. * - * On error this function will return -1. In this case the "err" field of stream - * will be set to the actual error. This can be one of the followings: - * + * On error this function will return -1. In this case the "err" field + * of stream will be set to the actual error. This can be one of the + * followings: * - STREAM_ERROR_NO_CHUNK_SIZE * - STREAM_ERROR_WRONG_CHUNK_SIZE * - STREAM_ERROR_INVALID_TYPE @@ -202,55 +167,44 @@ extern int http_input_stream_is_ready(struct http_input_stream_t * stream); * @param size maximum size of 'dest' (size to read) * * @return the actual read bytes or -1 on error. - * */ extern int http_input_stream_read(struct http_input_stream_t * stream, unsigned char *dest, int size); -/** - * - * Creates a new output stream. Transfer style will be found from the given - * header. +/** Creates a new output stream. Transfer style will be found from the + * given header. * * @param sock the socket to to send data to * @param header the header which must be sent before * - * @return a http_output_stream_t object. If no proper transfer style was found - * in the header, HTTP_TRANSFER_CONNECTION_CLOSE will be used as default. - * - * @see http_output_stream_free + * @return A http_output_stream_t object. If no proper transfer style + * was found in the header, HTTP_TRANSFER_CONNECTION_CLOSE will + * be used as default. * + * @see http_output_stream_free() */ extern struct http_output_stream_t *http_output_stream_new(struct hsocket_t *sock, hpair_t * header); -/** - * - * Free output stream. Note that this functions will not close any socket - * connections. - * - * @param stream the stream to free. +/** This function frees the given output stream. Note that this + * function will not close any socket connections. * + * @param stream The stream to free. */ -extern void http_output_stream_free(struct http_output_stream_t * stream); +extern void http_output_stream_free(struct http_output_stream_t *stream); -/** - * - * Writes 'size' bytes of 'bytes' into stream. +/** This function writes 'size' bytes of 'bytes' into stream. * * @param stream the stream to use to send data * @param bytes bytes to send * @param size size of bytes to send * - * @return H_OK on success. One of the followings otherwise + * @return H_OK on success. One of the followings otherwise: * - HSOCKET_ERROR_NOT_INITIALIZED * - HSOCKET_ERROR_SEND - * */ -extern herror_t http_output_stream_write(struct http_output_stream_t *stream, const unsigned char* bytes, int size); +extern herror_t http_output_stream_write(struct http_output_stream_t *stream, const unsigned char *bytes, int size); -/** - * - * Writes a null terminated string to the stream. +/** This function writes a null terminated string to the stream. * * @param stream the stream to use to send data * @param str a null terminated string to send @@ -258,21 +212,17 @@ extern herror_t http_output_stream_write(struct http_output_stream_t *stream, co * @return H_OK on success. One of the followings otherwise * - HSOCKET_ERROR_NOT_INITIALIZED * - HSOCKET_ERROR_SEND - * */ extern herror_t http_output_stream_write_string(struct http_output_stream_t *stream, const char *str); -/** - * - * Sends finish flags if nesseccary (like in chunked transport). - * Call always this function before closing the connections. +/** This function sends finish flags if nesseccary (like in chunked + * transport). Call always this function before closing the connections. * * @param stream the stream to send post data. * * @return H_OK on success. One of the followings otherwise * - HSOCKET_ERROR_NOT_INITIALIZED * - HSOCKET_ERROR_SEND - * */ extern herror_t http_output_stream_flush(struct http_output_stream_t *stream); @@ -280,4 +230,6 @@ extern herror_t http_output_stream_flush(struct http_output_stream_t *stream); } #endif +/**@}*/ + #endif diff --git a/nanohttp/nanohttp-url.c b/nanohttp/nanohttp-url.c index 316fd27..8ba1619 100644 --- a/nanohttp/nanohttp-url.c +++ b/nanohttp/nanohttp-url.c @@ -1,5 +1,6 @@ +/** @file nanohttp-url.c URL parsing functions */ /****************************************************************** -* $Id: nanohttp-url.c,v 1.3 2006/12/16 16:09:45 m0gg Exp $ +* $Id: nanohttp-url.c,v 1.4 2007/11/03 22:40:15 m0gg Exp $ * * CSOAP Project: A http client/server library in C * Copyright (C) 2003 Ferhat Ayaz @@ -61,14 +62,14 @@ _hurl_dump(const struct hurl_t *url) { if (!url) { - log_error1("parameter url is NULL"); + log_error("parameter url is NULL"); return; } - log_verbose2("PROTOCOL: %d", url->protocol); - log_verbose2(" HOST: \"%s\"", url->host); - log_verbose2(" PORT: %d", url->port); - log_verbose2(" CONTEXT: \"%s\"", url->context); + log_verbose("PROTOCOL: %d", url->protocol); + log_verbose(" HOST: \"%s\"", url->host); + log_verbose(" PORT: %d", url->port); + log_verbose(" CONTEXT: \"%s\"", url->context); return; } @@ -96,18 +97,18 @@ hurl_parse(struct hurl_t *url, const char *urlstr) if (iprotocol == 0) { - log_error1("no protocol"); + log_error("no protocol"); return herror_new("hurl_parse", URL_ERROR_NO_PROTOCOL, "No protocol"); } if (iprotocol + 3 >= len) { - log_error1("no host"); + log_error("no host"); return herror_new("hurl_parse", URL_ERROR_NO_HOST, "No host"); } if (urlstr[iprotocol] != ':' && urlstr[iprotocol + 1] != '/' && urlstr[iprotocol + 2] != '/') { - log_error1("no protocol"); + log_error("no protocol"); return herror_new("hurl_parse", URL_ERROR_NO_PROTOCOL, "No protocol"); } @@ -121,7 +122,7 @@ hurl_parse(struct hurl_t *url, const char *urlstr) if (ihost == iprotocol + 1) { - log_error1("no host"); + log_error("no host"); return herror_new("hurl_parse", URL_ERROR_NO_HOST, "No host"); } @@ -151,7 +152,7 @@ hurl_parse(struct hurl_t *url, const char *urlstr) /* find right port */ if (!(entry = getservbyname(protocol, "tcp"))) { - log_warn2("getservbyname(\"%s\", \"tcp\") returned NULL, please edit services database", protocol); + log_warn("getservbyname(\"%s\", \"tcp\") returned NULL, please edit services database", protocol); switch (url->protocol) { @@ -171,7 +172,7 @@ hurl_parse(struct hurl_t *url, const char *urlstr) size = ihost - iprotocol - 3; if (!(url->host = (char *)malloc(size + 1))) { - log_error2("malloc failed (%s)", strerror(errno)); + log_error("malloc failed (%s)", strerror(errno)); return herror_new("hurl_parse", URL_ERROR, "malloc failed (%s)", strerror(errno)); } strncpy(url->host, &urlstr[iprotocol + 3], size); @@ -191,7 +192,7 @@ hurl_parse(struct hurl_t *url, const char *urlstr) size = len - iport; if (!(url->context = (char *)malloc(size + 1))) { - log_error2("malloc failed (%s)", strerror(errno)); + log_error("malloc failed (%s)", strerror(errno)); return herror_new("hurl_parse", URL_ERROR, "malloc failed (%s)", strerror(errno)); } strncpy(url->context, &urlstr[iport], size); diff --git a/nanohttp/nanohttp-url.h b/nanohttp/nanohttp-url.h index 6e72749..8b07fa7 100644 --- a/nanohttp/nanohttp-url.h +++ b/nanohttp/nanohttp-url.h @@ -1,5 +1,5 @@ /****************************************************************** - * $Id: nanohttp-url.h,v 1.3 2006/12/11 08:13:19 m0gg Exp $ + * $Id: nanohttp-url.h,v 1.4 2007/11/03 22:40:15 m0gg Exp $ * * CSOAP Project: A http client/server library in C * Copyright (C) 2003-2004 Ferhat Ayaz @@ -24,23 +24,27 @@ #ifndef __nanohttp_url_h #define __nanohttp_url_h -/** +/** @file nanohttp-url.h URL handling * - * URL errors + * @defgroup NANOHTTP_URL URL handling + * @ingroup NANOHTTP * */ +/*@{*/ + +/** URL errors + */ +/**@{*/ #define URL_ERROR 1100 #define URL_ERROR_UNKNOWN_PROTOCOL (URL_ERROR + 1) #define URL_ERROR_NO_PROTOCOL (URL_ERROR + 2) #define URL_ERROR_NO_HOST (URL_ERROR + 3) +/**@}*/ -/** - * - * The protocol types in enumeration format. Used in some other nanohttp objects - * like hurl_t. +/** The protocol types in enumeration format. Used in some other + * nanohttp objects like hurl_t. * * @see hurl_t - * */ typedef enum _hprotocol { @@ -48,58 +52,39 @@ typedef enum _hprotocol PROTOCOL_HTTPS } hprotocol_t; -/** +/** The URL object. A representation of an URL like: * - * The URL object. A representation of an URL like: - * - * [protocol]://[user]@[host]:[port]/[context]['#' fragment]['?' query] + @verbatim + [protocol]://[user]@[host]:[port]/[context]['#' fragment]['?' query] + @endverbatim * * @see http://www.ietf.org/rfc/rfc2396.txt - * */ struct hurl_t { - /** - * - * The transfer protocol. Note that only PROTOCOL_HTTP and PROTOCOL_HTTPS are - * supported by nanohttp. - * - */ - hprotocol_t protocol; - - /** - * - * The port number. If no port number was given in the URL, one of the default - * port numbers will be selected: - * - HTTP_DEFAULT_PORT - * - HTTPS_DEFAULT_PORT - * - */ - unsigned short port; - - /** - * - * The hostname - * - */ - char *host; - - /** - * - * The string after the hostname. - * - */ - char *context; + hprotocol_t protocol; /**< The transfer protocol. Note that only + - PROTOCOL_HTTP and + - PROTOCOL_HTTPS + are supported by nanohttp. */ + unsigned short port; /**< The port number. If no port number was given + in the URL, one of the default port numbers + will be selected: + - HTTP_DEFAULT_PORT + - HTTPS_DEFAULT_PORT */ + char *host; /**< The hostname */ + char *context; /** The string after the hostname. */ }; #ifdef __cplusplus extern "C" { #endif -/** +/** This function parses the given 'urlstr' and fills the given hurl_t + * object. Parse an URI * - * Parses the given 'urlstr' and fills the given hurl_t object. - * Parse an URI URI-reference = [ absoluteURI | relativeURI ] [ "#" fragment ] + @verbatim + URI-reference = [ absoluteURI | relativeURI ] [ "#" fragment ] + @endverbatim * * @param obj the destination URL object to fill * @param url the URL in string format @@ -108,16 +93,12 @@ extern "C" { * - URL_ERROR_UNKNOWN_PROTOCOL * - URL_ERROR_NO_PROTOCOL * - URL_ERROR_NO_HOST - * */ extern herror_t hurl_parse(struct hurl_t * obj, const char *url); -/** - * - * Frees the resources within a url and the url itself. +/** This function frees the resources within a url and the url itself. * * @param url pointer to an hurl_t - * */ extern void hurl_free(struct hurl_t *url); @@ -125,4 +106,6 @@ extern void hurl_free(struct hurl_t *url); } #endif +/**@}*/ + #endif diff --git a/wsdl2c/Makefile.in b/wsdl2c/Makefile.in index f578d17..1a15ccf 100644 --- a/wsdl2c/Makefile.in +++ b/wsdl2c/Makefile.in @@ -15,7 +15,7 @@ @SET_MAKE@ # -# $Revision: 1.1 $ +# $Revision: 1.2 $ # srcdir = @srcdir@ -- cgit v1.1-32-gdbae