Main Page | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

wap_push_pap_mime.c File Reference

#include "wap_push_pap_mime.h"

Include dependency graph for wap_push_pap_mime.c:

Include dependency graph

Go to the source code of this file.

Functions

int is_cr (int c)
int is_lf (int c)
int islwspchar (int c)
long octstr_drop_leading_blanks (Octstr **header_value)
void drop_separator (Octstr **header_value, long *pos)
int parse_preamble (Octstr **mime_content, Octstr *boundary)
long parse_transport_padding (Octstr *mime_content, long pos)
long parse_terminator (Octstr *mime_content, long pos)
int parse_body_part (Octstr **multipart, Octstr *boundary, Octstr **body_part)
int parse_encapsulation (Octstr **mime_content, Octstr *boundary, Octstr **push_data, List **content_headers, Octstr **rdf_content)
int check_control_headers (Octstr **body_part)
int check_control_content_type_header (Octstr **body_part, Octstr *boundary)
int drop_optional_header (Octstr **body_part, char *name, Octstr *boundary)
int drop_header_true (Octstr **body_part, long content_pos)
int drop_extension_headers (Octstr **mime_content, Octstr *boundary)
long parse_field_value (Octstr *pap_content, long pos)
long parse_field_name (Octstr *pap_content, long pos)
void octstr_split_by_pos (Octstr **mime_content, Octstr **pap_content, long boundary_pos)
Octstrmake_close_delimiter (Octstr *boundary)
Octstrmake_part_delimiter (Octstr *boundary)
Octstrmake_start_delimiter (Octstr *dash_boundary)
int pass_data_headers (Octstr **body_part, List **data_headers)
int check_data_content_type_header (Octstr **body_part, List **data_headers, Octstr *boundary)
int pass_optional_header (Octstr **body_part, char *name, List **content_headers, Octstr *boundary)
int pass_extension_headers (Octstr **body_part, List **data_headers, Octstr *boundary)
long pass_field_name (Octstr **body_part, Octstr **content_header, long pos)
long pass_field_value (Octstr **body_part, Octstr **content_header, long pos)
int parse_epilogue (Octstr **mime_content)
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)
long parse_close_delimiter (Octstr *close_delimiter, Octstr *mime_content, long pos)


Function Documentation

int check_control_content_type_header Octstr **  body_part,
Octstr boundary
[static]
 

Definition at line 444 of file wap_push_pap_mime.c.

References drop_header_true(), octstr_case_nsearch(), octstr_case_search(), octstr_imm(), and octstr_search().

Referenced by check_control_headers().

00445 {
00446     long content_pos;
00447     long message_start_pos;
00448 
00449     message_start_pos = octstr_search(*body_part, boundary, 0);
00450     if ((content_pos = octstr_case_nsearch(*body_part, octstr_imm("Content-Type:"), 0,
00451             message_start_pos)) < 0 || 
00452             octstr_case_search(*body_part, octstr_imm("application/xml"), 0) < 0) {
00453         return 0;
00454     }
00455 
00456     if (drop_header_true(body_part, content_pos) < 0)
00457         return 0;
00458     
00459     return 1;
00460 }

Here is the call graph for this function:

int check_control_headers Octstr **  body_part  )  [static]
 

Definition at line 427 of file wap_push_pap_mime.c.

References check_control_content_type_header(), drop_extension_headers(), drop_optional_header(), and octstr_imm().

Referenced by mime_parse().

00428 {
00429     if (check_control_content_type_header(body_part, octstr_imm("\r\n\r\n")) == 0)
00430         return 0;
00431     if (drop_optional_header(body_part, "Content-Transfer-Encoding:",
00432             octstr_imm("\r\n\r\n")) == 0)
00433         return 0;
00434     if (drop_optional_header(body_part, "Content-ID:", octstr_imm("\r\n\r\n")) == 0)
00435         return 0;
00436     if (drop_optional_header(body_part, "Content-Description:", octstr_imm("\r\n\r\n")) == 0)
00437         return 0;
00438     if (drop_extension_headers(body_part, octstr_imm("\r\n\r\n")) == 0)
00439         return 0;
00440 
00441     return 1;
00442 }

Here is the call graph for this function:

int check_data_content_type_header Octstr **  body_part,
List **  data_headers,
Octstr boundary
[static]
 

Definition at line 609 of file wap_push_pap_mime.c.

