From 8a6946b18003fae6400a137389f0cb13d0ac4bd6 Mon Sep 17 00:00:00 2001 From: m0gg Date: Sat, 3 Nov 2007 22:40:09 +0000 Subject: Split nanoHTTP and cSOAP logging --- nanohttp/nanohttp-stream.h | 158 ++++++++++++++++----------------------------- 1 file changed, 55 insertions(+), 103 deletions(-) (limited to 'nanohttp/nanohttp-stream.h') diff --git a/nanohttp/nanohttp-stream.h b/nanohttp/nanohttp-stream.h index 7846df5..40d415e 100755 --- a/nanohttp/nanohttp-stream.h +++ b/nanohttp/nanohttp-stream.h @@ -1,5 +1,5 @@ /****************************************************************** - * $Id: nanohttp-stream.h,v 1.15 2006/12/11 08:35:58 m0gg Exp $ + * $Id: nanohttp-stream.h,v 1.16 2007/11/03 22:40:15 m0gg Exp $ * * CSOAP Project: A http client/server library in C * Copyright (C) 2003-2004 Ferhat Ayaz @@ -24,7 +24,7 @@ #ifndef __nanohttp_stream_h #define __nanohttp_stream_h -/** @file +/** @file nanohttp-stream.h Stream handling * * @section HTTP Stream modul * @@ -46,55 +46,36 @@ * * A stream will start sending/receiving data "after" sending/receiving header * information. (After )" - * */ +/**{@*/ -/** @defgroup stream_errors_group Stream errors - * +/** @defgroup NANOHTTP_STREAM_ERRORS Stream errors + * @ingroup NANOHTTP_ERRORS */ /*@{*/ - -/** - * - * Generic stream error. - * - */ #define STREAM_ERROR 1200 #define STREAM_ERROR_INVALID_TYPE (STREAM_ERROR + 1) #define STREAM_ERROR_SOCKET_ERROR (STREAM_ERROR + 2) #define STREAM_ERROR_NO_CHUNK_SIZE (STREAM_ERROR + 3) #define STREAM_ERROR_WRONG_CHUNK_SIZE (STREAM_ERROR + 4) - /*@}*/ -/** - * - * Transfer types supported while - * sending/receiving data. - * - */ +/** Transfer types supported while sending/receiving data. */ typedef enum http_transfer_type { - /** The stream cares about Content-length */ - HTTP_TRANSFER_CONTENT_LENGTH, - - /** The stream sends/receives chunked data */ - HTTP_TRANSFER_CHUNKED, - - /** The stream sends/receives data until connection is closed */ - HTTP_TRANSFER_CONNECTION_CLOSE, - - /** This transfer style will be used by MIME support and for debug purposes.*/ - HTTP_TRANSFER_FILE + HTTP_TRANSFER_CONTENT_LENGTH, /**< The stream cares about + Content-length */ + HTTP_TRANSFER_CHUNKED, /**< The stream sends/receives + chunked data */ + HTTP_TRANSFER_CONNECTION_CLOSE, /**< The stream sends/receives + data until connection is closed */ + HTTP_TRANSFER_FILE /**< This transfer style will be used + by MIME support and for debug + purposes. */ } http_transfer_type_t; - -/** - * - * HTTP INPUT STREAM. Receives data from a socket/file - * and cares about the transfer style. - * - */ +/** HTTP INPUT STREAM. Receives data from a socket/file and cares + * about the transfer style. */ struct http_input_stream_t { struct hsocket_t *sock; @@ -111,12 +92,8 @@ struct http_input_stream_t int deleteOnExit; /* default is 0 */ }; -/** - * - * HTTP OUTPUT STREAM. Sends data to a socket - * and cares about the transfer style. - * - */ +/** HTTP OUTPUT STREAM. Sends data to a socket and cares about the + * transfer style. */ struct http_output_stream_t { struct hsocket_t *sock; @@ -125,15 +102,12 @@ struct http_output_stream_t int sent; }; - #ifdef __cplusplus extern "C" { #endif -/** - * - * Creates a new input stream. The transfer style will be choosen from the given - * header. +/** This function creates a new input stream. The transfer style will + * be choosen from the given header. * * @param sock the socket to receive data from * @param header the http header. This must be received before creating a @@ -143,38 +117,31 @@ extern "C" { * found in the header, HTTP_TRANSFER_CONNECTION_CLOSE will be used as * default. * - * @see http_input_stream_free - * + * @see http_input_stream_free() */ extern struct http_input_stream_t *http_input_stream_new(struct hsocket_t *sock, hpair_t *header); -/** - * - * Creates a new input stream from file. This function was added for MIME - * messages and for debugging. The transfer style is always HTTP_TRANSFER_FILE. +/** This function creates a new input stream from file. It was added + * for MIME messages and for debugging purposes. The transfer style + * is always HTTP_TRANSFER_FILE. * * @param filename the name of the file to open and read. * - * @return The return value is a http_input_stream_t object if the file exists - * and could be opened. NULL otherwise. - * - * @see http_input_stream_free + * @return The return value is a http_input_stream_t object if the file + * exists and could be opened. NULL otherwise. * + * @see http_input_stream_free() */ extern struct http_input_stream_t *http_input_stream_new_from_file(const char *filename); -/** - * - * Free input stream. Note that the socket will not be closed by this functions. +/** Free input stream. Note that the socket will not be closed by this + * functions. * * @param stream the input stream to free. - * */ extern void http_input_stream_free(struct http_input_stream_t * stream); -/** - * - * Returns the actual status of the stream. +/** This function returns the actual status of the stream. * * @param stream the stream to check its status * @@ -183,15 +150,13 @@ extern void http_input_stream_free(struct http_input_stream_t * stream); */ extern int http_input_stream_is_ready(struct http_input_stream_t * stream); -/** - * - * Tries to read 'size' bytes from the stream. Check always with - * http_input_stream_is_ready() if there are some data to read. If it returns 0, - * no more data is available on stream. +/** This function tries to read 'size' bytes from the stream. Check + * always with http_input_stream_is_ready() if there are some data to + * read. If it returns 0, no more data is available on stream. * - * On error this function will return -1. In this case the "err" field of stream - * will be set to the actual error. This can be one of the followings: - * + * On error this function will return -1. In this case the "err" field + * of stream will be set to the actual error. This can be one of the + * followings: * - STREAM_ERROR_NO_CHUNK_SIZE * - STREAM_ERROR_WRONG_CHUNK_SIZE * - STREAM_ERROR_INVALID_TYPE @@ -202,55 +167,44 @@ extern int http_input_stream_is_ready(struct http_input_stream_t * stream); * @param size maximum size of 'dest' (size to read) * * @return the actual read bytes or -1 on error. - * */ extern int http_input_stream_read(struct http_input_stream_t * stream, unsigned char *dest, int size); -/** - * - * Creates a new output stream. Transfer style will be found from the given - * header. +/** Creates a new output stream. Transfer style will be found from the + * given header. * * @param sock the socket to to send data to * @param header the header which must be sent before * - * @return a http_output_stream_t object. If no proper transfer style was found - * in the header, HTTP_TRANSFER_CONNECTION_CLOSE will be used as default. - * - * @see http_output_stream_free + * @return A http_output_stream_t object. If no proper transfer style + * was found in the header, HTTP_TRANSFER_CONNECTION_CLOSE will + * be used as default. * + * @see http_output_stream_free() */ extern struct http_output_stream_t *http_output_stream_new(struct hsocket_t *sock, hpair_t * header); -/** - * - * Free output stream. Note that this functions will not close any socket - * connections. - * - * @param stream the stream to free. +/** This function frees the given output stream. Note that this + * function will not close any socket connections. * + * @param stream The stream to free. */ -extern void http_output_stream_free(struct http_output_stream_t * stream); +extern void http_output_stream_free(struct http_output_stream_t *stream); -/** - * - * Writes 'size' bytes of 'bytes' into stream. +/** This function writes 'size' bytes of 'bytes' into stream. * * @param stream the stream to use to send data * @param bytes bytes to send * @param size size of bytes to send * - * @return H_OK on success. One of the followings otherwise + * @return H_OK on success. One of the followings otherwise: * - HSOCKET_ERROR_NOT_INITIALIZED * - HSOCKET_ERROR_SEND - * */ -extern herror_t http_output_stream_write(struct http_output_stream_t *stream, const unsigned char* bytes, int size); +extern herror_t http_output_stream_write(struct http_output_stream_t *stream, const unsigned char *bytes, int size); -/** - * - * Writes a null terminated string to the stream. +/** This function writes a null terminated string to the stream. * * @param stream the stream to use to send data * @param str a null terminated string to send @@ -258,21 +212,17 @@ extern herror_t http_output_stream_write(struct http_output_stream_t *stream, co * @return H_OK on success. One of the followings otherwise * - HSOCKET_ERROR_NOT_INITIALIZED * - HSOCKET_ERROR_SEND - * */ extern herror_t http_output_stream_write_string(struct http_output_stream_t *stream, const char *str); -/** - * - * Sends finish flags if nesseccary (like in chunked transport). - * Call always this function before closing the connections. +/** This function sends finish flags if nesseccary (like in chunked + * transport). Call always this function before closing the connections. * * @param stream the stream to send post data. * * @return H_OK on success. One of the followings otherwise * - HSOCKET_ERROR_NOT_INITIALIZED * - HSOCKET_ERROR_SEND - * */ extern herror_t http_output_stream_flush(struct http_output_stream_t *stream); @@ -280,4 +230,6 @@ extern herror_t http_output_stream_flush(struct http_output_stream_t *stream); } #endif +/**@}*/ + #endif -- cgit v1.1-32-gdbae