summaryrefslogtreecommitdiffstats
path: root/nanohttp
diff options
context:
space:
mode:
authorGravatar m0gg2007-11-03 22:40:09 +0000
committerGravatar m0gg2007-11-03 22:40:09 +0000
commit8a6946b18003fae6400a137389f0cb13d0ac4bd6 (patch)
tree1fb0e6f58de5596f8dae00998da18472fb4952a1 /nanohttp
parentc1a7b2dabdc691139b744f0d4750f3b797b69073 (diff)
downloadcsoap-8a6946b18003fae6400a137389f0cb13d0ac4bd6.tar.gz
csoap-8a6946b18003fae6400a137389f0cb13d0ac4bd6.tar.bz2
Split nanoHTTP and cSOAP logging
Diffstat (limited to 'nanohttp')
-rw-r--r--nanohttp/Makefile.am34
-rw-r--r--nanohttp/Makefile.in142
-rw-r--r--nanohttp/nanohttp-admin.c124
-rw-r--r--nanohttp/nanohttp-admin.h100
-rw-r--r--nanohttp/nanohttp-base64.c5
-rw-r--r--nanohttp/nanohttp-base64.h44
-rw-r--r--nanohttp/nanohttp-client.c45
-rw-r--r--nanohttp/nanohttp-client.h13
-rw-r--r--nanohttp/nanohttp-common.c23
-rw-r--r--nanohttp/nanohttp-common.h366
-rw-r--r--nanohttp/nanohttp-error.c11
-rw-r--r--nanohttp/nanohttp-error.h39
-rw-r--r--nanohttp/nanohttp-logging.c209
-rw-r--r--nanohttp/nanohttp-logging.h162
-rwxr-xr-xnanohttp/nanohttp-mime.c45
-rwxr-xr-xnanohttp/nanohttp-mime.h25
-rwxr-xr-xnanohttp/nanohttp-request.c15
-rwxr-xr-xnanohttp/nanohttp-request.h25
-rwxr-xr-xnanohttp/nanohttp-response.c15
-rwxr-xr-xnanohttp/nanohttp-response.h44
-rw-r--r--nanohttp/nanohttp-server.c107
-rw-r--r--nanohttp/nanohttp-server.h177
-rw-r--r--nanohttp/nanohttp-socket.c39
-rw-r--r--nanohttp/nanohttp-socket.h127
-rw-r--r--nanohttp/nanohttp-ssl.c57
-rw-r--r--nanohttp/nanohttp-ssl.h99
-rwxr-xr-xnanohttp/nanohttp-stream.c29
-rwxr-xr-xnanohttp/nanohttp-stream.h158
-rw-r--r--nanohttp/nanohttp-url.c27
-rw-r--r--nanohttp/nanohttp-url.h87
30 files changed, 1146 insertions, 1247 deletions
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 <config.h>
#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)
"<span class=\"logo\">nhttpd</span> ");
http_output_stream_write_string(conn->out, title);
http_output_stream_write_string(conn->out, "<hr />");
-
- return;
}
static inline void
_httpd_admin_send_footer(httpd_conn_t *conn)
{
http_output_stream_write_string(conn->out,
+ "<hr />"
+ "<a href=\"" NHTTPD_ADMIN_CONTEXT "\">Admin page</a> "
+ "<a href=\"http://csoap.sf.net/\">cSOAP Home</a>"
"</body>"
"</html>");
-
- return;
}
static void
@@ -125,8 +127,6 @@ _httpd_admin_list_services(httpd_conn_t *conn)
http_output_stream_write_string(conn->out, "</ul>");
_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 <b>%s</b>", 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,
"<p>"
@@ -154,7 +156,7 @@ _httpd_admin_list_statistics(httpd_conn_t *conn, const char *service_name)
"<li>Bytes read: %lu</li>"
"<li>Bytes sent: %lu</li>"
"<li>Time used: %li.%li sec</li>"
- "<ul>",
+ "</ul>",
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)
"</p>");
_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"
"</p>");
_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, "<p>Switching from %s to %s</p>", 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,
"<ul>"
@@ -264,12 +342,19 @@ _httpd_admin_handle_get(httpd_conn_t * conn, struct hrequest_t *req)
"<li>"
"<a href=\"?" NHTTPD_ADMIN_QUERY_STATISTICS "\">Statistics</a>"
"</li>"
+ "<li>Set loglevel: "
+ "<a href=\"?" NHTTPD_ADMIN_QUERY_SET_LOGLEVEL "=" NANOHTTP_LOG_LEVEL_OFF_STRING "\">OFF</a> "
+ "<a href=\"?" NHTTPD_ADMIN_QUERY_SET_LOGLEVEL "=" NANOHTTP_LOG_LEVEL_VERBOSE_STRING "\">VERBOSE</a> "
+ "<a href=\"?" NHTTPD_ADMIN_QUERY_SET_LOGLEVEL "=" NANOHTTP_LOG_LEVEL_DEBUG_STRING "\">DEBUG</a> "
+ "<a href=\"?" NHTTPD_ADMIN_QUERY_SET_LOGLEVEL "=" NANOHTTP_LOG_LEVEL_INFO_STRING "\">INFO</a> "
+ "<a href=\"?" NHTTPD_ADMIN_QUERY_SET_LOGLEVEL "=" NANOHTTP_LOG_LEVEL_WARN_STRING "\">WARN</a> "
+ "<a href=\"?" NHTTPD_ADMIN_QUERY_SET_LOGLEVEL "=" NANOHTTP_LOG_LEVEL_ERROR_STRING "\">ERROR</a> "
+ "<a href=\"?" NHTTPD_ADMIN_QUERY_SET_LOGLEVEL "=" NANOHTTP_LOG_LEVEL_FATAL_STRING "\">FATAL</a> "
+ "</li>"
"</ul>");
_httpd_admin_send_footer(conn);
}
-
- return;
}
static void
@@ -289,11 +374,10 @@ _httpd_admin_entry(httpd_conn_t * conn, struct hrequest_t *req)
"<body>"
"<h1>Sorry!</h1>"
"<hr />"
- "<div>POST Service is not implemented now. Use your browser.</div>"
+ "<div>Only GET method is implemented now. Use your browser.</div>"
"</body>"
"</html>");
}
- 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 <nanohttp/nanohttp-stream.h>
#include <nanohttp/nanohttp-request.h>
#include <nanohttp/nanohttp-response.h>
-#include <nanohttp/nanohttp-logging.h>
#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 <config.h>
#endif
+#ifdef HAVE_CTYPE_H
+#include <ctype.h>
+#endif
+
#ifdef HAVE_STDIO_H
#include <stdio.h>
#endif
@@ -41,169 +45,130 @@
#include <string.h>
#endif
-#ifdef HAVE_CTYPE_H
-#include <ctype.h>
-#endif
-
-#ifdef HAVE_PTHREAD_H
-#include <pthread.h>
+#ifdef HAVE_SYSLOG_H
+#include <syslog.h>
#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 <received bytes> without initializing\n");
return;
}
if (!cbdata->current_part)
{
- log_error1
+ log_error
("MIME transport error Called <received bytes> 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 <nanohttp/nanohttp-stream.h>
#include <nanohttp/nanohttp-request.h>
#include <nanohttp/nanohttp-response.h>
-#include <nanohttp/nanohttp-logging.h>
#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 <CF><CF>)"
- *
*/
+/**{@*/
-/** @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