Return-Path: Delivered-To: apmail-httpd-cvs-archive@www.apache.org Received: (qmail 12199 invoked from network); 22 Dec 2006 16:45:24 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 22 Dec 2006 16:45:24 -0000 Received: (qmail 86098 invoked by uid 500); 22 Dec 2006 16:45:31 -0000 Delivered-To: apmail-httpd-cvs-archive@httpd.apache.org Received: (qmail 86050 invoked by uid 500); 22 Dec 2006 16:45:31 -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 86031 invoked by uid 99); 22 Dec 2006 16:45:31 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 22 Dec 2006 08:45:31 -0800 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 22 Dec 2006 08:45:23 -0800 Received: by eris.apache.org (Postfix, from userid 65534) id 310971A981A; Fri, 22 Dec 2006 08:44:33 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r489685 - /httpd/mod_mbox/branches/surgery/mod-mbox-util/mod-mbox-util.c Date: Fri, 22 Dec 2006 16:44:33 -0000 To: cvs@httpd.apache.org From: pquerna@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20061222164433.310971A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: pquerna Date: Fri Dec 22 08:44:32 2006 New Revision: 489685 URL: http://svn.apache.org/viewvc?view=rev&rev=489685 Log: - Merge r424680 from trunk; Adding MsgID output support to mod-mbox-util(-m cli option). Modified: httpd/mod_mbox/branches/surgery/mod-mbox-util/mod-mbox-util.c Modified: httpd/mod_mbox/branches/surgery/mod-mbox-util/mod-mbox-util.c URL: http://svn.apache.org/viewvc/httpd/mod_mbox/branches/surgery/mod-mbox-util/mod-mbox-util.c?view=diff&rev=489685&r1=489684&r2=489685 ============================================================================== --- httpd/mod_mbox/branches/surgery/mod-mbox-util/mod-mbox-util.c (original) +++ httpd/mod_mbox/branches/surgery/mod-mbox-util/mod-mbox-util.c Fri Dec 22 08:44:32 2006 @@ -46,6 +46,7 @@ "%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 @@ -57,10 +58,13 @@ " -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); } @@ -280,6 +284,28 @@ return rv; } +static int load_msgid(request_rec* r) +{ + apr_status_t rv; + apr_file_t *f; + MBOX_LIST *l; + + rv = apr_file_open(&f, r->filename, APR_READ, APR_OS_DEFAULT, r->pool); + if (rv != APR_SUCCESS) + return rv; + + l = mbox_load_index(r, f, NULL); + + while (l) { + Message *m; + m = (Message*)l->value; + printf("%s\n", m->msgID); + l = l->next; + } + + return APR_SUCCESS; +} + int main(int argc, const char* const argv[]) { apr_status_t rv = APR_SUCCESS; request_rec r; @@ -322,7 +348,7 @@ return EXIT_FAILURE; } - while ((rv = apr_getopt(opt, "vc::u::s::", &ch, &optarg)) == APR_SUCCESS) { + while ((rv = apr_getopt(opt, "vc::u::s::m::", &ch, &optarg)) == APR_SUCCESS) { switch (ch) { case 'v': if (verbose) { @@ -350,6 +376,17 @@ update_mode = 1; upath = apr_pstrdup(r.pool, optarg); break; + case 'm': + if (update_mode != -1) { + apr_file_printf(errfile, + "Error: -m can't be used with -u and -c " NL + NL); + usage(); + return EXIT_FAILURE; + } + update_mode = 2; + upath = apr_pstrdup(r.pool, optarg); + break; case 's': index_path = apr_pstrdup(r.pool, optarg); break; @@ -363,7 +400,7 @@ } if (update_mode == -1) { - apr_file_printf(errfile, "Error: -u or -c must be passed" NL NL); + apr_file_printf(errfile, "Error: -u, -c, or -m must be passed" NL NL); usage(); return EXIT_FAILURE; } @@ -374,55 +411,61 @@ return EXIT_FAILURE; } - rv = apr_filepath_merge(&r.filename, NULL, upath, - APR_FILEPATH_TRUENAME, - r.pool); - - if (rv != APR_SUCCESS) { - apr_file_printf(errfile, "Error: Unable to resolve path: %s" NL, - apr_strerror(rv, errbuf, sizeof(errbuf))); - return EXIT_FAILURE; - } - - rv = apr_filepath_set(r.filename, r.pool); + if (update_mode != 2) { + rv = apr_filepath_merge(&r.filename, NULL, upath, + APR_FILEPATH_TRUENAME, r.pool); + if (rv != APR_SUCCESS) { + apr_file_printf(errfile, "Error: Unable to resolve path: %s" NL, + apr_strerror(rv, errbuf, sizeof(errbuf))); + return EXIT_FAILURE; + } - if (rv != APR_SUCCESS) { - apr_file_printf(errfile, "Error: Unable to resolve path: %s" NL, - apr_strerror(rv, errbuf, sizeof(errbuf))); - return EXIT_FAILURE; - } + rv = apr_filepath_set(r.filename, r.pool); - 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_file_printf(errfile, "Error: Unable to resolve path: %s" NL, apr_strerror(rv, errbuf, sizeof(errbuf))); return EXIT_FAILURE; } - } - else { + + 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, "No Search Path Set. " - "Searching will not be available." NL); + apr_file_printf(errfile, "Base Path: %s" NL, r.filename); } - indexer = NULL; - } + if (r.filename[strlen(r.filename) - 1] != '/') { + r.filename = apr_pstrcat(r.pool, r.filename, "/", NULL); + } - if (verbose) { - apr_file_printf(errfile, "Base Path: %s" NL, r.filename); + rv = scan_dir(&r); } + else { + r.filename = (char*)upath; - if (r.filename[strlen(r.filename) - 1] != '/') { - r.filename = apr_pstrcat(r.pool, r.filename, "/", NULL); + rv = load_msgid(&r); } - rv = scan_dir(&r); if (indexer) { mbox_indexer_optimize(indexer); mbox_indexer_close(indexer);