References error(), gwlist_append(), octstr_case_nsearch(), octstr_create, octstr_delete(), octstr_destroy(), octstr_duplicate, octstr_len(), octstr_search(), parse_terminator(), and pass_field_value().

Referenced by pass_data_headers().

00611 {
00612     long header_pos,
00613          next_header_pos;
00614     Octstr *content_header;
00615     long message_start_pos;
00616 
00617     header_pos = next_header_pos = -1;
00618     content_header = octstr_create("Content-Type");
00619     message_start_pos = octstr_search(*body_part, boundary, 0);
00620     
00621     if ((header_pos = octstr_case_nsearch(*body_part, content_header, 0,
00622              message_start_pos)) < 0) {
00623         goto error;
00624     }
00625     if ((next_header_pos = pass_field_value(body_part, &content_header, 
00626         header_pos + octstr_len(content_header))) < 0) {
00627         goto error;
00628     }
00629     if ((next_header_pos = parse_terminator(*body_part, next_header_pos)) < 0) {
00630         goto error;
00631     }
00632 
00633     octstr_delete(*body_part, header_pos, next_header_pos - header_pos);
00634     gwlist_append(*content_headers, octstr_duplicate(content_header));
00635     octstr_destroy(content_header);
00636 
00637     return 1;
00638 
00639 error:
00640     octstr_destroy(content_header);
00641     return 0;
00642 }

Here is the call graph for this function:

int drop_extension_headers Octstr **  mime_content,
Octstr boundary
[static]
 

Definition at line 504 of file wap_push_pap_mime.c.

References islwspchar(), octstr_case_nsearch(), octstr_case_search(), octstr_delete(), octstr_get_char(), octstr_imm(), parse_field_name(), parse_field_value(), and parse_terminator().

Referenced by check_control_headers().

00505 {
00506     long content_pos,
00507          next_header_pos;  
00508     long next_content_part_pos;
00509 
00510     next_content_part_pos = octstr_case_search(*body_part, boundary, 0);
00511     do {
00512         if ((content_pos = octstr_case_nsearch(*body_part, octstr_imm("Content"), 0,
00513                 next_content_part_pos)) < 0)
00514             return 1;
00515         if ((next_header_pos = parse_field_name(*body_part, content_pos)) < 0)
00516             return 0;
00517         if ((next_header_pos = parse_field_value(*body_part, 
00518                  next_header_pos)) < 0)
00519         return 0;
00520         if ((next_header_pos = parse_terminator(*body_part, 
00521                  next_header_pos)) == 0)
00522             return 0;
00523     } while (islwspchar(octstr_get_char(*body_part, next_header_pos)));
00524 
00525     octstr_delete(*body_part, content_pos, next_header_pos - content_pos);
00526    
00527     return 1;
00528 }

Here is the call graph for this function:

int drop_header_true Octstr **  body_part,
long  content_pos
[static]
 

Definition at line 467 of file wap_push_pap_mime.c.

References octstr_delete(), parse_field_value(), and parse_terminator().

Referenced by check_control_content_type_header(), and drop_optional_header().

00468 {
00469     long next_header_pos;
00470 
00471     next_header_pos = -1;
00472     if ((next_header_pos = parse_field_value(*body_part, content_pos)) == 0)
00473         return 0;
00474     if ((next_header_pos = parse_terminator(*body_part, next_header_pos)) == 0)
00475         return 0;
00476     octstr_delete(*body_part, 0, next_header_pos);
00477 
00478     return 1;
00479 }

Here is the call graph for this function:

int drop_optional_header Octstr **  body_part,
char *  name,
Octstr boundary
[static]
 

Definition at line 481 of file wap_push_pap_mime.c.

References drop_header_true(), name, octstr_case_nsearch(), octstr_imm(), and octstr_search().

Referenced by check_control_headers().

00482 {
00483     long content_pos;
00484     long message_start_pos;
00485          
00486     content_pos = -1;
00487     message_start_pos = octstr_search(*body_part, boundary, 0);
00488 
00489     if ((content_pos = octstr_case_nsearch(*body_part, octstr_imm(name), 0, message_start_pos)) < 0)
00490         return 1;
00491     
00492     if (drop_header_true(body_part, content_pos) < 0)
00493         return 0;
00494 
00495     return 1;
00496 }

Here is the call graph for this function:

void drop_separator Octstr **  header_value,
long *  pos
[static]
 

