}
#endif
- if ((fp = fopen(omfil, "w")) == NULL) {
- perror(omfil);
- exit(1);
- }
+ fp = xfopen(omfil, "w");
#ifdef GIO_UNISCRNMAP
if (is_old_map) {
#endif
if (argv[optind] == NULL || strcmp(argv[optind], "-") == 0) {
wc_file(stdin, "");
- exit(TRUE);
+ return EXIT_SUCCESS;
} else {
while (optind < argc) {
- file = fopen(argv[optind], "r");
- if (file == NULL) {
- fatalError(argv[optind]);
- }
+ file = xfopen(argv[optind], "r");
wc_file(file, argv[optind]);
num_files_counted++;
optind++;
print_counts(total_lines, total_words, total_chars,
max_length, "total");
- return 0 ;
+ return EXIT_SUCCESS;
}
char *line;
char *nextline;
- cmdfile = fopen(filename, "r");
- if (cmdfile == NULL)
- fatalError(strerror(errno));
+ cmdfile = xfopen(filename, "r");
while ((line = get_line_from_file(cmdfile)) != NULL) {
/* if a line ends with '\' it needs the next line appended to it */
/* vi: set sw=4 ts=4: */
/*
- * $Id: hostname.c,v 1.13 2000/09/25 21:45:57 andersen Exp $
+ * $Id: hostname.c,v 1.14 2000/09/27 02:43:35 kraai Exp $
* Mini hostname implementation for busybox
*
* Copyright (C) 1999 by Randolph Chung <tausq@debian.org>
exit(1);
}
} else {
- if ((f = fopen(s, "r")) == NULL) {
- perror(s);
+ f = xfopen(s, "r");
+ fgets(buf, 255, f);
+ fclose(f);
+ if (buf[strlen(buf) - 1] == '\n')
+ buf[strlen(buf) - 1] = 0;
+ if (sethostname(buf, strlen(buf)) < 0) {
+ perror("sethostname");
exit(1);
- } else {
- fgets(buf, 255, f);
- fclose(f);
- if (buf[strlen(buf) - 1] == '\n')
- buf[strlen(buf) - 1] = 0;
- if (sethostname(buf, strlen(buf)) < 0) {
- perror("sethostname");
- exit(1);
- }
}
}
}
fprintf(stdout, "Enter 'help' for a list of built-in commands.\n\n");
} else if (local_pending_command==NULL) {
//fprintf(stdout, "optind=%d argv[optind]='%s'\n", optind, argv[optind]);
- input = fopen(argv[optind], "r");
- if (!input) {
- fatalError("%s: %s\n", argv[optind], strerror(errno));
- }
+ input = xfopen(argv[optind], "r");
}
/* initialize the cwd -- this is never freed...*/
}
#endif
- if ((fp = fopen(omfil, "w")) == NULL) {
- perror(omfil);
- exit(1);
- }
+ fp = xfopen(omfil, "w");
#ifdef GIO_UNISCRNMAP
if (is_old_map) {
#endif
if (argc == 0) {
file = stdin;
} else
- file = fopen(*argv, "r");
+ file = xfopen(*argv, "r");
- if (file == NULL) {
- perror(*argv);
- exit(FALSE);
- }
fstat(fileno(file), &st);
#ifdef BB_FEATURE_USE_TERMIOS
/* vi: set sw=4 ts=4: */
/*
- * $Id: hostname.c,v 1.13 2000/09/25 21:45:57 andersen Exp $
+ * $Id: hostname.c,v 1.14 2000/09/27 02:43:35 kraai Exp $
* Mini hostname implementation for busybox
*
* Copyright (C) 1999 by Randolph Chung <tausq@debian.org>
exit(1);
}
} else {
- if ((f = fopen(s, "r")) == NULL) {
- perror(s);
+ f = xfopen(s, "r");
+ fgets(buf, 255, f);
+ fclose(f);
+ if (buf[strlen(buf) - 1] == '\n')
+ buf[strlen(buf) - 1] = 0;
+ if (sethostname(buf, strlen(buf)) < 0) {
+ perror("sethostname");
exit(1);
- } else {
- fgets(buf, 255, f);
- fclose(f);
- if (buf[strlen(buf) - 1] == '\n')
- buf[strlen(buf) - 1] = 0;
- if (sethostname(buf, strlen(buf)) < 0) {
- perror("sethostname");
- exit(1);
- }
}
}
}
char *line;
char *nextline;
- cmdfile = fopen(filename, "r");
- if (cmdfile == NULL)
- fatalError(strerror(errno));
+ cmdfile = xfopen(filename, "r");
while ((line = get_line_from_file(cmdfile)) != NULL) {
/* if a line ends with '\' it needs the next line appended to it */
fprintf(stdout, "Enter 'help' for a list of built-in commands.\n\n");
} else if (local_pending_command==NULL) {
//fprintf(stdout, "optind=%d argv[optind]='%s'\n", optind, argv[optind]);
- input = fopen(argv[optind], "r");
- if (!input) {
- fatalError("%s: %s\n", argv[optind], strerror(errno));
- }
+ input = xfopen(argv[optind], "r");
}
/* initialize the cwd -- this is never freed...*/
fprintf(stdout, "Enter 'help' for a list of built-in commands.\n\n");
} else if (local_pending_command==NULL) {
//fprintf(stdout, "optind=%d argv[optind]='%s'\n", optind, argv[optind]);
- input = fopen(argv[optind], "r");
- if (!input) {
- fatalError("%s: %s\n", argv[optind], strerror(errno));
- }
+ input = xfopen(argv[optind], "r");
}
/* initialize the cwd -- this is never freed...*/
if (argc == 0) {
file = stdin;
} else
- file = fopen(*argv, "r");
+ file = xfopen(*argv, "r");
- if (file == NULL) {
- perror(*argv);
- exit(FALSE);
- }
fstat(fileno(file), &st);
#ifdef BB_FEATURE_USE_TERMIOS
}
#endif
-#if defined BB_UNIQ
+#if defined BB_HOSTNAME || defined BB_LOADACM || defined BB_MORE || defined BB_SED || defined BB_SH || defined BB_UNIQ || defined BB_WC
FILE *xfopen(const char *path, const char *mode)
{
FILE *fp;
if (argv[optind] == NULL || strcmp(argv[optind], "-") == 0) {
wc_file(stdin, "");
- exit(TRUE);
+ return EXIT_SUCCESS;
} else {
while (optind < argc) {
- file = fopen(argv[optind], "r");
- if (file == NULL) {
- fatalError(argv[optind]);
- }
+ file = xfopen(argv[optind], "r");
wc_file(file, argv[optind]);
num_files_counted++;
optind++;
print_counts(total_lines, total_words, total_chars,
max_length, "total");
- return 0 ;
+ return EXIT_SUCCESS;
}