/* 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. */ #include "mod_mbox.h" static int query_callback(void* baton, int position, mbox_search_doc_t* rdoc) { request_rec* r = baton; ap_rprintf(r, "# - %d\n" "Message ID: %s\n" "List: %s\n" "Domain: %s\n" "From: %s\n" "Subject: %s\n" "Date: %s\n" "Score: %2f\n\n", position, rdoc->msgid, rdoc->list, rdoc->domain, rdoc->from, rdoc->subject, rdoc->date, rdoc->score); return 0; } static int generate_search_page(request_rec *r, const char* search_path) { mbox_search_query_t qt; mbox_searcher_t* sctx; mbox_search_init(&sctx, search_path, r->pool); qt.msgid = NULL; qt.list = NULL; qt.domain = NULL, qt.from = NULL; qt.terms = NULL; qt.subject = "event"; mbox_search_query_do(sctx, &qt, query_callback, r); return OK; } int mbox_search_handler(request_rec *r) { mbox_dir_cfg_t *conf; if (strcmp(r->handler, "mbox-search")) { return DECLINED; } conf = ap_get_module_config(r->per_dir_config, &mbox_module); if (conf->search_path == NULL) { /* TODO: Log this */ return DECLINED; } return generate_search_page(r, conf->search_path); }