diff options
author | Jeffrey Stedfast <fejj@ximian.com> | 2003-08-27 00:06:03 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2003-08-27 00:06:03 +0800 |
commit | cea825b209dd4bc4a54d6ad2c8e21a6e78e16320 (patch) | |
tree | 07266e182a2641454d77c4b233218a70d95f17b4 | |
parent | 2f7d812ddc64ef56903eee5d6e417fd178345437 (diff) | |
download | gsoc2013-evolution-cea825b209dd4bc4a54d6ad2c8e21a6e78e16320.tar.gz gsoc2013-evolution-cea825b209dd4bc4a54d6ad2c8e21a6e78e16320.tar.zst gsoc2013-evolution-cea825b209dd4bc4a54d6ad2c8e21a6e78e16320.zip |
s/HSCAN_/CAMEL_MIME_PARSER_STATE_/g and
2003-08-26 Jeffrey Stedfast <fejj@ximian.com>
* camel-mime-parser.[c,h]: s/HSCAN_/CAMEL_MIME_PARSER_STATE_/g and
s/_header_state/_camel_mime_parser_state/g
* camel-filter-driver.c: Same.
* camel-folder-summary.c: Here too.
* camel-http-stream.c: And here.
* camel-mime-message.c: ...
* camel-mime-part-utils.c: ...
* camel-mime-part.c: ...
* camel-movemail.c: ...
* camel-multipart-signed.c: ...
* camel-multipart.c: ...
* providers/local/camel-mbox-folder.c: ...
* providers/local/camel-mbox-summary.c: ...
* providers/local/camel-mh-summary.c: ...
* providers/nntp/camel-nntp-summary.c: ...
* providers/pop3/camel-pop3-folder.c: ...
svn path=/trunk/; revision=22365
-rw-r--r-- | camel/ChangeLog | 41 | ||||
-rw-r--r-- | camel/camel-filter-driver.c | 2 | ||||
-rw-r--r-- | camel/camel-folder-summary.c | 26 | ||||
-rw-r--r-- | camel/camel-http-stream.c | 4 | ||||
-rw-r--r-- | camel/camel-mime-message.c | 4 | ||||
-rw-r--r-- | camel/camel-mime-parser.c | 176 | ||||
-rw-r--r-- | camel/camel-mime-parser.h | 45 | ||||
-rw-r--r-- | camel/camel-mime-part-utils.c | 8 | ||||
-rw-r--r-- | camel/camel-mime-part.c | 6 | ||||
-rw-r--r-- | camel/camel-movemail.c | 4 | ||||
-rw-r--r-- | camel/camel-multipart-signed.c | 6 | ||||
-rw-r--r-- | camel/camel-multipart.c | 4 | ||||
-rw-r--r-- | camel/providers/local/camel-mbox-folder.c | 2 | ||||
-rw-r--r-- | camel/providers/local/camel-mbox-summary.c | 16 | ||||
-rw-r--r-- | camel/providers/local/camel-mh-summary.c | 2 | ||||
-rw-r--r-- | camel/providers/nntp/camel-nntp-summary.c | 2 | ||||
-rw-r--r-- | camel/providers/pop3/camel-pop3-folder.c | 6 |
17 files changed, 193 insertions, 161 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog index 6a4d958d31..78268c2acf 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,3 +1,36 @@ +2003-08-26 Jeffrey Stedfast <fejj@ximian.com> + + * camel-mime-parser.[c,h]: s/HSCAN_/CAMEL_MIME_PARSER_STATE_/g and + s/_header_state/_camel_mime_parser_state/g + + * camel-filter-driver.c: Same. + + * camel-folder-summary.c: Here too. + + * camel-http-stream.c: And here. + + * camel-mime-message.c: ... + + * camel-mime-part-utils.c: ... + + * camel-mime-part.c: ... + + * camel-movemail.c: ... + + * camel-multipart-signed.c: ... + + * camel-multipart.c: ... + + * providers/local/camel-mbox-folder.c: ... + + * providers/local/camel-mbox-summary.c: ... + + * providers/local/camel-mh-summary.c: ... + + * providers/nntp/camel-nntp-summary.c: ... + + * providers/pop3/camel-pop3-folder.c: ... + 2003-08-25 Jeffrey Stedfast <fejj@ximian.com> * camel-mime-utils.[c,h]: Namespaced. @@ -17,8 +50,8 @@ * camel-folder-search.c: updated for namespace changed made to camel-mime-utils.[c,h] - * camel-folder-summary.[c,h]: updated for namespace changed made to - camel-mime-utils.[c,h] + * camel-folder-summary.[c,h]: updated for namespace changed made + to camel-mime-utils.[c,h] * camel-http-stream.c: updated for namespace changed made to camel-mime-utils.[c,h] @@ -56,8 +89,8 @@ * camel-multipart.c: updated for namespace changed made to camel-mime-utils.[c,h] - * camel-search-private.[c,h]: updated for namespace changed made to - camel-mime-utils.[c,h] + * camel-search-private.[c,h]: updated for namespace changed made + to camel-mime-utils.[c,h] * camel-types.h: updated for namespace changed made to camel-mime-utils.[c,h] diff --git a/camel/camel-filter-driver.c b/camel/camel-filter-driver.c index 976a8d2d7e..8ac4d8690e 100644 --- a/camel/camel-filter-driver.c +++ b/camel/camel-filter-driver.c @@ -1127,7 +1127,7 @@ camel_filter_driver_filter_mbox (CamelFilterDriver *driver, const char *mbox, co source_url = g_strdup_printf ("file://%s", mbox); - while (camel_mime_parser_step (mp, 0, 0) == HSCAN_FROM) { + while (camel_mime_parser_step (mp, 0, 0) == CAMEL_MIME_PARSER_STATE_FROM) { CamelMessageInfo *info; CamelMimeMessage *msg; int pc = 0; diff --git a/camel/camel-folder-summary.c b/camel/camel-folder-summary.c index ac67b29bae..d7c08219c5 100644 --- a/camel/camel-folder-summary.c +++ b/camel/camel-folder-summary.c @@ -907,7 +907,7 @@ CamelMessageInfo *camel_folder_summary_info_new_from_parser(CamelFolderSummary * /* should this check the parser is in the right state, or assume it is?? */ start = camel_mime_parser_tell(mp); - if (camel_mime_parser_step(mp, &buffer, &len) != HSCAN_EOF) { + if (camel_mime_parser_step(mp, &buffer, &len) != CAMEL_MIME_PARSER_STATE_EOF) { info = ((CamelFolderSummaryClass *)(CAMEL_OBJECT_GET_CLASS(s)))->message_info_new_from_parser(s, mp); camel_mime_parser_unstep(mp); @@ -1452,9 +1452,9 @@ static CamelMessageInfo * message_info_new_from_parser(CamelFolderSummary *s, Ca state = camel_mime_parser_state(mp); switch (state) { - case HSCAN_HEADER: - case HSCAN_MESSAGE: - case HSCAN_MULTIPART: + case CAMEL_MIME_PARSER_STATE_HEADER: + case CAMEL_MIME_PARSER_STATE_MESSAGE: + case CAMEL_MIME_PARSER_STATE_MULTIPART: mi = ((CamelFolderSummaryClass *)(CAMEL_OBJECT_GET_CLASS(s)))->message_info_new(s, camel_mime_parser_headers_raw(mp)); break; default: @@ -1469,9 +1469,9 @@ static CamelMessageContentInfo * content_info_new_from_parser(CamelFolderSummary CamelMessageContentInfo *ci = NULL; switch (camel_mime_parser_state(mp)) { - case HSCAN_HEADER: - case HSCAN_MESSAGE: - case HSCAN_MULTIPART: + case CAMEL_MIME_PARSER_STATE_HEADER: + case CAMEL_MIME_PARSER_STATE_MESSAGE: + case CAMEL_MIME_PARSER_STATE_MULTIPART: ci = ((CamelFolderSummaryClass *)(CAMEL_OBJECT_GET_CLASS(s)))->content_info_new(s, camel_mime_parser_headers_raw(mp)); if (ci) { ci->type = camel_mime_parser_content_type(mp); @@ -2009,7 +2009,7 @@ summary_build_content_info(CamelFolderSummary *s, CamelMessageInfo *msginfo, Cam info = ((CamelFolderSummaryClass *)(CAMEL_OBJECT_GET_CLASS(s)))->content_info_new_from_parser(s, mp); switch(state) { - case HSCAN_HEADER: + case CAMEL_MIME_PARSER_STATE_HEADER: /* check content type for indexing, then read body */ ct = camel_mime_parser_content_type(mp); /* update attachments flag as we go */ @@ -2085,7 +2085,7 @@ summary_build_content_info(CamelFolderSummary *s, CamelMessageInfo *msginfo, Cam idx_id = camel_mime_parser_filter_add(mp, (CamelMimeFilter *)p->filter_index); } /* and scan/index everything */ - while (camel_mime_parser_step(mp, &buffer, &len) != HSCAN_BODY_END) + while (camel_mime_parser_step(mp, &buffer, &len) != CAMEL_MIME_PARSER_STATE_BODY_END) ; /* and remove the filters */ camel_mime_parser_filter_remove(mp, enc_id); @@ -2093,14 +2093,14 @@ summary_build_content_info(CamelFolderSummary *s, CamelMessageInfo *msginfo, Cam camel_mime_parser_filter_remove(mp, html_id); camel_mime_parser_filter_remove(mp, idx_id); break; - case HSCAN_MULTIPART: + case CAMEL_MIME_PARSER_STATE_MULTIPART: d(printf("Summarising multipart\n")); /* update attachments flag as we go */ ct = camel_mime_parser_content_type(mp); if (camel_content_type_is(ct, "multipart", "mixed")) msginfo->flags |= CAMEL_MESSAGE_ATTACHMENTS; - while (camel_mime_parser_step(mp, &buffer, &len) != HSCAN_MULTIPART_END) { + while (camel_mime_parser_step(mp, &buffer, &len) != CAMEL_MIME_PARSER_STATE_MULTIPART_END) { camel_mime_parser_unstep(mp); part = summary_build_content_info(s, msginfo, mp); if (part) { @@ -2109,7 +2109,7 @@ summary_build_content_info(CamelFolderSummary *s, CamelMessageInfo *msginfo, Cam } } break; - case HSCAN_MESSAGE: + case CAMEL_MIME_PARSER_STATE_MESSAGE: d(printf("Summarising message\n")); /* update attachments flag as we go */ msginfo->flags |= CAMEL_MESSAGE_ATTACHMENTS; @@ -2120,7 +2120,7 @@ summary_build_content_info(CamelFolderSummary *s, CamelMessageInfo *msginfo, Cam my_list_append((struct _node **)&info->childs, (struct _node *)part); } state = camel_mime_parser_step(mp, &buffer, &len); - if (state != HSCAN_MESSAGE_END) { + if (state != CAMEL_MIME_PARSER_STATE_MESSAGE_END) { g_error("Bad parser state: Expecing MESSAGE_END or MESSAGE_EOF, got: %d", state); camel_mime_parser_unstep(mp); } diff --git a/camel/camel-http-stream.c b/camel/camel-http-stream.c index 2739aa0fcc..cf462af3a9 100644 --- a/camel/camel-http-stream.c +++ b/camel/camel-http-stream.c @@ -286,8 +286,8 @@ http_get_headers (CamelHttpStream *http) camel_mime_parser_init_with_stream (http->parser, http->read); switch (camel_mime_parser_step (http->parser, &buf, &len)) { - case HSCAN_MESSAGE: - case HSCAN_HEADER: + case CAMEL_MIME_PARSER_STATE_MESSAGE: + case CAMEL_MIME_PARSER_STATE_HEADER: headers = camel_mime_parser_headers_raw (http->parser); if (http->content_type) camel_content_type_unref (http->content_type); diff --git a/camel/camel-mime-message.c b/camel/camel-mime-message.c index 9edfee1f3b..65e4207a19 100644 --- a/camel/camel-mime-message.c +++ b/camel/camel-mime-message.c @@ -466,9 +466,9 @@ construct_from_parser (CamelMimePart *dw, CamelMimeParser *mp) /* ... then clean up the follow-on state */ state = camel_mime_parser_step (mp, &buf, &len); switch (state) { - case HSCAN_EOF: case HSCAN_FROM_END: /* these doesn't belong to us */ + case CAMEL_MIME_PARSER_STATE_EOF: case CAMEL_MIME_PARSER_STATE_FROM_END: /* these doesn't belong to us */ camel_mime_parser_unstep (mp); - case HSCAN_MESSAGE_END: + case CAMEL_MIME_PARSER_STATE_MESSAGE_END: break; default: g_error ("Bad parser state: Expecing MESSAGE_END or EOF or EOM, got: %d", camel_mime_parser_state (mp)); diff --git a/camel/camel-mime-parser.c b/camel/camel-mime-parser.c index 6b27b3b35e..7f2c515b3b 100644 --- a/camel/camel-mime-parser.c +++ b/camel/camel-mime-parser.c @@ -203,7 +203,7 @@ struct _header_scan_state { /* global state */ - enum _header_state state; + enum _camel_mime_parser_state state; /* for building headers during scanning */ char *outbuf; @@ -248,7 +248,7 @@ struct _header_scan_state { struct _header_scan_stack { struct _header_scan_stack *parent; - enum _header_state savestate; /* state at invocation of this part */ + enum _camel_mime_parser_state savestate; /* state at invocation of this part */ #ifdef MEMPOOL MemPool *pool; /* memory pool to keep track of headers/etc at this level */ @@ -297,23 +297,23 @@ static void camel_mime_parser_init (CamelMimeParser *obj); #if d(!)0 static char *states[] = { - "HSCAN_INITIAL", - "HSCAN_PRE_FROM", /* pre-from data */ - "HSCAN_FROM", /* got 'From' line */ - "HSCAN_HEADER", /* toplevel header */ - "HSCAN_BODY", /* scanning body of message */ - "HSCAN_MULTIPART", /* got multipart header */ - "HSCAN_MESSAGE", /* rfc822/news message */ - - "HSCAN_PART", /* part of a multipart */ - - "HSCAN_EOF", /* end of file */ - "HSCAN_PRE_FROM_END", - "HSCAN_FROM_END", - "HSCAN_HEAER_END", - "HSCAN_BODY_END", - "HSCAN_MULTIPART_END", - "HSCAN_MESSAGE_END", + "CAMEL_MIME_PARSER_STATE_INITIAL", + "CAMEL_MIME_PARSER_STATE_PRE_FROM", /* pre-from data */ + "CAMEL_MIME_PARSER_STATE_FROM", /* got 'From' line */ + "CAMEL_MIME_PARSER_STATE_HEADER", /* toplevel header */ + "CAMEL_MIME_PARSER_STATE_BODY", /* scanning body of message */ + "CAMEL_MIME_PARSER_STATE_MULTIPART", /* got multipart header */ + "CAMEL_MIME_PARSER_STATE_MESSAGE", /* rfc822/news message */ + + "CAMEL_MIME_PARSER_STATE_PART", /* part of a multipart */ + + "CAMEL_MIME_PARSER_STATE_EOF", /* end of file */ + "CAMEL_MIME_PARSER_STATE_PRE_FROM_END", + "CAMEL_MIME_PARSER_STATE_FROM_END", + "CAMEL_MIME_PARSER_STATE_HEAER_END", + "CAMEL_MIME_PARSER_STATE_BODY_END", + "CAMEL_MIME_PARSER_STATE_MULTIPART_END", + "CAMEL_MIME_PARSER_STATE_MESSAGE_END", }; #endif @@ -388,7 +388,7 @@ camel_mime_parser_new (void) * * Note that filters are only applied to the body content of messages, and once * a filter has been set, all content returned by a filter_step() with a state - * of HSCAN_BODY will have passed through the filter. + * of CAMEL_MIME_PARSER_STATE_BODY will have passed through the filter. * * Return value: An id that may be passed to filter_remove() to remove * the filter, or -1 if the operation failed. @@ -505,7 +505,7 @@ byte_array_to_string(GByteArray *array) * @m: * * Retrieve the preface text for the current multipart. - * Can only be used when the state is HSCAN_MULTIPART_END. + * Can only be used when the state is CAMEL_MIME_PARSER_STATE_MULTIPART_END. * * Return value: The preface text, or NULL if there wasn't any. **/ @@ -526,7 +526,7 @@ camel_mime_parser_preface(CamelMimeParser *m) * * Retrieve the postface text for the current multipart. * Only returns valid data when the current state if - * HSCAN_MULTIPART_END. + * CAMEL_MIME_PARSER_STATE_MULTIPART_END. * * Return value: The postface text, or NULL if there wasn't any. **/ @@ -546,10 +546,10 @@ camel_mime_parser_postface(CamelMimeParser *m) * @m: * * Get the last scanned "From " line, from a recently scanned from. - * This should only be called in the HSCAN_FROM state. The + * This should only be called in the CAMEL_MIME_PARSER_STATE_FROM state. The * from line will include the closing \n found (if there was one). * - * The return value will remain valid while in the HSCAN_FROM + * The return value will remain valid while in the CAMEL_MIME_PARSER_STATE_FROM * state, or any deeper state. * * Return value: The From line, or NULL if called out of context. @@ -613,11 +613,11 @@ camel_mime_parser_init_with_stream(CamelMimeParser *m, CamelStream *stream) * Tell the scanner if it should scan "^From " lines or not. * * If the scanner is scanning from lines, two additional - * states HSCAN_FROM and HSCAN_FROM_END will be returned + * states CAMEL_MIME_PARSER_STATE_FROM and CAMEL_MIME_PARSER_STATE_FROM_END will be returned * to the caller during parsing. * * This may also be preceeded by an optional - * HSCAN_PRE_FROM state which contains the scanned data + * CAMEL_MIME_PARSER_STATE_PRE_FROM state which contains the scanned data * found before the From line is encountered. See also * scan_pre_from(). **/ @@ -636,7 +636,7 @@ camel_mime_parser_scan_from (CamelMimeParser *parser, gboolean scan_from) * * Tell the scanner whether we want to know abou the pre-from * data during a scan. If we do, then we may get an additional - * state HSCAN_PRE_FROM which returns the specified data. + * state CAMEL_MIME_PARSER_STATE_PRE_FROM which returns the specified data. **/ void camel_mime_parser_scan_pre_from (CamelMimeParser *parser, gboolean scan_pre_from) @@ -721,7 +721,7 @@ camel_mime_parser_drop_step (CamelMimeParser *parser) * has been called, then continue to return the same state * for that many calls. * - * If the step is HSCAN_BODY then the databuffer and datalength + * If the step is CAMEL_MIME_PARSER_STATE_BODY then the databuffer and datalength * pointers will be setup to point to the internal data buffer * of the scanner and may be processed as required. Any * filters will have already been applied to this data. @@ -733,7 +733,7 @@ camel_mime_parser_drop_step (CamelMimeParser *parser) * Return value: The current new state of the parser * is returned. **/ -enum _header_state +enum _camel_mime_parser_state camel_mime_parser_step (CamelMimeParser *parser, char **databuffer, size_t *datalength) { struct _header_scan_state *s = _PRIVATE (parser); @@ -818,12 +818,12 @@ camel_mime_parser_read (CamelMimeParser *parser, const char **databuffer, int le * * An incomplete listing of the states: * - * HSCAN_INITIAL, The start of the current message. - * HSCAN_HEADER, HSCAN_MESSAGE, HSCAN_MULTIPART, the character + * CAMEL_MIME_PARSER_STATE_INITIAL, The start of the current message. + * CAMEL_MIME_PARSER_STATE_HEADER, CAMEL_MIME_PARSER_STATE_MESSAGE, CAMEL_MIME_PARSER_STATE_MULTIPART, the character * position immediately after the end of the header. - * HSCAN_BODY, Position within the message of the start + * CAMEL_MIME_PARSER_STATE_BODY, Position within the message of the start * of the current data block. - * HSCAN_*_END, The position of the character starting + * CAMEL_MIME_PARSER_STATE_*_END, The position of the character starting * the next section of the scan (the last position + 1 of * the respective current state). * @@ -907,7 +907,7 @@ camel_mime_parser_seek(CamelMimeParser *parser, off_t offset, int whence) * * Return value: The current parser state. **/ -enum _header_state +enum _camel_mime_parser_state camel_mime_parser_state (CamelMimeParser *parser) { struct _header_scan_state *s = _PRIVATE (parser); @@ -1536,7 +1536,7 @@ folder_scan_init(void) s->parts = NULL; - s->state = HSCAN_INITIAL; + s->state = CAMEL_MIME_PARSER_STATE_INITIAL; return s; } @@ -1547,7 +1547,7 @@ drop_states(struct _header_scan_state *s) folder_scan_drop_step(s); } s->unstep = 0; - s->state = HSCAN_INITIAL; + s->state = CAMEL_MIME_PARSER_STATE_INITIAL; } static void @@ -1625,7 +1625,7 @@ tail_recurse: switch (s->state) { #ifdef USE_FROM - case HSCAN_INITIAL: + case CAMEL_MIME_PARSER_STATE_INITIAL: if (s->scan_from) { h = g_malloc0(sizeof(*h)); h->boundary = g_strdup("From "); @@ -1633,13 +1633,13 @@ tail_recurse: h->boundarylenfinal = h->boundarylen; h->from_line = g_byte_array_new(); folder_push_part(s, h); - s->state = HSCAN_PRE_FROM; + s->state = CAMEL_MIME_PARSER_STATE_PRE_FROM; } else { s->start_of_from = -1; goto scan_header; } - case HSCAN_PRE_FROM: + case CAMEL_MIME_PARSER_STATE_PRE_FROM: h = s->parts; do { @@ -1654,32 +1654,32 @@ tail_recurse: d(printf("found 'From '\n")); s->start_of_from = folder_tell(s); folder_scan_skip_line(s, h->from_line); - h->savestate = HSCAN_INITIAL; - s->state = HSCAN_FROM; + h->savestate = CAMEL_MIME_PARSER_STATE_INITIAL; + s->state = CAMEL_MIME_PARSER_STATE_FROM; } else { folder_pull_part(s); - s->state = HSCAN_EOF; + s->state = CAMEL_MIME_PARSER_STATE_EOF; } return; #else - case HSCAN_INITIAL: - case HSCAN_PRE_FROM: + case CAMEL_MIME_PARSER_STATE_INITIAL: + case CAMEL_MIME_PARSER_STATE_PRE_FROM: #endif /* !USE_FROM */ scan_header: - case HSCAN_FROM: + case CAMEL_MIME_PARSER_STATE_FROM: s->start_of_headers = folder_tell(s); h = folder_scan_header(s, &state); #ifdef USE_FROM if (s->scan_from) - h->savestate = HSCAN_FROM_END; + h->savestate = CAMEL_MIME_PARSER_STATE_FROM_END; else #endif - h->savestate = HSCAN_EOF; + h->savestate = CAMEL_MIME_PARSER_STATE_EOF; /* FIXME: should this check for MIME-Version: 1.0 as well? */ - type = HSCAN_HEADER; + type = CAMEL_MIME_PARSER_STATE_HEADER; if ( (content = camel_header_raw_find(&h->headers, "Content-Type", NULL)) && (ct = camel_content_type_decode(content))) { if (!strcasecmp(ct->type, "multipart")) { @@ -1690,7 +1690,7 @@ tail_recurse: h->boundarylenfinal = h->boundarylen+2; h->boundary = g_malloc(h->boundarylen+3); sprintf(h->boundary, "--%s--", bound); - type = HSCAN_MULTIPART; + type = CAMEL_MIME_PARSER_STATE_MULTIPART; } else { /*camel_content_type_unref(ct); ct = camel_content_type_decode("text/plain");*/ @@ -1702,7 +1702,7 @@ tail_recurse: if (!strcasecmp(ct->subtype, "rfc822") || !strcasecmp(ct->subtype, "news") /*|| !strcasecmp(ct->subtype, "partial")*/) { - type = HSCAN_MESSAGE; + type = CAMEL_MIME_PARSER_STATE_MESSAGE; } } } else { @@ -1710,7 +1710,7 @@ tail_recurse: if ((s->parts && camel_content_type_is(s->parts->content_type, "multipart", "digest"))) { ct = camel_content_type_decode("message/rfc822"); - type = HSCAN_MESSAGE; + type = CAMEL_MIME_PARSER_STATE_MESSAGE; d(printf("parent was multipart/digest, autoupgrading to message/rfc822?\n")); /* maybe we should do this too? header_raw_append_parse(&h->headers, "Content-Type: message/rfc822", -1);*/ @@ -1723,10 +1723,10 @@ tail_recurse: s->state = type; return; - case HSCAN_HEADER: - s->state = HSCAN_BODY; + case CAMEL_MIME_PARSER_STATE_HEADER: + s->state = CAMEL_MIME_PARSER_STATE_BODY; - case HSCAN_BODY: + case CAMEL_MIME_PARSER_STATE_BODY: h = s->parts; *datalength = 0; presize = SCAN_HEAD; @@ -1762,10 +1762,10 @@ tail_recurse: if (*datalength > 0) return; - s->state = HSCAN_BODY_END; + s->state = CAMEL_MIME_PARSER_STATE_BODY_END; break; - case HSCAN_MULTIPART: + case CAMEL_MIME_PARSER_STATE_MULTIPART: h = s->parts; do { do { @@ -1791,9 +1791,9 @@ tail_recurse: d(printf("got boundary: %s\n", hb->boundary)); folder_scan_skip_line(s, NULL); if (!state) { - s->state = HSCAN_FROM; + s->state = CAMEL_MIME_PARSER_STATE_FROM; folder_scan_step(s, databuffer, datalength); - s->parts->savestate = HSCAN_MULTIPART; /* set return state for the new head part */ + s->parts->savestate = CAMEL_MIME_PARSER_STATE_MULTIPART; /* set return state for the new head part */ return; } } else { @@ -1801,26 +1801,26 @@ tail_recurse: } } while (1); - s->state = HSCAN_MULTIPART_END; + s->state = CAMEL_MIME_PARSER_STATE_MULTIPART_END; break; - case HSCAN_MESSAGE: - s->state = HSCAN_FROM; + case CAMEL_MIME_PARSER_STATE_MESSAGE: + s->state = CAMEL_MIME_PARSER_STATE_FROM; folder_scan_step(s, databuffer, datalength); - s->parts->savestate = HSCAN_MESSAGE_END; + s->parts->savestate = CAMEL_MIME_PARSER_STATE_MESSAGE_END; break; - case HSCAN_FROM_END: - case HSCAN_BODY_END: - case HSCAN_MULTIPART_END: - case HSCAN_MESSAGE_END: + case CAMEL_MIME_PARSER_STATE_FROM_END: + case CAMEL_MIME_PARSER_STATE_BODY_END: + case CAMEL_MIME_PARSER_STATE_MULTIPART_END: + case CAMEL_MIME_PARSER_STATE_MESSAGE_END: s->state = s->parts->savestate; folder_pull_part(s); - if (s->state & HSCAN_END) + if (s->state & CAMEL_MIME_PARSER_STATE_END) return; goto tail_recurse; - case HSCAN_EOF: + case CAMEL_MIME_PARSER_STATE_EOF: return; default: @@ -1836,30 +1836,30 @@ static void folder_scan_drop_step(struct _header_scan_state *s) { switch (s->state) { - case HSCAN_EOF: - s->state = HSCAN_INITIAL; - case HSCAN_INITIAL: + case CAMEL_MIME_PARSER_STATE_EOF: + s->state = CAMEL_MIME_PARSER_STATE_INITIAL; + case CAMEL_MIME_PARSER_STATE_INITIAL: return; - case HSCAN_FROM: - case HSCAN_PRE_FROM: - s->state = HSCAN_INITIAL; + case CAMEL_MIME_PARSER_STATE_FROM: + case CAMEL_MIME_PARSER_STATE_PRE_FROM: + s->state = CAMEL_MIME_PARSER_STATE_INITIAL; folder_pull_part(s); return; - case HSCAN_MESSAGE: - case HSCAN_HEADER: - case HSCAN_MULTIPART: + case CAMEL_MIME_PARSER_STATE_MESSAGE: + case CAMEL_MIME_PARSER_STATE_HEADER: + case CAMEL_MIME_PARSER_STATE_MULTIPART: - case HSCAN_FROM_END: - case HSCAN_BODY_END: - case HSCAN_MULTIPART_END: - case HSCAN_MESSAGE_END: + case CAMEL_MIME_PARSER_STATE_FROM_END: + case CAMEL_MIME_PARSER_STATE_BODY_END: + case CAMEL_MIME_PARSER_STATE_MULTIPART_END: + case CAMEL_MIME_PARSER_STATE_MESSAGE_END: s->state = s->parts->savestate; folder_pull_part(s); - if (s->state & HSCAN_END) { - s->state &= ~HSCAN_END; + if (s->state & CAMEL_MIME_PARSER_STATE_END) { + s->state &= ~CAMEL_MIME_PARSER_STATE_END; } return; default: @@ -1903,14 +1903,14 @@ int main(int argc, char **argv) s->scan_from = FALSE; #if 0 h = g_malloc0(sizeof(*h)); - h->savestate = HSCAN_EOF; + h->savestate = CAMEL_MIME_PARSER_STATE_EOF; folder_push_part(s, h); #endif - while (s->state != HSCAN_EOF) { + while (s->state != CAMEL_MIME_PARSER_STATE_EOF) { folder_scan_step(s, &data, &len); printf("\n -- PARSER STEP RETURN -- %d '%s'\n\n", s->state, states[s->state]); switch (s->state) { - case HSCAN_HEADER: + case CAMEL_MIME_PARSER_STATE_HEADER: if (s->parts->content_type && (charset = camel_content_type_param(s->parts->content_type, "charset"))) { if (strcasecmp(charset, "us-ascii")) { @@ -1950,10 +1950,10 @@ int main(int argc, char **argv) } break; - case HSCAN_BODY: + case CAMEL_MIME_PARSER_STATE_BODY: printf("got body %d '%.*s'\n", len, len, data); break; - case HSCAN_BODY_END: + case CAMEL_MIME_PARSER_STATE_BODY_END: printf("end body %d '%.*s'\n", len, len, data); if (encoding && !strncasecmp(encoding, " base64", 7)) { printf("removing filters\n"); diff --git a/camel/camel-mime-parser.h b/camel/camel-mime-parser.h index b95fe69f5b..db85133cbc 100644 --- a/camel/camel-mime-parser.h +++ b/camel/camel-mime-parser.h @@ -43,27 +43,26 @@ typedef struct _CamelMimeParserClass CamelMimeParserClass; /* NOTE: if you add more states, you may need to bump the start of the END tags to 16 or 32, etc - so they are the same as the matching start tag, with a bit difference */ -enum _header_state { - HSCAN_INITIAL, - HSCAN_PRE_FROM, /* data before a 'From' line */ - HSCAN_FROM, /* got 'From' line */ - HSCAN_HEADER, /* toplevel header */ - HSCAN_BODY, /* scanning body of message */ - HSCAN_MULTIPART, /* got multipart header */ - HSCAN_MESSAGE, /* rfc822 message */ - - HSCAN_PART, /* part of a multipart */ - - HSCAN_END = 8, /* bit mask for 'end' flags */ - - HSCAN_EOF = 8, /* end of file */ - HSCAN_PRE_FROM_END, /* pre from end */ - HSCAN_FROM_END, /* end of whole from bracket */ - HSCAN_HEADER_END, /* dummy value */ - HSCAN_BODY_END, /* end of message */ - HSCAN_MULTIPART_END, /* end of multipart */ - HSCAN_MESSAGE_END, /* end of message */ - +enum _camel_mime_parser_state { + CAMEL_MIME_PARSER_STATE_INITIAL, + CAMEL_MIME_PARSER_STATE_PRE_FROM, /* data before a 'From' line */ + CAMEL_MIME_PARSER_STATE_FROM, /* got 'From' line */ + CAMEL_MIME_PARSER_STATE_HEADER, /* toplevel header */ + CAMEL_MIME_PARSER_STATE_BODY, /* scanning body of message */ + CAMEL_MIME_PARSER_STATE_MULTIPART, /* got multipart header */ + CAMEL_MIME_PARSER_STATE_MESSAGE, /* rfc822 message */ + + CAMEL_MIME_PARSER_STATE_PART, /* part of a multipart */ + + CAMEL_MIME_PARSER_STATE_END = 8, /* bit mask for 'end' flags */ + + CAMEL_MIME_PARSER_STATE_EOF = 8, /* end of file */ + CAMEL_MIME_PARSER_STATE_PRE_FROM_END, /* pre from end */ + CAMEL_MIME_PARSER_STATE_FROM_END, /* end of whole from bracket */ + CAMEL_MIME_PARSER_STATE_HEADER_END, /* dummy value */ + CAMEL_MIME_PARSER_STATE_BODY_END, /* end of message */ + CAMEL_MIME_PARSER_STATE_MULTIPART_END, /* end of multipart */ + CAMEL_MIME_PARSER_STATE_MESSAGE_END, /* end of message */ }; struct _CamelMimeParser { @@ -103,10 +102,10 @@ void camel_mime_parser_scan_pre_from (CamelMimeParser *parser, gboolean scan_pre int camel_mime_parser_set_header_regex (CamelMimeParser *parser, char *matchstr); /* normal interface */ -enum _header_state camel_mime_parser_step (CamelMimeParser *parser, char **buf, size_t *buflen); +enum _camel_mime_parser_state camel_mime_parser_step (CamelMimeParser *parser, char **buf, size_t *buflen); void camel_mime_parser_unstep (CamelMimeParser *parser); void camel_mime_parser_drop_step (CamelMimeParser *parser); -enum _header_state camel_mime_parser_state (CamelMimeParser *parser); +enum _camel_mime_parser_state camel_mime_parser_state (CamelMimeParser *parser); /* read through the parser */ int camel_mime_parser_read (CamelMimeParser *parser, const char **databuffer, int len); diff --git a/camel/camel-mime-part-utils.c b/camel/camel-mime-part-utils.c index 6eed767744..e2df274abb 100644 --- a/camel/camel-mime-part-utils.c +++ b/camel/camel-mime-part-utils.c @@ -66,7 +66,7 @@ simple_data_wrapper_construct_from_parser (CamelDataWrapper *dw, CamelMimeParser /* read in the entire content */ buffer = g_byte_array_new (); - while (camel_mime_parser_step (mp, &buf, &len) != HSCAN_BODY_END) { + while (camel_mime_parser_step (mp, &buf, &len) != CAMEL_MIME_PARSER_STATE_BODY_END) { d(printf("appending o/p data: %d: %.*s\n", len, len, buf)); g_byte_array_append (buffer, buf, len); } @@ -91,7 +91,7 @@ camel_mime_part_construct_content_from_parser (CamelMimePart *dw, CamelMimeParse encoding = camel_header_content_encoding_decode (camel_mime_parser_header (mp, "Content-Transfer-Encoding", NULL)); switch (camel_mime_parser_state (mp)) { - case HSCAN_HEADER: + case CAMEL_MIME_PARSER_STATE_HEADER: d(printf("Creating body part\n")); /* multipart/signed is some fucked up type that we must treat as binary data, fun huh, idiots. */ if (camel_content_type_is (ct, "multipart", "signed")) { @@ -102,12 +102,12 @@ camel_mime_part_construct_content_from_parser (CamelMimePart *dw, CamelMimeParse simple_data_wrapper_construct_from_parser (content, mp); } break; - case HSCAN_MESSAGE: + case CAMEL_MIME_PARSER_STATE_MESSAGE: d(printf("Creating message part\n")); content = (CamelDataWrapper *) camel_mime_message_new (); camel_mime_part_construct_from_parser ((CamelMimePart *)content, mp); break; - case HSCAN_MULTIPART: + case CAMEL_MIME_PARSER_STATE_MULTIPART: d(printf("Creating multi-part\n")); if (camel_content_type_is (ct, "multipart", "encrypted")) content = (CamelDataWrapper *) camel_multipart_encrypted_new (); diff --git a/camel/camel-mime-part.c b/camel/camel-mime-part.c index 37a08426de..88ec42c53d 100644 --- a/camel/camel-mime-part.c +++ b/camel/camel-mime-part.c @@ -786,13 +786,13 @@ construct_from_parser (CamelMimePart *mime_part, CamelMimeParser *mp) d(printf("mime_part::construct_from_parser()\n")); switch (camel_mime_parser_step(mp, &buf, &len)) { - case HSCAN_MESSAGE: + case CAMEL_MIME_PARSER_STATE_MESSAGE: /* set the default type of a message always */ if (dw->mime_type) camel_content_type_unref (dw->mime_type); dw->mime_type = camel_content_type_decode ("message/rfc822"); - case HSCAN_HEADER: - case HSCAN_MULTIPART: + case CAMEL_MIME_PARSER_STATE_HEADER: + case CAMEL_MIME_PARSER_STATE_MULTIPART: /* we have the headers, build them into 'us' */ headers = camel_mime_parser_headers_raw(mp); diff --git a/camel/camel-movemail.c b/camel/camel-movemail.c index c94ce0e495..70807195e5 100644 --- a/camel/camel-movemail.c +++ b/camel/camel-movemail.c @@ -473,10 +473,10 @@ camel_movemail_solaris (int oldsfd, int dfd, CamelException *ex) ffrom = camel_mime_filter_from_new(); - while (camel_mime_parser_step(mp, &buffer, &len) == HSCAN_FROM) { + while (camel_mime_parser_step(mp, &buffer, &len) == CAMEL_MIME_PARSER_STATE_FROM) { g_assert(camel_mime_parser_from_line(mp)); from = g_strdup(camel_mime_parser_from_line(mp)); - if (camel_mime_parser_step(mp, &buffer, &len) != HSCAN_FROM_END) { + if (camel_mime_parser_step(mp, &buffer, &len) != CAMEL_MIME_PARSER_STATE_FROM_END) { const char *cl; int length; int start, body; diff --git a/camel/camel-multipart-signed.c b/camel/camel-multipart-signed.c index cee5a54e88..63c48a5b98 100644 --- a/camel/camel-multipart-signed.c +++ b/camel/camel-multipart-signed.c @@ -159,7 +159,7 @@ camel_multipart_signed_get_type (void) * set the mime_type appropriately to match the data uses, so * that the multiple parts my be extracted. * - * Use construct_from_parser. The parser MUST be in the HSCAN_HEADER + * Use construct_from_parser. The parser MUST be in the CAMEL_MIME_PARSER_STATE_HEADER * state, and the current content_type MUST be "multipart/signed" with * the appropriate boundary and it SHOULD include the appropriate protocol * and hash specifiers. @@ -440,14 +440,14 @@ signed_construct_from_parser(CamelMultipart *multipart, struct _CamelMimeParser /* we *must not* be in multipart state, otherwise the mime parser will parse the headers which is a no no @#$@# stupid multipart/signed spec */ - g_assert(camel_mime_parser_state(mp) == HSCAN_HEADER); + g_assert(camel_mime_parser_state(mp) == CAMEL_MIME_PARSER_STATE_HEADER); /* All we do is copy it to a memstream */ content_type = camel_mime_parser_content_type(mp); camel_multipart_set_boundary(multipart, camel_content_type_param(content_type, "boundary")); mem = camel_stream_mem_new(); - while (camel_mime_parser_step(mp, &buf, &len) != HSCAN_BODY_END) + while (camel_mime_parser_step(mp, &buf, &len) != CAMEL_MIME_PARSER_STATE_BODY_END) camel_stream_write(mem, buf, len); set_stream(mps, mem); diff --git a/camel/camel-multipart.c b/camel/camel-multipart.c index 542e75bf81..1ec771103d 100644 --- a/camel/camel-multipart.c +++ b/camel/camel-multipart.c @@ -551,7 +551,7 @@ construct_from_parser(CamelMultipart *multipart, struct _CamelMimeParser *mp) char *buf; size_t len; - g_assert(camel_mime_parser_state(mp) == HSCAN_MULTIPART); + g_assert(camel_mime_parser_state(mp) == CAMEL_MIME_PARSER_STATE_MULTIPART); /* FIXME: we should use a came-mime-mutlipart, not jsut a camel-multipart, but who cares */ d(printf("Creating multi-part\n")); @@ -560,7 +560,7 @@ construct_from_parser(CamelMultipart *multipart, struct _CamelMimeParser *mp) camel_multipart_set_boundary(multipart, camel_content_type_param(content_type, "boundary")); - while (camel_mime_parser_step(mp, &buf, &len) != HSCAN_MULTIPART_END) { + while (camel_mime_parser_step(mp, &buf, &len) != CAMEL_MIME_PARSER_STATE_MULTIPART_END) { camel_mime_parser_unstep(mp); bodypart = camel_mime_part_new(); camel_mime_part_construct_from_parser(bodypart, mp); diff --git a/camel/providers/local/camel-mbox-folder.c b/camel/providers/local/camel-mbox-folder.c index 942610d5a9..01c3d7811e 100644 --- a/camel/providers/local/camel-mbox-folder.c +++ b/camel/providers/local/camel-mbox-folder.c @@ -376,7 +376,7 @@ retry: camel_mime_parser_scan_from(parser, TRUE); camel_mime_parser_seek(parser, frompos, SEEK_SET); - if (camel_mime_parser_step(parser, NULL, NULL) != HSCAN_FROM + if (camel_mime_parser_step(parser, NULL, NULL) != CAMEL_MIME_PARSER_STATE_FROM || camel_mime_parser_tell_start_from(parser) != frompos) { g_warning("Summary doesn't match the folder contents! eek!\n" diff --git a/camel/providers/local/camel-mbox-summary.c b/camel/providers/local/camel-mbox-summary.c index 18cee39e05..4018fc93c9 100644 --- a/camel/providers/local/camel-mbox-summary.c +++ b/camel/providers/local/camel-mbox-summary.c @@ -355,7 +355,7 @@ summary_update(CamelLocalSummary *cls, off_t offset, CamelFolderChangeInfo *chan camel_mime_parser_seek(mp, offset, SEEK_SET); if (offset > 0) { - if (camel_mime_parser_step(mp, NULL, NULL) == HSCAN_FROM + if (camel_mime_parser_step(mp, NULL, NULL) == CAMEL_MIME_PARSER_STATE_FROM && camel_mime_parser_tell_start_from(mp) == offset) { camel_mime_parser_unstep(mp); } else { @@ -380,7 +380,7 @@ summary_update(CamelLocalSummary *cls, off_t offset, CamelFolderChangeInfo *chan } mbs->changes = changeinfo; - while (camel_mime_parser_step(mp, NULL, NULL) == HSCAN_FROM) { + while (camel_mime_parser_step(mp, NULL, NULL) == CAMEL_MIME_PARSER_STATE_FROM) { CamelMessageInfo *info; off_t pc = camel_mime_parser_tell_start_from (mp) + 1; @@ -394,7 +394,7 @@ summary_update(CamelLocalSummary *cls, off_t offset, CamelFolderChangeInfo *chan break; } - g_assert(camel_mime_parser_step(mp, NULL, NULL) == HSCAN_FROM_END); + g_assert(camel_mime_parser_step(mp, NULL, NULL) == CAMEL_MIME_PARSER_STATE_FROM_END); } camel_object_unref(CAMEL_OBJECT (mp)); @@ -638,7 +638,7 @@ mbox_summary_sync_quick(CamelMboxSummary *mbs, gboolean expunge, CamelFolderChan camel_mime_parser_seek(mp, info->frompos, SEEK_SET); - if (camel_mime_parser_step(mp, 0, 0) != HSCAN_FROM) { + if (camel_mime_parser_step(mp, 0, 0) != CAMEL_MIME_PARSER_STATE_FROM) { g_warning("Expected a From line here, didn't get it"); camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM, _("Summary and folder mismatch, even after a sync")); @@ -653,7 +653,7 @@ mbox_summary_sync_quick(CamelMboxSummary *mbs, gboolean expunge, CamelFolderChan goto error; } - if (camel_mime_parser_step(mp, 0, 0) == HSCAN_FROM_END) { + if (camel_mime_parser_step(mp, 0, 0) == CAMEL_MIME_PARSER_STATE_FROM_END) { g_warning("camel_mime_parser_step failed (2)"); goto error; } @@ -839,7 +839,7 @@ camel_mbox_summary_sync_mbox(CamelMboxSummary *cls, guint32 flags, CamelFolderCh camel_mime_parser_seek(mp, info->frompos, SEEK_SET); } - if (camel_mime_parser_step(mp, &buffer, &len) != HSCAN_FROM) { + if (camel_mime_parser_step(mp, &buffer, &len) != CAMEL_MIME_PARSER_STATE_FROM) { g_warning("Expected a From line here, didn't get it"); camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM, _("Summary and folder mismatch, even after a sync")); @@ -885,7 +885,7 @@ camel_mbox_summary_sync_mbox(CamelMboxSummary *cls, guint32 flags, CamelFolderCh if (info && info->info.flags & (CAMEL_MESSAGE_FOLDER_NOXEV | CAMEL_MESSAGE_FOLDER_FLAGGED)) { d(printf("Updating header for %s flags = %08x\n", camel_message_info_uid(info), info->info.flags)); - if (camel_mime_parser_step(mp, &buffer, &len) == HSCAN_FROM_END) { + if (camel_mime_parser_step(mp, &buffer, &len) == CAMEL_MIME_PARSER_STATE_FROM_END) { g_warning("camel_mime_parser_step failed (2)"); goto error; } @@ -918,7 +918,7 @@ camel_mbox_summary_sync_mbox(CamelMboxSummary *cls, guint32 flags, CamelFolderCh camel_mime_parser_drop_step(mp); if (info) { d(printf("looking for message content to copy across from %d\n", (int)camel_mime_parser_tell(mp))); - while (camel_mime_parser_step(mp, &buffer, &len) == HSCAN_PRE_FROM) { + while (camel_mime_parser_step(mp, &buffer, &len) == CAMEL_MIME_PARSER_STATE_PRE_FROM) { /*d(printf("copying mbox contents to tmp: '%.*s'\n", len, buffer));*/ if (write(fdout, buffer, len) != len) { camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, diff --git a/camel/providers/local/camel-mh-summary.c b/camel/providers/local/camel-mh-summary.c index 25794fa258..5dd26ac9ba 100644 --- a/camel/providers/local/camel-mh-summary.c +++ b/camel/providers/local/camel-mh-summary.c @@ -314,7 +314,7 @@ mh_summary_sync_message(CamelLocalSummary *cls, CamelMessageInfo *info, CamelExc mp = camel_mime_parser_new(); camel_mime_parser_init_with_fd(mp, fd); - if (camel_mime_parser_step(mp, 0, 0) != HSCAN_EOF) { + if (camel_mime_parser_step(mp, 0, 0) != CAMEL_MIME_PARSER_STATE_EOF) { xev = camel_mime_parser_header(mp, "X-Evolution", &xevoffset); d(printf("xev = '%s'\n", xev)); xevnew = camel_local_summary_encode_x_evolution(cls, info); diff --git a/camel/providers/nntp/camel-nntp-summary.c b/camel/providers/nntp/camel-nntp-summary.c index 50486a2631..2a9669d697 100644 --- a/camel/providers/nntp/camel-nntp-summary.c +++ b/camel/providers/nntp/camel-nntp-summary.c @@ -536,7 +536,7 @@ add_range_head(CamelNNTPSummary *cns, unsigned int high, unsigned int low, Camel if (camel_mime_parser_init_with_stream(mp, (CamelStream *)store->stream) == -1) goto error; mi = camel_folder_summary_add_from_parser(s, mp); - while (camel_mime_parser_step(mp, NULL, NULL) != HSCAN_EOF) + while (camel_mime_parser_step(mp, NULL, NULL) != CAMEL_MIME_PARSER_STATE_EOF) ; if (mi == NULL) { goto error; diff --git a/camel/providers/pop3/camel-pop3-folder.c b/camel/providers/pop3/camel-pop3-folder.c index e2b927858a..0df4fcf5c5 100644 --- a/camel/providers/pop3/camel-pop3-folder.c +++ b/camel/providers/pop3/camel-pop3-folder.c @@ -156,9 +156,9 @@ cmd_builduid(CamelPOP3Engine *pe, CamelPOP3Stream *stream, void *data) mp = camel_mime_parser_new(); camel_mime_parser_init_with_stream(mp, (CamelStream *)stream); switch (camel_mime_parser_step(mp, NULL, NULL)) { - case HSCAN_HEADER: - case HSCAN_MESSAGE: - case HSCAN_MULTIPART: + case CAMEL_MIME_PARSER_STATE_HEADER: + case CAMEL_MIME_PARSER_STATE_MESSAGE: + case CAMEL_MIME_PARSER_STATE_MULTIPART: h = camel_mime_parser_headers_raw(mp); while (h) { if (strcasecmp(h->name, "status") != 0 |