diff options
-rwxr-xr-x | nanohttp/nanohttp-mime.c | 26 | ||||
-rwxr-xr-x | nanohttp/nanohttp-stream.h | 64 |
2 files changed, 52 insertions, 38 deletions
diff --git a/nanohttp/nanohttp-mime.c b/nanohttp/nanohttp-mime.c index 05694c6..59b50c0 100755 --- a/nanohttp/nanohttp-mime.c +++ b/nanohttp/nanohttp-mime.c @@ -3,7 +3,7 @@ * | \/ | | | | \/ | | _/ * |_''_| |_| |_''_| |_'/ PARSER * -* $Id: nanohttp-mime.c,v 1.17 2006/11/25 15:06:58 m0gg Exp $ +* $Id: nanohttp-mime.c,v 1.18 2006/12/11 08:35:58 m0gg Exp $ * * CSOAP Project: A http client/server library in C * Copyright (C) 2003-2004 Ferhat Ayaz @@ -149,7 +149,7 @@ MIME_read_status MIME_reader_read(MIME_reader * reader, unsigned char *buffer, int size) { MIME_read_status status; - int readed_size; + int len; unsigned char tempBuffer[MIME_READER_MAX_BUFFER_SIZE]; int rest_size; @@ -178,14 +178,14 @@ MIME_reader_read(MIME_reader * reader, unsigned char *buffer, int size) else reader->current = 0; - readed_size = MIME_READER_MAX_BUFFER_SIZE - reader->current - 1; + len = MIME_READER_MAX_BUFFER_SIZE - reader->current - 1; status = reader->read_function(reader->userdata, reader->buffer + reader->current, - &readed_size); + &len); if (status == MIME_READ_OK) { - reader->size = readed_size + reader->current; + reader->size = len + reader->current; } else return status; @@ -518,22 +518,22 @@ typedef struct _mime_callback_data MIME_read_status mime_streamreader_function(void *userdata, unsigned char *dest, int *size) { - int readed = 0; + int len = 0; struct http_input_stream_t *in = (struct http_input_stream_t *) userdata; if (!http_input_stream_is_ready(in)) return MIME_READ_EOF; - readed = http_input_stream_read(in, dest, *size); + len = http_input_stream_read(in, dest, *size); /* log_info1("http_input_stream_read() returned 0"); */ - if (readed == -1) + if (len == -1) { log_error4("[%d] %s():%s ", herror_code(in->err), herror_func(in->err), herror_message(in->err)); } - *size = readed; + *size = len; if (*size != -1) { return MIME_READ_OK; @@ -552,6 +552,8 @@ _mime_parse_begin(void *data) mime_callback_data_t *cbdata = (mime_callback_data_t)data; */ log_verbose2("Begin parse (%p)", data); + + return; } @@ -562,6 +564,8 @@ _mime_parse_end(void *data) mime_callback_data_t *cbdata = (mime_callback_data_t)data; */ log_verbose2("End parse (%p)", data); + + return; } @@ -622,6 +626,8 @@ _mime_part_end(void *data) fclose(cbdata->current_fd); cbdata->current_fd = NULL; } + + return; } @@ -797,6 +803,8 @@ _mime_received_bytes(void *data, const unsigned char *bytes, int size) disabled in this version) */ if (cbdata->current_fd) fwrite(&(bytes[i]), 1, size - i, cbdata->current_fd); + + return; } diff --git a/nanohttp/nanohttp-stream.h b/nanohttp/nanohttp-stream.h index 5434953..7846df5 100755 --- a/nanohttp/nanohttp-stream.h +++ b/nanohttp/nanohttp-stream.h @@ -1,5 +1,5 @@ /****************************************************************** - * $Id: nanohttp-stream.h,v 1.14 2006/12/10 19:21:07 m0gg Exp $ + * $Id: nanohttp-stream.h,v 1.15 2006/12/11 08:35:58 m0gg Exp $ * * CSOAP Project: A http client/server library in C * Copyright (C) 2003-2004 Ferhat Ayaz @@ -26,10 +26,9 @@ /** @file * - * \section HTTP Stream modul - * - * nanohttp supports 2 different streams: + * @section HTTP Stream modul * + * nanoHTTP supports 2 different streams: * -# http_input_stream_t * -# http_output_stream_t * @@ -50,9 +49,14 @@ * */ +/** @defgroup stream_errors_group Stream errors + * + */ +/*@{*/ + /** * - * Stream errors + * Generic stream error. * */ #define STREAM_ERROR 1200 @@ -61,6 +65,8 @@ #define STREAM_ERROR_NO_CHUNK_SIZE (STREAM_ERROR + 3) #define STREAM_ERROR_WRONG_CHUNK_SIZE (STREAM_ERROR + 4) +/*@}*/ + /** * * Transfer types supported while @@ -126,16 +132,16 @@ extern "C" { /** * - * Creates a new input stream. The transfer style will be - * choosen from the given header. + * 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 http_input_stream_t. + * @param header the http header. This must be received before creating a + * http_input_stream_t. * - * @returns a newly created http_input_stream_t object. If no transfer style was - * found in the header, HTTP_TRANSFER_CONNECTION_CLOSE will be used as - * default. + * @return a newly created http_input_stream_t object. If no transfer style was + * found in the header, HTTP_TRANSFER_CONNECTION_CLOSE will be used as + * default. * * @see http_input_stream_free * @@ -149,8 +155,8 @@ extern struct http_input_stream_t *http_input_stream_new(struct hsocket_t *sock, * * @param filename the name of the file to open and read. * - * @returns The return value is a http_input_stream_t object if the file exists - * and could be opened. NULL otherwise. + * @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 * @@ -172,8 +178,8 @@ extern void http_input_stream_free(struct http_input_stream_t * stream); * * @param stream the stream to check its status * - * @returns <br>1 if there are still data to read. - * <br>0 if no more data exists. + * @return - 1, if there is still data to read. + * - 0, if no more data exists. */ extern int http_input_stream_is_ready(struct http_input_stream_t * stream); @@ -192,10 +198,10 @@ extern int http_input_stream_is_ready(struct http_input_stream_t * stream); * - HSOCKET_ERROR_RECEIVE * * @param stream the stream to read data from - * @param dest destination memory to store readed bytes + * @param dest destination memory to store read bytes * @param size maximum size of 'dest' (size to read) * - * @returns the actual readed bytes or -1 on error. + * @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); @@ -208,8 +214,8 @@ extern int http_input_stream_read(struct http_input_stream_t * stream, unsigned * @param sock the socket to to send data to * @param header the header which must be sent before * - * @returns 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. + * @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 * @@ -235,9 +241,9 @@ extern void http_output_stream_free(struct http_output_stream_t * stream); * @param bytes bytes to send * @param size size of bytes to send * - * @returns H_OK on success. One of the followings otherwise - * - HSOCKET_ERROR_NOT_INITIALIZED - * - HSOCKET_ERROR_SEND + * @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); @@ -249,9 +255,9 @@ extern herror_t http_output_stream_write(struct http_output_stream_t *stream, co * @param stream the stream to use to send data * @param str a null terminated string to send * - * @returns H_OK on success. One of the followings otherwise - * - HSOCKET_ERROR_NOT_INITIALIZED - * - HSOCKET_ERROR_SEND + * @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); @@ -263,9 +269,9 @@ extern herror_t http_output_stream_write_string(struct http_output_stream_t *str * * @param stream the stream to send post data. * - * @returns H_OK on success. One of the followings otherwise - * - HSOCKET_ERROR_NOT_INITIALIZED - * - HSOCKET_ERROR_SEND + * @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); |