Completely removed the backup-prefix (,). We move to +trash instead.
authormarkus schnalke <meillo@marmaro.de>
Thu, 28 Jun 2012 22:20:45 +0000 (00:20 +0200)
committermarkus schnalke <meillo@marmaro.de>
Thu, 28 Jun 2012 22:20:45 +0000 (00:20 +0200)
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.

15 files changed:
config/config.c
h/mh.h
man/mh-profile.man5
man/mhbuild.man1
man/send.man1
sbr/Makefile.in
sbr/folder_read.c
sbr/m_backup.c [deleted file]
sbr/readconfig.c
uip/distsbr.c
uip/mhbuild.c
uip/mhparam.c
uip/rmf.c
uip/send.c
uip/spost.c

index cfd5fe5..935c92d 100644 (file)
@@ -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";
 ** 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 (file)
--- 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;
 ** on any system.
 */
 extern char *attach_hdr;
-extern char *backup_prefix;
 extern char *components;
 extern char *context;
 extern char *curfolder;
 extern char *components;
 extern char *context;
 extern char *curfolder;
index 8d36895..a3f5ae2 100644 (file)
@@ -173,18 +173,6 @@ to send mail.
 (profile, default: %sendmailpath%)
 .RE
 .PP
 (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
 .BR Attachment-Header :
 Attach
 .RS 5
index 5545fff..62d01be 100644 (file)
@@ -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
 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.
 recover the
 .B mhbuild
 input file.
index b2c2cf4..34c4a22 100644 (file)
@@ -83,9 +83,8 @@ Consult the
 man page for more information.
 .PP
 Once the transport system has successfully accepted custody of 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.
 .B send
 will abort with a
 (hopefully) helpful error message.
index f7cd8d3..c6801b3 100644 (file)
@@ -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  \
        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  \
        m_convert.c m_draft.c m_getfld.c m_gmprot.c  \
        m_name.c \
        makedir.c mts.c norm_charmap.c  \
index 35dc195..4265763 100644 (file)
@@ -24,7 +24,7 @@
 struct msgs *
 folder_read(char *name)
 {
 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;
        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);
 
        if (access(name, W_OK) == -1)
                set_readonly(mp);
-       prefix_len = strlen(backup_prefix);
 
        /*
        ** Allocate a temporary place to record the
 
        /*
        ** Allocate a temporary place to record the
@@ -106,14 +105,6 @@ folder_read(char *name)
 
                        default:
                                /*
 
                        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
                                */
                                ** indicate that there are other
                                ** files in folder
                                */
diff --git a/sbr/m_backup.c b/sbr/m_backup.c
deleted file mode 100644 (file)
index bdb0e86..0000000
+++ /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 <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;
-}
index fe7b486..1b00bf9 100644 (file)
@@ -19,7 +19,6 @@ static struct procstr procs[] = {
        { "attachment-header",  &attach_hdr },
        { "context",       &context },
        { "mh-sequences",  &mh_seq },
        { "attachment-header",  &attach_hdr },
        { "context",       &context },
        { "mh-sequences",  &mh_seq },
-       { "backup-prefix", &backup_prefix },
        { "draft-folder",  &draftfolder },
        { "listproc",      &listproc },
        { "sendmail",      &sendmail },
        { "draft-folder",  &draftfolder },
        { "listproc",      &listproc },
        { "sendmail",      &sendmail },
index 1ad8e42..a9a52b1 100644 (file)
@@ -27,7 +27,8 @@ distout(char *drft, char *msgnam, char *backup)
        char name[NAMESZ], buffer[BUFSIZ];
        register FILE *ifp, *ofp;
 
        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"))) {
                adios(backup, "unable to rename %s to",drft);
        }
        if (!(ifp = fopen(backup, "r"))) {
index b22c137..5ad0fc1 100644 (file)
@@ -268,7 +268,7 @@ main(int argc, char **argv)
        fclose(fp_out);
 
        /* Rename composition draft */
        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);
        }
        if (rename(compfile, buffer) == NOTOK) {
                adios(buffer, "unable to rename draft %s to", compfile);
        }
index a339945..87b4d17 100644 (file)
@@ -46,7 +46,6 @@ static struct proc procs [] = {
        { "version",       &version_num },
        { "whatnowproc",   &whatnowproc },
        { "etcdir",        &mhetcdir },
        { "version",       &version_num },
        { "whatnowproc",   &whatnowproc },
        { "etcdir",        &mhetcdir },
-       { "backup-prefix", &backup_prefix },
        { "draft-folder",  &draftfolder },
        { "trash-folder",  &trashfolder },
        { NULL,            NULL },
        { "draft-folder",  &draftfolder },
        { "trash-folder",  &trashfolder },
        { NULL,            NULL },
index 05b3e96..a0c68a3 100644 (file)
--- a/uip/rmf.c
+++ b/uip/rmf.c
@@ -125,7 +125,7 @@ main(int argc, char **argv)
 static int
 rmf(char *folder)
 {
 static int
 rmf(char *folder)
 {
-       int i, j, others;
+       int i, others;
        register char *maildir;
        char cur[BUFSIZ];
        register struct dirent *dp;
        register char *maildir;
        char cur[BUFSIZ];
        register struct dirent *dp;
@@ -159,7 +159,6 @@ rmf(char *folder)
 
        ext_hook("del-hook", maildir, NULL);
 
 
        ext_hook("del-hook", maildir, NULL);
 
-       j = strlen(backup_prefix);
        while ((dp = readdir(dd))) {
                switch (dp->d_name[0]) {
                case '.':
        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;
                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);
 
                        admonish(NULL, "file \"%s/%s\" not deleted",
                                        folder, dp->d_name);
index 5e1f0a1..0660e95 100644 (file)
@@ -232,7 +232,6 @@ sendsbr(char **vec, int vecp, char *drft, struct stat *st)
        int status;
        char buffer[BUFSIZ];
        char *original_draft;
        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
 
        /*
        ** 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;
        switch (setjmp(env)) {
        case OK:
                status = sendaux(vec, vecp, drft, st) ? NOTOK : OK;
-               /* rename the original draft */
                if (status == OK) {
                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;
                        }
                }
                break;
@@ -286,31 +286,9 @@ sendsbr(char **vec, int vecp, char *drft, struct stat *st)
                unlink(distfile);
        }
 
                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 (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;
        }
 
        return status;
@@ -447,6 +425,11 @@ attach(char *draft_file_name)
                clean_up_temporary_files();
                return (NOTOK);
        }
                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);
 }
 
        return (OK);
 }
index da02d27..de4a6d2 100644 (file)
@@ -625,11 +625,6 @@ process_bccs(char *origmsg)
        FILE *out = NULL;
 
        for (mp=bccs; mp; mp=mp->m_next) {
        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 : "");
                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);
                }
                                        mp->m_text);
                        unlink(bccdraft);
                }
-               /* TODO: unlink renamed bcc draft after send(1) */
        }
 }
        }
 }