Layouting and comment changes. (minor stuff)
[mmh] / uip / sendsbr.c
index 9c335bd..89a0748 100644 (file)
@@ -30,7 +30,6 @@ int debugsw = 0;  /* global */
 int forwsw  = 1;
 int inplace = 1;
 int pushsw  = 0;
-int unique  = 0;
 int verbsw  = 0;
 
 char *altmsg   = NULL;  /*  .. */
@@ -79,7 +78,7 @@ int
 sendsbr(char **vec, int vecp, char *drft, struct stat *st, int rename_drft)
 {
        int status;
-       char buffer[BUFSIZ], file[BUFSIZ];
+       char buffer[BUFSIZ];
        char *original_draft;  /* name of original draft file */
        char *p;  /* string pointer for building file name */
 
@@ -115,23 +114,7 @@ sendsbr(char **vec, int vecp, char *drft, struct stat *st, int rename_drft)
        done=armed_done;
        switch (setjmp(env)) {
        case OK:
-               /*
-               ** If given -push and -unique (which is undocumented), then
-               ** rename the draft file.  I'm not quite sure why.
-               */
-               if (pushsw && unique) {
-                       char *cp = m_mktemp2(drft, invo_name, NULL, NULL);
-                       if (cp == NULL) {
-                               adios("sendsbr", "unable to create temporary file");
-                       }
-                       if (rename(drft, strncpy(file, cp, sizeof(file)))
-                                       == NOTOK)
-                               adios(file, "unable to rename %s to", drft);
-                       drft = file;
-               }
-
                status = sendaux(vec, vecp, drft, st) ? NOTOK : OK;
-
                /* rename the original draft */
                if (rename_drft && status == OK &&
                                rename(original_draft, strncpy(buffer,
@@ -214,15 +197,16 @@ attach(char *draft_file_name)
 
        has_attachment = 0;
 
-       while (get_line() != EOF && *field != '\0' && *field != '-')
+       while (get_line() != EOF && *field != '\0' && *field != '-') {
                if (strncasecmp(field, attach_hdr, length) == 0 &&
-                               field[length] == ':')
+                               field[length] == ':') {
                        has_attachment = 1;
+               }
+       }
 
        /*
-       ** We have at least one attachment.  Look for at least one
-       ** non-blank line in the body of the message which indicates
-       ** content in the body.
+       ** Look for at least one non-blank line in the body of the
+       ** message which indicates content in the body.
        ** Check if body contains at least one non-blank (= not empty)
        ** and if it contains any non-ASCII chars (= need MIME).
        */
@@ -267,8 +251,7 @@ attach(char *draft_file_name)
 
        composition_file = fopen(composition_file_name, "w");
 
-       if ((has_body && body_file == (FILE *)0) ||
-                       composition_file == (FILE *)0) {
+       if ((has_body && !body_file) || !composition_file) {
                clean_up_temporary_files();
                adios(NULL, "unable to open all of the temporary files.");
        }
@@ -279,27 +262,22 @@ attach(char *draft_file_name)
        ** Then add the dashed line separator.
        */
        rewind(draft_file);
-       while (get_line() != EOF && *field != '\0' && *field != '-')
+       while (get_line() != EOF && *field && *field != '-') {
                if (strncasecmp(field, attach_hdr, length) != 0 ||
-                               field[length] != ':')
+                               field[length] != ':') {
                        fprintf(composition_file, "%s\n", field);
+               }
+       }
        fputs("--------\n", composition_file);
 
-       /*
-       ** Copy the message body to a temporary file.
-       */
        if (has_body) {
-               while ((c = getc(draft_file)) != EOF)
-                               putc(c, body_file);
+               /* Copy the message body to the temporary file. */
+               while ((c = getc(draft_file)) != EOF) {
+                       putc(c, body_file);
+               }
                fclose(body_file);
-       }
 
-       /*
-       ** Add a mhbuild MIME composition file line for the body if
-       ** there was one.
-       */
-       if (has_body) {
-               /* old: make_mime_composition_file_entry(body_file_name); */
+               /* Add a mhbuild MIME composition file line for the body */
                /* charset will be discovered/guessed by buildmimeproc */
                fprintf(composition_file, "#text/plain %s\n", body_file_name);
        }
@@ -310,7 +288,7 @@ attach(char *draft_file_name)
        ** composition file for each.
        */
        rewind(draft_file);
-       while (get_line() != EOF && *field != '\0' && *field != '-') {
+       while (get_line() != EOF && *field && *field != '-') {
                if (strncasecmp(field, attach_hdr, length) == 0 &&
                                field[length] == ':') {
                        for (p = field+length+1; *p==' ' || *p=='\t'; p++) {
@@ -396,6 +374,7 @@ make_mime_composition_file_entry(char *file_name)
 
        content_type = NULL;
 
+       
        /*
        ** Check the file name for a suffix.  Scan the context for that
        ** suffix on a mhshow-suffix- entry.  We use these entries to
@@ -495,20 +474,14 @@ sendaux(char **vec, int vecp, char *drft, struct stat *st)
 {
        pid_t child_id;
        int i, status, fd, fd2;
-       char backup[BUFSIZ], buf[BUFSIZ];
+       char backup[BUFSIZ];
 
        fd = pushsw ? tmp_fd() : NOTOK;
        fd2 = NOTOK;
 
        vec[vecp++] = drft;
-       if (annotext) {
-               if ((fd2 = tmp_fd()) != NOTOK) {
-                       vec[vecp++] = "-idanno";
-                       snprintf(buf, sizeof(buf), "%d", fd2);
-                       vec[vecp++] = buf;
-               } else {
-                       admonish(NULL, "unable to create file for annotation list");
-               }
+       if (annotext && (fd2 = tmp_fd()) == NOTOK) {
+               admonish(NULL, "unable to create file for annotation list");
        }
        if (distfile && distout(drft, distfile, backup) == NOTOK)
                done(1);
@@ -785,7 +758,7 @@ annoaux(int fd)
                if (is_selected(mp, msgnum)) {
                        if (debugsw)
                                advise(NULL, "annotate message %d", msgnum);
-                       annotate(m_name (msgnum), annotext, cp, inplace,
+                       annotate(m_name(msgnum), annotext, cp, inplace,
                                        1, -2, 0);
                }
        }