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 */
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();
** 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");
}
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",
** 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);
** accustomed to.
*/
writelscmd(buf, sizeof(buf), argp);
- (void)system_in_dir(cwd, buf);
+ system_in_dir(cwd, buf);
break;
case ALISTCMDSW:
** -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 = "/";
}
if (n == -1)
- advise((char *)0, "usage is alist [-ln].");
+ advise(NULL, "usage is alist [-ln].");
else
annolist(drft, attach, l, n);
** 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;
}
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 == '/')
** 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;
}
*/
for (n = 0, arguments = argp + 1;
- *arguments != (char *)0;
+ *arguments != NULL;
arguments++) {
if (strcmp(*arguments, "-n") == 0) {
n = 1;
if (n == 1) {
for (arguments = argp + 1;
- *arguments != (char *)0;
+ *arguments != NULL;
arguments++) {
if (strcmp(*arguments, "-n") == 0)
continue;
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);
}
}
}
*/
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;
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" */
}
vecp = 0;
- vec[vecp++] = r1bindex(*ed, '/');
+ vec[vecp++] = mhbasename(*ed);
if (arg)
while (*arg)
vec[vecp++] = *arg++;
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;
** 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;
** 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 */
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
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 == '-') {
if ((pushsw = pushed))
push();
- vec[0] = r1bindex(postproc, '/');
+ vec[0] = mhbasename(postproc);
closefds(3);
if (sendsbr(vec, vecp, file, &st, 1, attach, attachformat) == OK)