/*
-** m_name.c -- return a message number as a string
+** m_name.c -- return a message number as a string (in static memory)
**
** This code is Copyright (c) 2002, by the authors of nmh. See the
** COPYRIGHT file in the root directory of the nmh distribution for
char *
m_name(int num)
{
- if (num <= 0)
+ if (num <= 0) {
return "?";
+ }
snprintf(name, sizeof(name), "%d", num);
return name;
*c = '/';
}
- if (!had_an_error) {
- /*
- ** Create the innermost nested subdirectory of the
- ** path we're being asked to create.
- */
- if (mkdir(dir, folder_perms) == -1) {
- advise(dir, "unable to create directory");
- had_an_error = 1;
- }
+ /*
+ ** Create the innermost nested subdirectory of the
+ ** path we're being asked to create.
+ */
+ if (!had_an_error && mkdir(dir, folder_perms)==-1) {
+ advise(dir, "unable to create directory");
+ had_an_error = 1;
}
} else {
/*
** -- Dan Harkless <dan-nmh@dilvish.speed.net>
*/
switch (pid = vfork()) {
- case -1:
- advise("fork", "unable to");
+ case -1:
+ advise("fork", "unable to");
+ return 0;
+
+ case 0:
+ setgid(getgid());
+ setuid(getuid());
+
+ execl("/bin/mkdir", "mkdir", dir, NULL);
+ execl("/usr/bin/mkdir", "mkdir", dir, NULL);
+ fprintf(stderr, "unable to exec ");
+ perror("mkdir");
+ _exit(-1);
+
+ default:
+ if (pidXwait(pid, "mkdir"))
return 0;
-
- case 0:
- setgid(getgid());
- setuid(getuid());
-
- execl("/bin/mkdir", "mkdir", dir, NULL);
- execl("/usr/bin/mkdir", "mkdir", dir, NULL);
- fprintf(stderr, "unable to exec ");
- perror("mkdir");
- _exit(-1);
-
- default:
- if (pidXwait(pid, "mkdir"))
- return 0;
- break;
+ break;
}
chmod(dir, folder_perms);
umask(saved_umask); /* put the user's umask back */
- if (had_an_error)
- return 0; /* opposite of UNIX error return convention */
- else
- return 1;
+ return (had_an_error) ? 0 : 1;
}