You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by ma...@apache.org on 2006/01/06 05:04:58 UTC
svn commit: r366415 - in /httpd/mod_mbox/branches/surgery: ./ src/libmbox/
src/module/
Author: maxime
Date: Thu Jan 5 20:04:49 2006
New Revision: 366415
URL: http://svn.apache.org/viewcvs?rev=366415&view=rev
Log:
More on code refactoring. Created a libmbox public header file.
Added:
httpd/mod_mbox/branches/surgery/src/libmbox/libmbox.h (with props)
Removed:
httpd/mod_mbox/branches/surgery/src/libmbox/mbox_sort.h
httpd/mod_mbox/branches/surgery/src/libmbox/mbox_thread.h
Modified:
httpd/mod_mbox/branches/surgery/Makefile.am
httpd/mod_mbox/branches/surgery/src/libmbox/mbox_cache.c
httpd/mod_mbox/branches/surgery/src/libmbox/mbox_cache.h
httpd/mod_mbox/branches/surgery/src/libmbox/mbox_parse.c
httpd/mod_mbox/branches/surgery/src/libmbox/mbox_parse.h
httpd/mod_mbox/branches/surgery/src/libmbox/mbox_search.h
httpd/mod_mbox/branches/surgery/src/libmbox/mbox_thread.c
httpd/mod_mbox/branches/surgery/src/module/Makefile.am
Modified: httpd/mod_mbox/branches/surgery/Makefile.am
URL: http://svn.apache.org/viewcvs/httpd/mod_mbox/branches/surgery/Makefile.am?rev=366415&r1=366414&r2=366415&view=diff
==============================================================================
--- httpd/mod_mbox/branches/surgery/Makefile.am (original)
+++ httpd/mod_mbox/branches/surgery/Makefile.am Thu Jan 5 20:04:49 2006
@@ -8,4 +8,4 @@
README \
STATUS
-SUBDIRS = src/module src/libmbox
+SUBDIRS = src/module src/libmbox src/libmime src/mod-mbox-util
Added: httpd/mod_mbox/branches/surgery/src/libmbox/libmbox.h
URL: http://svn.apache.org/viewcvs/httpd/mod_mbox/branches/surgery/src/libmbox/libmbox.h?rev=366415&view=auto
==============================================================================
--- httpd/mod_mbox/branches/surgery/src/libmbox/libmbox.h (added)
+++ httpd/mod_mbox/branches/surgery/src/libmbox/libmbox.h Thu Jan 5 20:04:49 2006
@@ -0,0 +1,261 @@
+/* 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.
+ */
+
+#ifndef LIBMBOX_H
+#define LIBMBOX_H
+
+#define CORE_PRIVATE
+#include "httpd.h"
+#include "http_config.h"
+#include "http_core.h"
+#include "http_log.h"
+#include "http_main.h"
+#include "http_protocol.h"
+#include "http_request.h"
+#include "util_script.h"
+
+#include <stdio.h>
+
+#include "apr.h"
+#include "apr_pools.h"
+#include "apr_strings.h"
+#include "apr_date.h"
+#include "apr_buckets.h"
+#include "apr_dbm.h"
+#include "apr_mmap.h"
+
+#ifndef NO_MBOX_SEARCH
+#include "lcn_init.h"
+#include "lcn_document.h"
+#include "lcn_pools.h"
+#include "lcn_index_writer.h"
+#include "lcn_query_parser.h"
+#include "lcn_searcher.h"
+#endif
+
+#define MBOX_SORT_DATE 0
+#define MBOX_SORT_AUTHOR 1
+#define MBOX_SORT_THREAD 2
+#define MBOX_SORT_REVERSE_DATE 3
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * MBOX_LIST is a generic linked list node.
+ * key is the value associated with the node
+ * value is the value associated with the key
+ * next is the next item in the list
+ */
+typedef struct mbox_list_struct MBOX_LIST;
+
+struct mbox_list_struct{
+ MBOX_LIST * next;
+ apr_time_t key;
+ void * value;
+};
+
+/*
+ * All possible Content-Transfer-Encodings.
+ */
+typedef enum {
+ CTE_NONE = 0,
+ CTE_7BIT = 1,
+ CTE_8BIT = 2,
+ CTE_UUENCODE = 3,
+ CTE_BINARY = 4,
+ CTE_QP = 5,
+ CTE_BASE64 = 6,
+} mbox_cte_e;
+
+mbox_cte_e mbox_parse_cte_header(char* src);
+
+/* The following is based on Jamie Zawinski's description of the Netscape 3.x
+ * threading algorithm at <http://www.jwz.org/doc/threading.html>.
+ */
+
+/* As JWZ says, this shouldn't be char*, but something that could be
+ * derived from an MD5 hash. That can come later.
+ */
+typedef char* ID;
+
+/* Typedefs for Message and Container */
+typedef struct Message_Struct Message;
+typedef struct Container_Struct Container;
+
+typedef struct mbox_mime_message
+{
+ char *body;
+ apr_size_t body_len;
+ char *boundary;
+
+ char *content_type;
+ char *content_encoding;
+ char *content_disposition;
+ char *content_name;
+ mbox_cte_e cte;
+
+ struct mbox_mime_message **sub;
+ unsigned int sub_count;
+} mbox_mime_message_t;
+
+/* The basic information about a message. */
+struct Message_Struct
+{
+ ID msgID;
+
+ char *from;
+ char *str_from;
+
+ char *subject;
+
+ apr_time_t date;
+ char *str_date;
+ char *rfc822_date;
+
+ char *content_type;
+ char *boundary;
+ mbox_cte_e cte;
+
+ apr_table_t *references;
+ char *raw_ref;
+
+ apr_off_t msg_start;
+ apr_off_t body_start;
+ apr_off_t body_end;
+
+ char *raw_msg;
+ char *raw_body;
+
+ mbox_mime_message_t *mime_msg;
+};
+
+/* The threading information about a message. */
+struct Container_Struct
+{
+ Message* message;
+ Container* parent; /* Only one parent */
+ Container* child; /* Many children */
+ Container* next; /* Many siblings */
+};
+
+/**
+ * Supported Mailing List Managers
+ *
+ * Changes how directions are given to subscribe.
+ */
+typedef enum mbox_mlist_manager_e {
+ MANAGER_EZMLM = 0,
+} mbox_mlist_manager_e;
+
+typedef struct mbox_cache_info {
+ int version;
+ apr_time_t mtime;
+ mbox_mlist_manager_e type;
+ const char* list;
+ const char* domain;
+ apr_dbm_t* db;
+ apr_pool_t* pool;
+} mbox_cache_info;
+
+typedef struct mbox_search_doc_t {
+ const char* msgid;
+ const char* list;
+ const char* domain;
+ const char* from;
+ const char* subject;
+ char date[APR_RFC822_DATE_LEN+1];
+ float score;
+} mbox_search_doc_t;
+
+typedef struct mbox_search_query_t {
+ const char* msgid;
+ const char* list;
+ const char* domain;
+ const char* from;
+ const char* subject;
+ const char* terms;
+} mbox_search_query_t;
+
+typedef struct mbox_searcher_t {
+ void* reader;
+} mbox_searcher_t;
+
+typedef struct mbox_indexer_t {
+#ifndef NO_MBOX_SEARCH
+ apr_pool_t* pool;
+ apr_pool_t* tpool;
+ lcn_analyzer_t *analyzer;
+ lcn_index_writer_t* writer;
+ lcn_searcher_t* searcher;
+ const char* path;
+#endif
+} mbox_indexer_t;
+
+/** mbox_thread **/
+Container* calculate_threads(apr_pool_t *p, MBOX_LIST *l);
+
+/** mbox_cache **/
+APR_DECLARE(apr_status_t)
+mbox_cache_get(mbox_cache_info** mli,
+ const char* path, apr_pool_t* p);
+
+APR_DECLARE(apr_status_t)
+mbox_cache_get_count(mbox_cache_info* mli, int *count, char* path);
+
+/** mbox_sort **/
+void *mbox_sort_linked_list(void *p, unsigned index,
+ int (*compare)(void *, void *, void *), void *pointer,
+ unsigned long *pcount);
+
+/** mbox_parse **/
+/* Sorts a list of MBOX_LIST items by the specified order. */
+MBOX_LIST* mbox_sort_list(MBOX_LIST* l, int sortFlags);
+
+/* Generates the DBM file. */
+apr_status_t mbox_generate_index(request_rec *r, apr_file_t * f,
+ mbox_indexer_t *indexer, const char* list,
+ const char* domain);
+
+/* Returns a list of Messages */
+MBOX_LIST* mbox_load_index(request_rec *r, apr_file_t *f, int *count);
+
+/* Returns a single message based on message ID */
+Message* mbox_fetch_index(request_rec *r, apr_file_t * f, const char * msgID);
+
+/* Get the total message count for a file. */
+int mbox_msg_count(request_rec *r, char* path);
+char* mbox_get_list_post(request_rec *r, char* path);
+
+/** mbox_search **/
+typedef int (query_callback_fn_t)(void* baton, int position,
+ mbox_search_doc_t* rdoc);
+
+apr_status_t mbox_search_init(mbox_searcher_t** ctx_, const char* path,
+ apr_pool_t* pool);
+
+apr_status_t mbox_search_query_do(mbox_searcher_t* ctx,
+ mbox_search_query_t* qt,
+ query_callback_fn_t* cb, void* baton);
+
+apr_status_t mbox_search_close(mbox_searcher_t* ctx);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* LIBMBOX_H */
Propchange: httpd/mod_mbox/branches/surgery/src/libmbox/libmbox.h
------------------------------------------------------------------------------
svn:eol-style = native
Modified: httpd/mod_mbox/branches/surgery/src/libmbox/mbox_cache.c
URL: http://svn.apache.org/viewcvs/httpd/mod_mbox/branches/surgery/src/libmbox/mbox_cache.c?rev=366415&r1=366414&r2=366415&view=diff
==============================================================================
--- httpd/mod_mbox/branches/surgery/src/libmbox/mbox_cache.c (original)
+++ httpd/mod_mbox/branches/surgery/src/libmbox/mbox_cache.c Thu Jan 5 20:04:49 2006
@@ -18,6 +18,8 @@
* This provides for caching all of the basic information about a mailing list.
* This includes the list name, the domain, and the message count for each month.
*/
+
+#include "libmbox.h"
#include "mbox_cache.h"
#define LIST_DB_NAME "listinfo.db"
Modified: httpd/mod_mbox/branches/surgery/src/libmbox/mbox_cache.h
URL: http://svn.apache.org/viewcvs/httpd/mod_mbox/branches/surgery/src/libmbox/mbox_cache.h?rev=366415&r1=366414&r2=366415&view=diff
==============================================================================
--- httpd/mod_mbox/branches/surgery/src/libmbox/mbox_cache.h (original)
+++ httpd/mod_mbox/branches/surgery/src/libmbox/mbox_cache.h Thu Jan 5 20:04:49 2006
@@ -17,48 +17,10 @@
#ifndef MBOX_CACHE_H
#define MBOX_CACHE_H
-/*
- * Data structures and header files needed for mbox_cache.c
- */
-
-#define CORE_PRIVATE
-#include "httpd.h"
-#include "http_config.h"
-#include "http_core.h"
-#include "http_log.h"
-#include "http_main.h"
-#include "http_protocol.h"
-#include "http_request.h"
-#include "util_script.h"
-
-#include "apr.h"
-#include "apr_pools.h"
-#include "apr_strings.h"
-#include "apr_dbm.h"
-
-#include <stdio.h>
+#include "libmbox.h"
#define MBOX_CACHE_VERSION 0x2
-/**
- * Supported Mailing List Managers
- *
- * Changes how directions are given to subscribe.
- */
-typedef enum mbox_mlist_manager_e {
- MANAGER_EZMLM = 0,
-} mbox_mlist_manager_e;
-
-typedef struct mbox_cache_info {
- int version;
- apr_time_t mtime;
- mbox_mlist_manager_e type;
- const char* list;
- const char* domain;
- apr_dbm_t* db;
- apr_pool_t* pool;
-} mbox_cache_info;
-
APR_DECLARE(void)
mbox_cache_close(mbox_cache_info* mli);
@@ -66,13 +28,6 @@
mbox_cache_update(mbox_cache_info** mli,
const char* path, apr_pool_t* p,
char* list, char* domain);
-
-APR_DECLARE(apr_status_t)
-mbox_cache_get(mbox_cache_info** mli,
- const char* path, apr_pool_t* p);
-
-APR_DECLARE(apr_status_t)
-mbox_cache_get_count(mbox_cache_info* mli, int *count, char* path);
APR_DECLARE(apr_status_t)
mbox_cache_set_count(mbox_cache_info* mli, int count, char* path);
Modified: httpd/mod_mbox/branches/surgery/src/libmbox/mbox_parse.c
URL: http://svn.apache.org/viewcvs/httpd/mod_mbox/branches/surgery/src/libmbox/mbox_parse.c?rev=366415&r1=366414&r2=366415&view=diff
==============================================================================
--- httpd/mod_mbox/branches/surgery/src/libmbox/mbox_parse.c (original)
+++ httpd/mod_mbox/branches/surgery/src/libmbox/mbox_parse.c Thu Jan 5 20:04:49 2006
@@ -32,7 +32,6 @@
*/
#include "mbox_parse.h"
-#include "mbox_sort.h"
#include "mbox_search.h"
/* FIXME: Remove this when apr_date_parse_rfc() and ap_strcasestr() are fixed ! */
Modified: httpd/mod_mbox/branches/surgery/src/libmbox/mbox_parse.h
URL: http://svn.apache.org/viewcvs/httpd/mod_mbox/branches/surgery/src/libmbox/mbox_parse.h?rev=366415&r1=366414&r2=366415&view=diff
==============================================================================
--- httpd/mod_mbox/branches/surgery/src/libmbox/mbox_parse.h (original)
+++ httpd/mod_mbox/branches/surgery/src/libmbox/mbox_parse.h Thu Jan 5 20:04:49 2006
@@ -17,31 +17,7 @@
#ifndef MBOX_PARSE_H
#define MBOX_PARSE_H
-/*
- * Data structures and header files needed for mbox_parse.c
- */
-
-#define CORE_PRIVATE
-#include "httpd.h"
-#include "http_config.h"
-#include "http_core.h"
-#include "http_log.h"
-#include "http_main.h"
-#include "http_protocol.h"
-#include "http_request.h"
-#include "util_script.h"
-
-#include "apr.h"
-#include "apr_strings.h"
-#include "apr_mmap.h"
-
-#include "mbox_search.h"
-#include <stdio.h>
-
-#define MBOX_SORT_DATE 0
-#define MBOX_SORT_AUTHOR 1
-#define MBOX_SORT_THREAD 2
-#define MBOX_SORT_REVERSE_DATE 3
+#include "libmbox.h"
/*
* MBOX_BUFF emulates the Apache BUFF structure, however it only
@@ -67,141 +43,10 @@
#endif
};
-/*
- * MBOX_LIST is a generic linked list node.
- * key is the value associated with the node
- * value is the value associated with the key
- * next is the next item in the list
- */
-typedef struct mbox_list_struct MBOX_LIST;
-
-struct mbox_list_struct{
- MBOX_LIST * next;
- apr_time_t key;
- void * value;
-};
-
-/*
- * All possible Content-Transfer-Encodings.
- */
-typedef enum {
- CTE_NONE = 0,
- CTE_7BIT = 1,
- CTE_8BIT = 2,
- CTE_UUENCODE = 3,
- CTE_BINARY = 4,
- CTE_QP = 5,
- CTE_BASE64 = 6,
-} mbox_cte_e;
-
-mbox_cte_e mbox_parse_cte_header(char* src);
-
-/* The following is based on Jamie Zawinski's description of the Netscape 3.x
- * threading algorithm at <http://www.jwz.org/doc/threading.html>.
- */
-
-/* As JWZ says, this shouldn't be char*, but something that could be
- * derived from an MD5 hash. That can come later.
- */
-typedef char* ID;
-
-/* Typedefs for Message and Container */
-typedef struct Message_Struct Message;
-typedef struct Container_Struct Container;
-
-typedef struct mbox_mime_message
-{
- char *body;
- apr_size_t body_len;
- char *boundary;
-
- char *content_type;
- char *content_encoding;
- char *content_disposition;
- char *content_name;
- mbox_cte_e cte;
-
- struct mbox_mime_message **sub;
- unsigned int sub_count;
-} mbox_mime_message_t;
-
-/* The basic information about a message. */
-struct Message_Struct
-{
- ID msgID;
-
- char *from;
- char *str_from;
-
- char *subject;
-
- apr_time_t date;
- char *str_date;
- char *rfc822_date;
-
- char *content_type;
- char *boundary;
- mbox_cte_e cte;
-
- apr_table_t *references;
- char *raw_ref;
-
- apr_off_t msg_start;
- apr_off_t body_start;
- apr_off_t body_end;
-
- char *raw_msg;
- char *raw_body;
-
- mbox_mime_message_t *mime_msg;
-};
-
-/* The threading information about a message. */
-struct Container_Struct
-{
- Message* message;
- Container* parent; /* Only one parent */
- Container* child; /* Many children */
- Container* next; /* Many siblings */
-};
-
-/*
- * Fills the MBOX_BUFF with data from the backing store.
- */
+/* Fills the MBOX_BUFF with data from the backing store. */
void mbox_fillbuf(MBOX_BUFF *fb);
-/*
- * Reads a line of protocol input.
- */
+/* Reads a line of protocol input. */
int mbox_getline(char *s, int n, MBOX_BUFF *in, int fold);
-
-/*
- * Sorts a list of MBOX_LIST items by the specified order.
- */
-MBOX_LIST* mbox_sort_list(MBOX_LIST* l, int sortFlags);
-
-/*
- * Generates the DBM file.
- */
-apr_status_t mbox_generate_index(request_rec *r, apr_file_t * f,
- mbox_indexer_t *indexer, const char* list,
- const char* domain);
-
-/*
- * Returns a list of Messages
- */
-MBOX_LIST* mbox_load_index(request_rec *r, apr_file_t *f, int *count);
-
-/*
- * Returns a single message based on message ID
- */
-Message* mbox_fetch_index(request_rec *r, apr_file_t * f, const char * msgID);
-
-/*
- * Get the total message count for a file.
- */
-int mbox_msg_count(request_rec *r, char* path);
-
-char* mbox_get_list_post(request_rec *r, char* path);
#endif
Modified: httpd/mod_mbox/branches/surgery/src/libmbox/mbox_search.h
URL: http://svn.apache.org/viewcvs/httpd/mod_mbox/branches/surgery/src/libmbox/mbox_search.h?rev=366415&r1=366414&r2=366415&view=diff
==============================================================================
--- httpd/mod_mbox/branches/surgery/src/libmbox/mbox_search.h (original)
+++ httpd/mod_mbox/branches/surgery/src/libmbox/mbox_search.h Thu Jan 5 20:04:49 2006
@@ -14,61 +14,15 @@
* limitations under the License.
*/
-#include "apr.h"
-#include "apr_strings.h"
-#include "apr_date.h"
-#include "apr_buckets.h"
-
-#ifndef NO_MBOX_SEARCH
-#include "lcn_init.h"
-#include "lcn_document.h"
-#include "lcn_pools.h"
-#include "lcn_index_writer.h"
-#include "lcn_query_parser.h"
-#include "lcn_searcher.h"
-#endif
-
#ifndef MBOX_SEARCH_H
#define MBOX_SEARCH_H
+#include "libmbox.h"
+
#ifdef __cplusplus
extern "C" {
#endif
-typedef struct mbox_search_doc_t {
- const char* msgid;
- const char* list;
- const char* domain;
- const char* from;
- const char* subject;
- char date[APR_RFC822_DATE_LEN+1];
- float score;
-} mbox_search_doc_t;
-
-typedef struct mbox_search_query_t {
- const char* msgid;
- const char* list;
- const char* domain;
- const char* from;
- const char* subject;
- const char* terms;
-} mbox_search_query_t;
-
-typedef struct mbox_searcher_t {
- void* reader;
-} mbox_searcher_t;
-
-typedef struct mbox_indexer_t {
-#ifndef NO_MBOX_SEARCH
- apr_pool_t* pool;
- apr_pool_t* tpool;
- lcn_analyzer_t *analyzer;
- lcn_index_writer_t* writer;
- lcn_searcher_t* searcher;
- const char* path;
-#endif
-} mbox_indexer_t;
-
apr_status_t mbox_indexer_init(mbox_indexer_t** ctx, const char* path,
apr_pool_t* pool);
@@ -77,19 +31,6 @@
apr_status_t mbox_indexer_close(mbox_indexer_t* ctx);
apr_status_t mbox_indexer_add(mbox_indexer_t* ctx, mbox_search_doc_t* doc);
-
-
-typedef int (query_callback_fn_t)(void* baton, int position,
- mbox_search_doc_t* rdoc);
-
-apr_status_t mbox_search_init(mbox_searcher_t** ctx_, const char* path,
- apr_pool_t* pool);
-
-apr_status_t mbox_search_query_do(mbox_searcher_t* ctx,
- mbox_search_query_t* qt,
- query_callback_fn_t* cb, void* baton);
-
-apr_status_t mbox_search_close(mbox_searcher_t* ctx);
#ifdef __cplusplus
}
Modified: httpd/mod_mbox/branches/surgery/src/libmbox/mbox_thread.c
URL: http://svn.apache.org/viewcvs/httpd/mod_mbox/branches/surgery/src/libmbox/mbox_thread.c?rev=366415&r1=366414&r2=366415&view=diff
==============================================================================
--- httpd/mod_mbox/branches/surgery/src/libmbox/mbox_thread.c (original)
+++ httpd/mod_mbox/branches/surgery/src/libmbox/mbox_thread.c Thu Jan 5 20:04:49 2006
@@ -18,9 +18,9 @@
* algorithm at <http://www.jwz.org/doc/threading.html>.
*/
-#include "mbox_thread.h"
-#include "mbox_sort.h"
#include "apr_lib.h"
+
+#include "libmbox.h"
/*
* Determines if a string is a reply
Modified: httpd/mod_mbox/branches/surgery/src/module/Makefile.am
URL: http://svn.apache.org/viewcvs/httpd/mod_mbox/branches/surgery/src/module/Makefile.am?rev=366415&r1=366414&r2=366415&view=diff
==============================================================================
--- httpd/mod_mbox/branches/surgery/src/module/Makefile.am (original)
+++ httpd/mod_mbox/branches/surgery/src/module/Makefile.am Thu Jan 5 20:04:49 2006
@@ -1,16 +1,17 @@
# mod_mbox
-mod_mbox_la_SOURCES = mod_mbox.c \
- mod_mbox_file.c \
- mod_mbox_out.c \
- mod_mbox_search.c \
- mod_mbox_index.c \
- mod_mbox_cte.c \
- mod_mbox_mime.c
+mod_mbox_la_SOURCES = \
+ mod_mbox.c \
+ mod_mbox_file.c \
+ mod_mbox_out.c \
+ mod_mbox_search.c \
+ mod_mbox_index.c \
+ mod_mbox_cte.c \
+ mod_mbox_mime.c
mod_mbox_la_LIBADD = libmbox.la libmime.la
-mod_mbox_la_CFLAGS = -Wall ${MOD_MBOX_LA_CFLAGS}
-mod_mbox_la_LDFLAGS = -rpath ${AP_LIBEXECDIR} -module -avoid-version ${MOD_MBOX_LA_LDFLAGS}
+mod_mbox_la_CFLAGS = -Wall ${MODULE_CFLAGS}
+mod_mbox_la_LDFLAGS = -rpath ${AP_LIBEXECDIR} -module -avoid-version ${MODULES_LDFLAGS}
pkglib_LTLIBRARIES = mod_mbox.la
pkginclude_HEADERS = mod_mbox.h