Return-Path: Delivered-To: apmail-httpd-cvs-archive@www.apache.org Received: (qmail 89170 invoked from network); 27 Dec 2008 05:28:19 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 27 Dec 2008 05:28:19 -0000 Received: (qmail 43830 invoked by uid 500); 27 Dec 2008 05:28:18 -0000 Delivered-To: apmail-httpd-cvs-archive@httpd.apache.org Received: (qmail 43767 invoked by uid 500); 27 Dec 2008 05:28:18 -0000 Mailing-List: contact cvs-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@httpd.apache.org list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list cvs@httpd.apache.org Received: (qmail 43758 invoked by uid 99); 27 Dec 2008 05:28:17 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 26 Dec 2008 21:28:17 -0800 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 27 Dec 2008 05:28:14 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id C3E1C23889C2; Fri, 26 Dec 2008 21:27:54 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r729600 [2/3] - in /httpd/mod_mbox/trunk: ./ config/ m4/ module-2.0/ scripts/ Date: Sat, 27 Dec 2008 05:27:53 -0000 To: cvs@httpd.apache.org From: pquerna@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20081227052754.C3E1C23889C2@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Modified: httpd/mod_mbox/trunk/module-2.0/mod-mbox-util.c URL: http://svn.apache.org/viewvc/httpd/mod_mbox/trunk/module-2.0/mod-mbox-util.c?rev=729600&r1=729599&r2=729600&view=diff ============================================================================== --- httpd/mod_mbox/trunk/module-2.0/mod-mbox-util.c (original) +++ httpd/mod_mbox/trunk/module-2.0/mod-mbox-util.c Fri Dec 26 21:27:52 2008 @@ -1,9 +1,9 @@ -/* Copyright 2001-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -21,7 +21,6 @@ #include "apr_strings.h" #include "mbox_cache.h" #include "mbox_parse.h" -#include "mbox_search.h" #include "apr_getopt.h" #include "apr_date.h" #include "apr_lib.h" @@ -33,55 +32,43 @@ static int update_mode; static int verbose; -static const char* upath; -static const char* shortname; +static const char *upath; +static const char *shortname; static apr_file_t *errfile; -static const char* index_path; -static mbox_indexer_t *indexer; - static void usage(void) { apr_file_printf(errfile, - "%s -- Program to Create and Update mod_mbox cache files" NL - "Usage: %s [-v] -u MBOX_PATH -s INDEX_PATH" NL - " %s [-v] -c MBOX_PATH -s INDEX_PATH" NL - " %s [-v] -m MBOX_FILE" NL - NL - "Options: " NL - " -v More verbose output"NL - NL - " -u Updates an existing cache. If this cache does not exist it will" NL - " be created. If it contains an older cache format, it will be " NL - " upgraded. " NL - NL - " -c Force creation of a new cache. If there is an existing cache, it" NL - " will be ignored and overwritten " NL - NL - " -m Dumps the Message-ID cache to stdout for the specified file." NL - NL - " -s Set the path to store a Full Text Index." NL - NL, - shortname, - shortname, - shortname, - shortname); + "%s -- Program to Create and Update mod_mbox cache files" + NL "Usage: %s [-v] -u MBOX_PATH" NL + " %s [-v] -c MBOX_PATH" NL + " %s [-v] -m MBOX_FILE" NL NL "Options: " NL + " -v More verbose output" NL NL + " -u Updates an existing cache. If this cache does not exist it will" + NL + " be created. If it contains an older cache format, it will be " + NL " upgraded. " NL NL + " -c Force creation of a new cache. If there is an existing cache, it" + NL " will be ignored and overwritten " NL NL + " -m Dumps the Message-ID cache to stdout for the specified file." + NL NL " -s Set the path to store a Full Text Index." NL + NL, shortname, shortname, shortname, shortname); } static int file_alphasort(const void *fn1, const void *fn2) { /* Reverse Order */ - return strcmp(*(char**)fn2, *(char**)fn1); + return strcmp(*(char **) fn2, *(char **) fn1); } -static int process_mbox(request_rec *r, mbox_cache_info* mli, char *path, - const char* list, const char* domain) +static int process_mbox(request_rec *r, mbox_cache_info *mli, char *path, + const char *list, const char *domain) { apr_status_t rv; apr_file_t *f; int count; - char* temp; - char* absfile = apr_pstrcat(r->pool, r->filename, path, NULL); + char *temp; + char *absfile = apr_pstrcat(r->pool, r->filename, path, NULL); if (update_mode) { /* check the last update time */ @@ -100,47 +87,45 @@ if (rv != APR_SUCCESS) { apr_file_printf(errfile, "Error: Cannot open '%s': %s" NL, - absfile, - apr_strerror(rv, errbuf, sizeof(errbuf))); + absfile, apr_strerror(rv, errbuf, sizeof(errbuf))); return EXIT_FAILURE; } temp = r->filename; r->filename = absfile; - rv = mbox_generate_index(r, f, indexer, list, domain); + rv = mbox_generate_index(r, f, list, domain); r->filename = temp; if (rv != APR_SUCCESS) { - apr_file_printf(errfile, "Error: Index Generation for '%s' failed: %s" NL, - absfile, - apr_strerror(rv, errbuf, sizeof(errbuf))); + apr_file_printf(errfile, + "Error: Index Generation for '%s' failed: %s" NL, + absfile, apr_strerror(rv, errbuf, sizeof(errbuf))); return 0; } count = mbox_msg_count(r, path); if (verbose) { - apr_file_printf(errfile, "\tscanned %d messages" NL, - count); + apr_file_printf(errfile, "\tscanned %d messages" NL, count); } mbox_cache_set_count(mli, count, path); return 0; } -static int scan_dir(request_rec* r) +static int scan_dir(request_rec *r) { apr_status_t rv; apr_dir_t *dir; apr_finfo_t finfo; - apr_array_header_t* files; - char* file = NULL; - char* ml; - char* domain; - char* list; - mbox_cache_info* mli; - apr_pool_t* rpool; + apr_array_header_t *files; + char *file = NULL; + char *ml; + char *domain; + char *list; + mbox_cache_info *mli; + apr_pool_t *rpool; int i; - apr_pool_t* mpool; - apr_pool_t* bpool; + apr_pool_t *mpool; + apr_pool_t *bpool; apr_time_t newtime; char date[APR_RFC822_DATE_LEN]; apr_pool_create(&mpool, r->pool); @@ -161,8 +146,8 @@ while (apr_dir_read(&finfo, APR_FINFO_NAME, dir) == APR_SUCCESS) { if (apr_fnmatch("*.mbox", finfo.name, 0) == APR_SUCCESS && strstr(finfo.name, "incomplete") == NULL) { - *(const char **)apr_array_push(files) = \ - apr_pstrdup(mpool, finfo.name); + *(const char **) apr_array_push(files) = + apr_pstrdup(mpool, finfo.name); } } @@ -174,8 +159,7 @@ return EXIT_FAILURE; } - qsort((void *) files->elts, files->nelts, - sizeof(char *), file_alphasort); + qsort((void *) files->elts, files->nelts, sizeof(char *), file_alphasort); if (verbose) { apr_file_printf(errfile, "Found %d mbox files to process" NL, @@ -184,16 +168,15 @@ /* Look for first non-empty file. */ for (i = 0; i < files->nelts; i++) { - file = ((char**)files->elts)[i]; - rv = apr_stat(&finfo, file, APR_FINFO_SIZE, mpool); - if (rv == APR_SUCCESS && finfo.size > 0) { - break; - } + file = ((char **) files->elts)[i]; + rv = apr_stat(&finfo, file, APR_FINFO_SIZE, mpool); + if (rv == APR_SUCCESS && finfo.size > 0) { + break; + } } if (verbose) { - apr_file_printf(errfile, "Scaning %s for Mailing List info" NL, - file); + apr_file_printf(errfile, "Scaning %s for Mailing List info" NL, file); } ml = mbox_get_list_post(r, file); @@ -230,8 +213,7 @@ } if (verbose) { - apr_file_printf(errfile, "Building Cache for %s@%s" NL, - list, domain); + apr_file_printf(errfile, "Building Cache for %s@%s" NL, list, domain); } rv = mbox_cache_update(&mli, r->filename, mpool, list, domain); @@ -246,21 +228,18 @@ if (verbose) { apr_rfc822_date(date, mli->mtime); - apr_file_printf(errfile, "Last Update: %s" NL, - date); + apr_file_printf(errfile, "Last Update: %s" NL, date); apr_rfc822_date(date, newtime); - apr_file_printf(errfile, "Current Time: %s" NL, - date); + apr_file_printf(errfile, "Current Time: %s" NL, date); } /* Iterate the .mbox files */ apr_pool_create(&rpool, mpool); r->pool = rpool; for (i = 0; i < files->nelts; i++) { - file = ((char**)files->elts)[i]; + file = ((char **) files->elts)[i]; if (verbose) { - apr_file_printf(errfile, "Processing '%s'" NL, - file); + apr_file_printf(errfile, "Processing '%s'" NL, file); } rv = process_mbox(r, mli, file, list, domain); apr_pool_clear(rpool); @@ -284,7 +263,7 @@ return rv; } -static int load_msgid(request_rec* r) +static int load_msgid(request_rec *r) { apr_status_t rv; apr_file_t *f; @@ -298,7 +277,7 @@ while (l) { Message *m; - m = (Message*)l->value; + m = (Message *) l->value; printf("%s\n", m->msgID); l = l->next; } @@ -306,7 +285,8 @@ return APR_SUCCESS; } -int main(int argc, const char* const argv[]) { +int main(int argc, const char *const argv[]) +{ apr_status_t rv = APR_SUCCESS; request_rec r; server_rec s; @@ -320,7 +300,6 @@ update_mode = -1; verbose = 0; upath = NULL; - index_path = NULL; r.server = &s; s.limit_req_fieldsize = DEFAULT_LIMIT_REQUEST_FIELDSIZE; @@ -339,7 +318,7 @@ rv = apr_getopt_init(&opt, r.pool, argc, argv); if (rv != APR_SUCCESS) { - apr_file_printf(errfile, "Error: apr_getopt_init failed."NL NL); + apr_file_printf(errfile, "Error: apr_getopt_init failed." NL NL); return EXIT_FAILURE; } @@ -348,11 +327,13 @@ return EXIT_FAILURE; } - while ((rv = apr_getopt(opt, "vc::u::s::m::", &ch, &optarg)) == APR_SUCCESS) { + while ((rv = + apr_getopt(opt, "vc::u::s::m::", &ch, &optarg)) == APR_SUCCESS) { switch (ch) { case 'v': if (verbose) { - apr_file_printf(errfile, "Error: -v can only be passed once" NL NL); + apr_file_printf(errfile, + "Error: -v can only be passed once" NL NL); usage(); return EXIT_FAILURE; } @@ -360,7 +341,8 @@ break; case 'c': if (update_mode != -1) { - apr_file_printf(errfile, "Error: -u and -c are exclusive" NL NL); + apr_file_printf(errfile, + "Error: -u and -c are exclusive" NL NL); usage(); return EXIT_FAILURE; } @@ -369,7 +351,8 @@ break; case 'u': if (update_mode != -1) { - apr_file_printf(errfile, "Error: -u and -c are exclusive" NL NL); + apr_file_printf(errfile, + "Error: -u and -c are exclusive" NL NL); usage(); return EXIT_FAILURE; } @@ -387,9 +370,6 @@ update_mode = 2; upath = apr_pstrdup(r.pool, optarg); break; - case 's': - index_path = apr_pstrdup(r.pool, optarg); - break; } } @@ -428,28 +408,6 @@ return EXIT_FAILURE; } - if (index_path) { - if (verbose) { - apr_file_printf(errfile, "Opening Lucene Index at: %s" NL, - index_path); - } - rv = mbox_indexer_init(&indexer, index_path, r.pool); - if (rv != APR_SUCCESS) { - apr_file_printf(errfile, - "Error: Unable to open Lucene Index at: " - "'%s', Error Code: %s" NL, index_path, - apr_strerror(rv, errbuf, sizeof(errbuf))); - return EXIT_FAILURE; - } - } - else { - if (verbose) { - apr_file_printf(errfile, "No Search Path Set. " - "Searching will not be available." NL); - } - indexer = NULL; - } - if (verbose) { apr_file_printf(errfile, "Base Path: %s" NL, r.filename); } @@ -461,15 +419,11 @@ rv = scan_dir(&r); } else { - r.filename = (char*)upath; + r.filename = (char *) upath; rv = load_msgid(&r); } - if (indexer) { - mbox_indexer_optimize(indexer); - mbox_indexer_close(indexer); - } apr_pool_clear(r.pool); return rv; } Modified: httpd/mod_mbox/trunk/module-2.0/mod_mbox.c URL: http://svn.apache.org/viewvc/httpd/mod_mbox/trunk/module-2.0/mod_mbox.c?rev=729600&r1=729599&r2=729600&view=diff ============================================================================== --- httpd/mod_mbox/trunk/module-2.0/mod_mbox.c (original) +++ httpd/mod_mbox/trunk/module-2.0/mod_mbox.c Fri Dec 26 21:27:52 2008 @@ -1,9 +1,9 @@ -/* Copyright 2001-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -44,7 +44,6 @@ { ap_hook_handler(mbox_file_handler, NULL, NULL, APR_HOOK_MIDDLE); ap_hook_handler(mbox_index_handler, NULL, NULL, APR_HOOK_FIRST); - ap_hook_handler(mbox_search_handler, NULL, NULL, APR_HOOK_MIDDLE); } /* Module configuration management. @@ -59,7 +58,6 @@ conf->hide_empty = 1; conf->antispam = 1; conf->root_path = NULL; - conf->search_path = NULL; conf->style_path = NULL; conf->script_path = NULL; @@ -68,8 +66,8 @@ static void *mbox_merge_dir_config(apr_pool_t *p, void *basev, void *addv) { - mbox_dir_cfg_t *from = (mbox_dir_cfg_t *)basev; - mbox_dir_cfg_t *merge = (mbox_dir_cfg_t *)addv; + mbox_dir_cfg_t *from = (mbox_dir_cfg_t *) basev; + mbox_dir_cfg_t *merge = (mbox_dir_cfg_t *) addv; mbox_dir_cfg_t *to; to = apr_palloc(p, sizeof(mbox_dir_cfg_t)); @@ -109,17 +107,6 @@ to->root_path = NULL; } - /* Update 'search_path' */ - if (merge->search_path != NULL) { - to->search_path = apr_pstrdup(p, merge->search_path); - } - else if (from->search_path != NULL) { - to->search_path = apr_pstrdup(p, from->search_path); - } - else { - to->search_path = NULL; - } - /* Update 'style_path' */ if (merge->style_path != NULL) { to->style_path = apr_pstrdup(p, merge->style_path); @@ -152,28 +139,27 @@ apr_size_t len; if (!str) - return NULL; + return NULL; len = strlen(str); /* Don't wrap messages with a size larger than MBOX_MAX_WRAP or smaller than a line length. */ if ((len < MBOX_WRAP_TO) || (len > MBOX_MAX_WRAP)) - return str; + return str; - for (i=0, pos=0; i= MBOX_WRAP_TO) && - ((str[i] == ' ') || (str[i] == '\t'))) { - str[i] = '\n'; - pos = 0; - } + if (str[i] == '\n') { + pos = 0; + } + + /* If the position counter is after the wrap limit, wrap text at + first space available */ + if ((pos >= MBOX_WRAP_TO) && ((str[i] == ' ') || (str[i] == '\t'))) { + str[i] = '\n'; + pos = 0; + } } return str; @@ -190,7 +176,7 @@ return NULL; } - temp = temp-7; + temp = temp - 7; *temp = 0; return baseURI; @@ -209,37 +195,38 @@ return baseURI; } -static const command_rec mbox_cmds[] ={ +static const command_rec mbox_cmds[] = { AP_INIT_FLAG("mboxindex", ap_set_flag_slot, - (void *)APR_OFFSETOF(mbox_dir_cfg_t, enabled), OR_INDEXES, - "Enable mod_mbox to create directory listings of .mbox files."), + (void *) APR_OFFSETOF(mbox_dir_cfg_t, enabled), OR_INDEXES, + "Enable mod_mbox to create directory listings of .mbox files."), AP_INIT_FLAG("mboxantispam", ap_set_flag_slot, - (void *)APR_OFFSETOF(mbox_dir_cfg_t, antispam), OR_INDEXES, - "Enable mod_mbox email obfuscation."), - AP_INIT_TAKE1("mboxsearch", ap_set_string_slot, - (void *)APR_OFFSETOF(mbox_dir_cfg_t, search_path), OR_INDEXES, - "Set the Directory that contains Search Data"), + (void *) APR_OFFSETOF(mbox_dir_cfg_t, antispam), OR_INDEXES, + "Enable mod_mbox email obfuscation."), AP_INIT_TAKE1("mboxrootpath", ap_set_string_slot, - (void *)APR_OFFSETOF(mbox_dir_cfg_t, root_path), OR_INDEXES, - "Set the path to the site index."), + (void *) APR_OFFSETOF(mbox_dir_cfg_t, root_path), + OR_INDEXES, + "Set the path to the site index."), AP_INIT_TAKE1("mboxstyle", ap_set_string_slot, - (void *)APR_OFFSETOF(mbox_dir_cfg_t, style_path), OR_INDEXES, - "Set the path to Css stylesheet file."), + (void *) APR_OFFSETOF(mbox_dir_cfg_t, style_path), + OR_INDEXES, + "Set the path to Css stylesheet file."), AP_INIT_TAKE1("mboxscript", ap_set_string_slot, - (void *)APR_OFFSETOF(mbox_dir_cfg_t, script_path), OR_INDEXES, - "Set the path to the Javascript file."), + (void *) APR_OFFSETOF(mbox_dir_cfg_t, script_path), + OR_INDEXES, + "Set the path to the Javascript file."), AP_INIT_FLAG("mboxhideempty", ap_set_flag_slot, - (void *)APR_OFFSETOF(mbox_dir_cfg_t, hide_empty), OR_INDEXES, - "Whether to display empty mboxes in index listing."), + (void *) APR_OFFSETOF(mbox_dir_cfg_t, hide_empty), + OR_INDEXES, + "Whether to display empty mboxes in index listing."), {NULL} }; module mbox_module = { STANDARD20_MODULE_STUFF, - mbox_create_dir_config, /* per-directory config creator */ - mbox_merge_dir_config, /* dir config merger */ - NULL, /* server config creator */ - NULL, /* server config merger */ - mbox_cmds, /* command table */ - mbox_register_hooks /* set up other request processing hooks */ + mbox_create_dir_config, /* per-directory config creator */ + mbox_merge_dir_config, /* dir config merger */ + NULL, /* server config creator */ + NULL, /* server config merger */ + mbox_cmds, /* command table */ + mbox_register_hooks /* set up other request processing hooks */ }; Modified: httpd/mod_mbox/trunk/module-2.0/mod_mbox.h URL: http://svn.apache.org/viewvc/httpd/mod_mbox/trunk/module-2.0/mod_mbox.h?rev=729600&r1=729599&r2=729600&view=diff ============================================================================== --- httpd/mod_mbox/trunk/module-2.0/mod_mbox.h (original) +++ httpd/mod_mbox/trunk/module-2.0/mod_mbox.h Fri Dec 26 21:27:52 2008 @@ -1,18 +1,18 @@ -/* Copyright 2001-2005 The Apache Software Foundation or its licensors, as -* applicable. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /* DEFAULT_LIMIT_REQUEST_FIELDSIZE is now CORE_PRIVATE */ #define CORE_PRIVATE @@ -43,7 +43,8 @@ #define MOD_MBOX_H #ifdef __cplusplus -extern "C" { +extern "C" +{ #endif #define MBOX_HANDLER "mbox-handler" @@ -67,17 +68,18 @@ #define MBOX_FETCH_ERROR_STR "An error occured while fetching this message, sorry !" -typedef struct mbox_dir_cfg { +typedef struct mbox_dir_cfg +{ int enabled; int antispam; int hide_empty; const char *root_path; - const char *search_path; const char *style_path; const char *script_path; } mbox_dir_cfg_t; -typedef struct mbox_file { +typedef struct mbox_file +{ char *filename; int count; } mbox_file_t; @@ -97,17 +99,20 @@ /* Handlers */ int mbox_atom_handler(request_rec *r, mbox_cache_info *mli); +int mbox_sitemap_handler(request_rec *r, mbox_cache_info *mli); int mbox_file_handler(request_rec *r); int mbox_index_handler(request_rec *r); -int mbox_search_handler(request_rec *r); /* Output functions */ -apr_status_t mbox_xml_msglist(request_rec *r, apr_file_t *f, int sortFlags); -apr_status_t mbox_static_msglist(request_rec *r, apr_file_t *f, int sortFlags); +apr_status_t mbox_xml_msglist(request_rec *r, apr_file_t *f, + int sortFlags); +apr_status_t mbox_static_msglist(request_rec *r, apr_file_t *f, + int sortFlags); apr_status_t mbox_xml_boxlist(request_rec *r); apr_status_t mbox_static_boxlist(request_rec *r); -apr_status_t mbox_static_index_boxlist(request_rec *r, mbox_dir_cfg_t *conf, - mbox_cache_info *mli); +apr_status_t mbox_static_index_boxlist(request_rec *r, + mbox_dir_cfg_t *conf, + mbox_cache_info *mli); void mbox_atom_entries(request_rec *r, mbox_cache_info *mli); @@ -119,23 +124,26 @@ /* CTE decoding functions */ const char *mbox_cte_to_char(mbox_cte_e cte); -apr_size_t mbox_cte_decode_qp(char* p); +apr_size_t mbox_cte_decode_qp(char *p); apr_size_t mbox_cte_decode_b64(char *src); apr_size_t mbox_cte_escape_html(apr_pool_t *p, const char *s, - apr_size_t len, char **body); + apr_size_t len, char **body); char *mbox_cte_decode_rfc2047(apr_pool_t *p, char *src); char *mbox_cte_decode_header(apr_pool_t *p, char *src); /* MIME decoding functions */ -mbox_mime_message_t *mbox_mime_decode_multipart(apr_pool_t *p, char *body, - char *ct, mbox_cte_e cte, - char *boundary); -char *mbox_mime_decode_body(apr_pool_t *p, mbox_cte_e cte, char *body, apr_size_t len, apr_size_t *ret_len); +mbox_mime_message_t *mbox_mime_decode_multipart(apr_pool_t *p, + char *body, char *ct, + mbox_cte_e cte, + char *boundary); +char *mbox_mime_decode_body(apr_pool_t *p, mbox_cte_e cte, char *body, + apr_size_t len, apr_size_t *ret_len); char *mbox_mime_get_body(apr_pool_t *p, mbox_mime_message_t *m); -void mbox_mime_display_static_structure(request_rec *r, mbox_mime_message_t *m, - char *link); -void mbox_mime_display_xml_structure(request_rec *r, mbox_mime_message_t *m, - char *link); +void mbox_mime_display_static_structure(request_rec *r, + mbox_mime_message_t *m, + char *link); +void mbox_mime_display_xml_structure(request_rec *r, + mbox_mime_message_t *m, char *link); /* Utility functions */ char *mbox_wrap_text(char *str); @@ -143,10 +151,11 @@ char *get_base_uri(request_rec *r); /* Backend functions */ -apr_array_header_t *mbox_fetch_boxes_list(request_rec *r, mbox_cache_info *mli, +apr_array_header_t *mbox_fetch_boxes_list(request_rec *r, + mbox_cache_info *mli, char *path); Message *fetch_message(request_rec *r, apr_file_t *f, char *msgID); -char **fetch_context_msgids(request_rec *r, apr_file_t *f, char*msgID); +char **fetch_context_msgids(request_rec *r, apr_file_t *f, char *msgID); void load_message(apr_pool_t *p, apr_file_t *f, Message *m); Modified: httpd/mod_mbox/trunk/module-2.0/mod_mbox_cte.c URL: http://svn.apache.org/viewvc/httpd/mod_mbox/trunk/module-2.0/mod_mbox_cte.c?rev=729600&r1=729599&r2=729600&view=diff ============================================================================== --- httpd/mod_mbox/trunk/module-2.0/mod_mbox_cte.c (original) +++ httpd/mod_mbox/trunk/module-2.0/mod_mbox_cte.c Fri Dec 26 21:27:52 2008 @@ -1,18 +1,18 @@ -/* Copyright 2001-2005 The Apache Software Foundation or its licensors, as -* applicable. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /* Decoding common Content-Encodings of E-Mail functions. * @@ -40,21 +40,21 @@ */ static char index_64[128] = { - -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, - -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, - -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,62, -1,-1,-1,63, - 52,53,54,55, 56,57,58,59, 60,61,-1,-1, -1,-1,-1,-1, - -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10, 11,12,13,14, - 15,16,17,18, 19,20,21,22, 23,24,25,-1, -1,-1,-1,-1, - -1,26,27,28, 29,30,31,32, 33,34,35,36, 37,38,39,40, - 41,42,43,44, 45,46,47,48, 49,50,51,-1, -1,-1,-1,-1 + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63, + 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1, + -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, + -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, + 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1 }; #define char64(c) (((c) < 0 || (c) > 127) ? -1 : index_64[(c)]) const char *mbox_cte_to_char(mbox_cte_e cte) { - switch(cte) { + switch (cte) { case CTE_NONE: return "None"; case CTE_7BIT: @@ -78,7 +78,7 @@ * safe. */ apr_size_t mbox_cte_escape_html(apr_pool_t *p, const char *s, - apr_size_t len, char **body) + apr_size_t len, char **body) { char *x; int i, j; @@ -143,7 +143,8 @@ if (isspace(c1)) { if (c1 == '\n') { newline = 1; - } else { + } + else { newline = 0; } continue; @@ -219,7 +220,7 @@ } /* Decode quoted-printable to raw text. */ -apr_size_t mbox_cte_decode_qp(char* p) +apr_size_t mbox_cte_decode_qp(char *p) { apr_size_t len = 0; char *src, *dst; @@ -296,54 +297,54 @@ /* Quoted-Printable decoding : mode 'q' */ if ((*mode == 'q') || (*mode == 'Q')) { apr_size_t data_len; - int i; + int i; - /* In QP header encoding, spaces are encoded either in =20 (as - in all QP encoding) or in underscores '_' (for header - encoding). The first case will be handle by the QP - decoding, so we must handle the other one */ - for (i = 0; i < strlen(data); i++) { - if (data[i] == '_') { - data[i] = ' '; - } - } + /* In QP header encoding, spaces are encoded either in =20 (as + in all QP encoding) or in underscores '_' (for header + encoding). The first case will be handle by the QP + decoding, so we must handle the other one */ + for (i = 0; i < strlen(data); i++) { + if (data[i] == '_') { + data[i] = ' '; + } + } - data_len = mbox_cte_decode_qp(data); - data[data_len] = 0; + data_len = mbox_cte_decode_qp(data); + data[data_len] = 0; } else if ((*mode == 'b') || (*mode == 'B')) { apr_size_t data_len; - data_len = mbox_cte_decode_b64(data); - data[data_len] = 0; + data_len = mbox_cte_decode_b64(data); + data[data_len] = 0; } /* Convert charset to uppercase */ - for (i=0; iraw_msg = NULL; - m->raw_body = NULL; + m->raw_body = NULL; - return m; + return m; } - m->raw_msg = apr_palloc(r->pool, len+1); + m->raw_msg = apr_palloc(r->pool, len + 1); if (apr_file_read(f, m->raw_msg, &len) != APR_SUCCESS) { return NULL; @@ -70,7 +70,7 @@ } len = m->body_end - m->msg_start; - m->raw_msg = apr_palloc(p, len+1); + m->raw_msg = apr_palloc(p, len + 1); if (apr_file_read(f, m->raw_msg, &len) != APR_SUCCESS) { return; @@ -97,7 +97,8 @@ return next; } -static Container *find_prev_thread(request_rec *r, char *msgID, Container *c) +static Container *find_prev_thread(request_rec *r, char *msgID, + Container *c) { Container *next = NULL; @@ -110,8 +111,7 @@ find_prev_thread(r, msgID, c->child)); } - if (!next && c->next) - { + if (!next && c->next) { /* Root set potentially does not have message */ if (c->next->message && strcmp(msgID, c->next->message->msgID) == 0) { if (c->message) { @@ -141,7 +141,8 @@ return next; } -static Container *find_next_thread(request_rec *r, char *msgID, Container *c) +static Container *find_next_thread(request_rec *r, char *msgID, + Container *c) { c = find_thread(r, msgID, c); @@ -190,9 +191,9 @@ MBOX_LIST *head, *prev = NULL; Container *threads, *c; - char **context = apr_palloc(r->pool, 4*sizeof(char *)); + char **context = apr_palloc(r->pool, 4 * sizeof(char *)); - memset(context, 0, 4*sizeof(char *)); + memset(context, 0, 4 * sizeof(char *)); head = mbox_load_index(r, f, NULL); @@ -201,31 +202,31 @@ /* First, set the MBOX_PREV and MBOX_NEXT IDs */ head = mbox_sort_list(head, MBOX_SORT_DATE); - while (head && strcmp(msgID, ((Message*)(head->value))->msgID) != 0) { - prev = head; - head = head->next; + while (head && strcmp(msgID, ((Message *) (head->value))->msgID) != 0) { + prev = head; + head = head->next; } if (prev) { - context[0] = ((Message*)(prev->value))->msgID; + context[0] = ((Message *) (prev->value))->msgID; } if (head && head->next) { - context[1] = ((Message*)(head->next->value))->msgID; + context[1] = ((Message *) (head->next->value))->msgID; } /* And the MBOX_PREV_THREAD and MBOX_NEXT_THREAD ones */ if (threads) { c = find_prev_thread(r, msgID, threads); - if (c && c->message) { - context[2] = c->message->msgID; - } - - c = find_next_thread(r, msgID, threads); - if (c && c->message) { - context[3] = c->message->msgID; - } + if (c && c->message) { + context[2] = c->message->msgID; + } + + c = find_next_thread(r, msgID, threads); + if (c && c->message) { + context[3] = c->message->msgID; + } } return context; @@ -248,8 +249,8 @@ r->handler != MBOX_MAGIC_TYPE or r->handler != MBOX_HANDLER */ if (!r->handler || - (strcmp(r->handler,MBOX_MAGIC_TYPE) && - strcmp(r->handler,MBOX_HANDLER))) { + (strcmp(r->handler, MBOX_MAGIC_TYPE) && + strcmp(r->handler, MBOX_HANDLER))) { return DECLINED; } @@ -278,52 +279,52 @@ /* Open the file */ if ((status = apr_file_open(&f, r->filename, APR_READ, - APR_OS_DEFAULT, r->pool)) != APR_SUCCESS) { + APR_OS_DEFAULT, r->pool)) != APR_SUCCESS) { ap_log_rerror(APLOG_MARK, APLOG_ERR, status, r, - "file permissions deny server access: %s", r->filename); + "file permissions deny server access: %s", r->filename); return HTTP_FORBIDDEN; } /* AJAX requests return XML */ if (strncmp(r->path_info, "/ajax", 5) == 0) { - /* Set content type */ + /* Set content type */ ap_set_content_type(r, "application/xml"); - if (r->header_only) { - return OK; + if (r->header_only) { + return OK; } - if (strcmp(r->path_info, "/ajax/boxlist") == 0) - status = mbox_xml_boxlist(r); + if (strcmp(r->path_info, "/ajax/boxlist") == 0) + status = mbox_xml_boxlist(r); - else if (strcmp(r->path_info, "/ajax/thread") == 0) - status = mbox_xml_msglist(r, f, MBOX_SORT_THREAD); - else if (strcmp(r->path_info, "/ajax/author") == 0) - status = mbox_xml_msglist(r, f, MBOX_SORT_AUTHOR); - else if (strcmp(r->path_info, "/ajax/date") == 0) - status = mbox_xml_msglist(r, f, MBOX_SORT_DATE); - else - status = mbox_xml_message(r, f); + else if (strcmp(r->path_info, "/ajax/thread") == 0) + status = mbox_xml_msglist(r, f, MBOX_SORT_THREAD); + else if (strcmp(r->path_info, "/ajax/author") == 0) + status = mbox_xml_msglist(r, f, MBOX_SORT_AUTHOR); + else if (strcmp(r->path_info, "/ajax/date") == 0) + status = mbox_xml_msglist(r, f, MBOX_SORT_DATE); + else + status = mbox_xml_message(r, f); } else if (strncmp(r->path_info, "/raw", 4) == 0) { status = mbox_raw_message(r, f); } else { - /* Set content type */ + /* Set content type */ ap_set_content_type(r, "text/html"); - if (r->header_only) { - return OK; + if (r->header_only) { + return OK; } - if (strcmp(r->path_info, "/browser") == 0) - status = mbox_ajax_browser(r); + if (strcmp(r->path_info, "/browser") == 0) + status = mbox_ajax_browser(r); else if (strcmp(r->path_info, "/thread") == 0) status = mbox_static_msglist(r, f, MBOX_SORT_THREAD); - else if (strcmp(r->path_info, "/author") == 0) + else if (strcmp(r->path_info, "/author") == 0) status = mbox_static_msglist(r, f, MBOX_SORT_AUTHOR); - else if (strcmp(r->path_info, "/date") == 0) + else if (strcmp(r->path_info, "/date") == 0) status = mbox_static_msglist(r, f, MBOX_SORT_DATE); else Modified: httpd/mod_mbox/trunk/module-2.0/mod_mbox_index.c URL: http://svn.apache.org/viewvc/httpd/mod_mbox/trunk/module-2.0/mod_mbox_index.c?rev=729600&r1=729599&r2=729600&view=diff ============================================================================== --- httpd/mod_mbox/trunk/module-2.0/mod_mbox_index.c (original) +++ httpd/mod_mbox/trunk/module-2.0/mod_mbox_index.c Fri Dec 26 21:27:52 2008 @@ -1,18 +1,18 @@ -/* Copyright 2001-2005 The Apache Software Foundation or its licensors, as -* applicable. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /* The file contains an alternative Directory Index Handler that * displays information about the mailing list. @@ -29,18 +29,18 @@ */ static int filename_rsort(const void *fn1, const void *fn2) { - mbox_file_t *f1 = (mbox_file_t *)fn1; - mbox_file_t *f2 = (mbox_file_t *)fn2; + mbox_file_t *f1 = (mbox_file_t *) fn1; + mbox_file_t *f2 = (mbox_file_t *) fn2; - return strcmp(f2->filename, f1->filename); + return strcmp(f2->filename, f1->filename); } /* Fetches the .mbox files from the directory and return a chained * list of mbox_files_t containing all the information we need to * output a complete box listing. */ -apr_array_header_t *mbox_fetch_boxes_list(request_rec *r, mbox_cache_info *mli, - char *path) +apr_array_header_t *mbox_fetch_boxes_list(request_rec *r, + mbox_cache_info *mli, char *path) { apr_status_t rv = APR_SUCCESS; apr_finfo_t finfo; @@ -54,8 +54,8 @@ permissions are stopping us. */ if (rv != APR_SUCCESS) { ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, - "mod_mbox(fetch_boxes_list): Failed to open directory '%s' for index", - path); + "mod_mbox(fetch_boxes_list): Failed to open directory '%s' for index", + path); return NULL; } @@ -71,10 +71,10 @@ while (apr_dir_read(&finfo, APR_FINFO_NAME, dir) == APR_SUCCESS) { if ((apr_fnmatch("*.mbox", finfo.name, 0) == APR_SUCCESS) && (strstr(finfo.name, "incomplete") == NULL)) { - fi = (mbox_file_t*)apr_array_push(files); + fi = (mbox_file_t *) apr_array_push(files); fi->filename = apr_pstrdup(r->pool, finfo.name); - mbox_cache_get_count(mli, &(fi->count), (char *)finfo.name); - } + mbox_cache_get_count(mli, &(fi->count), (char *) finfo.name); + } } apr_dir_close(dir); @@ -84,20 +84,21 @@ } /* Sort by reverse filename order */ - qsort((void *)files->elts, files->nelts, sizeof(mbox_file_t), filename_rsort); + qsort((void *) files->elts, files->nelts, sizeof(mbox_file_t), + filename_rsort); return files; } -int mbox_atom_handler(request_rec *r, mbox_cache_info *mli) +int mbox_atom_handler(request_rec *r, mbox_cache_info *mli) { int errstatus; char dstr[100]; apr_size_t dlen; char *etag; apr_time_exp_t extime; - + /* Only allow GETs */ r->allowed |= (AP_METHOD_BIT << M_GET); if (r->method_number != M_GET) { @@ -124,16 +125,17 @@ ap_rputs("\n", r); ap_rputs("\n", r); ap_rprintf(r, "%s@%s Archives\n", - ESCAPE_OR_BLANK(r->pool, mli->list), - ESCAPE_OR_BLANK(r->pool, mli->domain)); - ap_rprintf(r, "\n", ap_construct_url(r->pool, r->uri, r)); - ap_rprintf(r, "\n", ap_construct_url(r->pool, r->uri, r)); - ap_rprintf(r, "%s\n", ap_construct_url(r->pool, r->uri, r)); + ESCAPE_OR_BLANK(r->pool, mli->list), + ESCAPE_OR_BLANK(r->pool, mli->domain)); + ap_rprintf(r, "\n", + ap_construct_url(r->pool, r->uri, r)); + ap_rprintf(r, "\n", + ap_construct_url(r->pool, r->uri, r)); + ap_rprintf(r, "%s\n", ap_construct_url(r->pool, r->uri, r)); apr_time_exp_gmt(&extime, mli->mtime); - - apr_strftime(dstr, &dlen, sizeof(dstr), - "%G-%m-%dT%H:%M:%SZ", &extime); + + apr_strftime(dstr, &dlen, sizeof(dstr), "%G-%m-%dT%H:%M:%SZ", &extime); ap_rprintf(r, "%s\n", dstr); mbox_atom_entries(r, mli); @@ -165,8 +167,8 @@ rv = mbox_cache_get(&mli, r->filename, r->pool); if (rv != APR_SUCCESS) { ap_log_rerror(APLOG_MARK, APLOG_DEBUG, rv, r, - "mod_mbox: Can't open directory cache '%s' for index", - r->filename); + "mod_mbox: Can't open directory cache '%s' for index", + r->filename); return DECLINED; } @@ -174,6 +176,10 @@ return mbox_atom_handler(r, mli); } + if (r->args && strstr(r->args, "format=sitemap") != NULL) { + return mbox_sitemap_handler(r, mli); + } + /* Only allow GETs */ r->allowed |= (AP_METHOD_BIT << M_GET); if (r->method_number != M_GET) { @@ -198,12 +204,15 @@ } ap_rputs("\n", r); - ap_rputs("\n\n", r); ap_rputs("\n", r); ap_rputs(" \n", r); - ap_rputs(" \n", r); + ap_rputs + (" \n", + r); if (mli->list && mli->domain) { ap_rprintf(r, " %s@%s Archives\n", ESCAPE_OR_BLANK(r->pool, mli->list), @@ -214,66 +223,72 @@ } ap_rprintf(r, "", - ESCAPE_OR_BLANK(r->pool, mli->list), - ESCAPE_OR_BLANK(r->pool, mli->domain), - ap_construct_url(r->pool, r->uri, r)); + "type=\"application/atom+xml\" href=\"%s?format=atom\" />", + ESCAPE_OR_BLANK(r->pool, mli->list), + ESCAPE_OR_BLANK(r->pool, mli->domain), + ap_construct_url(r->pool, r->uri, r)); if (conf->style_path) { - ap_rprintf(r, " \n", - conf->style_path); + ap_rprintf(r, + " \n", + conf->style_path); } if (conf->script_path) { - ap_rprintf(r, " \n", - conf->script_path); + ap_rprintf(r, + " \n", + conf->script_path); } ap_rputs(" \n\n", r); ap_rputs(" \n", r); ap_rprintf(r, "

