On Sat, Sep 01, 2001 at 12:21:29AM -0500, William A. Rowe, Jr. wrote:
> Justin, Ryan,
>
> it seems there are now two interesting rfc822+ Apache apps out there
> (pop and mbox) and I was wondering... do either of you already have the
> multipart parsing that we could move to apr-util (along with rfc822) to
> implement Martin's suggestion of using multipart/alternative (server side)
> over the quick-hack .var map files I implemented?
This is a quicky hack at something that might work (not compiled, not
tested, not even correct, not going to get committed). It shouldn't
be too bad to rip out the parts of mod_mbox that assume we are in a
mbox file (i.e. "From ").
I intended from the beginning that mbox_* files should be in apr-util,
but there are a few parameters/thoughts that may need straightening
out and modification to completely separate mod_mbox.c and the
rfc822 parsing code. Feel free to hack away...
I'm going on vacation for a few weeks (before school starts again at the
end of the month), so I'm going to savor what little free time I have.
=-)
This should point you in the right direction... -- justin
Index: mbox_parse.c
===================================================================
RCS file: /home/cvs/httpd-mbox/module-2.0/mbox_parse.c,v
retrieving revision 1.3
diff -u -r1.3 mbox_parse.c
--- mbox_parse.c 2001/08/02 01:38:55 1.3
+++ mbox_parse.c 2001/09/01 06:33:47
@@ -655,7 +655,7 @@
#endif
MBOX_BUFF b;
long location;
- const char *temp, *msgID;
+ const char *temp, *msgID, *currentBoundary;
#ifdef APR_HAS_MMAP
status = apr_file_name_get(&temp, f);
@@ -715,6 +715,7 @@
location = b.totalread - b.len + b.b - b.rb;
#endif
msgID = apr_table_get(table, "Message-ID");
+
if (msgID)
{
put_field_int(msgDB, msgID, location, r->pool);
@@ -723,7 +724,35 @@
PUT_FIELD(r, table, "Date", dateDB, msgID);
PUT_FIELD(r, table, "References", refDB, msgID);
}
+ contentType = apr_table_get(table, "Content-Type");
+ currentBoundary = NULL;
+ if (contentType && strstr(contentType, "multipart/alternative"))
+ {
+ char * boundary = strstr(contentType, "boundary=");
+ if (boundary)
+ {
+ boundary += sizeof("boundary=") + 1;
+ currentBoundary = apr_pstrdup(r->pool, boundary);
+ }
+ }
}
+ else if (currentBoundary && (b.b[0] == '-' && b.b[1] == '-'))
+ {
+ if ((temp = strstr(b.b, currentBoundary)) != NULL)
+ {
+ apr_table_t *newTable = load_mbox_mime_tables(r, &b);
+ contentType = apr_table_get(newTable, "Content-Type");
+
+ /* Hey, if this is my content type, I want to read here
+ * instead of skipping over everything. We'll also
+ * assume that we're going to playing with nice MIME
+ * documents so we don't check for the end boundary.
+ */
+ while (b.b[0] != '-' && b.b[1] != '-') {
+ skipLine(&b);
+ }
+ }
+ }
else
skipLine(&b);
}