Localization changes.

Updated to use standard error message routines.
This commit is contained in:
jtc 1993-12-31 19:34:53 +00:00
parent e939834745
commit b148ed66e2
2 changed files with 20 additions and 16 deletions

View File

@ -39,16 +39,18 @@ char copyright[] =
#ifndef lint
/*static char sccsid[] = "from: @(#)mkdir.c 5.7 (Berkeley) 5/31/90";*/
static char rcsid[] = "$Id: mkdir.c,v 1.6 1993/10/13 18:34:36 jtc Exp $";
static char rcsid[] = "$Id: mkdir.c,v 1.7 1993/12/31 19:34:53 jtc Exp $";
#endif /* not lint */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <string.h>
#include <locale.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <err.h>
main(argc, argv)
int argc;
@ -58,6 +60,8 @@ main(argc, argv)
void *set;
mode_t mode, dir_mode;
setlocale(LC_ALL, "");
/* default file mode is a=rwx (777) with selected permissions
removed in accordance with the file mode creation mask.
For intermediate path name components, the mode is the default
@ -67,16 +71,15 @@ main(argc, argv)
dir_mode = mode | S_IWUSR | S_IXUSR;
pflag = 0;
while ((ch = getopt(argc, argv, "pm:")) != EOF)
while ((ch = getopt(argc, argv, "pm:")) != -1)
switch(ch) {
case 'p':
pflag = 1;
break;
case 'm':
if ((set = setmode(optarg)) == NULL) {
(void)fprintf(stderr,
"mkdir: invalid file mode.\n");
exit(1);
errx(1, "invalid file mode.");
/* NOTREACHED */
}
mode = getmode (set, S_IRWXU | S_IRWXG | S_IRWXO);
break;
@ -92,8 +95,7 @@ main(argc, argv)
if (pflag)
exitval |= build(*argv, mode, dir_mode);
else if (mkdir(*argv, mode) < 0) {
(void)fprintf(stderr, "mkdir: %s: %s\n",
*argv, strerror(errno));
warn("%s", *argv);
exitval = 1;
}
}
@ -120,8 +122,7 @@ build(path, mode, dir_mode)
*p = '\0';
if (stat(path, &sb)) {
if (errno != ENOENT || mkdir(path, (ch) ? dir_mode : mode) < 0) {
(void)fprintf(stderr, "mkdir: %s: %s\n",
path, strerror(errno));
warn("%s", path);
return(1);
}
}

View File

@ -39,16 +39,18 @@ char copyright[] =
#ifndef lint
/*static char sccsid[] = "from: @(#)mkfifo.c 5.3 (Berkeley) 6/1/90";*/
static char rcsid[] = "$Id: mkfifo.c,v 1.5 1993/10/13 18:34:41 jtc Exp $";
static char rcsid[] = "$Id: mkfifo.c,v 1.6 1993/12/31 19:35:37 jtc Exp $";
#endif /* not lint */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <locale.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <err.h>
static void usage();
@ -61,17 +63,19 @@ main(argc, argv)
void * set;
mode_t mode;
setlocale (LC_ALL, "");
/* The default mode is the value of the bitwise inclusive or of
S_IRUSR, S_IWUSR, S_IRGRP, S_IWGRP, S_IROTH, and S_IWOTH
modified by the file creation mask */
mode = 0666 & ~umask(0);
while ((ch = getopt(argc, argv, "m:")) != EOF)
while ((ch = getopt(argc, argv, "m:")) != -1)
switch(ch) {
case 'm':
if (!(set = setmode(optarg))) {
(void)fprintf(stderr, "mkfifo: invalid file mode.\n");
exit(1);
errx(1, "invalid file mode.");
/* NOTREACHED */
}
/* In symbolic mode strings, the + and - operators are
interpreted relative to an assumed initial mode of
@ -88,8 +92,7 @@ main(argc, argv)
for (exitval = 0; *argv; ++argv) {
if (mkfifo(*argv, mode) < 0) {
(void)fprintf(stderr, "mkfifo: %s: %s\n",
*argv, strerror(errno));
warn("%s", *argv);
exitval = 1;
}
}