summaryrefslogtreecommitdiffstats
path: root/nanohttp
diff options
context:
space:
mode:
authorGravatar m0gg2006-12-03 17:30:57 +0000
committerGravatar m0gg2006-12-03 17:30:57 +0000
commitc489665ace13d32f4959904b0215ed1021d0acf6 (patch)
tree7c9b3eb4d4d236a38e53be53d606c184b7192988 /nanohttp
parent60881bf7b91a87d12d0b2e694a6aa0db0b8b6fda (diff)
downloadcsoap-c489665ace13d32f4959904b0215ed1021d0acf6.tar.gz
csoap-c489665ace13d32f4959904b0215ed1021d0acf6.tar.bz2
Error codes moved
Diffstat (limited to 'nanohttp')
-rw-r--r--nanohttp/nanohttp-error.h119
-rwxr-xr-xnanohttp/nanohttp-mime.h25
-rw-r--r--nanohttp/nanohttp-socket.h21
-rw-r--r--nanohttp/nanohttp-ssl.h17
-rwxr-xr-xnanohttp/nanohttp-stream.h13
5 files changed, 132 insertions, 63 deletions
diff --git a/nanohttp/nanohttp-error.h b/nanohttp/nanohttp-error.h
index 642d6a0..0ceb162 100644
--- a/nanohttp/nanohttp-error.h
+++ b/nanohttp/nanohttp-error.h
@@ -1,5 +1,5 @@
/******************************************************************
- * $Id: nanohttp-error.h,v 1.2 2006/11/25 15:38:10 m0gg Exp $
+ * $Id: nanohttp-error.h,v 1.3 2006/12/03 17:30:57 m0gg Exp $
*
* CSOAP Project: A http client/server library in C
* Copyright (C) 2003-2004 Ferhat Ayaz
@@ -24,74 +24,87 @@
#ifndef __nanohttp_error_h
#define __nanohttp_error_h
-/* Success flag */
-#define H_OK 0
+/** @file
+ *
+ * nanoHTTP error handling
+ *
+ * Almost all function will return a "herror_t" object. If the function returns
+ * with success this object is H_OK. Another herror_t object will be returned
+ * otherwise. Following functions can be used with a returned herror_t object:
+ *
+ * - herror_code() - Returns the error code
+ * - herror_func() - Returns the function name, where the error occured
+ * - herror_message() - Returns the human readable error message
+ * - herror_release() - Frees the herror_t object.
+ *
+ * Example:
+ *
+ * herror_t err;
+ *
+ * if ((err = soap_client_invoke(...)) != H_OK)
+ * {
+ * printf("Message: %s\n", herror_message(err));
+ * printf("Error code: %d\n", herror_code(err));
+ * printf("In function: %s\n", herror_func(err));
+ * herror_release(err);
+ * }
+ *
+ * Note that you "must" call herror_release() to free the resources.
+ *
+ */
-/* Socket errors */
-#define HSOCKET_ERROR 1000
-#define HSOCKET_ERROR_CREATE (HSOCKET_ERROR + 1)
-#define HSOCKET_ERROR_GET_HOSTNAME (HSOCKET_ERROR + 2)
-#define HSOCKET_ERROR_CONNECT (HSOCKET_ERROR + 3)
-#define HSOCKET_ERROR_SEND (HSOCKET_ERROR + 4)
-#define HSOCKET_ERROR_RECEIVE (HSOCKET_ERROR + 5)
-#define HSOCKET_ERROR_BIND (HSOCKET_ERROR + 6)
-#define HSOCKET_ERROR_LISTEN (HSOCKET_ERROR + 7)
-#define HSOCKET_ERROR_ACCEPT (HSOCKET_ERROR + 8)
-#define HSOCKET_ERROR_NOT_INITIALIZED (HSOCKET_ERROR + 9)
-#define HSOCKET_ERROR_IOCTL (HSOCKET_ERROR + 10)
-#define HSOCKET_ERROR_SSLCLOSE (HSOCKET_ERROR + 11)
-#define HSOCKET_ERROR_SSLCTX (HSOCKET_ERROR + 11)
+/**
+ *
+ * Success flag
+ *
+ */
+#define H_OK 0
-/* URL errors */
+/**
+ *
+ * XXX: Move this to nanohttp-url.h
+ *
+ * URL errors
+ *
+ */
#define URL_ERROR 1100
#define URL_ERROR_UNKNOWN_PROTOCOL (URL_ERROR + 1)
#define URL_ERROR_NO_PROTOCOL (URL_ERROR + 2)
#define URL_ERROR_NO_HOST (URL_ERROR + 3)
-/* Stream errors */
-#define STREAM_ERROR 1200
-#define STREAM_ERROR_INVALID_TYPE (STREAM_ERROR + 1)
-#define STREAM_ERROR_SOCKET_ERROR (STREAM_ERROR + 2)
-#define STREAM_ERROR_NO_CHUNK_SIZE (STREAM_ERROR + 3)
-#define STREAM_ERROR_WRONG_CHUNK_SIZE (STREAM_ERROR + 4)
-
-/* MIME errors */
-#define MIME_ERROR 1300
-#define MIME_ERROR_NO_BOUNDARY_PARAM (MIME_ERROR + 1)
-#define MIME_ERROR_NO_START_PARAM (MIME_ERROR + 2)
-#define MIME_ERROR_PARSE_ERROR (MIME_ERROR + 3)
-#define MIME_ERROR_NO_ROOT_PART (MIME_ERROR + 4)
-#define MIME_ERROR_NOT_MIME_MESSAGE (MIME_ERROR + 5)
-
-/* General errors */
+/**
+ *
+ * General errors
+ *
+ */
#define GENERAL_ERROR 1400
#define GENERAL_INVALID_PARAM (GENERAL_ERROR + 1)
#define GENERAL_HEADER_PARSE_ERROR (GENERAL_ERROR + 2)
-/* Thread errors */
+/**
+ *
+ * Thread errors
+ *
+ */
#define THREAD_ERROR 1500
#define THREAD_BEGIN_ERROR (THREAD_ERROR)
-/* XML Errors */
-#define XML_ERROR 1600
-#define XML_ERROR_EMPTY_DOCUMENT (XML_ERROR + 1)
-#define XML_ERROR_PARSE (XML_ERROR + 2)
-
-/* SSL Errors */
-#define HSSL_ERROR 1700
-#define HSSL_ERROR_CA_LIST (HSSL_ERROR + 10)
-#define HSSL_ERROR_CONTEXT (HSSL_ERROR + 20)
-#define HSSL_ERROR_CERTIFICATE (HSSL_ERROR + 30)
-#define HSSL_ERROR_PEM (HSSL_ERROR + 40)
-#define HSSL_ERROR_CLIENT (HSSL_ERROR + 50)
-#define HSSL_ERROR_SERVER (HSSL_ERROR + 60)
-#define HSSL_ERROR_CONNECT (HSSL_ERROR + 70)
-
-/* File errors */
+/**
+ *
+ * File errors
+ *
+ */
#define FILE_ERROR 8000
#define FILE_ERROR_OPEN (FILE_ERROR + 1)
#define FILE_ERROR_READ (FILE_ERROR + 2)
+/**
+ *
+ * XXX: Remove me.
+ *
+ * Dummy deklaration to hide the implementation.
+ *
+ */
typedef void *herror_t;
#ifdef __cplusplus
@@ -100,7 +113,7 @@ extern "C" {
/**
*
- * Creates a new error struture.
+ * Creates a new error structure.
*
* @see printf
*
@@ -116,7 +129,7 @@ extern int herror_code(herror_t err);
/**
*
- * Returns the name of the function.
+ * Returns the name of the function, where the error was produced.
*
*/
extern const char *herror_func(herror_t err);
diff --git a/nanohttp/nanohttp-mime.h b/nanohttp/nanohttp-mime.h
index 894f6ce..b20a59b 100755
--- a/nanohttp/nanohttp-mime.h
+++ b/nanohttp/nanohttp-mime.h
@@ -3,7 +3,7 @@
* | \/ | | | | \/ | | _/
* |_''_| |_| |_''_| |_'/ PARSER
*
-* $Id: nanohttp-mime.h,v 1.12 2006/11/28 23:45:57 m0gg Exp $
+* $Id: nanohttp-mime.h,v 1.13 2006/12/03 17:30:57 m0gg Exp $
*
* CSOAP Project: A http client/server library in C
* Copyright (C) 2003-2004 Ferhat Ayaz
@@ -25,21 +25,32 @@
*
* Email: ferhatayaz@yahoo.com
******************************************************************/
-
#ifndef __nanohttp_mime_h
#define __nanohttp_mime_h
/** @file
*
* @author Ferhat Ayaz
- * @version $Revision: 1.12 $
+ * @version $Revision: 1.13 $
+ *
+ * @see http://www.ietf.org/rfc/rfc2045.txt
+ * @see http://www.ietf.org/rfc/rfc2046.txt
+ * @see http://www.ietf.org/rfc/rfc4288.txt
+ * @see http://www.ietf.org/rfc/rfc4289.txt,
+ *
+ */
+
+/**
*
- * @see http://www.ietf.org/rfc/rfc2045.txt,
- * http://www.ietf.org/rfc/rfc2046.txt,
- * http://www.ietf.org/rfc/rfc4288.txt,
- * http://www.ietf.org/rfc/rfc4289.txt,
+ * MIME errors
*
*/
+#define MIME_ERROR 1300
+#define MIME_ERROR_NO_BOUNDARY_PARAM (MIME_ERROR + 1)
+#define MIME_ERROR_NO_START_PARAM (MIME_ERROR + 2)
+#define MIME_ERROR_PARSE_ERROR (MIME_ERROR + 3)
+#define MIME_ERROR_NO_ROOT_PART (MIME_ERROR + 4)
+#define MIME_ERROR_NOT_MIME_MESSAGE (MIME_ERROR + 5)
#ifdef __cplusplus
extern "C" {
diff --git a/nanohttp/nanohttp-socket.h b/nanohttp/nanohttp-socket.h
index 417693a..dcb19eb 100644
--- a/nanohttp/nanohttp-socket.h
+++ b/nanohttp/nanohttp-socket.h
@@ -1,5 +1,5 @@
/******************************************************************
- * $Id: nanohttp-socket.h,v 1.35 2006/12/01 10:56:00 m0gg Exp $
+ * $Id: nanohttp-socket.h,v 1.36 2006/12/03 17:30:58 m0gg Exp $
*
* CSOAP Project: A http client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -26,6 +26,25 @@
/**
*
+ * Socket error
+ *
+ */
+#define HSOCKET_ERROR 1000
+#define HSOCKET_ERROR_CREATE (HSOCKET_ERROR + 1)
+#define HSOCKET_ERROR_GET_HOSTNAME (HSOCKET_ERROR + 2)
+#define HSOCKET_ERROR_CONNECT (HSOCKET_ERROR + 3)
+#define HSOCKET_ERROR_SEND (HSOCKET_ERROR + 4)
+#define HSOCKET_ERROR_RECEIVE (HSOCKET_ERROR + 5)
+#define HSOCKET_ERROR_BIND (HSOCKET_ERROR + 6)
+#define HSOCKET_ERROR_LISTEN (HSOCKET_ERROR + 7)
+#define HSOCKET_ERROR_ACCEPT (HSOCKET_ERROR + 8)
+#define HSOCKET_ERROR_NOT_INITIALIZED (HSOCKET_ERROR + 9)
+#define HSOCKET_ERROR_IOCTL (HSOCKET_ERROR + 10)
+#define HSOCKET_ERROR_SSLCLOSE (HSOCKET_ERROR + 11)
+#define HSOCKET_ERROR_SSLCTX (HSOCKET_ERROR + 11)
+
+/**
+ *
* Socket definition
*
*/
diff --git a/nanohttp/nanohttp-ssl.h b/nanohttp/nanohttp-ssl.h
index 6dbcad4..cc8b7f7 100644
--- a/nanohttp/nanohttp-ssl.h
+++ b/nanohttp/nanohttp-ssl.h
@@ -1,5 +1,5 @@
/******************************************************************
-* $Id: nanohttp-ssl.h,v 1.24 2006/12/01 10:56:00 m0gg Exp $
+* $Id: nanohttp-ssl.h,v 1.25 2006/12/03 17:30:58 m0gg Exp $
*
* CSOAP Project: A http client/server library in C
* Copyright (C) 2001-2005 Rochester Institute of Technology
@@ -31,6 +31,21 @@
*/
#define NHTTPD_ARG_HTTPS "-NHTTPS"
+
+/**
+ *
+ * SSL Errors
+ *
+ */
+#define HSSL_ERROR 1700
+#define HSSL_ERROR_CA_LIST (HSSL_ERROR + 10)
+#define HSSL_ERROR_CONTEXT (HSSL_ERROR + 20)
+#define HSSL_ERROR_CERTIFICATE (HSSL_ERROR + 30)
+#define HSSL_ERROR_PEM (HSSL_ERROR + 40)
+#define HSSL_ERROR_CLIENT (HSSL_ERROR + 50)
+#define HSSL_ERROR_SERVER (HSSL_ERROR + 60)
+#define HSSL_ERROR_CONNECT (HSSL_ERROR + 70)
+
#ifdef __cplusplus
extern "C" {
#endif
diff --git a/nanohttp/nanohttp-stream.h b/nanohttp/nanohttp-stream.h
index cb37deb..1c27164 100755
--- a/nanohttp/nanohttp-stream.h
+++ b/nanohttp/nanohttp-stream.h
@@ -1,5 +1,5 @@
/******************************************************************
- * $Id: nanohttp-stream.h,v 1.12 2006/11/23 15:27:33 m0gg Exp $
+ * $Id: nanohttp-stream.h,v 1.13 2006/12/03 17:30:58 m0gg Exp $
*
* CSOAP Project: A http client/server library in C
* Copyright (C) 2003-2004 Ferhat Ayaz
@@ -52,6 +52,17 @@
/**
*
+ * Stream errors
+ *
+ */
+#define STREAM_ERROR 1200
+#define STREAM_ERROR_INVALID_TYPE (STREAM_ERROR + 1)
+#define STREAM_ERROR_SOCKET_ERROR (STREAM_ERROR + 2)
+#define STREAM_ERROR_NO_CHUNK_SIZE (STREAM_ERROR + 3)
+#define STREAM_ERROR_WRONG_CHUNK_SIZE (STREAM_ERROR + 4)
+
+/**
+ *
* Transfer types supported while
* sending/receiving data.
*