remove bb_printf and the like

This commit is contained in:
Denis Vlasenko
2006-10-26 23:21:47 +00:00
parent 670a6626ca
commit f0ed376eda
48 changed files with 315 additions and 314 deletions

View File

@@ -46,5 +46,5 @@ int basename_main(int argc, char **argv)
puts(s);
bb_fflush_stdout_and_exit(EXIT_SUCCESS);
fflush_stdout_and_exit(EXIT_SUCCESS);
}

View File

@@ -139,7 +139,7 @@ int cal_main(int argc, char **argv)
day_array(month, year, dp);
len = sprintf(lineout, "%s %d", month_names[month - 1], year);
bb_printf("%*s%s\n%s\n",
printf("%*s%s\n%s\n",
((7*julian + WEEK_LEN) - len) / 2, "",
lineout, day_headings);
for (row = 0; row < 6; row++) {
@@ -170,9 +170,9 @@ int cal_main(int argc, char **argv)
center(month_names[month + 1], week_len, HEAD_SEP);
}
center(month_names[month + 2 - julian], week_len, 0);
bb_printf("\n%s%*s%s", day_headings, HEAD_SEP, "", day_headings);
printf("\n%s%*s%s", day_headings, HEAD_SEP, "", day_headings);
if (!julian) {
bb_printf("%*s%s", HEAD_SEP, "", day_headings);
printf("%*s%s", HEAD_SEP, "", day_headings);
}
putchar('\n');
for (row = 0; row < (6*7); row += 7) {
@@ -186,7 +186,7 @@ int cal_main(int argc, char **argv)
}
}
bb_fflush_stdout_and_exit(0);
fflush_stdout_and_exit(0);
}
/*
@@ -281,7 +281,7 @@ static void center(char *str, int len, int separate)
{
int n = strlen(str);
len -= n;
bb_printf("%*s%*s", (len/2) + n, str, (len/2) + (len % 2) + separate, "");
printf("%*s%*s", (len/2) + n, str, (len/2) + (len % 2) + separate, "");
}
static void blank_string(char *buf, size_t buflen)

View File

@@ -42,10 +42,10 @@ int catv_main(int argc, char **argv)
if (c > 126 && (flags & CATV_OPT_v)) {
if (c == 127) {
bb_printf("^?");
printf("^?");
continue;
} else {
bb_printf("M-");
printf("M-");
c -= 128;
}
}
@@ -54,7 +54,7 @@ int catv_main(int argc, char **argv)
if (flags & CATV_OPT_e)
putchar('$');
} else if (flags & (c==9 ? CATV_OPT_t : CATV_OPT_v)) {
bb_printf("^%c", c+'@');
printf("^%c", c+'@');
continue;
}
}
@@ -65,5 +65,5 @@ int catv_main(int argc, char **argv)
close(fd);
} while (*++argv);
return retval;
fflush_stdout_and_exit(retval);
}

View File

@@ -41,13 +41,13 @@ int cksum_main(int argc, char **argv)
crc ^= 0xffffffffL;
if (inp_stdin) {
bb_printf("%" PRIu32 " %li\n", crc, filesize);
printf("%" PRIu32 " %li\n", crc, filesize);
break;
}
bb_printf("%" PRIu32 " %li %s\n", crc, filesize, *argv);
printf("%" PRIu32 " %li %s\n", crc, filesize, *argv);
fclose(fp);
} while (*(argv + 1));
return EXIT_SUCCESS;
fflush_stdout_and_exit(EXIT_SUCCESS);
}

View File

@@ -96,7 +96,7 @@ int cmp_main(int argc, char **argv)
c1 = c2;
}
if (c1 == EOF) {
xferror(fp1, filename1);
die_if_ferror(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
@@ -107,7 +107,7 @@ int cmp_main(int argc, char **argv)
if (opt & CMP_OPT_l) {
line_pos = c1; /* line_pos is unused in the -l case. */
}
bb_fprintf(outfile, fmt, filename1, filename2, char_pos, line_pos, c2);
fprintf(outfile, fmt, filename1, filename2, char_pos, line_pos, c2);
if (opt) { /* This must be -l since not -s. */
/* If we encountered an EOF,
* the while check will catch it. */
@@ -121,8 +121,8 @@ int cmp_main(int argc, char **argv)
}
} while (c1 != EOF);
xferror(fp1, filename1);
xferror(fp2, filename2);
die_if_ferror(fp1, filename1);
die_if_ferror(fp2, filename2);
bb_fflush_stdout_and_exit(retval);
fflush_stdout_and_exit(retval);
}

