- if (strchr(disposition, ';'))
- *(strchr(disposition, ';')) = '\0';
- striplt(disposition);
- if (strchr(content_type, ';'))
- *(strchr(content_type, ';')) = '\0';
- striplt(content_type);
-
- if (!IsEmptyStr(boundary)) {
- is_multipart = 1;
- } else {
- is_multipart = 0;
+ ptr = strchr(m->b[disposition].Key, ';');
+ if (ptr != NULL) *ptr = '\0';
+ m->b[disposition].len = striplt(m->b[disposition].Key);
+
+ ptr = strchr(m->b[content_type].Key, ';');
+ if (ptr != NULL) *ptr = '\0';
+ m->b[content_type].len = striplt(m->b[content_type].Key);
+
+ m->is_multipart = m->b[boundary].len != 0;
+
+ return 0;
+}
+
+/*
+ * Break out the components of a multipart message
+ * (This function expects to be fed HEADERS + CONTENT)
+ * Note: NULL can be supplied as content_end; in this case, the message is
+ * considered to have ended when the parser encounters a 0x00 byte.
+ */
+void the_mime_parser(char *partnum,
+ char *content_start, char *content_end,
+ MimeParserCallBackType CallBack,
+ MimeParserCallBackType PreMultiPartCallBack,
+ MimeParserCallBackType PostMultiPartCallBack,
+ void *userdata,
+ int dont_decode)
+{
+
+ char *ptr;
+ char *part_start, *part_end = NULL;
+ char *next_boundary;
+
+ size_t content_length;
+ int part_seq = 0;
+ size_t length;
+ char nested_partnum[256];
+ int crlf_in_use = 0;
+ char *evaluate_crlf_ptr = NULL;
+
+ interesting_mime_headers *m;
+ CBufStr *chosen_name;
+
+ ptr = content_start;
+ content_length = 0;
+
+ m = InitInterestingMimes();
+
+
+ /* If the caller didn't supply an endpointer, generate one by measure */
+ if (content_end == NULL) {
+ content_end = &content_start[strlen(content_start)];