Definition at line 694 of file wap_push_pap_mime.c.

References octstr_delete(), and octstr_drop_leading_blanks().

Referenced by pass_extension_headers(), and pass_optional_header().

00695 {
00696    long count;
00697 
00698    octstr_delete(*header_value, 0, 1);            /* remove :*/
00699    count = octstr_drop_leading_blanks(header_value);
00700    pos = pos - 1 - count;
00701 } 

Here is the call graph for this function:

int is_cr int  c  )  [static]
 

Definition at line 183 of file wap_push_pap_mime.c.

Referenced by parse_field_value(), parse_terminator(), and pass_field_value().

00184 {
00185     return c == '\r';
00186 }

int is_lf int  c  )  [static]
 

Definition at line 188 of file wap_push_pap_mime.c.

Referenced by parse_field_value(), and parse_terminator().

00189 {
00190     return c == '\n';
00191 }

int islwspchar int  c  )  [static]
 

Definition at line 196 of file wap_push_pap_mime.c.

Referenced by drop_extension_headers(), parse_transport_padding(), and pass_extension_headers().

00197 {
00198     return c == '\t' || c == ' ';
00199 }

Octstr * make_close_delimiter Octstr boundary  )  [static]
 

Definition at line 389 of file wap_push_pap_mime.c.

References make_part_delimiter(), and octstr_format_append().

00390 {
00391     Octstr *close_delimiter;
00392 
00393     close_delimiter = make_part_delimiter(boundary);
00394     octstr_format_append(close_delimiter, "%s", "--");
00395 
00396     return close_delimiter;
00397 }

Here is the call graph for this function:

Octstr * make_part_delimiter Octstr boundary  )  [static]
 

Definition at line 399 of file wap_push_pap_mime.c.

References octstr_append(), and octstr_create.

00400 {
00401     Octstr *part_delimiter;
00402 
00403     part_delimiter = octstr_create("\r\n--");
00404     octstr_append(part_delimiter, dash_boundary);
00405     
00406     return part_delimiter;
00407 }

Here is the call graph for this function:

Octstr * make_start_delimiter Octstr dash_boundary  )  [static]
 

Definition at line 409 of file wap_push_pap_mime.c.

References octstr_append(), and octstr_create.

Referenced by parse_preamble().

00410 {
00411     Octstr *start_delimiter;
00412 
00413     start_delimiter = octstr_create("--");
00414     octstr_append(start_delimiter, dash_boundary);
00415 
00416     return start_delimiter;
00417 }

Here is the call graph for this function:

int mime_parse Octstr boundary,
Octstr mime_content,
Octstr **  pap_content,
Octstr **  push_data,
List **  content_headers,
Octstr **  rdf_content
 

Definition at line 130 of file wap_push_pap_mime.c.

References check_control_headers(), gw_assert, octstr_len(), parse_body_part(), parse_encapsulation(), parse_epilogue(), parse_preamble(), and warning().

Referenced by main(), and pap_request_thread().

00133 {
00134     int ret;
00135 
00136     *pap_content = NULL;
00137     *push_data = NULL;
00138     *content_headers = NULL;
00139     *rdf_content = NULL;
00140 
00141     if (parse_preamble(&mime_content, boundary) < 0) {
00142         warning(0, "erroneous preamble");
00143         return 0;
00144     }
00145     if (parse_body_part(&mime_content, boundary, pap_content) <= 0) {
00146         warning(0, "erroneous control entity");
00147         return 0;
00148     }
00149     if (check_control_headers(pap_content) == 0) {
00150         warning(0, "erroneous control headers");
00151         return 0;
00152     }
00153 
00154     ret = -1;
00155     if ((ret = parse_encapsulation(&mime_content, boundary, push_data, 
00156                                    content_headers, rdf_content)) < 0) {
00157         warning(0, "erroneous content entity (push message)");
00158         return 0;
00159     } else if (ret == 0) {
00160         gw_assert(*rdf_content == NULL);
00161         if (octstr_len(mime_content) != 0)
00162             parse_epilogue(&mime_content);
00163         return 1;
00164     }
00165 
00166     if (check_control_headers(rdf_content) == 0) {
00167         warning(0, "erroneous capacity (rdf) headers");
00168         return 0;
00169     }
00170 
00171     if (octstr_len(mime_content) != 0)
00172         parse_epilogue(&mime_content);
00173     gw_assert(octstr_len(mime_content) == 0);
00174     
00175     return 1;
00176 }

