summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar m0gg2006-11-27 12:47:27 +0000
committerGravatar m0gg2006-11-27 12:47:27 +0000
commit17d9b98c8525c74cd83a421f151062825fe66890 (patch)
tree615dc9207798af270a8a0d957e427cc59a29166c
parent504da9682a1e739b41cfdbb25721f518c83ebf83 (diff)
downloadcsoap-17d9b98c8525c74cd83a421f151062825fe66890.tar.gz
csoap-17d9b98c8525c74cd83a421f151062825fe66890.tar.bz2
Code cleanup
-rw-r--r--TODO26
-rwxr-xr-xconfigure45
-rw-r--r--configure.ac19
-rw-r--r--libcsoap/soap-addressing.h5
-rw-r--r--nanohttp/Makefile.am16
-rw-r--r--nanohttp/nanohttp-server.c9
-rw-r--r--nanohttp/nanohttp-socket.c52
-rw-r--r--nanohttp/nanohttp-ssl.c45
-rw-r--r--nanohttp/nanohttp-ssl.h65
9 files changed, 145 insertions, 137 deletions
diff --git a/TODO b/TODO
index 152d4f0..86305a1 100644
--- a/TODO
+++ b/TODO
@@ -1,13 +1,15 @@
-remove most of the typedefs!
-
-------------------------------------------------------------
-improve error handling!!!!
-
-
-mime_message_t *
-mime_message_parse(http_input_stream_t *in,
- const char* root_id, const char* boundary,
- const char* dest_dir);
-
-and try to optimize mime API
+$Id: TODO,v 1.4 2006/11/27 12:47:27 m0gg Exp $
+-------------------------------------------------------------------------------
+
+- Get rid of #ifdef HAVE_SSL in nanohttp-socket.c
+- remove most of the typedefs!
+- cleanup circular module dependencies (e.g. hsocket <-> hssl)
+- include neccessary headers in *-client.h *-server.h if __*_INTERNAL isn't
+ specified
+- improve error handling!!!!
+- optimize mime API
+- cleanup/improve nanohttp request parsing
+- XML encryption/signature verification
+- Check portability to Win32/Linux/MaxOS (only tested on FreeBSD 6.2)
+- API documentation
diff --git a/configure b/configure
index f8fd081..916cba0 100755
--- a/configure
+++ b/configure
@@ -464,7 +464,7 @@ ac_includes_default="\
# include <unistd.h>
#endif"
-ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE build build_cpu build_vendor build_os host host_cpu host_vendor host_os EGREP LN_S ECHO AR ac_ct_AR RANLIB ac_ct_RANLIB CPP CXX CXXFLAGS ac_ct_CXX CXXDEPMODE am__fastdepCXX_TRUE am__fastdepCXX_FALSE CXXCPP F77 FFLAGS ac_ct_F77 LIBTOOL csoap_major csoap_minor csoap_patch csoap_release csoap_version nanohttp_release nanohttp_version LIBOBJS LIBUUID acx_pthread_config PTHREAD_CC PTHREAD_LIBS PTHREAD_CFLAGS LIBSOCKET LIBNSL XML2_CONFIG XML_CPPFLAGS XML_LIBS BUILD_WITH_XMLSEC1_TRUE BUILD_WITH_XMLSEC1_FALSE XMLSEC1_CONFIG XMLSEC1_CFLAGS XMLSEC1_LIBS LTLIBOBJS'
+ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE build build_cpu build_vendor build_os host host_cpu host_vendor host_os EGREP LN_S ECHO AR ac_ct_AR RANLIB ac_ct_RANLIB CPP CXX CXXFLAGS ac_ct_CXX CXXDEPMODE am__fastdepCXX_TRUE am__fastdepCXX_FALSE CXXCPP F77 FFLAGS ac_ct_F77 LIBTOOL csoap_major csoap_minor csoap_patch csoap_release csoap_version nanohttp_release nanohttp_version LIBOBJS LIBUUID acx_pthread_config PTHREAD_CC PTHREAD_LIBS PTHREAD_CFLAGS LIBSOCKET LIBNSL XML2_CONFIG XML_CPPFLAGS XML_LIBS BUILD_WITH_SSL_TRUE BUILD_WITH_SSL_FALSE BUILD_WITH_XMLSEC1_TRUE BUILD_WITH_XMLSEC1_FALSE XMLSEC1_CONFIG XMLSEC1_CFLAGS XMLSEC1_LIBS LTLIBOBJS'
ac_subst_files=''
# Initialize some variables set by options.
@@ -21696,7 +21696,9 @@ fi
if test "x$no_xml" = x ; then
echo "$as_me:$LINENO: result: yes (version $xml_config_major_version.$xml_config_minor_version.$xml_config_micro_version)" >&5
echo "${ECHO_T}yes (version $xml_config_major_version.$xml_config_minor_version.$xml_config_micro_version)" >&6
- CFLAGS="$CFLAGS $XML_CPPFLAGS"; LDFLAGS="$LDFLAGS $XML_LIBS"
+ CFLAGS="$CFLAGS $XML_CPPFLAGS";
+ LDFLAGS="$LDFLAGS $XML_LIBS"
+
else
echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6
@@ -21780,6 +21782,7 @@ rm -f conftest.err conftest.$ac_objext \
XML_CPPFLAGS=""
XML_LIBS=""
exit 1
+
fi
@@ -21829,6 +21832,17 @@ cat >>confdefs.h <<\_ACEOF
#define HAVE_SSL 1
_ACEOF
+
+
+if true; then
+ BUILD_WITH_SSL_TRUE=
+ BUILD_WITH_SSL_FALSE='#'
+else
+ BUILD_WITH_SSL_TRUE='#'
+ BUILD_WITH_SSL_FALSE=
+fi
+
+
fi
else
@@ -21836,6 +21850,17 @@ else
echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6
+
+if false; then
+ BUILD_WITH_SSL_TRUE=
+ BUILD_WITH_SSL_FALSE='#'
+else
+ BUILD_WITH_SSL_TRUE='#'
+ BUILD_WITH_SSL_FALSE=
+fi
+
+
+
fi;
@@ -22265,6 +22290,20 @@ echo "$as_me: error: conditional \"am__fastdepCXX\" was never defined.
Usually this means the macro was only invoked conditionally." >&2;}
{ (exit 1); exit 1; }; }
fi
+if test -z "${BUILD_WITH_SSL_TRUE}" && test -z "${BUILD_WITH_SSL_FALSE}"; then
+ { { echo "$as_me:$LINENO: error: conditional \"BUILD_WITH_SSL\" was never defined.
+Usually this means the macro was only invoked conditionally." >&5
+echo "$as_me: error: conditional \"BUILD_WITH_SSL\" was never defined.
+Usually this means the macro was only invoked conditionally." >&2;}
+ { (exit 1); exit 1; }; }
+fi
+if test -z "${BUILD_WITH_SSL_TRUE}" && test -z "${BUILD_WITH_SSL_FALSE}"; then
+ { { echo "$as_me:$LINENO: error: conditional \"BUILD_WITH_SSL\" was never defined.
+Usually this means the macro was only invoked conditionally." >&5
+echo "$as_me: error: conditional \"BUILD_WITH_SSL\" was never defined.
+Usually this means the macro was only invoked conditionally." >&2;}
+ { (exit 1); exit 1; }; }
+fi
if test -z "${BUILD_WITH_XMLSEC1_TRUE}" && test -z "${BUILD_WITH_XMLSEC1_FALSE}"; then
{ { echo "$as_me:$LINENO: error: conditional \"BUILD_WITH_XMLSEC1\" was never defined.
Usually this means the macro was only invoked conditionally." >&5
@@ -22901,6 +22940,8 @@ s,@LIBNSL@,$LIBNSL,;t t
s,@XML2_CONFIG@,$XML2_CONFIG,;t t
s,@XML_CPPFLAGS@,$XML_CPPFLAGS,;t t
s,@XML_LIBS@,$XML_LIBS,;t t
+s,@BUILD_WITH_SSL_TRUE@,$BUILD_WITH_SSL_TRUE,;t t
+s,@BUILD_WITH_SSL_FALSE@,$BUILD_WITH_SSL_FALSE,;t t
s,@BUILD_WITH_XMLSEC1_TRUE@,$BUILD_WITH_XMLSEC1_TRUE,;t t
s,@BUILD_WITH_XMLSEC1_FALSE@,$BUILD_WITH_XMLSEC1_FALSE,;t t
s,@XMLSEC1_CONFIG@,$XMLSEC1_CONFIG,;t t
diff --git a/configure.ac b/configure.ac
index be4e69d..d52370c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -330,13 +330,18 @@ AC_CHECK_LIB(nsl, inet_ntoa, [LIBNSL="-lnsl"])
AC_CHECK_LIB(nsl, gethostbyname, [LIBNSL="-lnsl"])
AC_SUBST(LIBNSL)
-AM_PATH_XML2(2.6.0,CFLAGS="$CFLAGS $XML_CPPFLAGS"; LDFLAGS="$LDFLAGS $XML_LIBS",exit 1)
+AM_PATH_XML2(2.6.0,
+ CFLAGS="$CFLAGS $XML_CPPFLAGS";
+ LDFLAGS="$LDFLAGS $XML_LIBS"
+,
+ exit 1
+)
# ------------------------------------------
# Check ssl library
# Original work at: http://autoconf-archive.cryp.to/check_ssl.html
# ------------------------------------------
-AC_DEFUN([CHECK_SSL],
+AC_DEFUN([AM_PATH_SSL],
[AC_MSG_CHECKING(if ssl is wanted)
AC_ARG_WITH(ssl,
[ --with-ssl=PFX will check PFX for ssl library
@@ -364,15 +369,21 @@ AC_ARG_WITH(ssl,
printf "OpenSSL found in $ssldir\n";
LIBS="$LIBS -lssl -lcrypto";
LDFLAGS="$LDFLAGS -L$ssldir/lib";
- AC_DEFINE(HAVE_SSL,1,Define to 1 if you have requested --with-ssl)
+ ifelse([$2], , :, [$2])
fi
],
[
AC_MSG_RESULT(no)
+ ifelse([$3], , :, [$3])
])
])dnl
-CHECK_SSL
+AM_PATH_SSL(,
+ AC_DEFINE(HAVE_SSL,1,Define to 1 if you have requested --with-ssl)
+ AM_CONDITIONAL(BUILD_WITH_SSL, true)
+,
+ AM_CONDITIONAL(BUILD_WITH_SSL, false)
+)
#---------------------------------------------
# Check xmlsec1 library
diff --git a/libcsoap/soap-addressing.h b/libcsoap/soap-addressing.h
index e6ac288..7b6aed1 100644
--- a/libcsoap/soap-addressing.h
+++ b/libcsoap/soap-addressing.h
@@ -1,5 +1,5 @@
/******************************************************************
- * $Id: soap-addressing.h,v 1.6 2006/11/27 11:15:27 m0gg Exp $
+ * $Id: soap-addressing.h,v 1.7 2006/11/27 12:47:27 m0gg Exp $
*
* CSOAP Project: A SOAP client/server library in C
* Copyright (C) 2006 Heiko Ronsdorf
@@ -37,7 +37,7 @@
* in a transport-neutral manner.
*
* @author H. Ronsdorf
- * @version $Revision: 1.6 $
+ * @version $Revision: 1.7 $
*
* @see http://www.w3.org/TR/ws-addr-core/,
* http://www.w3.org/TR/REC-xml-names/
@@ -217,6 +217,7 @@ xmlNodePtr soap_addressing_set_metadata(xmlNodePtr endpoint_reference, xmlNodePt
xmlURI *soap_addressing_get_message_id(struct SoapEnv *envelope);
xmlChar *soap_addressing_get_message_id_string(struct SoapEnv *envelope);
xmlNodePtr soap_addressing_set_message_id(struct SoapEnv *envelope, xmlURI *id);
+xmlNodePtr soap_addressing_set_message_id_string(struct SoapEnv *envelope, xmlChar *id);
xmlNodePtr soap_addressing_get_relates_to(struct SoapEnv *envelope);
xmlNodePtr soap_addressing_add_relates_to(struct SoapEnv *envelope, xmlURI *id, xmlURI *type);
diff --git a/nanohttp/Makefile.am b/nanohttp/Makefile.am
index e960f50..dae7909 100644
--- a/nanohttp/Makefile.am
+++ b/nanohttp/Makefile.am
@@ -3,16 +3,20 @@ 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-ssl.c nanohttp-logging.c \
- nanohttp-admin.c nanohttp-error.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_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-base64.h nanohttp-ssl.h nanohttp-logging.h \
- nanohttp-admin.h nanohttp-error.h
+ nanohttp-base64.h nanohttp-logging.h nanohttp-admin.h \
+ nanohttp-error.h
+
+if BUILD_WITH_SSL
+libnanohttp_la_SOURCES+=nanohttp-ssl.c
+libnanohttp_la_HEADERS+=nanohttp-ssl.h
+endif
libnanohttp_la_LDFLAGS= -version-info @nanohttp_version@ -release @nanohttp_release@
libnanohttp_la_CFLAGS=-I${top_srcdir} -D__NHTTP_INTERNAL=1
diff --git a/nanohttp/nanohttp-server.c b/nanohttp/nanohttp-server.c
index b0e650d..8c16e5f 100644
--- a/nanohttp/nanohttp-server.c
+++ b/nanohttp/nanohttp-server.c
@@ -1,5 +1,5 @@
/******************************************************************
-* $Id: nanohttp-server.c,v 1.69 2006/11/26 20:13:06 m0gg Exp $
+* $Id: nanohttp-server.c,v 1.70 2006/11/27 12:47:27 m0gg Exp $
*
* CSOAP Project: A http client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -86,7 +86,14 @@
#include "nanohttp-response.h"
#include "nanohttp-server.h"
#include "nanohttp-base64.h"
+#ifdef HAVE_SSL
+#ifdef HAVE_OPENSSL_SSL_H
+#include <openssl/ssl.h>
+#endif
#include "nanohttp-ssl.h"
+#else
+static inline int hssl_enabled(void) { return 0; }
+#endif
#include "nanohttp-admin.h"
typedef struct _conndata
diff --git a/nanohttp/nanohttp-socket.c b/nanohttp/nanohttp-socket.c
index 3fd600b..4869cd7 100644
--- a/nanohttp/nanohttp-socket.c
+++ b/nanohttp/nanohttp-socket.c
@@ -1,5 +1,5 @@
/******************************************************************
-* $Id: nanohttp-socket.c,v 1.65 2006/11/26 20:13:06 m0gg Exp $
+* $Id: nanohttp-socket.c,v 1.66 2006/11/27 12:47:27 m0gg Exp $
*
* CSOAP Project: A http client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -84,7 +84,12 @@ typedef int ssize_t;
#include "nanohttp-common.h"
#include "nanohttp-socket.h"
+#ifdef HAVE_SSL
+#ifdef HAVE_OPENSSL_SSL_H
+#include <openssl/ssl.h>
+#endif
#include "nanohttp-ssl.h"
+#endif
#include "nanohttp-request.h"
#include "nanohttp-server.h"
@@ -121,9 +126,21 @@ _hsocket_module_sys_destroy(void)
herror_t
hsocket_module_init(int argc, char **argv)
{
+#ifdef HAVE_SSL
+ herror_t status;
+#endif
+
_hsocket_module_sys_init(argc, argv);
- return hssl_module_init(argc, argv);
+#ifdef HAVE_SSL
+ if ((status = hssl_module_init(argc, argv)) != H_OK)
+ {
+ log_error2("hssl_module_init failed (%s)", herror_message(status));
+ return status;
+ }
+#endif
+
+ return H_OK;
}
void
@@ -177,13 +194,12 @@ hsocket_open(struct hsocket_t * dsock, const char *hostname, int port, int ssl)
log_verbose4("Opening %s://%s:%i", ssl ? "https" : "http", hostname, port);
/* connect to the server */
- if (connect(dsock->sock, (struct sockaddr *) &address, sizeof(address)) !=
- 0)
- return herror_new("hsocket_open", HSOCKET_ERROR_CONNECT,
- "Socket error (%s)", strerror(errno));
+ if (connect(dsock->sock, (struct sockaddr *) &address, sizeof(address)) != 0)
+ return herror_new("hsocket_open", HSOCKET_ERROR_CONNECT, "Socket error (%s)", strerror(errno));
if (ssl)
{
+#ifdef HAVE_SSL
herror_t status;
if ((status = hssl_client_ssl(dsock)) != H_OK)
@@ -191,8 +207,10 @@ hsocket_open(struct hsocket_t * dsock, const char *hostname, int port, int ssl)
log_error2("hssl_client_ssl failed (%s)", herror_message(status));
return status;
}
+#else
+ return herror_new("hssl_client_ssl", 0, "SSL wasn't enabled at compile time");
+#endif
}
-
return H_OK;
}
@@ -287,11 +305,13 @@ hsocket_accept(struct hsocket_t * sock, struct hsocket_t * dest)
if ((status = _hsocket_sys_accept(sock, dest)) != H_OK)
return status;
+#ifdef HAVE_SSL
if ((status = hssl_server_ssl(dest)) != H_OK)
{
log_warn2("SSL startup failed (%s)", herror_message(status));
return status;
}
+#endif
log_verbose3("accepting connection from '%s' socket=%d",
SAVE_STR(((char *) inet_ntoa(dest->addr.sin_addr))),
@@ -350,7 +370,9 @@ hsocket_close(struct hsocket_t * sock)
{
log_verbose3("closing socket %p (%d)...", sock, sock->sock);
+#ifdef HAVE_SSL
hssl_cleanup(sock);
+#endif
_hsocket_sys_close(sock);
@@ -365,7 +387,9 @@ hsocket_close(struct hsocket_t * sock)
herror_t
hsocket_nsend(struct hsocket_t * sock, const unsigned char * bytes, int n)
{
+#ifdef HAVE_SSL
herror_t status;
+#endif
size_t total = 0;
size_t size;
@@ -378,11 +402,17 @@ hsocket_nsend(struct hsocket_t * sock, const unsigned char * bytes, int n)
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));
return status;
}
+#else
+ if ((size = send(sock->sock, bytes + total, n, 0)) == -1)
+ return herror_new("hsocket_nsend", HSOCKET_ERROR_SEND, "send failed (%s)", strerror(errno));
+#endif
+ sock->bytes_received += size;
n -= size;
total += size;
@@ -434,11 +464,17 @@ hsocket_read(struct hsocket_t * sock, unsigned char * buffer, int total, int for
do
{
- if ((status = hssl_read(sock, &buffer[totalRead], (size_t) total - totalRead, &count)) != H_OK)
+#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));
return status;
}
+#else
+ if ((count = hsocket_select_recv(sock->sock, buffer + totalRead, (size_t) total - totalRead)) == -1)
+ return herror_new("hsocket_read", HSOCKET_ERROR_RECEIVE, "recv failed (%s)", strerror(errno));
+#endif
+ sock->bytes_received += count;
if (!force)
{
diff --git a/nanohttp/nanohttp-ssl.c b/nanohttp/nanohttp-ssl.c
index 1a98ed5..8b8fb5d 100644
--- a/nanohttp/nanohttp-ssl.c
+++ b/nanohttp/nanohttp-ssl.c
@@ -1,5 +1,5 @@
/******************************************************************
-* $Id: nanohttp-ssl.c,v 1.32 2006/11/26 20:13:06 m0gg Exp $
+* $Id: nanohttp-ssl.c,v 1.33 2006/11/27 12:47:27 m0gg Exp $
*
* CSOAP Project: A http client/server library in C
* Copyright (C) 2001-2005 Rochester Institute of Technology
@@ -65,7 +65,10 @@
#include <io.h>
#endif
-#ifdef HAVE_SSL
+#ifdef HAVE_OPENSSL_SSL_H
+#include <openssl/ssl.h>
+#endif
+
#ifdef HAVE_OPENSSL_RAND_H
#include <openssl/rand.h>
#endif
@@ -73,7 +76,6 @@
#ifdef HAVE_OPENSSL_ERR_H
#include <openssl/err.h>
#endif
-#endif
#include "nanohttp-error.h"
#include "nanohttp-common.h"
@@ -82,8 +84,6 @@
#include "nanohttp-ssl.h"
-#ifdef HAVE_SSL
-
static char *certificate = NULL;
static char *certpass = "";
static char *ca_list = NULL;
@@ -540,7 +540,6 @@ hssl_read(struct hsocket_t * sock, char *buf, size_t len, size_t * received)
return herror_new("hssl_read", HSOCKET_ERROR_RECEIVE,
"recv failed (%s)", strerror(errno));
}
- sock->bytes_received += count;
*received = count;
return H_OK;
@@ -567,41 +566,7 @@ hssl_write(struct hsocket_t * sock, const char *buf, size_t len, size_t * sent)
return herror_new("hssl_write", HSOCKET_ERROR_SEND, "send failed (%s)",
strerror(errno));
}
- sock->bytes_transmitted += count;
- *sent = count;
-
- return H_OK;
-}
-
-#else
-
-herror_t
-hssl_read(struct hsocket_t * sock, char *buf, size_t len, size_t * received)
-{
- int count;
-
- if ((count = hsocket_select_recv(sock->sock, buf, len)) == -1)
- return herror_new("hssl_read", HSOCKET_ERROR_RECEIVE, "recv failed (%s)",
- strerror(errno));
- sock->bytes_received += count;
- *received = count;
-
- return H_OK;
-}
-
-
-herror_t
-hssl_write(struct hsocket_t * sock, const char *buf, size_t len, size_t * sent)
-{
- int count;
-
- if ((count = send(sock->sock, buf, len, 0)) == -1)
- return herror_new("hssl_write", HSOCKET_ERROR_SEND, "send failed (%s)",
- strerror(errno));
- sock->bytes_received += count;
*sent = count;
return H_OK;
}
-
-#endif
diff --git a/nanohttp/nanohttp-ssl.h b/nanohttp/nanohttp-ssl.h
index 1b23be8..6df53e7 100644
--- a/nanohttp/nanohttp-ssl.h
+++ b/nanohttp/nanohttp-ssl.h
@@ -1,5 +1,5 @@
/******************************************************************
-* $Id: nanohttp-ssl.h,v 1.21 2006/11/24 17:28:07 m0gg Exp $
+* $Id: nanohttp-ssl.h,v 1.22 2006/11/27 12:47:27 m0gg Exp $
*
* CSOAP Project: A http client/server library in C
* Copyright (C) 2001-2005 Rochester Institute of Technology
@@ -24,16 +24,6 @@
#ifndef __nanohttp_ssl_h
#define __nanohttp_ssl_h
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#ifdef HAVE_SSL
-
-#ifdef HAVE_OPENSSL_SSL_H
-#include <openssl/ssl.h>
-#endif
-
/**
*
* Commandline argument to enabled SSL in the nanoHTTP server.
@@ -42,8 +32,7 @@
#define NHTTPD_ARG_HTTPS "-NHTTPS"
#ifdef __cplusplus
-extern "C"
-{
+extern "C" {
#endif
/**
@@ -127,56 +116,8 @@ extern int verify_sn(X509 * cert, int who, int nid, char *str);
*/
extern void hssl_set_user_verify(int func(X509 * cert));
-#ifdef __cplusplus
-}
-#endif
-
-#else /* HAVE_SSL */
-
-static inline herror_t
-hssl_module_init(int argc, char **argv)
-{
- return H_OK;
-}
-
-static inline void
-hssl_module_destroy(void)
-{
- return;
-}
-
-static inline int
-hssl_enabled(void)
-{
- return 0;
-}
-
-static inline herror_t
-hssl_client_ssl(struct hsocket_t *sock)
-{
- return H_OK;
-}
-
-static inline herror_t
-hssl_server_ssl(struct hsocket_t *sock)
-{
- return H_OK;
-}
-
-static inline void
-hssl_cleanup(struct hsocket_t *sock)
-{
- return;
-}
-
-#endif /* HAVE_SSL */
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
extern herror_t hssl_read(struct hsocket_t * sock, char *buf, size_t len, size_t * received);
+
extern herror_t hssl_write(struct hsocket_t * sock, const char *buf, size_t len, size_t * sent);
#ifdef __cplusplus