Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions docs/hmrc.html
Original file line number Diff line number Diff line change
Expand Up @@ -1301,9 +1301,7 @@ <h3><a name="sysmisc" id="sysmisc">System miscellaneous</a></h3>
<i>append = 1</i></dd>
<dd><a name="append_filename" id="append_filename"></a></dd>
<dt><strong>append_filename = [ string ]</strong></dt>
<dd>Specifies the filename to be used by the append option. $DIR
may be used to specify a name relative to the directory specified
in the -d or dir option.<br>
<dd>Specifies the filename to be used by the append option. $DIR may be used to specify a name relative to the directory specified in the -d or dir option. The string will be passed to strftime(3) to allow splitting the mailbox into yearly or monthy files, such as "%Y-%m.mbox". <br>
<br>
<i>append_filename = $DIR/INBOX</i></dd>
<dd><a name="txtsuffix" id="txtsuffix"></a></dd>
Expand Down
2 changes: 1 addition & 1 deletion src/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ CPPFLAGS=@CPPFLAGS@ @INCLUDES@
YACC=@YACC@
NETLIBS=@LIBS@
LDFLAGS=@LDFLAGS@
MISC_LIBS= -lm -lpcre -ltrio
MISC_LIBS= -lpcre -ltrio -lm
OPT_LIBS=@EXTRA_LIBS@

INCS= domains.h hypermail.h lang.h proto.h \
Expand Down
35 changes: 24 additions & 11 deletions src/parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -1531,6 +1531,7 @@ int parsemail(char *mbox, /* file name */
int num, isinheader, hassubject, hasdate;
int num_added = 0;
long exp_time = -1;
time_t curtime;
time_t delete_older_than = (set_delete_older ? convtoyearsecs(set_delete_older) : 0);
time_t delete_newer_than = (set_delete_newer ? convtoyearsecs(set_delete_newer) : 0);
annotation_robot_t annotation_robot = ANNOTATION_ROBOT_NONE;
Expand All @@ -1541,6 +1542,8 @@ int parsemail(char *mbox, /* file name */
int require_filter_len, require_filter_full_len;
struct hmlist *tlist;
char filename[MAXFILELEN];
char directory[MAXFILELEN];
char pathname[MAXFILELEN];
struct emailinfo *emp;
char *att_dir = NULL; /* directory name to store attachments in */
char *meta_dir = NULL; /* directory name where we're storing the meta data
Expand Down Expand Up @@ -1655,21 +1658,31 @@ int parsemail(char *mbox, /* file name */
if(set_append) {

/* add to an mbox as we read */

if(set_append_filename && strncmp(set_append_filename, "$DIR/", 5)) {
if(strlen(set_append_filename) >= sizeof(filename))
progerr("append_filename too long");
strcpy(filename, set_append_filename);
*directory = 0;
*filename = 0;
*pathname = 0;
if (set_append_filename) {
time(&curtime);
if(strncmp(set_append_filename, "$DIR/", 5) == 0) {
strncpy(directory, dir, MAXFILELEN - 1);
strftime(filename, MAXFILELEN - 1, set_append_filename+5,
localtime(&curtime));
} else {
strftime(filename, MAXFILELEN - 1, set_append_filename,
localtime(&curtime));
}
} else {
strncpy(directory, dir, MAXFILELEN - 1);
strncpy(filename, "mbox", MAXFILELEN - 1);
}
else if(trio_snprintf(filename, sizeof(filename), "%s%s", dir,
set_append_filename ? set_append_filename + 5
: "mbox")
== sizeof(filename)) {

if(trio_snprintf(pathname, sizeof(pathname), "%s%s", directory,
filename) == sizeof(pathname)) {
progerr("Can't build mbox filename");
}
if(!(fpo = fopen(filename, "a"))) {
if(!(fpo = fopen(pathname, "a"))) {
trio_snprintf(errmsg, sizeof(errmsg), "%s \"%s\".",
lang[MSG_CANNOT_OPEN_MAIL_ARCHIVE], filename);
lang[MSG_CANNOT_OPEN_MAIL_ARCHIVE], pathname);
progerr(errmsg);
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,9 @@ struct Config cfg[] = {
{"append_filename", &set_append_filename, NULL, CFG_STRING,
"# Specifies the filename to be used by the append option.\n"
"# $DIR may be used to specify a name relative to the directory\n"
"# specified in the -d or dir option.\n", FALSE},
"# specified in the -d or dir option.\n"
"# The string will be passed to strftime(3) to allow splitting the\n"
"# mailbox into yearly or monthy files, such as \"%Y-%m.mbox\".\n" , FALSE},

{"nonsequential", &set_nonsequential, BFALSE, CFG_SWITCH,
"# Set this to On to generate filenames that are not sequential, but\n"
Expand Down