nanohttp-mime.c File Reference

#include "nanohttp-logging.h"
#include "nanohttp-error.h"
#include "nanohttp-common.h"
#include "nanohttp-socket.h"
#include "nanohttp-stream.h"
#include "nanohttp-mime.h"

Go to the source code of this file.

Classes

struct  _MIME_reader
struct  _MIME_callbacks
struct  _MIME_buffer
struct  _mime_callback_data

Defines

#define MIME_READER_MAX_BUFFER_SIZE   1054
#define MIME_PARSER_BUFFER_SIZE   1054

Typedefs

typedef void(* MIME_part_begin )(void *)
typedef void(* MIME_part_end )(void *)
typedef void(* MIME_parse_begin )(void *)
typedef void(* MIME_parse_end )(void *)
typedef void(* MIME_ERROR_bytes )(void *, const unsigned char *, int)
typedef enum _MIME_parser_status MIME_parser_status
typedef enum _MIME_read_status MIME_read_status
typedef MIME_read_status(* MIME_read_function )(void *, unsigned char *, int *)
typedef _MIME_reader MIME_reader
typedef _MIME_callbacks MIME_callbacks
typedef _MIME_buffer MIME_buffer
typedef _mime_callback_data mime_callback_data_t

Enumerations

enum  _MIME_parser_status { MIME_PARSER_INCOMPLETE_MESSAGE, MIME_PARSER_READ_ERROR, MIME_PARSER_OK }
enum  _MIME_read_status { MIME_READ_OK, MIME_READ_EOF, MIME_READ_ERROR }

Functions

MIME_read_status MIME_filereader_function (void *userdata, unsigned char *dest, int *size)
MIME_parser_status MIME_parse (MIME_read_function reader_function, void *reader_userdata, const char *user_boundary, const MIME_callbacks *callbacks, void *callbacks_userdata)
void MIME_reader_init (MIME_reader *reader, MIME_read_function reader_function, void *userdata)
MIME_read_status MIME_reader_read (MIME_reader *reader, unsigned char *buffer, int size)
void MIME_reader_set_marker (MIME_reader *reader)
void MIME_reader_unset_marker (MIME_reader *reader)
void MIME_reader_jump_marker (MIME_reader *reader)
void MIME_buffer_init (MIME_buffer *buffer)
void MIME_buffer_add (MIME_buffer *buffer, unsigned char ch)
void MIME_buffer_add_bytes (MIME_buffer *buffer, unsigned char *bytes, int size)
int MIME_buffer_is_full (MIME_buffer *buffer)
int MIME_buffer_is_empty (MIME_buffer *buffer)
void MIME_buffer_clear (MIME_buffer *buffer)
MIME_read_status mime_streamreader_function (void *userdata, unsigned char *dest, int *size)
attachments_tmime_message_parse (struct http_input_stream_t *in, const char *root_id, const char *boundary, const char *dest_dir)
attachments_tmime_message_parse_from_file (FILE *in, const char *root_id, const char *boundary, const char *dest_dir)
herror_t mime_get_attachments (content_type_t *ctype, struct http_input_stream_t *in, struct attachments_t **dest)


Define Documentation

#define MIME_PARSER_BUFFER_SIZE   1054
 

Definition at line 88 of file nanohttp-mime.c.

Referenced by MIME_buffer_is_full().

#define MIME_READER_MAX_BUFFER_SIZE   1054
 

Definition at line 87 of file nanohttp-mime.c.

Referenced by MIME_reader_read().


Typedef Documentation

typedef struct _MIME_buffer MIME_buffer
 

typedef struct _mime_callback_data mime_callback_data_t
 

typedef struct _MIME_callbacks MIME_callbacks
 

typedef void(* MIME_ERROR_bytes)(void *, const unsigned char *, int)
 

Definition at line 71 of file nanohttp-mime.c.

typedef void(* MIME_parse_begin)(void *)
 

Definition at line 69 of file nanohttp-mime.c.

typedef void(* MIME_parse_end)(void *)
 

Definition at line 70 of file nanohttp-mime.c.

typedef enum _MIME_parser_status MIME_parser_status
 

