Renames: s/+outbox/+sent/ and s/cc:/Cc:/
[mmh] / uip / whatnowsbr.c
index 5a31a90..aefe67f 100644 (file)
@@ -128,7 +128,7 @@ WhatNow(int argc, char **argv)
        char buf[BUFSIZ], prompt[BUFSIZ];
        char **argp, **arguments;
        struct stat st;
-       char *attach = (char *)0;  /* attachment header field name */
+       char *attach = NULL;  /* attachment header field name */
        char cwd[MAXPATHLEN + 1];  /* current working directory */
        char file[MAXPATHLEN + 1];  /* file name buffer */
        char shell[MAXPATHLEN + 1];  /* shell response buffer */
@@ -136,7 +136,7 @@ WhatNow(int argc, char **argv)
        char *l;  /* set on -l to alist  command */
        int n;  /* set on -n to alist command */
 
-       invo_name = r1bindex(argv[0], '/');
+       invo_name = mhbasename(argv[0]);
 
        /* read user profile/context */
        context_read();
@@ -148,7 +148,7 @@ WhatNow(int argc, char **argv)
        ** Get the initial current working directory.
        */
 
-       if (getcwd(cwd, sizeof (cwd)) == (char *)0) {
+       if (getcwd(cwd, sizeof (cwd)) == NULL) {
                adios("getcwd", "could not get working directory");
        }
 
@@ -188,7 +188,7 @@ WhatNow(int argc, char **argv)
                                continue;
 
                        case ATTACHSW:
-                               if (attach != (char *)0)
+                               if (attach != NULL)
                                        adios(NULL, "only one attachment header field name at a time!");
                                if (!(attach = *argp++) || *attach == '-')
                                        adios(NULL, "missing argument to %s",
@@ -300,15 +300,15 @@ WhatNow(int argc, char **argv)
                        ** the absolute path.
                        */
 
-                       if (*(argp+1) == (char *)0) {
-                               (void)sprintf(buf, "$SHELL -c \"cd;pwd\"");
+                       if (*(argp+1) == NULL) {
+                               sprintf(buf, "$SHELL -c \"cd;pwd\"");
                        } else {
                                writesomecmd(buf, BUFSIZ, "cd", "pwd", argp);
                        }
                        if ((f = popen_in_dir(cwd, buf, "r")) != (FILE *)0) {
                                fgets(cwd, sizeof (cwd), f);
 
-                               if (strchr(cwd, '\n') != (char *)0)
+                               if (strchr(cwd, '\n') != NULL)
                                                *strchr(cwd, '\n') = '\0';
 
                                pclose(f);
@@ -333,7 +333,7 @@ WhatNow(int argc, char **argv)
                        ** accustomed to.
                        */
                        writelscmd(buf, sizeof(buf), argp);
-                       (void)system_in_dir(cwd, buf);
+                       system_in_dir(cwd, buf);
                        break;
 
                case ALISTCMDSW:
@@ -344,15 +344,15 @@ WhatNow(int argc, char **argv)
                        ** -n    numbers listing
                        */
 
-                       if (attach == (char *)0) {
-                               advise((char *)0, "can't list because no header field name was given.");
+                       if (attach == NULL) {
+                               advise(NULL, "can't list because no header field name was given.");
                                break;
                        }
 
-                       l = (char *)0;
+                       l = NULL;
                        n = 0;
 
-                       while (*++argp != (char *)0) {
+                       while (*++argp != NULL) {
                                if (strcmp(*argp, "-l") == 0)
                                        l = "/";
 
@@ -370,7 +370,7 @@ WhatNow(int argc, char **argv)
                        }
 
                        if (n == -1)
-                               advise((char *)0, "usage is alist [-ln].");
+                               advise(NULL, "usage is alist [-ln].");
 
                        else
                                annolist(drft, attach, l, n);
@@ -382,13 +382,13 @@ WhatNow(int argc, char **argv)
                        ** Attach files to current draft.
                        */
 
-                       if (attach == (char *)0) {
-                               advise((char *)0, "can't attach because no header field name was given.");
+                       if (attach == NULL) {
+                               advise(NULL, "can't attach because no header field name was given.");
                                break;
                        }
 
-                       if (*(argp+1) == (char *)0) {
-                               advise((char *)0, "attach command requires file argument(s).");
+                       if (*(argp+1) == NULL) {
+                               advise(NULL, "attach command requires file argument(s).");
                                break;
                        }
 
@@ -412,7 +412,7 @@ WhatNow(int argc, char **argv)
 
                        if ((f = popen_in_dir(cwd, buf, "r")) != (FILE *)0) {
                                while (fgets(shell, sizeof (shell), f)
-                                               != (char *)0) {
+                                               != NULL) {
                                        *(strchr(shell, '\n')) = '\0';
 
                                        if (*shell == '/')
@@ -438,8 +438,8 @@ WhatNow(int argc, char **argv)
                        ** Detach files from current draft.
                        */
 
-                       if (attach == (char *)0) {
-                               advise((char *)0, "can't detach because no header field name was given.");
+                       if (attach == NULL) {
+                               advise(NULL, "can't detach because no header field name was given.");
                                break;
                        }
 
@@ -450,7 +450,7 @@ WhatNow(int argc, char **argv)
                        */
 
                        for (n = 0, arguments = argp + 1;
-                                       *arguments != (char *)0;
+                                       *arguments != NULL;
                                        arguments++) {
                                if (strcmp(*arguments, "-n") == 0) {
                                                n = 1;
@@ -468,7 +468,7 @@ WhatNow(int argc, char **argv)
 
                        if (n == 1) {
                                for (arguments = argp + 1;
-                                               *arguments != (char *)0;
+                                               *arguments != NULL;
                                                arguments++) {
                                        if (strcmp(*arguments, "-n") == 0)
                                                continue;
@@ -478,12 +478,12 @@ WhatNow(int argc, char **argv)
                                                annotate(drft, attach, NULL,
                                                                1, 0, n, 1);
 
-                                               for (argp = arguments + 1; *argp != (char *)0; argp++) {
+                                               for (argp = arguments + 1; *argp != NULL; argp++) {
                                                        if (atoi(*argp) > n) {
                                                                if (atoi(*argp) == 1)
                                                                        *argp = "";
                                                                else
-                                                                       (void)sprintf(*argp, "%d", atoi(*argp) - 1);
+                                                                       sprintf(*argp, "%d", atoi(*argp) - 1);
                                                        }
                                                }
                                        }
@@ -555,15 +555,15 @@ writesomecmd(char *buf, int bufsz, char *cmd, char *trailcmd, char **argp)
        */
        int trailln = strlen(trailcmd) + 3;
        if (ln < 0 || ln + trailln > bufsz)
-               adios((char *)0, "arguments too long");
+               adios(NULL, "arguments too long");
 
        cp = buf + ln;
 
-       while (*++argp != (char *)0) {
+       while (*++argp != NULL) {
                ln = strlen(*argp);
                /* +1 for leading space */
                if (ln + trailln + 1 > bufsz - (cp-buf))
-                       adios((char *)0, "arguments too long");
+                       adios(NULL, "arguments too long");
                *cp++ = ' ';
                memcpy(cp, *argp, ln+1);
                cp += ln;
@@ -651,7 +651,7 @@ editfile(char **ed, char **arg, char *file, int use, struct msgs *mp,
        if (reedit) {
                if (!*ed) {  /* no explicit editor */
                        *ed = edsave;  /* so use the previous one */
-                       if ((cp = r1bindex(*ed, '/')) == NULL)
+                       if ((cp = mhbasename(*ed)) == NULL)
                                cp = *ed;
 
                        /* unless we've specified it via "editor-next" */
@@ -719,7 +719,7 @@ editfile(char **ed, char **arg, char *file, int use, struct msgs *mp,
                        }
 
                        vecp = 0;
-                       vec[vecp++] = r1bindex(*ed, '/');
+                       vec[vecp++] = mhbasename(*ed);
                        if (arg)
                                while (*arg)
                                        vec[vecp++] = *arg++;
@@ -734,7 +734,7 @@ editfile(char **ed, char **arg, char *file, int use, struct msgs *mp,
                default:
                        if ((status = pidwait(pid, NOTOK))) {
 #ifdef ATTVIBUG
-                               if ((cp = r1bindex(*ed, '/')) &&
+                               if ((cp = mhbasename(*ed)) &&
                                                strcmp(cp, "vi") == 0 &&
                                                (status & 0x00ff) == 0)
                                        status = 0;
@@ -845,7 +845,7 @@ sendfile(char **arg, char *file, int pushsw)
        ** If the sendproc is the nmh command `send', then we call
        ** those routines directly rather than exec'ing the command.
        */
-       if (strcmp(sp = r1bindex(sendproc, '/'), "send") == 0) {
+       if (strcmp(sp = mhbasename(sendproc), "send") == 0) {
                cp = invo_name;
                sendit(invo_name = sp, arg, file, pushsw);
                invo_name = cp;
@@ -909,7 +909,7 @@ buildfile(char **argp, char *file)
        ** if we are using mhn as buildmimeproc
        */
        i = 0;
-       if (strcmp(r1bindex(ed, '/'), "mhn") == 0)
+       if (strcmp(mhbasename(ed), "mhn") == 0)
                args[i++] = "-build";
 
        /* copy any other arguments */
@@ -1072,7 +1072,7 @@ sendit(char *sp, char **arg, char *file, int pushed)
        char *cp, buf[BUFSIZ], **argp;
        char **arguments, *vec[MAXARGS];
        struct stat st;
-       char *attach = (char *)0;  /* attachment header field name */
+       char *attach = NULL;  /* attachment header field name */
        int attachformat = 0;  /* mhbuild format specifier for attachments */
 
 #ifndef lint
@@ -1126,7 +1126,7 @@ sendit(char *sp, char **arg, char *file, int pushed)
 
        vecp = 1;  /* we'll get the zero'th element later */
        vec[vecp++] = "-library";
-       vec[vecp++] = getcpy(m_maildir(""));
+       vec[vecp++] = getcpy(toabsdir("+"));
 
        while ((cp = *argp++)) {
                if (*cp == '-') {
@@ -1292,7 +1292,7 @@ sendit(char *sp, char **arg, char *file, int pushed)
        if ((pushsw = pushed))
                push();
 
-       vec[0] = r1bindex(postproc, '/');
+       vec[0] = mhbasename(postproc);
        closefds(3);
 
        if (sendsbr(vec, vecp, file, &st, 1, attach, attachformat) == OK)