Mailing list archives: %s@%s

\n", - ESCAPE_OR_BLANK(r->pool, mli->list), - ESCAPE_OR_BLANK(r->pool, mli->domain)); + ESCAPE_OR_BLANK(r->pool, mli->list), + ESCAPE_OR_BLANK(r->pool, mli->domain)); if (conf->root_path) { - ap_rprintf(r, "
" - "Site index
\n\n", - conf->root_path); + ap_rprintf(r, + "
" + "Site index
\n\n", conf->root_path); } /* Output header and list information */ ap_rputs(" \n", r); - ap_rputs(" \n", r); + ap_rputs + (" \n", + r); ap_rputs(" \n", r); ap_rprintf(r, " " - "\n", - ESCAPE_OR_BLANK(r->pool, mli->list), - ESCAPE_OR_BLANK(r->pool, mli->domain)); + "\n", + ESCAPE_OR_BLANK(r->pool, mli->list), + ESCAPE_OR_BLANK(r->pool, mli->domain)); ap_rprintf(r, " " - "\n", - ESCAPE_OR_BLANK(r->pool, mli->list), - ESCAPE_OR_BLANK(r->pool, mli->domain)); - - ap_rprintf(r, " " - "\n", - ESCAPE_OR_BLANK(r->pool, mli->list), - ESCAPE_OR_BLANK(r->pool, mli->domain)); + "\n", + ESCAPE_OR_BLANK(r->pool, mli->list), + ESCAPE_OR_BLANK(r->pool, mli->domain)); + + ap_rprintf(r, + " " + "\n", + ESCAPE_OR_BLANK(r->pool, mli->list), ESCAPE_OR_BLANK(r->pool, + mli-> + domain)); ap_rprintf(r, " " - "\n", - ESCAPE_OR_BLANK(r->pool, mli->list), - ESCAPE_OR_BLANK(r->pool, mli->domain)); + "\n", + ESCAPE_OR_BLANK(r->pool, mli->list), + ESCAPE_OR_BLANK(r->pool, mli->domain)); ap_rprintf(r, " " - "\n", - ESCAPE_OR_BLANK(r->pool, mli->list), - ESCAPE_OR_BLANK(r->pool, mli->domain)); + "\n", + ESCAPE_OR_BLANK(r->pool, mli->list), + ESCAPE_OR_BLANK(r->pool, mli->domain)); ap_rputs("" - "\n", r); ap_rputs(" \n", r); Modified: httpd/mod_mbox/trunk/module-2.0/mod_mbox_mime.c URL: http://svn.apache.org/viewvc/httpd/mod_mbox/trunk/module-2.0/mod_mbox_mime.c?rev=729600&r1=729599&r2=729600&view=diff ============================================================================== --- httpd/mod_mbox/trunk/module-2.0/mod_mbox_mime.c (original) +++ httpd/mod_mbox/trunk/module-2.0/mod_mbox_mime.c Fri Dec 26 21:27:52 2008 @@ -1,18 +1,18 @@ -/* Copyright 2001-2005 The Apache Software Foundation or its licensors, as -* applicable. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /* MIME parsing and structure management functions. */ @@ -23,8 +23,8 @@ * levels of MIME parts, this function is recursive. */ mbox_mime_message_t *mbox_mime_decode_multipart(apr_pool_t *p, char *body, - char *ct, mbox_cte_e cte, - char *boundary) + char *ct, mbox_cte_e cte, + char *boundary) { mbox_mime_message_t *mail; char *tmp = NULL, *k = NULL, *end_bound = NULL; @@ -38,7 +38,7 @@ if (!ct) { headers_bound = ap_strstr(body, "\n\n"); if (!headers_bound) { - return NULL; + return NULL; } } else { @@ -58,55 +58,56 @@ /* If no Content-Type is given, we have to look for it. */ if (!ct) { - tmp += sizeof("Content-Type: ") - 1; - k = strchr(tmp, ';'); + tmp += sizeof("Content-Type: ") - 1; + k = strchr(tmp, ';'); + + /* Isolate the Content-Type string (between 'Content-Type: ' + and ';' or end of line */ + if (k && k < headers_bound) { + *k = 0; + } + else { + k = tmp; + while (*k) { + if (isspace(*k)) { + *k = 0; + break; + } + *k++; + } + } - /* Isolate the Content-Type string (between 'Content-Type: ' - and ';' or end of line */ - if (k && k < headers_bound) { - *k = 0; - } - else { - k = tmp; - while (*k) { - if (isspace(*k)) { - *k = 0; - break; - } - *k++; - } - } - - /* Copy the Content-Type and reset *k */ - mail->content_type = apr_pstrdup(p, tmp); - *k = ';'; - - /* If available, get MIME part name */ - tmp = ap_strstr(body, "name="); - if (tmp && tmp < headers_bound) { - char c; - tmp += sizeof("name=") - 1; - k = tmp; + /* Copy the Content-Type and reset *k */ + mail->content_type = apr_pstrdup(p, tmp); + *k = ';'; + + /* If available, get MIME part name */ + tmp = ap_strstr(body, "name="); + if (tmp && tmp < headers_bound) { + char c = '\0'; + tmp += sizeof("name=") - 1; + k = tmp; - while (*k) { - if (isspace(*k) || *k == ';') { + while (*k) { + if (isspace(*k) || *k == ';') { c = *k; - *k = 0; - break; - } - *k++; - } - - /* Check for double quotes */ - if ((*tmp == '"') && (tmp[strlen(tmp)-1] == '"')) { - mail->content_name = apr_pstrndup(p, tmp+1, strlen(tmp) - 2); - } - else { - mail->content_name = apr_pstrdup(p, tmp); - } + *k = 0; + break; + } + *k++; + } + + /* Check for double quotes */ + if ((*tmp == '"') && (tmp[strlen(tmp) - 1] == '"')) { + mail->content_name = + apr_pstrndup(p, tmp + 1, strlen(tmp) - 2); + } + else { + mail->content_name = apr_pstrdup(p, tmp); + } - *k = c; - } + *k = c; + } } else { mail->content_type = ct; @@ -117,50 +118,49 @@ /* Check Content-Disposition if the match is within the headers */ tmp = ap_strstr(body, "Content-Disposition: "); if (tmp && tmp < headers_bound) { - char c; - tmp += sizeof("Content-Disposition: ") - 1; - k = tmp; + char c = '\0'; + tmp += sizeof("Content-Disposition: ") - 1; + k = tmp; - while (*k) { - if (isspace(*k) || *k == ';') { + while (*k) { + if (isspace(*k) || *k == ';') { c = *k; - *k = 0; - break; - } - *k++; - } - - /* Copy the Content-Disposition and reset *k */ - mail->content_disposition = apr_pstrdup(p, tmp); - *k = c; + *k = 0; + break; + } + *k++; + } + + /* Copy the Content-Disposition and reset *k */ + mail->content_disposition = apr_pstrdup(p, tmp); + *k = c; } else { mail->content_disposition = apr_pstrdup(p, "inline"); } /* Check Content-Transfer-Encoding, if needed */ - if (cte == CTE_NONE) - { - tmp = ap_strstr(body, "Content-Transfer-Encoding: "); - if (tmp && tmp < headers_bound) { - char c; - tmp += sizeof("Content-Transfer-Encoding: ") - 1; - k = tmp; - - while (*k) { - if (isspace(*k) || *k == ';') { - c = *k; - *k = 0; - break; - } - *k++; - } - - /* Copy the Content-Disposition and reset *k */ - mail->cte = mbox_parse_cte_header(tmp); - *k = c; - } - } + if (cte == CTE_NONE) { + tmp = ap_strstr(body, "Content-Transfer-Encoding: "); + if (tmp && tmp < headers_bound) { + char c = '\0'; + tmp += sizeof("Content-Transfer-Encoding: ") - 1; + k = tmp; + + while (*k) { + if (isspace(*k) || *k == ';') { + c = *k; + *k = 0; + break; + } + *k++; + } + + /* Copy the Content-Disposition and reset *k */ + mail->cte = mbox_parse_cte_header(tmp); + *k = c; + } + } else { mail->cte = cte; } @@ -183,95 +183,97 @@ /* If the mail is a multipart message, search for the boundary, and process its sub parts by recursive calls. */ if (strncmp(mail->content_type, "multipart/", strlen("multipart/")) == 0) { - int end = 0, count = 0; - char *search, *bound, *boundary_line; + int end = 0, count = 0; + char *search, *bound, *boundary_line; + + /* If the boundary was not given, we must look for it in the headers */ + if (!boundary) { + tmp = ap_strstr(body, "boundary=\""); + if (!tmp) { + return NULL; + } + + tmp += sizeof("boundary=\"") - 1; + k = tmp; + + while (*k) { + if (*k == '"') { + *k = 0; + break; + } + *k++; + } + + mail->boundary = apr_pstrdup(p, tmp); + *k = '"'; + } - /* If the boundary was not given, we must look for it in the headers */ - if (!boundary) { - tmp = ap_strstr(body, "boundary=\""); - if (!tmp) { - return NULL; - } - - tmp += sizeof("boundary=\"") - 1; - k = tmp; - - while (*k) { - if (*k == '"') { - *k = 0; - break; - } - *k++; - } - - mail->boundary = apr_pstrdup(p, tmp); - *k = '"'; - } - - /* Otherwise, the boundary is as given to us */ - else { - mail->boundary = boundary; - } - - /* Now we have our boundary string. We must : look for it once - (begining of MIME part) and then look for the end boundary : - --boundary-- to mark the end of the MIME part. - - In order to handle empty boundaries, we'll look for the - boundary plus the \n. */ - - boundary_line = apr_pstrcat(p, "--", mail->boundary, NULL); - - /* The start boundary */ - bound = ap_strstr(mail->body, boundary_line); - if (!bound) { - return NULL; - } - - /* The end boudary */ - end_bound = apr_psprintf(p, "--%s--", mail->boundary); - tmp = ap_strstr(mail->body, end_bound); - if (!tmp) { - return NULL; - } - *tmp = 0; - - /* Set the search begining to the line after the start boundary. */ - search = bound + strlen(boundary_line) + 1; - - /* While the MIME part is not finished, go through all sub parts */ - while (!end) { - char *inbound; - - inbound = ap_strstr(search, boundary_line); - if (inbound) { - *inbound = 0; - } - - /* Allocate a new pointer for the sub part, and parse it. */ - mail->sub = realloc(mail->sub, ++count * sizeof(struct mimemsg *)); - mail->sub[count-1] = mbox_mime_decode_multipart(p, search, NULL, CTE_NONE, NULL); - - /* If the boudary is found again, it means we have another - MIME part in the same multipart message. Set the new - search begining to the line after this new start - boundary */ - if (inbound) { - *inbound = '-'; - - search = inbound + strlen(boundary_line) + 1; - } - - /* Otherwise, the MIME part is finished. */ - else { - mail->sub_count = count; - end = 1; - } - } - - /* Finally reset the end-body pointer. */ - // *tmp = '-'; - } + /* Otherwise, the boundary is as given to us */ + else { + mail->boundary = boundary; + } + + /* Now we have our boundary string. We must : look for it once + (begining of MIME part) and then look for the end boundary : + --boundary-- to mark the end of the MIME part. + + In order to handle empty boundaries, we'll look for the + boundary plus the \n. */ + + boundary_line = apr_pstrcat(p, "--", mail->boundary, NULL); + + /* The start boundary */ + bound = ap_strstr(mail->body, boundary_line); + if (!bound) { + return NULL; + } + + /* The end boudary */ + end_bound = apr_psprintf(p, "--%s--", mail->boundary); + tmp = ap_strstr(mail->body, end_bound); + if (!tmp) { + return NULL; + } + *tmp = 0; + + /* Set the search begining to the line after the start boundary. */ + search = bound + strlen(boundary_line) + 1; + + /* While the MIME part is not finished, go through all sub parts */ + while (!end) { + char *inbound; + + inbound = ap_strstr(search, boundary_line); + if (inbound) { + *inbound = 0; + } + + /* Allocate a new pointer for the sub part, and parse it. */ + mail->sub = + realloc(mail->sub, ++count * sizeof(struct mimemsg *)); + mail->sub[count - 1] = + mbox_mime_decode_multipart(p, search, NULL, CTE_NONE, NULL); + + /* If the boudary is found again, it means we have another + MIME part in the same multipart message. Set the new + search begining to the line after this new start + boundary */ + if (inbound) { + *inbound = '-'; + + search = inbound + strlen(boundary_line) + 1; + } + + /* Otherwise, the MIME part is finished. */ + else { + mail->sub_count = count; + end = 1; + } + } + + /* Finally reset the end-body pointer. */ + // *tmp = '-'; + } /* If the parsed body is not multipart or is a MIME part, the body length is the length of the body string (no surprise here). If @@ -335,21 +337,23 @@ if (strncasecmp(m->content_type, "text/", strlen("text/")) == 0) { char *new_body; - new_body = mbox_mime_decode_body(p, m->cte, m->body, m->body_len, NULL); - if (!new_body) { - return MBOX_FETCH_ERROR_STR; - } + new_body = + mbox_mime_decode_body(p, m->cte, m->body, m->body_len, NULL); + if (!new_body) { + return MBOX_FETCH_ERROR_STR; + } - m->body_len = mbox_cte_escape_html(p, new_body, m->body_len, &(m->body)); + m->body_len = + mbox_cte_escape_html(p, new_body, m->body_len, &(m->body)); - return apr_pstrndup(p, m->body, m->body_len); + return apr_pstrndup(p, m->body, m->body_len); } if (!m->sub) { return MBOX_FETCH_ERROR_STR; } - for (i=0 ; isub_count ; i++) { + for (i = 0; i < m->sub_count; i++) { return mbox_mime_get_body(p, m->sub[i]); } @@ -357,8 +361,8 @@ } /* Display an XHTML MIME structure */ -void mbox_mime_display_static_structure(request_rec *r, mbox_mime_message_t *m, - char *link) +void mbox_mime_display_static_structure(request_rec *r, + mbox_mime_message_t *m, char *link) { int i; @@ -383,29 +387,30 @@ ap_rputs("", r); } - ap_rprintf(r, " (%s, %s, %u bytes)\n", m->content_disposition, - mbox_cte_to_char(m->cte), m->body_len); + ap_rprintf(r, " (%s, %s, %" APR_SIZE_T_FMT " bytes)\n", + m->content_disposition, mbox_cte_to_char(m->cte), m->body_len); if (!m->sub) { return; } - for (i=0 ; isub_count ; i++) { + for (i = 0; i < m->sub_count; i++) { ap_rputs("
    \n", r); - if (link[strlen(link)-1] == '/') { - link[strlen(link)-1] = 0; - } - - mbox_mime_display_static_structure(r, m->sub[i], - apr_psprintf(r->pool, "%s/%d", link, i+1)); - ap_rputs("
