Relayouted all switch statements: case aligns with switch.
[mmh] / uip / sendsbr.c
index 8d85559..42c2c21 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)
@@ -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);
 
        /*
@@ -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.");
        }
 
        /*
@@ -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);
                }
 
@@ -461,7 +461,7 @@ 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) {
@@ -470,19 +470,19 @@ make_mime_composition_file_entry(char *file_name, int attachformat)
                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);
                }
 
                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';
 
                        /*
@@ -528,7 +528,7 @@ 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);
                }
 
@@ -550,13 +550,13 @@ 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);
        }
 
        /*
@@ -675,48 +675,48 @@ alert(char *file, int out)
                sleep(5);
 
        switch (child_id) {
-               case NOTOK:
-                       /* oops -- fork error */
-                       advise("fork", "unable to");
+       case NOTOK:
+               /* oops -- fork error */
+               advise("fork", "unable to");
 
-               case OK:
-                       /* child process -- send it */
-                       SIGNAL(SIGHUP, SIG_IGN);
-                       SIGNAL(SIGINT, SIG_IGN);
-                       SIGNAL(SIGQUIT, SIG_IGN);
-                       SIGNAL(SIGTERM, SIG_IGN);
-                       if (forwsw) {
-                               if ((in = open(file, O_RDONLY)) == NOTOK) {
-                                       admonish(file, "unable to re-open");
-                               } else {
-                                       lseek(out, (off_t) 0, SEEK_END);
-                                       strncpy(buf, "\nMessage not delivered to anyone.\n", sizeof(buf));
-                                       write(out, buf, strlen(buf));
-                                       strncpy(buf, "\n------- Unsent Draft\n\n", sizeof(buf));
-                                       write(out, buf, strlen(buf));
-                                       cpydgst(in, out, file, "temporary file");
-                                       close(in);
-                                       strncpy(buf, "\n------- End of Unsent Draft\n", sizeof(buf));
-                                       write(out, buf, strlen(buf));
-                                       if (rename(file, strncpy(buf, m_backup(file), sizeof(buf))) == NOTOK)
-                                               admonish(buf, "unable to rename %s to", file);
-                               }
+       case OK:
+               /* child process -- send it */
+               SIGNAL(SIGHUP, SIG_IGN);
+               SIGNAL(SIGINT, SIG_IGN);
+               SIGNAL(SIGQUIT, SIG_IGN);
+               SIGNAL(SIGTERM, SIG_IGN);
+               if (forwsw) {
+                       if ((in = open(file, O_RDONLY)) == NOTOK) {
+                               admonish(file, "unable to re-open");
+                       } else {
+                               lseek(out, (off_t) 0, SEEK_END);
+                               strncpy(buf, "\nMessage not delivered to anyone.\n", sizeof(buf));
+                               write(out, buf, strlen(buf));
+                               strncpy(buf, "\n------- Unsent Draft\n\n", sizeof(buf));
+                               write(out, buf, strlen(buf));
+                               cpydgst(in, out, file, "temporary file");
+                               close(in);
+                               strncpy(buf, "\n------- End of Unsent Draft\n", sizeof(buf));
+                               write(out, buf, strlen(buf));
+                               if (rename(file, strncpy(buf, m_backup(file), sizeof(buf))) == NOTOK)
+                                       admonish(buf, "unable to rename %s to", file);
                        }
-                       lseek(out, (off_t) 0, SEEK_SET);
-                       dup2(out, fileno(stdin));
-                       close(out);
-                       /* create subject for error notification */
-                       snprintf(buf, sizeof(buf), "send failed on %s",
-                                       forwsw ? "enclosed draft" : file);
-
-                       execlp(mailproc, mhbasename(mailproc),
-                                       getusername(), "-subject", buf, NULL);
-                       fprintf(stderr, "unable to exec ");
-                       perror(mailproc);
-                       _exit(-1);
-
-               default:  /* no waiting... */
-                       break;
+               }
+               lseek(out, (off_t) 0, SEEK_SET);
+               dup2(out, fileno(stdin));
+               close(out);
+               /* create subject for error notification */
+               snprintf(buf, sizeof(buf), "send failed on %s",
+                               forwsw ? "enclosed draft" : file);
+
+               execlp(mailproc, mhbasename(mailproc), getusername(),
+                               "-subject", buf, NULL);
+               fprintf(stderr, "unable to exec ");
+               perror(mailproc);
+               _exit(-1);
+
+       default:  /* no waiting... */
+               break;
        }
 }
 
@@ -760,34 +760,34 @@ anno(int fd, struct stat *st)
 
        child_id = debugsw ? NOTOK : fork();
        switch (child_id) {
-               case NOTOK:  /* oops */
-                       if (!debugsw)
-                               advise(NULL, "unable to fork, so doing annotations by hand...");
-                       if (cwd == NULL)
-                               cwd = getcpy(pwd());
+       case NOTOK:  /* oops */
+               if (!debugsw)
+                       advise(NULL, "unable to fork, so doing annotations by hand...");
+               if (cwd == NULL)
+                       cwd = getcpy(pwd());
 
-               case OK:
-                       /* block a few signals */
-                       sigemptyset(&set);
-                       sigaddset(&set, SIGHUP);
-                       sigaddset(&set, SIGINT);
-                       sigaddset(&set, SIGQUIT);
-                       sigaddset(&set, SIGTERM);
-                       SIGPROCMASK(SIG_BLOCK, &set, &oset);
-
-                       annoaux(fd);
-                       if (child_id == OK)
-                               _exit(0);
-
-                       /* reset the signal mask */
-                       SIGPROCMASK(SIG_SETMASK, &oset, &set);
-
-                       chdir(cwd);
-                       break;
+       case OK:
+               /* block a few signals */
+               sigemptyset(&set);
+               sigaddset(&set, SIGHUP);
+               sigaddset(&set, SIGINT);
+               sigaddset(&set, SIGQUIT);
+               sigaddset(&set, SIGTERM);
+               SIGPROCMASK(SIG_BLOCK, &set, &oset);
+
+               annoaux(fd);
+               if (child_id == OK)
+                       _exit(0);
+
+               /* reset the signal mask */
+               SIGPROCMASK(SIG_SETMASK, &oset, &set);
+
+               chdir(cwd);
+               break;
 
-               default:  /* no waiting... */
-                       close(fd);
-                       break;
+       default:  /* no waiting... */
+               close(fd);
+               break;
        }
 }