typedef void(* MIME_part_begin)(void *)
 

Definition at line 67 of file nanohttp-mime.c.

typedef void(* MIME_part_end)(void *)
 

Definition at line 68 of file nanohttp-mime.c.

typedef MIME_read_status(* MIME_read_function)(void *, unsigned char *, int *)
 

Definition at line 91 of file nanohttp-mime.c.

typedef enum _MIME_read_status MIME_read_status
 

typedef struct _MIME_reader MIME_reader
 

Reader structure. This will be use by the parser


Enumeration Type Documentation

enum _MIME_parser_status
 

Enumerator:
MIME_PARSER_INCOMPLETE_MESSAGE 
MIME_PARSER_READ_ERROR 
MIME_PARSER_OK 

Definition at line 73 of file nanohttp-mime.c.

enum _MIME_read_status
 

Enumerator:
MIME_READ_OK 
MIME_READ_EOF 
MIME_READ_ERROR 

Definition at line 80 of file nanohttp-mime.c.


Function Documentation

void MIME_buffer_add MIME_buffer buffer,
unsigned char  ch
 

Definition at line 246 of file nanohttp-mime.c.

References _MIME_buffer::data, and _MIME_buffer::size.

Referenced by MIME_parse().

void MIME_buffer_add_bytes MIME_buffer buffer,
unsigned char *  bytes,
int  size
 

Definition at line 252 of file nanohttp-mime.c.

References _MIME_buffer::data, and _MIME_buffer::size.

Referenced by MIME_parse().

void MIME_buffer_clear MIME_buffer buffer  ) 
 

Definition at line 271 of file nanohttp-mime.c.

References _MIME_buffer::size.

Referenced by MIME_parse().

void MIME_buffer_init MIME_buffer buffer  ) 
 

Definition at line 240 of file nanohttp-mime.c.

References _MIME_buffer::size.

Referenced by MIME_parse().

int MIME_buffer_is_empty MIME_buffer buffer  ) 
 

Definition at line 265 of file nanohttp-mime.c.

References _MIME_buffer::size.

Referenced by MIME_parse().

int MIME_buffer_is_full MIME_buffer buffer  ) 
 

Definition at line 259 of file nanohttp-mime.c.

References MIME_PARSER_BUFFER_SIZE, and _MIME_buffer::size.

Referenced by MIME_parse().

MIME_read_status MIME_filereader_function void *  userdata,
unsigned char *  dest,
int *  size
 

Definition at line 484 of file nanohttp-mime.c.

References MIME_READ_EOF, and MIME_READ_OK.

Referenced by mime_message_parse_from_file().

herror_t mime_get_attachments content_type_t ctype,
struct http_input_stream_t in,
struct attachments_t **  dest
 

Definition at line 936 of file nanohttp-mime.c.

References attachments_free(), H_OK, herror_new(), hpairnode_get(), log_error1, MIME_ERROR_NO_BOUNDARY_PARAM, MIME_ERROR_NO_ROOT_PART, MIME_ERROR_NO_START_PARAM, MIME_ERROR_NOT_MIME_MESSAGE, MIME_ERROR_PARSE_ERROR, mime_message_parse(), part_t::next, _content_type::params, attachments_t::parts, attachments_t::root_part, and _content_type::type.

Referenced by hresponse_new_from_socket().

struct attachments_t* mime_message_parse struct http_input_stream_t in,
const char *  root_id,
const char *  boundary,
const char *  dest_dir
 

Definition at line 816 of file nanohttp-mime.c.

References _mime_callback_data::buffer_capacity, _mime_callback_data::current_fd, _mime_callback_data::current_part, _mime_callback_data::header_index, _mime_callback_data::header_search, log_error2, _mime_callback_data::message, MIME_parse(), MIME_PARSER_OK, MIME_PARSER_READ_ERROR, mime_streamreader_function(), _MIME_callbacks::parse_begin_cb, _MIME_callbacks::parse_end_cb, _MIME_callbacks::part_begin_cb, _MIME_callbacks::part_end_cb, _mime_callback_data::part_id, attachments_t::parts, _MIME_callbacks::received_bytes_cb, _mime_callback_data::root_dir, _mime_callback_data::root_id, and attachments_t::root_part.