Here is the call graph for this function:

long octstr_drop_leading_blanks Octstr **  header_value  )  [static]
 

Definition at line 706 of file wap_push_pap_mime.c.

References octstr_delete(), and octstr_get_char().

Referenced by drop_separator().

00707 {
00708     long count;
00709 
00710     count = 0;
00711     while (octstr_get_char(*header_value, 0) == ' ') {
00712         octstr_delete(*header_value, 0, 1);
00713         ++count;
00714     }
00715 
00716     return count;
00717 }

Here is the call graph for this function:

void octstr_split_by_pos Octstr **  mime_content,
Octstr **  pap_content,
long  boundary_pos
[static]
 

Definition at line 382 of file wap_push_pap_mime.c.

References octstr_copy, and octstr_delete().

Referenced by parse_body_part().

00384 {
00385     *os2 = octstr_copy(*os1, 0, boundary_pos);
00386     octstr_delete(*os1, 0, boundary_pos);
00387 }

Here is the call graph for this function:

int parse_body_part Octstr **  multipart,
Octstr boundary,
Octstr **  body_part
[static]
 

Definition at line 288 of file wap_push_pap_mime.c.

References error(), make_close_delimiter(), make_part_delimiter(), octstr_delete(), octstr_destroy(), octstr_search(), octstr_split_by_pos(), parse_close_delimiter(), parse_tail(), and parse_transport_padding().

Referenced by mime_parse(), and parse_encapsulation().

00290 {
00291     Octstr *part_delimiter,
00292            *close_delimiter;
00293     long boundary_pos,          /* start of the boundary */
00294          close_delimiter_pos,   /* start of the close delimiter */
00295          next_part_pos,         /* start of the next part */
00296          epilogue_pos;          /* start of the epilogue */
00297  
00298     part_delimiter = make_part_delimiter(boundary);
00299     close_delimiter = make_close_delimiter(boundary);
00300 
00301     if ((close_delimiter_pos = octstr_search(*multipart, 
00302             close_delimiter, 0)) < 0) 
00303         goto error;
00304 
00305     boundary_pos = octstr_search(*multipart, part_delimiter, 0);
00306     if (boundary_pos == close_delimiter_pos) {
00307         octstr_split_by_pos(multipart, body_part, close_delimiter_pos);
00308         if ((epilogue_pos = 
00309                 parse_close_delimiter(close_delimiter, *multipart, 0)) < 0)
00310             goto error;
00311         epilogue_pos = parse_transport_padding(*multipart, epilogue_pos);
00312         octstr_delete(*multipart, 0, epilogue_pos);
00313     goto last_part;
00314     }
00315 
00316     octstr_split_by_pos(multipart, body_part, boundary_pos);
00317 
00318     if (parse_tail(multipart, part_delimiter, 0, &next_part_pos) < 0) {
00319         goto error;
00320     }
00321 
00322     octstr_delete(*multipart, 0, next_part_pos);
00323     octstr_destroy(part_delimiter);
00324     octstr_destroy(close_delimiter);
00325 
00326     return 1;
00327 
00328 error:
00329     octstr_destroy(part_delimiter);
00330     octstr_destroy(close_delimiter);
00331     return -1;
00332 
00333 last_part:
00334     octstr_destroy(part_delimiter);
00335     octstr_destroy(close_delimiter);
00336     return 0;
00337 
00338 }

Here is the call graph for this function:

long parse_close_delimiter Octstr close_delimiter,
Octstr mime_content,
long  pos
[static]
 

Definition at line 268 of file wap_push_pap_mime.c.

References octstr_len(), and octstr_ncompare().

Referenced by parse_body_part().

00270 {
00271     if (octstr_ncompare(close_delimiter, mime_content, 
00272                         octstr_len(close_delimiter)) != 0)
00273         return -1;
00274     pos += octstr_len(close_delimiter);
00275 
00276     return pos;
00277 }

Here is the call graph for this function:

int parse_encapsulation Octstr **  mime_content,
Octstr boundary,
Octstr **  push_data,
List **  content_headers,
Octstr **  rdf_content
[static]
 

Definition at line 353 of file wap_push_pap_mime.c.

References parse_body_part(), and pass_data_headers().

Referenced by mime_parse().

