You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by pq...@apache.org on 2006/12/22 17:44:33 UTC
svn commit: r489685 -
/httpd/mod_mbox/branches/surgery/mod-mbox-util/mod-mbox-util.c
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);