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 2008/12/27 05:02:35 UTC
svn commit: r729588 [2/2] - /httpd/sandbox/mod_mbox-3/module-2.0/
Modified: httpd/sandbox/mod_mbox-3/module-2.0/mod_mbox_cte.c
URL: http://svn.apache.org/viewvc/httpd/sandbox/mod_mbox-3/module-2.0/mod_mbox_cte.c?rev=729588&r1=729587&r2=729588&view=diff
==============================================================================
--- httpd/sandbox/mod_mbox-3/module-2.0/mod_mbox_cte.c (original)
+++ httpd/sandbox/mod_mbox-3/module-2.0/mod_mbox_cte.c Fri Dec 26 20:02:34 2008
@@ -40,21 +40,21 @@
*/
static char index_64[128] = {
- -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
- -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
- -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,62, -1,-1,-1,63,
- 52,53,54,55, 56,57,58,59, 60,61,-1,-1, -1,-1,-1,-1,
- -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10, 11,12,13,14,
- 15,16,17,18, 19,20,21,22, 23,24,25,-1, -1,-1,-1,-1,
- -1,26,27,28, 29,30,31,32, 33,34,35,36, 37,38,39,40,
- 41,42,43,44, 45,46,47,48, 49,50,51,-1, -1,-1,-1,-1
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
+ 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1,
+ -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
+ 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1,
+ -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
+ 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1
};
#define char64(c) (((c) < 0 || (c) > 127) ? -1 : index_64[(c)])
const char *mbox_cte_to_char(mbox_cte_e cte)
{
- switch(cte) {
+ switch (cte) {
case CTE_NONE:
return "None";
case CTE_7BIT:
@@ -78,7 +78,7 @@
* safe.
*/
apr_size_t mbox_cte_escape_html(apr_pool_t *p, const char *s,
- apr_size_t len, char **body)
+ apr_size_t len, char **body)
{
char *x;
int i, j;
@@ -143,7 +143,8 @@
if (isspace(c1)) {
if (c1 == '\n') {
newline = 1;
- } else {
+ }
+ else {
newline = 0;
}
continue;
@@ -219,7 +220,7 @@
}
/* Decode quoted-printable to raw text. */
-apr_size_t mbox_cte_decode_qp(char* p)
+apr_size_t mbox_cte_decode_qp(char *p)
{
apr_size_t len = 0;
char *src, *dst;
@@ -296,54 +297,54 @@
/* Quoted-Printable decoding : mode 'q' */
if ((*mode == 'q') || (*mode == 'Q')) {
apr_size_t data_len;
- int i;
+ int i;
- /* In QP header encoding, spaces are encoded either in =20 (as
- in all QP encoding) or in underscores '_' (for header
- encoding). The first case will be handle by the QP
- decoding, so we must handle the other one */
- for (i = 0; i < strlen(data); i++) {
- if (data[i] == '_') {
- data[i] = ' ';
- }
- }
+ /* In QP header encoding, spaces are encoded either in =20 (as
+ in all QP encoding) or in underscores '_' (for header
+ encoding). The first case will be handle by the QP
+ decoding, so we must handle the other one */
+ for (i = 0; i < strlen(data); i++) {
+ if (data[i] == '_') {
+ data[i] = ' ';
+ }
+ }
- data_len = mbox_cte_decode_qp(data);
- data[data_len] = 0;
+ data_len = mbox_cte_decode_qp(data);
+ data[data_len] = 0;
}
else if ((*mode == 'b') || (*mode == 'B')) {
apr_size_t data_len;
- data_len = mbox_cte_decode_b64(data);
- data[data_len] = 0;
+ data_len = mbox_cte_decode_b64(data);
+ data[data_len] = 0;
}
/* Convert charset to uppercase */
- for (i=0; i<strlen(charset); i++) {
+ for (i = 0; i < strlen(charset); i++) {
charset[i] = toupper(charset[i]);
}
/* Charset conversion */
if (apr_xlate_open(&xlate, "UTF-8", charset, p) == APR_SUCCESS) {
apr_size_t inbytes_left, outbytes_left;
- apr_size_t outbuf_len = strlen(data);
+ apr_size_t outbuf_len = strlen(data);
- char *new_data;
+ char *new_data;
- /* Allocate some memory for our resulting data, and initialize
- counters. */
- new_data = apr_palloc(p, outbuf_len);
- inbytes_left = strlen(data);
- outbytes_left = strlen(data);
+ /* Allocate some memory for our resulting data, and initialize
+ counters. */
+ new_data = apr_palloc(p, outbuf_len);
+ inbytes_left = strlen(data);
+ outbytes_left = strlen(data);
- /* Convert */
- // apr_xlate_conv_buffer(xlate, data, &inbytes_left,
- // new_data, &outbytes_left);
+ /* Convert */
+ // apr_xlate_conv_buffer(xlate, data, &inbytes_left,
+ // new_data, &outbytes_left);
- // new_data[outbuf_len - outbytes_left] = 0;
- // data = new_data;
+ // new_data[outbuf_len - outbytes_left] = 0;
+ // data = new_data;
- apr_xlate_close(xlate);
+ apr_xlate_close(xlate);
}
return data;
@@ -358,27 +359,27 @@
do {
char c;
- start = strstr(src, "=?");
- if (!start) {
- result = apr_psprintf(p, "%s%s", result, src);
- return result;
- }
+ start = strstr(src, "=?");
+ if (!start) {
+ result = apr_psprintf(p, "%s%s", result, src);
+ return result;
+ }
- end = strstr(start, "?=");
- if (!end) {
+ end = strstr(start, "?=");
+ if (!end) {
result = apr_psprintf(p, "%s%s", result, src);
- return result;
- }
+ return result;
+ }
- c = *start;
- *start = 0;
- result = apr_psprintf(p, "%s%s", result, src);
- *start = c;
+ c = *start;
+ *start = 0;
+ result = apr_psprintf(p, "%s%s", result, src);
+ *start = c;
- part = mbox_cte_decode_rfc2047(p, start);
- result = apr_psprintf(p, "%s%s", result, part);
+ part = mbox_cte_decode_rfc2047(p, start);
+ result = apr_psprintf(p, "%s%s", result, part);
- src = end + 2;
+ src = end + 2;
} while (src && *src);
return result;
Modified: httpd/sandbox/mod_mbox-3/module-2.0/mod_mbox_file.c
URL: http://svn.apache.org/viewvc/httpd/sandbox/mod_mbox-3/module-2.0/mod_mbox_file.c?rev=729588&r1=729587&r2=729588&view=diff
==============================================================================
--- httpd/sandbox/mod_mbox-3/module-2.0/mod_mbox_file.c (original)
+++ httpd/sandbox/mod_mbox-3/module-2.0/mod_mbox_file.c Fri Dec 26 20:02:34 2008
@@ -42,12 +42,12 @@
values */
if (!len) {
m->raw_msg = NULL;
- m->raw_body = NULL;
+ m->raw_body = NULL;
- return m;
+ return m;
}
- m->raw_msg = apr_palloc(r->pool, len+1);
+ m->raw_msg = apr_palloc(r->pool, len + 1);
if (apr_file_read(f, m->raw_msg, &len) != APR_SUCCESS) {
return NULL;
@@ -70,7 +70,7 @@
}
len = m->body_end - m->msg_start;
- m->raw_msg = apr_palloc(p, len+1);
+ m->raw_msg = apr_palloc(p, len + 1);
if (apr_file_read(f, m->raw_msg, &len) != APR_SUCCESS) {
return;
@@ -97,7 +97,8 @@
return next;
}
-static Container *find_prev_thread(request_rec *r, char *msgID, Container *c)
+static Container *find_prev_thread(request_rec *r, char *msgID,
+ Container *c)
{
Container *next = NULL;
@@ -110,8 +111,7 @@
find_prev_thread(r, msgID, c->child));
}
- if (!next && c->next)
- {
+ if (!next && c->next) {
/* Root set potentially does not have message */
if (c->next->message && strcmp(msgID, c->next->message->msgID) == 0) {
if (c->message) {
@@ -141,7 +141,8 @@
return next;
}
-static Container *find_next_thread(request_rec *r, char *msgID, Container *c)
+static Container *find_next_thread(request_rec *r, char *msgID,
+ Container *c)
{
c = find_thread(r, msgID, c);
@@ -190,9 +191,9 @@
MBOX_LIST *head, *prev = NULL;
Container *threads, *c;
- char **context = apr_palloc(r->pool, 4*sizeof(char *));
+ char **context = apr_palloc(r->pool, 4 * sizeof(char *));
- memset(context, 0, 4*sizeof(char *));
+ memset(context, 0, 4 * sizeof(char *));
head = mbox_load_index(r, f, NULL);
@@ -201,31 +202,31 @@
/* First, set the MBOX_PREV and MBOX_NEXT IDs */
head = mbox_sort_list(head, MBOX_SORT_DATE);
- while (head && strcmp(msgID, ((Message*)(head->value))->msgID) != 0) {
- prev = head;
- head = head->next;
+ while (head && strcmp(msgID, ((Message *) (head->value))->msgID) != 0) {
+ prev = head;
+ head = head->next;
}
if (prev) {
- context[0] = ((Message*)(prev->value))->msgID;
+ context[0] = ((Message *) (prev->value))->msgID;
}
if (head && head->next) {
- context[1] = ((Message*)(head->next->value))->msgID;
+ context[1] = ((Message *) (head->next->value))->msgID;
}
/* And the MBOX_PREV_THREAD and MBOX_NEXT_THREAD ones */
if (threads) {
c = find_prev_thread(r, msgID, threads);
- if (c && c->message) {
- context[2] = c->message->msgID;
- }
-
- c = find_next_thread(r, msgID, threads);
- if (c && c->message) {
- context[3] = c->message->msgID;
- }
+ if (c && c->message) {
+ context[2] = c->message->msgID;
+ }
+
+ c = find_next_thread(r, msgID, threads);
+ if (c && c->message) {
+ context[3] = c->message->msgID;
+ }
}
return context;
@@ -248,8 +249,8 @@
r->handler != MBOX_MAGIC_TYPE or
r->handler != MBOX_HANDLER */
if (!r->handler ||
- (strcmp(r->handler,MBOX_MAGIC_TYPE) &&
- strcmp(r->handler,MBOX_HANDLER))) {
+ (strcmp(r->handler, MBOX_MAGIC_TYPE) &&
+ strcmp(r->handler, MBOX_HANDLER))) {
return DECLINED;
}
@@ -278,52 +279,52 @@
/* Open the file */
if ((status = apr_file_open(&f, r->filename, APR_READ,
- APR_OS_DEFAULT, r->pool)) != APR_SUCCESS) {
+ APR_OS_DEFAULT, r->pool)) != APR_SUCCESS) {
ap_log_rerror(APLOG_MARK, APLOG_ERR, status, r,
- "file permissions deny server access: %s", r->filename);
+ "file permissions deny server access: %s", r->filename);
return HTTP_FORBIDDEN;
}
/* AJAX requests return XML */
if (strncmp(r->path_info, "/ajax", 5) == 0) {
- /* Set content type */
+ /* Set content type */
ap_set_content_type(r, "application/xml");
- if (r->header_only) {
- return OK;
+ if (r->header_only) {
+ return OK;
}
- if (strcmp(r->path_info, "/ajax/boxlist") == 0)
- status = mbox_xml_boxlist(r);
+ if (strcmp(r->path_info, "/ajax/boxlist") == 0)
+ status = mbox_xml_boxlist(r);
- else if (strcmp(r->path_info, "/ajax/thread") == 0)
- status = mbox_xml_msglist(r, f, MBOX_SORT_THREAD);
- else if (strcmp(r->path_info, "/ajax/author") == 0)
- status = mbox_xml_msglist(r, f, MBOX_SORT_AUTHOR);
- else if (strcmp(r->path_info, "/ajax/date") == 0)
- status = mbox_xml_msglist(r, f, MBOX_SORT_DATE);
- else
- status = mbox_xml_message(r, f);
+ else if (strcmp(r->path_info, "/ajax/thread") == 0)
+ status = mbox_xml_msglist(r, f, MBOX_SORT_THREAD);
+ else if (strcmp(r->path_info, "/ajax/author") == 0)
+ status = mbox_xml_msglist(r, f, MBOX_SORT_AUTHOR);
+ else if (strcmp(r->path_info, "/ajax/date") == 0)
+ status = mbox_xml_msglist(r, f, MBOX_SORT_DATE);
+ else
+ status = mbox_xml_message(r, f);
}
else if (strncmp(r->path_info, "/raw", 4) == 0) {
status = mbox_raw_message(r, f);
}
else {
- /* Set content type */
+ /* Set content type */
ap_set_content_type(r, "text/html");
- if (r->header_only) {
- return OK;
+ if (r->header_only) {
+ return OK;
}
- if (strcmp(r->path_info, "/browser") == 0)
- status = mbox_ajax_browser(r);
+ if (strcmp(r->path_info, "/browser") == 0)
+ status = mbox_ajax_browser(r);
else if (strcmp(r->path_info, "/thread") == 0)
status = mbox_static_msglist(r, f, MBOX_SORT_THREAD);
- else if (strcmp(r->path_info, "/author") == 0)
+ else if (strcmp(r->path_info, "/author") == 0)
status = mbox_static_msglist(r, f, MBOX_SORT_AUTHOR);
- else if (strcmp(r->path_info, "/date") == 0)
+ else if (strcmp(r->path_info, "/date") == 0)
status = mbox_static_msglist(r, f, MBOX_SORT_DATE);
else
Modified: httpd/sandbox/mod_mbox-3/module-2.0/mod_mbox_index.c
URL: http://svn.apache.org/viewvc/httpd/sandbox/mod_mbox-3/module-2.0/mod_mbox_index.c?rev=729588&r1=729587&r2=729588&view=diff
==============================================================================
--- httpd/sandbox/mod_mbox-3/module-2.0/mod_mbox_index.c (original)
+++ httpd/sandbox/mod_mbox-3/module-2.0/mod_mbox_index.c Fri Dec 26 20:02:34 2008
@@ -29,18 +29,18 @@
*/
static int filename_rsort(const void *fn1, const void *fn2)
{
- mbox_file_t *f1 = (mbox_file_t *)fn1;
- mbox_file_t *f2 = (mbox_file_t *)fn2;
+ mbox_file_t *f1 = (mbox_file_t *) fn1;
+ mbox_file_t *f2 = (mbox_file_t *) fn2;
- return strcmp(f2->filename, f1->filename);
+ return strcmp(f2->filename, f1->filename);
}
/* Fetches the .mbox files from the directory and return a chained
* list of mbox_files_t containing all the information we need to
* output a complete box listing.
*/
-apr_array_header_t *mbox_fetch_boxes_list(request_rec *r, mbox_cache_info *mli,
- char *path)
+apr_array_header_t *mbox_fetch_boxes_list(request_rec *r,
+ mbox_cache_info *mli, char *path)
{
apr_status_t rv = APR_SUCCESS;
apr_finfo_t finfo;
@@ -54,8 +54,8 @@
permissions are stopping us. */
if (rv != APR_SUCCESS) {
ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
- "mod_mbox(fetch_boxes_list): Failed to open directory '%s' for index",
- path);
+ "mod_mbox(fetch_boxes_list): Failed to open directory '%s' for index",
+ path);
return NULL;
}
@@ -71,10 +71,10 @@
while (apr_dir_read(&finfo, APR_FINFO_NAME, dir) == APR_SUCCESS) {
if ((apr_fnmatch("*.mbox", finfo.name, 0) == APR_SUCCESS) &&
(strstr(finfo.name, "incomplete") == NULL)) {
- fi = (mbox_file_t*)apr_array_push(files);
+ fi = (mbox_file_t *) apr_array_push(files);
fi->filename = apr_pstrdup(r->pool, finfo.name);
- mbox_cache_get_count(mli, &(fi->count), (char *)finfo.name);
- }
+ mbox_cache_get_count(mli, &(fi->count), (char *) finfo.name);
+ }
}
apr_dir_close(dir);
@@ -84,20 +84,21 @@
}
/* Sort by reverse filename order */
- qsort((void *)files->elts, files->nelts, sizeof(mbox_file_t), filename_rsort);
+ qsort((void *) files->elts, files->nelts, sizeof(mbox_file_t),
+ filename_rsort);
return files;
}
-int mbox_atom_handler(request_rec *r, mbox_cache_info *mli)
+int mbox_atom_handler(request_rec *r, mbox_cache_info *mli)
{
int errstatus;
char dstr[100];
apr_size_t dlen;
char *etag;
apr_time_exp_t extime;
-
+
/* Only allow GETs */
r->allowed |= (AP_METHOD_BIT << M_GET);
if (r->method_number != M_GET) {
@@ -124,16 +125,17 @@
ap_rputs("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n", r);
ap_rputs("<feed xmlns=\"http://www.w3.org/2005/Atom\">\n", r);
ap_rprintf(r, "<title>%s@%s Archives</title>\n",
- ESCAPE_OR_BLANK(r->pool, mli->list),
- ESCAPE_OR_BLANK(r->pool, mli->domain));
- ap_rprintf(r, "<link rel=\"self\" href=\"%s?format=atom\"/>\n", ap_construct_url(r->pool, r->uri, r));
- ap_rprintf(r, "<link href=\"%s\"/>\n", ap_construct_url(r->pool, r->uri, r));
- ap_rprintf(r, "<id>%s</id>\n", ap_construct_url(r->pool, r->uri, r));
+ ESCAPE_OR_BLANK(r->pool, mli->list),
+ ESCAPE_OR_BLANK(r->pool, mli->domain));
+ ap_rprintf(r, "<link rel=\"self\" href=\"%s?format=atom\"/>\n",
+ ap_construct_url(r->pool, r->uri, r));
+ ap_rprintf(r, "<link href=\"%s\"/>\n",
+ ap_construct_url(r->pool, r->uri, r));
+ ap_rprintf(r, "<id>%s</id>\n", ap_construct_url(r->pool, r->uri, r));
apr_time_exp_gmt(&extime, mli->mtime);
-
- apr_strftime(dstr, &dlen, sizeof(dstr),
- "%G-%m-%dT%H:%M:%SZ", &extime);
+
+ apr_strftime(dstr, &dlen, sizeof(dstr), "%G-%m-%dT%H:%M:%SZ", &extime);
ap_rprintf(r, "<updated>%s</updated>\n", dstr);
mbox_atom_entries(r, mli);
@@ -165,8 +167,8 @@
rv = mbox_cache_get(&mli, r->filename, r->pool);
if (rv != APR_SUCCESS) {
ap_log_rerror(APLOG_MARK, APLOG_DEBUG, rv, r,
- "mod_mbox: Can't open directory cache '%s' for index",
- r->filename);
+ "mod_mbox: Can't open directory cache '%s' for index",
+ r->filename);
return DECLINED;
}
@@ -198,12 +200,15 @@
}
ap_rputs("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n", r);
- ap_rputs("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n", r);
+ ap_rputs("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n",
+ r);
ap_rputs("\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n\n", r);
ap_rputs("<html xmlns=\"http://www.w3.org/1999/xhtml\">\n", r);
ap_rputs(" <head>\n", r);
- ap_rputs(" <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n", r);
+ ap_rputs
+ (" <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n",
+ r);
if (mli->list && mli->domain) {
ap_rprintf(r, " <title>%s@%s Archives</title>\n",
ESCAPE_OR_BLANK(r->pool, mli->list),
@@ -214,66 +219,72 @@
}
ap_rprintf(r, "<link rel=\"alternate\" title=\"%s@%s Archives\" "
- "type=\"application/atom+xml\" href=\"%s?format=atom\" />",
- ESCAPE_OR_BLANK(r->pool, mli->list),
- ESCAPE_OR_BLANK(r->pool, mli->domain),
- ap_construct_url(r->pool, r->uri, r));
+ "type=\"application/atom+xml\" href=\"%s?format=atom\" />",
+ ESCAPE_OR_BLANK(r->pool, mli->list),
+ ESCAPE_OR_BLANK(r->pool, mli->domain),
+ ap_construct_url(r->pool, r->uri, r));
if (conf->style_path) {
- ap_rprintf(r, " <link rel=\"stylesheet\" type=\"text/css\" href=\"%s\" />\n",
- conf->style_path);
+ ap_rprintf(r,
+ " <link rel=\"stylesheet\" type=\"text/css\" href=\"%s\" />\n",
+ conf->style_path);
}
if (conf->script_path) {
- ap_rprintf(r, " <script type=\"text/javascript\" src=\"%s\"></script>\n",
- conf->script_path);
+ ap_rprintf(r,
+ " <script type=\"text/javascript\" src=\"%s\"></script>\n",
+ conf->script_path);
}
ap_rputs(" </head>\n\n", r);
ap_rputs(" <body id=\"archives\" onload=\"indexLinks ();\">\n", r);
ap_rprintf(r, " <h1>Mailing list archives: %s@%s</h1>\n",
- ESCAPE_OR_BLANK(r->pool, mli->list),
- ESCAPE_OR_BLANK(r->pool, mli->domain));
+ ESCAPE_OR_BLANK(r->pool, mli->list),
+ ESCAPE_OR_BLANK(r->pool, mli->domain));
if (conf->root_path) {
- ap_rprintf(r, " <h5><a href=\"%s\" title=\"Back to the archives depot\">"
- "Site index</a></h5>\n\n",
- conf->root_path);
+ ap_rprintf(r,
+ " <h5><a href=\"%s\" title=\"Back to the archives depot\">"
+ "Site index</a></h5>\n\n", conf->root_path);
}
/* Output header and list information */
ap_rputs(" <table id=\"listinfo\">\n", r);
- ap_rputs(" <thead><tr><th colspan=\"2\">List information</th></tr></thead>\n", r);
+ ap_rputs
+ (" <thead><tr><th colspan=\"2\">List information</th></tr></thead>\n",
+ r);
ap_rputs(" <tbody>\n", r);
ap_rprintf(r, " <tr><td class=\"left\">Writing to the list</td>"
- "<td class=\"right\">%s@%s</td></tr>\n",
- ESCAPE_OR_BLANK(r->pool, mli->list),
- ESCAPE_OR_BLANK(r->pool, mli->domain));
+ "<td class=\"right\">%s@%s</td></tr>\n",
+ ESCAPE_OR_BLANK(r->pool, mli->list),
+ ESCAPE_OR_BLANK(r->pool, mli->domain));
ap_rprintf(r, " <tr><td class=\"left\">Subscription address</td>"
- "<td class=\"right\">%s-subscribe@%s</td></tr>\n",
- ESCAPE_OR_BLANK(r->pool, mli->list),
- ESCAPE_OR_BLANK(r->pool, mli->domain));
-
- ap_rprintf(r, " <tr><td class=\"left\">Digest subscription address</td>"
- "<td class=\"right\">%s-digest-subscribe@%s</td></tr>\n",
- ESCAPE_OR_BLANK(r->pool, mli->list),
- ESCAPE_OR_BLANK(r->pool, mli->domain));
+ "<td class=\"right\">%s-subscribe@%s</td></tr>\n",
+ ESCAPE_OR_BLANK(r->pool, mli->list),
+ ESCAPE_OR_BLANK(r->pool, mli->domain));
+
+ ap_rprintf(r,
+ " <tr><td class=\"left\">Digest subscription address</td>"
+ "<td class=\"right\">%s-digest-subscribe@%s</td></tr>\n",
+ ESCAPE_OR_BLANK(r->pool, mli->list), ESCAPE_OR_BLANK(r->pool,
+ mli->
+ domain));
ap_rprintf(r, " <tr><td class=\"left\">Unsubscription addresses</td>"
- "<td class=\"right\">%s-unsubscribe@%s</td></tr>\n",
- ESCAPE_OR_BLANK(r->pool, mli->list),
- ESCAPE_OR_BLANK(r->pool, mli->domain));
+ "<td class=\"right\">%s-unsubscribe@%s</td></tr>\n",
+ ESCAPE_OR_BLANK(r->pool, mli->list),
+ ESCAPE_OR_BLANK(r->pool, mli->domain));
ap_rprintf(r, " <tr><td class=\"left\">Getting help with the list</td>"
- "<td class=\"right\">%s-help@%s</td></tr>\n",
- ESCAPE_OR_BLANK(r->pool, mli->list),
- ESCAPE_OR_BLANK(r->pool, mli->domain));
+ "<td class=\"right\">%s-help@%s</td></tr>\n",
+ ESCAPE_OR_BLANK(r->pool, mli->list),
+ ESCAPE_OR_BLANK(r->pool, mli->domain));
ap_rputs("<tr><td class=\"left\">Feeds:</td>"
- "<td class=\"right\">"
+ "<td class=\"right\">"
"<a href=\"?format=atom\">Atom 1.0</a></td></tr>\n", r);
ap_rputs(" </tbody>\n", r);
Modified: httpd/sandbox/mod_mbox-3/module-2.0/mod_mbox_mime.c
URL: http://svn.apache.org/viewvc/httpd/sandbox/mod_mbox-3/module-2.0/mod_mbox_mime.c?rev=729588&r1=729587&r2=729588&view=diff
==============================================================================
--- httpd/sandbox/mod_mbox-3/module-2.0/mod_mbox_mime.c (original)
+++ httpd/sandbox/mod_mbox-3/module-2.0/mod_mbox_mime.c Fri Dec 26 20:02:34 2008
@@ -23,8 +23,8 @@
* levels of MIME parts, this function is recursive.
*/
mbox_mime_message_t *mbox_mime_decode_multipart(apr_pool_t *p, char *body,
- char *ct, mbox_cte_e cte,
- char *boundary)
+ char *ct, mbox_cte_e cte,
+ char *boundary)
{
mbox_mime_message_t *mail;
char *tmp = NULL, *k = NULL, *end_bound = NULL;
@@ -38,7 +38,7 @@
if (!ct) {
headers_bound = ap_strstr(body, "\n\n");
if (!headers_bound) {
- return NULL;
+ return NULL;
}
}
else {
@@ -58,55 +58,56 @@
/* If no Content-Type is given, we have to look for it. */
if (!ct) {
- tmp += sizeof("Content-Type: ") - 1;
- k = strchr(tmp, ';');
+ tmp += sizeof("Content-Type: ") - 1;
+ k = strchr(tmp, ';');
- /* Isolate the Content-Type string (between 'Content-Type: '
- and ';' or end of line */
- if (k && k < headers_bound) {
- *k = 0;
- }
- else {
- k = tmp;
- while (*k) {
- if (isspace(*k)) {
- *k = 0;
- break;
- }
- *k++;
- }
- }
-
- /* Copy the Content-Type and reset *k */
- mail->content_type = apr_pstrdup(p, tmp);
- *k = ';';
-
- /* If available, get MIME part name */
- tmp = ap_strstr(body, "name=");
- if (tmp && tmp < headers_bound) {
- char c = '\0';
- tmp += sizeof("name=") - 1;
- k = tmp;
+ /* Isolate the Content-Type string (between 'Content-Type: '
+ and ';' or end of line */
+ if (k && k < headers_bound) {
+ *k = 0;
+ }
+ else {
+ k = tmp;
+ while (*k) {
+ if (isspace(*k)) {
+ *k = 0;
+ break;
+ }
+ *k++;
+ }
+ }
- while (*k) {
- if (isspace(*k) || *k == ';') {
+ /* Copy the Content-Type and reset *k */
+ mail->content_type = apr_pstrdup(p, tmp);
+ *k = ';';
+
+ /* If available, get MIME part name */
+ tmp = ap_strstr(body, "name=");
+ if (tmp && tmp < headers_bound) {
+ char c = '\0';
+ tmp += sizeof("name=") - 1;
+ k = tmp;
+
+ while (*k) {
+ if (isspace(*k) || *k == ';') {
c = *k;
- *k = 0;
- break;
- }
- *k++;
- }
-
- /* Check for double quotes */
- if ((*tmp == '"') && (tmp[strlen(tmp)-1] == '"')) {
- mail->content_name = apr_pstrndup(p, tmp+1, strlen(tmp) - 2);
- }
- else {
- mail->content_name = apr_pstrdup(p, tmp);
- }
+ *k = 0;
+ break;
+ }
+ *k++;
+ }
+
+ /* Check for double quotes */
+ if ((*tmp == '"') && (tmp[strlen(tmp) - 1] == '"')) {
+ mail->content_name =
+ apr_pstrndup(p, tmp + 1, strlen(tmp) - 2);
+ }
+ else {
+ mail->content_name = apr_pstrdup(p, tmp);
+ }
- *k = c;
- }
+ *k = c;
+ }
}
else {
mail->content_type = ct;
@@ -118,49 +119,48 @@
tmp = ap_strstr(body, "Content-Disposition: ");
if (tmp && tmp < headers_bound) {
char c = '\0';
- tmp += sizeof("Content-Disposition: ") - 1;
- k = tmp;
+ tmp += sizeof("Content-Disposition: ") - 1;
+ k = tmp;
- while (*k) {
- if (isspace(*k) || *k == ';') {
+ while (*k) {
+ if (isspace(*k) || *k == ';') {
c = *k;
- *k = 0;
- break;
- }
- *k++;
- }
-
- /* Copy the Content-Disposition and reset *k */
- mail->content_disposition = apr_pstrdup(p, tmp);
- *k = c;
+ *k = 0;
+ break;
+ }
+ *k++;
+ }
+
+ /* Copy the Content-Disposition and reset *k */
+ mail->content_disposition = apr_pstrdup(p, tmp);
+ *k = c;
}
else {
mail->content_disposition = apr_pstrdup(p, "inline");
}
/* Check Content-Transfer-Encoding, if needed */
- if (cte == CTE_NONE)
- {
- tmp = ap_strstr(body, "Content-Transfer-Encoding: ");
- if (tmp && tmp < headers_bound) {
- char c = '\0';
- tmp += sizeof("Content-Transfer-Encoding: ") - 1;
- k = tmp;
-
- while (*k) {
- if (isspace(*k) || *k == ';') {
- c = *k;
- *k = 0;
- break;
- }
- *k++;
- }
-
- /* Copy the Content-Disposition and reset *k */
- mail->cte = mbox_parse_cte_header(tmp);
- *k = c;
- }
- }
+ if (cte == CTE_NONE) {
+ tmp = ap_strstr(body, "Content-Transfer-Encoding: ");
+ if (tmp && tmp < headers_bound) {
+ char c = '\0';
+ tmp += sizeof("Content-Transfer-Encoding: ") - 1;
+ k = tmp;
+
+ while (*k) {
+ if (isspace(*k) || *k == ';') {
+ c = *k;
+ *k = 0;
+ break;
+ }
+ *k++;
+ }
+
+ /* Copy the Content-Disposition and reset *k */
+ mail->cte = mbox_parse_cte_header(tmp);
+ *k = c;
+ }
+ }
else {
mail->cte = cte;
}
@@ -183,95 +183,97 @@
/* If the mail is a multipart message, search for the boundary,
and process its sub parts by recursive calls. */
if (strncmp(mail->content_type, "multipart/", strlen("multipart/")) == 0) {
- int end = 0, count = 0;
- char *search, *bound, *boundary_line;
+ int end = 0, count = 0;
+ char *search, *bound, *boundary_line;
+
+ /* If the boundary was not given, we must look for it in the headers */
+ if (!boundary) {
+ tmp = ap_strstr(body, "boundary=\"");
+ if (!tmp) {
+ return NULL;
+ }
+
+ tmp += sizeof("boundary=\"") - 1;
+ k = tmp;
+
+ while (*k) {
+ if (*k == '"') {
+ *k = 0;
+ break;
+ }
+ *k++;
+ }
+
+ mail->boundary = apr_pstrdup(p, tmp);
+ *k = '"';
+ }
- /* If the boundary was not given, we must look for it in the headers */
- if (!boundary) {
- tmp = ap_strstr(body, "boundary=\"");
- if (!tmp) {
- return NULL;
- }
-
- tmp += sizeof("boundary=\"") - 1;
- k = tmp;
-
- while (*k) {
- if (*k == '"') {
- *k = 0;
- break;
- }
- *k++;
- }
-
- mail->boundary = apr_pstrdup(p, tmp);
- *k = '"';
- }
-
- /* Otherwise, the boundary is as given to us */
- else {
- mail->boundary = boundary;
- }
-
- /* Now we have our boundary string. We must : look for it once
- (begining of MIME part) and then look for the end boundary :
- --boundary-- to mark the end of the MIME part.
-
- In order to handle empty boundaries, we'll look for the
- boundary plus the \n. */
-
- boundary_line = apr_pstrcat(p, "--", mail->boundary, NULL);
-
- /* The start boundary */
- bound = ap_strstr(mail->body, boundary_line);
- if (!bound) {
- return NULL;
- }
-
- /* The end boudary */
- end_bound = apr_psprintf(p, "--%s--", mail->boundary);
- tmp = ap_strstr(mail->body, end_bound);
- if (!tmp) {
- return NULL;
- }
- *tmp = 0;
-
- /* Set the search begining to the line after the start boundary. */
- search = bound + strlen(boundary_line) + 1;
-
- /* While the MIME part is not finished, go through all sub parts */
- while (!end) {
- char *inbound;
-
- inbound = ap_strstr(search, boundary_line);
- if (inbound) {
- *inbound = 0;
- }
-
- /* Allocate a new pointer for the sub part, and parse it. */
- mail->sub = realloc(mail->sub, ++count * sizeof(struct mimemsg *));
- mail->sub[count-1] = mbox_mime_decode_multipart(p, search, NULL, CTE_NONE, NULL);
-
- /* If the boudary is found again, it means we have another
- MIME part in the same multipart message. Set the new
- search begining to the line after this new start
- boundary */
- if (inbound) {
- *inbound = '-';
-
- search = inbound + strlen(boundary_line) + 1;
- }
-
- /* Otherwise, the MIME part is finished. */
- else {
- mail->sub_count = count;
- end = 1;
- }
- }
-
- /* Finally reset the end-body pointer. */
- // *tmp = '-';
- }
+ /* Otherwise, the boundary is as given to us */
+ else {
+ mail->boundary = boundary;
+ }
+
+ /* Now we have our boundary string. We must : look for it once
+ (begining of MIME part) and then look for the end boundary :
+ --boundary-- to mark the end of the MIME part.
+
+ In order to handle empty boundaries, we'll look for the
+ boundary plus the \n. */
+
+ boundary_line = apr_pstrcat(p, "--", mail->boundary, NULL);
+
+ /* The start boundary */
+ bound = ap_strstr(mail->body, boundary_line);
+ if (!bound) {
+ return NULL;
+ }
+
+ /* The end boudary */
+ end_bound = apr_psprintf(p, "--%s--", mail->boundary);
+ tmp = ap_strstr(mail->body, end_bound);
+ if (!tmp) {
+ return NULL;
+ }
+ *tmp = 0;
+
+ /* Set the search begining to the line after the start boundary. */
+ search = bound + strlen(boundary_line) + 1;
+
+ /* While the MIME part is not finished, go through all sub parts */
+ while (!end) {
+ char *inbound;
+
+ inbound = ap_strstr(search, boundary_line);
+ if (inbound) {
+ *inbound = 0;
+ }
+
+ /* Allocate a new pointer for the sub part, and parse it. */
+ mail->sub =
+ realloc(mail->sub, ++count * sizeof(struct mimemsg *));
+ mail->sub[count - 1] =
+ mbox_mime_decode_multipart(p, search, NULL, CTE_NONE, NULL);
+
+ /* If the boudary is found again, it means we have another
+ MIME part in the same multipart message. Set the new
+ search begining to the line after this new start
+ boundary */
+ if (inbound) {
+ *inbound = '-';
+
+ search = inbound + strlen(boundary_line) + 1;
+ }
+
+ /* Otherwise, the MIME part is finished. */
+ else {
+ mail->sub_count = count;
+ end = 1;
+ }
+ }
+
+ /* Finally reset the end-body pointer. */
+ // *tmp = '-';
+ }
/* If the parsed body is not multipart or is a MIME part, the body
length is the length of the body string (no surprise here). If
@@ -335,21 +337,23 @@
if (strncasecmp(m->content_type, "text/", strlen("text/")) == 0) {
char *new_body;
- new_body = mbox_mime_decode_body(p, m->cte, m->body, m->body_len, NULL);
- if (!new_body) {
- return MBOX_FETCH_ERROR_STR;
- }
+ new_body =
+ mbox_mime_decode_body(p, m->cte, m->body, m->body_len, NULL);
+ if (!new_body) {
+ return MBOX_FETCH_ERROR_STR;
+ }
- m->body_len = mbox_cte_escape_html(p, new_body, m->body_len, &(m->body));
+ m->body_len =
+ mbox_cte_escape_html(p, new_body, m->body_len, &(m->body));
- return apr_pstrndup(p, m->body, m->body_len);
+ return apr_pstrndup(p, m->body, m->body_len);
}
if (!m->sub) {
return MBOX_FETCH_ERROR_STR;
}
- for (i=0 ; i<m->sub_count ; i++) {
+ for (i = 0; i < m->sub_count; i++) {
return mbox_mime_get_body(p, m->sub[i]);
}
@@ -357,8 +361,8 @@
}
/* Display an XHTML MIME structure */
-void mbox_mime_display_static_structure(request_rec *r, mbox_mime_message_t *m,
- char *link)
+void mbox_mime_display_static_structure(request_rec *r,
+ mbox_mime_message_t *m, char *link)
{
int i;
@@ -383,29 +387,30 @@
ap_rputs("</a>", r);
}
- ap_rprintf(r, " (%s, %s, %"APR_SIZE_T_FMT" bytes)</li>\n", m->content_disposition,
- mbox_cte_to_char(m->cte), m->body_len);
+ ap_rprintf(r, " (%s, %s, %" APR_SIZE_T_FMT " bytes)</li>\n",
+ m->content_disposition, mbox_cte_to_char(m->cte), m->body_len);
if (!m->sub) {
return;
}
- for (i=0 ; i<m->sub_count ; i++) {
+ for (i = 0; i < m->sub_count; i++) {
ap_rputs("<ul>\n", r);
- if (link[strlen(link)-1] == '/') {
- link[strlen(link)-1] = 0;
- }
-
- mbox_mime_display_static_structure(r, m->sub[i],
- apr_psprintf(r->pool, "%s/%d", link, i+1));
- ap_rputs("</ul>\n", r);
+ if (link[strlen(link) - 1] == '/') {
+ link[strlen(link) - 1] = 0;
+ }
+
+ mbox_mime_display_static_structure(r, m->sub[i],
+ apr_psprintf(r->pool, "%s/%d",
+ link, i + 1));
+ ap_rputs("</ul>\n", r);
}
}
/* Display an XML MIME structure */
void mbox_mime_display_xml_structure(request_rec *r, mbox_mime_message_t *m,
- char *link)
+ char *link)
{
int i;
@@ -415,15 +420,15 @@
if (m->content_name) {
ap_rprintf(r, "<part name=\"%s\" cd=\"%s\" cte=\"%s\" "
- "length=\"%"APR_SIZE_T_FMT"\" link=\"%s\" />\n",
- m->content_name, m->content_disposition,
- mbox_cte_to_char(m->cte), m->body_len, link);
+ "length=\"%" APR_SIZE_T_FMT "\" link=\"%s\" />\n",
+ m->content_name, m->content_disposition,
+ mbox_cte_to_char(m->cte), m->body_len, link);
}
else {
ap_rprintf(r, "<part ct=\"%s\" cd=\"%s\" cte=\"%s\" "
- "length=\"%"APR_SIZE_T_FMT"\" link=\"%s\" />\n",
- m->content_type, m->content_disposition,
- mbox_cte_to_char(m->cte), m->body_len, link);
+ "length=\"%" APR_SIZE_T_FMT "\" link=\"%s\" />\n",
+ m->content_type, m->content_disposition,
+ mbox_cte_to_char(m->cte), m->body_len, link);
}
if (!m->sub) {
@@ -431,13 +436,14 @@
}
ap_rputs("<mime>\n", r);
- for (i=0 ; i<m->sub_count ; i++) {
- if (link[strlen(link)-1] == '/') {
- link[strlen(link)-1] = 0;
- }
+ for (i = 0; i < m->sub_count; i++) {
+ if (link[strlen(link) - 1] == '/') {
+ link[strlen(link) - 1] = 0;
+ }
mbox_mime_display_xml_structure(r, m->sub[i],
- apr_psprintf(r->pool, "%s/%d", link, i+1));
+ apr_psprintf(r->pool, "%s/%d", link,
+ i + 1));
}
ap_rputs("</mime>\n", r);
}
Modified: httpd/sandbox/mod_mbox-3/module-2.0/mod_mbox_out.c
URL: http://svn.apache.org/viewvc/httpd/sandbox/mod_mbox-3/module-2.0/mod_mbox_out.c?rev=729588&r1=729587&r2=729588&view=diff
==============================================================================
--- httpd/sandbox/mod_mbox-3/module-2.0/mod_mbox_out.c (original)
+++ httpd/sandbox/mod_mbox-3/module-2.0/mod_mbox_out.c Fri Dec 26 20:02:34 2008
@@ -21,38 +21,38 @@
/* Define local prototypes, even if functions are declared before
they're called (avoid GCC warnings). */
-void display_atom_entry(request_rec *r, Message *m, const char* mboxfile,
+void display_atom_entry(request_rec *r, Message *m, const char *mboxfile,
apr_pool_t *pool, apr_file_t *f);
void mbox_static_message_nav(request_rec *r, char **context,
- char *baseURI, char *msgID);
+ char *baseURI, char *msgID);
char *mbox_months[12][2] = {
- { "Jan", "January" },
- { "Feb", "February" },
- { "Mar", "March" },
- { "Apr", "April" },
- { "May", "May" },
- { "Jun", "June" },
- { "Jul", "July" },
- { "Aug", "August" },
- { "Sep", "September"},
- { "Oct", "October" },
- { "Nov", "November" },
- { "Dec", "December" }
+ {"Jan", "January"},
+ {"Feb", "February"},
+ {"Mar", "March"},
+ {"Apr", "April"},
+ {"May", "May"},
+ {"Jun", "June"},
+ {"Jul", "July"},
+ {"Aug", "August"},
+ {"Sep", "September"},
+ {"Oct", "October"},
+ {"Nov", "November"},
+ {"Dec", "December"}
};
/* Display an ATOM feed entry from given message structure */
-void display_atom_entry(request_rec *r, Message *m, const char* mboxfile,
+void display_atom_entry(request_rec *r, Message *m, const char *mboxfile,
apr_pool_t *pool, apr_file_t *f)
{
char dstr[100];
apr_size_t dlen;
apr_time_exp_t extime;
- char* uid;
- char* c;
+ char *uid;
+ char *c;
ap_rputs("<entry>\n", r);
- ap_rprintf(r, "<title>%s</title>\n", ESCAPE_OR_BLANK(pool, m->subject));
+ ap_rprintf(r, "<title>%s</title>\n", ESCAPE_OR_BLANK(pool, m->subject));
ap_rprintf(r, "<author><name>%s</name></author>\n",
ESCAPE_OR_BLANK(pool, m->from));
@@ -74,45 +74,44 @@
apr_time_exp_gmt(&extime, m->date);
- apr_strftime(dstr, &dlen, sizeof(dstr),
- "%G-%m-%dT%H:%M:%SZ", &extime);
+ apr_strftime(dstr, &dlen, sizeof(dstr), "%G-%m-%dT%H:%M:%SZ", &extime);
ap_rprintf(r, "<updated>%s</updated>\n", dstr);
ap_rputs("<content type=\"xhtml\">\n"
- "<div xmlns=\"http://www.w3.org/1999/xhtml\">\n"
- "<pre>\n", r);
+ "<div xmlns=\"http://www.w3.org/1999/xhtml\">\n" "<pre>\n", r);
load_message(pool, f, m);
/* Parse multipart information */
m->mime_msg = mbox_mime_decode_multipart(pool, m->raw_body,
- m->content_type,
- m->cte, m->boundary);
+ m->content_type,
+ m->cte, m->boundary);
- ap_rprintf(r, "%s", mbox_wrap_text(mbox_mime_get_body(pool, m->mime_msg)));
+ ap_rprintf(r, "%s",
+ mbox_wrap_text(mbox_mime_get_body(pool, m->mime_msg)));
ap_rputs("\n</pre>\n</div>\n</content>\n", r);
ap_rputs("</entry>\n", r);
}
-static int mbox2atom(request_rec *r, const char* mboxfile, mbox_cache_info *mli, int max)
+static int mbox2atom(request_rec *r, const char *mboxfile,
+ mbox_cache_info *mli, int max)
{
apr_status_t rv;
- char* filename;
- char* origfilename;
+ char *filename;
+ char *origfilename;
apr_file_t *f;
MBOX_LIST *head;
Message *m;
int i;
- apr_pool_t* tpool;
+ apr_pool_t *tpool;
apr_pool_create(&tpool, r->pool);
filename = apr_pstrcat(r->pool, r->filename, mboxfile, NULL);
- rv = apr_file_open(&f, filename, APR_READ,
- APR_OS_DEFAULT, r->pool);
+ rv = apr_file_open(&f, filename, APR_READ, APR_OS_DEFAULT, r->pool);
- if(rv != APR_SUCCESS) {
+ if (rv != APR_SUCCESS) {
ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
"mod_mbox(mbox2atom): Can't open mbox '%s' for atom feed",
filename);
@@ -128,7 +127,7 @@
head = mbox_sort_list(head, MBOX_SORT_REVERSE_DATE);
for (i = 0; i < max && head != NULL; i++) {
- m = (Message*)head->value;
+ m = (Message *) head->value;
display_atom_entry(r, m, mboxfile, tpool, f);
head = head->next;
apr_pool_clear(tpool);
@@ -150,12 +149,14 @@
return;
}
- fi = (mbox_file_t *)files->elts;
+ fi = (mbox_file_t *) files->elts;
for (i = 0; i < files->nelts && entries < MBOX_ATOM_NUM_ENTRIES; i++) {
if (!fi[i].count) {
continue;
}
- entries += mbox2atom(r, fi[i].filename, mli, MBOX_ATOM_NUM_ENTRIES - entries);
+ entries +=
+ mbox2atom(r, fi[i].filename, mli,
+ MBOX_ATOM_NUM_ENTRIES - entries);
}
}
@@ -181,15 +182,15 @@
return HTTP_NOT_FOUND;
}
- k = k-6;
+ k = k - 6;
*k = 0;
/* Open mbox cache */
rv = mbox_cache_get(&mli, path, r->pool);
if (rv != APR_SUCCESS) {
ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
- "mod_mbox(xml_boxlist): Can't open directory cache '%s' for index",
- r->filename);
+ "mod_mbox(xml_boxlist): Can't open directory cache '%s' for index",
+ r->filename);
return HTTP_FORBIDDEN;
}
@@ -201,13 +202,13 @@
ap_rputs("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n", r);
ap_rputs("<boxlist>\n", r);
- fi = (mbox_file_t *)files->elts;
+ fi = (mbox_file_t *) files->elts;
for (i = 0; i < files->nelts; i++) {
if (fi[i].count || !conf->hide_empty) {
- ap_rprintf(r, "<mbox id=\"%s\" count=\"%d\" />\n",
+ ap_rprintf(r, "<mbox id=\"%s\" count=\"%d\" />\n",
fi[i].filename, fi[i].count);
- }
+ }
}
ap_rputs("</boxlist>\n", r);
@@ -239,15 +240,15 @@
}
/* Roll back before the '/YYYYMM' part of the filename */
- k = k-7;
+ k = k - 7;
*k = 0;
/* Open mbox cache */
rv = mbox_cache_get(&mli, path, r->pool);
if (rv != APR_SUCCESS) {
ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
- "mod_mbox(static_boxlist): Can't open directory cache '%s' for index",
- path);
+ "mod_mbox(static_boxlist): Can't open directory cache '%s' for index",
+ path);
return HTTP_FORBIDDEN;
}
@@ -257,32 +258,36 @@
}
ap_rputs(" <table id=\"boxlist\">\n", r);
- ap_rputs(" <thead><tr><th colspan=\"2\">Box list</th></tr></thead>\n", r);
+ ap_rputs(" <thead><tr><th colspan=\"2\">Box list</th></tr></thead>\n",
+ r);
ap_rputs(" <tbody>\n", r);
- fi = (mbox_file_t *)files->elts;
+ fi = (mbox_file_t *) files->elts;
- for (i=0 ; i < files->nelts; i++) {
+ for (i = 0; i < files->nelts; i++) {
if (fi[i].count || !conf->hide_empty) {
- if (strcmp(k+1, fi[i].filename) == 0) {
- ap_rputs(" <tr id=\"boxactive\">", r);
- }
- else {
- ap_rputs(" <tr>", r);
- }
-
- ap_rprintf(r, " <td class=\"box\"><a href=\"%s/%s%s\" title=\"Browse %s %.4s archives\">"
- "%s %.4s</a></td><td class=\"msgcount\">%d</td>\n",
- base_path, fi[i].filename, r->path_info,
- mbox_months[atoi(apr_pstrndup(r->pool,
- fi[i].filename+4, 2)) - 1][1],
- fi[i].filename,
- mbox_months[atoi(apr_pstrndup(r->pool,
- fi[i].filename+4, 2)) - 1][0],
- fi[i].filename, fi[i].count);
+ if (strcmp(k + 1, fi[i].filename) == 0) {
+ ap_rputs(" <tr id=\"boxactive\">", r);
+ }
+ else {
+ ap_rputs(" <tr>", r);
+ }
+
+ ap_rprintf(r,
+ " <td class=\"box\"><a href=\"%s/%s%s\" title=\"Browse %s %.4s archives\">"
+ "%s %.4s</a></td><td class=\"msgcount\">%d</td>\n",
+ base_path, fi[i].filename, r->path_info,
+ mbox_months[atoi
+ (apr_pstrndup
+ (r->pool, fi[i].filename + 4, 2)) - 1][1],
+ fi[i].filename,
+ mbox_months[atoi
+ (apr_pstrndup
+ (r->pool, fi[i].filename + 4, 2)) - 1][0],
+ fi[i].filename, fi[i].count);
- ap_rputs(" </tr>\n", r);
- }
+ ap_rputs(" </tr>\n", r);
+ }
}
ap_rputs(" </tbody>\n", r);
@@ -293,7 +298,7 @@
/* Outputs an XHTML list of available mailboxes */
apr_status_t mbox_static_index_boxlist(request_rec *r, mbox_dir_cfg_t *conf,
- mbox_cache_info *mli)
+ mbox_cache_info *mli)
{
mbox_file_t *fi;
apr_array_header_t *files;
@@ -306,63 +311,65 @@
ap_rputs(" <table id=\"grid\">\n", r);
- fi = (mbox_file_t *)files->elts;
+ fi = (mbox_file_t *) files->elts;
- for (i=0; i < files->nelts; i++) {
+ for (i = 0; i < files->nelts; i++) {
/* Only display an entry if it has messages or if we don't
- hide empty mailboxes */
+ hide empty mailboxes */
if (fi[i].count || !conf->hide_empty) {
- if (!year_hdr) {
- if (!side) {
- ap_rputs(" <tr><td class=\"left\">\n", r);
- side = 1;
- }
- else {
- ap_rputs(" <td class=\"right\">\n", r);
- side = 0;
- }
-
- ap_rputs(" <table class=\"year\">\n", r);
- ap_rputs(" <thead><tr>\n", r);
- ap_rprintf(r, " <th colspan=\"3\">Year %.4s</th>\n",
- fi[i].filename);
- ap_rputs(" </tr></thead>\n", r);
- ap_rputs(" <tbody>\n", r);
-
- year_hdr = 1;
- }
-
- ap_rputs(" <tr>\n", r);
- ap_rprintf(r, " <td class=\"date\">%s %.4s</td>\n",
- mbox_months[atoi(apr_pstrndup(r->pool,
- fi[i].filename+4, 2)) - 1][0],
- fi[i].filename);
- ap_rprintf(r, " <td class=\"links\"><span class=\"links\" id=\"%.4s%.2s\">"
- "<a href=\"%.4s%.2s.mbox/thread\">Thread</a>"
- " · <a href=\"%.4s%.2s.mbox/date\">Date</a>"
- " · <a href=\"%.4s%.2s.mbox/author\">Author</a></span></td>\n",
- fi[i].filename, fi[i].filename+4,
- fi[i].filename, fi[i].filename+4,
- fi[i].filename, fi[i].filename+4,
- fi[i].filename, fi[i].filename+4);
- ap_rprintf(r, " <td class=\"msgcount\">%d</td>\n", fi[i].count);
- ap_rputs(" </tr>\n", r);
- }
-
- /* Year separation */
- if ((fi[i+1].filename && year_hdr) &&
- (fi[i].filename[3] != fi[i+1].filename[3])) {
- ap_rputs(" </tbody>\n", r);
- ap_rputs(" </table>\n", r);
- if (side) {
- ap_rputs(" </td>\n", r);
- }
- else {
- ap_rputs(" </td></tr>\n\n", r);
- }
+ if (!year_hdr) {
+ if (!side) {
+ ap_rputs(" <tr><td class=\"left\">\n", r);
+ side = 1;
+ }
+ else {
+ ap_rputs(" <td class=\"right\">\n", r);
+ side = 0;
+ }
+
+ ap_rputs(" <table class=\"year\">\n", r);
+ ap_rputs(" <thead><tr>\n", r);
+ ap_rprintf(r, " <th colspan=\"3\">Year %.4s</th>\n",
+ fi[i].filename);
+ ap_rputs(" </tr></thead>\n", r);
+ ap_rputs(" <tbody>\n", r);
+
+ year_hdr = 1;
+ }
+
+ ap_rputs(" <tr>\n", r);
+ ap_rprintf(r, " <td class=\"date\">%s %.4s</td>\n",
+ mbox_months[atoi(apr_pstrndup(r->pool,
+ fi[i].filename + 4,
+ 2)) - 1][0],
+ fi[i].filename);
+ ap_rprintf(r,
+ " <td class=\"links\"><span class=\"links\" id=\"%.4s%.2s\">"
+ "<a href=\"%.4s%.2s.mbox/thread\">Thread</a>"
+ " · <a href=\"%.4s%.2s.mbox/date\">Date</a>"
+ " · <a href=\"%.4s%.2s.mbox/author\">Author</a></span></td>\n",
+ fi[i].filename, fi[i].filename + 4, fi[i].filename,
+ fi[i].filename + 4, fi[i].filename, fi[i].filename + 4,
+ fi[i].filename, fi[i].filename + 4);
+ ap_rprintf(r, " <td class=\"msgcount\">%d</td>\n",
+ fi[i].count);
+ ap_rputs(" </tr>\n", r);
+ }
+
+ /* Year separation */
+ if ((fi[i + 1].filename && year_hdr) &&
+ (fi[i].filename[3] != fi[i + 1].filename[3])) {
+ ap_rputs(" </tbody>\n", r);
+ ap_rputs(" </table>\n", r);
+ if (side) {
+ ap_rputs(" </td>\n", r);
+ }
+ else {
+ ap_rputs(" </td></tr>\n\n", r);
+ }
- year_hdr = 0;
- }
+ year_hdr = 0;
+ }
}
ap_rputs(" </tbody>\n", r);
@@ -399,10 +406,10 @@
}
/* Wipe out at most three chars preceding the '@' sign */
- for (i=0 ; i<3 ; i++) {
+ for (i = 0; i < 3; i++) {
if ((atsign - i) > ltsign) {
- email[atsign - i] = '.';
- }
+ email[atsign - i] = '.';
+ }
}
return email;
@@ -410,7 +417,7 @@
/* Display an XHTML message list entry */
static void display_static_msglist_entry(request_rec *r, Message *m,
- int linked, int depth)
+ int linked, int depth)
{
mbox_dir_cfg_t *conf;
@@ -432,29 +439,30 @@
ap_rprintf(r, " <td class=\"author\">%s</td>\n", from);
}
else {
- ap_rputs(" <td class=\"author\"></td>\n", r);
+ ap_rputs(" <td class=\"author\"></td>\n", r);
}
/* Subject, linked or not */
ap_rputs(" <td class=\"subject\">", r);
- for (i=0 ; i < depth ; i++) {
+ for (i = 0; i < depth; i++) {
ap_rputs(" ", r);
}
if (linked) {
- ap_rprintf(r, "<a href=\"%s\">", URI_ESCAPE_OR_BLANK(r->pool, m->msgID));
+ ap_rprintf(r, "<a href=\"%s\">",
+ URI_ESCAPE_OR_BLANK(r->pool, m->msgID));
}
ap_rprintf(r, "%s", ESCAPE_OR_BLANK(r->pool, m->subject));
if (linked) {
- ap_rputs("</a>" , r);
+ ap_rputs("</a>", r);
}
ap_rputs(" </td>\n", r);
/* Message date */
if (linked) {
ap_rprintf(r, " <td class=\"date\">%s</td>\n",
- ESCAPE_OR_BLANK(r->pool, m->str_date));
+ ESCAPE_OR_BLANK(r->pool, m->str_date));
}
else {
ap_rputs(" <td class=\"date\"></td>\n", r);
@@ -465,7 +473,7 @@
/* Display an XML message list entry */
static void display_xml_msglist_entry(request_rec *r, Message *m,
- int linked, int depth)
+ int linked, int depth)
{
mbox_dir_cfg_t *conf;
@@ -480,18 +488,20 @@
}
ap_rprintf(r, " <message linked=\"%d\" depth=\"%d\" id=\"%s\">\n",
- linked, depth, URI_ESCAPE_OR_BLANK(r->pool, m->msgID));
+ linked, depth, URI_ESCAPE_OR_BLANK(r->pool, m->msgID));
ap_rprintf(r, " <from><![CDATA[%s]]></from>\n", from);
- ap_rprintf(r, " <date><![CDATA[%s]]></date>\n", ESCAPE_OR_BLANK(r->pool, m->str_date));
+ ap_rprintf(r, " <date><![CDATA[%s]]></date>\n",
+ ESCAPE_OR_BLANK(r->pool, m->str_date));
- ap_rprintf(r, " <subject><![CDATA[%s]]></subject>\n", ESCAPE_OR_BLANK(r->pool, m->subject));
+ ap_rprintf(r, " <subject><![CDATA[%s]]></subject>\n",
+ ESCAPE_OR_BLANK(r->pool, m->subject));
ap_rprintf(r, " </message>\n");
}
/* Display a threaded message list for Container 'c' */
static void display_msglist_thread(request_rec *r, Container *c,
- int depth, int mode)
+ int depth, int mode)
{
Message *m;
int linked = 1;
@@ -506,7 +516,7 @@
}
else {
m = c->child->message;
- linked = 0;
+ linked = 0;
}
if (mode == MBOX_OUTPUT_STATIC) {
@@ -520,7 +530,7 @@
* Subject
* +-> Re: Subject */
if (c->child) {
- display_msglist_thread(r, c->child, depth+1, mode);
+ display_msglist_thread(r, c->child, depth + 1, mode);
}
/* Display follow-ups :
@@ -543,16 +553,16 @@
Message *m;
Container *threads = NULL, *c;
- int current_page = 0; /* Current page number, starting at 0 */
- int pages; /* Number of pages */
- int count = 0; /* Message count */
+ int current_page = 0; /* Current page number, starting at 0 */
+ int pages; /* Number of pages */
+ int count = 0; /* Message count */
int i = 0;
conf = ap_get_module_config(r->per_dir_config, &mbox_module);
/* Fetch page number if present. Otherwise, assume page #1 */
if (r->args && strcmp(r->args, ""))
- current_page = atoi(r->args);
+ current_page = atoi(r->args);
/* Load the index of messages from the DB into the MBOX_LIST */
head = mbox_load_index(r, f, &count);
@@ -560,24 +570,24 @@
/* Compute the page count, depending on the sort flags */
if (sortFlags != MBOX_SORT_THREAD) {
pages = count / DEFAULT_MSGS_PER_PAGE;
- if (count > pages * DEFAULT_MSGS_PER_PAGE) {
- pages++;
- }
+ if (count > pages * DEFAULT_MSGS_PER_PAGE) {
+ pages++;
+ }
}
else {
- threads = calculate_threads(r->pool, head);
- c = threads;
- count = 0;
-
- while (c) {
- c = c->next;
- count++;
- }
+ threads = calculate_threads(r->pool, head);
+ c = threads;
+ count = 0;
+
+ while (c) {
+ c = c->next;
+ count++;
+ }
pages = count / DEFAULT_THREADS_PER_PAGE;
- if (count > pages * DEFAULT_THREADS_PER_PAGE) {
- pages++;
- }
+ if (count > pages * DEFAULT_THREADS_PER_PAGE) {
+ pages++;
+ }
}
/* This index only changes when the .mbox file changes. */
@@ -587,46 +597,45 @@
/* Send page header */
ap_rputs("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n", r);
- ap_rprintf(r, "<index page=\"%d\" pages=\"%d\">\n",
- current_page, pages);
+ ap_rprintf(r, "<index page=\"%d\" pages=\"%d\">\n", current_page, pages);
/* For date and author sorts */
if (sortFlags != MBOX_SORT_THREAD) {
/* Sort the list */
head = mbox_sort_list(head, sortFlags);
- /* Pass useless messages */
- while (head && (i < current_page * DEFAULT_MSGS_PER_PAGE)) {
- head = head->next;
- i++;
- }
-
- /* Display current_page's messages */
- while (head && (i < (current_page + 1) * DEFAULT_MSGS_PER_PAGE)) {
- m = (Message*)head->value;
- display_xml_msglist_entry(r, m, 1, 0);
-
- head = head->next;
- i++;
- }
+ /* Pass useless messages */
+ while (head && (i < current_page * DEFAULT_MSGS_PER_PAGE)) {
+ head = head->next;
+ i++;
+ }
+
+ /* Display current_page's messages */
+ while (head && (i < (current_page + 1) * DEFAULT_MSGS_PER_PAGE)) {
+ m = (Message *) head->value;
+ display_xml_msglist_entry(r, m, 1, 0);
+
+ head = head->next;
+ i++;
+ }
}
/* For threaded view */
else {
c = threads;
- /* Pass useless threads */
- while (c && (i < current_page * DEFAULT_THREADS_PER_PAGE)) {
- c = c->next;
- i++;
- }
-
- /* Display current_page's threads */
- while (c && (i < (current_page + 1) * DEFAULT_THREADS_PER_PAGE)) {
- display_msglist_thread(r, c, 0, MBOX_OUTPUT_AJAX);
- c = c->next;
- i++;
- }
+ /* Pass useless threads */
+ while (c && (i < current_page * DEFAULT_THREADS_PER_PAGE)) {
+ c = c->next;
+ i++;
+ }
+
+ /* Display current_page's threads */
+ while (c && (i < (current_page + 1) * DEFAULT_THREADS_PER_PAGE)) {
+ display_msglist_thread(r, c, 0, MBOX_OUTPUT_AJAX);
+ c = c->next;
+ i++;
+ }
}
ap_rputs("</index>", r);
@@ -639,7 +648,7 @@
* FIXME: improve the algorithm in order to handle long pages list.
*/
static void mbox_static_msglist_page_selector(request_rec *r, char *baseURI,
- int pages, int current_page)
+ int pages, int current_page)
{
int i;
@@ -650,35 +659,37 @@
}
if (current_page) {
- ap_rprintf(r, "<a href=\"%s%s?%d\">« Previous</a> · ",
- baseURI, r->path_info, current_page-1);
+ ap_rprintf(r, "<a href=\"%s%s?%d\">« Previous</a> · ",
+ baseURI, r->path_info, current_page - 1);
}
for (i = 0; i < pages; i++) {
if (i != 0) {
- ap_rputs(" · ", r);
- }
+ ap_rputs(" · ", r);
+ }
- if (i != current_page) {
- ap_rprintf(r, "<a href=\"%s%s?%d\">%d</a>",
- baseURI, r->path_info, i, i+1);
- }
- else {
- ap_rprintf(r, "%d", i+1);
- }
+ if (i != current_page) {
+ ap_rprintf(r, "<a href=\"%s%s?%d\">%d</a>",
+ baseURI, r->path_info, i, i + 1);
+ }
+ else {
+ ap_rprintf(r, "%d", i + 1);
+ }
}
- if (current_page+1 < pages) {
- ap_rprintf(r, " · <a href=\"%s%s?%d\">Next »</a>",
- baseURI, r->path_info, current_page+1);
+ if (current_page + 1 < pages) {
+ ap_rprintf(r, " · <a href=\"%s%s?%d\">Next »</a>",
+ baseURI, r->path_info, current_page + 1);
}
}
static void mbox_static_msglist_nav(request_rec *r, char *baseURI,
- int pages, int current_page,
- int sortFlags)
+ int pages, int current_page,
+ int sortFlags)
{
- ap_rputs(" <tr><th class=\"title\"><a href=\"browser\">Message list</a></th>", r);
+ ap_rputs
+ (" <tr><th class=\"title\"><a href=\"browser\">Message list</a></th>",
+ r);
ap_rputs("<th class=\"pages\">", r);
mbox_static_msglist_page_selector(r, baseURI, pages, current_page);
@@ -687,27 +698,25 @@
ap_rputs("<th class=\"sort\">", r);
if (sortFlags == MBOX_SORT_THREAD) {
ap_rprintf(r, "Thread · "
- "<a href=\"%s/author\">Author</a> · "
- "<a href=\"%s/date\">Date</a>",
- baseURI, baseURI);
+ "<a href=\"%s/author\">Author</a> · "
+ "<a href=\"%s/date\">Date</a>", baseURI, baseURI);
}
else if (sortFlags == MBOX_SORT_AUTHOR) {
ap_rprintf(r, "<a href=\"%s/thread\">Thread</a> · "
- "Author · "
- "<a href=\"%s/date\">Date</a>",
- baseURI, baseURI);
+ "Author · "
+ "<a href=\"%s/date\">Date</a>", baseURI, baseURI);
}
else {
ap_rprintf(r, "<a href=\"%s/thread\">Thread</a> · "
- "<a href=\"%s/author\">Author</a> · "
- "Date",
- baseURI, baseURI);
+ "<a href=\"%s/author\">Author</a> · "
+ "Date", baseURI, baseURI);
}
ap_rputs("</th></tr>\n", r);
}
/* Display the XHTML index of the specified mbox file. */
-apr_status_t mbox_static_msglist(request_rec *r, apr_file_t *f, int sortFlags)
+apr_status_t mbox_static_msglist(request_rec *r, apr_file_t *f,
+ int sortFlags)
{
apr_finfo_t fi;
@@ -716,9 +725,9 @@
Message *m;
Container *threads = NULL, *c;
- int current_page = 0; /* Current page number, starting at 0 */
- int pages; /* Total number of pages */
- int count = 0; /* Message count */
+ int current_page = 0; /* Current page number, starting at 0 */
+ int pages; /* Total number of pages */
+ int count = 0; /* Message count */
int i = 0;
char *baseURI;
@@ -731,7 +740,7 @@
/* Fetch page number if present. Otherwise, assume page #1 */
if (r->args && strcmp(r->args, ""))
- current_page = atoi(r->args);
+ current_page = atoi(r->args);
/* Load the index of messages from the DB into the MBOX_LIST */
head = mbox_load_index(r, f, &count);
@@ -739,24 +748,24 @@
/* Compute the page count, depending on the sort flags */
if (sortFlags != MBOX_SORT_THREAD) {
pages = count / DEFAULT_MSGS_PER_PAGE;
- if (count > pages * DEFAULT_MSGS_PER_PAGE) {
- pages++;
- }
+ if (count > pages * DEFAULT_MSGS_PER_PAGE) {
+ pages++;
+ }
}
else {
- threads = calculate_threads(r->pool, head);
- c = threads;
- count = 0;
-
- while (c) {
- c = c->next;
- count++;
- }
+ threads = calculate_threads(r->pool, head);
+ c = threads;
+ count = 0;
+
+ while (c) {
+ c = c->next;
+ count++;
+ }
pages = count / DEFAULT_THREADS_PER_PAGE;
- if (count > pages * DEFAULT_THREADS_PER_PAGE) {
- pages++;
- }
+ if (count > pages * DEFAULT_THREADS_PER_PAGE) {
+ pages++;
+ }
}
/* This index only changes when the .mbox file changes. */
@@ -768,9 +777,11 @@
filename = strrchr(r->filename, '/');
if (filename &&
apr_fnmatch("[0-9][0-9][0-9][0-9][0-9][0-9].mbox", filename + 1, 0)
- == APR_SUCCESS) {
+ == APR_SUCCESS) {
month = mbox_months[atoi(apr_pstrndup(r->pool, baseURI +
- (strlen(baseURI) - strlen(".mbox") - 2), 2)) - 1][1];
+ (strlen(baseURI) -
+ strlen(".mbox") - 2),
+ 2)) - 1][1];
year = baseURI + (strlen(baseURI) - strlen(".mbox") - 6);
}
else {
@@ -780,19 +791,21 @@
/* Send page header */
ap_rputs("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n", r);
- ap_rputs("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n", r);
+ ap_rputs("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n",
+ r);
ap_rputs("\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n\n", r);
ap_rputs("<html xmlns=\"http://www.w3.org/1999/xhtml\">\n", r);
ap_rputs(" <head>\n", r);
ap_rputs(" <meta http-equiv=\"Content-Type\" "
- "content=\"text/html; charset=utf-8\" />\n", r);
+ "content=\"text/html; charset=utf-8\" />\n", r);
ap_rprintf(r, " <title>Mailing list archives: %s %.4s</title>\n",
month, year);
if (conf->style_path) {
- ap_rprintf(r, " <link rel=\"stylesheet\" type=\"text/css\" href=\"%s\" />\n",
- conf->style_path);
+ ap_rprintf(r,
+ " <link rel=\"stylesheet\" type=\"text/css\" href=\"%s\" />\n",
+ conf->style_path);
}
ap_rputs(" </head>\n\n", r);
@@ -805,12 +818,11 @@
if (conf->root_path) {
ap_rprintf(r, "<a href=\"%s\" title=\"Back to the archives depot\">"
- "Site index</a> · ",
- conf->root_path);
+ "Site index</a> · ", conf->root_path);
}
ap_rprintf(r, "<a href=\"%s\" title=\"Back to the list index\">"
- "List index</a></h5>", get_base_path(r));
+ "List index</a></h5>", get_base_path(r));
ap_rputs(" <table id=\"msglist\">\n", r);
ap_rputs(" <thead>\n", r);
@@ -824,38 +836,38 @@
/* Sort the list */
head = mbox_sort_list(head, sortFlags);
- /* Pass useless messages */
- while (head && (i < current_page * DEFAULT_MSGS_PER_PAGE)) {
- head = head->next;
- i++;
- }
-
- /* Display current_page's messages */
- while (head && (i < (current_page + 1) * DEFAULT_MSGS_PER_PAGE)) {
- m = (Message*)head->value;
- display_static_msglist_entry(r, m, 1, 0);
-
- head = head->next;
- i++;
- }
+ /* Pass useless messages */
+ while (head && (i < current_page * DEFAULT_MSGS_PER_PAGE)) {
+ head = head->next;
+ i++;
+ }
+
+ /* Display current_page's messages */
+ while (head && (i < (current_page + 1) * DEFAULT_MSGS_PER_PAGE)) {
+ m = (Message *) head->value;
+ display_static_msglist_entry(r, m, 1, 0);
+
+ head = head->next;
+ i++;
+ }
}
/* For threaded view */
else {
c = threads;
- /* Pass useless threads */
- while (c && (i < current_page * DEFAULT_THREADS_PER_PAGE)) {
- c = c->next;
- i++;
- }
-
- /* Display current_page's threads */
- while (c && (i < (current_page + 1) * DEFAULT_THREADS_PER_PAGE)) {
- display_msglist_thread(r, c, 0, MBOX_OUTPUT_STATIC);
- c = c->next;
- i++;
- }
+ /* Pass useless threads */
+ while (c && (i < current_page * DEFAULT_THREADS_PER_PAGE)) {
+ c = c->next;
+ i++;
+ }
+
+ /* Display current_page's threads */
+ while (c && (i < (current_page + 1) * DEFAULT_THREADS_PER_PAGE)) {
+ display_msglist_thread(r, c, 0, MBOX_OUTPUT_STATIC);
+ c = c->next;
+ i++;
+ }
}
ap_rputs(" </tbody>\n", r);
@@ -884,46 +896,51 @@
ap_set_content_type(r, "text/html; charset=utf-8");
ap_rputs("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n", r);
- ap_rputs("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n", r);
+ ap_rputs("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n",
+ r);
ap_rputs("\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n\n", r);
ap_rputs("<html xmlns=\"http://www.w3.org/1999/xhtml\">\n", r);
ap_rputs(" <head>\n", r);
ap_rputs(" <meta http-equiv=\"Content-Type\" "
- "content=\"text/html; charset=utf-8\" />\n", r);
+ "content=\"text/html; charset=utf-8\" />\n", r);
ap_rputs(" <title>Mailing list archives</title>\n", r);
if (conf->style_path) {
- ap_rprintf(r, " <link rel=\"stylesheet\" type=\"text/css\" href=\"%s\" />\n",
- conf->style_path);
+ ap_rprintf(r,
+ " <link rel=\"stylesheet\" type=\"text/css\" href=\"%s\" />\n",
+ conf->style_path);
}
if (conf->script_path) {
- ap_rprintf(r, " <script type=\"text/javascript\" src=\"%s\"></script>\n",
- conf->script_path);
+ ap_rprintf(r,
+ " <script type=\"text/javascript\" src=\"%s\"></script>\n",
+ conf->script_path);
}
ap_rputs(" </head>\n\n", r);
- ap_rprintf(r, " <body id=\"archives\" onload=\"javascript:loadBrowser ('%s');\">\n", baseURI);
+ ap_rprintf(r,
+ " <body id=\"archives\" onload=\"javascript:loadBrowser ('%s');\">\n",
+ baseURI);
ap_rputs(" <h1>Mailing list archives</h1>\n\n", r);
ap_rputs(" <h5>\n", r);
if (conf->root_path) {
ap_rprintf(r, "<a href=\"%s\" title=\"Back to the archives depot\">"
- "Site index</a> · ",
- conf->root_path);
+ "Site index</a> · ", conf->root_path);
}
ap_rprintf(r, "<a href=\"%s\" title=\"Back to the list index\">"
- "List index</a></h5>", get_base_path(r));
+ "List index</a></h5>", get_base_path(r));
/* Output a small notice if no MboxScriptPath configuration
directive was specified. */
if (!conf->script_path) {
ap_rputs(" <p>You did not specified a script path, and the dynamic "
- "browser won't run without it. Check your server configuration.\n", r);
+ "browser won't run without it. Check your server configuration.\n",
+ r);
}
ap_rputs(" </body>\n</html>\n", r);
@@ -942,12 +959,12 @@
/* Fetch message ID (offset is 5 : '/raw') and eventual MIME part
number. */
- msgID = r->path_info+5;
+ msgID = r->path_info + 5;
part = strchr(msgID, '/');
if (part) {
*part = 0;
- part++;
+ part++;
}
ap_unescape_url(msgID);
@@ -971,7 +988,7 @@
/* No MIME part specified : output whole message and return. */
if (!part) {
ap_set_content_type(r, "text/plain");
- ap_rprintf(r, "%s", m->raw_msg);
+ ap_rprintf(r, "%s", m->raw_msg);
return OK;
}
@@ -989,35 +1006,35 @@
/* First, parse the MIME structure, and look for the correct
subpart */
m->mime_msg = mbox_mime_decode_multipart(r->pool, m->raw_body,
- m->content_type,
- m->cte, m->boundary);
+ m->content_type,
+ m->cte, m->boundary);
mime_part = m->mime_msg;
do {
int num;
- end = strchr(part, '/');
- if (end) {
- *end = 0;
- num = atoi(part);
- *end = '/';
-
- part = end + 1;
- }
- else {
- num = atoi(part);
- }
-
- if (mime_part && num > 0 &&
- (num <= mime_part->sub_count) &&
- mime_part->sub[num - 1] &&
- mime_part->sub[num - 1]->body != NULL) {
- mime_part = mime_part->sub[num - 1];
- }
- else {
- return HTTP_NOT_FOUND;
- }
+ end = strchr(part, '/');
+ if (end) {
+ *end = 0;
+ num = atoi(part);
+ *end = '/';
+
+ part = end + 1;
+ }
+ else {
+ num = atoi(part);
+ }
+
+ if (mime_part && num > 0 &&
+ (num <= mime_part->sub_count) &&
+ mime_part->sub[num - 1] &&
+ mime_part->sub[num - 1]->body != NULL) {
+ mime_part = mime_part->sub[num - 1];
+ }
+ else {
+ return HTTP_NOT_FOUND;
+ }
} while (*part && end);
if (strncmp(mime_part->content_type, "multipart/", 10) == 0) {
@@ -1028,7 +1045,7 @@
}
if (mime_part->body_len > 0) {
- const char* pdata;
+ const char *pdata;
apr_size_t ret_len;
mime_part->body[mime_part->body_len] = 0;
@@ -1036,8 +1053,7 @@
pdata = mbox_mime_decode_body(r->pool,
mime_part->cte,
mime_part->body,
- mime_part->body_len,
- &ret_len);
+ mime_part->body_len, &ret_len);
if (pdata != NULL && ret_len) {
ap_rwrite(pdata, ret_len, r);
}
@@ -1047,28 +1063,27 @@
}
void mbox_static_message_nav(request_rec *r, char **context,
- char *baseURI, char *msgID)
+ char *baseURI, char *msgID)
{
ap_rputs(" <th class=\"nav\">", r);
/* Date navigation */
if (context[0]) {
ap_rprintf(r, "<a href=\"%s/%s\" "
- "title=\"Previous by date\">«</a>",
- baseURI, URI_ESCAPE_OR_BLANK(r->pool, context[0]));
+ "title=\"Previous by date\">«</a>",
+ baseURI, URI_ESCAPE_OR_BLANK(r->pool, context[0]));
}
else {
ap_rputs("«", r);
}
ap_rprintf(r, " <a href=\"%s/date\" "
- "title=\"View messages sorted by date\">Date</a> ",
- baseURI);
+ "title=\"View messages sorted by date\">Date</a> ", baseURI);
if (context[1]) {
ap_rprintf(r, "<a href=\"%s/%s\" "
- "title=\"Next by date\">»</a>",
- baseURI, URI_ESCAPE_OR_BLANK(r->pool, context[1]));
+ "title=\"Next by date\">»</a>",
+ baseURI, URI_ESCAPE_OR_BLANK(r->pool, context[1]));
}
else {
ap_rputs("»", r);
@@ -1079,21 +1094,21 @@
/* Thread navigation */
if (context[2]) {
ap_rprintf(r, "<a href=\"%s/%s\" "
- "title=\"Previous by thread\">«</a>",
- baseURI, URI_ESCAPE_OR_BLANK(r->pool, context[2]));
+ "title=\"Previous by thread\">«</a>",
+ baseURI, URI_ESCAPE_OR_BLANK(r->pool, context[2]));
}
else {
ap_rputs("«", r);
}
ap_rprintf(r, " <a href=\"%s/thread\" "
- "title=\"View messages sorted by thread\">Thread</a> ",
- baseURI);
+ "title=\"View messages sorted by thread\">Thread</a> ",
+ baseURI);
if (context[3]) {
ap_rprintf(r, "<a href=\"%s/%s\" "
- "title=\"Next by thread\">»</a>",
- baseURI, URI_ESCAPE_OR_BLANK(r->pool, context[3]));
+ "title=\"Next by thread\">»</a>",
+ baseURI, URI_ESCAPE_OR_BLANK(r->pool, context[3]));
}
else {
ap_rputs("»", r);
@@ -1114,7 +1129,7 @@
conf = ap_get_module_config(r->per_dir_config, &mbox_module);
baseURI = get_base_uri(r);
- msgID = r->path_info+1;
+ msgID = r->path_info + 1;
ap_unescape_url(msgID);
/* msgID should be the part of the URI that Apache could not resolve
@@ -1131,22 +1146,25 @@
/* Parse multipart information */
m->mime_msg = mbox_mime_decode_multipart(r->pool, m->raw_body,
- m->content_type,
- m->cte, m->boundary);
+ m->content_type,
+ m->cte, m->boundary);
ap_rputs("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n", r);
- ap_rputs("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n", r);
+ ap_rputs("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n",
+ r);
ap_rputs("\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n\n", r);
ap_rputs("<html xmlns=\"http://www.w3.org/1999/xhtml\">\n", r);
ap_rputs(" <head>\n", r);
ap_rputs(" <meta http-equiv=\"Content-Type\" "
- "content=\"text/html; charset=utf-8\" />\n", r);
- ap_rprintf(r, " <title>%s</title>\n", ESCAPE_OR_BLANK(r->pool, m->subject));
+ "content=\"text/html; charset=utf-8\" />\n", r);
+ ap_rprintf(r, " <title>%s</title>\n",
+ ESCAPE_OR_BLANK(r->pool, m->subject));
if (conf->style_path) {
- ap_rprintf(r, " <link rel=\"stylesheet\" type=\"text/css\" href=\"%s\" />\n",
- conf->style_path);
+ ap_rprintf(r,
+ " <link rel=\"stylesheet\" type=\"text/css\" href=\"%s\" />\n",
+ conf->style_path);
}
ap_rputs(" </head>\n\n", r);
@@ -1157,8 +1175,7 @@
if (conf->root_path) {
ap_rprintf(r, "<a href=\"%s\" title=\"Back to the archives depot\">"
- "Site index</a> · ",
- conf->root_path);
+ "Site index</a> · ", conf->root_path);
}
ap_rprintf(r, "<a href=\"%s\" title=\"Back to the list index\">"
@@ -1177,55 +1194,53 @@
/* Top navigation */
ap_rputs(" <thead>\n"
- " <tr>\n"
- " <th class=\"title\">Message view</th>\n", r);
+ " <tr>\n" " <th class=\"title\">Message view</th>\n", r);
mbox_static_message_nav(r, context, baseURI, m->msgID);
- ap_rputs(" </tr>\n"
- " </thead>\n\n", r);
+ ap_rputs(" </tr>\n" " </thead>\n\n", r);
/* Bottom navigation */
ap_rputs(" <tfoot>\n"
- " <tr>\n"
- " <th class=\"title\"><a href=\"#archives\">Top</a></th>\n", r);
+ " <tr>\n"
+ " <th class=\"title\"><a href=\"#archives\">Top</a></th>\n",
+ r);
mbox_static_message_nav(r, context, baseURI, m->msgID);
- ap_rputs(" </tr>\n"
- " </tfoot>\n\n", r);
+ ap_rputs(" </tr>\n" " </tfoot>\n\n", r);
/* Headers */
ap_rputs(" <tbody>\n", r);
ap_rprintf(r, " <tr class=\"from\">\n"
- " <td class=\"left\">From</td>\n"
- " <td class=\"right\">%s</td>\n"
- " </tr>\n", from);
+ " <td class=\"left\">From</td>\n"
+ " <td class=\"right\">%s</td>\n" " </tr>\n", from);
ap_rprintf(r, " <tr class=\"subject\">\n"
- " <td class=\"left\">Subject</td>\n"
- " <td class=\"right\">%s</td>\n"
- " </tr>\n", ESCAPE_OR_BLANK(r->pool, m->subject));
+ " <td class=\"left\">Subject</td>\n"
+ " <td class=\"right\">%s</td>\n"
+ " </tr>\n", ESCAPE_OR_BLANK(r->pool, m->subject));
ap_rprintf(r, " <tr class=\"date\">\n"
- " <td class=\"left\">Date</td>\n"
- " <td class=\"right\">%s</td>\n"
- " </tr>\n", ESCAPE_OR_BLANK(r->pool, m->rfc822_date));
+ " <td class=\"left\">Date</td>\n"
+ " <td class=\"right\">%s</td>\n"
+ " </tr>\n", ESCAPE_OR_BLANK(r->pool, m->rfc822_date));
/* Message body */
ap_rputs(" <tr class=\"contents\"><td colspan=\"2\"><pre>\n", r);
- ap_rprintf(r, "%s", mbox_wrap_text(mbox_mime_get_body(r->pool, m->mime_msg)));
+ ap_rprintf(r, "%s",
+ mbox_wrap_text(mbox_mime_get_body(r->pool, m->mime_msg)));
ap_rputs("</pre></td></tr>\n", r);
/* MIME structure */
ap_rputs(" <tr class=\"mime\">\n"
- " <td class=\"left\">Mime</td>\n"
- " <td class=\"right\">\n<ul>\n", r);
+ " <td class=\"left\">Mime</td>\n"
+ " <td class=\"right\">\n<ul>\n", r);
mbox_mime_display_static_structure(r, m->mime_msg,
- apr_psprintf(r->pool, "%s/raw/%s/",
- baseURI, m->msgID));
+ apr_psprintf(r->pool, "%s/raw/%s/",
+ baseURI, m->msgID));
ap_rputs("</ul>\n</td>\n</tr>\n", r);
ap_rprintf(r, " <tr class=\"raw\">\n"
- " <td class=\"left\"></td>\n"
- " <td class=\"right\"><a href=\"%s/raw/%s\" rel=\"nofollow\">View raw message</a></td>\n"
- " </tr>\n", baseURI, URI_ESCAPE_OR_BLANK(r->pool, m->msgID));
+ " <td class=\"left\"></td>\n"
+ " <td class=\"right\"><a href=\"%s/raw/%s\" rel=\"nofollow\">View raw message</a></td>\n"
+ " </tr>\n", baseURI, URI_ESCAPE_OR_BLANK(r->pool, m->msgID));
ap_rputs(" </tbody>\n", r);
ap_rputs(" </table>\n", r);
@@ -1248,7 +1263,7 @@
baseURI = get_base_uri(r);
/* Here, we skip 6 chars (/ajax/). */
- msgID = r->path_info+6;
+ msgID = r->path_info + 6;
ap_unescape_url(msgID);
m = fetch_message(r, f, msgID);
@@ -1258,31 +1273,33 @@
/* Parse multipart information */
m->mime_msg = mbox_mime_decode_multipart(r->pool, m->raw_body,
- m->content_type,
- m->cte, m->boundary);
+ m->content_type,
+ m->cte, m->boundary);
ap_rputs("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n", r);
from = ESCAPE_OR_BLANK(r->pool, m->from);
from = mbox_cte_decode_header(r->pool, from);
if (conf->antispam) {
- from = email_antispam(from);
+ from = email_antispam(from);
}
ap_rprintf(r, "<mail id=\"%s\">\n"
- " <from><![CDATA[%s]]></from>\n"
- " <subject><![CDATA[%s]]></subject>\n"
- " <date><![CDATA[%s]]></date>\n"
- " <contents><![CDATA[",
- URI_ESCAPE_OR_BLANK(r->pool, m->msgID),
- from,
- ESCAPE_OR_BLANK(r->pool, m->subject),
- ESCAPE_OR_BLANK(r->pool, m->rfc822_date));
+ " <from><![CDATA[%s]]></from>\n"
+ " <subject><![CDATA[%s]]></subject>\n"
+ " <date><![CDATA[%s]]></date>\n"
+ " <contents><![CDATA[",
+ URI_ESCAPE_OR_BLANK(r->pool, m->msgID),
+ from,
+ ESCAPE_OR_BLANK(r->pool, m->subject),
+ ESCAPE_OR_BLANK(r->pool, m->rfc822_date));
- ap_rprintf(r, "%s", mbox_wrap_text(mbox_mime_get_body(r->pool, m->mime_msg)));
+ ap_rprintf(r, "%s",
+ mbox_wrap_text(mbox_mime_get_body(r->pool, m->mime_msg)));
ap_rputs("]]></contents>\n", r);
ap_rputs(" <mime>\n", r);
- mbox_mime_display_xml_structure(r, m->mime_msg, apr_psprintf(r->pool, "/"));
+ mbox_mime_display_xml_structure(r, m->mime_msg,
+ apr_psprintf(r->pool, "/"));
ap_rputs(" </mime>\n", r);
ap_rputs("</mail>\n", r);