nanohttp-stream.h

Go to the documentation of this file.
00001 /******************************************************************
00002  *  $Id: nanohttp-stream.h,v 1.15 2006/12/11 08:35:58 m0gg Exp $
00003  *
00004  * CSOAP Project:  A http client/server library in C
00005  * Copyright (C) 2003-2004  Ferhat Ayaz
00006  *
00007  * This library is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Library General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2 of the License, or (at your option) any later version.
00011  *
00012  * This library is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Library General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Library General Public
00018  * License along with this library; if not, write to the
00019  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00020  * Boston, MA  02111-1307, USA.
00021  * 
00022  * Email: ferhatayaz@yahoo.com
00023  ******************************************************************/
00024 #ifndef __nanohttp_stream_h
00025 #define __nanohttp_stream_h
00026 
00056 
00062 #define STREAM_ERROR                    1200
00063 #define STREAM_ERROR_INVALID_TYPE       (STREAM_ERROR + 1)
00064 #define STREAM_ERROR_SOCKET_ERROR       (STREAM_ERROR + 2)
00065 #define STREAM_ERROR_NO_CHUNK_SIZE      (STREAM_ERROR + 3)
00066 #define STREAM_ERROR_WRONG_CHUNK_SIZE   (STREAM_ERROR + 4)
00067 
00076 typedef enum http_transfer_type
00077 {
00079   HTTP_TRANSFER_CONTENT_LENGTH,
00080 
00082   HTTP_TRANSFER_CHUNKED,
00083 
00085   HTTP_TRANSFER_CONNECTION_CLOSE,
00086 
00088   HTTP_TRANSFER_FILE
00089 } http_transfer_type_t;
00090 
00091 
00098 struct http_input_stream_t
00099 {
00100   struct hsocket_t *sock;
00101   herror_t err;
00102   http_transfer_type_t type;
00103   int received;
00104   int content_length;
00105   int chunk_size;
00106   char connection_closed;
00107 
00108   /* file handling */
00109   FILE *fd;
00110   char filename[255];
00111   int deleteOnExit;             /* default is 0 */
00112 };
00113 
00120 struct http_output_stream_t
00121 {
00122   struct hsocket_t *sock;
00123   http_transfer_type_t type;
00124   int content_length;
00125   int sent;
00126 };
00127 
00128 
00129 #ifdef __cplusplus
00130 extern "C" {
00131 #endif
00132 
00149 extern struct http_input_stream_t *http_input_stream_new(struct hsocket_t *sock, hpair_t *header);
00150 
00164 extern struct http_input_stream_t *http_input_stream_new_from_file(const char *filename);
00165 
00173 extern void http_input_stream_free(struct http_input_stream_t * stream);
00174 
00184 extern int http_input_stream_is_ready(struct http_input_stream_t * stream);
00185 
00207 extern int http_input_stream_read(struct http_input_stream_t * stream, unsigned char *dest, int size);
00208 
00223 extern struct http_output_stream_t *http_output_stream_new(struct hsocket_t *sock, hpair_t * header);
00224 
00225 
00234 extern void http_output_stream_free(struct http_output_stream_t * stream);
00235 
00249 extern herror_t http_output_stream_write(struct http_output_stream_t *stream, const unsigned char* bytes, int size);
00250 
00263 extern herror_t http_output_stream_write_string(struct http_output_stream_t *stream, const char *str);
00264 
00277 extern herror_t http_output_stream_flush(struct http_output_stream_t *stream);
00278 
00279 #ifdef __cplusplus
00280 }
00281 #endif
00282 
00283 #endif

Generated on Thu Jan 25 23:36:03 2007 for csoap by  doxygen 1.4.6