#include "gwlib/gwlib.h"Include dependency graph for mime.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.
Typedefs | |
| typedef MIMEEntity | MIMEEntity |
Functions | |
| MIMEEntity * | mime_entity_create (void) |
| void | mime_entity_destroy (MIMEEntity *e) |
| MIMEEntity * | mime_entity_duplicate (MIMEEntity *e) |
| void | mime_replace_headers (MIMEEntity *e, List *headers) |
| int | mime_entity_num_parts (MIMEEntity *e) |
| void | mime_entity_add_part (MIMEEntity *e, MIMEEntity *part) |
| MIMEEntity * | mime_entity_get_part (MIMEEntity *e, int i) |
| void | mime_entity_replace_part (MIMEEntity *e, int i, MIMEEntity *newpart) |
| void | mime_entity_remove_part (MIMEEntity *e, int i) |
| void | mime_entity_set_body (MIMEEntity *e, Octstr *body) |
| MIMEEntity * | mime_multipart_start_elem (MIMEEntity *e) |
| MIMEEntity * | mime_octstr_to_entity (Octstr *mime) |
| MIMEEntity * | mime_http_to_entity (List *headers, Octstr *body) |
| Octstr * | mime_entity_to_octstr (MIMEEntity *m) |
| List * | mime_entity_headers (MIMEEntity *m) |
| Octstr * | mime_entity_body (MIMEEntity *m) |
| void | mime_entity_dump (MIMEEntity *m) |
|
|
|
|
||||||||||||
|
Definition at line 560 of file mime.c. References gw_assert, gwlist_append(), mime_entity_duplicate(), and MIMEEntity::multiparts. 00561 {
00562 gw_assert(e != NULL);
00563 gw_assert(part != NULL);
00564
00565 gwlist_append(e->multiparts, mime_entity_duplicate(part));
00566 }
|
Here is the call graph for this function:

|
|
Definition at line 485 of file mime.c. References MIMEEntity::body, debug(), gw_assert, MIMEEntity::headers, m, mime_entity_create(), mime_entity_destroy(), mime_entity_num_parts(), mime_entity_to_octstr(), octstr_destroy(), octstr_dump, octstr_duplicate, parse_context_create(), parse_context_destroy(), parse_get_rest(), ParseContext, and read_mime_headers(). 00486 {
00487 Octstr *os, *body;
00488 ParseContext *context;
00489 MIMEEntity *e;
00490
00491 gw_assert(m != NULL && m->headers != NULL);
00492
00493 /* For non-multipart, return body directly. */
00494 if (mime_entity_num_parts(m) == 0)
00495 return octstr_duplicate(m->body);
00496
00497 os = mime_entity_to_octstr(m);
00498 context = parse_context_create(os);
00499 e = mime_entity_create();
00500
00501 /* parse the headers up to the body */
00502 if ((read_mime_headers(context, e->headers) != 0) || e->headers == NULL) {
00503 debug("mime.parse",0,"Failed to read MIME headers in Octstr block:");
00504 octstr_dump(os, 0);
00505 mime_entity_destroy(e);
00506 parse_context_destroy(context);
00507 return NULL;
00508 }
00509
00510 /* the rest is the body */
00511 body = parse_get_rest(context);
00512
00513 octstr_destroy(os);
00514 mime_entity_destroy(e);
00515 parse_context_destroy(context);
00516
00517 return body;
00518 }
|
Here is the call graph for this function:

|
|
Definition at line 87 of file mime.c. References MIMEEntity::body, gwlist_create, MIMEEntity::headers, http_create_empty_headers(), MIMEEntity::multiparts, and MIMEEntity::start. Referenced by mime_entity_body(), mime_entity_duplicate(), and mime_something_to_entity(). 00088 {
00089 MIMEEntity *e;
00090
00091 e = gw_malloc(sizeof(MIMEEntity));
00092 e->headers = http_create_empty_headers();
00093 e->multiparts = gwlist_create();
00094 e->body = NULL;
00095 e->start = NULL;
00096
00097 return e;
00098 }
|
Here is the call graph for this function:

|
|
Definition at line 105 of file mime.c. References MIMEEntity::body, gw_assert, gwlist_destroy(), MIMEEntity::headers, mime_entity_destroy_item(), MIMEEntity::multiparts, octstr_destroy(), octstr_destroy_item(), and MIMEEntity::start. Referenced by main(), mime_entity_body(), mime_entity_destroy_item(), mime_entity_remove_part(), mime_entity_replace_part(), and mime_something_to_entity(). 00106 {
00107 gw_assert(e != NULL);
00108
00109 if (e->headers != NULL)
00110 gwlist_destroy(e->headers, octstr_destroy_item);
00111 if (e->multiparts != NULL)
00112 gwlist_destroy(e->multiparts, mime_entity_destroy_item);
00113 octstr_destroy(e->body);
00114 e->start = NULL; /* will be destroyed on it's own via gwlist_destroy */
00115
00116 gw_free(e);
00117 }
|
Here is the call graph for this function:

|
|
Definition at line 717 of file mime.c. References debug(), gw_assert, MIMEEntity::headers, m, and mime_entity_dump_real(). Referenced by main(). 00718 {
00719 gw_assert(m != NULL && m->headers != NULL);
00720
00721 debug("mms",0,"Dumping MIMEEntity at address %p", m);
00722 mime_entity_dump_real(m, 0);
00723 }
|
Here is the call graph for this function:

|
|
Definition at line 521 of file mime.c. References MIMEEntity::body, gwlist_append(), gwlist_get(), gwlist_len(), MIMEEntity::headers, mime_entity_create(), mime_entity_duplicate(), mime_replace_headers(), MIMEEntity::multiparts, and octstr_duplicate. Referenced by mime_entity_add_part(), mime_entity_duplicate(), mime_entity_get_part(), mime_entity_replace_part(), and mime_multipart_start_elem(). 00522 {
00523 MIMEEntity *copy = mime_entity_create();
00524 int i, n;
00525
00526 mime_replace_headers(copy, e->headers);
00527 copy->body = e->body ? octstr_duplicate(e->body) : NULL;
00528
00529 for (i = 0, n = gwlist_len(e->multiparts); i < n; i++)
00530 gwlist_append(copy->multiparts,
00531 mime_entity_duplicate(gwlist_get(e->multiparts, i)));
00532 return copy;
00533 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 570 of file mime.c. References gw_assert, gwlist_get(), m, mime_entity_duplicate(), and MIMEEntity::multiparts. 00571 {
00572 MIMEEntity *m;
00573 gw_assert(e != NULL);
00574 gw_assert(i >= 0);
00575 gw_assert(i < gwlist_len(e->multiparts));
00576
00577 m = gwlist_get(e->multiparts, i);
00578 gw_assert(m);
00579 return mime_entity_duplicate(m);
00580 }
|
Here is the call graph for this function:

|
|
Definition at line 469 of file mime.c. References fix_boundary_element(), gw_assert, MIMEEntity::headers, http_header_duplicate(), m, and mime_entity_num_parts(). 00470 {
00471 List *headers;
00472
00473 gw_assert(m != NULL && m->headers != NULL);
00474
00475 /* Need a fixup before hand over. */
00476 if (mime_entity_num_parts(m) > 0)
00477 fix_boundary_element(m->headers, NULL);
00478
00479 headers = http_header_duplicate(m->headers);
00480
00481 return headers;
00482 }
|
Here is the call graph for this function:

|
|
Definition at line 550 of file mime.c. References gw_assert, gwlist_len(), and MIMEEntity::multiparts. Referenced by mime_entity_body(), and mime_entity_headers(). 00551 {
00552 gw_assert(e != NULL);
00553 return e->multiparts ? gwlist_len(e->multiparts) : 0;
00554 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 584 of file mime.c. References gw_assert, gwlist_delete(), gwlist_get(), m, mime_entity_destroy(), MIMEEntity::multiparts, and MIMEEntity::start. 00585 {
00586 MIMEEntity *m;
00587
00588 gw_assert(e != NULL);
00589 gw_assert(i >= 0);
00590 gw_assert(i < gwlist_len(e->multiparts));
00591
00592
00593 m = gwlist_get(e->multiparts, i);
00594 gwlist_delete(e->multiparts, i, 1);
00595 if (m == e->start) e->start = NULL;
00596
00597 mime_entity_destroy(m);
00598 }
|
Here is the call graph for this function:

|
||||||||||||||||
|
Definition at line 601 of file mime.c. References gw_assert, gwlist_delete(), gwlist_get(), gwlist_insert(), m, mime_entity_destroy(), mime_entity_duplicate(), MIMEEntity::multiparts, and MIMEEntity::start. 00602 {
00603
00604 MIMEEntity *m;
00605
00606 gw_assert(e != NULL);
00607 gw_assert(i >= 0);
00608 gw_assert(i < gwlist_len(e->multiparts));
00609
00610 m = gwlist_get(e->multiparts, i);
00611 gwlist_delete(e->multiparts, i, 1);
00612 gwlist_insert(e->multiparts, i, mime_entity_duplicate(newpart));
00613 if (m == e->start) e->start = NULL;
00614
00615 mime_entity_destroy(m);
00616 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 622 of file mime.c. References MIMEEntity::body, gw_assert, octstr_destroy(), and octstr_duplicate. 00623 {
00624 gw_assert(e != NULL);
00625 gw_assert(body != NULL);
00626
00627 if (e->body)
00628 octstr_destroy(e->body);
00629 e->body = octstr_duplicate(body);
00630 }
|
Here is the call graph for this function:

|
|
Definition at line 216 of file mime.c. References MIMEEntity::body, fix_boundary_element(), gw_assert, gwlist_get(), gwlist_len(), MIMEEntity::headers, http_destroy_headers(), http_header_duplicate(), m, MIMEEntity::multiparts, octstr_append(), octstr_create, octstr_destroy(), and octstr_imm(). Referenced by main(), and mime_entity_body(). 00217 {
00218 Octstr *mime, *boundary = NULL;
00219 List *headers;
00220 long i;
00221
00222 gw_assert(m != NULL && m->headers != NULL);
00223
00224 mime = octstr_create("");
00225
00226 /*
00227 * First of all check if we have further MIME entity dependencies,
00228 * which means we have further MIMEEntities in our m->multiparts
00229 * list. If no, then add headers and body and return. This is the
00230 * easy case. Otherwise we have to loop inside our entities.
00231 */
00232 if (gwlist_len(m->multiparts) == 0) {
00233 for (i = 0; i < gwlist_len(m->headers); i++) {
00234 octstr_append(mime, gwlist_get(m->headers, i));
00235 octstr_append(mime, octstr_imm("\r\n"));
00236 }
00237 octstr_append(mime, octstr_imm("\r\n"));
00238 if (m->body != NULL)
00239 octstr_append(mime, m->body);
00240 goto finished;
00241 }
00242
00243 /* This call ensures boundary exists, and returns it */
00244 fix_boundary_element(m->headers, &boundary);
00245 headers = http_header_duplicate(m->headers);
00246
00247 /* headers */
00248 for (i = 0; i < gwlist_len(headers); i++) {
00249 octstr_append(mime, gwlist_get(headers, i));
00250 octstr_append(mime, octstr_imm("\r\n"));
00251 }
00252 http_destroy_headers(headers);
00253 octstr_append(mime, octstr_imm("\r\n")); /* Mark end of headers. */
00254
00255 /* loop through all MIME multipart entities of this entity */
00256 for (i = 0; i < gwlist_len(m->multiparts); i++) {
00257 MIMEEntity *e = gwlist_get(m->multiparts, i);
00258 Octstr *body;
00259
00260 octstr_append(mime, octstr_imm("\r\n--"));
00261 octstr_append(mime, boundary);
00262 octstr_append(mime, octstr_imm("\r\n"));
00263
00264 /* call ourself to produce the MIME entity body */
00265 body = mime_entity_to_octstr(e);
00266 octstr_append(mime, body);
00267
00268 octstr_destroy(body);
00269 }
00270
00271 octstr_append(mime, octstr_imm("\r\n--"));
00272 octstr_append(mime, boundary);
00273 octstr_append(mime, octstr_imm("--\r\n"));
00274
00275 octstr_destroy(boundary);
00276
00277 finished:
00278
00279 return mime;
00280 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 461 of file mime.c. References gw_assert, and mime_something_to_entity(). 00462 {
00463 gw_assert(headers != NULL && body != NULL);
00464
00465 return mime_something_to_entity(body, headers);
00466 }
|
Here is the call graph for this function:

|
|
Definition at line 633 of file mime.c. References cid_matches(), get_start_param(), gw_assert, gwlist_get(), gwlist_len(), MIMEEntity::headers, http_header_value(), mime_entity_duplicate(), MIMEEntity::multiparts, octstr_destroy(), octstr_imm(), and MIMEEntity::start. 00634 {
00635 gw_assert(e != NULL);
00636
00637 /* If e->start element is not yet set, set it as follows:
00638 * - if content type is not set, then set it to NULL
00639 * - if the start element is not set but this is a multipart object, set
00640 * it to first multipart element, else set it to null
00641 * - if the start element of the content type is set, find a matching object
00642 * and set e->start accordingly.
00643 * Finally, return a copy of it.
00644 */
00645 if (!e->start) {
00646 Octstr *ctype = http_header_value(e->headers, octstr_imm("Content-Type"));
00647 Octstr *start = get_start_param(ctype);
00648 int i;
00649
00650 if (!ctype)
00651 e->start = NULL;
00652 else if (!start) {
00653 if (gwlist_len(e->multiparts) > 0)
00654 e->start = gwlist_get(e->multiparts, 0);
00655 else
00656 e->start = NULL;
00657 } else
00658 for (i = 0; i < gwlist_len(e->multiparts); i++) {
00659 MIMEEntity *x = gwlist_get(e->multiparts, i);
00660 if (cid_matches(x->headers, start)) {
00661 e->start = x;
00662 break;
00663 }
00664 }
00665
00666 if (ctype)
00667 octstr_destroy(ctype);
00668 if (start)
00669 octstr_destroy(start);
00670 }
00671
00672 return (e->start) ? mime_entity_duplicate(e->start) : NULL;
00673 }
|
Here is the call graph for this function:

|
|
Definition at line 453 of file mime.c. References gw_assert, and mime_something_to_entity(). Referenced by main(), and mime_something_to_entity(). 00454 {
00455 gw_assert(mime != NULL);
00456
00457 return mime_something_to_entity(mime, NULL);
00458 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 536 of file mime.c. References gw_assert, MIMEEntity::headers, http_destroy_headers(), http_header_duplicate(), and MIMEEntity::start. Referenced by mime_entity_duplicate(). 00537 {
00538 gw_assert(e != NULL);
00539 gw_assert(headers != NULL);
00540
00541 http_destroy_headers(e->headers);
00542 e->headers = http_header_duplicate(headers);
00543 e->start = NULL; /* clear it, since header change means it could have changed.*/
00544 }
|
Here is the call graph for this function:
