aboutsummaryrefslogtreecommitdiff
path: root/coreutils
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2006-08-03 15:41:12 +0000
committerRob Landley <rob@landley.net>2006-08-03 15:41:12 +0000
commitd921b2ecc0d294ad4bf8c7458fc52a60c28727d2 (patch)
treee4a2769349867c441cf2983d83097bb66701a733 /coreutils
parent6dce0b6fa79f2d4bb7e9d90e1fbc0f6beb25f855 (diff)
downloadbusybox-d921b2ecc0d294ad4bf8c7458fc52a60c28727d2.tar.gz
Remove bb_ prefixes from xfuncs.c (and a few other places), consolidate
things like xasprintf() into xfuncs.c, remove xprint_file_by_name() (it only had one user), clean up lots of #includes... General cleanup pass. What I've been doing for the last couple days. And it conflicts! I've removed httpd.c from this checkin due to somebody else touching that file. It builds for me. I have to catch a bus. (Now you know why I'm looking forward to Mercurial.)
Diffstat (limited to 'coreutils')
-rw-r--r--coreutils/cal.c14
-rw-r--r--coreutils/catv.c4
-rw-r--r--coreutils/chroot.c6
-rw-r--r--coreutils/cksum.c5
-rw-r--r--coreutils/cmp.c11
-rw-r--r--coreutils/comm.c6
-rw-r--r--coreutils/dd.c12
-rw-r--r--coreutils/diff.c41
-rw-r--r--coreutils/dos2unix.c6
-rw-r--r--coreutils/expr.c16
-rw-r--r--coreutils/fold.c9
-rw-r--r--coreutils/head.c7
-rw-r--r--coreutils/ln.c10
-rw-r--r--coreutils/ls.c12
-rw-r--r--coreutils/md5_sha1_sum.c10
-rw-r--r--coreutils/nohup.c7
-rw-r--r--coreutils/sort.c14
-rw-r--r--coreutils/stat.c14
-rw-r--r--coreutils/stty.c36
-rw-r--r--coreutils/tee.c6
-rw-r--r--coreutils/uniq.c7
-rw-r--r--coreutils/uudecode.c9
-rw-r--r--coreutils/uuencode.c11
-rw-r--r--coreutils/watch.c10
24 files changed, 53 insertions, 230 deletions
diff --git a/coreutils/cal.c b/coreutils/cal.c
index 5d61b6ccf..9628459fe 100644
--- a/coreutils/cal.c
+++ b/coreutils/cal.c
@@ -17,20 +17,8 @@
* Major size reduction... over 50% (>1.5k) on i386.
*/
-#include <sys/types.h>
-#include <ctype.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-#include <unistd.h>
-
#include "busybox.h"
-#ifdef CONFIG_LOCALE_SUPPORT
-#include <locale.h>
-#endif
-
#define THURSDAY 4 /* for reformation */
#define SATURDAY 6 /* 1 Jan 1 was a Saturday */
@@ -135,7 +123,7 @@ int cal_main(int argc, char **argv)
do {
zero_tm.tm_mon = i;
strftime(buf, sizeof(buf), "%B", &zero_tm);
- month_names[i] = bb_xstrdup(buf);
+ month_names[i] = xstrdup(buf);
if (i < 7) {
zero_tm.tm_wday = i;
diff --git a/coreutils/catv.c b/coreutils/catv.c
index dd4aa44e3..e18203915 100644
--- a/coreutils/catv.c
+++ b/coreutils/catv.c
@@ -11,8 +11,6 @@
* http://cm.bell-labs.com/cm/cs/doc/84/kp.ps.gz */
#include "busybox.h"
-#include <unistd.h>
-#include <fcntl.h>
int catv_main(int argc, char **argv)
{
@@ -28,7 +26,7 @@ int catv_main(int argc, char **argv)
// Read from stdin if there's nothing else to do.
fd = 0;
- if (*argv && 0>(fd = bb_xopen(*argv, O_RDONLY))) retval = EXIT_FAILURE;
+ if (*argv && 0>(fd = xopen(*argv, O_RDONLY))) retval = EXIT_FAILURE;
else for(;;) {
int i, res;
diff --git a/coreutils/chroot.c b/coreutils/chroot.c
index 8ad680c02..62cfdc244 100644
--- a/coreutils/chroot.c
+++ b/coreutils/chroot.c
@@ -9,10 +9,6 @@
/* BB_AUDIT SUSv3 N/A -- Matches GNU behavior. */
-#include <stdlib.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <errno.h>
#include "busybox.h"
int chroot_main(int argc, char **argv)
@@ -25,7 +21,7 @@ int chroot_main(int argc, char **argv)
if (chroot(*argv)) {
bb_perror_msg_and_die("cannot change root directory to %s", *argv);
}
- bb_xchdir("/");
+ xchdir("/");
++argv;
if (argc == 2) {
diff --git a/coreutils/cksum.c b/coreutils/cksum.c
index 1396a5d5b..5849ddab2 100644
--- a/coreutils/cksum.c
+++ b/coreutils/cksum.c
@@ -6,14 +6,11 @@
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details. */
-#include <stdio.h>
-#include <unistd.h>
-#include <fcntl.h>
#include "busybox.h"
int cksum_main(int argc, char **argv) {
- uint32_t *crc32_table = bb_crc32_filltable(1);
+ uint32_t *crc32_table = crc32_filltable(1);
FILE *fp;
uint32_t crc;
diff --git a/coreutils/cmp.c b/coreutils/cmp.c
index 016158bfe..a569eb3fe 100644
--- a/coreutils/cmp.c
+++ b/coreutils/cmp.c
@@ -21,9 +21,6 @@
* in the '-l' case.
*/
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
#include "busybox.h"
static FILE *cmp_xfopen_input(const char *filename)
@@ -105,12 +102,12 @@ int cmp_main(int argc, char **argv)
c1 = c2;
}
if (c1 == EOF) {
- bb_xferror(fp1, filename1);
+ xferror(fp1, filename1);
fmt = fmt_eof; /* Well, no error, so it must really be EOF. */
outfile = stderr;
/* There may have been output to stdout (option -l), so
* make sure we fflush before writing to stderr. */
- bb_xfflush_stdout();
+ xfflush_stdout();
}
if (opt_flags != OPT_s) {
if (opt_flags == OPT_l) {
@@ -129,8 +126,8 @@ int cmp_main(int argc, char **argv)
}
} while (c1 != EOF);
- bb_xferror(fp1, filename1);
- bb_xferror(fp2, filename2);
+ xferror(fp1, filename1);
+ xferror(fp2, filename2);
bb_fflush_stdout_and_exit(exit_val);
}
diff --git a/coreutils/comm.c b/coreutils/comm.c
index 8b9380175..7524a7b25 100644
--- a/coreutils/comm.c
+++ b/coreutils/comm.c
@@ -7,10 +7,6 @@
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
#include "busybox.h"
#define COMM_OPT_1 0x01
@@ -57,7 +53,7 @@ static void cmp_files(char **infiles)
int i;
for (i = 0; i < 2; ++i) {
- streams[i] = ((infiles[i][0] == '=' && infiles[i][1]) ? stdin : bb_xfopen(infiles[i], "r"));
+ streams[i] = ((infiles[i][0] == '=' && infiles[i][1]) ? stdin : xfopen(infiles[i], "r"));
fgets(thisline[i], LINE_LEN, streams[i]);
}
diff --git a/coreutils/dd.c b/coreutils/dd.c
index 3d6f7cd2d..052cd2902 100644
--- a/coreutils/dd.c
+++ b/coreutils/dd.c
@@ -8,14 +8,6 @@
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <string.h>
-#include <fcntl.h>
-#include <signal.h> // For FEATURE_DD_SIGNAL_HANDLING
#include "busybox.h"
static const struct suffix_mult dd_suffixes[] = {
@@ -110,7 +102,7 @@ int dd_main(int argc, char **argv)
else obuf = ibuf;
if (infile != NULL) {
- ifd = bb_xopen(infile, O_RDONLY);
+ ifd = xopen(infile, O_RDONLY);
} else {
ifd = STDIN_FILENO;
infile = bb_msg_standard_input;
@@ -123,7 +115,7 @@ int dd_main(int argc, char **argv)
oflag |= O_TRUNC;
}
- ofd = bb_xopen3(outfile, oflag, 0666);
+ ofd = xopen3(outfile, oflag, 0666);
if (seek && trunc_flag) {
if (ftruncate(ofd, seek * obs) < 0) {
diff --git a/coreutils/diff.c b/coreutils/diff.c
index 368efd383..22c157412 100644
--- a/coreutils/diff.c
+++ b/coreutils/diff.c
@@ -12,23 +12,6 @@
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
-#include <time.h>
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/stat.h>
-#include <ctype.h>
-#include <errno.h>
-#include <signal.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <stdarg.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/wait.h>
-#include <fcntl.h>
-#include <stddef.h>
-#include <paths.h>
-#include <dirent.h>
#include "busybox.h"
#define FSIZE_MAX 32768
@@ -917,21 +900,21 @@ static int diffreg(char *ofile1, char *ofile2, int flags)
goto closem;
if (flags & D_EMPTY1)
- f1 = bb_xfopen(bb_dev_null, "r");
+ f1 = xfopen(bb_dev_null, "r");
else {
if (strcmp(file1, "-") == 0)
f1 = stdin;
else
- f1 = bb_xfopen(file1, "r");
+ f1 = xfopen(file1, "r");
}
if (flags & D_EMPTY2)
- f2 = bb_xfopen(bb_dev_null, "r");
+ f2 = xfopen(bb_dev_null, "r");
else {
if (strcmp(file2, "-") == 0)
f2 = stdin;
else
- f2 = bb_xfopen(file2, "r");
+ f2 = xfopen(file2, "r");
}
if ((i = files_differ(f1, f2, flags)) == 0)
@@ -1004,19 +987,19 @@ static void do_diff(char *dir1, char *path1, char *dir2, char *path2)
int flags = D_HEADER;
int val;
- char *fullpath1 = bb_xasprintf("%s/%s", dir1, path1);
- char *fullpath2 = bb_xasprintf("%s/%s", dir2, path2);
+ char *fullpath1 = xasprintf("%s/%s", dir1, path1);
+ char *fullpath2 = xasprintf("%s/%s", dir2, path2);
if (stat(fullpath1, &stb1) != 0) {
flags |= D_EMPTY1;
memset(&stb1, 0, sizeof(stb1));
- fullpath1 = bb_xasprintf("%s/%s", dir1, path2);
+ fullpath1 = xasprintf("%s/%s", dir1, path2);
}
if (stat(fullpath2, &stb2) != 0) {
flags |= D_EMPTY2;
memset(&stb2, 0, sizeof(stb2));
stb2.st_mode = stb1.st_mode;
- fullpath2 = bb_xasprintf("%s/%s", dir2, path1);
+ fullpath2 = xasprintf("%s/%s", dir2, path1);
}
if (stb1.st_mode == 0)
@@ -1051,7 +1034,7 @@ static int add_to_dirlist(const char *filename,
{
dl_count++;
dl = xrealloc(dl, dl_count * sizeof(char *));
- dl[dl_count - 1] = bb_xstrdup(filename);
+ dl[dl_count - 1] = xstrdup(filename);
if (cmd_flags & FLAG_r) {
int *pp = (int *) userdata;
int path_len = *pp + 1;
@@ -1077,7 +1060,7 @@ static char **get_dir(char *path)
int path_len = strlen(path);
void *userdata = &path_len;
- /* Reset dl_count - there's no need to free dl as bb_xrealloc does
+ /* Reset dl_count - there's no need to free dl as xrealloc does
* the job nicely. */
dl_count = 0;
@@ -1089,7 +1072,7 @@ static char **get_dir(char *path)
DIR *dp;
struct dirent *ep;
- dp = bb_opendir(path);
+ dp = warn_opendir(path);
while ((ep = readdir(dp))) {
if ((!strcmp(ep->d_name, "..")) || (!strcmp(ep->d_name, ".")))
continue;
@@ -1104,7 +1087,7 @@ static char **get_dir(char *path)
/* Copy dl so that we can return it. */
retval = xmalloc(dl_count * sizeof(char *));
for (i = 0; i < dl_count; i++)
- retval[i] = bb_xstrdup(dl[i]);
+ retval[i] = xstrdup(dl[i]);
return retval;
}
diff --git a/coreutils/dos2unix.c b/coreutils/dos2unix.c
index 5bf16e5af..19f1a3257 100644
--- a/coreutils/dos2unix.c
+++ b/coreutils/dos2unix.c
@@ -12,10 +12,6 @@
* Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
*/
-#include <string.h>
-#include <unistd.h>
-#include <stdint.h>
-#include <fcntl.h>
#include "busybox.h"
enum ConvType {
@@ -30,7 +26,7 @@ static int convert(char *fn)
int i;
if (fn != NULL) {
- in = bb_xfopen(fn, "rw");
+ in = xfopen(fn, "rw");
/*
The file is then created with mode read/write and
permissions 0666 for glibc 2.0.6 and earlier or
diff --git a/coreutils/expr.c b/coreutils/expr.c
index 725196039..0a1baa19d 100644
--- a/coreutils/expr.c
+++ b/coreutils/expr.c
@@ -25,14 +25,8 @@
/* no getopt needed */
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <regex.h>
-#include <sys/types.h>
-#include <errno.h>
#include "busybox.h"
-
+#include "xregex.h"
/* The kinds of value we can have. */
enum valtype {
@@ -116,9 +110,9 @@ static VALUE *str_value (char *s)
{
VALUE *v;
- v = xmalloc (sizeof(VALUE));
+ v = xmalloc(sizeof(VALUE));
v->type = string;
- v->u.s = bb_xstrdup (s);
+ v->u.s = xstrdup(s);
return v;
}
@@ -148,7 +142,7 @@ static int null (VALUE *v)
static void tostring (VALUE *v)
{
if (v->type == integer) {
- v->u.s = bb_xasprintf ("%" PF_REZ "d", PF_REZ_TYPE v->u.i);
+ v->u.s = xasprintf("%" PF_REZ "d", PF_REZ_TYPE v->u.i);
v->type = string;
}
}
@@ -366,7 +360,7 @@ static VALUE *eval6 (void)
else {
v = xmalloc (sizeof(VALUE));
v->type = string;
- v->u.s = bb_xstrndup(l->u.s + i1->u.i - 1, i2->u.i);
+ v->u.s = xstrndup(l->u.s + i1->u.i - 1, i2->u.i);
}
freev (l);
freev (i1);
diff --git a/coreutils/fold.c b/coreutils/fold.c
index 665b93e6e..aff7bb1d9 100644
--- a/coreutils/fold.c
+++ b/coreutils/fold.c
@@ -10,13 +10,6 @@
Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
*/
-#include <ctype.h>
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <unistd.h>
#include "busybox.h"
static unsigned long flags;
@@ -61,7 +54,7 @@ int fold_main(int argc, char **argv)
if (*a == '-' && !a[1])
break;
if (isdigit(*a)) {
- argv[i] = bb_xasprintf("-w%s", a);
+ argv[i] = xasprintf("-w%s", a);
}
}
}
diff --git a/coreutils/head.c b/coreutils/head.c
index 184e8161c..e961ca6b6 100644
--- a/coreutils/head.c
+++ b/coreutils/head.c
@@ -11,11 +11,6 @@
/* BB_AUDIT GNU compatible -c, -q, and -v options in 'fancy' configuration. */
/* http://www.opengroup.org/onlinepubs/007904975/utilities/head.html */
-#include <stdio.h>
-#include <stdlib.h>
-#include <limits.h>
-#include <ctype.h>
-#include <unistd.h>
#include "busybox.h"
static const char head_opts[] =
@@ -137,7 +132,7 @@ int head_main(int argc, char **argv)
bb_perror_msg("%s", *argv); /* Avoid multibyte problems. */
retval = EXIT_FAILURE;
}
- bb_xferror_stdout();
+ xferror_stdout();
}
fmt = header_fmt_str;
} while (*++argv);
diff --git a/coreutils/ln.c b/coreutils/ln.c
index 54ced0b89..df183581e 100644
--- a/coreutils/ln.c
+++ b/coreutils/ln.c
@@ -11,10 +11,6 @@
/* BB_AUDIT GNU options missing: -d, -F, -i, and -v. */
/* http://www.opengroup.org/onlinepubs/007904975/utilities/ln.html */
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <errno.h>
#include "busybox.h"
#define LN_SYMLINK 1
@@ -45,7 +41,7 @@ int ln_main(int argc, char **argv)
if (argc == optind + 1) {
*--argv = last;
- last = bb_get_last_path_component(bb_xstrdup(last));
+ last = bb_get_last_path_component(xstrdup(last));
}
do {
@@ -55,7 +51,7 @@ int ln_main(int argc, char **argv)
if (is_directory(src,
(flag & LN_NODEREFERENCE) ^ LN_NODEREFERENCE,
NULL)) {
- src_name = bb_xstrdup(*argv);
+ src_name = xstrdup(*argv);
src = concat_path_file(src, bb_get_last_path_component(src_name));
free(src_name);
src_name = src;
@@ -69,7 +65,7 @@ int ln_main(int argc, char **argv)
if (flag & LN_BACKUP) {
char *backup;
- backup = bb_xasprintf("%s%s", src, suffix);
+ backup = xasprintf("%s%s", src, suffix);
if (rename(src, backup) < 0 && errno != ENOENT) {
bb_perror_msg("%s", src);
status = EXIT_FAILURE;
diff --git a/coreutils/ls.c b/coreutils/ls.c
index de8405dab..6b9fbbfc9 100644
--- a/coreutils/ls.c
+++ b/coreutils/ls.c
@@ -37,15 +37,7 @@ enum {
/************************************************************************/
#include "busybox.h"
-#include <unistd.h>
-#include <errno.h>
-#include <string.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <getopt.h> /* struct option */
-#include <sys/ioctl.h>
-#include <sys/sysmacros.h> /* major() and minor() */
-#include <time.h>
+#include <getopt.h>
/* what is the overall style of the listing */
#define STYLE_COLUMNS (1U<<21) /* fill columns */
@@ -535,7 +527,7 @@ static struct dnode **list_dir(const char *path)
dn = NULL;
nfiles = 0;
- dir = bb_opendir(path);
+ dir = warn_opendir(path);
if (dir == NULL) {
status = EXIT_FAILURE;
return (NULL); /* could not open the dir */
diff --git a/coreutils/md5_sha1_sum.c b/coreutils/md5_sha1_sum.c
index aea43ff8c..49766a925 100644
--- a/coreutils/md5_sha1_sum.c
+++ b/coreutils/md5_sha1_sum.c
@@ -6,14 +6,6 @@
* Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
*/
-#include <fcntl.h>
-#include <limits.h>
-#include <stdio.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
#include "busybox.h"
typedef enum { HASH_SHA1, HASH_MD5 } hash_algo_t;
@@ -129,7 +121,7 @@ static int hash_files(int argc, char **argv, hash_algo_t hash_algo)
if (strcmp(file_ptr, "-") == 0) {
pre_computed_stream = stdin;
} else {
- pre_computed_stream = bb_xfopen(file_ptr, "r");
+ pre_computed_stream = xfopen(file_ptr, "r");
}
while ((line = bb_get_chomped_line_from_file(pre_computed_stream)) != NULL) {
diff --git a/coreutils/nohup.c b/coreutils/nohup.c
index 41c4b779c..86d788683 100644
--- a/coreutils/nohup.c
+++ b/coreutils/nohup.c
@@ -9,9 +9,6 @@
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
-#include <fcntl.h>
-#include <signal.h>
-#include <unistd.h>
#include "busybox.h"
int nohup_main(int argc, char *argv[])
@@ -25,7 +22,7 @@ int nohup_main(int argc, char *argv[])
if (argc<2) bb_show_usage();
- nullfd = bb_xopen(bb_dev_null, O_WRONLY|O_APPEND);
+ nullfd = xopen(bb_dev_null, O_WRONLY|O_APPEND);
// If stdin is a tty, detach from it.
if (isatty(0)) dup2(nullfd, 0);
@@ -38,7 +35,7 @@ int nohup_main(int argc, char *argv[])
home = getenv("HOME");
if (home) {
home = concat_path_file(home, nohupout);
- bb_xopen3(nohupout, O_CREAT|O_WRONLY|O_APPEND, S_IRUSR|S_IWUSR);
+ xopen3(nohupout, O_CREAT|O_WRONLY|O_APPEND, S_IRUSR|S_IWUSR);
}
}
} else dup2(nullfd, 1);
diff --git a/coreutils/sort.c b/coreutils/sort.c
index 3354385a4..195e13d13 100644
--- a/coreutils/sort.c
+++ b/coreutils/sort.c
@@ -12,13 +12,6 @@
* http://www.opengroup.org/onlinepubs/007904975/utilities/sort.html
*/
-#include <ctype.h>
-#include <math.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-#include <unistd.h>
#include "busybox.h"
static int global_flags;
@@ -104,7 +97,7 @@ static char *get_key(char *str, struct sort_key *key, int flags)
}
/* Make the copy */
if(end<start) end=start;
- str=bb_xstrndup(str+start,end-start);
+ str=xstrndup(str+start,end-start);
/* Handle -d */
if(flags&FLAG_d) {
for(start=end=0;str[end];end++)
@@ -222,7 +215,6 @@ static int compare_keys(const void *xarg, const void *yarg)
/* Perform fallback sort if necessary */
if(!retval && !(global_flags&FLAG_s))
retval=strcmp(*(char **)xarg, *(char **)yarg);
-//dprintf(2,"reverse=%d\n",flags&FLAG_r);
return ((flags&FLAG_r)?-1:1)*retval;
}
@@ -242,7 +234,7 @@ int sort_main(int argc, char **argv)
#ifdef CONFIG_FEATURE_SORT_BIG
case 'o':
if(outfile) bb_error_msg_and_die("Too many -o.");
- outfile=bb_xfopen(optarg,"w");
+ outfile=xfopen(optarg,"w");
break;
case 't':
if(key_separator || optarg[1])
@@ -289,7 +281,7 @@ int sort_main(int argc, char **argv)
/* Open input files and read data */
for(i=argv[optind] ? optind : optind-1;argv[i];i++) {
if(i<optind || (*argv[i]=='-' && !argv[i][1])) fp=stdin;
- else fp=bb_xfopen(argv[i],"r");
+ else fp=xfopen(argv[i],"r");
for(;;) {
line=GET_LINE(fp);
if(!line) break;
diff --git a/coreutils/stat.c b/coreutils/stat.c
index 7e39d5ecd..8e0121849 100644
--- a/coreutils/stat.c
+++ b/coreutils/stat.c
@@ -12,18 +12,6 @@
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
-#include <stdio.h>
-#include <stdint.h>
-#include <sys/types.h>
-#include <pwd.h>
-#include <grp.h>
-#include <sys/vfs.h>
-#include <time.h>
-#include <getopt.h> /* optind */
-#include <sys/stat.h>
-#include <sys/statfs.h>
-#include <sys/statvfs.h>
-#include <string.h>
#include "busybox.h"
/* vars to control behavior */
@@ -321,7 +309,7 @@ static void print_it(char const *masterformat, char const *filename,
char *b;
/* create a working copy of the format string */
- char *format = bb_xstrdup(masterformat);
+ char *format = xstrdup(masterformat);
/* Add 2 to accommodate our conversion of the stat `%s' format string
* to the printf `%llu' one. */
diff --git a/coreutils/stty.c b/coreutils/stty.c
index b78368e7b..073de847b 100644
--- a/coreutils/stty.c
+++ b/coreutils/stty.c
@@ -21,31 +21,7 @@
*/
-//#define TEST
-
#include "busybox.h"
-#include <stddef.h>
-#include <termios.h>
-#include <sys/ioctl.h>
-
-#include <sys/param.h>
-#include <unistd.h>
-
-#ifndef STDIN_FILENO
-# define STDIN_FILENO 0
-#endif
-
-#ifndef STDOUT_FILENO
-# define STDOUT_FILENO 1
-#endif
-
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-#include <ctype.h>
-#include <errno.h>
-#include <limits.h>
-#include <fcntl.h>
#define STREQ(a, b) (strcmp ((a), (b)) == 0)
@@ -469,11 +445,7 @@ static const struct suffix_mult stty_suffixes[] = {
{NULL, 0 }
};
-#ifndef TEST
int stty_main(int argc, char **argv)
-#else
-int main(int argc, char **argv)
-#endif
{
struct termios mode;
void (*output_func)(struct termios *);
@@ -541,7 +513,7 @@ int main(int argc, char **argv)
device_name = file_name;
fclose(stdin);
- bb_xopen(device_name, O_RDONLY | O_NONBLOCK);
+ xopen(device_name, O_RDONLY | O_NONBLOCK);
if ((fdflags = fcntl(STDIN_FILENO, F_GETFL)) == -1
|| fcntl(STDIN_FILENO, F_SETFL, fdflags & ~O_NONBLOCK) < 0)
perror_on_device("%s: couldn't reset non-blocking mode");
@@ -1299,9 +1271,3 @@ static const char *visible(unsigned int ch)
*bpout = '\0';
return (const char *) buf;
}
-
-#ifdef TEST
-
-const char *bb_applet_name = "stty";
-
-#endif
diff --git a/coreutils/tee.c b/coreutils/tee.c
index 30496eefa..4d0e6ff85 100644
--- a/coreutils/tee.c
+++ b/coreutils/tee.c
@@ -10,10 +10,6 @@
/* BB_AUDIT SUSv3 compliant */
/* http://www.opengroup.org/onlinepubs/007904975/utilities/tee.html */
-#include <stdio.h>
-#include <stdlib.h>
-#include <signal.h>
-#include <unistd.h>
#include "busybox.h"
int tee_main(int argc, char **argv)
@@ -96,7 +92,7 @@ int tee_main(int argc, char **argv)
do { /* Now check for (input and) output errors. */
/* Checking ferror should be sufficient, but we may want to fclose.
* If we do, remember not to close stdin! */
- bb_xferror(*p, filenames[(int)(p - files)]);
+ xferror(*p, filenames[(int)(p - files)]);
} while (*++p);
bb_fflush_stdout_and_exit(retval);
diff --git a/coreutils/uniq.c b/coreutils/uniq.c
index 956c50796..26afc00f4 100644
--- a/coreutils/uniq.c
+++ b/coreutils/uniq.c
@@ -11,9 +11,6 @@
/* http://www.opengroup.org/onlinepubs/007904975/utilities/uniq.html */
#include "busybox.h"
-#include <string.h>
-#include <ctype.h>
-#include <unistd.h>
static const char uniq_opts[] = "f:s:" "cdu\0\1\2\4";
@@ -23,7 +20,7 @@ static FILE *xgetoptfile_uniq_s(char **argv, int read0write2)
if ((n = *argv) != NULL) {
if ((*n != '-') || n[1]) {
- return bb_xfopen(n, "r\0w" + read0write2);
+ return xfopen(n, "r\0w" + read0write2);
}
}
return (read0write2) ? stdout : stdin;
@@ -100,7 +97,7 @@ int uniq_main(int argc, char **argv)
}
} while (s1);
- bb_xferror(in, input_filename);
+ xferror(in, input_filename);
bb_fflush_stdout_and_exit(EXIT_SUCCESS);
}
diff --git a/coreutils/uudecode.c b/coreutils/uudecode.c
index 06b2fc1c1..6050c0af7 100644
--- a/coreutils/uudecode.c
+++ b/coreutils/uudecode.c
@@ -12,11 +12,6 @@
*/
-#include <stdio.h>
-#include <errno.h>
-#include <getopt.h> /* optind */
-#include <string.h>
-#include <stdlib.h>
#include "busybox.h"
static int read_stduu(FILE *src_stream, FILE *dst_stream)
@@ -141,7 +136,7 @@ int uudecode_main(int argc, char **argv)
if (optind == argc) {
src_stream = stdin;
} else if (optind + 1 == argc) {
- src_stream = bb_xfopen(argv[optind], "r");
+ src_stream = xfopen(argv[optind], "r");
} else {
bb_show_usage();
}
@@ -174,7 +169,7 @@ int uudecode_main(int argc, char **argv)
if (strcmp(outname, "-") == 0) {
dst_stream = stdout;
} else {
- dst_stream = bb_xfopen(outname, "w");
+ dst_stream = xfopen(outname, "w");
chmod(outname, mode & (S_IRWXU | S_IRWXG | S_IRWXO));
}
free(line);
diff --git a/coreutils/uuencode.c b/coreutils/uuencode.c
index fee408605..1449d9aeb 100644
--- a/coreutils/uuencode.c
+++ b/coreutils/uuencode.c
@@ -7,12 +7,7 @@
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
+
#include "busybox.h"
/* Conversion table. for base 64 */
@@ -92,7 +87,7 @@ int uuencode_main(int argc, char **argv)
switch (argc - optind) {
case 2:
- src_stream = bb_xfopen(argv[optind], "r");
+ src_stream = xfopen(argv[optind], "r");
xstat(argv[optind], &stat_buf);
mode = stat_buf.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO);
if (src_stream == stdout) {
@@ -128,7 +123,7 @@ int uuencode_main(int argc, char **argv)
}
bb_printf(tbl == tbl_std ? "\n`\nend\n" : "\n====\n");
- bb_xferror(src_stream, "source"); /* TODO - Fix this! */
+ xferror(src_stream, "source"); /* TODO - Fix this! */
bb_fflush_stdout_and_exit(EXIT_SUCCESS);
}
diff --git a/coreutils/watch.c b/coreutils/watch.c
index b783d34de..c8b16b908 100644
--- a/coreutils/watch.c
+++ b/coreutils/watch.c
@@ -16,14 +16,6 @@
* reduced size.
*/
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <limits.h>
-#include <time.h>
-#include <assert.h>
-#include <unistd.h>
-#include <sys/wait.h>
#include "busybox.h"
int watch_main(int argc, char **argv)
@@ -62,7 +54,7 @@ int watch_main(int argc, char **argv)
printf("\033[H\033[J%s %s\n", header, thyme);
- waitpid(bb_xspawn(watched_argv),0,0);
+ waitpid(xspawn(watched_argv),0,0);
sleep(period);
}
}