summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xexamples/csoap/echoattachments-client.c3
-rwxr-xr-xexamples/csoap/echoattachments-server.c5
-rw-r--r--examples/csoap/simpleclient.c3
-rw-r--r--examples/csoap/simpleserver.c3
-rw-r--r--examples/csoap/soapclient.c1
-rw-r--r--examples/nanohttp/http_client.c3
-rw-r--r--examples/nanohttp/http_server.c3
-rw-r--r--libcsoap/soap-addressing.c3
-rw-r--r--libcsoap/soap-admin.c4
-rw-r--r--libcsoap/soap-client.c6
-rwxr-xr-xlibcsoap/soap-ctx.c23
-rwxr-xr-xlibcsoap/soap-ctx.h55
-rw-r--r--libcsoap/soap-env.c7
-rw-r--r--libcsoap/soap-env.h4
-rw-r--r--libcsoap/soap-fault.c4
-rw-r--r--libcsoap/soap-nhttp.c12
-rw-r--r--libcsoap/soap-nudp.c3
-rw-r--r--libcsoap/soap-router.c4
-rw-r--r--libcsoap/soap-server.c8
-rw-r--r--libcsoap/soap-service.c4
-rw-r--r--libcsoap/soap-transport.c3
-rw-r--r--libcsoap/soap-wsil.c3
-rw-r--r--libcsoap/soap-xmlsec.c3
-rw-r--r--nanohttp/Makefile.am4
-rw-r--r--nanohttp/nanohttp-admin.c3
-rw-r--r--nanohttp/nanohttp-client.c5
-rw-r--r--nanohttp/nanohttp-common.c119
-rw-r--r--nanohttp/nanohttp-common.h564
-rw-r--r--nanohttp/nanohttp-error.h102
-rwxr-xr-xnanohttp/nanohttp-mime.c79
-rwxr-xr-xnanohttp/nanohttp-mime.h4
-rwxr-xr-xnanohttp/nanohttp-request.c5
-rwxr-xr-xnanohttp/nanohttp-request.h217
-rwxr-xr-xnanohttp/nanohttp-response.c12
-rwxr-xr-xnanohttp/nanohttp-response.h119
-rw-r--r--nanohttp/nanohttp-server.c3
-rw-r--r--nanohttp/nanohttp-socket.c6
-rw-r--r--nanohttp/nanohttp-ssl.c3
-rwxr-xr-xnanohttp/nanohttp-stream.c5
39 files changed, 943 insertions, 474 deletions
diff --git a/examples/csoap/echoattachments-client.c b/examples/csoap/echoattachments-client.c
index 26c65ff..5c22805 100755
--- a/examples/csoap/echoattachments-client.c
+++ b/examples/csoap/echoattachments-client.c
@@ -1,5 +1,5 @@
/******************************************************************
- * $Id: echoattachments-client.c,v 1.14 2006/11/23 15:27:33 m0gg Exp $
+ * $Id: echoattachments-client.c,v 1.15 2006/11/25 15:06:57 m0gg Exp $
*
* CSOAP Project: CSOAP examples project
* Copyright (C) 2003-2004 Ferhat Ayaz
@@ -25,6 +25,7 @@
#include <libxml/tree.h>
+#include <nanohttp/nanohttp-error.h>
#include <nanohttp/nanohttp-common.h>
#include <nanohttp/nanohttp-logging.h>
diff --git a/examples/csoap/echoattachments-server.c b/examples/csoap/echoattachments-server.c
index abfb7ec..ea45aa8 100755
--- a/examples/csoap/echoattachments-server.c
+++ b/examples/csoap/echoattachments-server.c
@@ -1,5 +1,5 @@
/******************************************************************
- * $Id: echoattachments-server.c,v 1.11 2006/11/23 15:27:33 m0gg Exp $
+ * $Id: echoattachments-server.c,v 1.12 2006/11/25 15:06:57 m0gg Exp $
*
* CSOAP Project: CSOAP examples project
* Copyright (C) 2003-2004 Ferhat Ayaz
@@ -25,6 +25,7 @@
#include <libxml/tree.h>
+#include <nanohttp/nanohttp-error.h>
#include <nanohttp/nanohttp-common.h>
#include <nanohttp/nanohttp-logging.h>
@@ -43,7 +44,7 @@ echo_attachments(struct SoapCtx * req, struct SoapCtx * res)
{
herror_t err;
- part_t *part;
+ struct part_t *part;
char href[MAX_HREF_SIZE];
err = soap_env_new_with_response(req->env, &res->env);
diff --git a/examples/csoap/simpleclient.c b/examples/csoap/simpleclient.c
index 1e3b3ff..9add626 100644
--- a/examples/csoap/simpleclient.c
+++ b/examples/csoap/simpleclient.c
@@ -1,5 +1,5 @@
/******************************************************************
- * $Id: simpleclient.c,v 1.15 2006/11/23 15:27:33 m0gg Exp $
+ * $Id: simpleclient.c,v 1.16 2006/11/25 15:06:57 m0gg Exp $
*
* CSOAP Project: CSOAP examples project
* Copyright (C) 2003-2004 Ferhat Ayaz
@@ -25,6 +25,7 @@
#include <libxml/tree.h>
+#include <nanohttp/nanohttp-error.h>
#include <nanohttp/nanohttp-common.h>
#include <nanohttp/nanohttp-logging.h>
diff --git a/examples/csoap/simpleserver.c b/examples/csoap/simpleserver.c
index 9a814ea..3d2506a 100644
--- a/examples/csoap/simpleserver.c
+++ b/examples/csoap/simpleserver.c
@@ -1,5 +1,5 @@
/******************************************************************
- * $Id: simpleserver.c,v 1.23 2006/11/24 10:54:03 m0gg Exp $
+ * $Id: simpleserver.c,v 1.24 2006/11/25 15:06:57 m0gg Exp $
*
* CSOAP Project: CSOAP examples project
* Copyright (C) 2003-2004 Ferhat Ayaz
@@ -26,6 +26,7 @@
#include <libxml/tree.h>
#include <libxml/xpath.h>
+#include <nanohttp/nanohttp-error.h>
#include <nanohttp/nanohttp-common.h>
#include <nanohttp/nanohttp-logging.h>
diff --git a/examples/csoap/soapclient.c b/examples/csoap/soapclient.c
index ea7d05f..ec6374c 100644
--- a/examples/csoap/soapclient.c
+++ b/examples/csoap/soapclient.c
@@ -11,6 +11,7 @@
#include <libxml/tree.h>
#include <libxml/uri.h>
+#include <nanohttp/nanohttp-error.h>
#include <nanohttp/nanohttp-common.h>
// #include <nanohttp/nanohttp-request.h>
diff --git a/examples/nanohttp/http_client.c b/examples/nanohttp/http_client.c
index f871739..e320cb9 100644
--- a/examples/nanohttp/http_client.c
+++ b/examples/nanohttp/http_client.c
@@ -1,5 +1,5 @@
/******************************************************************
-* $Id: http_client.c,v 1.5 2006/11/23 15:27:33 m0gg Exp $
+* $Id: http_client.c,v 1.6 2006/11/25 15:06:57 m0gg Exp $
*
* CSOAP Project: A http client/server library in C (example)
* Copyright (C) 2003-2004 Ferhat Ayaz
@@ -25,6 +25,7 @@
#include <stdlib.h>
#include <string.h>
+#include <nanohttp/nanohttp-error.h>
#include <nanohttp/nanohttp-common.h>
#include <nanohttp/nanohttp-stream.h>
#include <nanohttp/nanohttp-request.h>
diff --git a/examples/nanohttp/http_server.c b/examples/nanohttp/http_server.c
index 950a717..655ad7a 100644
--- a/examples/nanohttp/http_server.c
+++ b/examples/nanohttp/http_server.c
@@ -1,5 +1,5 @@
/******************************************************************
-* $Id: http_server.c,v 1.7 2006/11/23 15:27:33 m0gg Exp $
+* $Id: http_server.c,v 1.8 2006/11/25 15:06:57 m0gg Exp $
*
* CSOAP Project: A http client/server library in C (example)
* Copyright (C) 2003 Ferhat Ayaz
@@ -24,6 +24,7 @@
#include <stdio.h>
#include <string.h>
+#include <nanohttp/nanohttp-error.h>
#include <nanohttp/nanohttp-common.h>
#include <nanohttp/nanohttp-stream.h>
#include <nanohttp/nanohttp-request.h>
diff --git a/libcsoap/soap-addressing.c b/libcsoap/soap-addressing.c
index 95c47cd..e6852d8 100644
--- a/libcsoap/soap-addressing.c
+++ b/libcsoap/soap-addressing.c
@@ -1,5 +1,5 @@
/******************************************************************
-* $Id: soap-addressing.c,v 1.4 2006/11/24 10:54:03 m0gg Exp $
+* $Id: soap-addressing.c,v 1.5 2006/11/25 15:06:57 m0gg Exp $
*
* CSOAP Project: A SOAP client/server library in C
* Copyright (C) 2006 Heiko Ronsdorf
@@ -53,6 +53,7 @@
#include <libxml/xpath.h>
#include <libxml/uri.h>
+#include <nanohttp/nanohttp-error.h>
#include <nanohttp/nanohttp-common.h>
#include <nanohttp/nanohttp-logging.h>
diff --git a/libcsoap/soap-admin.c b/libcsoap/soap-admin.c
index b792ae6..20b3412 100644
--- a/libcsoap/soap-admin.c
+++ b/libcsoap/soap-admin.c
@@ -1,5 +1,5 @@
/******************************************************************
-* $Id: soap-admin.c,v 1.7 2006/11/23 15:27:33 m0gg Exp $
+* $Id: soap-admin.c,v 1.8 2006/11/25 15:06:57 m0gg Exp $
*
* CSOAP Project: A SOAP client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -44,12 +44,14 @@
#include <libxml/tree.h>
#include <libxml/uri.h>
+#include <nanohttp/nanohttp-error.h>
#include <nanohttp/nanohttp-common.h>
#include <nanohttp/nanohttp-request.h>
#include <nanohttp/nanohttp-server.h>
#include <nanohttp/nanohttp-admin.h>
#include "soap-env.h"
+#include "soap-ctx.h"
#include "soap-service.h"
#include "soap-router.h"
#include "soap-server.h"
diff --git a/libcsoap/soap-client.c b/libcsoap/soap-client.c
index a49ba2a..5d34f8f 100644
--- a/libcsoap/soap-client.c
+++ b/libcsoap/soap-client.c
@@ -1,5 +1,5 @@
/******************************************************************
-* $Id: soap-client.c,v 1.30 2006/11/23 15:27:33 m0gg Exp $
+* $Id: soap-client.c,v 1.31 2006/11/25 15:06:57 m0gg Exp $
*
* CSOAP Project: A SOAP client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -28,9 +28,7 @@
#include <libxml/tree.h>
#include <libxml/uri.h>
-#include <nanohttp/nanohttp-common.h>
-#include <nanohttp/nanohttp-request.h>
-#include <nanohttp/nanohttp-server.h>
+#include <nanohttp/nanohttp-error.h>
#include <nanohttp/nanohttp-logging.h>
#include "soap-fault.h"
diff --git a/libcsoap/soap-ctx.c b/libcsoap/soap-ctx.c
index 25c34dd..4d595f4 100755
--- a/libcsoap/soap-ctx.c
+++ b/libcsoap/soap-ctx.c
@@ -1,5 +1,5 @@
/******************************************************************
- * $Id: soap-ctx.c,v 1.13 2006/11/23 15:27:33 m0gg Exp $
+ * $Id: soap-ctx.c,v 1.14 2006/11/25 15:06:57 m0gg Exp $
*
* CSOAP Project: A SOAP client/server library in C
* Copyright (C) 2003-2004 Ferhat Ayaz
@@ -43,6 +43,7 @@
#include <libxml/tree.h>
+#include <nanohttp/nanohttp-error.h>
#include <nanohttp/nanohttp-common.h>
#include <nanohttp/nanohttp-logging.h>
@@ -67,11 +68,10 @@ soap_ctx_new(struct SoapEnv * env) /* should only be used internally */
return ctx;
}
-
void
-soap_ctx_add_files(struct SoapCtx * ctx, attachments_t * attachments)
+soap_ctx_add_files(struct SoapCtx *ctx, struct attachments_t *attachments)
{
- part_t *part;
+ struct part_t *part;
char href[MAX_HREF_SIZE];
if (attachments == NULL)
@@ -83,8 +83,9 @@ soap_ctx_add_files(struct SoapCtx * ctx, attachments_t * attachments)
soap_ctx_add_file(ctx, part->filename, part->content_type, href);
part = part->next;
}
-}
+ return;
+}
herror_t
soap_ctx_add_file(struct SoapCtx * ctx, const char *filename,
@@ -92,7 +93,7 @@ soap_ctx_add_file(struct SoapCtx * ctx, const char *filename,
{
char cid[250];
char id[250];
- part_t *part;
+ struct part_t *part;
static int counter = 1;
FILE *test = fopen(filename, "r");
if (!test)
@@ -115,13 +116,13 @@ soap_ctx_add_file(struct SoapCtx * ctx, const char *filename,
return H_OK;
}
-part_t *
+struct part_t *
soap_ctx_get_file(struct SoapCtx * ctx, xmlNodePtr node)
{
xmlChar *prop;
char href[MAX_HREF_SIZE];
char buffer[MAX_HREF_SIZE];
- part_t *part;
+ struct part_t *part;
if (!ctx->attachments)
return NULL;
@@ -172,15 +173,15 @@ soap_ctx_free(struct SoapCtx * ctx)
return;
}
-
herror_t
soap_ctx_new_with_method(const char *urn, const char *method, struct SoapCtx ** out)
{
struct SoapEnv *env;
herror_t err;
- err = soap_env_new_with_method(urn, method, &env);
- if (err != H_OK)
+
+ if ((err = soap_env_new_with_method(urn, method, &env)) != H_OK)
return err;
+
*out = soap_ctx_new(env);
return H_OK;
diff --git a/libcsoap/soap-ctx.h b/libcsoap/soap-ctx.h
index b8bfb3d..a1c041a 100755
--- a/libcsoap/soap-ctx.h
+++ b/libcsoap/soap-ctx.h
@@ -1,5 +1,5 @@
/******************************************************************
- * $Id: soap-ctx.h,v 1.12 2006/11/23 15:27:33 m0gg Exp $
+ * $Id: soap-ctx.h,v 1.13 2006/11/25 15:06:57 m0gg Exp $
*
* CSOAP Project: A SOAP client/server library in C
* Copyright (C) 2003-2004 Ferhat Ayaz
@@ -32,40 +32,55 @@
struct SoapCtx
{
struct SoapEnv *env;
- attachments_t *attachments;
+ struct attachments_t *attachments;
};
#ifdef __cplusplus
extern "C" {
#endif
-/* should only be used internally */
+/**
+ *
+ * should only be used internally
+ *
+ */
extern struct SoapCtx *soap_ctx_new(struct SoapEnv * env);
/**
- Creates a new soap context object.
-*/
+ *
+ * Creates a new soap context object.
+ *
+ */
extern herror_t soap_ctx_new_with_method(const char *urn, const char *method, struct SoapCtx ** out);
extern void soap_ctx_free(struct SoapCtx * ctx);
+
/**
- Returns the attached file if any found.
- @param ctx the SoapCtx object which should contain the part
- @param node the xml node which points to a file via the "href" xml attribute
+ *
+ * Returns the attached file if any found.
+ *
+ * @param ctx the SoapCtx object which should contain the part
+ * @param node the xml node which points to a file via the "href" xml attribute
+ *
+ * @returns a part_t object of attachment was found, NULL otherwise.
+ *
+ */
+extern struct part_t *soap_ctx_get_file(struct SoapCtx * ctx, xmlNodePtr node);
- @returns a part_t object of attachment was found, NULL otherwise.
-
-*/
-extern part_t *soap_ctx_get_file(struct SoapCtx * ctx, xmlNodePtr node);
+/**
+ *
+ * Size of destination dest_href should be MAX_HREF_SIZE
+ *
+ */
+extern herror_t soap_ctx_add_file(struct SoapCtx * ctx, const char *filename, const char *content_type, char *dest_href);
-/* Size of destination dest_href should be MAX_HREF_SIZE */
-extern herror_t soap_ctx_add_file(struct SoapCtx * ctx, const char *filename,
- const char *content_type, char *dest_href);
-/*
-Used internally. Will switch the deleteOnExit flag from the
-given one to the added part.
-*/
-extern void soap_ctx_add_files(struct SoapCtx * ctx, attachments_t * attachments);
+/**
+ *
+ * Used internally. Will switch the deleteOnExit flag from the given one to the
+ * added part.
+ *
+ */
+extern void soap_ctx_add_files(struct SoapCtx * ctx, struct attachments_t * attachments);
#ifdef __cplusplus
}
diff --git a/libcsoap/soap-env.c b/libcsoap/soap-env.c
index 6abfb1f..04146f4 100644
--- a/libcsoap/soap-env.c
+++ b/libcsoap/soap-env.c
@@ -1,5 +1,5 @@
/******************************************************************
-* $Id: soap-env.c,v 1.25 2006/11/24 10:54:03 m0gg Exp $
+* $Id: soap-env.c,v 1.26 2006/11/25 15:06:57 m0gg Exp $
*
* CSOAP Project: A SOAP client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -53,7 +53,7 @@
#include <libxml/xpath.h>
#include <libxml/xmlstring.h>
-#include <nanohttp/nanohttp-common.h>
+#include <nanohttp/nanohttp-error.h>
#include <nanohttp/nanohttp-logging.h>
#include "soap-xml.h"
@@ -265,8 +265,7 @@ soap_env_new_with_response(struct SoapEnv * request, struct SoapEnv ** out)
{
return herror_new("soap_env_new_with_response",
GENERAL_INVALID_PARAM,
- "Method name '%s' not found in request",
- SAVE_STR(method));
+ "Method name not found in request");
}
if (!(urn = soap_env_find_urn(request)))
diff --git a/libcsoap/soap-env.h b/libcsoap/soap-env.h
index b73bb38..95867d7 100644
--- a/libcsoap/soap-env.h
+++ b/libcsoap/soap-env.h
@@ -1,5 +1,5 @@
/******************************************************************
- * $Id: soap-env.h,v 1.17 2006/11/23 15:27:33 m0gg Exp $
+ * $Id: soap-env.h,v 1.18 2006/11/25 15:06:57 m0gg Exp $
*
* CSOAP Project: A SOAP client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -277,7 +277,7 @@ extern void soap_env_pop_item(struct SoapEnv * env);
* @param env The envelope object
*
*/
-extern void soap_env_free(struct SoapEnv * env);
+extern void soap_env_free(struct SoapEnv *env);
/**
*
diff --git a/libcsoap/soap-fault.c b/libcsoap/soap-fault.c
index 8bb3945..4d86d2b 100644
--- a/libcsoap/soap-fault.c
+++ b/libcsoap/soap-fault.c
@@ -1,5 +1,5 @@
/******************************************************************
-* $Id: soap-fault.c,v 1.14 2006/11/24 10:54:03 m0gg Exp $
+* $Id: soap-fault.c,v 1.15 2006/11/25 15:06:57 m0gg Exp $
*
* CSOAP Project: A SOAP client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -31,7 +31,7 @@
#include <libxml/xpath.h>
-#include <nanohttp/nanohttp-common.h>
+#include <nanohttp/nanohttp-error.h>
#include <nanohttp/nanohttp-logging.h>
#include "soap-xml.h"
diff --git a/libcsoap/soap-nhttp.c b/libcsoap/soap-nhttp.c
index b8b0e35..0546c58 100644
--- a/libcsoap/soap-nhttp.c
+++ b/libcsoap/soap-nhttp.c
@@ -1,5 +1,5 @@
/******************************************************************
-* $Id: soap-nhttp.c,v 1.2 2006/11/23 15:27:33 m0gg Exp $
+* $Id: soap-nhttp.c,v 1.3 2006/11/25 15:06:57 m0gg Exp $
*
* CSOAP Project: A SOAP client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -40,10 +40,10 @@
#include <libxml/tree.h>
#include <libxml/uri.h>
+#include <nanohttp/nanohttp-error.h>
#include <nanohttp/nanohttp-common.h>
#include <nanohttp/nanohttp-logging.h>
#include <nanohttp/nanohttp-stream.h>
-
#include <nanohttp/nanohttp-request.h>
#include <nanohttp/nanohttp-response.h>
@@ -273,7 +273,7 @@ _soap_nhttp_client_invoke(void *unused, struct SoapCtx *request, struct SoapCtx
/* multipart/related start id */
char start_id[150];
static int counter = 1;
- part_t *part;
+ struct part_t *part;
/* for copy attachments */
char href[MAX_HREF_SIZE];
@@ -363,11 +363,9 @@ _soap_nhttp_client_invoke(void *unused, struct SoapCtx *request, struct SoapCtx
for (part=request->attachments->parts; part; part=part->next)
{
- status = httpc_mime_send_file(conn, part->id, part->content_type, part->transfer_encoding, part->filename);
-
- if (status != H_OK)
+ if ((status = httpc_mime_send_file(conn, part->id, part->content_type, part->transfer_encoding, part->filename)) != H_OK)
{
- log_error2("Send file failed. Status: %d", status);
+ log_error2("httpc_mime_send_file failed (%s)", herror_message(status));
httpc_close_free(conn);
xmlBufferFree(buffer);
return status;
diff --git a/libcsoap/soap-nudp.c b/libcsoap/soap-nudp.c
index 4520631..93357a2 100644
--- a/libcsoap/soap-nudp.c
+++ b/libcsoap/soap-nudp.c
@@ -1,5 +1,5 @@
/******************************************************************
-* $Id: soap-nudp.c,v 1.2 2006/11/23 15:27:33 m0gg Exp $
+* $Id: soap-nudp.c,v 1.3 2006/11/25 15:06:57 m0gg Exp $
*
* CSOAP Project: A SOAP client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -36,6 +36,7 @@
#include <libxml/tree.h>
#include <libxml/uri.h>
+#include <nanohttp/nanohttp-error.h>
#include <nanohttp/nanohttp-common.h>
#include <nanohttp/nanohttp-logging.h>
diff --git a/libcsoap/soap-router.c b/libcsoap/soap-router.c
index c0891f6..cc443ca 100644
--- a/libcsoap/soap-router.c
+++ b/libcsoap/soap-router.c
@@ -1,5 +1,5 @@
/******************************************************************
-* $Id: soap-router.c,v 1.13 2006/11/23 15:27:33 m0gg Exp $
+* $Id: soap-router.c,v 1.14 2006/11/25 15:06:57 m0gg Exp $
*
* CSOAP Project: A SOAP client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -39,7 +39,7 @@
#include <libxml/tree.h>
-#include <nanohttp/nanohttp-common.h>
+#include <nanohttp/nanohttp-error.h>
#include <nanohttp/nanohttp-logging.h>
#include "soap-fault.h"
diff --git a/libcsoap/soap-server.c b/libcsoap/soap-server.c
index 78114c2..2f7a0b2 100644
--- a/libcsoap/soap-server.c
+++ b/libcsoap/soap-server.c
@@ -1,5 +1,5 @@
/******************************************************************
-* $Id: soap-server.c,v 1.31 2006/11/24 10:54:03 m0gg Exp $
+* $Id: soap-server.c,v 1.32 2006/11/25 15:06:57 m0gg Exp $
*
* CSOAP Project: A SOAP client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -40,9 +40,7 @@
#include <libxml/tree.h>
#include <libxml/uri.h>
-#include <nanohttp/nanohttp-common.h>
-#include <nanohttp/nanohttp-request.h>
-#include <nanohttp/nanohttp-server.h>
+#include <nanohttp/nanohttp-error.h>
#include <nanohttp/nanohttp-logging.h>
#include "soap-fault.h"
@@ -119,7 +117,7 @@ _soap_server_fillup_header(struct SoapEnv *envelope)
else
xmlFreeURI(uri);
- if (!(uri = soap_addressing_get_from(envelope)))
+ if (!(uri = soap_addressing_get_from_address(envelope)))
soap_addressing_set_from_string(envelope, soap_server_get_name());
else
xmlFreeURI(uri);
diff --git a/libcsoap/soap-service.c b/libcsoap/soap-service.c
index 241eb82..e63dd22 100644
--- a/libcsoap/soap-service.c
+++ b/libcsoap/soap-service.c
@@ -1,5 +1,5 @@
/******************************************************************
-* $Id: soap-service.c,v 1.11 2006/11/23 15:27:33 m0gg Exp $
+* $Id: soap-service.c,v 1.12 2006/11/25 15:06:57 m0gg Exp $
*
* CSOAP Project: A SOAP client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -48,7 +48,7 @@
#include <libxml/tree.h>
#include <libxml/uri.h>
-#include <nanohttp/nanohttp-common.h>
+#include <nanohttp/nanohttp-error.h>
#include <nanohttp/nanohttp-logging.h>
#include "soap-fault.h"
diff --git a/libcsoap/soap-transport.c b/libcsoap/soap-transport.c
index 1fc2c51..1a30ba9 100644
--- a/libcsoap/soap-transport.c
+++ b/libcsoap/soap-transport.c
@@ -1,5 +1,5 @@
/******************************************************************
-* $Id: soap-transport.c,v 1.2 2006/11/23 15:27:33 m0gg Exp $
+* $Id: soap-transport.c,v 1.3 2006/11/25 15:06:57 m0gg Exp $
*
* CSOAP Project: A SOAP client/server library in C
* Copyright (C) 2007 Heiko Ronsdorf
@@ -36,6 +36,7 @@
#include <libxml/tree.h>
#include <libxml/uri.h>
+#include <nanohttp/nanohttp-error.h>
#include <nanohttp/nanohttp-common.h>
#include <nanohttp/nanohttp-logging.h>
diff --git a/libcsoap/soap-wsil.c b/libcsoap/soap-wsil.c
index 7e0a7f2..2a11130 100644
--- a/libcsoap/soap-wsil.c
+++ b/libcsoap/soap-wsil.c
@@ -1,5 +1,5 @@
/******************************************************************
-* $Id: soap-wsil.c,v 1.2 2006/11/23 15:27:33 m0gg Exp $
+* $Id: soap-wsil.c,v 1.3 2006/11/25 15:06:58 m0gg Exp $
*
* CSOAP Project: A SOAP client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -35,6 +35,7 @@
#include <libxml/tree.h>
+#include <nanohttp/nanohttp-error.h>
#include <nanohttp/nanohttp-common.h>
#include <nanohttp/nanohttp-request.h>
#include <nanohttp/nanohttp-server.h>
diff --git a/libcsoap/soap-xmlsec.c b/libcsoap/soap-xmlsec.c
index 66ec75b..aa6e0c2 100644
--- a/libcsoap/soap-xmlsec.c
+++ b/libcsoap/soap-xmlsec.c
@@ -1,5 +1,5 @@
/******************************************************************
-* $Id: soap-xmlsec.c,v 1.1 2006/11/24 11:22:55 m0gg Exp $
+* $Id: soap-xmlsec.c,v 1.2 2006/11/25 15:06:58 m0gg Exp $
*
* CSOAP Project: A SOAP client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -50,6 +50,7 @@
#include <xmlsec/crypto.h>
#include <xmlsec/errors.h>
+#include <nanohttp/nanohttp-error.h>
#include <nanohttp/nanohttp-common.h>
#include <nanohttp/nanohttp-logging.h>
diff --git a/nanohttp/Makefile.am b/nanohttp/Makefile.am
index 18ccaf6..e960f50 100644
--- a/nanohttp/Makefile.am
+++ b/nanohttp/Makefile.am
@@ -6,13 +6,13 @@ 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-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-admin.h nanohttp-error.h
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-admin.c b/nanohttp/nanohttp-admin.c
index 746855b..fa2fdaf 100644
--- a/nanohttp/nanohttp-admin.c
+++ b/nanohttp/nanohttp-admin.c
@@ -1,5 +1,5 @@
/******************************************************************
-* $Id: nanohttp-admin.c,v 1.4 2006/11/23 15:27:33 m0gg Exp $
+* $Id: nanohttp-admin.c,v 1.5 2006/11/25 15:06:58 m0gg Exp $
*
* CSOAP Project: A SOAP client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -37,6 +37,7 @@
#include <pthread.h>
#endif
+#include "nanohttp-error.h"
#include "nanohttp-common.h"
#include "nanohttp-stream.h"
#include "nanohttp-request.h"
diff --git a/nanohttp/nanohttp-client.c b/nanohttp/nanohttp-client.c
index b475d65..d9bf113 100644
--- a/nanohttp/nanohttp-client.c
+++ b/nanohttp/nanohttp-client.c
@@ -1,5 +1,5 @@
/******************************************************************
-* $Id: nanohttp-client.c,v 1.45 2006/11/24 17:28:07 m0gg Exp $
+* $Id: nanohttp-client.c,v 1.46 2006/11/25 15:06:58 m0gg Exp $
*
* CSOAP Project: A http client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -61,13 +61,14 @@
#include <netinet/in.h>
#endif
+#include "nanohttp-logging.h"
+#include "nanohttp-error.h"
#include "nanohttp-common.h"
#include "nanohttp-socket.h"
#include "nanohttp-stream.h"
#include "nanohttp-request.h"
#include "nanohttp-response.h"
#include "nanohttp-base64.h"
-#include "nanohttp-logging.h"
#include "nanohttp-client.h"
/*--------------------------------------------------
diff --git a/nanohttp/nanohttp-common.c b/nanohttp/nanohttp-common.c
index 5e13755..212de01 100644
--- a/nanohttp/nanohttp-common.c
+++ b/nanohttp/nanohttp-common.c
@@ -1,5 +1,5 @@
/******************************************************************
-* $Id: nanohttp-common.c,v 1.32 2006/11/24 17:28:07 m0gg Exp $
+* $Id: nanohttp-common.c,v 1.33 2006/11/25 15:06:58 m0gg Exp $
*
* CSOAP Project: A http client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -53,8 +53,9 @@
#include <pthread.h>
#endif
-#include "nanohttp-common.h"
#include "nanohttp-logging.h"
+#include "nanohttp-error.h"
+#include "nanohttp-common.h"
static int
strcmpigcase(const char *s1, const char *s2)
@@ -79,72 +80,6 @@ strcmpigcase(const char *s1, const char *s2)
return 1;
}
-typedef struct _herror_impl_t
-{
- int errcode;
- char message[250];
- char func[100];
-} herror_impl_t;
-
-herror_t
-herror_new(const char *func, int errcode, const char *format, ...)
-{
- va_list ap;
- herror_impl_t *impl;
-
- if (!(impl = (herror_impl_t *) malloc(sizeof(herror_impl_t))))
- {
- log_error2("malloc failed (%s)", strerror(errno));
- return NULL;
- }
-
- impl->errcode = errcode;
- strcpy(impl->func, func);
-
- va_start(ap, format);
- vsprintf(impl->message, format, ap);
- va_end(ap);
-
- return (herror_t) impl;
-}
-
-int
-herror_code(herror_t err)
-{
- herror_impl_t *impl = (herror_impl_t *) err;
- if (!err)
- return H_OK;
- return impl->errcode;
-}
-
-char *
-herror_func(herror_t err)
-{
- herror_impl_t *impl = (herror_impl_t *) err;
- if (!err)
- return "";
- return impl->func;
-}
-
-char *
-herror_message(herror_t err)
-{
- herror_impl_t *impl = (herror_impl_t *) err;
- if (!err)
- return "";
- return impl->message;
-}
-
-void
-herror_release(herror_t err)
-{
- herror_impl_t *impl = (herror_impl_t *) err;
- if (!err)
- return;
- free(impl);
-}
-
-
hpair_t *
hpairnode_new(const char *key, const char *value, hpair_t * next)
{
@@ -583,7 +518,6 @@ content_type_new(const char *content_type_str)
return ct;
}
-
void
content_type_free(content_type_t * ct)
{
@@ -592,15 +526,21 @@ content_type_free(content_type_t * ct)
hpairnode_free_deep(ct->params);
free(ct);
-}
+ return;
+}
-part_t *
-part_new(const char *id, const char *filename,
- const char *content_type, const char *transfer_encoding,
- part_t * next)
+struct part_t *
+part_new(const char *id, const char *filename, const char *content_type, const char *transfer_encoding, struct part_t * next)
{
- part_t *part = (part_t *) malloc(sizeof(part_t));
+ struct part_t *part;
+
+ if (!(part = (struct part_t *) malloc(sizeof(struct part_t))))
+ {
+ log_error2("malloc failed (%s)", strerror(errno));
+ return NULL;
+ }
+
part->header = NULL;
part->next = next;
part->deleteOnExit = 0;
@@ -632,7 +572,7 @@ part_new(const char *id, const char *filename,
}
void
-part_free(part_t * part)
+part_free(struct part_t * part)
{
if (part == NULL)
return;
@@ -647,11 +587,17 @@ part_free(part_t * part)
free(part);
}
-attachments_t *
-attachments_new() /* should be used internally */
+struct attachments_t *
+attachments_new(void) /* should be used internally */
{
- attachments_t *attachments =
- (attachments_t *) malloc(sizeof(attachments_t));
+ struct attachments_t *attachments;
+
+ if (!(attachments = (struct attachments_t *) malloc(sizeof(struct attachments_t))))
+ {
+ log_error2("malloc failed (%s)", strerror(errno));
+ return NULL;
+ }
+
attachments->parts = NULL;
attachments->last = NULL;
attachments->root_part = NULL;
@@ -660,9 +606,8 @@ attachments_new() /* should be used internally */
}
void
-attachments_add_part(attachments_t * attachments, part_t * part)
+attachments_add_part(struct attachments_t *attachments, struct part_t *part)
{
- /* paranoya check */
if (!attachments)
return;
@@ -672,15 +617,17 @@ attachments_add_part(attachments_t * attachments, part_t * part)
attachments->parts = part;
attachments->last = part;
+
+ return;
}
/*
Free a mime message
*/
void
-attachments_free(attachments_t * message)
+attachments_free(struct attachments_t *message)
{
- part_t *tmp, *part;
+ struct part_t *tmp, *part;
if (message == NULL)
return;
@@ -695,8 +642,10 @@ attachments_free(attachments_t * message)
if (message->root_part)
part_free(message->root_part);
-/* TODO (#1#): HERE IS A BUG!!!! */
+
free(message);
+
+ return;
}
diff --git a/nanohttp/nanohttp-common.h b/nanohttp/nanohttp-common.h
index cc9f8f8..dabdda6 100644
--- a/nanohttp/nanohttp-common.h
+++ b/nanohttp/nanohttp-common.h
@@ -1,5 +1,5 @@
/******************************************************************
- * $Id: nanohttp-common.h,v 1.33 2006/11/23 15:27:33 m0gg Exp $
+ * $Id: nanohttp-common.h,v 1.34 2006/11/25 15:06:58 m0gg Exp $
*
* CSOAP Project: A http client/server library in C
* Copyright (C) 2003-2004 Ferhat Ayaz
@@ -34,10 +34,12 @@
*
* 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
- * transferred. These header fields apply only to the message being transmitted.
- * (see RFC2616)
+ * transferred. These header fields apply only to the message being transmitted.
+ *
+ * @see http://www.ietf.org/rfc/rfc/2616.txt
*
*/
+
#define HEADER_CACHE_CONTROL "Cache-Control"
#define HEADER_CONNECTION "Connection"
#define HEADER_DATE "Date"
@@ -57,6 +59,8 @@
* metainformation is OPTIONAL; some might be REQUIRED by portions of this
* specification. (see RFC2616 7.1)
*
+ * @see http://www.ietf.org/rfc/rfc2616.txt
+ *
*/
#define HEADER_ALLOW "Allow"
#define HEADER_CONTENT_ENCODING "Content-Encoding"
@@ -71,7 +75,7 @@
/**
*
- * Command line arguments for client and server.
+ * Common commandline arguments for client and server.
*
*/
#define NHTTP_ARG_CERT "-NHTTPcert"
@@ -98,71 +102,11 @@
#define URL_DEFAULT_PORT_HTTPS 81
#define URL_DEFAULT_PORT_FTP 120
-/* Success flag */
-#define H_OK 0
-
-/* File errors */
-#define FILE_ERROR_OPEN 8000
-#define FILE_ERROR_READ 8001
-
-/* Socket errors */
-#define HSOCKET_ERROR_CREATE 1001
-#define HSOCKET_ERROR_GET_HOSTNAME 1002
-#define HSOCKET_ERROR_CONNECT 1003
-#define HSOCKET_ERROR_SEND 1004
-#define HSOCKET_ERROR_RECEIVE 1005
-#define HSOCKET_ERROR_BIND 1006
-#define HSOCKET_ERROR_LISTEN 1007
-#define HSOCKET_ERROR_ACCEPT 1008
-#define HSOCKET_ERROR_NOT_INITIALIZED 1009
-#define HSOCKET_ERROR_IOCTL 1010
-#define HSOCKET_ERROR_SSLCLOSE 1011
-#define HSOCKET_ERROR_SSLCTX 1011
-
-/* URL errors */
-#define URL_ERROR_UNKNOWN_PROTOCOL 1101
-#define URL_ERROR_NO_PROTOCOL 1102
-#define URL_ERROR_NO_HOST 1103
-
-/* Stream errors */
-#define STREAM_ERROR_INVALID_TYPE 1201
-#define STREAM_ERROR_SOCKET_ERROR 1202
-#define STREAM_ERROR_NO_CHUNK_SIZE 1203
-#define STREAM_ERROR_WRONG_CHUNK_SIZE 1204
-
-
-/* MIME errors */
-#define MIME_ERROR_NO_BOUNDARY_PARAM 1301
-#define MIME_ERROR_NO_START_PARAM 1302
-#define MIME_ERROR_PARSE_ERROR 1303
-#define MIME_ERROR_NO_ROOT_PART 1304
-#define MIME_ERROR_NOT_MIME_MESSAGE 1305
-
-
-/* General errors */
-#define GENERAL_INVALID_PARAM 1400
-#define GENERAL_HEADER_PARSE_ERROR 1401
-
-/* Thread errors */
-#define THREAD_BEGIN_ERROR 1500
-
-/* XML Errors */
-#define XML_ERROR_EMPTY_DOCUMENT 1600
-#define XML_ERROR_PARSE 1601
-
-/* SSL Errors */
-#define HSSL_ERROR_CA_LIST 1710
-#define HSSL_ERROR_CONTEXT 1720
-#define HSSL_ERROR_CERTIFICATE 1730
-#define HSSL_ERROR_PEM 1740
-#define HSSL_ERROR_CLIENT 1750
-#define HSSL_ERROR_SERVER 1760
-#define HSSL_ERROR_CONNECT 1770
-
/**
- Indicates the version of the
- used HTTP protocol.
-*/
+ *
+ * Indicates the version of the used HTTP protocol.
+ *
+ */
typedef enum _http_version
{
HTTP_1_0,
@@ -171,37 +115,124 @@ typedef enum _http_version
/**
- Indicates the used method
-*/
+ *
+ * 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.
+ *
+ * @see HTTP_HEADER_HOST
+ *
+ */
typedef enum _hreq_method
{
- HTTP_REQUEST_POST,
+ /**
+ *
+ * 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
+ * method to cover the following functions:
+ * - Annotation of existing resources;
+ * - Posting a message to a bulletin board, newsgroup, mailing list, or
+ * similar group of articles;
+ * - 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
+ * sent in response to a GET request. This method can be used for obtaining
+ * 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
+ * the one residing on the origin server. If the Request-URI does not point to
+ * an existing resource, and that URI is capable of being defined as a new
+ * resource by the requesting user agent, the origin server can create the
+ * resource with that URI. If a new resource is created, the origin server MUST
+ * inform the user agent via the 201 (Created) response. If an existing
+ * resource is modified, either the 200 (OK) or 204 (No Content) response codes
+ * SHOULD be sent to indicate successful completion of the request. If the
+ * resource could not be created or modified with the Request-URI, an
+ * appropriate error response SHOULD be given that reflects the nature of the
+ * 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
+ * guaranteed that the operation has been carried out, even if the status code
+ * returned from the origin server indicates that the action has been completed
+ * 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;
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef void *herror_t;
-
-herror_t herror_new(const char *func, int errcode, const char *format, ...);
-int herror_code(herror_t err);
-char *herror_func(herror_t err);
-char *herror_message(herror_t err);
-void herror_release(herror_t err);
-
-/*
- hpairnode_t represents a pair (key, value) pair.
- This is also a linked list.
+/**
+ *
+ * hpairnode_t represents a pair (key, value) pair. This is also a linked list.
+ *
*/
typedef struct hpair hpair_t;
struct hpair
@@ -211,122 +242,134 @@ struct hpair
hpair_t *next;
};
+#ifdef __cplusplus
+extern "C" {
+#endif
/**
- Creates a new pair with the given parameters. Both strings
- key and value will be cloned while creating the pair.
-
- @param key the key of the (key,value) pair
- @param value the value of the (key,value) pair
- @param next next pair node in the linked list
-
- @returns A newly crated hpair_t object. Use hpair_free()
- or hpair_free_deep() to free the pair.
-*/
-hpair_t *hpairnode_new(const char *key, const char *value, hpair_t * next);
-
+ *
+ * Creates a new pair with the given parameters. Both strings key and value will
+ * be cloned while creating the pair.
+ *
+ * @param key the key of the (key,value) pair
+ * @param value the value of the (key,value) pair
+ * @param next next pair node in the linked list
+ *
+ * @returns A newly crated hpair_t object. Use hpair_free() or hpair_free_deep()
+ * to free the pair.
+ *
+ */
+extern hpair_t *hpairnode_new(const char *key, const char *value, hpair_t * next);
/**
- Creates a new pair from a given string. This function
- will split 'str' with the found first delimiter 'delim'.
- The 'value' field of the newly created pair will have
- the value "", if no delimiter was found/
- Whitespaces (' ') will be removed from the beginnig of
- the parsed value.
-
- @param str A string to parse
- @param delim a delimiter to use while splitting into key,value
- @param next next pair node in the linked list
-
- @returns A newly crated hpair_t object. Use hpair_free()
- or hpair_free_deep() to free the pair.
-*/
-hpair_t *hpairnode_parse(const char *str, const char *delim, hpair_t * next);
-
+ *
+ * Creates a new pair from a given string. This function will split 'str' with
+ * the found first delimiter 'delim'. The 'value' field of the newly created
+ * pair will have the value "", if no delimiter was found/ Whitespaces (' ') will
+ * be removed from the beginnig of the parsed value.
+ *
+ * @param str A string to parse
+ * @param delim a delimiter to use while splitting into key,value
+ * @param next next pair node in the linked list
+ *
+ * @returns A newly crated hpair_t object. Use hpair_free() or hpair_free_deep()
+ * to free the pair.
+ *
+ */
+extern hpair_t *hpairnode_parse(const char *str, const char *delim, hpair_t * next);
/**
- Frees a given pair.
-
- @param pair the pair to free
-*/
-void hpairnode_free(hpair_t * pair);
-
+ *
+ * Frees a given pair.
+ *
+ * @param pair the pair to free
+ *
+ */
+extern void hpairnode_free(hpair_t * pair);
/**
- Makes a deep free operation. All pairnodes,
- beginning with the given pari, in the
- linked list will be destroyed.
-
- @param pair the pair to start to free the linked list
-*/
-void hpairnode_free_deep(hpair_t * pair);
-
+ *
+ * Makes a deep free operation. All pairnodes, beginning with the given pari, in
+ * the linked list will be destroyed.
+ *
+ * @param pair the pair to start to free the linked list
+ *
+ */
+extern void hpairnode_free_deep(hpair_t * pair);
/**
- Returns the (key,value) pair, which key is the
- given 'key'.
-
- @param pair the first pair to start to search from.
- @param key key to find the in the pair.
- @returns if a value will be found, this function will
- return the value (do not free this string) or NULL
- if no pair was found with the key 'key'.
-*/
-char *hpairnode_get(hpair_t * pair, const char *key);
-
+ *
+ * Returns the (key,value) pair, which key is the given 'key'.
+ *
+ * @param pair the first pair to start to search from.
+ * @param key key to find the in the pair.
+ * @returns if a value will be found, this function will
+ *
+ * @return the value (do not free this string) or NULL if no pair was found with
+ * the key 'key'.
+ *
+ */
+extern char *hpairnode_get(hpair_t * pair, const char *key);
/**
- Returns the (key,value) pair, which key is the
- given 'key'. The case will be ignored while
- comparing the key strings.
-
- @param pair the first pair to start to search from.
- @param key key to find the in the pair.
- @returns if a value will be found, this function will
- return the value (do not free this string) or NULL
- if no pair was found with the key 'key'.
-*/
-char *hpairnode_get_ignore_case(hpair_t * pair, const char *key);
-
+ *
+ * Returns the (key,value) pair, which key is the given 'key'. The case will be
+ * ignored while comparing the key strings.
+ *
+ * @param pair the first pair to start to search from.
+ * @param key key to find the in the pair.
+ * @returns if a value will be found, this function will
+ *
+ * @return the value (do not free this string) or NULL if no pair was found with
+ * the key 'key'.
+ *
+ */
+extern char *hpairnode_get_ignore_case(hpair_t * pair, const char *key);
/**
- This function will create a new pair and fills the
- (key,value) fields of a given pair. Note that the 'next'
- field will not be copied.
-
- @param src the source pair object to copy.
-
- @returns a newly created pair with the same (key,value)
- pairs as in 'src'. This fields will be cloned. The'next'
- field will be set to NULL.
-
- @see hpairnode_copy_deep
-*/
-hpair_t *hpairnode_copy(const hpair_t * src);
-
+ *
+ * This function will create a new pair and fills the (key,value) fields of a
+ * given pair. Note that the 'next' field will not be copied.
+ *
+ * @param src the source pair object to copy.
+ *
+ * @returns a newly created pair with the same (key,value) pairs as in 'src'.
+ * This fields will be cloned. The'next' field will be set to NULL.
+ *
+ * @see hpairnode_copy_deep
+ *
+ */
+extern hpair_t *hpairnode_copy(const hpair_t * src);
/**
- Clones the hole linked list.
-
- @param src the source pair object to copy from
-
- @returns the first object in the linked list.
-
- @see hpairnode_copy
-*/
-hpair_t *hpairnode_copy_deep(const hpair_t * src);
-
-/* Debug functions */
-void hpairnode_dump_deep(hpair_t * pair);
-void hpairnode_dump(hpair_t * pair);
+ *
+ * Clones the hole linked list.
+ *
+ * @param src the source pair object to copy from
+ *
+ * @return the first object in the linked list.
+ *
+ * @see hpairnode_copy
+ *
+ */
+extern hpair_t *hpairnode_copy_deep(const hpair_t * src);
/**
- The protocol types in enumeration
- format. Used in some other nanohttp objects
- like hurl_t.
+ *
+ * Debug functions
+ *
+ */
+extern void hpairnode_dump_deep(hpair_t * pair);
+extern void hpairnode_dump(hpair_t * pair);
- @see hurl_t
-*/
+/**
+ *
+ * The protocol types in enumeration format. Used in some other nanohttp objects
+ * like hurl_t.
+ *
+ * @see hurl_t
+ *
+ */
typedef enum _hprotocol
{
PROTOCOL_HTTP,
@@ -337,12 +380,14 @@ typedef enum _hprotocol
/**
- The URL object. A representation
- of an URL like:<P>
-
- [protocol]://[host]:[port]/[context]
-
-*/
+ *
+ * The URL object. A representation of an URL like:
+ *
+ * [protocol]://[host]:[port]/[context]
+ *
+ * @see http://www.ietf.org/rfc/rfc2396.txt
+ *
+ */
typedef struct _hurl
{
/**
@@ -367,62 +412,64 @@ typedef struct _hurl
char context[URL_MAX_CONTEXT_SIZE];
} hurl_t;
+/**
+ *
+ * Parses the given 'urlstr' and fills the given hurl_t object.
+ *
+ * @param obj the destination URL object to fill
+ * @param url the URL in string format
+ *
+ * @returns H_OK on success or one of the following otherwise
+ * - URL_ERROR_UNKNOWN_PROTOCOL
+ * - URL_ERROR_NO_PROTOCOL
+ * - URL_ERROR_NO_HOST
+ *
+ */
+extern herror_t hurl_parse(hurl_t * obj, const char *url);
/**
- Parses the given 'urlstr' and fills the given hurl_t object.
-
- @param obj the destination URL object to fill
- @param url the URL in string format
-
- @returns H_OK on success or one of the following otherwise
-
- URL_ERROR_UNKNOWN_PROTOCOL
- URL_ERROR_NO_PROTOCOL
- URL_ERROR_NO_HOST
-*/
-herror_t hurl_parse(hurl_t * obj, const char *url);
-
-/*
- Object representation of the content-type field
- in a HTTP header:
- <P>
- Example:<P>
-
- text/xml; key="value" key2="value2' ...
-*/
+ *
+ * Object representation of the content-type field in a HTTP header:
+ *
+ * Example:
+ *
+ * text/xml; key="value" key2="value2' ...
+ *
+ */
typedef struct _content_type
{
char type[128];
hpair_t *params;
} content_type_t;
-
/**
- Parses the given string and creates a new ccontent_type_t
- object.
-
- @param content_type_str the string representation of the
- content-type field in a HTTP header.
-
- @returns A newly created content_type_t object. Free this
- object with content_type_free();
-
- @see content_type_free
-*/
-content_type_t *content_type_new(const char *content_type_str);
+ *
+ * Parses the given string and creates a new ccontent_type_t object.
+ *
+ * @param content_type_str the string representation of the content-type field in
+ * a HTTP header.
+ *
+ * @returns A newly created content_type_t object. Free this object with
+ * content_type_free();
+ *
+ * @see content_type_free
+ */
+extern content_type_t *content_type_new(const char *content_type_str);
/**
- Frees the given content_type_t object
-*/
-void content_type_free(content_type_t * ct);
-
-
+ *
+ * Frees the given content_type_t object
+ *
+ */
+extern void content_type_free(content_type_t * ct);
-/*
- part. Attachment
-*/
-typedef struct _part
+/**
+ *
+ * part. Attachment
+ *
+ */
+struct part_t
{
char id[250];
char location[250];
@@ -430,39 +477,38 @@ typedef struct _part
char content_type[128];
char transfer_encoding[128];
char filename[250];
- struct _part *next;
+ struct part_t *next;
int deleteOnExit; /* default is 0 */
-} part_t;
-
-
-part_t *part_new(const char *id, const char *filename,
- const char *content_type, const char *transfer_encoding,
- part_t * next);
-void part_free(part_t * part);
-
+};
+extern struct part_t *part_new(const char *id, const char *filename, const char *content_type, const char *transfer_encoding, struct part_t * next);
+extern void part_free(struct part_t * part);
-/*
- Attachments
-*/
-typedef struct _attachments
+/**
+ *
+ * Attachments
+ *
+ */
+struct attachments_t
{
- part_t *parts;
- part_t *last;
- part_t *root_part;
-} attachments_t;
-
-attachments_t *attachments_new(void); /* should be used internally */
+ struct part_t *parts;
+ struct part_t *last;
+ struct part_t *root_part;
+};
-/*
- Free a attachment. Create attachments with MIME
- and DIME (DIME is not supported yet).
+extern struct attachments_t *attachments_new(void); /* should be used internally */
- @see mime_get_attachments
-*/
-void attachments_free(attachments_t * message);
-void attachments_add_part(attachments_t * attachments, part_t * part);
+/**
+ *
+ * Free a attachment. Create attachments with MIME and DIME (DIME is not
+ * supported yet).
+ *
+ * @see mime_get_attachments
+ *
+ */
+extern void attachments_free(struct attachments_t * message);
+extern void attachments_add_part(struct attachments_t * attachments, struct part_t * part);
#ifdef __cplusplus
}
diff --git a/nanohttp/nanohttp-error.h b/nanohttp/nanohttp-error.h
new file mode 100644
index 0000000..57b6634
--- /dev/null
+++ b/nanohttp/nanohttp-error.h
@@ -0,0 +1,102 @@
+/******************************************************************
+ * $Id: nanohttp-error.h,v 1.1 2006/11/25 15:06:58 m0gg Exp $
+ *
+ * CSOAP Project: A http client/server library in C
+ * Copyright (C) 2003-2004 Ferhat Ayaz
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Email: ferhatayaz@yahoo.com
+ ******************************************************************/
+#ifndef __nanohttp_error_h
+#define __nanohttp_error_h
+
+/* Success flag */
+#define H_OK 0
+
+/* Socket errors */
+#define HSOCKET_ERROR_CREATE 1001
+#define HSOCKET_ERROR_GET_HOSTNAME 1002
+#define HSOCKET_ERROR_CONNECT 1003
+#define HSOCKET_ERROR_SEND 1004
+#define HSOCKET_ERROR_RECEIVE 1005
+#define HSOCKET_ERROR_BIND 1006
+#define HSOCKET_ERROR_LISTEN 1007
+#define HSOCKET_ERROR_ACCEPT 1008
+#define HSOCKET_ERROR_NOT_INITIALIZED 1009
+#define HSOCKET_ERROR_IOCTL 1010
+#define HSOCKET_ERROR_SSLCLOSE 1011
+#define HSOCKET_ERROR_SSLCTX 1011
+
+/* URL errors */
+#define URL_ERROR_UNKNOWN_PROTOCOL 1101
+#define URL_ERROR_NO_PROTOCOL 1102
+#define URL_ERROR_NO_HOST 1103
+
+/* Stream errors */
+#define STREAM_ERROR_INVALID_TYPE 1201
+#define STREAM_ERROR_SOCKET_ERROR 1202
+#define STREAM_ERROR_NO_CHUNK_SIZE 1203
+#define STREAM_ERROR_WRONG_CHUNK_SIZE 1204
+
+/* MIME errors */
+#define MIME_ERROR_NO_BOUNDARY_PARAM 1301
+#define MIME_ERROR_NO_START_PARAM 1302
+#define MIME_ERROR_PARSE_ERROR 1303
+#define MIME_ERROR_NO_ROOT_PART 1304
+#define MIME_ERROR_NOT_MIME_MESSAGE 1305
+
+/* General errors */
+#define GENERAL_INVALID_PARAM 1400
+#define GENERAL_HEADER_PARSE_ERROR 1401
+
+/* Thread errors */
+#define THREAD_BEGIN_ERROR 1500
+
+/* XML Errors */
+#define XML_ERROR_EMPTY_DOCUMENT 1600
+#define XML_ERROR_PARSE 1601
+
+/* SSL Errors */
+#define HSSL_ERROR_CA_LIST 1710
+#define HSSL_ERROR_CONTEXT 1720
+#define HSSL_ERROR_CERTIFICATE 1730
+#define HSSL_ERROR_PEM 1740
+#define HSSL_ERROR_CLIENT 1750
+#define HSSL_ERROR_SERVER 1760
+#define HSSL_ERROR_CONNECT 1770
+
+/* File errors */
+#define FILE_ERROR_OPEN 8000
+#define FILE_ERROR_READ 8001
+
+typedef void *herror_t;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern herror_t herror_new(const char *func, int errcode, const char *format, ...);
+extern int herror_code(herror_t err);
+extern char *herror_func(herror_t err);
+extern char *herror_message(herror_t err);
+extern void herror_release(herror_t err);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/nanohttp/nanohttp-mime.c b/nanohttp/nanohttp-mime.c
index 1736e3b..05694c6 100755
--- a/nanohttp/nanohttp-mime.c
+++ b/nanohttp/nanohttp-mime.c
@@ -3,7 +3,7 @@
* | \/ | | | | \/ | | _/
* |_''_| |_| |_''_| |_'/ PARSER
*
-* $Id: nanohttp-mime.c,v 1.16 2006/11/23 15:27:33 m0gg Exp $
+* $Id: nanohttp-mime.c,v 1.17 2006/11/25 15:06:58 m0gg Exp $
*
* CSOAP Project: A http client/server library in C
* Copyright (C) 2003-2004 Ferhat Ayaz
@@ -41,6 +41,10 @@
#include <string.h>
#endif
+#ifdef HAVE_ERRNO_H
+#include <errno.h>
+#endif
+
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
@@ -49,11 +53,12 @@
Buffered Reader. A helper object to read bytes from a source
----------------------------------------------------------------*/
+#include "nanohttp-logging.h"
+#include "nanohttp-error.h"
#include "nanohttp-common.h"
#include "nanohttp-socket.h"
#include "nanohttp-stream.h"
#include "nanohttp-mime.h"
-#include "nanohttp-logging.h"
/* ------------------------------------------------------------------
@@ -475,9 +480,6 @@ MIME_parse(MIME_read_function reader_function,
} /* while (1) */
}
-
-
-
MIME_read_status
MIME_filereader_function(void *userdata, unsigned char *dest, int *size)
{
@@ -501,8 +503,8 @@ MIME_filereader_function(void *userdata, unsigned char *dest, int *size)
typedef struct _mime_callback_data
{
int part_id;
- attachments_t *message;
- part_t *current_part;
+ struct attachments_t *message;
+ struct part_t *current_part;
int buffer_capacity;
char header[4064];
char root_id[256];
@@ -513,7 +515,6 @@ typedef struct _mime_callback_data
} mime_callback_data_t;
-
MIME_read_status
mime_streamreader_function(void *userdata, unsigned char *dest, int *size)
{
@@ -568,11 +569,16 @@ static void
_mime_part_begin(void *data)
{
char buffer[1054];
- mime_callback_data_t *cbdata = (mime_callback_data_t *) data;
- part_t *part;
-
+ struct part_t *part;
+ mime_callback_data_t *cbdata;
+
+ cbdata = (mime_callback_data_t *) data;
log_verbose2("Begin Part (%p)", data);
- part = (part_t *) malloc(sizeof(part_t));
+ if (!(part = (struct part_t *) malloc(sizeof(struct part_t))))
+ {
+ log_error2("malloc failed (%s)", strerror(errno));
+ return;
+ }
part->next = NULL;
@@ -798,16 +804,21 @@ _mime_received_bytes(void *data, const unsigned char *bytes, int size)
The mime message parser
*/
-attachments_t *
+struct attachments_t *
mime_message_parse(struct http_input_stream_t * in, const char *root_id,
const char *boundary, const char *dest_dir)
{
MIME_parser_status status;
MIME_callbacks callbacks;
- attachments_t *message;
+ struct attachments_t *message;
- mime_callback_data_t *cbdata = (mime_callback_data_t *)
- malloc(sizeof(mime_callback_data_t));
+ mime_callback_data_t *cbdata;
+
+ if (!(cbdata = (mime_callback_data_t *) malloc(sizeof(mime_callback_data_t))))
+ {
+ log_error2("malloc failed (%s)", strerror(errno));
+ return NULL;
+ }
cbdata->part_id = 100;
cbdata->buffer_capacity = 0;
@@ -817,7 +828,13 @@ mime_message_parse(struct http_input_stream_t * in, const char *root_id,
cbdata->header_search = 0;
strcpy(cbdata->root_id, root_id);
strcpy(cbdata->root_dir, dest_dir);
- message = (attachments_t *) malloc(sizeof(attachments_t));
+
+ if (!(message = (struct attachments_t *) malloc(sizeof(struct attachments_t))))
+ {
+ log_error2("malloc failed (%s)", strerror(errno));
+ free(cbdata);
+ return NULL;
+ }
cbdata->message = message;
cbdata->message->parts = NULL;
cbdata->message->root_part = NULL;
@@ -845,16 +862,21 @@ mime_message_parse(struct http_input_stream_t * in, const char *root_id,
}
}
-attachments_t *
+struct attachments_t *
mime_message_parse_from_file(FILE * in, const char *root_id,
const char *boundary, const char *dest_dir)
{
MIME_parser_status status;
MIME_callbacks callbacks;
- attachments_t *message;
+ struct attachments_t *message;
- mime_callback_data_t *cbdata = (mime_callback_data_t *)
- malloc(sizeof(mime_callback_data_t));
+ mime_callback_data_t *cbdata;
+
+ if (!(cbdata = (mime_callback_data_t *) malloc(sizeof(mime_callback_data_t))))
+ {
+ log_error2("malloc failed (%s)", strerror(errno));
+ return NULL;
+ }
cbdata->part_id = 100;
cbdata->buffer_capacity = 0;
@@ -864,7 +886,14 @@ mime_message_parse_from_file(FILE * in, const char *root_id,
cbdata->header_search = 0;
strcpy(cbdata->root_id, root_id);
strcpy(cbdata->root_dir, dest_dir);
- message = (attachments_t *) malloc(sizeof(attachments_t));
+
+ if (!(message = (struct attachments_t *) malloc(sizeof(struct attachments_t))))
+ {
+ log_error2("malloc failed (%s)", strerror(errno));
+ free(cbdata);
+ return NULL;
+ }
+
cbdata->message = message;
cbdata->message->parts = NULL;
cbdata->message->root_part = NULL;
@@ -897,11 +926,11 @@ mime_message_parse_from_file(FILE * in, const char *root_id,
herror_t
mime_get_attachments(content_type_t * ctype, struct http_input_stream_t * in,
- attachments_t ** dest)
+ struct attachments_t ** dest)
{
/* MIME variables */
- attachments_t *mimeMessage;
- part_t *part, *tmp_part = NULL;
+ struct attachments_t *mimeMessage;
+ struct part_t *part, *tmp_part = NULL;
char *boundary, *root_id;
/* Check for MIME message */
diff --git a/nanohttp/nanohttp-mime.h b/nanohttp/nanohttp-mime.h
index 655c7e2..d6ce17d 100755
--- a/nanohttp/nanohttp-mime.h
+++ b/nanohttp/nanohttp-mime.h
@@ -3,7 +3,7 @@
* | \/ | | | | \/ | | _/
* |_''_| |_| |_''_| |_'/ PARSER
*
-* $Id: nanohttp-mime.h,v 1.10 2006/11/23 15:27:33 m0gg Exp $
+* $Id: nanohttp-mime.h,v 1.11 2006/11/25 15:06:58 m0gg Exp $
*
* CSOAP Project: A http client/server library in C
* Copyright (C) 2003-2004 Ferhat Ayaz
@@ -37,7 +37,7 @@ extern "C" {
"multipart/related" MIME Message Builder
------------------------------------------------------------------*/
-extern herror_t mime_get_attachments(content_type_t * ctype, struct http_input_stream_t * in, attachments_t ** dest);
+extern herror_t mime_get_attachments(content_type_t * ctype, struct http_input_stream_t * in, struct attachments_t ** dest);
#ifdef __cplusplus
}
diff --git a/nanohttp/nanohttp-request.c b/nanohttp/nanohttp-request.c
index 0fd1d7e..4572e2c 100755
--- a/nanohttp/nanohttp-request.c
+++ b/nanohttp/nanohttp-request.c
@@ -1,5 +1,5 @@
/******************************************************************
-* $Id: nanohttp-request.c,v 1.18 2006/11/23 15:27:33 m0gg Exp $
+* $Id: nanohttp-request.c,v 1.19 2006/11/25 15:06:58 m0gg Exp $
*
* CSOAP Project: A http client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -50,6 +50,7 @@
#endif
#include "nanohttp-logging.h"
+#include "nanohttp-error.h"
#include "nanohttp-common.h"
#include "nanohttp-socket.h"
#include "nanohttp-stream.h"
@@ -275,7 +276,7 @@ hrequest_new_from_socket(struct hsocket_t *sock, struct hrequest_t ** out)
herror_t status;
struct hrequest_t *req;
char buffer[MAX_HEADER_SIZE + 1];
- attachments_t *mimeMessage;
+ struct attachments_t *mimeMessage;
memset(buffer, 0, MAX_HEADER_SIZE);
/* Read header */
diff --git a/nanohttp/nanohttp-request.h b/nanohttp/nanohttp-request.h
index 2234e99..d1d599b 100755
--- a/nanohttp/nanohttp-request.h
+++ b/nanohttp/nanohttp-request.h
@@ -1,5 +1,5 @@
/******************************************************************
- * $Id: nanohttp-request.h,v 1.10 2006/11/23 15:27:33 m0gg Exp $
+ * $Id: nanohttp-request.h,v 1.11 2006/11/25 15:06:58 m0gg Exp $
*
* CSOAP Project: A http client/server library in C
* Copyright (C) 2003-2004 Ferhat Ayaz
@@ -31,27 +31,226 @@
* 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 RFC2616).
+ * programming language method invocation.
+ *
+ * @see http://www.ietf.org/rfc/rfc2616.txt
+ *
+ */
+
+/**
+ *
+ * The Accept request-header field can be used to specify certain media types
+ * which are acceptable for the response. Accept headers can be used to indicate
+ * that the request is specifically limited to a small set of desired types, as
+ * in the case of a request for an in-line image.
*
*/
#define HEADER_ACCEPT "Accept"
-#define HEADER_CHARSET "Accept-Charset"
+
+/**
+ *
+ * The Accept-Charset request-header field can be used to indicate what character
+ * sets are acceptable for the response. This field allows clients capable of
+ * understanding more comprehensive or special-purpose character sets to signal
+ * that capability to a server which is capable of representing documents in
+ * those character sets.
+ *
+ */
+#define HEADER_ACCEPT_CHARSET "Accept-Charset"
+
+/**
+ *
+ * The Accept-Encoding request-header field is similar to Accept, but restricts
+ * the content-codings (section 3.5) that are acceptable in the response.
+ *
+ */
#define HEADER_ACCEPT_ENCODING "Accept-Encoding"
+
+/**
+ *
+ * The Accept-Language request-header field is similar to Accept, but restricts
+ * the set of natural languages that are preferred as a response to the request.
+ *
+ */
#define HEADER_ACCEPT_LANGUAGE "Accept-Language"
+
+/**
+ *
+ * A user agent that wishes to authenticate itself with a server -- usually, but
+ * not necessarily, after receiving a 401 response -- does so by including an
+ * Authorization request-header field with the request. The Authorization field
+ * value consists of credentials containing the authentication information of the
+ * user agent for the realm of the resource being requested.
+ *
+ */
#define HEADER_AUTHORIZATION "Authorization"
+
+/**
+ *
+ * The Expect request-header field is used to indicate that particular server
+ * behaviors are required by the client.
+ *
+ */
#define HEADER_EXPECT "Expect"
+
+/**
+ *
+ * The From request-header field, if given, SHOULD contain an Internet e-mail
+ * address for the human user who controls the requesting user agent. The
+ * address SHOULD be machine-usable, as defined by "mailbox" in RFC 822 as
+ * updated by RFC 1123.
+ *
+ * @see http://www.ietf.org/rfc/rfc1123.txt,
+ * http://www.ietf.org/rfc/rfc822.txt
+ *
+ */
#define HEADER_FROM "From"
+
+/**
+ *
+ * The Host request-header field specifies the Internet host and port number of
+ * the resource being requested, as obtained from the original URI given by the
+ * user or referring resource (generally an HTTP URL, as described in section
+ * 3.2.2). The Host field value MUST represent the naming authority of the origin
+ * server or gateway given by the original URL. This allows the origin server or
+ * gateway to differentiate between internally-ambiguous URLs, such as the root
+ * "/" URL of a server for multiple host names on a single IP address.
+ *
+ */
#define HEADER_HOST "Host"
+
+/**
+ *
+ * The If-Match request-header field is used with a method to make it
+ * conditional. A client that has one or more entities previously obtained from
+ * the resource can verify that one of those entities is current by including a
+ * list of their associated entity tags in the If-Match header field. Entity tags
+ * are defined in section 3.11. The purpose of this feature is to allow efficient
+ * updates of cached information with a minimum amount of transaction overhead.
+ * It is also used, on updating requests, to prevent inadvertent modification of
+ * the wrong version of a resource. As a special case, the value "*" matches any
+ * current entity of the resource.
+ *
+ */
#define HEADER_IF_MATCH "If-Match"
+
+/**
+ *
+ * The If-Modified-Since request-header field is used with a method to make it
+ * conditional: if the requested variant has not been modified since the time
+ * specified in this field, an entity will not be returned from the server;
+ * instead, a 304 (not modified) response will be returned without any
+ * message-body.
+ *
+ */
#define HEADER_IF_MODIFIED_SINCE "If-Modified-Since"
+
+/**
+ *
+ * The If-None-Match request-header field is used with a method to make it
+ * conditional. A client that has one or more entities previously obtained from
+ * the resource can verify that none of those entities is current by including a
+ * list of their associated entity tags in the If-None-Match header field. The
+ * purpose of this feature is to allow efficient updates of cached information
+ * with a minimum amount of transaction overhead. It is also used to prevent a
+ * method (e.g. PUT) from inadvertently modifying an existing resource when the
+ * client believes that the resource does not exist.
+ *
+ */
#define HEADER_IF_NONE_MATCH "If-None-Match"
+
+/**
+ *
+ * If a client has a partial copy of an entity in its cache, and wishes to have
+ * an up-to-date copy of the entire entity in its cache, it could use the Range
+ * request-header with a conditional GET (using either or both of
+ * If-Unmodified-Since and If-Match.) However, if the condition fails because the
+ * entity has been modified, the client would then have to make a second request
+ * to obtain the entire current entity-body.
+ *
+ */
#define HEADER_IF_RANGE "If-Range"
+
+/**
+ *
+ * The If-Unmodified-Since request-header field is used with a method to make it
+ * conditional. If the requested resource has not been modified since the time
+ * specified in this field, the server SHOULD perform the requested operation as
+ * if the If-Unmodified-Since header were not present.
+ *
+ */
#define HEADER_IF_UNMODIFIED_SINCE "If-Unmodified-Since"
+
+/**
+ *
+ * The Max-Forwards request-header field provides a mechanism with the TRACE
+ * (section 9.8) and OPTIONS (section 9.2) methods to limit the number of
+ * proxies or gateways that can forward the request to the next inbound server.
+ * This can be useful when the client is attempting to trace a request chain
+ * which appears to be failing or looping in mid-chain.
+ *
+ */
#define HEADER_IF_MAX_FORWARDS "Max-Forwards"
+
+/**
+ *
+ * The Proxy-Authorization request-header field allows the client to identify
+ * itself (or its user) to a proxy which requires authentication. The
+ * Proxy-Authorization field value consists of credentials containing the
+ * authentication information of the user agent for the proxy and/or realm of
+ * the resource being requested.
+ *
+ */
#define HEADER_PROXY_AUTHORIZATION "Proxy-Authorization"
+
+/**
+ *
+ * HTTP retrieval requests using conditional or unconditional GET methods MAY
+ * request one or more sub-ranges of the entity, instead of the entire entity,
+ * using the Range request header, which applies to the entity returned as the
+ * result of the request
+ *
+ */
#define HEADER_RANGE "Range"
+
+/**
+ *
+ * The Referer[sic] request-header field allows the client to specify, for the
+ * server's benefit, the address (URI) of the resource from which the Request-URI
+ * was obtained (the "referrer", although the header field is misspelled.) The
+ * Referer request-header allows a server to generate lists of back-links to
+ * resources for interest, logging, optimized caching, etc. It also allows
+ * obsolete or mistyped links to be traced for maintenance. The Referer field
+ * MUST NOT be sent if the Request-URI was obtained from a source that does not
+ * have its own URI, such as input from the user keyboard.
+ *
+ */
#define HEADER_REFERER "Referer"
+
+/**
+ *
+ * The TE request-header field indicates what extension transfer-codings it is
+ * willing to accept in the response and whether or not it is willing to accept
+ * trailer fields in a chunked transfer-coding. Its value may consist of the
+ * keyword "trailers" and/or a comma-separated list of extension transfer-coding
+ * names with optional accept parameters.
+ *
+ */
#define HEADER_TRANSFER_EXTENSION "TE"
+
+/**
+ *
+ * The User-Agent request-header field contains information about the user agent
+ * originating the request. This is for statistical purposes, the tracing of
+ * protocol violations, and automated recognition of user agents for the sake of
+ * tailoring responses to avoid particular user agent limitations. User agents
+ * SHOULD include this field with requests. The field can contain multiple
+ * product tokens (section 3.8) and comments identifying the agent and any
+ * subproducts which form a significant part of the user agent. By convention,
+ * the product tokens are listed in order of their significance for identifying
+ * the application.
+ *
+ */
#define HEADER_USER_AGENT "User-Agent"
#ifdef __NHTTP_INTERNAL
@@ -63,8 +262,10 @@ struct request_statistics
};
#endif
-/*
- request object
+/**
+ *
+ * HTTP request object
+ *
*/
struct hrequest_t
{
@@ -79,7 +280,7 @@ struct hrequest_t
struct http_input_stream_t *in;
content_type_t *content_type;
- attachments_t *attachments;
+ struct attachments_t *attachments;
char root_part_id[150];
};
@@ -88,8 +289,8 @@ extern "C" {
#endif
#ifdef __NHTTP_INTERNAL
-herror_t hrequest_new_from_socket(struct hsocket_t *sock, struct hrequest_t **out);
-void hrequest_free(struct hrequest_t *req);
+extern herror_t hrequest_new_from_socket(struct hsocket_t *sock, struct hrequest_t **out);
+extern void hrequest_free(struct hrequest_t *req);
#endif
#ifdef __cplusplus
diff --git a/nanohttp/nanohttp-response.c b/nanohttp/nanohttp-response.c
index ad8c4a1..c239eb4 100755
--- a/nanohttp/nanohttp-response.c
+++ b/nanohttp/nanohttp-response.c
@@ -1,5 +1,5 @@
/******************************************************************
-* $Id: nanohttp-response.c,v 1.14 2006/11/23 15:27:33 m0gg Exp $
+* $Id: nanohttp-response.c,v 1.15 2006/11/25 15:06:58 m0gg Exp $
*
* CSOAP Project: A http client/server library in C
* Copyright (C) 2003-2004 Ferhat Ayaz
@@ -46,6 +46,7 @@
#endif
#include "nanohttp-logging.h"
+#include "nanohttp-error.h"
#include "nanohttp-common.h"
#include "nanohttp-socket.h"
#include "nanohttp-stream.h"
@@ -57,10 +58,11 @@ hresponse_new(void)
{
hresponse_t *res;
- if (!(res = (hresponse_t *) malloc(sizeof(hresponse_t)))) {
+ if (!(res = (hresponse_t *) malloc(sizeof(hresponse_t))))
+ {
- log_error2("malloc failed (%s)", strerror(errno));
- return NULL;
+ log_error2("malloc failed (%s)", strerror(errno));
+ return NULL;
}
res->version = HTTP_1_1;
@@ -159,7 +161,7 @@ hresponse_new_from_socket(struct hsocket_t *sock, hresponse_t ** out)
int i = 0, count;
herror_t status;
hresponse_t *res;
- attachments_t *mimeMessage;
+ struct attachments_t *mimeMessage;
char buffer[MAX_HEADER_SIZE + 1];
read_header: /* for errorcode: 100 (continue) */
diff --git a/nanohttp/nanohttp-response.h b/nanohttp/nanohttp-response.h
index 553d69f..edc48fc 100755
--- a/nanohttp/nanohttp-response.h
+++ b/nanohttp/nanohttp-response.h
@@ -1,5 +1,5 @@
/******************************************************************
- * $Id: nanohttp-response.h,v 1.9 2006/11/23 15:27:33 m0gg Exp $
+ * $Id: nanohttp-response.h,v 1.10 2006/11/25 15:06:58 m0gg Exp $
*
* CSOAP Project: A http client/server library in C
* Copyright (C) 2003-2004 Ferhat Ayaz
@@ -36,17 +36,126 @@
* @see http://www.ietf.org/rfc/rfc2616.txt
*
*/
+
+/**
+ *
+ * The Accept-Ranges response-header field allows the server to indicate its
+ * acceptance of range requests for a resource
+ *
+ */
#define HEADER_ACCEPT_RANGES "Accept-Ranges"
+
+/**
+ *
+ * The Age response-header field conveys the sender's estimate of the amount of
+ * time since the response (or its revalidation) was generated at the origin
+ * server. A cached response is "fresh" if its age does not exceed its freshness
+ * lifetime.
+ *
+ */
#define HEADER_AGE "Age"
+
+/**
+ *
+ * The ETag response-header field provides the current value of the entity tag
+ * for the requested variant. The headers used with entity tags are described in
+ * RFC 2616 sections 14.24, 14.26 and 14.44. The entity tag MAY be used for
+ * comparison with other entities from the same resource
+ *
+ * @see http://www.ietf.org/rfc/rfc/2616.txt
+ *
+ */
#define HEADER_EXTENSION_TAG "ETag"
+
+/**
+ *
+ * The Location response-header field is used to redirect the recipient to a
+ * location other than the Request-URI for completion of the request or
+ * identification of a new resource. For 201 (Created) responses, the Location
+ * is that of the new resource which was created by the request. For 3xx
+ * responses, the location SHOULD indicate the server's preferred URI for
+ * automatic redirection to the resource. The field value consists of a single
+ * absolute URI.
+ *
+ */
#define HEADER_LOCATION "Location"
+
+/**
+ *
+ * The Proxy-Authenticate response-header field MUST be included as part of a
+ * 407 (Proxy Authentication Required) response. The field value consists of a
+ * challenge that indicates the authentication scheme and parameters applicable
+ * to the proxy for this Request-URI.
+ *
+ */
#define HEADER_PROXY_AUTHENTICATE "Proxy-Authenticate"
+
+/**
+ *
+ * The Retry-After response-header field can be used with a 503 (Service
+ * Unavailable) response to indicate how long the service is expected to be
+ * unavailable to the requesting client. This field MAY also be used with any
+ * 3xx (Redirection) response to indicate the minimum time the user-agent is
+ * asked wait before issuing the redirected request. The value of this field
+ * can be either an HTTP-date or an integer number of seconds (in decimal) after
+ * the time of the response.
+ *
+ */
#define HEADER_RETRY_AFTER "Retry-After"
+
+/**
+ *
+ * The Server response-header field contains information about the software used
+ * by the origin server to handle the request. The field can contain multiple
+ * product tokens (section 3.8) and comments identifying the server and any
+ * significant subproducts. The product tokens are listed in order of their
+ * significance for identifying the application.
+ *
+ */
#define HEADER_SERVER "Server"
+
+/**
+ *
+ * The Vary field value indicates the set of request-header fields that fully
+ * determines, while the response is fresh, whether a cache is permitted to use
+ * the response to reply to a subsequent request without revalidation. For
+ * uncacheable or stale responses, the Vary field value advises the user agent
+ * about the criteria that were used to select the representation. A Vary field
+ * value of "*" implies that a cache cannot determine from the request headers of
+ * a subsequent request whether this response is the appropriate representation.
+ * See RFC 2616 section 13.6 for use of the Vary header field by caches.
+ *
+ * @see http://www.ietf.org/rfc/rfc2616.txt
+ *
+ */
#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.
+ *
+ * WWW-Authenticate = "WWW-Authenticate" ":" 1#challenge
+ *
+ * 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.
+ *
+ * @see http://www.ietf.org/rfc/rfc2617.txt
+ *
+ */
#define HEADER_WWW_AUTHENTICATE "WWW-Authenticate"
-/* response object */
+/**
+ *
+ * HTTP response object
+ *
+ */
typedef struct hresponse
{
http_version_t version;
@@ -57,7 +166,7 @@ typedef struct hresponse
struct http_input_stream_t *in;
content_type_t *content_type;
- attachments_t *attachments;
+ struct attachments_t *attachments;
char root_part_id[150];
} hresponse_t;
@@ -66,8 +175,8 @@ extern "C" {
#endif
#ifdef __NHTTP_INTERNAL
-herror_t hresponse_new_from_socket(struct hsocket_t *sock, hresponse_t ** out);
-void hresponse_free(hresponse_t * res);
+extern herror_t hresponse_new_from_socket(struct hsocket_t *sock, hresponse_t **out);
+extern void hresponse_free(hresponse_t * res);
#endif
#ifdef __cplusplus
diff --git a/nanohttp/nanohttp-server.c b/nanohttp/nanohttp-server.c
index f9e56fb..e79e448 100644
--- a/nanohttp/nanohttp-server.c
+++ b/nanohttp/nanohttp-server.c
@@ -1,5 +1,5 @@
/******************************************************************
-* $Id: nanohttp-server.c,v 1.66 2006/11/24 10:54:03 m0gg Exp $
+* $Id: nanohttp-server.c,v 1.67 2006/11/25 15:06:58 m0gg Exp $
*
* CSOAP Project: A http client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -78,6 +78,7 @@
#endif
#include "nanohttp-logging.h"
+#include "nanohttp-error.h"
#include "nanohttp-common.h"
#include "nanohttp-socket.h"
#include "nanohttp-stream.h"
diff --git a/nanohttp/nanohttp-socket.c b/nanohttp/nanohttp-socket.c
index 9936379..c5c4b98 100644
--- a/nanohttp/nanohttp-socket.c
+++ b/nanohttp/nanohttp-socket.c
@@ -1,5 +1,5 @@
/******************************************************************
-* $Id: nanohttp-socket.c,v 1.63 2006/11/23 15:27:33 m0gg Exp $
+* $Id: nanohttp-socket.c,v 1.64 2006/11/25 15:06:58 m0gg Exp $
*
* CSOAP Project: A http client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -79,10 +79,12 @@ typedef int ssize_t;
#endif
+#include "nanohttp-error.h"
+#include "nanohttp-logging.h"
+
#include "nanohttp-common.h"
#include "nanohttp-socket.h"
#include "nanohttp-ssl.h"
-#include "nanohttp-logging.h"
#ifdef WIN32
static void
diff --git a/nanohttp/nanohttp-ssl.c b/nanohttp/nanohttp-ssl.c
index 8dbc948..7967bfb 100644
--- a/nanohttp/nanohttp-ssl.c
+++ b/nanohttp/nanohttp-ssl.c
@@ -1,5 +1,5 @@
/******************************************************************
-* $Id: nanohttp-ssl.c,v 1.30 2006/11/23 15:27:33 m0gg Exp $
+* $Id: nanohttp-ssl.c,v 1.31 2006/11/25 15:06:58 m0gg Exp $
*
* CSOAP Project: A http client/server library in C
* Copyright (C) 2001-2005 Rochester Institute of Technology
@@ -71,6 +71,7 @@
#endif
#endif
+#include "nanohttp-error.h"
#include "nanohttp-common.h"
#include "nanohttp-socket.h"
#include "nanohttp-logging.h"
diff --git a/nanohttp/nanohttp-stream.c b/nanohttp/nanohttp-stream.c
index 821c279..59888d1 100755
--- a/nanohttp/nanohttp-stream.c
+++ b/nanohttp/nanohttp-stream.c
@@ -1,5 +1,5 @@
/******************************************************************
-* $Id: nanohttp-stream.c,v 1.16 2006/11/24 17:28:07 m0gg Exp $
+* $Id: nanohttp-stream.c,v 1.17 2006/11/25 15:06:58 m0gg Exp $
*
* CSOAP Project: A http client/server library in C
* Copyright (C) 2003-2004 Ferhat Ayaz
@@ -45,9 +45,10 @@
#include <netinet/in.h>
#endif
+#include "nanohttp-logging.h"
+#include "nanohttp-error.h"
#include "nanohttp-common.h"
#include "nanohttp-socket.h"
-#include "nanohttp-logging.h"
#include "nanohttp-stream.h"
/*------------------------------------------------------------