View File

@@ -29,7 +29,7 @@ static off_t out_full, out_part, in_full, in_part;
static void dd_output_status(int ATTRIBUTE_UNUSED cur_signal)
{
bb_fprintf(stderr, OFF_FMT"+"OFF_FMT" records in\n"
fprintf(stderr, OFF_FMT"+"OFF_FMT" records in\n"
OFF_FMT"+"OFF_FMT" records out\n",
in_full, in_part,
out_full, out_part);

View File

@@ -51,25 +51,26 @@ int df_main(int argc, char **argv)
#ifdef CONFIG_FEATURE_HUMAN_READABLE
opt_complementary = "h-km:k-hm:m-hk";
opt = getopt32(argc, argv, "hmk");
if(opt & 1) {
df_disp_hr = 0;
disp_units_hdr = " Size";
if (opt & 1) {
df_disp_hr = 0;
disp_units_hdr = " Size";
}
if(opt & 2) {
df_disp_hr = MEGABYTE;
disp_units_hdr = "1M-blocks";
if (opt & 2) {
df_disp_hr = MEGABYTE;
disp_units_hdr = "1M-blocks";
}
#else
opt = getopt32(argc, argv, "k");
#endif
bb_printf("Filesystem%11s%-15sUsed Available Use%% Mounted on\n",
printf("Filesystem%11s%-15sUsed Available Use%% Mounted on\n",
"", disp_units_hdr);
mount_table = NULL;
argv += optind;
if (optind >= argc) {
if (!(mount_table = setmntent(bb_path_mtab_file, "r"))) {
mount_table = setmntent(bb_path_mtab_file, "r");
if (!mount_table) {
bb_perror_msg_and_die(bb_path_mtab_file);
}
}
@@ -79,16 +80,19 @@ int df_main(int argc, char **argv)
const char *mount_point;
if (mount_table) {
if (!(mount_entry = getmntent(mount_table))) {
mount_entry = getmntent(mount_table);
if (!mount_entry) {
endmntent(mount_table);
break;
}
} else {
if (!(mount_point = *argv++)) {
mount_point = *argv++;
if (!mount_point) {
break;
}
if (!(mount_entry = find_mount_point(mount_point, bb_path_mtab_file))) {
bb_error_msg("%s: can't find mount point.", mount_point);
mount_entry = find_mount_point(mount_point, bb_path_mtab_file);
if (!mount_entry) {
bb_error_msg("%s: can't find mount point", mount_point);
SET_ERROR:
status = EXIT_FAILURE;
continue;
@@ -108,8 +112,8 @@ int df_main(int argc, char **argv)
blocks_percent_used = 0;
if (blocks_used + s.f_bavail) {
blocks_percent_used = (((long long) blocks_used) * 100
+ (blocks_used + s.f_bavail)/2
) / (blocks_used + s.f_bavail);
+ (blocks_used + s.f_bavail)/2
) / (blocks_used + s.f_bavail);
}
if (strcmp(device, "rootfs") == 0) {
@@ -117,24 +121,25 @@ int df_main(int argc, char **argv)
} else if (strcmp(device, "/dev/root") == 0) {
/* Adjusts device to be the real root device,
* or leaves device alone if it can't find it */
if ((device = find_block_device("/")) == NULL) {
device = find_block_device("/");
if (!device) {
goto SET_ERROR;
}
}
#ifdef CONFIG_FEATURE_HUMAN_READABLE
bb_printf("%-20s %9s ", device,
make_human_readable_str(s.f_blocks, s.f_bsize, df_disp_hr));
printf("%-20s %9s ", device,
make_human_readable_str(s.f_blocks, s.f_bsize, df_disp_hr));
bb_printf("%9s ",
make_human_readable_str( (s.f_blocks - s.f_bfree),
s.f_bsize, df_disp_hr));
printf("%9s ",
make_human_readable_str( (s.f_blocks - s.f_bfree),
s.f_bsize, df_disp_hr));
bb_printf("%9s %3ld%% %s\n",
printf("%9s %3ld%% %s\n",
make_human_readable_str(s.f_bavail, s.f_bsize, df_disp_hr),
blocks_percent_used, mount_point);
#else
bb_printf("%-20s %9ld %9ld %9ld %3ld%% %s\n",
printf("%-20s %9ld %9ld %9ld %3ld%% %s\n",
device,
kscale(s.f_blocks, s.f_bsize),
kscale(s.f_blocks-s.f_bfree, s.f_bsize),
@@ -145,5 +150,5 @@ int df_main(int argc, char **argv)
} while (1);
bb_fflush_stdout_and_exit(status);
fflush_stdout_and_exit(status);
}

View File

@@ -22,5 +22,5 @@ int dirname_main(int argc, char **argv)
puts(dirname(argv[1]));
bb_fflush_stdout_and_exit(EXIT_SUCCESS);
fflush_stdout_and_exit(EXIT_SUCCESS);
}

View File

@@ -56,14 +56,14 @@ static void print(long size, const char * const filename)
{
/* TODO - May not want to defer error checking here. */
#ifdef CONFIG_FEATURE_HUMAN_READABLE
bb_printf("%s\t%s\n", make_human_readable_str(size, 512, disp_hr),
printf("%s\t%s\n", make_human_readable_str(size, 512, disp_hr),
filename);
#else
if (disp_k) {
size++;
size >>= 1;
}
bb_printf("%ld\t%s\n", size, filename);
printf("%ld\t%s\n", size, filename);
#endif
}
@@ -246,5 +246,5 @@ int du_main(int argc, char **argv)
print(total, "total");
}
bb_fflush_stdout_and_exit(status);
fflush_stdout_and_exit(status);
}

View File

@@ -115,7 +115,7 @@ just_echo:
int echo_main(int argc, char** argv)
{
(void)bb_echo(argc, argv);
bb_fflush_stdout_and_exit(EXIT_SUCCESS);
fflush_stdout_and_exit(EXIT_SUCCESS);
}
/*-

View File

@@ -90,7 +90,7 @@ int env_main(int argc, char** argv)
puts(*ep);
}
bb_fflush_stdout_and_exit(0);
fflush_stdout_and_exit(0);
}
/*

View File

@@ -87,11 +87,11 @@ int expr_main(int argc, char **argv)
bb_error_msg_and_die("syntax error");
if (v->type == integer)
bb_printf("%" PF_REZ "d\n", PF_REZ_TYPE v->u.i);
printf("%" PF_REZ "d\n", PF_REZ_TYPE v->u.i);
else
puts(v->u.s);
exit(null(v));
fflush_stdout_and_exit(null(v));
}
/* Return a VALUE for I. */

View File

@@ -150,5 +150,5 @@ rescan:
}
} while (*++argv);
bb_fflush_stdout_and_exit(errs);
fflush_stdout_and_exit(errs);
}

View File

@@ -112,12 +112,13 @@ int head_main(int argc, char **argv)
#endif
do {
if ((fp = bb_wfopen_input(*argv)) != NULL) {
fp = bb_wfopen_input(*argv);
if (fp) {
if (fp == stdin) {
*argv = (char *) bb_msg_standard_input;
}
if (header_threshhold) {
bb_printf(fmt, *argv);
printf(fmt, *argv);
}
i = count;
while (i && ((c = getc(fp)) != EOF)) {
@@ -130,10 +131,10 @@ int head_main(int argc, char **argv)
bb_perror_msg("%s", *argv); /* Avoid multibyte problems. */
retval = EXIT_FAILURE;
}
xferror_stdout();
die_if_ferror_stdout();
}
fmt = header_fmt_str;
} while (*++argv);
bb_fflush_stdout_and_exit(retval);
fflush_stdout_and_exit(retval);
}

View File

@@ -19,7 +19,7 @@ int hostid_main(int argc, char ATTRIBUTE_UNUSED **argv)
bb_show_usage();
}
bb_printf("%lx\n", gethostid());
printf("%lx\n", gethostid());
bb_fflush_stdout_and_exit(EXIT_SUCCESS);
fflush_stdout_and_exit(EXIT_SUCCESS);
}

View File

@@ -35,7 +35,7 @@ static short printf_full(unsigned int id, const char *arg, const char prefix)
fmt = "%cid=%u(%s)";
status = EXIT_SUCCESS;
}
bb_printf(fmt, prefix, id, arg);
printf(fmt, prefix, id, arg);
return status;
}
@@ -74,10 +74,10 @@ int id_main(int argc, char **argv)
/* bb_getpwuid and bb_getgrgid exit on failure so puts cannot segfault */
puts((flags & JUST_USER) ? bb_getpwuid(NULL, uid, -1 ) : bb_getgrgid(NULL, gid, -1 ));
} else {
bb_printf("%u\n", (flags & JUST_USER) ? uid : gid);
printf("%u\n", (flags & JUST_USER) ? uid : gid);
}
/* exit */
bb_fflush_stdout_and_exit(EXIT_SUCCESS);
fflush_stdout_and_exit(EXIT_SUCCESS);
}
/* Print full info like GNU id */
@@ -96,16 +96,16 @@ int id_main(int argc, char **argv)
getcon(&mysid);
context[0] = '\0';
if (mysid) {
len = strlen(mysid)+1;
safe_strncpy(context, mysid, len);
freecon(mysid);
len = strlen(mysid)+1;
safe_strncpy(context, mysid, len);
freecon(mysid);
} else {
safe_strncpy(context, "unknown", 8);
safe_strncpy(context, "unknown", 8);
}
bb_printf(" context=%s", context);
printf(" context=%s", context);
}
#endif
putchar('\n');
bb_fflush_stdout_and_exit(status);
fflush_stdout_and_exit(status);
}

View File

@@ -35,7 +35,7 @@ int logname_main(int argc, char ATTRIBUTE_UNUSED **argv)
if ((p = getlogin()) != NULL) {
puts(p);
bb_fflush_stdout_and_exit(EXIT_SUCCESS);
fflush_stdout_and_exit(EXIT_SUCCESS);
}
bb_perror_msg_and_die("getlogin");

View File

@@ -17,8 +17,8 @@ int nice_main(int argc, char **argv)
old_priority = getpriority(PRIO_PROCESS, 0);
if (!*++argv) { /* No args, so (GNU) output current nice value. */
bb_printf("%d\n", old_priority);
bb_fflush_stdout_and_exit(EXIT_SUCCESS);
printf("%d\n", old_priority);
fflush_stdout_and_exit(EXIT_SUCCESS);
}
adjustment = 10; /* Set default adjustment. */

View File

@@ -37,5 +37,5 @@ int printenv_main(int argc, char **argv)
}
}
bb_fflush_stdout_and_exit(0);
fflush_stdout_and_exit(0);
}

View File

@@ -17,7 +17,7 @@ int pwd_main(int argc, char **argv)
if ((buf = xgetcwd(NULL)) != NULL) {
puts(buf);
bb_fflush_stdout_and_exit(EXIT_SUCCESS);
fflush_stdout_and_exit(EXIT_SUCCESS);
}
return EXIT_FAILURE;

View File

@@ -44,5 +44,5 @@ int realpath_main(int argc, char **argv)
RELEASE_CONFIG_BUFFER(resolved_path);
#endif
bb_fflush_stdout_and_exit(retval);
fflush_stdout_and_exit(retval);
}

View File

@@ -318,5 +318,5 @@ int sort_main(int argc, char **argv)
/* Print it */
if(!outfile) outfile=stdout;
for(i=0;i<linecount;i++) fprintf(outfile,"%s\n",lines[i]);
bb_fflush_stdout_and_exit(EXIT_SUCCESS);
fflush_stdout_and_exit(EXIT_SUCCESS);
}

View File

@@ -85,7 +85,7 @@ int tee_main(int argc, char **argv)
* output files. Since we know that the first entry in the output
* file table is stdout, we can save one "if ferror" test by
* setting the first entry to stdin and checking stdout error
* status with bb_fflush_stdout_and_exit()... although fflush()ing
* status with fflush_stdout_and_exit()... although fflush()ing
* is unnecessary here. */
p = files;
@@ -93,8 +93,8 @@ 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! */
xferror(*p, filenames[(int)(p - files)]);
die_if_ferror(*p, filenames[(int)(p - files)]);
} while (*++p);
bb_fflush_stdout_and_exit(retval);
fflush_stdout_and_exit(retval);
}

View File

@@ -41,5 +41,5 @@ int tty_main(int argc, char **argv)
puts(s);
}
bb_fflush_stdout_and_exit(retval);
fflush_stdout_and_exit(retval);
}

View File

@@ -91,10 +91,10 @@ int uname_main(int argc, char **argv)
strcpy(uname_info.processor, "unknown");
delta=utsname_offset;
delta = utsname_offset;
do {
if (toprint & 1) {
bb_printf(((char *)(&uname_info)) + *delta);
printf(((char *)(&uname_info)) + *delta);
if (toprint > 1) {
putchar(' ');
}
@@ -103,5 +103,5 @@ int uname_main(int argc, char **argv)
} while (toprint >>= 1);
putchar('\n');
bb_fflush_stdout_and_exit(EXIT_SUCCESS);
fflush_stdout_and_exit(EXIT_SUCCESS);
}

View File

@@ -37,7 +37,7 @@ int uniq_main(int argc, char **argv)
while ((opt = getopt(argc, argv, uniq_opts)) > 0) {
if ((opt == 'f') || (opt == 's')) {
int t = xatoul(optarg);
unsigned long t = xatoul(optarg);
if (opt == 'f') {
skip_fields = t;
} else {
@@ -71,13 +71,13 @@ int uniq_main(int argc, char **argv)
/* gnu uniq ignores newlines */
while ((s1 = xmalloc_getline(in)) != NULL) {
e1 = s1;
for (i=skip_fields ; i ; i--) {
for (i = skip_fields; i; i--) {
e1 = skip_whitespace(e1);
while (*e1 && !isspace(*e1)) {
++e1;
}
}
for (i = skip_chars ; *e1 && i ; i--) {
for (i = skip_chars; *e1 && i; i--) {
++e1;
}
@@ -90,14 +90,14 @@ int uniq_main(int argc, char **argv)
if (s0) {
if (!(uniq_flags & (2 << !!dups))) {
bb_fprintf(out, "\0%d " + (uniq_flags & 1), dups + 1);
bb_fprintf(out, "%s\n", s0);
fprintf(out, "\0%d " + (uniq_flags & 1), dups + 1);
fprintf(out, "%s\n", s0);
}
free((void *)s0);
}
} while (s1);
xferror(in, input_filename);
die_if_ferror(in, input_filename);
bb_fflush_stdout_and_exit(EXIT_SUCCESS);
fflush_stdout_and_exit(EXIT_SUCCESS);
}

View File

@@ -47,12 +47,12 @@ int uuencode_main(int argc, char **argv)
bb_show_usage();
}
bb_printf("begin%s %o %s", tbl == bb_uuenc_tbl_std ? "" : "-base64", mode, argv[argc - 1]);
printf("begin%s %o %s", tbl == bb_uuenc_tbl_std ? "" : "-base64", mode, argv[argc - 1]);
while ((size = fread(src_buf, 1, src_buf_size, src_stream)) > 0) {
if (size != src_buf_size) {
/* write_size is always 60 until the last line */
write_size=(4 * ((size + 2) / 3));
write_size = (4 * ((size + 2) / 3));
/* pad with 0s so we can just encode extra bits */
memset(&src_buf[size], 0, src_buf_size - size);
}
@@ -67,9 +67,9 @@ int uuencode_main(int argc, char **argv)
bb_perror_msg_and_die(bb_msg_write_error);
}
}
bb_printf(tbl == bb_uuenc_tbl_std ? "\n`\nend\n" : "\n====\n");
printf(tbl == bb_uuenc_tbl_std ? "\n`\nend\n" : "\n====\n");
xferror(src_stream, "source"); /* TODO - Fix this! */
die_if_ferror(src_stream, "source"); /* TODO - Fix this! */
bb_fflush_stdout_and_exit(EXIT_SUCCESS);
fflush_stdout_and_exit(EXIT_SUCCESS);
}

View File

@@ -182,12 +182,12 @@ int wc_main(int argc, char **argv)
u = 0;
do {
if (print_type & (1 << u)) {
bb_printf(s, pcounts[u]);
printf(s, pcounts[u]);
s = " %9"COUNT_FMT; /* Ok... restore the leading space. */
}
totals[u] += pcounts[u];
} while (++u < 4);
bb_printf(fname_fmt, arg);
printf(fname_fmt, arg);
}
/* If more than one file was processed, we want the totals. To save some
@@ -202,5 +202,5 @@ int wc_main(int argc, char **argv)
goto OUTPUT;
}
bb_fflush_stdout_and_exit(status);
fflush_stdout_and_exit(status);
}

View File

@@ -21,5 +21,5 @@ int whoami_main(int argc, char **argv)
puts(bb_getpwuid(NULL, geteuid(), -1));
/* exits on error */
bb_fflush_stdout_and_exit(EXIT_SUCCESS);
fflush_stdout_and_exit(EXIT_SUCCESS);
}

View File

@@ -14,8 +14,6 @@
* Size reductions and removed redundant applet name prefix from error messages.
*/
#include <stdio.h>
#include <stdlib.h>
#include "busybox.h"
int yes_main(int argc, char **argv)
@@ -33,7 +31,7 @@ int yes_main(int argc, char **argv)
do {
fmt = fmt_str + 1;
do {
bb_printf(fmt, *argv);
printf(fmt, *argv);
fmt = fmt_str;
} while (*++argv);
argv = first_arg;