/* 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. */ #define CORE_PRIVATE #include "httpd.h" #include "apr_pools.h" #include "apr_general.h" #include "apr_strings.h" #include "apr_hash.h" #include "libmbox.h" void print_container(Container *c, int depth) { int i; for (i = 0; i < depth; i++) printf("-"); if (c->message) printf("From: %s Subject: %s\n", c->message->from, c->message->subject); else printf("Blank\n"); if (c->child) print_container(c->child, depth+1); if (c->next) print_container(c->next, depth); } int main(int argc, char** argv) { request_rec r; server_rec s; apr_file_t *f; apr_status_t status; MBOX_LIST *l; Container *c; int count = 0; if (argc <= 1) { puts("Please give me a filename to generate an index for.\n"); return EXIT_FAILURE; } status = EXIT_SUCCESS; apr_initialize(); atexit(apr_terminate); r.server = &s; s.limit_req_fieldsize = DEFAULT_LIMIT_REQUEST_FIELDSIZE; s.limit_req_fields = DEFAULT_LIMIT_REQUEST_FIELDS; apr_pool_create(&r.pool, NULL); r.filename = apr_pstrdup(r.pool, argv[1]); if ((status = apr_file_open(&f, r.filename, APR_READ, APR_OS_DEFAULT, r.pool)) != APR_SUCCESS) return status; l = mbox_load_index(&r, f, &count); c = calculate_threads(r.pool, l); print_container(c, 0); return EXIT_SUCCESS; }