*/
/*
-** The prefix that is prepended to the name of message files when they
-** are backup'd for some reason. send, for instance, does this.
-** Note: rmm does NOT anymore use the backup prefix.
-** It should typically be set to `,' or `#'.
-*/
-char *backup_prefix = ",";
-
-/*
** Folders (directories) are created with this protection (mode)
*/
char *foldprot = "0700";
** on any system.
*/
extern char *attach_hdr;
-extern char *backup_prefix;
extern char *components;
extern char *context;
extern char *curfolder;
(profile, default: %sendmailpath%)
.RE
.PP
-.BR Backup-Prefix :
-,
-.RS 5
-The prefix that is prepended to the name of message files when they
-are backup'd for some reason.
-.BR send ,
-for instance, does this.
-Note: rmm does NOT anymore use the backup prefix.
-It should typically be set to `,' or `#'.
-(profile, default: `,')
-.RE
-.PP
.BR Attachment-Header :
Attach
.RS 5
is the name of a valid
composition file, and the translation is successful,
.B mhbuild
-will replace the original file with the new MIME message. It will rename
-the original file to start with the `,' character and end with the
-string `.orig', e.g., if you are editing the file `draft',
-it will be renamed to `,draft.orig'. This allows you to easily
+will replace the original file with the new MIME message.
+It will preserve the original file under the same name with `.orig'
+appended.
+E.g., if you are editing the file `draft', its original contents
+it will be preserved as `draft.orig'. This allows you to easily
recover the
.B mhbuild
input file.
man page for more information.
.PP
Once the transport system has successfully accepted custody of the
-message, the message will be renamed with a leading comma, which allows
-it to be retrieved until the next draft message is sent. If there are
-errors in the formatting of the message,
+message, the message will be moved into the trash folder.
+If there are errors in the formatting of the message,
.B send
will abort with a
(hopefully) helpful error message.
folder_realloc.c gans.c getans.c getanswer.c \
getarguments.c getcpy.c getpass.c \
fmt_addr.c fmt_compile.c fmt_new.c fmt_rfc2047.c \
- fmt_scan.c lock_file.c m_atoi.c m_backup.c \
+ fmt_scan.c lock_file.c m_atoi.c \
m_convert.c m_draft.c m_getfld.c m_gmprot.c \
m_name.c \
makedir.c mts.c norm_charmap.c \
struct msgs *
folder_read(char *name)
{
- int msgnum, prefix_len, len, *mi;
+ int msgnum, len, *mi;
struct msgs *mp;
struct stat st;
struct dirent *dp;
if (access(name, W_OK) == -1)
set_readonly(mp);
- prefix_len = strlen(backup_prefix);
/*
** Allocate a temporary place to record the
default:
/*
- ** skip any files beginning with
- ** backup prefix
- */
- if (strncmp(dp->d_name, backup_prefix,
- prefix_len)==0)
- continue;
-
- /*
** indicate that there are other
** files in folder
*/
+++ /dev/null
-/*
-** m_backup.c -- construct a backup file
-**
-** This code is Copyright (c) 2002, by the authors of nmh. See the
-** COPYRIGHT file in the root directory of the nmh distribution for
-** complete copyright information.
-*/
-
-#include <h/mh.h>
-
-
-char *
-m_backup(char *file)
-{
- char *cp;
- static char buffer[BUFSIZ];
-
- if ((cp = mhbasename(file)) == file)
- snprintf(buffer, sizeof(buffer), "%s%s", backup_prefix, cp);
- else
- snprintf(buffer, sizeof(buffer), "%.*s%s%s", (int)(cp - file),
- file, backup_prefix, cp);
-
- unlink(buffer);
- return buffer;
-}
{ "attachment-header", &attach_hdr },
{ "context", &context },
{ "mh-sequences", &mh_seq },
- { "backup-prefix", &backup_prefix },
{ "draft-folder", &draftfolder },
{ "listproc", &listproc },
{ "sendmail", &sendmail },
char name[NAMESZ], buffer[BUFSIZ];
register FILE *ifp, *ofp;
- if (rename(drft, strcpy(backup, m_backup(drft))) == NOTOK) {
+ strcpy(backup, m_mktemp(toabsdir(invo_name), NULL, NULL));
+ if (rename(drft, backup) == NOTOK) {
adios(backup, "unable to rename %s to",drft);
}
if (!(ifp = fopen(backup, "r"))) {
fclose(fp_out);
/* Rename composition draft */
- snprintf(buffer, sizeof(buffer), "%s.orig", m_backup(compfile));
+ snprintf(buffer, sizeof(buffer), "%s.orig", compfile);
if (rename(compfile, buffer) == NOTOK) {
adios(buffer, "unable to rename draft %s to", compfile);
}
{ "version", &version_num },
{ "whatnowproc", &whatnowproc },
{ "etcdir", &mhetcdir },
- { "backup-prefix", &backup_prefix },
{ "draft-folder", &draftfolder },
{ "trash-folder", &trashfolder },
{ NULL, NULL },
static int
rmf(char *folder)
{
- int i, j, others;
+ int i, others;
register char *maildir;
char cur[BUFSIZ];
register struct dirent *dp;
ext_hook("del-hook", maildir, NULL);
- j = strlen(backup_prefix);
while ((dp = readdir(dd))) {
switch (dp->d_name[0]) {
case '.':
default:
if (m_atoi(dp->d_name))
break;
- if (strncmp(dp->d_name, backup_prefix, j) == 0)
- break;
admonish(NULL, "file \"%s/%s\" not deleted",
folder, dp->d_name);
int status;
char buffer[BUFSIZ];
char *original_draft;
- char *p; /* string pointer for building file name */
/*
** Save the original name of the draft file. The name of the
switch (setjmp(env)) {
case OK:
status = sendaux(vec, vecp, drft, st) ? NOTOK : OK;
- /* rename the original draft */
if (status == OK) {
- strncpy(buffer, m_backup(original_draft),
- sizeof(buffer));
- if (rename(original_draft, buffer) == NOTOK) {
- advise(buffer, "unable to rename %s to", drft);
+ /* move original draft to +trash folder */
+ snprintf(buffer, sizeof buffer,
+ "</dev/null refile -file %s +trash",
+ original_draft);
+ if (system(buffer) != 0) {
+ advise(NULL, "unable to trash the draft");
}
}
break;
unlink(distfile);
}
- /*
- ** Get rid of any temporary files that we created for attachments.
- ** Also get rid of the renamed composition file that mhbuild
- ** leaves as a turd. It looks confusing, but we use the body
- ** file name to help build the renamed composition file name.
- */
+ /* Get rid of temporary files that we created for attachments. */
if (drft == composition_file_name) {
clean_up_temporary_files();
-
- if (strlen(composition_file_name) >=
- sizeof (composition_file_name) - 6) {
- advise(NULL, "unable to remove original composition file.");
- } else {
- if (!(p = strrchr(composition_file_name, '/'))) {
- p = composition_file_name;
- } else {
- p++;
- }
- strcpy(body_file_name, p);
- *p++ = ',';
- strcpy(p, body_file_name);
- strcat(p, ".orig");
-
- unlink(composition_file_name);
- }
}
return status;
clean_up_temporary_files();
return (NOTOK);
}
+ /* Remove the automatically created backup of mhbuild. */
+ snprintf(buf, sizeof buf, "%s.orig", composition_file_name);
+ if (unlink(buf) == -1) {
+ advise(NULL, "unable to remove original composition file.");
+ }
return (OK);
}
FILE *out = NULL;
for (mp=bccs; mp; mp=mp->m_next) {
- /*
- ** Note: This draft file will be left existing by send(1),
- ** although renamed with backup prefix.
- ** TODO: We should have it removed eventually.
- */
bccdraft = getcpy(m_mktemp2("/tmp/", invo_name, NULL, &out));
fprintf(out, "To: %s\n", mp->m_text);
fprintf(out, "Subject: [BCC] %s", subject ? subject : "");
mp->m_text);
unlink(bccdraft);
}
- /* TODO: unlink renamed bcc draft after send(1) */
}
}