00356 {
00357     int ret;
00358 
00359     ret = -1;
00360     if ((ret = parse_body_part(mime_content, boundary, push_data)) < 0)
00361         return -1;
00362     if (pass_data_headers(push_data, content_headers) == 0)
00363         return -1;
00364 
00365     if (ret == 0) {
00366         *rdf_content = NULL;
00367         return 0;
00368     }
00369 
00370     if ((ret = parse_body_part(mime_content, boundary, rdf_content)) < 0 || 
00371             ret > 0)
00372         return -1;
00373     else if (ret == 0)
00374         return 1;
00375     
00376     return 1;
00377 }

Here is the call graph for this function:

int parse_epilogue Octstr **  mime_content  )  [static]
 

Definition at line 823 of file wap_push_pap_mime.c.

References octstr_delete(), octstr_len(), and parse_terminator().

Referenced by mime_parse().

00824 {
00825     long pos;
00826 
00827     if (octstr_len(*mime_content) == 0)
00828         return 0;
00829     
00830     if ((pos = parse_terminator(*mime_content, 0)) < 0)
00831         return -1;
00832 
00833     octstr_delete(*mime_content, 0, octstr_len(*mime_content));
00834     return 0;
00835 }

Here is the call graph for this function:

long parse_field_name Octstr pap_content,
long  pos
[static]
 

Definition at line 554 of file wap_push_pap_mime.c.

References octstr_get_char(), and octstr_len().

Referenced by drop_extension_headers().

00555 {
00556     while (octstr_get_char(content, pos) != ':' && 
00557                pos < octstr_len(content))
00558            ++pos;
00559 
00560     if (pos == octstr_len(content))
00561         return -1;
00562 
00563     return pos;
00564 }

Here is the call graph for this function:

long parse_field_value Octstr pap_content,
long  pos
[static]
 

Definition at line 530 of file wap_push_pap_mime.c.

References is_cr(), is_lf(), octstr_get_char(), and octstr_len().

Referenced by drop_extension_headers(), and drop_header_true().

00531 {
00532     int c;
00533 
00534     while (!is_cr(c = octstr_get_char(pap_content, pos)) &&
00535          pos < octstr_len(pap_content)) {
00536          ++pos;
00537     }
00538  
00539     if (is_lf(c)) {
00540         if (is_lf(octstr_get_char(pap_content, pos))) {
00541         ++pos;
00542         } else {
00543         return -1;
00544         }
00545     }
00546 
00547     if (pos == octstr_len(pap_content)) {
00548         return -1;
00549     }
00550 
00551     return pos;
00552 }

Here is the call graph for this function:

int parse_preamble Octstr **  mime_content,
Octstr boundary
[static]
 

Definition at line 219 of file wap_push_pap_mime.c.

References error(), make_start_delimiter(), octstr_delete(), octstr_destroy(), octstr_search(), and parse_tail().

Referenced by mime_parse().

00220 {
00221     long boundary_pos,
00222          next_part_pos;
00223     Octstr *dash_boundary;
00224 
00225     boundary_pos = next_part_pos = -1;
00226     dash_boundary = make_start_delimiter(boundary);
00227     
00228     if ((boundary_pos = octstr_search(*mime_content, dash_boundary, 0)) < 0)
00229         goto error;
00230 
00231     if (parse_tail(mime_content, dash_boundary, boundary_pos, 
00232             &next_part_pos) < 0) 
00233         goto error;
00234 
00235     octstr_delete(*mime_content, 0, next_part_pos);
00236     octstr_destroy(dash_boundary);
00237 
00238     return 0;
00239 
00240 error:
00241     octstr_destroy(dash_boundary);
00242     return -1;
00243 }

Here is the call graph for this function:

int parse_tail Octstr **  multipart,
Octstr part_delimiter,
long  boundary_pos,
long *  next_part_pos
[static]
 

Definition at line 202 of file wap_push_pap_mime.c.

References octstr_len(), parse_terminator(), and parse_transport_padding().

Referenced by parse_body_part(), and parse_preamble().

00204 {
00205     *next_part_pos = parse_transport_padding(*multipart, 
00206          boundary_pos + octstr_len(delimiter));
00207 
00208     if ((*next_part_pos = parse_terminator(*multipart, *next_part_pos)) < 0)
00209         return -1;
00210     
00211     return 0;
00212 }

Here is the call graph for this function:

long parse_terminator Octstr mime_content,
long  pos
[static]
 

Definition at line 245 of file wap_push_pap_mime.c.

