From: markus schnalke Date: Thu, 28 Jun 2012 22:20:45 +0000 (+0200) Subject: Completely removed the backup-prefix (,). We move to +trash instead. X-Git-Tag: mmh-thesis-end~16 X-Git-Url: http://git.marmaro.de/?a=commitdiff_plain;h=ca0b3e830b86700d9e5e31b1784de2bdcaf58fc5;p=mmh Completely removed the backup-prefix (,). We move to +trash instead. mhbuild does not create `,foo.orig' but `foo.orig' now. Maybe it should move the file to +trash as well ... this is likely to be changed. Temporary files of bcc mails get removed now. --- diff --git a/config/config.c b/config/config.c index cfd5fe5..935c92d 100644 --- a/config/config.c +++ b/config/config.c @@ -150,14 +150,6 @@ char *mailspool = MAILSPOOL; */ /* -** 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"; diff --git a/h/mh.h b/h/mh.h index 37678db..bee5518 100644 --- a/h/mh.h +++ b/h/mh.h @@ -273,7 +273,6 @@ extern char *mailstore; /* name of mail storage directory */ ** on any system. */ extern char *attach_hdr; -extern char *backup_prefix; extern char *components; extern char *context; extern char *curfolder; diff --git a/man/mh-profile.man5 b/man/mh-profile.man5 index 8d36895..a3f5ae2 100644 --- a/man/mh-profile.man5 +++ b/man/mh-profile.man5 @@ -173,18 +173,6 @@ to send mail. (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 diff --git a/man/mhbuild.man1 b/man/mhbuild.man1 index 5545fff..62d01be 100644 --- a/man/mhbuild.man1 +++ b/man/mhbuild.man1 @@ -41,10 +41,11 @@ Otherwise if the file argument to 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. diff --git a/man/send.man1 b/man/send.man1 index b2c2cf4..34c4a22 100644 --- a/man/send.man1 +++ b/man/send.man1 @@ -83,9 +83,8 @@ Consult the 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. diff --git a/sbr/Makefile.in b/sbr/Makefile.in index f7cd8d3..c6801b3 100644 --- a/sbr/Makefile.in +++ b/sbr/Makefile.in @@ -54,7 +54,7 @@ SRCS = addrsbr.c ambigsw.c brkstring.c \ 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 \ diff --git a/sbr/folder_read.c b/sbr/folder_read.c index 35dc195..4265763 100644 --- a/sbr/folder_read.c +++ b/sbr/folder_read.c @@ -24,7 +24,7 @@ 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; @@ -57,7 +57,6 @@ folder_read(char *name) if (access(name, W_OK) == -1) set_readonly(mp); - prefix_len = strlen(backup_prefix); /* ** Allocate a temporary place to record the @@ -106,14 +105,6 @@ folder_read(char *name) 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 */ diff --git a/sbr/m_backup.c b/sbr/m_backup.c deleted file mode 100644 index bdb0e86..0000000 --- a/sbr/m_backup.c +++ /dev/null @@ -1,26 +0,0 @@ -/* -** 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 - - -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; -} diff --git a/sbr/readconfig.c b/sbr/readconfig.c index fe7b486..1b00bf9 100644 --- a/sbr/readconfig.c +++ b/sbr/readconfig.c @@ -19,7 +19,6 @@ static struct procstr procs[] = { { "attachment-header", &attach_hdr }, { "context", &context }, { "mh-sequences", &mh_seq }, - { "backup-prefix", &backup_prefix }, { "draft-folder", &draftfolder }, { "listproc", &listproc }, { "sendmail", &sendmail }, diff --git a/uip/distsbr.c b/uip/distsbr.c index 1ad8e42..a9a52b1 100644 --- a/uip/distsbr.c +++ b/uip/distsbr.c @@ -27,7 +27,8 @@ distout(char *drft, char *msgnam, char *backup) 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"))) { diff --git a/uip/mhbuild.c b/uip/mhbuild.c index b22c137..5ad0fc1 100644 --- a/uip/mhbuild.c +++ b/uip/mhbuild.c @@ -268,7 +268,7 @@ main(int argc, char **argv) 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); } diff --git a/uip/mhparam.c b/uip/mhparam.c index a339945..87b4d17 100644 --- a/uip/mhparam.c +++ b/uip/mhparam.c @@ -46,7 +46,6 @@ static struct proc procs [] = { { "version", &version_num }, { "whatnowproc", &whatnowproc }, { "etcdir", &mhetcdir }, - { "backup-prefix", &backup_prefix }, { "draft-folder", &draftfolder }, { "trash-folder", &trashfolder }, { NULL, NULL }, diff --git a/uip/rmf.c b/uip/rmf.c index 05b3e96..a0c68a3 100644 --- a/uip/rmf.c +++ b/uip/rmf.c @@ -125,7 +125,7 @@ main(int argc, char **argv) static int rmf(char *folder) { - int i, j, others; + int i, others; register char *maildir; char cur[BUFSIZ]; register struct dirent *dp; @@ -159,7 +159,6 @@ rmf(char *folder) ext_hook("del-hook", maildir, NULL); - j = strlen(backup_prefix); while ((dp = readdir(dd))) { switch (dp->d_name[0]) { case '.': @@ -173,8 +172,6 @@ rmf(char *folder) 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); diff --git a/uip/send.c b/uip/send.c index 5e1f0a1..0660e95 100644 --- a/uip/send.c +++ b/uip/send.c @@ -232,7 +232,6 @@ sendsbr(char **vec, int vecp, char *drft, struct stat *st) 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 @@ -266,12 +265,13 @@ sendsbr(char **vec, int vecp, char *drft, struct stat *st) 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, + "= - 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; @@ -447,6 +425,11 @@ attach(char *draft_file_name) 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); } diff --git a/uip/spost.c b/uip/spost.c index da02d27..de4a6d2 100644 --- a/uip/spost.c +++ b/uip/spost.c @@ -625,11 +625,6 @@ process_bccs(char *origmsg) 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 : ""); @@ -643,6 +638,5 @@ process_bccs(char *origmsg) mp->m_text); unlink(bccdraft); } - /* TODO: unlink renamed bcc draft after send(1) */ } }