summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--configure.ac2
-rw-r--r--examples/csoap/soapclient.c7
-rw-r--r--libcsoap/soap-client.c20
-rw-r--r--libcsoap/soap-server.c96
-rw-r--r--libcsoap/soap-server.h3
-rw-r--r--libcsoap/soap-xml.c4
-rw-r--r--nanohttp/nanohttp-client.c37
-rw-r--r--nanohttp/nanohttp-client.h8
-rw-r--r--nanohttp/nanohttp-common.c6
-rw-r--r--nanohttp/nanohttp-server.c57
-rw-r--r--nanohttp/nanohttp-server.h7
-rw-r--r--nanohttp/nanohttp-socket.c4
-rw-r--r--nanohttp/nanohttp-ssl.c15
13 files changed, 164 insertions, 102 deletions
diff --git a/configure.ac b/configure.ac
index c291cf8..2f9cdae 100644
--- a/configure.ac
+++ b/configure.ac
@@ -104,7 +104,7 @@ AC_C_CONST
AC_HEADER_TIME
AC_STRUCT_TM
- Checks for library functions.
+dnl Checks for library functions.
#AC_FUNC_MALLOC
AC_FUNC_VPRINTF
AC_CHECK_FUNCS([gethostbyname socket])
diff --git a/examples/csoap/soapclient.c b/examples/csoap/soapclient.c
index 7f96364..d40faf8 100644
--- a/examples/csoap/soapclient.c
+++ b/examples/csoap/soapclient.c
@@ -5,6 +5,7 @@
#include <stdio.h>
#include <string.h>
+#include <ctype.h>
#include <libcsoap/soap-client.h>
#define MAX_LINE_LENGTH 65535
@@ -200,7 +201,7 @@ main(int argc, char *argv[])
// create buffer
char Buffer[MAX_LINE_LENGTH];
- int bytes_read, bytes_left;
+ long bytes_read, bytes_left;
// read from stdin until EOF
while (!feof(stdin))
@@ -209,7 +210,7 @@ main(int argc, char *argv[])
// pass each line into ParseLine
char *EndLinePos;
- while (EndLinePos = strchr(Buffer, '\n'))
+ while ((EndLinePos = strchr(Buffer, '\n')))
{
ParseLine(ctx, Buffer, EndLinePos - Buffer);
memmove(Buffer, EndLinePos + 1, bytes_read - (EndLinePos - Buffer + 1));
@@ -217,7 +218,7 @@ main(int argc, char *argv[])
}
// no '\n' found in the whole Buffer, that means line's too
- long bytes_left = strlen(Buffer);
+ bytes_left = strlen(Buffer);
if (bytes_left == MAX_LINE_LENGTH)
{
log_error1("The parameter line is too long.");
diff --git a/libcsoap/soap-client.c b/libcsoap/soap-client.c
index f7c38c2..55fa6ca 100644
--- a/libcsoap/soap-client.c
+++ b/libcsoap/soap-client.c
@@ -1,5 +1,5 @@
/******************************************************************
-* $Id: soap-client.c,v 1.21 2006/01/10 11:29:04 snowdrop Exp $
+* $Id: soap-client.c,v 1.22 2006/02/08 11:13:14 snowdrop Exp $
*
* CSOAP Project: A SOAP client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -42,8 +42,6 @@ soap_client_get_blockmode()
return _block_socket;
}
-
-
herror_t
soap_client_init_args(int argc, char *argv[])
{
@@ -58,22 +56,6 @@ soap_client_destroy()
httpc_destroy();
}
-static long
-_file_get_size(const char *filename)
-{
- FILE *f = fopen(filename, "r");
- long size;
-
- if (!f)
- return -1;
-
- fseek(f, 0, SEEK_END);
- size = ftell(f);
- fclose(f);
- return size;
-}
-
-
herror_t
soap_client_invoke(SoapCtx * call, SoapCtx ** response, const char *url,
const char *soap_action)
diff --git a/libcsoap/soap-server.c b/libcsoap/soap-server.c
index 4f55bf5..af1d808 100644
--- a/libcsoap/soap-server.c
+++ b/libcsoap/soap-server.c
@@ -1,5 +1,5 @@
/******************************************************************
-* $Id: soap-server.c,v 1.15 2006/01/27 20:23:40 mrcsys Exp $
+* $Id: soap-server.c,v 1.16 2006/02/08 11:13:14 snowdrop Exp $
*
* CSOAP Project: A SOAP client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -37,15 +37,9 @@ typedef struct _SoapRouterNode
SoapRouterNode *head = NULL;
SoapRouterNode *tail = NULL;
-static
- SoapRouterNode *router_node_new(SoapRouter * router,
- const char *context, SoapRouterNode * next);
-
-static SoapRouter *router_find(const char *context);
-
+/*---------------------------------*/
static void _soap_server_send_ctx(httpd_conn_t * conn, SoapCtx * ctxres);
-/*---------------------------------*/
void soap_server_entry(httpd_conn_t * conn, hrequest_t * req);
static void _soap_server_send_env(http_output_stream_t * out, SoapEnv * env);
static
@@ -53,6 +47,46 @@ static
const char *errmsg);
/*---------------------------------*/
+static SoapRouterNode *
+router_node_new(SoapRouter * router,
+ const char *context, SoapRouterNode * next)
+{
+ SoapRouterNode *node;
+ const char *noname = "/lost_found";
+
+ node = (SoapRouterNode *) malloc(sizeof(SoapRouterNode));
+ if (context)
+ {
+ node->context = (char *) malloc(strlen(context) + 1);
+ strcpy(node->context, context);
+ }
+ else
+ {
+ log_warn2("context is null. Using '%s'", noname);
+ node->context = (char *) malloc(strlen(noname) + 1);
+ strcpy(node->context, noname);
+ }
+
+ node->router = router;
+ node->next = next;
+
+ return node;
+}
+
+static SoapRouter *
+router_find(const char *context)
+{
+ SoapRouterNode *node = head;
+
+ while (node != NULL)
+ {
+ if (!strcmp(node->context, context))
+ return node->router;
+ node = node->next;
+ }
+
+ return NULL;
+}
herror_t
soap_server_init_args(int argc, char *argv[])
@@ -90,6 +124,11 @@ soap_server_run()
return httpd_run();
}
+int
+soap_server_get_port(void)
+{
+ return httpd_get_port();
+}
void
soap_server_destroy()
@@ -390,44 +429,3 @@ _soap_server_send_fault(httpd_conn_t * conn, hpair_t * header,
-static SoapRouterNode *
-router_node_new(SoapRouter * router,
- const char *context, SoapRouterNode * next)
-{
- SoapRouterNode *node;
- const char *noname = "/lost_found";
-
- node = (SoapRouterNode *) malloc(sizeof(SoapRouterNode));
- if (context)
- {
- node->context = (char *) malloc(strlen(context) + 1);
- strcpy(node->context, context);
- }
- else
- {
- log_warn2("context is null. Using '%s'", noname);
- node->context = (char *) malloc(strlen(noname) + 1);
- strcpy(node->context, noname);
- }
-
- node->router = router;
- node->next = next;
-
- return node;
-}
-
-
-static SoapRouter *
-router_find(const char *context)
-{
- SoapRouterNode *node = head;
-
- while (node != NULL)
- {
- if (!strcmp(node->context, context))
- return node->router;
- node = node->next;
- }
-
- return NULL;
-}
diff --git a/libcsoap/soap-server.h b/libcsoap/soap-server.h
index 9306f1a..4e2db62 100644
--- a/libcsoap/soap-server.h
+++ b/libcsoap/soap-server.h
@@ -1,5 +1,5 @@
/******************************************************************
- * $Id: soap-server.h,v 1.7 2006/01/10 11:29:04 snowdrop Exp $
+ * $Id: soap-server.h,v 1.8 2006/02/08 11:13:14 snowdrop Exp $
*
* CSOAP Project: A SOAP client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -70,6 +70,7 @@ int soap_server_register_router(SoapRouter * router, const char *context);
*/
herror_t soap_server_run();
+int soap_server_get_port(void);
/**
Frees the soap server.
diff --git a/libcsoap/soap-xml.c b/libcsoap/soap-xml.c
index 7b6ba87..62b0b7d 100644
--- a/libcsoap/soap-xml.c
+++ b/libcsoap/soap-xml.c
@@ -1,5 +1,5 @@
/******************************************************************
-* $Id: soap-xml.c,v 1.8 2006/01/10 11:29:04 snowdrop Exp $
+* $Id: soap-xml.c,v 1.9 2006/02/08 11:13:14 snowdrop Exp $
*
* CSOAP Project: A SOAP client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -23,8 +23,6 @@
******************************************************************/
#include <libcsoap/soap-xml.h>
-static const char *soap_env_ns = "http://schemas.xmlsoap.org/soap/envelope/";
-
xmlNodePtr
soap_xml_get_children(xmlNodePtr param)
{
diff --git a/nanohttp/nanohttp-client.c b/nanohttp/nanohttp-client.c
index bf01fbe..44ba815 100644
--- a/nanohttp/nanohttp-client.c
+++ b/nanohttp/nanohttp-client.c
@@ -1,5 +1,5 @@
/******************************************************************
-* $Id: nanohttp-client.c,v 1.36 2006/01/25 19:18:42 mrcsys Exp $
+* $Id: nanohttp-client.c,v 1.37 2006/02/08 11:13:14 snowdrop Exp $
*
* CSOAP Project: A http client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -145,7 +145,35 @@ httpc_close_free(httpc_conn_t * conn)
httpc_free(conn);
}
+int
+httpc_add_header(httpc_conn_t *conn, const char *key, const char *value)
+{
+ if (!conn)
+ {
+ log_warn1("Connection object is NULL");
+ return -1;
+ }
+
+ conn->header = hpairnode_new(key, value, conn->header);
+
+ return 0;
+}
+void
+httpc_add_headers(httpc_conn_t *conn, const hpair_t *values)
+{
+ if (conn == NULL)
+ {
+ log_warn1("Connection object is NULL");
+ return;
+ }
+
+ for(;values; values=values->next)
+ httpc_add_header(conn, values->key, values->value);
+
+ return;
+}
+
/*--------------------------------------------------
FUNCTION: httpc_set_header
DESC: Adds a new (key, value) pair to the header
@@ -153,7 +181,7 @@ or modifies the old pair if this function will
finds another pair with the same 'key' value.
----------------------------------------------------*/
int
-httpc_set_header(httpc_conn_t * conn, const char *key, const char *value)
+httpc_set_header(httpc_conn_t *conn, const char *key, const char *value)
{
hpair_t *p;
@@ -182,12 +210,11 @@ httpc_set_header(httpc_conn_t * conn, const char *key, const char *value)
return 0;
}
-
/*--------------------------------------------------
FUNCTION: httpc_header_add_date
DESC: Adds the current date to the header.
----------------------------------------------------*/
-static void
+/* static void
_httpc_set_error(httpc_conn_t * conn, int errcode, const char *format, ...)
{
va_list ap;
@@ -197,7 +224,7 @@ _httpc_set_error(httpc_conn_t * conn, int errcode, const char *format, ...)
va_start(ap, format);
vsprintf(conn->errmsg, format, ap);
va_end(ap);
-}
+} */
/*--------------------------------------------------
FUNCTION: httpc_header_add_date
diff --git a/nanohttp/nanohttp-client.h b/nanohttp/nanohttp-client.h
index 2b93617..03e1e16 100644
--- a/nanohttp/nanohttp-client.h
+++ b/nanohttp/nanohttp-client.h
@@ -1,5 +1,5 @@
/******************************************************************
- * $Id: nanohttp-client.h,v 1.18 2006/01/10 11:29:05 snowdrop Exp $
+ * $Id: nanohttp-client.h,v 1.19 2006/02/08 11:13:14 snowdrop Exp $
*
* CSOAP Project: A http client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -88,11 +88,13 @@ void httpc_close_free(httpc_conn_t * conn);
*/
int httpc_set_header(httpc_conn_t * conn, const char *key, const char *value);
+int httpc_add_header(httpc_conn_t *conn, const char *key, const char *value);
+void httpc_add_headers(httpc_conn_t *conn, const hpair_t *values);
+
/**
Invoke a "GET" method request and receive the response
*/
-herror_t
-httpc_get(httpc_conn_t * conn, hresponse_t ** out, const char *urlstr);
+herror_t httpc_get(httpc_conn_t * conn, hresponse_t ** out, const char *urlstr);
/**
Start a "POST" method request
diff --git a/nanohttp/nanohttp-common.c b/nanohttp/nanohttp-common.c
index 062c66c..adead8c 100644
--- a/nanohttp/nanohttp-common.c
+++ b/nanohttp/nanohttp-common.c
@@ -1,5 +1,5 @@
/******************************************************************
-* $Id: nanohttp-common.c,v 1.24 2006/01/18 16:28:24 mrcsys Exp $
+* $Id: nanohttp-common.c,v 1.25 2006/02/08 11:13:14 snowdrop Exp $
*
* CSOAP Project: A http client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -31,6 +31,8 @@
#include <string.h>
#include <ctype.h>
+#include <pthread.h>
+
#ifdef MEM_DEBUG
#include <utils/alloc.h>
#endif
@@ -283,7 +285,7 @@ log_write(log_level_t level, const char *prefix,
#ifdef WIN32
sprintf(buffer, "*%s*: [%s] %s\n", prefix, func, format);
#else
- sprintf(buffer, "*%s*:(%d) [%s] %s\n",
+ sprintf(buffer, "*%s*:(%ld) [%s] %s\n",
prefix, pthread_self(), func, format);
#endif
vsprintf(buffer2, buffer, ap);
diff --git a/nanohttp/nanohttp-server.c b/nanohttp/nanohttp-server.c
index 24a8333..e063045 100644
--- a/nanohttp/nanohttp-server.c
+++ b/nanohttp/nanohttp-server.c
@@ -1,5 +1,5 @@
/******************************************************************
-* $Id: nanohttp-server.c,v 1.47 2006/01/25 19:15:18 mrcsys Exp $
+* $Id: nanohttp-server.c,v 1.48 2006/02/08 11:13:14 snowdrop Exp $
*
* CSOAP Project: A http client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -85,6 +85,7 @@ static int _httpd_max_connections = 20;
static int _httpd_max_idle = 120;
#endif
static hsocket_t _httpd_socket;
+static hservice_t *_httpd_services_default = NULL;
static hservice_t *_httpd_services_head = NULL;
static hservice_t *_httpd_services_tail = NULL;
static int _httpd_run = 1;
@@ -180,7 +181,7 @@ httpd_init (int argc, char *argv[])
SSLPass = hoption_get(HOPTION_SSL_PASS);
SSLCA = hoption_get(HOPTION_SSL_CA);
log_verbose3("SSL: %s %s", SSLCert, SSLCA);
- if(SSLCert[0] != NULL){
+ if(SSLCert[0] != '\0'){
status = hsocket_init_ssl(&_httpd_socket, SSLCert, SSLPass, SSLCA);
} else
#endif
@@ -227,6 +228,24 @@ httpd_register (const char *ctx, httpd_service func)
return 1;
}
+int
+httpd_register_default (const char *ctx, httpd_service func)
+{
+ int ret;
+
+ ret = httpd_register(ctx, func);
+
+ /* this is broken, but working */
+ _httpd_services_default = _httpd_services_tail;
+
+ return ret;
+}
+
+int
+httpd_get_port(void)
+{
+ return _httpd_port;
+}
/*
* -----------------------------------------------------
@@ -269,7 +288,7 @@ httpd_find_service (const char *ctx)
cur = cur->next;
}
- return NULL;
+ return _httpd_services_default;
}
@@ -609,7 +628,6 @@ httpd_set_header (httpd_conn_t * conn, const char *key, const char *value)
return 0;
}
-
void
httpd_set_headers (httpd_conn_t * conn, hpair_t * header)
{
@@ -620,6 +638,37 @@ httpd_set_headers (httpd_conn_t * conn, hpair_t * header)
}
}
+int
+httpd_add_header (httpd_conn_t *conn, const char *key, const char *value)
+{
+ if (!conn)
+ {
+ log_warn1("Connection object is NULL");
+ return 0;
+ }
+
+ conn->header = hpairnode_new(key, value, conn->header);
+
+ return 1;
+}
+
+void
+httpd_add_headers (httpd_conn_t *conn, const hpair_t *values)
+{
+ if (!conn)
+ {
+ log_warn1("Connection object is NULL");
+ return;
+ }
+
+ while (values)
+ {
+ httpd_add_header(conn, values->key, values->value);
+ values = values->next;
+ }
+ return;
+}
+
/*
* -----------------------------------------------------
* FUNCTION: httpd_term
diff --git a/nanohttp/nanohttp-server.h b/nanohttp/nanohttp-server.h
index 383b7be..ccafe8f 100644
--- a/nanohttp/nanohttp-server.h
+++ b/nanohttp/nanohttp-server.h
@@ -1,5 +1,5 @@
/******************************************************************
- * $Id: nanohttp-server.h,v 1.11 2006/01/10 11:29:05 snowdrop Exp $
+ * $Id: nanohttp-server.h,v 1.12 2006/02/08 11:13:14 snowdrop Exp $
*
* CSOAP Project: A http client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -67,6 +67,8 @@ int httpd_register(const char *ctx, httpd_service service);
herror_t httpd_run();
void httpd_destroy();
+int httpd_get_port(void);
+
hservice_t *httpd_services();
herror_t httpd_send_header(httpd_conn_t * res, int code, const char *text);
@@ -74,6 +76,9 @@ herror_t httpd_send_header(httpd_conn_t * res, int code, const char *text);
int httpd_set_header(httpd_conn_t * conn, const char *key, const char *value);
void httpd_set_headers(httpd_conn_t * conn, hpair_t * header);
+int httpd_add_header(httpd_conn_t * conn, const char *key, const char *value);
+void httpd_add_headers(httpd_conn_t * conn, const hpair_t *values);
+
/*
unsigned char *httpd_get_postdata(httpd_conn_t *conn,
hrequest_t *req, long *received, long max);
diff --git a/nanohttp/nanohttp-socket.c b/nanohttp/nanohttp-socket.c
index 0c2c5ae..f880b74 100644
--- a/nanohttp/nanohttp-socket.c
+++ b/nanohttp/nanohttp-socket.c
@@ -1,5 +1,5 @@
/******************************************************************
-* $Id: nanohttp-socket.c,v 1.46 2006/02/04 01:25:13 snowdrop Exp $
+* $Id: nanohttp-socket.c,v 1.47 2006/02/08 11:13:14 snowdrop Exp $
*
* CSOAP Project: A http client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -631,7 +631,7 @@ hsocket_read(hsocket_t sock, byte_t * buffer, int total, int force,
if (SSL_get_shutdown(sock.ssl) == SSL_RECEIVED_SHUTDOWN ||
SSL_get_error(sock.ssl, status) == SSL_ERROR_SYSCALL)
{
- *received = NULL;;
+ *received = 0;
return herror_new("hsocket_read", HSOCKET_ERROR_SSLCLOSE, "SSL Closed");
}
log_error2("Read error (%d)", status);
diff --git a/nanohttp/nanohttp-ssl.c b/nanohttp/nanohttp-ssl.c
index e1139ac..b0f3aa2 100644
--- a/nanohttp/nanohttp-ssl.c
+++ b/nanohttp/nanohttp-ssl.c
@@ -129,20 +129,18 @@ verify_sn (X509 * cert, int who, int nid, char *str)
static int
verify_cb (int prev_ok, X509_STORE_CTX * ctx)
{
- X509 *cert = X509_STORE_CTX_get_current_cert (ctx);
- int depth = X509_STORE_CTX_get_error_depth (ctx);
- int err = X509_STORE_CTX_get_error (ctx);
/*
- if( err = X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN ){
+ if ((X509_STORE_CTX_get_error(ctx) = X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN))
+ {
log_verbose1("Self signed cert in chain");
return 1;
}
*/
#ifdef NOUSER_VERIFY /* ifdef's added by Ferhat. because of
unresolved reference while compiling */
- if (depth == 0)
+ if (X509_STORE_CTX_get_error_depth(ctx) == 0)
{
- return user_verify (cert);
+ return user_verify (X509_STORE_CTX_get_current_cert(ctx));
}
else
{
@@ -207,7 +205,7 @@ initialize_ctx (const char *keyfile, const char *password, const char *calist)
log_verbose1 ("Certificate file read ok");
- pass = password;
+ pass = strdup(password);
SSL_CTX_set_default_passwd_cb (ctx, pw_cb);
if (!(SSL_CTX_use_PrivateKey_file (ctx, keyfile, SSL_FILETYPE_PEM)))
@@ -299,7 +297,7 @@ log_ssl_error (SSL * ssl, int ret)
break;
case SSL_ERROR_SSL:
strcat (errorbuf, "SSL library");
- while (errqueue = ERR_get_error ())
+ while ((errqueue = ERR_get_error()))
{
log_error2 ("SSL %s", ERR_error_string (errqueue, NULL));
}
@@ -313,7 +311,6 @@ SSL *
init_ssl (SSL_CTX * ctx, int sock, int type)
{
int ret;
- int status;
SSL *ssl;
#if 0
#ifdef WIN32