References is_cr(), is_lf(), and octstr_get_char().

Referenced by check_data_content_type_header(), drop_extension_headers(), drop_header_true(), parse_epilogue(), parse_tail(), pass_extension_headers(), and pass_optional_header().

00246 {
00247     if (is_cr(octstr_get_char(mime_content, pos)))
00248         ++pos;
00249     else 
00250         return -1;
00251 
00252     if (is_lf(octstr_get_char(mime_content, pos)))
00253         ++pos;
00254     else 
00255         return -1;
00256 
00257     return pos;
00258 }

Here is the call graph for this function:

long parse_transport_padding Octstr mime_content,
long  pos
[static]
 

Definition at line 260 of file wap_push_pap_mime.c.

References islwspchar(), and octstr_get_char().

Referenced by parse_body_part(), and parse_tail().

00261 {
00262     while (islwspchar(octstr_get_char(mime_content, pos)))
00263         ++pos;
00264 
00265     return pos;
00266 }

Here is the call graph for this function:

int pass_data_headers Octstr **  body_part,
List **  data_headers
[static]
 

Definition at line 575 of file wap_push_pap_mime.c.

References check_data_content_type_header(), http_create_empty_headers(), octstr_delete(), octstr_imm(), octstr_len(), pass_extension_headers(), pass_optional_header(), and warning().

Referenced by parse_encapsulation().

00576 {
00577     *data_headers = http_create_empty_headers();
00578 
00579     if (check_data_content_type_header(body_part, data_headers, octstr_imm("\r\n\r\n")) == 0) {
00580         warning(0, "MIME: pass_data_headers: Content-Type header missing"); 
00581         return 0;
00582     }
00583         
00584     if (pass_optional_header(body_part, "Content-Transfer-Encoding", data_headers,
00585             octstr_imm("\r\n\r\n")) < 0)
00586         goto operror;
00587     if (pass_optional_header(body_part, "Content-ID", data_headers, octstr_imm("\r\n\r\n")) < 0)
00588         goto operror;
00589     if (pass_optional_header(body_part, "Content-Description", data_headers, 
00590             octstr_imm("\r\n\r\n")) < 0)
00591         goto operror;
00592     if (pass_extension_headers(body_part, data_headers, octstr_imm("\r\n\r\n")) == 0)
00593         goto operror;
00594    
00595     octstr_delete(*body_part, 0, octstr_len(octstr_imm("\r\n")));   
00596 
00597     return 1;
00598 
00599 operror:
00600     warning(0, "MIME: pass_data_headers: an unparsable optional header");
00601     return 0;
00602 }

Here is the call graph for this function:

int pass_extension_headers Octstr **  body_part,
List **  data_headers,
Octstr boundary
[static]
 

Definition at line 725 of file wap_push_pap_mime.c.

References drop_separator(), error(), http_header_add(), islwspchar(), octstr_case_nsearch(), octstr_create, octstr_delete(), octstr_destroy(), octstr_get_char(), octstr_get_cstr, octstr_imm(), octstr_search(), parse_terminator(), pass_field_name(), and pass_field_value().

Referenced by pass_data_headers().

00726 {
00727     long next_field_part_pos,
00728          count;  
00729     Octstr *header_name,
00730            *header_value; 
00731     long next_content_part_pos;
00732 
00733     header_name = octstr_create("");
00734     header_value = octstr_create("");
00735     count = 0;
00736     next_field_part_pos = 0;
00737     next_content_part_pos = octstr_search(*body_part, boundary, 0);
00738 
00739     do {
00740         if ((octstr_case_nsearch(*body_part, octstr_imm("Content"), 0,
00741                 next_content_part_pos)) < 0)
00742             goto end; 
00743         if ((next_field_part_pos = pass_field_name(body_part, &header_name,
00744                  next_field_part_pos)) < 0)
00745             goto error;
00746         if ((next_field_part_pos = pass_field_value(body_part, &header_value, 
00747                  next_field_part_pos)) < 0)
00748             goto error;
00749         if ((next_field_part_pos = parse_terminator(*body_part, 
00750                  next_field_part_pos)) == 0)
00751             goto error;
00752         drop_separator(&header_value, &next_field_part_pos);
00753         http_header_add(*content_headers, octstr_get_cstr(header_name), 
00754             octstr_get_cstr(header_value));
00755     } while (islwspchar(octstr_get_char(*body_part, next_field_part_pos)));
00756 
00757     octstr_delete(*body_part, 0, next_field_part_pos);
00758 
00759 /*
00760  * An intentional fall-through. We must eventually use a function for memory
00761  * cleaning.
00762  */
00763 end:
00764     octstr_destroy(header_name);
00765     octstr_destroy(header_value);
00766     return 1;
00767 
00768 error:
00769     octstr_destroy(header_name);
00770     octstr_destroy(header_value);
00771     return 0;
00772 }

