71 static int is_cr(
int c);
72 static int is_lf(
int c);
108 long boundary_pos,
long *next_part_pos);
139 *content_headers = NULL;
143 warning(0,
"erroneous preamble");
147 warning(0,
"erroneous control entity");
151 warning(0,
"erroneous control headers");
157 content_headers, rdf_content)) < 0) {
158 warning(0,
"erroneous content entity (push message)");
160 }
else if (ret == 0) {
168 warning(0,
"erroneous capacity (rdf) headers");
199 return c ==
'\t' || c ==
' ';
204 long boundary_pos,
long *next_part_pos)
226 boundary_pos = next_part_pos = -1;
229 if ((boundary_pos =
octstr_search(*mime_content, dash_boundary, 0)) < 0)
232 if (
parse_tail(mime_content, dash_boundary, boundary_pos,
303 close_delimiter, 0)) < 0)
307 if (boundary_pos == close_delimiter_pos) {
319 if (
parse_tail(multipart, part_delimiter, 0, &next_part_pos) < 0) {
397 return close_delimiter;
407 return part_delimiter;
417 return start_delimiter;
448 long message_start_pos;
452 message_start_pos)) < 0 ||
470 long next_header_pos;
472 next_header_pos = -1;
485 long message_start_pos;
509 long next_content_part_pos;
514 next_content_part_pos)) < 0)
519 next_header_pos)) < 0)
522 next_header_pos)) == 0)
526 octstr_delete(*body_part, content_pos, next_header_pos - content_pos);
583 warning(0,
"MIME: %s: X-Wap-Application-Id header missing, assuming 'wml.ua'", __func__);
588 warning(0,
"MIME: %s: Content-Type header missing", __func__);
614 warning(0,
"MIME: pass_data_headers: an unparseable optional header");
626 long header_pos, next_header_pos;
628 long message_start_pos;
630 header_pos = next_header_pos = -1;
635 message_start_pos)) < 0) {
642 if ((next_header_pos =
parse_terminator(*body_part, next_header_pos)) < 0) {
646 octstr_delete(*body_part, header_pos, next_header_pos - header_pos);
665 long header_pos, next_header_pos;
667 long message_start_pos;
669 header_pos = next_header_pos = -1;
674 message_start_pos)) < 0) {
681 if ((next_header_pos =
parse_terminator(*body_part, next_header_pos)) < 0) {
685 octstr_delete(*body_part, header_pos, next_header_pos - header_pos);
704 long content_pos, next_header_pos;
706 long message_start_pos;
708 content_pos = next_header_pos = -1;
723 octstr_delete(*body_part, content_pos, next_header_pos - content_pos);
749 pos = pos - 1 - count;
776 long next_field_part_pos;
779 long next_content_part_pos;
783 next_field_part_pos = 0;
788 next_content_part_pos)) < 0)
791 next_field_part_pos)) < 0)
794 next_field_part_pos)) < 0)
797 next_field_part_pos)) == 0)
void error(int err, const char *fmt,...)
static Octstr * delimiter
static int parse_epilogue(Octstr **mime_content)
void http_header_add(List *headers, char *name, char *contents)
static int check_data_content_type_header(Octstr **body_part, List **data_headers, Octstr *boundary)
gw_assert(wtls_machine->packet_to_send !=NULL)
void gwlist_append(List *list, void *item)
static void octstr_split_by_pos(Octstr **mime_content, Octstr **pap_content, long boundary_pos)
void octstr_append(Octstr *ostr1, const Octstr *ostr2)
static Octstr * make_start_delimiter(Octstr *dash_boundary)
static int islwspchar(int c)
static Octstr * make_part_delimiter(Octstr *boundary)
long octstr_search(const Octstr *haystack, const Octstr *needle, long pos)
static int check_data_x_wap_application_id_header(Octstr **body_part, List **data_headers, Octstr *boundary)
long octstr_case_nsearch(const Octstr *haystack, const Octstr *needle, long pos, long n)
static void drop_separator(Octstr **header_value, long *pos)
static long parse_field_name(Octstr *pap_content, long pos)
static int check_control_headers(Octstr **body_part)
#define octstr_get_cstr(ostr)
#define octstr_copy(ostr, from, len)
static int pass_extension_headers(Octstr **body_part, List **data_headers, Octstr *boundary)
static long parse_terminator(Octstr *mime_content, long pos)
static long pass_field_value(Octstr **body_part, Octstr **content_header, long pos)
static Octstr * content_header
static long parse_transport_padding(Octstr *mime_content, long pos)
static Octstr * make_close_delimiter(Octstr *boundary)
Octstr * octstr_imm(const char *cstr)
static int parse_body_part(Octstr **multipart, Octstr *boundary, Octstr **body_part)
static int drop_header_true(Octstr **body_part, long content_pos)
void octstr_delete(Octstr *ostr1, long pos, long len)
List * http_create_empty_headers(void)
int octstr_ncompare(const Octstr *ostr1, const Octstr *ostr2, long n)
static long octstr_drop_leading_blanks(Octstr **header_value)
#define octstr_duplicate(ostr)
long octstr_case_search(const Octstr *haystack, const Octstr *needle, long pos)
void warning(int err, const char *fmt,...)
static int drop_optional_header(Octstr **body_part, char *name, Octstr *boundary)
void octstr_destroy(Octstr *ostr)
#define octstr_create(cstr)
static long pass_field_name(Octstr **body_part, Octstr **content_header, long pos)
static long parse_field_value(Octstr *pap_content, long pos)
static long parse_close_delimiter(Octstr *close_delimiter, Octstr *mime_content, long pos)
long octstr_len(const Octstr *ostr)
static int pass_optional_header(Octstr **body_part, char *name, List **content_headers, Octstr *boundary)
static int parse_preamble(Octstr **mime_content, Octstr *boundary)
void octstr_format_append(Octstr *os, const char *fmt,...)
static int pass_data_headers(Octstr **body_part, List **data_headers)
int octstr_get_char(const Octstr *ostr, long pos)
static int parse_tail(Octstr **multipart, Octstr *part_delimiter, long boundary_pos, long *next_part_pos)
int mime_parse(Octstr *boundary, Octstr *mime_content, Octstr **pap_content, Octstr **push_data, List **content_headers, Octstr **rdf_content)
static int drop_extension_headers(Octstr **mime_content, Octstr *boundary)
static int check_control_content_type_header(Octstr **body_part, Octstr *boundary)
static int parse_encapsulation(Octstr **mime_content, Octstr *boundary, Octstr **push_data, List **content_headers, Octstr **rdf_content)