Referenced by mime_get_attachments().

struct attachments_t* mime_message_parse_from_file FILE *  in,
const char *  root_id,
const char *  boundary,
const char *  dest_dir
 

Definition at line 874 of file nanohttp-mime.c.

References _mime_callback_data::buffer_capacity, _mime_callback_data::current_fd, _mime_callback_data::current_part, _mime_callback_data::header_index, _mime_callback_data::header_search, log_error2, _mime_callback_data::message, MIME_filereader_function(), MIME_parse(), MIME_PARSER_OK, MIME_PARSER_READ_ERROR, _MIME_callbacks::parse_begin_cb, _MIME_callbacks::parse_end_cb, _MIME_callbacks::part_begin_cb, _MIME_callbacks::part_end_cb, _mime_callback_data::part_id, attachments_t::parts, _MIME_callbacks::received_bytes_cb, _mime_callback_data::root_dir, _mime_callback_data::root_id, and attachments_t::root_part.

MIME_parser_status MIME_parse MIME_read_function  reader_function,
void *  reader_userdata,
const char *  user_boundary,
const MIME_callbacks callbacks,
void *  callbacks_userdata
 

Definition at line 278 of file nanohttp-mime.c.

References _MIME_buffer::data, MIME_buffer_add(), MIME_buffer_add_bytes(), MIME_buffer_clear(), MIME_buffer_init(), MIME_buffer_is_empty(), MIME_buffer_is_full(), MIME_PARSER_INCOMPLETE_MESSAGE, MIME_PARSER_OK, MIME_PARSER_READ_ERROR, MIME_READ_EOF, MIME_READ_ERROR, MIME_reader_init(), MIME_reader_jump_marker(), MIME_reader_read(), MIME_reader_set_marker(), _MIME_callbacks::parse_begin_cb, _MIME_callbacks::parse_end_cb, _MIME_callbacks::part_begin_cb, _MIME_callbacks::part_end_cb, _MIME_callbacks::received_bytes_cb, and _MIME_buffer::size.

Referenced by mime_message_parse(), and mime_message_parse_from_file().

void MIME_reader_init MIME_reader reader,
MIME_read_function  reader_function,
void *  userdata
 

Initialize a reader

Definition at line 134 of file nanohttp-mime.c.

References _MIME_reader::current, _MIME_reader::marker, _MIME_reader::read_function, _MIME_reader::size, and _MIME_reader::userdata.

Referenced by MIME_parse().

void MIME_reader_jump_marker MIME_reader reader  ) 
 

Definition at line 225 of file nanohttp-mime.c.

References _MIME_reader::current, and _MIME_reader::marker.

Referenced by MIME_parse().

MIME_read_status MIME_reader_read MIME_reader reader,
unsigned char *  buffer,
int  size
 

Read data from a reader source.

Definition at line 149 of file nanohttp-mime.c.

References _MIME_reader::buffer, _MIME_reader::current, _MIME_reader::marker, MIME_READ_ERROR, MIME_READ_OK, MIME_READER_MAX_BUFFER_SIZE, _MIME_reader::read_function, _MIME_reader::size, and _MIME_reader::userdata.

Referenced by MIME_parse().

void MIME_reader_set_marker MIME_reader reader  ) 
 

Definition at line 213 of file nanohttp-mime.c.

References _MIME_reader::current, and _MIME_reader::marker.

Referenced by MIME_parse().

void MIME_reader_unset_marker MIME_reader reader  ) 
 

Definition at line 219 of file nanohttp-mime.c.

References _MIME_reader::marker.

MIME_read_status mime_streamreader_function void *  userdata,
unsigned char *  dest,
int *  size
 

Definition at line 519 of file nanohttp-mime.c.

References http_input_stream_t::err, herror_code(), herror_func(), herror_message(), http_input_stream_is_ready(), http_input_stream_read(), log_error4, MIME_READ_EOF, MIME_READ_ERROR, and MIME_READ_OK.

Referenced by mime_message_parse().


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