Here is the call graph for this function:

long pass_field_name Octstr **  body_part,
Octstr **  content_header,
long  pos
[static]
 

Definition at line 798 of file wap_push_pap_mime.c.

References name, octstr_append(), octstr_copy, octstr_destroy(), octstr_get_char(), and octstr_len().

Referenced by pass_extension_headers().

00800 {
00801     int c;
00802     long start;
00803     Octstr *name = NULL;
00804 
00805     start = pos;
00806     while (((c = octstr_get_char(*body_part, pos)) != ':') &&
00807             pos < octstr_len(*body_part)) {
00808         ++pos;
00809     }
00810 
00811     if (pos == octstr_len(*body_part)) {
00812         return -1;
00813     }
00814 
00815     name = octstr_copy(*body_part, start, pos - start);
00816     octstr_append(*field_part, name);
00817 
00818     octstr_destroy(name);
00819     return pos;
00820 }

Here is the call graph for this function:

long pass_field_value Octstr **  body_part,
Octstr **  content_header,
long  pos
[static]
 

Definition at line 774 of file wap_push_pap_mime.c.

References is_cr(), octstr_append(), octstr_copy, octstr_destroy(), octstr_get_char(), and octstr_len().

Referenced by check_data_content_type_header(), pass_extension_headers(), and pass_optional_header().

00776 {
00777     int c;
00778     long start;
00779     Octstr *field = NULL;
00780 
00781     start = pos;
00782     while (!is_cr(c = octstr_get_char(*body_part, pos)) &&
00783              pos < octstr_len(*body_part)) {
00784         ++pos;
00785     }
00786  
00787     if (pos == octstr_len(*body_part)) {
00788         return -1;
00789     }
00790 
00791     field = octstr_copy(*body_part, start, pos - start);
00792     octstr_append(*header, field);
00793 
00794     octstr_destroy(field);
00795     return pos;
00796 }

Here is the call graph for this function:

int pass_optional_header Octstr **  body_part,
char *  name,
List **  content_headers,
Octstr boundary
[static]
 

Definition at line 649 of file wap_push_pap_mime.c.

References drop_separator(), error(), http_header_add(), name, octstr_case_nsearch(), octstr_create, octstr_delete(), octstr_destroy(), octstr_get_cstr, octstr_len(), octstr_search(), parse_terminator(), and pass_field_value().

Referenced by pass_data_headers().

00651 {
00652     long content_pos,
00653          next_header_pos;
00654     Octstr *osname,
00655            *osvalue;
00656     long message_start_pos;
00657 
00658     content_pos = next_header_pos = -1;
00659     osname = octstr_create(name);
00660     osvalue = octstr_create("");
00661     message_start_pos = octstr_search(*body_part, boundary, 0);
00662 
00663     if ((content_pos = octstr_case_nsearch(*body_part, osname, 0, message_start_pos)) < 0) 
00664         goto noheader;
00665     if ((next_header_pos = pass_field_value(body_part, &osvalue, 
00666          content_pos + octstr_len(osname))) < 0)
00667         goto error;   
00668     if ((next_header_pos = 
00669          parse_terminator(*body_part, next_header_pos)) == 0)
00670         goto error;
00671 
00672     drop_separator(&osvalue, &next_header_pos);
00673     http_header_add(*content_headers, name, octstr_get_cstr(osvalue));
00674     octstr_delete(*body_part, content_pos, next_header_pos - content_pos);
00675 
00676     octstr_destroy(osname);
00677     octstr_destroy(osvalue);
00678     return 1;
00679 
00680 error:
00681     octstr_destroy(osvalue);
00682     octstr_destroy(osname);
00683     return -1;
00684 
00685 noheader:
00686     octstr_destroy(osvalue);
00687     octstr_destroy(osname);
00688     return 0;
00689 }

Here is the call graph for this function:

See file LICENSE for details about the license agreement for using, modifying, copying or deriving work from this software.