\n", r); + if (link[strlen(link) - 1] == '/') { + link[strlen(link) - 1] = 0; + } + + mbox_mime_display_static_structure(r, m->sub[i], + apr_psprintf(r->pool, "%s/%d", + link, i + 1)); + ap_rputs("\n", r); } } /* Display an XML MIME structure */ void mbox_mime_display_xml_structure(request_rec *r, mbox_mime_message_t *m, - char *link) + char *link) { int i; @@ -415,15 +420,15 @@ if (m->content_name) { ap_rprintf(r, "\n", - m->content_name, m->content_disposition, - mbox_cte_to_char(m->cte), m->body_len, link); + "length=\"%" APR_SIZE_T_FMT "\" link=\"%s\" />\n", + m->content_name, m->content_disposition, + mbox_cte_to_char(m->cte), m->body_len, link); } else { ap_rprintf(r, "\n", - m->content_type, m->content_disposition, - mbox_cte_to_char(m->cte), m->body_len, link); + "length=\"%" APR_SIZE_T_FMT "\" link=\"%s\" />\n", + m->content_type, m->content_disposition, + mbox_cte_to_char(m->cte), m->body_len, link); } if (!m->sub) { @@ -431,13 +436,14 @@ } ap_rputs("\n", r); - for (i=0 ; isub_count ; i++) { - if (link[strlen(link)-1] == '/') { - link[strlen(link)-1] = 0; - } + for (i = 0; i < m->sub_count; i++) { + if (link[strlen(link) - 1] == '/') { + link[strlen(link) - 1] = 0; + } mbox_mime_display_xml_structure(r, m->sub[i], - apr_psprintf(r->pool, "%s/%d", link, i+1)); + apr_psprintf(r->pool, "%s/%d", link, + i + 1)); } ap_rputs("\n", r); }
List information
List information
Writing to the list%s@%s
%s@%s
Subscription address%s-subscribe@%s
Digest subscription address%s-digest-subscribe@%s
%s-subscribe@%s
Digest subscription address%s-digest-subscribe@%s
Unsubscription addresses%s-unsubscribe@%s
%s-unsubscribe@%s
Getting help with the list%s-help@%s
%s-help@%s
Feeds:" + "" "Atom 1.0