From 07c7c81772c4b60b7980880847f3b21455a0f3c9 Mon Sep 17 00:00:00 2001 From: snowdrop Date: Tue, 10 Jan 2006 11:29:04 +0000 Subject: indent with 'indent -nut -bli0 -fca -npcs' command --- nanohttp/nanohttp-mime.c | 334 +++++++++++++++++++++++------------------------ 1 file changed, 166 insertions(+), 168 deletions(-) (limited to 'nanohttp/nanohttp-mime.c') diff --git a/nanohttp/nanohttp-mime.c b/nanohttp/nanohttp-mime.c index 3f17d38..5ca7df9 100755 --- a/nanohttp/nanohttp-mime.c +++ b/nanohttp/nanohttp-mime.c @@ -3,7 +3,7 @@ * | \/ | | | | \/ | | _/ * |_''_| |_| |_''_| |_'/ PARSER * -* $Id: nanohttp-mime.c,v 1.8 2006/01/10 11:21:55 snowdrop Exp $ +* $Id: nanohttp-mime.c,v 1.9 2006/01/10 11:29:05 snowdrop Exp $ * * CSOAP Project: A http client/server library in C * Copyright (C) 2003-2004 Ferhat Ayaz @@ -69,8 +69,8 @@ typedef enum _MIME_read_status #define MIME_PARSER_BUFFER_SIZE 1054 -typedef MIME_read_status (*MIME_read_function) (void *, unsigned char *, - int *); +typedef MIME_read_status(*MIME_read_function) (void *, unsigned char *, + int *); /** @@ -88,8 +88,8 @@ typedef struct _MIME_reader } MIME_reader; -MIME_read_status MIME_filereader_function (void *userdata, - unsigned char *dest, int *size); +MIME_read_status MIME_filereader_function(void *userdata, + unsigned char *dest, int *size); typedef struct _MIME_callbacks { @@ -101,19 +101,19 @@ typedef struct _MIME_callbacks } MIME_callbacks; -MIME_parser_status MIME_parse (MIME_read_function reader_function, - void *reader_userdata, - const char *user_boundary, - const MIME_callbacks * callbacks, - void *callbacks_userdata); +MIME_parser_status MIME_parse(MIME_read_function reader_function, + void *reader_userdata, + const char *user_boundary, + const MIME_callbacks * callbacks, + void *callbacks_userdata); /** Initialize a reader */ void -MIME_reader_init (MIME_reader * reader, - MIME_read_function reader_function, void *userdata) +MIME_reader_init(MIME_reader * reader, + MIME_read_function reader_function, void *userdata) { reader->size = 0; reader->marker = -1; @@ -127,7 +127,7 @@ MIME_reader_init (MIME_reader * reader, Read data from a reader source. */ MIME_read_status -MIME_reader_read (MIME_reader * reader, unsigned char *buffer, int size) +MIME_reader_read(MIME_reader * reader, unsigned char *buffer, int size) { MIME_read_status status; int readed_size; @@ -144,14 +144,14 @@ MIME_reader_read (MIME_reader * reader, unsigned char *buffer, int size) { if (reader->marker != 0) { - memcpy (tempBuffer, reader->buffer + reader->marker, - reader->size - reader->marker); - memcpy (reader->buffer, tempBuffer, reader->size - reader->marker); + memcpy(tempBuffer, reader->buffer + reader->marker, + reader->size - reader->marker); + memcpy(reader->buffer, tempBuffer, reader->size - reader->marker); reader->current = reader->size - reader->marker; } else if (reader->current == MIME_READER_MAX_BUFFER_SIZE - 1) { - fprintf (stderr, "Marker error"); + fprintf(stderr, "Marker error"); return MIME_READ_ERROR; } reader->marker = 0; @@ -160,9 +160,9 @@ MIME_reader_read (MIME_reader * reader, unsigned char *buffer, int size) reader->current = 0; readed_size = MIME_READER_MAX_BUFFER_SIZE - reader->current - 1; - status = reader->read_function (reader->userdata, - reader->buffer + reader->current, - &readed_size); + status = reader->read_function(reader->userdata, + reader->buffer + reader->current, + &readed_size); if (status == MIME_READ_OK) { @@ -174,7 +174,7 @@ MIME_reader_read (MIME_reader * reader, unsigned char *buffer, int size) if (size <= reader->size - reader->current) { - memcpy (buffer, reader->buffer + reader->current, size); + memcpy(buffer, reader->buffer + reader->current, size); reader->current += size; return MIME_READ_OK; } @@ -182,28 +182,28 @@ MIME_reader_read (MIME_reader * reader, unsigned char *buffer, int size) { /* Fill rest data */ rest_size = reader->size - reader->current; - memcpy (buffer, reader->buffer + reader->current, rest_size); + memcpy(buffer, reader->buffer + reader->current, rest_size); reader->current = reader->size; - return MIME_reader_read (reader, buffer + rest_size, size - rest_size); + return MIME_reader_read(reader, buffer + rest_size, size - rest_size); } } void -MIME_reader_set_marker (MIME_reader * reader) +MIME_reader_set_marker(MIME_reader * reader) { reader->marker = reader->current; } void -MIME_reader_unset_marker (MIME_reader * reader) +MIME_reader_unset_marker(MIME_reader * reader) { reader->marker = -1; } void -MIME_reader_jump_marker (MIME_reader * reader) +MIME_reader_jump_marker(MIME_reader * reader) { reader->current = reader->marker; } @@ -218,48 +218,48 @@ typedef struct _MIME_buffer void -MIME_buffer_init (MIME_buffer * buffer) +MIME_buffer_init(MIME_buffer * buffer) { buffer->size = 0; } void -MIME_buffer_add (MIME_buffer * buffer, unsigned char ch) +MIME_buffer_add(MIME_buffer * buffer, unsigned char ch) { buffer->data[buffer->size++] = ch; } void -MIME_buffer_add_bytes (MIME_buffer * buffer, unsigned char *bytes, int size) +MIME_buffer_add_bytes(MIME_buffer * buffer, unsigned char *bytes, int size) { - memcpy (buffer->data, bytes, size); + memcpy(buffer->data, bytes, size); buffer->size += size; } int -MIME_buffer_is_full (MIME_buffer * buffer) +MIME_buffer_is_full(MIME_buffer * buffer) { return buffer->size + 150 >= MIME_PARSER_BUFFER_SIZE; } int -MIME_buffer_is_empty (MIME_buffer * buffer) +MIME_buffer_is_empty(MIME_buffer * buffer) { return buffer->size == 0; } void -MIME_buffer_clear (MIME_buffer * buffer) +MIME_buffer_clear(MIME_buffer * buffer) { buffer->size = 0; } MIME_parser_status -MIME_parse (MIME_read_function reader_function, - void *reader_userdata, - const char *user_boundary, - const MIME_callbacks * callbacks, void *callbacks_userdata) +MIME_parse(MIME_read_function reader_function, + void *reader_userdata, + const char *user_boundary, + const MIME_callbacks * callbacks, void *callbacks_userdata) { char boundary[150]; unsigned char ch[153]; @@ -269,30 +269,30 @@ MIME_parse (MIME_read_function reader_function, MIME_read_status status; /* Init reader */ - MIME_reader_init (&reader, reader_function, reader_userdata); + MIME_reader_init(&reader, reader_function, reader_userdata); /* Init buffer */ - MIME_buffer_init (&buffer); + MIME_buffer_init(&buffer); /* Set boundary related stuff */ - sprintf (boundary, "\n--%s", user_boundary); - boundary_length = strlen (boundary); + sprintf(boundary, "\n--%s", user_boundary); + boundary_length = strlen(boundary); /* Call parse begin callback */ - callbacks->parse_begin_cb (callbacks_userdata); + callbacks->parse_begin_cb(callbacks_userdata); while (1) { set_marker: /* Set marker */ - MIME_reader_set_marker (&reader); + MIME_reader_set_marker(&reader); read_byte: /* Read 1 byte */ - status = MIME_reader_read (&reader, ch, 1); - _log_str ("buffer.log", ch, 1); + status = MIME_reader_read(&reader, ch, 1); + _log_str("buffer.log", ch, 1); if (status == MIME_READ_EOF) return MIME_PARSER_INCOMPLETE_MESSAGE; else if (status == MIME_READ_ERROR) @@ -304,8 +304,8 @@ MIME_parse (MIME_read_function reader_function, while (n < boundary_length) { /* Read 1 byte */ - status = MIME_reader_read (&reader, ch, 1); - _log_str ("buffer.log", ch, 1); + status = MIME_reader_read(&reader, ch, 1); + _log_str("buffer.log", ch, 1); if (status == MIME_READ_EOF) return MIME_PARSER_INCOMPLETE_MESSAGE; else if (status == MIME_READ_ERROR) @@ -319,7 +319,7 @@ MIME_parse (MIME_read_function reader_function, } else { - MIME_reader_jump_marker (&reader); + MIME_reader_jump_marker(&reader); ignore = 1; goto read_byte; } @@ -327,8 +327,8 @@ MIME_parse (MIME_read_function reader_function, } /* while n < boundary_length */ /* Read 1 byte */ - status = MIME_reader_read (&reader, ch, 1); - _log_str ("buffer.log", ch, 1); + status = MIME_reader_read(&reader, ch, 1); + _log_str("buffer.log", ch, 1); if (status == MIME_READ_EOF) @@ -340,8 +340,8 @@ MIME_parse (MIME_read_function reader_function, if (ch[0] == '\r') { /* Read 1 byte */ - status = MIME_reader_read (&reader, ch, 1); - _log_str ("buffer.log", ch, 1); + status = MIME_reader_read(&reader, ch, 1); + _log_str("buffer.log", ch, 1); if (status == MIME_READ_EOF) @@ -352,42 +352,42 @@ MIME_parse (MIME_read_function reader_function, /* Check if byte is '\n' */ if (ch[0] == '\n') { - if (!MIME_buffer_is_empty (&buffer)) + if (!MIME_buffer_is_empty(&buffer)) { /* Invoke callback */ - callbacks->received_bytes_cb (callbacks_userdata, buffer.data, - buffer.size); + callbacks->received_bytes_cb(callbacks_userdata, buffer.data, + buffer.size); /* Empty the buffer */ - MIME_buffer_clear (&buffer); + MIME_buffer_clear(&buffer); /* Invoke End Part */ - callbacks->part_end_cb (callbacks_userdata); + callbacks->part_end_cb(callbacks_userdata); } /* Invoke start new Part */ - callbacks->part_begin_cb (callbacks_userdata); + callbacks->part_begin_cb(callbacks_userdata); goto set_marker; } /* if (ch[0] == '\n') */ else { /* Jump to marker and read bytes */ - MIME_reader_jump_marker (&reader); - MIME_reader_read (&reader, ch, boundary_length + 2); - _log_str ("buffer.log", ch, 1); + MIME_reader_jump_marker(&reader); + MIME_reader_read(&reader, ch, boundary_length + 2); + _log_str("buffer.log", ch, 1); - MIME_buffer_add_bytes (&buffer, ch, boundary_length + 2); + MIME_buffer_add_bytes(&buffer, ch, boundary_length + 2); - if (MIME_buffer_is_full (&buffer)) + if (MIME_buffer_is_full(&buffer)) { /* Invoke callback */ - callbacks->received_bytes_cb (callbacks_userdata, buffer.data, - buffer.size); + callbacks->received_bytes_cb(callbacks_userdata, buffer.data, + buffer.size); /* Empty the buffer */ - MIME_buffer_clear (&buffer); + MIME_buffer_clear(&buffer); } } /* else of if (ch[0] == '\n') */ @@ -397,8 +397,8 @@ MIME_parse (MIME_read_function reader_function, if (ch[0] == '-') { /* Read 1 byte */ - status = MIME_reader_read (&reader, ch, 1); - _log_str ("buffer.log", ch, 1); + status = MIME_reader_read(&reader, ch, 1); + _log_str("buffer.log", ch, 1); if (status == MIME_READ_EOF) return MIME_PARSER_INCOMPLETE_MESSAGE; @@ -407,21 +407,21 @@ MIME_parse (MIME_read_function reader_function, if (ch[0] == '-') { - if (!MIME_buffer_is_empty (&buffer)) + if (!MIME_buffer_is_empty(&buffer)) { /* Invoke callback */ - callbacks->received_bytes_cb (callbacks_userdata, buffer.data, - buffer.size); + callbacks->received_bytes_cb(callbacks_userdata, buffer.data, + buffer.size); /* Empty the buffer */ - MIME_buffer_clear (&buffer); + MIME_buffer_clear(&buffer); /* Invoke End Part */ - callbacks->part_end_cb (callbacks_userdata); + callbacks->part_end_cb(callbacks_userdata); } /* Invoke start new Part */ - callbacks->parse_end_cb (callbacks_userdata); + callbacks->parse_end_cb(callbacks_userdata); /* Finish parsing */ /* TODO (#1#): We assume that after -- comes \r\n This is not @@ -432,7 +432,7 @@ MIME_parse (MIME_read_function reader_function, } /* if (ch[0] == '-') */ else { - MIME_reader_jump_marker (&reader); + MIME_reader_jump_marker(&reader); ignore = 1; goto read_byte; } /* else of if (ch[0] == '-') */ @@ -440,7 +440,7 @@ MIME_parse (MIME_read_function reader_function, } /* if (ch[0] == '-') */ else { - MIME_reader_jump_marker (&reader); + MIME_reader_jump_marker(&reader); ignore = 1; goto read_byte; } /* else of if (ch[0] == '-') */ @@ -451,17 +451,17 @@ MIME_parse (MIME_read_function reader_function, else { ignore = 0; - MIME_buffer_add (&buffer, ch[0]); + MIME_buffer_add(&buffer, ch[0]); /* Chec if buffer is full */ - if (MIME_buffer_is_full (&buffer)) + if (MIME_buffer_is_full(&buffer)) { /* Invoke callback */ - callbacks->received_bytes_cb (callbacks_userdata, buffer.data, - buffer.size); + callbacks->received_bytes_cb(callbacks_userdata, buffer.data, + buffer.size); /* Empty the buffer */ - MIME_buffer_clear (&buffer); + MIME_buffer_clear(&buffer); } } /* else of if ch[0] == '\r' && !ignore */ } /* while (1) */ @@ -471,14 +471,14 @@ MIME_parse (MIME_read_function reader_function, MIME_read_status -MIME_filereader_function (void *userdata, unsigned char *dest, int *size) +MIME_filereader_function(void *userdata, unsigned char *dest, int *size) { FILE *f = (FILE *) userdata; - if (feof (f)) + if (feof(f)) return MIME_READ_EOF; - *size = fread (dest, 1, *size, f); + *size = fread(dest, 1, *size, f); return MIME_READ_OK; } @@ -507,21 +507,21 @@ typedef struct _mime_callback_data MIME_read_status -mime_streamreader_function (void *userdata, unsigned char *dest, int *size) +mime_streamreader_function(void *userdata, unsigned char *dest, int *size) { int readed = 0; http_input_stream_t *in = (http_input_stream_t *) userdata; - if (!http_input_stream_is_ready (in)) + if (!http_input_stream_is_ready(in)) return MIME_READ_EOF; - readed = http_input_stream_read (in, dest, *size); + readed = http_input_stream_read(in, dest, *size); /* log_info1("http_input_stream_read() returned 0"); */ if (readed == -1) { - log_error4 ("[%d] %s():%s ", herror_code (in->err), herror_func (in->err), - herror_message (in->err)); + log_error4("[%d] %s():%s ", herror_code(in->err), herror_func(in->err), + herror_message(in->err)); } *size = readed; @@ -539,34 +539,34 @@ mime_streamreader_function (void *userdata, unsigned char *dest, int *size) Start Callback functions */ static void -_mime_parse_begin (void *data) +_mime_parse_begin(void *data) { /* Nothing to do mime_callback_data_t *cbdata = (mime_callback_data_t)data; */ - log_verbose2 ("Begin parse (%p)", data); + log_verbose2("Begin parse (%p)", data); } static void -_mime_parse_end (void *data) +_mime_parse_end(void *data) { /* Nothing to do mime_callback_data_t *cbdata = (mime_callback_data_t)data; */ - log_verbose2 ("End parse (%p)", data); + log_verbose2("End parse (%p)", data); } static void -_mime_part_begin (void *data) +_mime_part_begin(void *data) { char buffer[1054]; mime_callback_data_t *cbdata = (mime_callback_data_t *) data; part_t *part; - log_verbose2 ("Begin Part (%p)", data); - part = (part_t *) malloc (sizeof (part_t)); + log_verbose2("Begin Part (%p)", data); + part = (part_t *) malloc(sizeof(part_t)); part->next = NULL; @@ -583,38 +583,38 @@ _mime_part_begin (void *data) cbdata->header_search = 0; #ifdef WIN32 - sprintf (buffer, "%s\\mime_%p_%d.part", cbdata->root_dir, - cbdata, cbdata->part_id++); + sprintf(buffer, "%s\\mime_%p_%d.part", cbdata->root_dir, + cbdata, cbdata->part_id++); #else - sprintf (buffer, "%s/mime_%p_%d.part", cbdata->root_dir, - cbdata, cbdata->part_id++); + sprintf(buffer, "%s/mime_%p_%d.part", cbdata->root_dir, + cbdata, cbdata->part_id++); #endif /* log_info2("Creating FILE ('%s') deleteOnExit=1", buffer);*/ part->deleteOnExit = 1; - cbdata->current_fd = fopen (buffer, "wb"); + cbdata->current_fd = fopen(buffer, "wb"); if (cbdata->current_fd) - strcpy (cbdata->current_part->filename, buffer); + strcpy(cbdata->current_part->filename, buffer); else - log_error2 ("Can not open file for write '%s'", buffer); + log_error2("Can not open file for write '%s'", buffer); } static void -_mime_part_end (void *data) +_mime_part_end(void *data) { mime_callback_data_t *cbdata = (mime_callback_data_t *) data; - log_verbose2 ("End Part (%p)", data); + log_verbose2("End Part (%p)", data); if (cbdata->current_fd) { - fclose (cbdata->current_fd); + fclose(cbdata->current_fd); cbdata->current_fd = NULL; } } static hpair_t * -_mime_process_header (char *buffer) +_mime_process_header(char *buffer) { int i = 0, c = 0, proc_key, begin = 0; hpair_t *first = NULL, *last = NULL; @@ -631,12 +631,12 @@ _mime_process_header (char *buffer) value[c] = '\0'; if (last) { - last->next = hpairnode_new (key, value, NULL); + last->next = hpairnode_new(key, value, NULL); last = last->next; } else { - first = last = hpairnode_new (key, value, NULL); + first = last = hpairnode_new(key, value, NULL); } proc_key = 1; c = 0; @@ -668,7 +668,7 @@ _mime_process_header (char *buffer) static void -_mime_received_bytes (void *data, const unsigned char *bytes, int size) +_mime_received_bytes(void *data, const unsigned char *bytes, int size) { int i = 0; char *id, *type, *location; @@ -738,30 +738,28 @@ _mime_received_bytes (void *data, const unsigned char *bytes, int size) cbdata->header[cbdata->header_index++] = '\n'; cbdata->header[cbdata->header_index++] = '\0'; cbdata->header_search = 4; - cbdata->current_part->header = - _mime_process_header (cbdata->header); - hpairnode_dump_deep (cbdata->current_part->header); + cbdata->current_part->header = _mime_process_header(cbdata->header); + hpairnode_dump_deep(cbdata->current_part->header); /* set id */ - id = - hpairnode_get (cbdata->current_part->header, HEADER_CONTENT_ID); + id = hpairnode_get(cbdata->current_part->header, HEADER_CONTENT_ID); if (id != NULL) { - strcpy (cbdata->current_part->id, id); - if (!strcmp (id, cbdata->root_id)) + strcpy(cbdata->current_part->id, id); + if (!strcmp(id, cbdata->root_id)) cbdata->message->root_part = cbdata->current_part; } location = - hpairnode_get (cbdata->current_part->header, - HEADER_CONTENT_LOCATION); + hpairnode_get(cbdata->current_part->header, + HEADER_CONTENT_LOCATION); if (location != NULL) { - strcpy (cbdata->current_part->location, location); + strcpy(cbdata->current_part->location, location); } type = - hpairnode_get (cbdata->current_part->header, HEADER_CONTENT_TYPE); + hpairnode_get(cbdata->current_part->header, HEADER_CONTENT_TYPE); if (type != NULL) { - strcpy (cbdata->current_part->content_type, type); + strcpy(cbdata->current_part->content_type, type); } i++; break; @@ -786,7 +784,7 @@ _mime_received_bytes (void *data, const unsigned char *bytes, int size) /* Write remaining bytes into the file or buffer (if root) (buffer is disabled in this version) */ if (cbdata->current_fd) - fwrite (&(bytes[i]), 1, size - i, cbdata->current_fd); + fwrite(&(bytes[i]), 1, size - i, cbdata->current_fd); } @@ -795,15 +793,15 @@ _mime_received_bytes (void *data, const unsigned char *bytes, int size) */ attachments_t * -mime_message_parse (http_input_stream_t * in, const char *root_id, - const char *boundary, const char *dest_dir) +mime_message_parse(http_input_stream_t * in, const char *root_id, + const char *boundary, const char *dest_dir) { MIME_parser_status status; MIME_callbacks callbacks; attachments_t *message; mime_callback_data_t *cbdata = (mime_callback_data_t *) - malloc (sizeof (mime_callback_data_t)); + malloc(sizeof(mime_callback_data_t)); cbdata->part_id = 100; cbdata->buffer_capacity = 0; @@ -811,9 +809,9 @@ mime_message_parse (http_input_stream_t * in, const char *root_id, cbdata->current_part = NULL; cbdata->header_index = 0; cbdata->header_search = 0; - strcpy (cbdata->root_id, root_id); - strcpy (cbdata->root_dir, dest_dir); - message = (attachments_t *) malloc (sizeof (attachments_t)); + strcpy(cbdata->root_id, root_id); + strcpy(cbdata->root_dir, dest_dir); + message = (attachments_t *) malloc(sizeof(attachments_t)); cbdata->message = message; cbdata->message->parts = NULL; cbdata->message->root_part = NULL; @@ -824,33 +822,33 @@ mime_message_parse (http_input_stream_t * in, const char *root_id, callbacks.part_end_cb = _mime_part_end; callbacks.received_bytes_cb = _mime_received_bytes; - status = MIME_parse (mime_streamreader_function, - in, boundary, &callbacks, cbdata); + status = MIME_parse(mime_streamreader_function, + in, boundary, &callbacks, cbdata); if (status == MIME_PARSER_OK) { - free (cbdata); + free(cbdata); return message; } else { - log_error2 ("MIME parser error '%s'!", - status == - MIME_PARSER_READ_ERROR ? "read error" : "Incomplete message"); + log_error2("MIME parser error '%s'!", + status == + MIME_PARSER_READ_ERROR ? "read error" : "Incomplete message"); return NULL; } } attachments_t * -mime_message_parse_from_file (FILE * in, const char *root_id, - const char *boundary, const char *dest_dir) +mime_message_parse_from_file(FILE * in, const char *root_id, + const char *boundary, const char *dest_dir) { MIME_parser_status status; MIME_callbacks callbacks; attachments_t *message; mime_callback_data_t *cbdata = (mime_callback_data_t *) - malloc (sizeof (mime_callback_data_t)); + malloc(sizeof(mime_callback_data_t)); cbdata->part_id = 100; cbdata->buffer_capacity = 0; @@ -858,9 +856,9 @@ mime_message_parse_from_file (FILE * in, const char *root_id, cbdata->current_part = NULL; cbdata->header_index = 0; cbdata->header_search = 0; - strcpy (cbdata->root_id, root_id); - strcpy (cbdata->root_dir, dest_dir); - message = (attachments_t *) malloc (sizeof (attachments_t)); + strcpy(cbdata->root_id, root_id); + strcpy(cbdata->root_dir, dest_dir); + message = (attachments_t *) malloc(sizeof(attachments_t)); cbdata->message = message; cbdata->message->parts = NULL; cbdata->message->root_part = NULL; @@ -871,22 +869,22 @@ mime_message_parse_from_file (FILE * in, const char *root_id, callbacks.part_end_cb = _mime_part_end; callbacks.received_bytes_cb = _mime_received_bytes; - status = MIME_parse (MIME_filereader_function, - in, boundary, &callbacks, cbdata); + status = MIME_parse(MIME_filereader_function, + in, boundary, &callbacks, cbdata); if (status == MIME_PARSER_OK) { - free (cbdata); + free(cbdata); return message; } else { /* TODO (#1#): Free objects */ - log_error2 ("MIME parser error '%s'!", - status == - MIME_PARSER_READ_ERROR ? "general error" : - "Incomplete message"); + log_error2("MIME parser error '%s'!", + status == + MIME_PARSER_READ_ERROR ? "general error" : + "Incomplete message"); return NULL; } } @@ -894,8 +892,8 @@ mime_message_parse_from_file (FILE * in, const char *root_id, herror_t -mime_get_attachments (content_type_t * ctype, http_input_stream_t * in, - attachments_t ** dest) +mime_get_attachments(content_type_t * ctype, http_input_stream_t * in, + attachments_t ** dest) { /* MIME variables */ attachments_t *mimeMessage; @@ -903,44 +901,44 @@ mime_get_attachments (content_type_t * ctype, http_input_stream_t * in, char *boundary, *root_id; /* Check for MIME message */ - if (!(ctype && !strcmp (ctype->type, "multipart/related"))) - return herror_new ("mime_get_attachments", MIME_ERROR_NOT_MIME_MESSAGE, - "Not a MIME message '%s'", ctype->type); + if (!(ctype && !strcmp(ctype->type, "multipart/related"))) + return herror_new("mime_get_attachments", MIME_ERROR_NOT_MIME_MESSAGE, + "Not a MIME message '%s'", ctype->type); - boundary = hpairnode_get (ctype->params, "boundary"); - root_id = hpairnode_get (ctype->params, "start"); + boundary = hpairnode_get(ctype->params, "boundary"); + root_id = hpairnode_get(ctype->params, "start"); if (boundary == NULL) { /* TODO (#1#): Handle Error in http form */ - log_error1 ("'boundary' not set for multipart/related"); - return herror_new ("mime_get_attachments", MIME_ERROR_NO_BOUNDARY_PARAM, - "'boundary' not set for multipart/related"); + log_error1("'boundary' not set for multipart/related"); + return herror_new("mime_get_attachments", MIME_ERROR_NO_BOUNDARY_PARAM, + "'boundary' not set for multipart/related"); } if (root_id == NULL) { /* TODO (#1#): Handle Error in http form */ - log_error1 ("'start' not set for multipart/related"); - return herror_new ("mime_get_attachments", MIME_ERROR_NO_START_PARAM, - "'start' not set for multipart/related"); + log_error1("'start' not set for multipart/related"); + return herror_new("mime_get_attachments", MIME_ERROR_NO_START_PARAM, + "'start' not set for multipart/related"); } mimeMessage = - mime_message_parse (in, root_id, boundary, hoption_get (HOPTION_TMP_DIR)); + mime_message_parse(in, root_id, boundary, hoption_get(HOPTION_TMP_DIR)); if (mimeMessage == NULL) { /* TODO (#1#): Handle Error in http form */ - log_error1 ("MIME Parse Error"); - return herror_new ("mime_get_attachments", MIME_ERROR_PARSE_ERROR, - "MIME Parse Error"); + log_error1("MIME Parse Error"); + return herror_new("mime_get_attachments", MIME_ERROR_PARSE_ERROR, + "MIME Parse Error"); } /* Find root */ if (!mimeMessage->root_part) { - attachments_free (mimeMessage); - return herror_new ("mime_get_attachments", MIME_ERROR_NO_ROOT_PART, - "No root part found!"); + attachments_free(mimeMessage); + return herror_new("mime_get_attachments", MIME_ERROR_NO_ROOT_PART, + "No root part found!"); } /* delete root_part from list */ -- cgit v1.1-32-gdbae