/*
** Copyright (C) 1994, 1995 Enterprise Integration Technologies Corp.
** VeriFone Inc./Hewlett-Packard. All Rights Reserved.
** Kevin Hughes, kev@kevcom.com 3/11/94
** Kent Landfield, kent@landfield.com 4/6/97
**
** This program and library is free software; you can redistribute it and/or
** modify it under the terms of the GNU (Library) General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU (Library) General Public License for more details.
**
** You should have received a copy of the GNU (Library) General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#include "hypermail.h"
#include "setup.h"
#include "struct.h"
#include "printfile.h"
#include "print.h"
#include "parse.h"
#include "txt2html.h"
#include "finelink.h"
#include "threadprint.h"
#include "proto.h"
#ifdef HAVE_DIRENT_H
#include \n");
if (set_mailcommand && set_hmail) {
ptr = makemailcommand("mailto:$TO", set_hmail, "", "");
fprintf(fp, "%s\n",
ptr ? ptr : "", lang[MSG_NEW_MESSAGE]);
if (ptr)
free(ptr);
}
if (!set_reverse && (called_from != AUTHOR_INDEX && called_from != SUBJECT_INDEX))
fprintf(fp, "%s\n
\n\n");
if (set_mailcommand) {
if (set_hmail) {
ptr = makemailcommand(set_newmsg_command, set_hmail,
currentid, cursub);
if (strcmp(ptr, "NONE")!=0)
fprintf(fp, " %s \n",
ptr ? ptr : "", lang[MSG_NEW_MESSAGE]);
if (ptr)
free(ptr);
if ((currentid != NULL && currentid[0] != '\0') ||
(cursub != NULL && cursub[0] != '\0')) {
ptr = makemailcommand(set_replymsg_command, set_hmail,
currentid, cursub);
if (strcmp(ptr, "NONE")!=0)
fprintf(fp, "%s \n",
ptr ? ptr : "", lang[MSG_REPLY]);
if (ptr)
free(ptr);
}
}
}
if (set_about && *set_about)
fprintf(fp, "%s \n", set_about,
lang[MSG_ABOUT_THIS_LIST]);
if (set_show_index_links && set_show_index_links != (pos == PAGE_TOP ? 4 : 3)) {
if (idx != NO_INDEX && !set_reverse) {
if (pos == PAGE_TOP)
fprintf(fp, "%s \n",
lang[MSG_END_OF_MESSAGES]);
else
fprintf(fp, "%s \n",
lang[MSG_START_OF_MESSAGES]);
}
for (i = 0; i <= AUTHOR_INDEX; ++i) {
if (idx != i && show_index[dlev][i]) {
fprintf(fp, "%s \n",
index_name[dlev][i], lang[MSG_DATE_VIEW + i]);
++count_l;
}
}
if (show_index[dlev][ATTACHMENT_INDEX]) {
if (idx != ATTACHMENT_INDEX) {
fprintf(fp, "%s \n",
index_name[dlev][ATTACHMENT_INDEX],
lang[MSG_ATTACHMENT_VIEW]);
++count_l;
}
}
if (subdir && idx != NO_INDEX) {
int f_cols = (subdir->prior_subdir != NULL)
+ (subdir->next_subdir != NULL);
const char *colspan = 2*f_cols <= count_l ? " colspan=\"2\"": "";
fprintf(fp, "");
if (subdir->prior_subdir)
fprintf(fp, " \n%s, %s ",
colspan, subdir->rel_path_to_top,
subdir->prior_subdir->subdir, index_name[dlev][idx],
lang[MSG_PREV_DIRECTORY], lang[MSG_DATE_VIEW + idx]);
if (subdir->next_subdir)
fprintf(fp, "%s, %s ",
colspan, subdir->rel_path_to_top,
subdir->next_subdir->subdir, index_name[dlev][idx],
lang[MSG_NEXT_DIRECTORY], lang[MSG_DATE_VIEW + idx]);
if (show_index[0][FOLDERS_INDEX])
fprintf(fp, "%s ",
subdir->rel_path_to_top, index_name[0][FOLDERS_INDEX],
lang[MSG_FOLDERS_INDEX]);
}
}
if (archives && *archives)
fprintf(fp, "%s \n", archives,
lang[MSG_OTHER_MAIL_ARCHIVES]);
fprintf(fp, "\n");
if (pos == PAGE_TOP) {
fprintf(fp, "
\n\n \n",
num, lang[MSG_MESSAGES]);
fprintf(fp, "%d %s \n\n \n",
lang[MSG_ENDING], getdatestr(last_d));
}
else { /* bottom of page */
fprintf(fp,"%s: %s \n",
lang[MSG_STARTING], getdatestr(first_d));
fprintf(fp, " %s: %s \n%s: %s \n",
lang[MSG_LAST_MESSAGE_DATE], getdatestr(last_d));
fprintf(fp, "%s: %s \n",
lang[MSG_ARCHIVED_ON], getlocaltime());
}
fprintf(fp, "
\n",
lang[MSG_MOST_RECENT_MESSAGES]);
if ((called_from != AUTHOR_INDEX && show_index[dlev][AUTHOR_INDEX]) ||
(called_from != DATE_INDEX && show_index[dlev][DATE_INDEX]) ||
(called_from != THREAD_INDEX && show_index[dlev][THREAD_INDEX]) ||
(called_from != SUBJECT_INDEX && show_index[dlev][SUBJECT_INDEX]))
fprintf(fp, "%d %s %s: \n", amountmsgs,
lang[MSG_ARTICLES], lang[MSG_SORTED_BY]);
if (called_from != AUTHOR_INDEX && show_index[dlev][AUTHOR_INDEX])
fprintf(fp, "[ %s ]\n",
index_name[dlev][AUTHOR_INDEX], lang[MSG_AUTHOR]);
if (called_from != DATE_INDEX && show_index[dlev][DATE_INDEX])
fprintf(fp, "[ %s ]\n",
index_name[dlev][DATE_INDEX], lang[MSG_DATE]);
if (called_from != THREAD_INDEX && show_index[dlev][THREAD_INDEX])
fprintf(fp, "[ %s ]\n",
index_name[dlev][THREAD_INDEX], lang[MSG_THREAD]);
if (called_from != SUBJECT_INDEX && show_index[dlev][SUBJECT_INDEX])
fprintf(fp, "[ %s ]\n",
index_name[dlev][SUBJECT_INDEX], lang[MSG_SUBJECT]);
if (set_attachmentsindex) {
if (called_from != ATTACHMENT_INDEX) {
fprintf(fp, "[ %s ]\n",
index_name[dlev][ATTACHMENT_INDEX], lang[MSG_ATTACHMENT]);
}
}
if (subdir) {
fprintf(fp, "
");
if (subdir->prior_subdir)
fprintf(fp, " %s, %s | ",
subdir->rel_path_to_top, subdir->prior_subdir->subdir,
index_name[dlev][called_from], lang[MSG_PREV_DIRECTORY],
lang[MSG_DATE_VIEW + called_from]);
if (subdir->next_subdir)
fprintf(fp, " %s, %s | ",
subdir->rel_path_to_top, subdir->next_subdir->subdir,
index_name[dlev][called_from], lang[MSG_NEXT_DIRECTORY],
lang[MSG_DATE_VIEW + called_from]);
if (show_index[0][FOLDERS_INDEX])
fprintf(fp, " %s",
subdir->rel_path_to_top, index_name[0][FOLDERS_INDEX],
lang[MSG_FOLDERS_INDEX]);
}
if (set_about && *set_about)
fprintf(fp, "
%s\n",
set_about, lang[MSG_ABOUT_THIS_ARCHIVE]);
if (set_archives && *set_archives)
fprintf(fp, "
%s\n",
set_archives, lang[MSG_OTHER_MAIL_ARCHIVES]);
if (set_custom_archives && *set_custom_archives)
fprintf(fp,"
%s: %s\n",
lang[MSG_OTHER_MAIL_ARCHIVES], set_custom_archives);
/* JK: moved it here as it looks better and changed a bit the text */
if (set_mailcommand && set_hmail) {
ptr = makemailcommand(set_newmsg_command, set_hmail, "", "");
fprintf(fp, "
%s: [ %s ]\n",
lang[MSG_MAIL_ACTIONS], ptr ? ptr : "",
lang[MSG_MA_NEW_MESSAGE]);
if (ptr)
free(ptr);
}
if (set_showhr)
fprintf(fp, "
\n");
else
fprintf(fp, "
\n");
fprintf(fp, "%s: %s
\n",
lang[MSG_STARTING], getdatestr(startdatenum));
fprintf(fp, "%s: %s
\n",
lang[MSG_ENDING], getdatestr(enddatenum));
fprintf(fp, "
\n");
fprintf(fp, "%s: %s
\n",
lang[MSG_LAST_MESSAGE_DATE], getdatestr(lastdatenum));
fprintf(fp, "%s: %s\n",
lang[MSG_ARCHIVED_ON], getlocaltime());
if (set_showhr)
fprintf(fp, "
\n");
if ((called_from != AUTHOR_INDEX && show_index[dlev][AUTHOR_INDEX]) ||
(called_from != DATE_INDEX && show_index[dlev][DATE_INDEX]) ||
(called_from != THREAD_INDEX && show_index[dlev][THREAD_INDEX]) ||
(called_from != SUBJECT_INDEX && show_index[dlev][SUBJECT_INDEX]))
fprintf(fp, "%d %s %s: \n", amountmsgs,
lang[MSG_ARTICLES], lang[MSG_SORTED_BY]);
if (called_from != AUTHOR_INDEX && show_index[dlev][AUTHOR_INDEX])
fprintf(fp, "[ %s ]\n",
index_name[dlev][AUTHOR_INDEX], lang[MSG_AUTHOR]);
if (called_from != DATE_INDEX && show_index[dlev][DATE_INDEX])
fprintf(fp, "[ %s ]\n",
index_name[dlev][DATE_INDEX], lang[MSG_DATE]);
if (called_from != THREAD_INDEX && show_index[dlev][THREAD_INDEX])
fprintf(fp, "[ %s ]\n",
index_name[dlev][THREAD_INDEX], lang[MSG_THREAD]);
if (called_from != SUBJECT_INDEX && show_index[dlev][SUBJECT_INDEX])
fprintf(fp, "[ %s ]\n",
index_name[dlev][SUBJECT_INDEX], lang[MSG_SUBJECT]);
if (set_attachmentsindex) {
if (called_from != ATTACHMENT_INDEX) {
fprintf(fp, "[ %s ]\n",
index_name[dlev][ATTACHMENT_INDEX], lang[MSG_ATTACHMENT]);
}
}
if (subdir) {
fprintf(fp, "
");
if (subdir->prior_subdir)
fprintf(fp, " %s, %s",
subdir->rel_path_to_top, subdir->prior_subdir->subdir,
index_name[dlev][called_from], lang[MSG_PREV_DIRECTORY],
lang[MSG_DATE_VIEW + called_from]);
if (subdir->next_subdir)
fprintf(fp, " %s, %s",
subdir->rel_path_to_top, subdir->next_subdir->subdir,
index_name[dlev][called_from], lang[MSG_NEXT_DIRECTORY],
lang[MSG_DATE_VIEW + called_from]);
if (show_index[0][FOLDERS_INDEX])
fprintf(fp, " %s",
subdir->rel_path_to_top, index_name[0][FOLDERS_INDEX],
lang[MSG_FOLDERS_INDEX]);
}
if (set_about && *set_about)
fprintf(fp, "
%s\n",
set_about, lang[MSG_ABOUT_THIS_ARCHIVE]);
if (set_archives && *set_archives)
fprintf(fp, "
%s\n",
set_archives, lang[MSG_OTHER_MAIL_ARCHIVES]);
if (set_custom_archives && *set_custom_archives)
fprintf(fp,"
%s: %s\n",
lang[MSG_OTHER_MAIL_ARCHIVES], set_custom_archives);
/* JK: added it here as it looks better and changed a bit the text */
if (set_mailcommand && set_hmail) {
ptr = makemailcommand(set_newmsg_command, set_hmail, "", "");
fprintf(fp, "
%s: [ %s ]\n",
lang[MSG_MAIL_ACTIONS], ptr ? ptr : "",
lang[MSG_MA_NEW_MESSAGE]);
if (ptr)
free(ptr);
}
fprintf(fp, "
. We accomplish this by checking ** ahead when we print each line... if we determine that the next line ** should be broken before, we do so. */ void printbody(FILE *fp, struct emailinfo *email, int maybe_reply) { int insig, inblank; struct body *bp = email->bodylist; char *id = email->msgid; char *subject = email->subject; int msgnum = email->msgnum; char inheader = FALSE; /* we always start in a mail header */ int pre = FALSE; int inquote; int quote_num; int quoted_percent = (set_quote_hide_threshold <= 100 ? compute_quoted_percent(bp) : 100); bool replace_quoted = (quoted_percent > set_quote_hide_threshold); if(set_showprogress && replace_quoted) printf("\nMessage %d quoted text (%d %%) replaced by links\n", msgnum,quoted_percent); if (set_showhr) fprintf(fp, "
\n");
pre = TRUE;
}
if (set_showhtml == 2)
init_txt2html();
inquote = 0;
quote_num = 0;
inblank = 1;
insig = 0;
while (bp != NULL) {
if (bp->html) {
/* already in HTML, don't touch */
if (pre) {
fprintf(fp, "\n");
pre = FALSE;
}
printhtml(fp, bp->line);
inheader = FALSE; /* this can't be a header if already in HTML */
bp = bp->next;
continue;
}
if (bp->header) {
char head[128];
if (!inheader) {
/* @@ JK: I'm not sure why, but I had a !set_showhtml here */
if(!set_showhtml && !pre && set_showheaders) {
fprintf(fp, "\n");
pre = TRUE;
}
inheader = TRUE;
}
if (sscanf(bp->line, "%127[^:]", head) == 1 &&
set_show_headers && !showheader(head)) {
/* the show header keyword has been used, then we skip all those
that aren't mentioned! */
if (isalnum(*head) || !set_showheaders) {
/* this check is only to make sure that the last line among
the headers (the "\n" one) won't be filtered off */
bp = bp->next;
continue;
}
}
}
else {
if (inheader) {
insig=0;
if (set_showhtml) {
if (pre) {
fprintf(fp, "\n");
pre = FALSE;
}
fprintf(fp, "\n"); } else { if (!pre) { fprintf(fp, "
\n");
pre = TRUE;
}
}
inheader = FALSE;
}
}
if (((bp->line)[0] != '\n') && (bp->header && !set_showheaders)) {
bp = bp->next;
continue;
}
if (set_showhtml == 2 && !inheader) {
txt2html(fp, email, bp, replace_quoted, maybe_reply);
bp = bp->next;
continue;
}
if (bp->header && set_showheaders && !pre) {
fprintf(fp, "\n");
pre = TRUE;
}
if ((bp->line)[0] == '\n' && inblank) {
bp = bp->next;
continue;
}
else
inblank = 0;
if (set_showhtml) {
if (is_sig_start(bp->line)) {
insig = 1;
if (!pre) {
fprintf(fp, "\n");
pre = TRUE;
}
}
if (!inheader && (bp->line)[0] == '\n')
/* within the statements you do not need to
insert statements since text is already preformated.
the W3C HTML validation script fails for such pages
Akis Karnouskos */
{
if (!pre)
fprintf(fp, "");
}
else {
if (insig) {
ConvURLs(fp, bp->line, id, subject);
}
else if (isquote(bp->line)) {
if(set_linkquotes) {
if(handle_quoted_text(fp, email, bp, bp->line, inquote,
quote_num,
replace_quoted, maybe_reply)) {
++quote_num;
inquote = 1;
}
}
else {
fprintf(fp, "%s", (set_iquotes) ? "" : "");
ConvURLs(fp, bp->line, id, subject);
fprintf(fp, "%s
\n", (set_iquotes) ? "" : "");
}
}
else if ((bp->line)[0] != '\0') {
char *sp;
sp = print_leading_whitespace(fp, bp->line);
/* JK: avoid converting Message-Id: headers */
if (bp->header && bp->parsedheader
&& !strncasecmp(bp->line, "Message-Id:", 11)
&& use_mailcommand) {
/* we desactivate it just during this conversion */
use_mailcommand = 0;
ConvURLs(fp, sp, id, subject);
use_mailcommand = 1;
}
else
ConvURLs(fp, sp, id, subject);
/*
* Determine whether we should break.
* We could check for leading spaces
* or quote lines, but in general,
* non-alphanumeric lines should be
* broken before.
*/
if ((set_showbr && !bp->header) ||
((bp->next != NULL) &&
!isalnum(bp->next->line[0]))) fprintf(fp, "
");
if (!bp->header) {
fprintf(fp, "\n");
}
}
}
}
else if ((bp->line)[0] != '\0') {
/* JK: avoid converting Message-Id: headers */
if (bp->header && bp->parsedheader
&& !strncasecmp(bp->line, "Message-Id:", 11)
&& use_mailcommand) {
/* we desactivate it just during this conversion */
use_mailcommand = 0;
ConvURLs(fp, bp->line, id, subject);
use_mailcommand = 1;
}
else
ConvURLs(fp, bp->line, id, subject);
}
if (!isquote(bp->line))
inquote = 0;
bp = bp->next;
}
if (pre)
fprintf(fp, "
\n");
else if (set_showhtml == 2)
end_txt2html(fp);
printcomment(fp, "body", "end");
if (set_showhr)
fprintf(fp, "
\n");
}
char *
print_leading_whitespace(FILE *fp, char *sp)
{
while (*sp && (*sp == ' ' || *sp == '\t')) {
if (*sp == '\t')
fprintf(fp, " ");
else
fprintf(fp, " ");
sp++;
}
return sp;
}
/*
* Perform deletions on old messages when run in incremental mode.
*/
void update_deletions(int num_old)
{
struct hmlist *tlist;
struct reply *rp;
int save_ov = set_overwrite;
set_overwrite = TRUE;
for (tlist = set_delete_msgnum; tlist != NULL; tlist = tlist->next) {
struct emailinfo *ep;
int num = atoi(tlist->val);
if (num >= num_old)
continue; /* new message - already done */
if (hashnumlookup(num, &ep)) {
char *filename = articlehtmlfilename(ep);
if (set_delete_level != DELETE_REMOVES_FILES)
writearticles(num, num + 1);
else if (isfile(filename)) {
unlink(filename);
}
free(filename);
#ifdef FASTREPLYCODE
for (rp = ep->replylist; rp != NULL; rp = rp->next) {
#else
for (rp = replylist; rp != NULL; rp = rp->next) {
#endif
int rnum = rp->data->msgnum;
if (rnum < num_old) {
if (!rp->data->bodylist || !rp->data->bodylist->line[0])
parse_old_html(rnum, rp->data, TRUE, FALSE, NULL);
writearticles(rnum, rnum + 1);/* update MSG_IN_REPLY_TO line */
}
}
}
}
set_overwrite = save_ov;
}
/*
** Printing...the other main part of this program!
** This writes out the articles, beginning with the number startnum.
*/
void writearticles(int startnum, int maxnum)
{
int num, skip, subjmatch, newfile;
int is_reply = 0;
int maybe_reply = 0;
struct emailinfo *old_reply_to = NULL;
struct emailinfo *email;
struct emailinfo *email2;
struct emailinfo *email_next_in_thread;
struct body *bp;
struct reply *rp;
FILE *fp;
char *ptr;
#ifdef GDBM
/* A gdbm hack for avoiding opening all the message files to
* get the header comments; see parse.c for details thereof. */
char indexname[MAXFILELEN];
static GDBM_FILE gp;
if(set_usegdbm) {
sprintf(indexname, (set_dir[strlen(set_dir)-1] == '/')
? "%s%s" : "%s/%s",
set_dir, GDBM_INDEX_NAME);
/* open the database, creating it if necessary */
if(!(gp = gdbm_open(indexname, 0, GDBM_WRCREAT, 0664, 0))) {
if (set_folder_by_date && set_increment && !is_empty_archive()) {
sprintf(errmsg, "Cannot open or create file \"%s\". Unable to "
"do\nincremental updates with the folder_by_date "
"option without using that file.", indexname);
progerr(errmsg);
}
/* couldn't open; unlink it rather than risk running
* with an inconsistent version; it will be recreated if
* necessary */
unlink(indexname);
}
}
#endif
num = startnum;
if (set_showprogress)
printf("%s \"%s\"... ", lang[MSG_WRITING_ARTICLES], set_dir);
while (num < maxnum) {
char *filename;
if ((bp = hashnumlookup(num, &email)) == NULL) {
++num;
continue;
}
filename = articlehtmlfilename(email);
/*
* Determine to overwrite files or not
*/
if (isfile(filename))
newfile = 0;
else
newfile = 1;
is_reply = 0;
set_new_reply_to(-1, -1);
skip = 0;
if (email->is_deleted && set_delete_level == DELETE_REMOVES_FILES) {
if (!newfile) {
unlink(filename);
}
#ifdef GDBM
else if(gp) {
togdbm((void *) gp, email);
}
#endif
++num;
free(filename);
continue;
}
else if (!newfile && !set_overwrite
&& !(email->is_deleted && set_delete_msgnum)) {
skip = 1; /* is this really necessary with continue ??? */
num++;
free(filename);
continue;
}
else {
if ((fp = fopen(filename, "w")) == NULL) {
sprintf(errmsg, "%s \"%s\".", lang[MSG_COULD_NOT_WRITE],
filename);
progerr(errmsg);
}
}
email_next_in_thread = nextinthread(email->msgnum);
/*
* Create the comment fields necessary for incremental updating
*/
print_msg_header(fp, set_label,
email->subject, set_dir,
email->name, email->emailaddr, email->msgid,
email->charset, filename);
printcomment(fp, "received", email->fromdatestr);
printcomment(fp, "isoreceived", secs_to_iso(email->fromdate));
printcomment(fp, "sent", email->datestr);
printcomment(fp, "isosent", secs_to_iso(email->date));
printcomment(fp, "name", email->name);
printcomment(fp, "email", email->emailaddr);
printcomment(fp, "subject", ptr = convchars(email->subject));
if (ptr)
free(ptr);
printcomment(fp, "id", email->msgid);
printcomment(fp, "charset", email->charset);
printcomment(fp, "inreplyto", ptr = convchars(email->inreplyto));
if (email->is_deleted) {
char num_buf[32];
sprintf(num_buf, "%d", email->is_deleted);
printcomment(fp, "isdeleted", num_buf);
}
printcomment(fp, "expires", email->exp_time == -1 ? "-1"
: secs_to_iso(email->exp_time));
#ifdef GDBM
if(gp) {
togdbm((void *) gp, email);
}
#endif
if (ptr)
free(ptr);
if (set_usetable) {
fprint_menu(fp, NO_INDEX, "",
email->msgid, email->subject, PAGE_TOP, email->subdir);
}
/*
* Print the message's author info and date.
*/
fprintf(fp, "\n");
if (!strcmp(email->name, email->emailaddr)) {
if (use_mailcommand) {
ptr = makemailcommand(set_mailcommand,
email->emailaddr,
email->msgid, email->subject);
fprintf(fp, "%s: ", lang[MSG_FROM], ptr ? ptr : "");
if (ptr)
free(ptr);
fprintf(fp, "%s
\n", email->name);
}
else
fprintf(fp, "%s
\n", email->name);
}
else {
if (use_mailcommand && strcmp(email->emailaddr,"(no email)")!=0) {
ptr = makemailcommand(set_mailcommand,
email->emailaddr,
email->msgid, email->subject);
fprintf(fp, "%s: %s (",
lang[MSG_FROM], email->name, ptr ? ptr : "");
if (ptr)
free(ptr);
fprintf(fp, "%s)
\n", email->emailaddr);
}
else
{
fprintf(fp,
"%s: %s (%s)
\n",
lang[MSG_FROM], email->name,
(strcmp(email->emailaddr,"(no email)")!=0) ? email->emailaddr : "no email");
}
}
fprintf(fp, "%s: %s\n", lang[MSG_CDATE],
getdatestr(email->date));
fprintf(fp, "
\n");
/*
* This is here because it looks better here. The table looks
* better before the Author info. This stuff should be in
* printfile() so it could be laid out as the user wants...
*/
/*
* Should we print message links ?
*/
if (set_show_msg_links && set_show_msg_links != 4) {
printcomment(fp, "next", "start");
fprintf(fp, "\n here */ fprintf(fp, "
%s", email->msgnum, set_txtsuffix, lang[MSG_TXT_VERSION]); } printfooter(fp, mhtmlfooterfile, set_label, set_dir, email->subject, filename); fclose(fp); if (get_new_reply_to() != -1) { /* will only be true if set_linkquotes is */ struct emailinfo *e3, *e4; int was_correct = 0; replace_maybe_replies(filename, email, get_new_reply_to()); for (rp = replylist; rp != NULL; rp = rp->next) { /* get rid of old guesses for where this links */ if (rp->msgnum == num) { #ifdef FASTREPLYCODE struct reply *rp3; was_correct = (rp->frommsgnum == get_new_reply_to()); if (was_correct) break; hashnumlookup(get_new_reply_to(), &e4); hashnumlookup(rp->frommsgnum, &e3); for (rp3 = e3->replylist; rp3 != NULL && rp3->next != NULL; rp3 = rp3->next) { if (rp3->next->msgnum == num) { rp3->next = rp3->next->next; /* remove */ } } e4->replylist = addreply(e4->replylist, e4->msgnum, email, 0, NULL); #endif rp->frommsgnum = get_new_reply_to(); rp->maybereply = 0; break; /* revisit me */ } } if (!rp) { if(hashnumlookup(num, &e3)) { #ifdef FASTREPLYCODE hashnumlookup(get_new_reply_to(), &e4); replylist = addreply2(replylist, e4, e3, 0, &replylist_end); #else replylist = addreply(replylist, get_new_reply_to(), e3, 0, &replylist_end); #endif } } if (!was_correct) fixreplyheader(set_dir, num, TRUE, num); } if (newfile && chmod(filename, set_filemode) == -1) { sprintf(errmsg, "%s \"%s\": %o.", lang[MSG_CANNOT_CHMOD], filename, set_filemode); progerr(errmsg); } if (maxnum && !(num % 5) && set_showprogress) { printf("\b\b\b\b%03.0f%c", ((float)num / (float)maxnum) * 100, '%'); fflush(stdout); } free(filename); num++; } #ifdef GDBM if(gp) { datum key; datum content; int nkey = -1; char num_buf[32]; key.dsize = sizeof(nkey); /* the key -1 is for the last msgnum */ key.dptr = (char *) &nkey; sprintf(num_buf, "%d", max_msgnum); content.dsize = strlen(num_buf) + 1; content.dptr = num_buf; gdbm_store((GDBM_FILE) gp, key, content, GDBM_REPLACE); gdbm_close(gp); } #endif if (set_showprogress) printf("\b\b\b\b \n"); } /* end writearticles() */ /* ** Write the date index... ** If email != NULL, write index for the subdir in which that email is. */ void writedates(int amountmsgs, struct emailinfo *email) { int newfile; char *filename; FILE *fp; char *datename = index_name[email && email->subdir != NULL][DATE_INDEX]; filename = htmlfilename(datename, email, ""); if (isfile(filename)) newfile = 0; else newfile = 1; if ((fp = fopen(filename, "w")) == NULL) { sprintf(errmsg, "%s \"%s\".", lang[MSG_COULD_NOT_WRITE], filename); progerr(errmsg); } if (set_showprogress) printf("%s \"%s\"...", lang[MSG_WRITING_DATE_INDEX], filename); /* * Print out the index file header */ print_index_header(fp, set_label, set_dir, lang[MSG_BY_DATE], datename); /* * Print out archive information links at the top of the index */ if (!set_usetable) print_index_header_links(fp, DATE_INDEX, firstdatenum, lastdatenum, amountmsgs, email ? email->subdir : NULL); else { fprint_menu(fp, DATE_INDEX, set_archives, "", "", PAGE_TOP, email ? email->subdir : NULL); fprint_summary(fp, PAGE_TOP, firstdatenum, lastdatenum, amountmsgs); if (set_showhr) fprintf(fp, "
| %s | %s | %s |
| %s | %s | %s |
| %s | %s | %s |
| %s | %s | %s |
| %s | %s | %s |
| %s | %s | %s |
| "); else ++empties; } else { if (!started_line) { fprintf(fp, " | |||
| %s | %d %s | ", sd->description, sd->count, lang[MSG_ARTICLES]); while(empties--) fprintf(fp, ""); started_line = 1; } fprintf(fp, " | %s | ", sd->subdir, index_name[1][j], indextypename[j]); } } if (started_line && fp) fprintf(fp, "