Code cosmetic
[mmh] / uip / sendsbr.c
index c7f4d44..1534402 100644 (file)
@@ -103,7 +103,7 @@ sendsbr(char **vec, int vecp, char *drft, struct stat *st,
        ** and modified if desired.
        */
 
-       if (attachment_header_field_name != (char *)0) {
+       if (attachment_header_field_name != NULL) {
                switch (attach(attachment_header_field_name, drft,
                                attachformat)) {
                case OK:
@@ -167,7 +167,7 @@ sendsbr(char **vec, int vecp, char *drft, struct stat *st,
 
                if (strlen(composition_file_name) >=
                                sizeof (composition_file_name) - 6)
-                       advise((char *)0, "unable to remove original composition file.");
+                       advise(NULL, "unable to remove original composition file.");
 
                else {
                        if ((p = strrchr(composition_file_name, '/')) == NULL)
@@ -175,12 +175,12 @@ sendsbr(char **vec, int vecp, char *drft, struct stat *st,
                        else
                                p++;
 
-                       (void)strcpy(body_file_name, p);
+                       strcpy(body_file_name, p);
                        *p++ = ',';
-                       (void)strcpy(p, body_file_name);
-                       (void)strcat(p, ".orig");
+                       strcpy(p, body_file_name);
+                       strcat(p, ".orig");
 
-                       (void)unlink(composition_file_name);
+                       unlink(composition_file_name);
                }
        }
 
@@ -203,7 +203,7 @@ attach(char *attachment_header_field_name, char *draft_file_name,
        */
 
        if ((draft_file = fopen(draft_file_name, "r")) == (FILE *)0)
-               adios((char *)0, "can't open draft file `%s'.",
+               adios(NULL, "can't open draft file `%s'.",
                                draft_file_name);
 
        /*
@@ -257,11 +257,11 @@ attach(char *attachment_header_field_name, char *draft_file_name,
        ** Make names for the temporary files.
        */
 
-       (void)strncpy(body_file_name,
-                       m_mktemp(m_maildir(invo_name), NULL, NULL),
+       strncpy(body_file_name,
+                       m_mktemp(toabsdir(invo_name), NULL, NULL),
                        sizeof (body_file_name));
-       (void)strncpy(composition_file_name,
-                       m_mktemp(m_maildir(invo_name), NULL, NULL),
+       strncpy(composition_file_name,
+                       m_mktemp(toabsdir(invo_name), NULL, NULL),
                        sizeof (composition_file_name));
 
        if (has_body)
@@ -272,7 +272,7 @@ attach(char *attachment_header_field_name, char *draft_file_name,
        if ((has_body && body_file == (FILE *)0) ||
                        composition_file == (FILE *)0) {
                clean_up_temporary_files();
-               adios((char *)0, "unable to open all of the temporary files.");
+               adios(NULL, "unable to open all of the temporary files.");
        }
 
        /*
@@ -286,9 +286,9 @@ attach(char *attachment_header_field_name, char *draft_file_name,
        while (get_line() != EOF && *field != '\0' && *field != '-')
                if (strncasecmp(field, attachment_header_field_name, length)
                                != 0 || field[length] != ':')
-                       (void)fprintf(composition_file, "%s\n", field);
+                       fprintf(composition_file, "%s\n", field);
 
-       (void)fputs("--------\n", composition_file);
+       fputs("--------\n", composition_file);
 
        /*
        ** Copy the message body to a temporary file.
@@ -298,7 +298,7 @@ attach(char *attachment_header_field_name, char *draft_file_name,
                while ((c = getc(draft_file)) != EOF)
                                putc(c, body_file);
 
-               (void)fclose(body_file);
+               fclose(body_file);
        }
 
        /*
@@ -328,14 +328,14 @@ attach(char *attachment_header_field_name, char *draft_file_name,
                }
        }
 
-       (void)fclose(composition_file);
+       fclose(composition_file);
 
        /*
        ** We're ready to roll!  Run mhbuild on the composition file.
        ** Note that mhbuild is in the context as buildmimeproc.
        */
 
-       (void)sprintf(buf, "%s %s", buildmimeproc, composition_file_name);
+       sprintf(buf, "%s %s", buildmimeproc, composition_file_name);
 
        if (system(buf) != 0) {
                clean_up_temporary_files();
@@ -348,8 +348,8 @@ attach(char *attachment_header_field_name, char *draft_file_name,
 static void
 clean_up_temporary_files(void)
 {
-       (void)unlink(body_file_name);
-       (void)unlink(composition_file_name);
+       unlink(body_file_name);
+       unlink(composition_file_name);
 
        return;
 }
@@ -370,7 +370,7 @@ get_line(void)
 
        for (n = 0, p = field; (c = getc(draft_file)) != EOF; *p++ = c) {
                if (c == '\n' && (c = getc(draft_file)) != ' ' && c != '\t') {
-                       (void)ungetc(c, draft_file);
+                       ungetc(c, draft_file);
                        c = '\n';
                        break;
                }
@@ -400,7 +400,7 @@ make_mime_composition_file_entry(char *file_name, int attachformat)
        char *p;  /* miscellaneous string pointer */
        struct stat st;  /* file status buffer */
 
-       content_type = (char *)0;
+       content_type = NULL;
 
        /*
        ** Check the file name for a suffix.  Scan the context for that
@@ -411,7 +411,7 @@ make_mime_composition_file_entry(char *file_name, int attachformat)
        ** the field, including the dot.
        */
 
-       if ((p = strrchr(file_name, '.')) != (char *)0) {
+       if ((p = strrchr(file_name, '.')) != NULL) {
                for (np = m_defs; np; np = np->n_next) {
                        if (strncasecmp(np->n_name, "mhshow-suffix-", 14) == 0
                                        && mh_strcasecmp(p, np->n_field) == 0)
@@ -429,10 +429,10 @@ make_mime_composition_file_entry(char *file_name, int attachformat)
        ** content type based on this check.
        */
 
-       if (content_type == (char *)0) {
+       if (content_type == NULL) {
                if ((fp = fopen(file_name, "r")) == (FILE *)0) {
                        clean_up_temporary_files();
-                       adios((char *)0, "unable to access file \"%s\"",
+                       adios(NULL, "unable to access file \"%s\"",
                                        file_name);
                }
 
@@ -445,7 +445,7 @@ make_mime_composition_file_entry(char *file_name, int attachformat)
                        }
                }
 
-               (void)fclose(fp);
+               fclose(fp);
 
                content_type = binary ?
                                "application/octet-stream" : "text/plain";
@@ -461,28 +461,28 @@ make_mime_composition_file_entry(char *file_name, int attachformat)
 
        if (stat(file_name, &st) == -1 || access(file_name, R_OK) != 0) {
                clean_up_temporary_files();
-               adios((char *)0, "unable to access file \"%s\"", file_name);
+               adios(NULL, "unable to access file \"%s\"", file_name);
        }
 
        switch (attachformat) {
        case 0:
                /* Insert name, file mode, and Content-Id. */
-               (void)fprintf(composition_file,
+               fprintf(composition_file,
                                "#%s; name=\"%s\"; x-unix-mode=0%.3ho",
                                content_type, ((p = strrchr(file_name, '/'))
-                               == (char *)0) ? file_name : p + 1,
+                               == NULL) ? file_name : p + 1,
                                (unsigned short)(st.st_mode & 0777));
 
                if (strlen(file_name) > MAXPATHLEN) {
                        clean_up_temporary_files();
-                       adios((char *)0, "attachment file name `%s' too long.",
+                       adios(NULL, "attachment file name `%s' too long.",
                                        file_name);
                }
 
-               (void)sprintf(cmd, "file '%s'", file_name);
+               sprintf(cmd, "file '%s'", file_name);
 
                if ((fp = popen(cmd, "r")) != (FILE *)0 &&
-                               fgets(cmd, sizeof (cmd), fp) != (char *)0) {
+                               fgets(cmd, sizeof (cmd), fp) != NULL) {
                        *strchr(cmd, '\n') = '\0';
 
                        /*
@@ -505,14 +505,14 @@ make_mime_composition_file_entry(char *file_name, int attachformat)
 
                        if (*p != '\0')
                                /* Insert Content-Description. */
-                               (void)fprintf(composition_file, " [ %s ]", p);
+                               fprintf(composition_file, " [ %s ]", p);
 
-                       (void)pclose(fp);
+                       pclose(fp);
                }
 
                break;
        case 1:
-               if (stringdex(m_maildir(invo_name), file_name) == 0) {
+               if (stringdex(toabsdir(invo_name), file_name) == 0) {
                        /*
                        ** Content had been placed by send into a temp file.
                        ** Don't generate Content-Disposition header, because
@@ -528,13 +528,13 @@ make_mime_composition_file_entry(char *file_name, int attachformat)
                        fprintf(composition_file,
                                "#%s; name=\"%s\" <>{attachment}",
                                content_type,
-                               ((p = strrchr(file_name, '/')) == (char *)0) ?
+                               ((p = strrchr(file_name, '/')) == NULL) ?
                                file_name : p + 1);
                }
 
                break;
        case 2:
-               if (stringdex(m_maildir(invo_name), file_name) == 0) {
+               if (stringdex(toabsdir(invo_name), file_name) == 0) {
                        /*
                        ** Content had been placed by send into a temp file.
                        ** Don't generate Content-Disposition header, because
@@ -550,20 +550,20 @@ make_mime_composition_file_entry(char *file_name, int attachformat)
                        fprintf(composition_file,
                                "#%s; name=\"%s\" <>{attachment; modification-date=\"%s\"}",
                                content_type,
-                               ((p = strrchr(file_name, '/')) == (char *)0) ?
+                               ((p = strrchr(file_name, '/')) == NULL) ?
                                file_name : p + 1, dtime(&st.st_mtime, 0));
                }
 
                break;
        default:
-               adios((char *)0, "unsupported attachformat %d", attachformat);
+               adios(NULL, "unsupported attachformat %d", attachformat);
        }
 
        /*
        ** Finish up with the file name.
        */
 
-       (void)fprintf(composition_file, " %s\n", file_name);
+       fprintf(composition_file, " %s\n", file_name);
 
        return;
 }
@@ -709,7 +709,7 @@ alert(char *file, int out)
                        snprintf(buf, sizeof(buf), "send failed on %s",
                                        forwsw ? "enclosed draft" : file);
 
-                       execlp(mailproc, r1bindex(mailproc, '/'),
+                       execlp(mailproc, mhbasename(mailproc),
                                        getusername(), "-subject", buf, NULL);
                        fprintf(stderr, "unable to exec ");
                        perror(mailproc);
@@ -806,7 +806,7 @@ annoaux(int fd)
                        admonish(NULL, "$mhfolder not set");
                return;
        }
-       maildir = m_maildir(folder);
+       maildir = toabsdir(folder);
        if (chdir(maildir) == NOTOK) {
                if (debugsw)
                        admonish(maildir, "unable to change directory to");