aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2006-10-26 23:21:47 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2006-10-26 23:21:47 +0000
commitf0ed376eda5d5c25d270e5100a881fb2d801bee6 (patch)
tree79166b700c497fbe798b6031e5bbff97e0933573
parent670a6626cabc1498f32b35f959591f8621d8447e (diff)
downloadbusybox-w32-f0ed376eda5d5c25d270e5100a881fb2d801bee6.tar.gz
busybox-w32-f0ed376eda5d5c25d270e5100a881fb2d801bee6.tar.bz2
busybox-w32-f0ed376eda5d5c25d270e5100a881fb2d801bee6.zip
remove bb_printf and the like
-rw-r--r--coreutils/basename.c2
-rw-r--r--coreutils/cal.c10
-rw-r--r--coreutils/catv.c8
-rw-r--r--coreutils/cksum.c6
-rw-r--r--coreutils/cmp.c10
-rw-r--r--coreutils/dd.c2
-rw-r--r--coreutils/df.c51
-rw-r--r--coreutils/dirname.c2
-rw-r--r--coreutils/du.c6
-rw-r--r--coreutils/echo.c2
-rw-r--r--coreutils/env.c2
-rw-r--r--coreutils/expr.c4
-rw-r--r--coreutils/fold.c2
-rw-r--r--coreutils/head.c9
-rw-r--r--coreutils/hostid.c4
-rw-r--r--coreutils/id.c18
-rw-r--r--coreutils/logname.c2
-rw-r--r--coreutils/nice.c4
-rw-r--r--coreutils/printenv.c2
-rw-r--r--coreutils/pwd.c2
-rw-r--r--coreutils/realpath.c2
-rw-r--r--coreutils/sort.c2
-rw-r--r--coreutils/tee.c6
-rw-r--r--coreutils/tty.c2
-rw-r--r--coreutils/uname.c6
-rw-r--r--coreutils/uniq.c14
-rw-r--r--coreutils/uuencode.c10
-rw-r--r--coreutils/wc.c6
-rw-r--r--coreutils/whoami.c2
-rw-r--r--coreutils/yes.c4
-rw-r--r--debianutils/readlink.c2
-rw-r--r--debianutils/which.c2
-rw-r--r--e2fsprogs/mke2fs.c14
-rw-r--r--include/libbb.h17
-rw-r--r--libbb/Kbuild1
-rw-r--r--libbb/fflush_stdout_and_exit.c6
-rw-r--r--libbb/getopt32.c2
-rw-r--r--libbb/xfuncs.c6
-rw-r--r--miscutils/crond.c24
-rw-r--r--miscutils/devfsd.c8
-rw-r--r--miscutils/last.c2
-rw-r--r--miscutils/less.c39
-rw-r--r--miscutils/mountpoint.c73
-rw-r--r--miscutils/rx.c2
-rw-r--r--miscutils/strings.c2
-rw-r--r--networking/route.c27
-rw-r--r--util-linux/ipcrm.c4
-rw-r--r--util-linux/ipcs.c196
48 files changed, 315 insertions, 314 deletions
diff --git a/coreutils/basename.c b/coreutils/basename.c
index 446f486cd..30f76dc12 100644
--- a/coreutils/basename.c
+++ b/coreutils/basename.c
@@ -46,5 +46,5 @@ int basename_main(int argc, char **argv)
46 46
47 puts(s); 47 puts(s);
48 48
49 bb_fflush_stdout_and_exit(EXIT_SUCCESS); 49 fflush_stdout_and_exit(EXIT_SUCCESS);
50} 50}
diff --git a/coreutils/cal.c b/coreutils/cal.c
index e2bc5ab12..6f5f0a434 100644
--- a/coreutils/cal.c
+++ b/coreutils/cal.c
@@ -139,7 +139,7 @@ int cal_main(int argc, char **argv)
139 139
140 day_array(month, year, dp); 140 day_array(month, year, dp);
141 len = sprintf(lineout, "%s %d", month_names[month - 1], year); 141 len = sprintf(lineout, "%s %d", month_names[month - 1], year);
142 bb_printf("%*s%s\n%s\n", 142 printf("%*s%s\n%s\n",
143 ((7*julian + WEEK_LEN) - len) / 2, "", 143 ((7*julian + WEEK_LEN) - len) / 2, "",
144 lineout, day_headings); 144 lineout, day_headings);
145 for (row = 0; row < 6; row++) { 145 for (row = 0; row < 6; row++) {
@@ -170,9 +170,9 @@ int cal_main(int argc, char **argv)
170 center(month_names[month + 1], week_len, HEAD_SEP); 170 center(month_names[month + 1], week_len, HEAD_SEP);
171 } 171 }
172 center(month_names[month + 2 - julian], week_len, 0); 172 center(month_names[month + 2 - julian], week_len, 0);
173 bb_printf("\n%s%*s%s", day_headings, HEAD_SEP, "", day_headings); 173 printf("\n%s%*s%s", day_headings, HEAD_SEP, "", day_headings);
174 if (!julian) { 174 if (!julian) {
175 bb_printf("%*s%s", HEAD_SEP, "", day_headings); 175 printf("%*s%s", HEAD_SEP, "", day_headings);
176 } 176 }
177 putchar('\n'); 177 putchar('\n');
178 for (row = 0; row < (6*7); row += 7) { 178 for (row = 0; row < (6*7); row += 7) {
@@ -186,7 +186,7 @@ int cal_main(int argc, char **argv)
186 } 186 }
187 } 187 }
188 188
189 bb_fflush_stdout_and_exit(0); 189 fflush_stdout_and_exit(0);
190} 190}
191 191
192/* 192/*
@@ -281,7 +281,7 @@ static void center(char *str, int len, int separate)
281{ 281{
282 int n = strlen(str); 282 int n = strlen(str);
283 len -= n; 283 len -= n;
284 bb_printf("%*s%*s", (len/2) + n, str, (len/2) + (len % 2) + separate, ""); 284 printf("%*s%*s", (len/2) + n, str, (len/2) + (len % 2) + separate, "");
285} 285}
286 286
287static void blank_string(char *buf, size_t buflen) 287static void blank_string(char *buf, size_t buflen)
diff --git a/coreutils/catv.c b/coreutils/catv.c
index a5a8b43e4..66f30693a 100644
--- a/coreutils/catv.c
+++ b/coreutils/catv.c
@@ -42,10 +42,10 @@ int catv_main(int argc, char **argv)
42 42
43 if (c > 126 && (flags & CATV_OPT_v)) { 43 if (c > 126 && (flags & CATV_OPT_v)) {
44 if (c == 127) { 44 if (c == 127) {
45 bb_printf("^?"); 45 printf("^?");
46 continue; 46 continue;
47 } else { 47 } else {
48 bb_printf("M-"); 48 printf("M-");
49 c -= 128; 49 c -= 128;
50 } 50 }
51 } 51 }
@@ -54,7 +54,7 @@ int catv_main(int argc, char **argv)
54 if (flags & CATV_OPT_e) 54 if (flags & CATV_OPT_e)
55 putchar('$'); 55 putchar('$');
56 } else if (flags & (c==9 ? CATV_OPT_t : CATV_OPT_v)) { 56 } else if (flags & (c==9 ? CATV_OPT_t : CATV_OPT_v)) {
57 bb_printf("^%c", c+'@'); 57 printf("^%c", c+'@');
58 continue; 58 continue;
59 } 59 }
60 } 60 }
@@ -65,5 +65,5 @@ int catv_main(int argc, char **argv)
65 close(fd); 65 close(fd);
66 } while (*++argv); 66 } while (*++argv);
67 67
68 return retval; 68 fflush_stdout_and_exit(retval);
69} 69}
diff --git a/coreutils/cksum.c b/coreutils/cksum.c
index 9bec3bff4..3a9b0b08c 100644
--- a/coreutils/cksum.c
+++ b/coreutils/cksum.c
@@ -41,13 +41,13 @@ int cksum_main(int argc, char **argv)
41 crc ^= 0xffffffffL; 41 crc ^= 0xffffffffL;
42 42
43 if (inp_stdin) { 43 if (inp_stdin) {
44 bb_printf("%" PRIu32 " %li\n", crc, filesize); 44 printf("%" PRIu32 " %li\n", crc, filesize);
45 break; 45 break;
46 } 46 }
47 47
48 bb_printf("%" PRIu32 " %li %s\n", crc, filesize, *argv); 48 printf("%" PRIu32 " %li %s\n", crc, filesize, *argv);
49 fclose(fp); 49 fclose(fp);
50 } while (*(argv + 1)); 50 } while (*(argv + 1));
51 51
52 return EXIT_SUCCESS; 52 fflush_stdout_and_exit(EXIT_SUCCESS);
53} 53}
diff --git a/coreutils/cmp.c b/coreutils/cmp.c
index 07858c64e..2b923c845 100644
--- a/coreutils/cmp.c
+++ b/coreutils/cmp.c
@@ -96,7 +96,7 @@ int cmp_main(int argc, char **argv)
96 c1 = c2; 96 c1 = c2;
97 } 97 }
98 if (c1 == EOF) { 98 if (c1 == EOF) {
99 xferror(fp1, filename1); 99 die_if_ferror(fp1, filename1);
100 fmt = fmt_eof; /* Well, no error, so it must really be EOF. */ 100 fmt = fmt_eof; /* Well, no error, so it must really be EOF. */
101 outfile = stderr; 101 outfile = stderr;
102 /* There may have been output to stdout (option -l), so 102 /* There may have been output to stdout (option -l), so
@@ -107,7 +107,7 @@ int cmp_main(int argc, char **argv)
107 if (opt & CMP_OPT_l) { 107 if (opt & CMP_OPT_l) {
108 line_pos = c1; /* line_pos is unused in the -l case. */ 108 line_pos = c1; /* line_pos is unused in the -l case. */
109 } 109 }
110 bb_fprintf(outfile, fmt, filename1, filename2, char_pos, line_pos, c2); 110 fprintf(outfile, fmt, filename1, filename2, char_pos, line_pos, c2);
111 if (opt) { /* This must be -l since not -s. */ 111 if (opt) { /* This must be -l since not -s. */
112 /* If we encountered an EOF, 112 /* If we encountered an EOF,
113 * the while check will catch it. */ 113 * the while check will catch it. */
@@ -121,8 +121,8 @@ int cmp_main(int argc, char **argv)
121 } 121 }
122 } while (c1 != EOF); 122 } while (c1 != EOF);
123 123
124 xferror(fp1, filename1); 124 die_if_ferror(fp1, filename1);
125 xferror(fp2, filename2); 125 die_if_ferror(fp2, filename2);
126 126
127 bb_fflush_stdout_and_exit(retval); 127 fflush_stdout_and_exit(retval);
128} 128}
diff --git a/coreutils/dd.c b/coreutils/dd.c
index d60192e7c..d72ca8b7e 100644
--- a/coreutils/dd.c
+++ b/coreutils/dd.c
@@ -29,7 +29,7 @@ static off_t out_full, out_part, in_full, in_part;
29 29
30static void dd_output_status(int ATTRIBUTE_UNUSED cur_signal) 30static void dd_output_status(int ATTRIBUTE_UNUSED cur_signal)
31{ 31{
32 bb_fprintf(stderr, OFF_FMT"+"OFF_FMT" records in\n" 32 fprintf(stderr, OFF_FMT"+"OFF_FMT" records in\n"
33 OFF_FMT"+"OFF_FMT" records out\n", 33 OFF_FMT"+"OFF_FMT" records out\n",
34 in_full, in_part, 34 in_full, in_part,
35 out_full, out_part); 35 out_full, out_part);
diff --git a/coreutils/df.c b/coreutils/df.c
index 94ead32eb..c569dae33 100644
--- a/coreutils/df.c
+++ b/coreutils/df.c
@@ -51,25 +51,26 @@ int df_main(int argc, char **argv)
51#ifdef CONFIG_FEATURE_HUMAN_READABLE 51#ifdef CONFIG_FEATURE_HUMAN_READABLE
52 opt_complementary = "h-km:k-hm:m-hk"; 52 opt_complementary = "h-km:k-hm:m-hk";
53 opt = getopt32(argc, argv, "hmk"); 53 opt = getopt32(argc, argv, "hmk");
54 if(opt & 1) { 54 if (opt & 1) {
55 df_disp_hr = 0; 55 df_disp_hr = 0;
56 disp_units_hdr = " Size"; 56 disp_units_hdr = " Size";
57 } 57 }
58 if(opt & 2) { 58 if (opt & 2) {
59 df_disp_hr = MEGABYTE; 59 df_disp_hr = MEGABYTE;
60 disp_units_hdr = "1M-blocks"; 60 disp_units_hdr = "1M-blocks";
61 } 61 }
62#else 62#else
63 opt = getopt32(argc, argv, "k"); 63 opt = getopt32(argc, argv, "k");
64#endif 64#endif
65 65
66 bb_printf("Filesystem%11s%-15sUsed Available Use%% Mounted on\n", 66 printf("Filesystem%11s%-15sUsed Available Use%% Mounted on\n",
67 "", disp_units_hdr); 67 "", disp_units_hdr);
68 68
69 mount_table = NULL; 69 mount_table = NULL;
70 argv += optind; 70 argv += optind;
71 if (optind >= argc) { 71 if (optind >= argc) {
72 if (!(mount_table = setmntent(bb_path_mtab_file, "r"))) { 72 mount_table = setmntent(bb_path_mtab_file, "r");
73 if (!mount_table) {
73 bb_perror_msg_and_die(bb_path_mtab_file); 74 bb_perror_msg_and_die(bb_path_mtab_file);
74 } 75 }
75 } 76 }
@@ -79,16 +80,19 @@ int df_main(int argc, char **argv)
79 const char *mount_point; 80 const char *mount_point;
80 81
81 if (mount_table) { 82 if (mount_table) {
82 if (!(mount_entry = getmntent(mount_table))) { 83 mount_entry = getmntent(mount_table);
84 if (!mount_entry) {
83 endmntent(mount_table); 85 endmntent(mount_table);
84 break; 86 break;
85 } 87 }
86 } else { 88 } else {
87 if (!(mount_point = *argv++)) { 89 mount_point = *argv++;
90 if (!mount_point) {
88 break; 91 break;
89 } 92 }
90 if (!(mount_entry = find_mount_point(mount_point, bb_path_mtab_file))) { 93 mount_entry = find_mount_point(mount_point, bb_path_mtab_file);
91 bb_error_msg("%s: can't find mount point.", mount_point); 94 if (!mount_entry) {
95 bb_error_msg("%s: can't find mount point", mount_point);
92 SET_ERROR: 96 SET_ERROR:
93 status = EXIT_FAILURE; 97 status = EXIT_FAILURE;
94 continue; 98 continue;
@@ -108,8 +112,8 @@ int df_main(int argc, char **argv)
108 blocks_percent_used = 0; 112 blocks_percent_used = 0;
109 if (blocks_used + s.f_bavail) { 113 if (blocks_used + s.f_bavail) {
110 blocks_percent_used = (((long long) blocks_used) * 100 114 blocks_percent_used = (((long long) blocks_used) * 100
111 + (blocks_used + s.f_bavail)/2 115 + (blocks_used + s.f_bavail)/2
112 ) / (blocks_used + s.f_bavail); 116 ) / (blocks_used + s.f_bavail);
113 } 117 }
114 118
115 if (strcmp(device, "rootfs") == 0) { 119 if (strcmp(device, "rootfs") == 0) {
@@ -117,24 +121,25 @@ int df_main(int argc, char **argv)
117 } else if (strcmp(device, "/dev/root") == 0) { 121 } else if (strcmp(device, "/dev/root") == 0) {
118 /* Adjusts device to be the real root device, 122 /* Adjusts device to be the real root device,
119 * or leaves device alone if it can't find it */ 123 * or leaves device alone if it can't find it */
120 if ((device = find_block_device("/")) == NULL) { 124 device = find_block_device("/");
125 if (!device) {
121 goto SET_ERROR; 126 goto SET_ERROR;
122 } 127 }
123 } 128 }
124 129
125#ifdef CONFIG_FEATURE_HUMAN_READABLE 130#ifdef CONFIG_FEATURE_HUMAN_READABLE
126 bb_printf("%-20s %9s ", device, 131 printf("%-20s %9s ", device,
127 make_human_readable_str(s.f_blocks, s.f_bsize, df_disp_hr)); 132 make_human_readable_str(s.f_blocks, s.f_bsize, df_disp_hr));
128 133
129 bb_printf("%9s ", 134 printf("%9s ",
130 make_human_readable_str( (s.f_blocks - s.f_bfree), 135 make_human_readable_str( (s.f_blocks - s.f_bfree),
131 s.f_bsize, df_disp_hr)); 136 s.f_bsize, df_disp_hr));
132 137
133 bb_printf("%9s %3ld%% %s\n", 138 printf("%9s %3ld%% %s\n",
134 make_human_readable_str(s.f_bavail, s.f_bsize, df_disp_hr), 139 make_human_readable_str(s.f_bavail, s.f_bsize, df_disp_hr),
135 blocks_percent_used, mount_point); 140 blocks_percent_used, mount_point);
136#else 141#else
137 bb_printf("%-20s %9ld %9ld %9ld %3ld%% %s\n", 142 printf("%-20s %9ld %9ld %9ld %3ld%% %s\n",
138 device, 143 device,
139 kscale(s.f_blocks, s.f_bsize), 144 kscale(s.f_blocks, s.f_bsize),
140 kscale(s.f_blocks-s.f_bfree, s.f_bsize), 145 kscale(s.f_blocks-s.f_bfree, s.f_bsize),
@@ -145,5 +150,5 @@ int df_main(int argc, char **argv)
145 150
146 } while (1); 151 } while (1);
147 152
148 bb_fflush_stdout_and_exit(status); 153 fflush_stdout_and_exit(status);
149} 154}
diff --git a/coreutils/dirname.c b/coreutils/dirname.c
index 3471a2631..e986a9701 100644
--- a/coreutils/dirname.c
+++ b/coreutils/dirname.c
@@ -22,5 +22,5 @@ int dirname_main(int argc, char **argv)
22 22
23 puts(dirname(argv[1])); 23 puts(dirname(argv[1]));
24 24
25 bb_fflush_stdout_and_exit(EXIT_SUCCESS); 25 fflush_stdout_and_exit(EXIT_SUCCESS);
26} 26}
diff --git a/coreutils/du.c b/coreutils/du.c
index efc449097..cae76af38 100644
--- a/coreutils/du.c
+++ b/coreutils/du.c
@@ -56,14 +56,14 @@ static void print(long size, const char * const filename)
56{ 56{
57 /* TODO - May not want to defer error checking here. */ 57 /* TODO - May not want to defer error checking here. */
58#ifdef CONFIG_FEATURE_HUMAN_READABLE 58#ifdef CONFIG_FEATURE_HUMAN_READABLE
59 bb_printf("%s\t%s\n", make_human_readable_str(size, 512, disp_hr), 59 printf("%s\t%s\n", make_human_readable_str(size, 512, disp_hr),
60 filename); 60 filename);
61#else 61#else
62 if (disp_k) { 62 if (disp_k) {
63 size++; 63 size++;
64 size >>= 1; 64 size >>= 1;
65 } 65 }
66 bb_printf("%ld\t%s\n", size, filename); 66 printf("%ld\t%s\n", size, filename);
67#endif 67#endif
68} 68}
69 69
@@ -246,5 +246,5 @@ int du_main(int argc, char **argv)
246 print(total, "total"); 246 print(total, "total");
247 } 247 }
248 248
249 bb_fflush_stdout_and_exit(status); 249 fflush_stdout_and_exit(status);
250} 250}
diff --git a/coreutils/echo.c b/coreutils/echo.c
index d278c1143..99063ae52 100644
--- a/coreutils/echo.c
+++ b/coreutils/echo.c
@@ -115,7 +115,7 @@ just_echo:
115int echo_main(int argc, char** argv) 115int echo_main(int argc, char** argv)
116{ 116{
117 (void)bb_echo(argc, argv); 117 (void)bb_echo(argc, argv);
118 bb_fflush_stdout_and_exit(EXIT_SUCCESS); 118 fflush_stdout_and_exit(EXIT_SUCCESS);
119} 119}
120 120
121/*- 121/*-
diff --git a/coreutils/env.c b/coreutils/env.c
index d03318fea..2ce99b0ad 100644
--- a/coreutils/env.c
+++ b/coreutils/env.c
@@ -90,7 +90,7 @@ int env_main(int argc, char** argv)
90 puts(*ep); 90 puts(*ep);
91 } 91 }
92 92
93 bb_fflush_stdout_and_exit(0); 93 fflush_stdout_and_exit(0);
94} 94}
95 95
96/* 96/*
diff --git a/coreutils/expr.c b/coreutils/expr.c
index ea99d8b5b..854a657f9 100644
--- a/coreutils/expr.c
+++ b/coreutils/expr.c
@@ -87,11 +87,11 @@ int expr_main(int argc, char **argv)
87 bb_error_msg_and_die("syntax error"); 87 bb_error_msg_and_die("syntax error");
88 88
89 if (v->type == integer) 89 if (v->type == integer)
90 bb_printf("%" PF_REZ "d\n", PF_REZ_TYPE v->u.i); 90 printf("%" PF_REZ "d\n", PF_REZ_TYPE v->u.i);
91 else 91 else
92 puts(v->u.s); 92 puts(v->u.s);
93 93
94 exit(null(v)); 94 fflush_stdout_and_exit(null(v));
95} 95}
96 96
97/* Return a VALUE for I. */ 97/* Return a VALUE for I. */
diff --git a/coreutils/fold.c b/coreutils/fold.c
index 45f4472e4..e33be5594 100644
--- a/coreutils/fold.c
+++ b/coreutils/fold.c
@@ -150,5 +150,5 @@ rescan:
150 } 150 }
151 } while (*++argv); 151 } while (*++argv);
152 152
153 bb_fflush_stdout_and_exit(errs); 153 fflush_stdout_and_exit(errs);
154} 154}
diff --git a/coreutils/head.c b/coreutils/head.c
index 060febcf7..2e9000df4 100644
--- a/coreutils/head.c
+++ b/coreutils/head.c
@@ -112,12 +112,13 @@ int head_main(int argc, char **argv)
112#endif 112#endif
113 113
114 do { 114 do {
115 if ((fp = bb_wfopen_input(*argv)) != NULL) { 115 fp = bb_wfopen_input(*argv);
116 if (fp) {
116 if (fp == stdin) { 117 if (fp == stdin) {
117 *argv = (char *) bb_msg_standard_input; 118 *argv = (char *) bb_msg_standard_input;
118 } 119 }
119 if (header_threshhold) { 120 if (header_threshhold) {
120 bb_printf(fmt, *argv); 121 printf(fmt, *argv);
121 } 122 }
122 i = count; 123 i = count;
123 while (i && ((c = getc(fp)) != EOF)) { 124 while (i && ((c = getc(fp)) != EOF)) {
@@ -130,10 +131,10 @@ int head_main(int argc, char **argv)
130 bb_perror_msg("%s", *argv); /* Avoid multibyte problems. */ 131 bb_perror_msg("%s", *argv); /* Avoid multibyte problems. */
131 retval = EXIT_FAILURE; 132 retval = EXIT_FAILURE;
132 } 133 }
133 xferror_stdout(); 134 die_if_ferror_stdout();
134 } 135 }
135 fmt = header_fmt_str; 136 fmt = header_fmt_str;
136 } while (*++argv); 137 } while (*++argv);
137 138
138 bb_fflush_stdout_and_exit(retval); 139 fflush_stdout_and_exit(retval);
139} 140}
diff --git a/coreutils/hostid.c b/coreutils/hostid.c
index cda96726a..65447aa63 100644
--- a/coreutils/hostid.c
+++ b/coreutils/hostid.c
@@ -19,7 +19,7 @@ int hostid_main(int argc, char ATTRIBUTE_UNUSED **argv)
19 bb_show_usage(); 19 bb_show_usage();
20 } 20 }
21 21
22 bb_printf("%lx\n", gethostid()); 22 printf("%lx\n", gethostid());
23 23
24 bb_fflush_stdout_and_exit(EXIT_SUCCESS); 24 fflush_stdout_and_exit(EXIT_SUCCESS);
25} 25}
diff --git a/coreutils/id.c b/coreutils/id.c
index 9d605325c..66874a71e 100644
--- a/coreutils/id.c
+++ b/coreutils/id.c
@@ -35,7 +35,7 @@ static short printf_full(unsigned int id, const char *arg, const char prefix)
35 fmt = "%cid=%u(%s)"; 35 fmt = "%cid=%u(%s)";
36 status = EXIT_SUCCESS; 36 status = EXIT_SUCCESS;
37 } 37 }
38 bb_printf(fmt, prefix, id, arg); 38 printf(fmt, prefix, id, arg);
39 return status; 39 return status;
40} 40}
41 41
@@ -74,10 +74,10 @@ int id_main(int argc, char **argv)
74 /* bb_getpwuid and bb_getgrgid exit on failure so puts cannot segfault */ 74 /* bb_getpwuid and bb_getgrgid exit on failure so puts cannot segfault */
75 puts((flags & JUST_USER) ? bb_getpwuid(NULL, uid, -1 ) : bb_getgrgid(NULL, gid, -1 )); 75 puts((flags & JUST_USER) ? bb_getpwuid(NULL, uid, -1 ) : bb_getgrgid(NULL, gid, -1 ));
76 } else { 76 } else {
77 bb_printf("%u\n", (flags & JUST_USER) ? uid : gid); 77 printf("%u\n", (flags & JUST_USER) ? uid : gid);
78 } 78 }
79 /* exit */ 79 /* exit */
80 bb_fflush_stdout_and_exit(EXIT_SUCCESS); 80 fflush_stdout_and_exit(EXIT_SUCCESS);
81 } 81 }
82 82
83 /* Print full info like GNU id */ 83 /* Print full info like GNU id */
@@ -96,16 +96,16 @@ int id_main(int argc, char **argv)
96 getcon(&mysid); 96 getcon(&mysid);
97 context[0] = '\0'; 97 context[0] = '\0';
98 if (mysid) { 98 if (mysid) {
99 len = strlen(mysid)+1; 99 len = strlen(mysid)+1;
100 safe_strncpy(context, mysid, len); 100 safe_strncpy(context, mysid, len);
101 freecon(mysid); 101 freecon(mysid);
102 } else { 102 } else {
103 safe_strncpy(context, "unknown", 8); 103 safe_strncpy(context, "unknown", 8);
104 } 104 }
105 bb_printf(" context=%s", context); 105 printf(" context=%s", context);
106 } 106 }
107#endif 107#endif
108 108
109 putchar('\n'); 109 putchar('\n');
110 bb_fflush_stdout_and_exit(status); 110 fflush_stdout_and_exit(status);
111} 111}
diff --git a/coreutils/logname.c b/coreutils/logname.c
index da8a1cfc9..695a736c6 100644
--- a/coreutils/logname.c
+++ b/coreutils/logname.c
@@ -35,7 +35,7 @@ int logname_main(int argc, char ATTRIBUTE_UNUSED **argv)
35 35
36 if ((p = getlogin()) != NULL) { 36 if ((p = getlogin()) != NULL) {
37 puts(p); 37 puts(p);
38 bb_fflush_stdout_and_exit(EXIT_SUCCESS); 38 fflush_stdout_and_exit(EXIT_SUCCESS);
39 } 39 }
40 40
41 bb_perror_msg_and_die("getlogin"); 41 bb_perror_msg_and_die("getlogin");
diff --git a/coreutils/nice.c b/coreutils/nice.c
index dbd90648d..293861842 100644
--- a/coreutils/nice.c
+++ b/coreutils/nice.c
@@ -17,8 +17,8 @@ int nice_main(int argc, char **argv)
17 old_priority = getpriority(PRIO_PROCESS, 0); 17 old_priority = getpriority(PRIO_PROCESS, 0);
18 18
19 if (!*++argv) { /* No args, so (GNU) output current nice value. */ 19 if (!*++argv) { /* No args, so (GNU) output current nice value. */
20 bb_printf("%d\n", old_priority); 20 printf("%d\n", old_priority);
21 bb_fflush_stdout_and_exit(EXIT_SUCCESS); 21 fflush_stdout_and_exit(EXIT_SUCCESS);
22 } 22 }
23 23
24 adjustment = 10; /* Set default adjustment. */ 24 adjustment = 10; /* Set default adjustment. */
diff --git a/coreutils/printenv.c b/coreutils/printenv.c
index aea88d701..ec50f7151 100644
--- a/coreutils/printenv.c
+++ b/coreutils/printenv.c
@@ -37,5 +37,5 @@ int printenv_main(int argc, char **argv)
37 } 37 }
38 } 38 }
39 39
40 bb_fflush_stdout_and_exit(0); 40 fflush_stdout_and_exit(0);
41} 41}
diff --git a/coreutils/pwd.c b/coreutils/pwd.c
index b2d7c0e5f..bd36d627e 100644
--- a/coreutils/pwd.c
+++ b/coreutils/pwd.c
@@ -17,7 +17,7 @@ int pwd_main(int argc, char **argv)
17 17
18 if ((buf = xgetcwd(NULL)) != NULL) { 18 if ((buf = xgetcwd(NULL)) != NULL) {
19 puts(buf); 19 puts(buf);
20 bb_fflush_stdout_and_exit(EXIT_SUCCESS); 20 fflush_stdout_and_exit(EXIT_SUCCESS);
21 } 21 }
22 22
23 return EXIT_FAILURE; 23 return EXIT_FAILURE;
diff --git a/coreutils/realpath.c b/coreutils/realpath.c
index 0fd2c7625..5f3242fb5 100644
--- a/coreutils/realpath.c
+++ b/coreutils/realpath.c
@@ -44,5 +44,5 @@ int realpath_main(int argc, char **argv)
44 RELEASE_CONFIG_BUFFER(resolved_path); 44 RELEASE_CONFIG_BUFFER(resolved_path);
45#endif 45#endif
46 46
47 bb_fflush_stdout_and_exit(retval); 47 fflush_stdout_and_exit(retval);
48} 48}
diff --git a/coreutils/sort.c b/coreutils/sort.c
index c23c14226..972477bab 100644
--- a/coreutils/sort.c
+++ b/coreutils/sort.c
@@ -318,5 +318,5 @@ int sort_main(int argc, char **argv)
318 /* Print it */ 318 /* Print it */
319 if(!outfile) outfile=stdout; 319 if(!outfile) outfile=stdout;
320 for(i=0;i<linecount;i++) fprintf(outfile,"%s\n",lines[i]); 320 for(i=0;i<linecount;i++) fprintf(outfile,"%s\n",lines[i]);
321 bb_fflush_stdout_and_exit(EXIT_SUCCESS); 321 fflush_stdout_and_exit(EXIT_SUCCESS);
322} 322}
diff --git a/coreutils/tee.c b/coreutils/tee.c
index a194153e0..f0e1fad86 100644
--- a/coreutils/tee.c
+++ b/coreutils/tee.c
@@ -85,7 +85,7 @@ int tee_main(int argc, char **argv)
85 * output files. Since we know that the first entry in the output 85 * output files. Since we know that the first entry in the output
86 * file table is stdout, we can save one "if ferror" test by 86 * file table is stdout, we can save one "if ferror" test by
87 * setting the first entry to stdin and checking stdout error 87 * setting the first entry to stdin and checking stdout error
88 * status with bb_fflush_stdout_and_exit()... although fflush()ing 88 * status with fflush_stdout_and_exit()... although fflush()ing
89 * is unnecessary here. */ 89 * is unnecessary here. */
90 90
91 p = files; 91 p = files;
@@ -93,8 +93,8 @@ int tee_main(int argc, char **argv)
93 do { /* Now check for (input and) output errors. */ 93 do { /* Now check for (input and) output errors. */
94 /* Checking ferror should be sufficient, but we may want to fclose. 94 /* Checking ferror should be sufficient, but we may want to fclose.
95 * If we do, remember not to close stdin! */ 95 * If we do, remember not to close stdin! */
96 xferror(*p, filenames[(int)(p - files)]); 96 die_if_ferror(*p, filenames[(int)(p - files)]);
97 } while (*++p); 97 } while (*++p);
98 98
99 bb_fflush_stdout_and_exit(retval); 99 fflush_stdout_and_exit(retval);
100} 100}
diff --git a/coreutils/tty.c b/coreutils/tty.c
index 579e6f73c..b2ab862ec 100644
--- a/coreutils/tty.c
+++ b/coreutils/tty.c
@@ -41,5 +41,5 @@ int tty_main(int argc, char **argv)
41 puts(s); 41 puts(s);
42 } 42 }
43 43
44 bb_fflush_stdout_and_exit(retval); 44 fflush_stdout_and_exit(retval);
45} 45}
diff --git a/coreutils/uname.c b/coreutils/uname.c
index 575fb525c..5a3eafe92 100644
--- a/coreutils/uname.c
+++ b/coreutils/uname.c
@@ -91,10 +91,10 @@ int uname_main(int argc, char **argv)
91 91
92 strcpy(uname_info.processor, "unknown"); 92 strcpy(uname_info.processor, "unknown");
93 93
94 delta=utsname_offset; 94 delta = utsname_offset;
95 do { 95 do {
96 if (toprint & 1) { 96 if (toprint & 1) {
97 bb_printf(((char *)(&uname_info)) + *delta); 97 printf(((char *)(&uname_info)) + *delta);
98 if (toprint > 1) { 98 if (toprint > 1) {
99 putchar(' '); 99 putchar(' ');
100 } 100 }
@@ -103,5 +103,5 @@ int uname_main(int argc, char **argv)
103 } while (toprint >>= 1); 103 } while (toprint >>= 1);
104 putchar('\n'); 104 putchar('\n');
105 105
106 bb_fflush_stdout_and_exit(EXIT_SUCCESS); 106 fflush_stdout_and_exit(EXIT_SUCCESS);
107} 107}
diff --git a/coreutils/uniq.c b/coreutils/uniq.c
index a7b7a8e07..100f2be00 100644
--- a/coreutils/uniq.c
+++ b/coreutils/uniq.c
@@ -37,7 +37,7 @@ int uniq_main(int argc, char **argv)
37 37
38 while ((opt = getopt(argc, argv, uniq_opts)) > 0) { 38 while ((opt = getopt(argc, argv, uniq_opts)) > 0) {
39 if ((opt == 'f') || (opt == 's')) { 39 if ((opt == 'f') || (opt == 's')) {
40 int t = xatoul(optarg); 40 unsigned long t = xatoul(optarg);
41 if (opt == 'f') { 41 if (opt == 'f') {
42 skip_fields = t; 42 skip_fields = t;
43 } else { 43 } else {
@@ -71,13 +71,13 @@ int uniq_main(int argc, char **argv)
71 /* gnu uniq ignores newlines */ 71 /* gnu uniq ignores newlines */
72 while ((s1 = xmalloc_getline(in)) != NULL) { 72 while ((s1 = xmalloc_getline(in)) != NULL) {
73 e1 = s1; 73 e1 = s1;
74 for (i=skip_fields ; i ; i--) { 74 for (i = skip_fields; i; i--) {
75 e1 = skip_whitespace(e1); 75 e1 = skip_whitespace(e1);
76 while (*e1 && !isspace(*e1)) { 76 while (*e1 && !isspace(*e1)) {
77 ++e1; 77 ++e1;
78 } 78 }
79 } 79 }
80 for (i = skip_chars ; *e1 && i ; i--) { 80 for (i = skip_chars; *e1 && i; i--) {
81 ++e1; 81 ++e1;
82 } 82 }
83 83
@@ -90,14 +90,14 @@ int uniq_main(int argc, char **argv)
90 90
91 if (s0) { 91 if (s0) {
92 if (!(uniq_flags & (2 << !!dups))) { 92 if (!(uniq_flags & (2 << !!dups))) {
93 bb_fprintf(out, "\0%d " + (uniq_flags & 1), dups + 1); 93 fprintf(out, "\0%d " + (uniq_flags & 1), dups + 1);
94 bb_fprintf(out, "%s\n", s0); 94 fprintf(out, "%s\n", s0);
95 } 95 }
96 free((void *)s0); 96 free((void *)s0);
97 } 97 }
98 } while (s1); 98 } while (s1);
99 99
100 xferror(in, input_filename); 100 die_if_ferror(in, input_filename);
101 101
102 bb_fflush_stdout_and_exit(EXIT_SUCCESS); 102 fflush_stdout_and_exit(EXIT_SUCCESS);
103} 103}
diff --git a/coreutils/uuencode.c b/coreutils/uuencode.c
index 58538365e..e8f8d541c 100644
--- a/coreutils/uuencode.c
+++ b/coreutils/uuencode.c
@@ -47,12 +47,12 @@ int uuencode_main(int argc, char **argv)
47 bb_show_usage(); 47 bb_show_usage();
48 } 48 }
49 49
50 bb_printf("begin%s %o %s", tbl == bb_uuenc_tbl_std ? "" : "-base64", mode, argv[argc - 1]); 50 printf("begin%s %o %s", tbl == bb_uuenc_tbl_std ? "" : "-base64", mode, argv[argc - 1]);
51 51
52 while ((size = fread(src_buf, 1, src_buf_size, src_stream)) > 0) { 52 while ((size = fread(src_buf, 1, src_buf_size, src_stream)) > 0) {
53 if (size != src_buf_size) { 53 if (size != src_buf_size) {
54 /* write_size is always 60 until the last line */ 54 /* write_size is always 60 until the last line */
55 write_size=(4 * ((size + 2) / 3)); 55 write_size = (4 * ((size + 2) / 3));
56 /* pad with 0s so we can just encode extra bits */ 56 /* pad with 0s so we can just encode extra bits */
57 memset(&src_buf[size], 0, src_buf_size - size); 57 memset(&src_buf[size], 0, src_buf_size - size);
58 } 58 }
@@ -67,9 +67,9 @@ int uuencode_main(int argc, char **argv)
67 bb_perror_msg_and_die(bb_msg_write_error); 67 bb_perror_msg_and_die(bb_msg_write_error);
68 } 68 }
69 } 69 }
70 bb_printf(tbl == bb_uuenc_tbl_std ? "\n`\nend\n" : "\n====\n"); 70 printf(tbl == bb_uuenc_tbl_std ? "\n`\nend\n" : "\n====\n");
71 71
72 xferror(src_stream, "source"); /* TODO - Fix this! */ 72 die_if_ferror(src_stream, "source"); /* TODO - Fix this! */
73 73
74 bb_fflush_stdout_and_exit(EXIT_SUCCESS); 74 fflush_stdout_and_exit(EXIT_SUCCESS);
75} 75}
diff --git a/coreutils/wc.c b/coreutils/wc.c
index 359d9fd6d..ebae5f69f 100644
--- a/coreutils/wc.c
+++ b/coreutils/wc.c
@@ -182,12 +182,12 @@ int wc_main(int argc, char **argv)
182 u = 0; 182 u = 0;
183 do { 183 do {
184 if (print_type & (1 << u)) { 184 if (print_type & (1 << u)) {
185 bb_printf(s, pcounts[u]); 185 printf(s, pcounts[u]);
186 s = " %9"COUNT_FMT; /* Ok... restore the leading space. */ 186 s = " %9"COUNT_FMT; /* Ok... restore the leading space. */
187 } 187 }
188 totals[u] += pcounts[u]; 188 totals[u] += pcounts[u];
189 } while (++u < 4); 189 } while (++u < 4);
190 bb_printf(fname_fmt, arg); 190 printf(fname_fmt, arg);
191 } 191 }
192 192
193 /* If more than one file was processed, we want the totals. To save some 193 /* 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)
202 goto OUTPUT; 202 goto OUTPUT;
203 } 203 }
204 204
205 bb_fflush_stdout_and_exit(status); 205 fflush_stdout_and_exit(status);
206} 206}
diff --git a/coreutils/whoami.c b/coreutils/whoami.c
index 5cdec922b..df714f22c 100644
--- a/coreutils/whoami.c
+++ b/coreutils/whoami.c
@@ -21,5 +21,5 @@ int whoami_main(int argc, char **argv)
21 21
22 puts(bb_getpwuid(NULL, geteuid(), -1)); 22 puts(bb_getpwuid(NULL, geteuid(), -1));
23 /* exits on error */ 23 /* exits on error */
24 bb_fflush_stdout_and_exit(EXIT_SUCCESS); 24 fflush_stdout_and_exit(EXIT_SUCCESS);
25} 25}
diff --git a/coreutils/yes.c b/coreutils/yes.c
index 97b4fe54c..894506a89 100644
--- a/coreutils/yes.c
+++ b/coreutils/yes.c
@@ -14,8 +14,6 @@
14 * Size reductions and removed redundant applet name prefix from error messages. 14 * Size reductions and removed redundant applet name prefix from error messages.
15 */ 15 */
16 16
17#include <stdio.h>
18#include <stdlib.h>
19#include "busybox.h" 17#include "busybox.h"
20 18
21int yes_main(int argc, char **argv) 19int yes_main(int argc, char **argv)
@@ -33,7 +31,7 @@ int yes_main(int argc, char **argv)
33 do { 31 do {
34 fmt = fmt_str + 1; 32 fmt = fmt_str + 1;
35 do { 33 do {
36 bb_printf(fmt, *argv); 34 printf(fmt, *argv);
37 fmt = fmt_str; 35 fmt = fmt_str;
38 } while (*++argv); 36 } while (*++argv);
39 argv = first_arg; 37 argv = first_arg;
diff --git a/debianutils/readlink.c b/debianutils/readlink.c
index 9536d3200..400259080 100644
--- a/debianutils/readlink.c
+++ b/debianutils/readlink.c
@@ -47,5 +47,5 @@ int readlink_main(int argc, char **argv)
47 if (ENABLE_FEATURE_CLEAN_UP && buf != bb_common_bufsiz1) 47 if (ENABLE_FEATURE_CLEAN_UP && buf != bb_common_bufsiz1)
48 free(buf); 48 free(buf);
49 49
50 bb_fflush_stdout_and_exit(EXIT_SUCCESS); 50 fflush_stdout_and_exit(EXIT_SUCCESS);
51} 51}
diff --git a/debianutils/which.c b/debianutils/which.c
index e83c752a1..a715a2664 100644
--- a/debianutils/which.c
+++ b/debianutils/which.c
@@ -39,5 +39,5 @@ int which_main(int argc, char **argv)
39 status = EXIT_FAILURE; 39 status = EXIT_FAILURE;
40 } 40 }
41 41
42 bb_fflush_stdout_and_exit(status); 42 fflush_stdout_and_exit(status);
43} 43}
diff --git a/e2fsprogs/mke2fs.c b/e2fsprogs/mke2fs.c
index 30110f8b6..1c4f1541e 100644
--- a/e2fsprogs/mke2fs.c
+++ b/e2fsprogs/mke2fs.c
@@ -177,9 +177,9 @@ static void mke2fs_error_msg_and_die(int retval, const char *fmt, ...)
177 177
178 if (retval) { 178 if (retval) {
179 va_start(ap, fmt); 179 va_start(ap, fmt);
180 bb_fprintf(stderr,"\nCould not "); 180 fprintf(stderr,"\nCould not ");
181 bb_vfprintf(stderr, fmt, ap); 181 vfprintf(stderr, fmt, ap);
182 bb_fprintf(stderr, "\n"); 182 fprintf(stderr, "\n");
183 va_end(ap); 183 va_end(ap);
184 exit(EXIT_FAILURE); 184 exit(EXIT_FAILURE);
185 } 185 }
@@ -192,7 +192,7 @@ static void mke2fs_verbose(const char *fmt, ...)
192 192
193 if (!quiet) { 193 if (!quiet) {
194 va_start(ap, fmt); 194 va_start(ap, fmt);
195 bb_vfprintf(stdout, fmt, ap); 195 vfprintf(stdout, fmt, ap);
196 fflush(stdout); 196 fflush(stdout);
197 va_end(ap); 197 va_end(ap);
198 } 198 }
@@ -210,9 +210,9 @@ static void mke2fs_warning_msg(int retval, char *fmt, ... )
210 210
211 if (retval) { 211 if (retval) {
212 va_start(ap, fmt); 212 va_start(ap, fmt);
213 bb_fprintf(stderr,"\nWarning: "); 213 fprintf(stderr,"\nWarning: ");
214 bb_vfprintf(stderr, fmt, ap); 214 vfprintf(stderr, fmt, ap);
215 bb_fprintf(stderr, "\n"); 215 fprintf(stderr, "\n");
216 va_end(ap); 216 va_end(ap);
217 } 217 }
218} 218}
diff --git a/include/libbb.h b/include/libbb.h
index a2267f942..f435a5915 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -227,7 +227,7 @@ extern int recursive_action(const char *fileName, int recurse,
227 int (*dirAction) (const char *fileName, struct stat* statbuf, void* userData), 227 int (*dirAction) (const char *fileName, struct stat* statbuf, void* userData),
228 void* userData); 228 void* userData);
229 229
230extern int bb_parse_mode( const char* s, mode_t* theMode); 230extern int bb_parse_mode(const char* s, mode_t* theMode);
231 231
232extern unsigned int tty_baud_to_value(speed_t speed); 232extern unsigned int tty_baud_to_value(speed_t speed);
233extern speed_t tty_value_to_baud(unsigned int value); 233extern speed_t tty_value_to_baud(unsigned int value);
@@ -253,7 +253,7 @@ extern FILE *bb_wfopen_input(const char *filename);
253extern FILE *xfopen(const char *path, const char *mode); 253extern FILE *xfopen(const char *path, const char *mode);
254 254
255extern int bb_fclose_nonstdin(FILE *f); 255extern int bb_fclose_nonstdin(FILE *f);
256extern void bb_fflush_stdout_and_exit(int retval) ATTRIBUTE_NORETURN; 256extern void fflush_stdout_and_exit(int retval) ATTRIBUTE_NORETURN;
257 257
258extern void xstat(char *filename, struct stat *buf); 258extern void xstat(char *filename, struct stat *buf);
259extern int xsocket(int domain, int type, int protocol); 259extern int xsocket(int domain, int type, int protocol);
@@ -278,17 +278,8 @@ extern const struct option *applet_long_options;
278extern uint32_t option_mask32; 278extern uint32_t option_mask32;
279extern uint32_t getopt32(int argc, char **argv, const char *applet_opts, ...); 279extern uint32_t getopt32(int argc, char **argv, const char *applet_opts, ...);
280 280
281extern int bb_vfprintf(FILE * __restrict stream, const char * __restrict format, 281extern void die_if_ferror(FILE *fp, const char *fn);
282 va_list arg) __attribute__ ((format (printf, 2, 0))); 282extern void die_if_ferror_stdout(void);
283extern int bb_vprintf(const char * __restrict format, va_list arg)
284 __attribute__ ((format (printf, 1, 0)));
285extern int bb_fprintf(FILE * __restrict stream, const char * __restrict format, ...)
286 __attribute__ ((format (printf, 2, 3)));
287extern int bb_printf(const char * __restrict format, ...)
288 __attribute__ ((format (printf, 1, 2)));
289
290extern void xferror(FILE *fp, const char *fn);
291extern void xferror_stdout(void);
292extern void xfflush_stdout(void); 283extern void xfflush_stdout(void);
293 284
294extern void bb_warn_ignoring_args(int n); 285extern void bb_warn_ignoring_args(int n);
diff --git a/libbb/Kbuild b/libbb/Kbuild
index 3b16f5c45..0dd8c2be4 100644
--- a/libbb/Kbuild
+++ b/libbb/Kbuild
@@ -54,7 +54,6 @@ lib-$(CONFIG_DEVFSD) += xregcomp.o
54 54
55lib-y += messages.o 55lib-y += messages.o
56lib-y += xfuncs.o 56lib-y += xfuncs.o
57lib-y += printf.o
58lib-y += xatol.o 57lib-y += xatol.o
59lib-y += safe_strtol.o 58lib-y += safe_strtol.o
60lib-y += bb_pwd.o 59lib-y += bb_pwd.o
diff --git a/libbb/fflush_stdout_and_exit.c b/libbb/fflush_stdout_and_exit.c
index 6df8dde13..456ce9513 100644
--- a/libbb/fflush_stdout_and_exit.c
+++ b/libbb/fflush_stdout_and_exit.c
@@ -11,11 +11,9 @@
11 * in an error state. 11 * in an error state.
12 */ 12 */
13 13
14#include <stdio.h> 14#include "libbb.h"
15#include <stdlib.h>
16#include <libbb.h>
17 15
18void bb_fflush_stdout_and_exit(int retval) 16void fflush_stdout_and_exit(int retval)
19{ 17{
20 if (fflush(stdout)) { 18 if (fflush(stdout)) {
21 retval = xfunc_error_retval; 19 retval = xfunc_error_retval;
diff --git a/libbb/getopt32.c b/libbb/getopt32.c
index 967729a1b..f442933a3 100644
--- a/libbb/getopt32.c
+++ b/libbb/getopt32.c
@@ -143,7 +143,7 @@ const char *opt_complementary
143 while (my_b) { dosomething_with(my_b->data); my_b = my_b->link; } 143 while (my_b) { dosomething_with(my_b->data); my_b = my_b->link; }
144 if (my_b) // but llist is stored if -b is specified 144 if (my_b) // but llist is stored if -b is specified
145 free_llist(my_b); 145 free_llist(my_b);
146 if (verbose_level) bb_printf("verbose level is %d\n", verbose_level); 146 if (verbose_level) printf("verbose level is %d\n", verbose_level);
147 147
148Special characters: 148Special characters:
149 149
diff --git a/libbb/xfuncs.c b/libbb/xfuncs.c
index 0a6d90de5..c5e18c312 100644
--- a/libbb/xfuncs.c
+++ b/libbb/xfuncs.c
@@ -130,7 +130,7 @@ off_t xlseek(int fd, off_t offset, int whence)
130} 130}
131 131
132// Die with supplied error message if this FILE * has ferror set. 132// Die with supplied error message if this FILE * has ferror set.
133void xferror(FILE *fp, const char *fn) 133void die_if_ferror(FILE *fp, const char *fn)
134{ 134{
135 if (ferror(fp)) { 135 if (ferror(fp)) {
136 bb_error_msg_and_die("%s", fn); 136 bb_error_msg_and_die("%s", fn);
@@ -138,9 +138,9 @@ void xferror(FILE *fp, const char *fn)
138} 138}
139 139
140// Die with an error message if stdout has ferror set. 140// Die with an error message if stdout has ferror set.
141void xferror_stdout(void) 141void die_if_ferror_stdout(void)
142{ 142{
143 xferror(stdout, bb_msg_standard_output); 143 die_if_ferror(stdout, bb_msg_standard_output);
144} 144}
145 145
146// Die with an error message if we have trouble flushing stdout. 146// Die with an error message if we have trouble flushing stdout.
diff --git a/miscutils/crond.c b/miscutils/crond.c
index 4fc940b79..b18e27489 100644
--- a/miscutils/crond.c
+++ b/miscutils/crond.c
@@ -264,7 +264,7 @@ int crond_main(int ac, char **av)
264 } 264 }
265 } 265 }
266 } 266 }
267 bb_fflush_stdout_and_exit(EXIT_SUCCESS); /* not reached */ 267 return 0; /* not reached */
268} 268}
269 269
270static int ChangeUser(const char *user) 270static int ChangeUser(const char *user)
@@ -278,7 +278,7 @@ static int ChangeUser(const char *user)
278 pas = getpwnam(user); 278 pas = getpwnam(user);
279 if (pas == 0) { 279 if (pas == 0) {
280 crondlog("\011failed to get uid for %s", user); 280 crondlog("\011failed to get uid for %s", user);
281 return (-1); 281 return -1;
282 } 282 }
283 setenv("USER", pas->pw_name, 1); 283 setenv("USER", pas->pw_name, 1);
284 setenv("HOME", pas->pw_dir, 1); 284 setenv("HOME", pas->pw_dir, 1);
@@ -290,16 +290,16 @@ static int ChangeUser(const char *user)
290 err_msg = change_identity_e2str(pas); 290 err_msg = change_identity_e2str(pas);
291 if (err_msg) { 291 if (err_msg) {
292 crondlog("\011%s for user %s", err_msg, user); 292 crondlog("\011%s for user %s", err_msg, user);
293 return (-1); 293 return -1;
294 } 294 }
295 if (chdir(pas->pw_dir) < 0) { 295 if (chdir(pas->pw_dir) < 0) {
296 crondlog("\011chdir failed: %s: %m", pas->pw_dir); 296 crondlog("\011chdir failed: %s: %m", pas->pw_dir);
297 if (chdir(TMPDIR) < 0) { 297 if (chdir(TMPDIR) < 0) {
298 crondlog("\011chdir failed: %s: %m", TMPDIR); 298 crondlog("\011chdir failed: %s: %m", TMPDIR);
299 return (-1); 299 return -1;
300 } 300 }
301 } 301 }
302 return (pas->pw_uid); 302 return pas->pw_uid;
303} 303}
304 304
305static void startlogger(void) 305static void startlogger(void)
@@ -377,7 +377,7 @@ static char *ParseField(char *user, char *ary, int modvalue, int off,
377 int n2 = -1; 377 int n2 = -1;
378 378
379 if (base == NULL) { 379 if (base == NULL) {
380 return (NULL); 380 return NULL;
381 } 381 }
382 382
383 while (*ptr != ' ' && *ptr != '\t' && *ptr != '\n') { 383 while (*ptr != ' ' && *ptr != '\t' && *ptr != '\n') {
@@ -420,7 +420,7 @@ static char *ParseField(char *user, char *ary, int modvalue, int off,
420 420
421 if (skip == 0) { 421 if (skip == 0) {
422 crondlog("\111failed user %s parsing %s\n", user, base); 422 crondlog("\111failed user %s parsing %s\n", user, base);
423 return (NULL); 423 return NULL;
424 } 424 }
425 if (*ptr == '-' && n2 < 0) { 425 if (*ptr == '-' && n2 < 0) {
426 ++ptr; 426 ++ptr;
@@ -460,7 +460,7 @@ static char *ParseField(char *user, char *ary, int modvalue, int off,
460 460
461 if (failsafe == 0) { 461 if (failsafe == 0) {
462 crondlog("\111failed user %s parsing %s\n", user, base); 462 crondlog("\111failed user %s parsing %s\n", user, base);
463 return (NULL); 463 return NULL;
464 } 464 }
465 } 465 }
466 if (*ptr != ',') { 466 if (*ptr != ',') {
@@ -473,7 +473,7 @@ static char *ParseField(char *user, char *ary, int modvalue, int off,
473 473
474 if (*ptr != ' ' && *ptr != '\t' && *ptr != '\n') { 474 if (*ptr != ' ' && *ptr != '\t' && *ptr != '\n') {
475 crondlog("\111failed user %s parsing %s\n", user, base); 475 crondlog("\111failed user %s parsing %s\n", user, base);
476 return (NULL); 476 return NULL;
477 } 477 }
478 478
479 while (*ptr == ' ' || *ptr == '\t' || *ptr == '\n') { 479 while (*ptr == ' ' || *ptr == '\t' || *ptr == '\n') {
@@ -490,7 +490,7 @@ static char *ParseField(char *user, char *ary, int modvalue, int off,
490 } 490 }
491#endif 491#endif
492 492
493 return (ptr); 493 return ptr;
494} 494}
495 495
496static void FixDayDow(CronLine * line) 496static void FixDayDow(CronLine * line)
@@ -777,7 +777,7 @@ static int TestJobs(time_t t1, time_t t2)
777 } 777 }
778 } 778 }
779 } 779 }
780 return (nJobs); 780 return nJobs;
781} 781}
782 782
783static void RunJobs(void) 783static void RunJobs(void)
@@ -843,7 +843,7 @@ static int CheckJobs(void)
843 } 843 }
844 nStillRunning += file->cf_Running; 844 nStillRunning += file->cf_Running;
845 } 845 }
846 return (nStillRunning); 846 return nStillRunning;
847} 847}
848 848
849 849
diff --git a/miscutils/devfsd.c b/miscutils/devfsd.c
index f1fee2c90..32973d630 100644
--- a/miscutils/devfsd.c
+++ b/miscutils/devfsd.c
@@ -491,9 +491,9 @@ int devfsd_main (int argc, char **argv)
491 491
492 if ( print_version || (DEVFSD_PROTOCOL_REVISION_DAEMON != proto_rev) ) 492 if ( print_version || (DEVFSD_PROTOCOL_REVISION_DAEMON != proto_rev) )
493 { 493 {
494 bb_printf( "%s v%s\nDaemon %s:\t%d\nKernel-side %s:\t%d\n", 494 printf( "%s v%s\nDaemon %s:\t%d\nKernel-side %s:\t%d\n",
495 applet_name,DEVFSD_VERSION,bb_msg_proto_rev, 495 applet_name,DEVFSD_VERSION,bb_msg_proto_rev,
496 DEVFSD_PROTOCOL_REVISION_DAEMON,bb_msg_proto_rev, proto_rev); 496 DEVFSD_PROTOCOL_REVISION_DAEMON,bb_msg_proto_rev, proto_rev);
497 if (DEVFSD_PROTOCOL_REVISION_DAEMON != proto_rev) 497 if (DEVFSD_PROTOCOL_REVISION_DAEMON != proto_rev)
498 bb_error_msg_and_die( "%s mismatch!",bb_msg_proto_rev); 498 bb_error_msg_and_die( "%s mismatch!",bb_msg_proto_rev);
499 exit(EXIT_SUCCESS); /* -v */ 499 exit(EXIT_SUCCESS); /* -v */
@@ -509,7 +509,7 @@ int devfsd_main (int argc, char **argv)
509 if (sigaction (SIGHUP, &new_action, NULL) != 0 || sigaction (SIGUSR1, &new_action, NULL) != 0 ) 509 if (sigaction (SIGHUP, &new_action, NULL) != 0 || sigaction (SIGUSR1, &new_action, NULL) != 0 )
510 devfsd_error_msg_and_die( "sigaction"); 510 devfsd_error_msg_and_die( "sigaction");
511 511
512 bb_printf("%s v%s started for %s\n",applet_name, DEVFSD_VERSION, mount_point); 512 printf("%s v%s started for %s\n",applet_name, DEVFSD_VERSION, mount_point);
513 513
514 /* Set umask so that mknod(2), open(2) and mkdir(2) have complete control over permissions */ 514 /* Set umask so that mknod(2), open(2) and mkdir(2) have complete control over permissions */
515 umask (0); 515 umask (0);
diff --git a/miscutils/last.c b/miscutils/last.c
index 9f9f639f2..668f0c17d 100644
--- a/miscutils/last.c
+++ b/miscutils/last.c
@@ -87,5 +87,5 @@ int last_main(int argc, char **argv)
87 ctime(&t_tmp) + 4); 87 ctime(&t_tmp) + 4);
88 } 88 }
89 89
90 bb_fflush_stdout_and_exit(EXIT_SUCCESS); 90 fflush_stdout_and_exit(EXIT_SUCCESS);
91} 91}
diff --git a/miscutils/less.c b/miscutils/less.c
index 11f1d8baa..de97ba6b9 100644
--- a/miscutils/less.c
+++ b/miscutils/less.c
@@ -76,7 +76,7 @@ static int num_files = 1;
76static int past_eof; 76static int past_eof;
77 77
78/* Command line options */ 78/* Command line options */
79static unsigned long flags; 79static unsigned flags;
80#define FLAG_E 1 80#define FLAG_E 1
81#define FLAG_M (1<<1) 81#define FLAG_M (1<<1)
82#define FLAG_m (1<<2) 82#define FLAG_m (1<<2)
@@ -185,12 +185,12 @@ static void clear_line(void)
185/* This adds line numbers to every line, as the -N flag necessitates */ 185/* This adds line numbers to every line, as the -N flag necessitates */
186static void add_linenumbers(void) 186static void add_linenumbers(void)
187{ 187{
188 char current_line[256];
189 int i; 188 int i;
190 189
191 for (i = 0; i <= num_flines; i++) { 190 for (i = 0; i <= num_flines; i++) {
192 safe_strncpy(current_line, flines[i], 256); 191 char *new = xasprintf("%5d %s", i + 1, flines[i]);
193 flines[i] = xasprintf("%5d %s", i + 1, current_line); 192 free(flines[i]);
193 flines[i] = new;
194 } 194 }
195} 195}
196 196
@@ -206,7 +206,7 @@ static void data_readlines(void)
206 strcpy(current_line, ""); 206 strcpy(current_line, "");
207 fgets(current_line, 256, fp); 207 fgets(current_line, 256, fp);
208 if (fp != stdin) 208 if (fp != stdin)
209 xferror(fp, filename); 209 die_if_ferror(fp, filename);
210 flines = xrealloc(flines, (i+1) * sizeof(char *)); 210 flines = xrealloc(flines, (i+1) * sizeof(char *));
211 flines[i] = xstrdup(current_line); 211 flines[i] = xstrdup(current_line);
212 } 212 }
@@ -243,13 +243,18 @@ static void m_status_print(void)
243 if (!past_eof) { 243 if (!past_eof) {
244 if (!line_pos) { 244 if (!line_pos) {
245 if (num_files > 1) 245 if (num_files > 1)
246 printf("%s%s %s%i%s%i%s%i-%i/%i ", HIGHLIGHT, filename, "(file ", current_file, " of ", num_files, ") lines ", line_pos + 1, line_pos + height - 1, num_flines + 1); 246 printf("%s%s %s%i%s%i%s%i-%i/%i ", HIGHLIGHT,
247 filename, "(file ", current_file, " of ", num_files, ") lines ",
248 line_pos + 1, line_pos + height - 1, num_flines + 1);
247 else { 249 else {
248 printf("%s%s lines %i-%i/%i ", HIGHLIGHT, filename, line_pos + 1, line_pos + height - 1, num_flines + 1); 250 printf("%s%s lines %i-%i/%i ", HIGHLIGHT,
251 filename, line_pos + 1, line_pos + height - 1,
252 num_flines + 1);
249 } 253 }
250 } 254 }
251 else { 255 else {
252 printf("%s %s lines %i-%i/%i ", HIGHLIGHT, filename, line_pos + 1, line_pos + height - 1, num_flines + 1); 256 printf("%s %s lines %i-%i/%i ", HIGHLIGHT, filename,
257 line_pos + 1, line_pos + height - 1, num_flines + 1);
253 } 258 }
254 259
255 if (line_pos == num_flines - height + 2) { 260 if (line_pos == num_flines - height + 2) {
@@ -263,7 +268,8 @@ static void m_status_print(void)
263 } 268 }
264 } 269 }
265 else { 270 else {
266 printf("%s%s lines %i-%i/%i (END) ", HIGHLIGHT, filename, line_pos + 1, num_flines + 1, num_flines + 1); 271 printf("%s%s lines %i-%i/%i (END) ", HIGHLIGHT, filename,
272 line_pos + 1, num_flines + 1, num_flines + 1);
267 if ((num_files > 1) && (current_file != num_files)) 273 if ((num_files > 1) && (current_file != num_files))
268 printf("- Next: %s", files[current_file]); 274 printf("- Next: %s", files[current_file]);
269 printf("%s", NORMAL); 275 printf("%s", NORMAL);
@@ -300,7 +306,8 @@ static void status_print(void)
300 if (!line_pos) { 306 if (!line_pos) {
301 printf("%s%s %s", HIGHLIGHT, filename, NORMAL); 307 printf("%s%s %s", HIGHLIGHT, filename, NORMAL);
302 if (num_files > 1) 308 if (num_files > 1)
303 printf("%s%s%i%s%i%s%s", HIGHLIGHT, "(file ", current_file, " of ", num_files, ")", NORMAL); 309 printf("%s%s%i%s%i%s%s", HIGHLIGHT, "(file ",
310 current_file, " of ", num_files, ")", NORMAL);
304 } 311 }
305 else if (line_pos == num_flines - height + 2) { 312 else if (line_pos == num_flines - height + 2) {
306 printf("%s%s %s", HIGHLIGHT, "(END)", NORMAL); 313 printf("%s%s %s", HIGHLIGHT, "(END)", NORMAL);
@@ -602,7 +609,7 @@ static char *process_regex_on_line(char *line, regex_t *pattern, int action)
602 insert_highlights if action = 1, or has the escape sequences 609 insert_highlights if action = 1, or has the escape sequences
603 removed if action = 0, and then the line is returned. */ 610 removed if action = 0, and then the line is returned. */
604 int match_status; 611 int match_status;
605 char *line2 = (char *) xmalloc((sizeof(char) * (strlen(line) + 1)) + 64); 612 char *line2 = xmalloc((sizeof(char) * (strlen(line) + 1)) + 64);
606 char *growline = ""; 613 char *growline = "";
607 regmatch_t match_structs; 614 regmatch_t match_structs;
608 615
@@ -616,10 +623,16 @@ static char *process_regex_on_line(char *line, regex_t *pattern, int action)
616 match_found = 1; 623 match_found = 1;
617 624
618 if (action) { 625 if (action) {
619 growline = xasprintf("%s%.*s%s%.*s%s", growline, match_structs.rm_so, line2, HIGHLIGHT, match_structs.rm_eo - match_structs.rm_so, line2 + match_structs.rm_so, NORMAL); 626 growline = xasprintf("%s%.*s%s%.*s%s", growline,
627 match_structs.rm_so, line2, HIGHLIGHT,
628 match_structs.rm_eo - match_structs.rm_so,
629 line2 + match_structs.rm_so, NORMAL);
620 } 630 }
621 else { 631 else {
622 growline = xasprintf("%s%.*s%.*s", growline, match_structs.rm_so - 4, line2, match_structs.rm_eo - match_structs.rm_so, line2 + match_structs.rm_so); 632 growline = xasprintf("%s%.*s%.*s", growline,
633 match_structs.rm_so - 4, line2,
634 match_structs.rm_eo - match_structs.rm_so,
635 line2 + match_structs.rm_so);
623 } 636 }
624 637
625 line2 += match_structs.rm_eo; 638 line2 += match_structs.rm_eo;
diff --git a/miscutils/mountpoint.c b/miscutils/mountpoint.c
index dbc8fe0e9..b1bcab698 100644
--- a/miscutils/mountpoint.c
+++ b/miscutils/mountpoint.c
@@ -13,6 +13,8 @@
13 13
14int mountpoint_main(int argc, char **argv) 14int mountpoint_main(int argc, char **argv)
15{ 15{
16 struct stat st;
17 char *arg;
16 int opt = getopt32(argc, argv, "qdx"); 18 int opt = getopt32(argc, argv, "qdx");
17#define OPT_q (1) 19#define OPT_q (1)
18#define OPT_d (2) 20#define OPT_d (2)
@@ -20,47 +22,44 @@ int mountpoint_main(int argc, char **argv)
20 22
21 if (optind != argc - 1) 23 if (optind != argc - 1)
22 bb_show_usage(); 24 bb_show_usage();
23 {
24 char *arg = argv[optind];
25 struct stat st;
26 25
27 if ( (opt & OPT_x && stat(arg, &st) == 0) || (lstat(arg, &st) == 0) ) { 26 arg = argv[optind];
28 if (opt & OPT_x) {
29 if (S_ISBLK(st.st_mode))
30 {
31 bb_printf("%u:%u\n", major(st.st_rdev),
32 minor(st.st_rdev));
33 return EXIT_SUCCESS;
34 } else {
35 if (opt & OPT_q)
36 putchar('\n');
37 else
38 bb_error_msg("%s: not a block device", arg);
39 }
40 return EXIT_FAILURE;
41 } else
42 if (S_ISDIR(st.st_mode)) {
43 dev_t st_dev = st.st_dev;
44 ino_t st_ino = st.st_ino;
45 char *p = xasprintf("%s/..", arg);
46 27
47 if (stat(p, &st) == 0) { 28 if ( (opt & OPT_x && stat(arg, &st) == 0) || (lstat(arg, &st) == 0) ) {
48 short ret = (st_dev != st.st_dev) || 29 if (opt & OPT_x) {
49 (st_dev == st.st_dev && st_ino == st.st_ino); 30 if (S_ISBLK(st.st_mode)) {
50 if (opt & OPT_d) 31 printf("%u:%u\n", major(st.st_rdev),
51 bb_printf("%u:%u\n", major(st_dev), minor(st_dev)); 32 minor(st.st_rdev));
52 else if (!(opt & OPT_q)) 33 return EXIT_SUCCESS;
53 bb_printf("%s is %sa mountpoint\n", arg, ret?"":"not ");
54 return !ret;
55 }
56 } else { 34 } else {
57 if (!(opt & OPT_q)) 35 if (opt & OPT_q)
58 bb_error_msg("%s: not a directory", arg); 36 putchar('\n');
59 return EXIT_FAILURE; 37 else
38 bb_error_msg("%s: not a block device", arg);
60 } 39 }
40 return EXIT_FAILURE;
41 } else
42 if (S_ISDIR(st.st_mode)) {
43 dev_t st_dev = st.st_dev;
44 ino_t st_ino = st.st_ino;
45 char *p = xasprintf("%s/..", arg);
46
47 if (stat(p, &st) == 0) {
48 int ret = (st_dev != st.st_dev) ||
49 (st_dev == st.st_dev && st_ino == st.st_ino);
50 if (opt & OPT_d)
51 printf("%u:%u\n", major(st_dev), minor(st_dev));
52 else if (!(opt & OPT_q))
53 printf("%s is %sa mountpoint\n", arg, ret?"":"not ");
54 return !ret;
55 }
56 } else {
57 if (!(opt & OPT_q))
58 bb_error_msg("%s: not a directory", arg);
59 return EXIT_FAILURE;
61 } 60 }
62 if (!(opt & OPT_q))
63 bb_perror_msg("%s", arg);
64 return EXIT_FAILURE;
65 } 61 }
62 if (!(opt & OPT_q))
63 bb_perror_msg("%s", arg);
64 return EXIT_FAILURE;
66} 65}
diff --git a/miscutils/rx.c b/miscutils/rx.c
index 00951b711..f723c1676 100644
--- a/miscutils/rx.c
+++ b/miscutils/rx.c
@@ -286,5 +286,5 @@ int rx_main(int argc, char **argv)
286 if (n < 0) 286 if (n < 0)
287 bb_error_msg_and_die("\nreceive failed:\n %s", error_buf); 287 bb_error_msg_and_die("\nreceive failed:\n %s", error_buf);
288 288
289 bb_fflush_stdout_and_exit(EXIT_SUCCESS); 289 fflush_stdout_and_exit(EXIT_SUCCESS);
290} 290}
diff --git a/miscutils/strings.c b/miscutils/strings.c
index 1ff41ad9c..dae17315e 100644
--- a/miscutils/strings.c
+++ b/miscutils/strings.c
@@ -84,5 +84,5 @@ PIPE:
84 if (ENABLE_FEATURE_CLEAN_UP) 84 if (ENABLE_FEATURE_CLEAN_UP)
85 free(string); 85 free(string);
86 86
87 bb_fflush_stdout_and_exit(status); 87 fflush_stdout_and_exit(status);
88} 88}
diff --git a/networking/route.c b/networking/route.c
index 65b40fcd6..c99405d72 100644
--- a/networking/route.c
+++ b/networking/route.c
@@ -491,7 +491,7 @@ void displayroutes(int noresolve, int netstatfmt)
491 491
492 FILE *fp = xfopen("/proc/net/route", "r"); 492 FILE *fp = xfopen("/proc/net/route", "r");
493 493
494 bb_printf("Kernel IP routing table\n" 494 printf("Kernel IP routing table\n"
495 "Destination Gateway Genmask" 495 "Destination Gateway Genmask"
496 " Flags %s Iface\n", 496 " Flags %s Iface\n",
497 netstatfmt ? " MSS Window irtt" : "Metric Ref Use"); 497 netstatfmt ? " MSS Window irtt" : "Metric Ref Use");
@@ -534,11 +534,11 @@ void displayroutes(int noresolve, int netstatfmt)
534 (noresolve | 0x4000), m); /* Host instead of net. */ 534 (noresolve | 0x4000), m); /* Host instead of net. */
535 535
536 mask.s_addr = m; 536 mask.s_addr = m;
537 bb_printf("%-16s%-16s%-16s%-6s", sdest, sgw, inet_ntoa(mask), flags); 537 printf("%-16s%-16s%-16s%-6s", sdest, sgw, inet_ntoa(mask), flags);
538 if (netstatfmt) { 538 if (netstatfmt) {
539 bb_printf("%5d %-5d %6d %s\n", mtu, win, ir, devname); 539 printf("%5d %-5d %6d %s\n", mtu, win, ir, devname);
540 } else { 540 } else {
541 bb_printf("%-6d %-2d %7d %s\n", metric, ref, use, devname); 541 printf("%-6d %-2d %7d %s\n", metric, ref, use, devname);
542 } 542 }
543 } 543 }
544} 544}
@@ -561,7 +561,7 @@ static void INET6_displayroutes(int noresolve)
561 561
562 FILE *fp = xfopen("/proc/net/ipv6_route", "r"); 562 FILE *fp = xfopen("/proc/net/ipv6_route", "r");
563 563
564 bb_printf("Kernel IPv6 routing table\n%-44s%-40s" 564 printf("Kernel IPv6 routing table\n%-44s%-40s"
565 "Flags Metric Ref Use Iface\n", 565 "Flags Metric Ref Use Iface\n",
566 "Destination", "Next Hop"); 566 "Destination", "Next Hop");
567 567
@@ -622,7 +622,7 @@ static void INET6_displayroutes(int noresolve)
622 r += 40; 622 r += 40;
623 } else { /* 2nd pass */ 623 } else { /* 2nd pass */
624 /* Print the info. */ 624 /* Print the info. */
625 bb_printf("%-43s %-39s %-5s %-6d %-2d %7d %-8s\n", 625 printf("%-43s %-39s %-5s %-6d %-2d %7d %-8s\n",
626 addr6, naddr6, flags, metric, refcnt, use, iface); 626 addr6, naddr6, flags, metric, refcnt, use, iface);
627 break; 627 break;
628 } 628 }
@@ -650,15 +650,13 @@ int route_main(int argc, char **argv)
650 unsigned opt; 650 unsigned opt;
651 int what; 651 int what;
652 char *family; 652 char *family;
653 char **p;
653 654
654 /* First, remap '-net' and '-host' to avoid getopt problems. */ 655 /* First, remap '-net' and '-host' to avoid getopt problems. */
655 { 656 p = argv;
656 char **p = argv; 657 while (*++p) {
657 658 if ((strcmp(*p, "-net") == 0) || (strcmp(*p, "-host") == 0)) {
658 while (*++p) { 659 p[0][0] = '#';
659 if ((strcmp(*p, "-net") == 0) || (strcmp(*p, "-host") == 0)) {
660 p[0][0] = '#';
661 }
662 } 660 }
663 } 661 }
664 662
@@ -685,8 +683,7 @@ int route_main(int argc, char **argv)
685#endif 683#endif
686 displayroutes(noresolve, opt & ROUTE_OPT_e); 684 displayroutes(noresolve, opt & ROUTE_OPT_e);
687 685
688 xferror_stdout(); 686 fflush_stdout_and_exit(EXIT_SUCCESS);
689 bb_fflush_stdout_and_exit(EXIT_SUCCESS);
690 } 687 }
691 688
692 /* Check verb. At the moment, must be add, del, or delete. */ 689 /* Check verb. At the moment, must be add, del, or delete. */
diff --git a/util-linux/ipcrm.c b/util-linux/ipcrm.c
index 735a8955b..0e44783b3 100644
--- a/util-linux/ipcrm.c
+++ b/util-linux/ipcrm.c
@@ -108,8 +108,8 @@ int ipcrm_main(int argc, char **argv)
108 what = SEM; 108 what = SEM;
109 109
110 if (remove_ids(what, argc-2, &argv[2])) 110 if (remove_ids(what, argc-2, &argv[2]))
111 bb_fflush_stdout_and_exit(1); 111 fflush_stdout_and_exit(1);
112 bb_printf("resource(s) deleted\n"); 112 printf("resource(s) deleted\n");
113 return 0; 113 return 0;
114 } 114 }
115 } 115 }
diff --git a/util-linux/ipcs.c b/util-linux/ipcs.c
index ba81ea97c..b81d07d6d 100644
--- a/util-linux/ipcs.c
+++ b/util-linux/ipcs.c
@@ -103,25 +103,25 @@ static void print_perms(int id, struct ipc_perm *ipcp)
103 struct passwd *pw; 103 struct passwd *pw;
104 struct group *gr; 104 struct group *gr;
105 105
106 bb_printf("%-10d %-10o", id, ipcp->mode & 0777); 106 printf("%-10d %-10o", id, ipcp->mode & 0777);
107 107
108 if ((pw = getpwuid(ipcp->cuid))) 108 if ((pw = getpwuid(ipcp->cuid)))
109 bb_printf(" %-10s", pw->pw_name); 109 printf(" %-10s", pw->pw_name);
110 else 110 else
111 bb_printf(" %-10d", ipcp->cuid); 111 printf(" %-10d", ipcp->cuid);
112 if ((gr = getgrgid(ipcp->cgid))) 112 if ((gr = getgrgid(ipcp->cgid)))
113 bb_printf(" %-10s", gr->gr_name); 113 printf(" %-10s", gr->gr_name);
114 else 114 else
115 bb_printf(" %-10d", ipcp->cgid); 115 printf(" %-10d", ipcp->cgid);
116 116
117 if ((pw = getpwuid(ipcp->uid))) 117 if ((pw = getpwuid(ipcp->uid)))
118 bb_printf(" %-10s", pw->pw_name); 118 printf(" %-10s", pw->pw_name);
119 else 119 else
120 bb_printf(" %-10d", ipcp->uid); 120 printf(" %-10d", ipcp->uid);
121 if ((gr = getgrgid(ipcp->gid))) 121 if ((gr = getgrgid(ipcp->gid)))
122 bb_printf(" %-10s\n", gr->gr_name); 122 printf(" %-10s\n", gr->gr_name);
123 else 123 else
124 bb_printf(" %-10d\n", ipcp->gid); 124 printf(" %-10d\n", ipcp->gid);
125} 125}
126 126
127 127
@@ -136,18 +136,18 @@ static void do_shm(void)
136 136
137 maxid = shmctl(0, SHM_INFO, (struct shmid_ds *) (void *) &shm_info); 137 maxid = shmctl(0, SHM_INFO, (struct shmid_ds *) (void *) &shm_info);
138 if (maxid < 0) { 138 if (maxid < 0) {
139 bb_printf("kernel not configured for %s\n", "shared memory"); 139 printf("kernel not configured for %s\n", "shared memory");
140 return; 140 return;
141 } 141 }
142 142
143 switch (format) { 143 switch (format) {
144 case LIMITS: 144 case LIMITS:
145 bb_printf("------ Shared Memory %s --------\n", "Limits"); 145 printf("------ Shared Memory %s --------\n", "Limits");
146 if ((shmctl(0, IPC_INFO, (struct shmid_ds *) (void *) &shminfo)) < 0) 146 if ((shmctl(0, IPC_INFO, (struct shmid_ds *) (void *) &shminfo)) < 0)
147 return; 147 return;
148 /* glibc 2.1.3 and all earlier libc's have ints as fields 148 /* glibc 2.1.3 and all earlier libc's have ints as fields
149 of struct shminfo; glibc 2.1.91 has unsigned long; ach */ 149 of struct shminfo; glibc 2.1.91 has unsigned long; ach */
150 bb_printf("max number of segments = %lu\n" 150 printf("max number of segments = %lu\n"
151 "max seg size (kbytes) = %lu\n" 151 "max seg size (kbytes) = %lu\n"
152 "max total shared memory (pages) = %lu\n" 152 "max total shared memory (pages) = %lu\n"
153 "min seg size (bytes) = %lu\n", 153 "min seg size (bytes) = %lu\n",
@@ -158,8 +158,8 @@ static void do_shm(void)
158 return; 158 return;
159 159
160 case STATUS: 160 case STATUS:
161 bb_printf("------ Shared Memory %s --------\n", "Status"); 161 printf("------ Shared Memory %s --------\n", "Status");
162 bb_printf( "segments allocated %d\n" 162 printf( "segments allocated %d\n"
163 "pages allocated %ld\n" 163 "pages allocated %ld\n"
164 "pages resident %ld\n" 164 "pages resident %ld\n"
165 "pages swapped %ld\n" 165 "pages swapped %ld\n"
@@ -172,26 +172,26 @@ static void do_shm(void)
172 return; 172 return;
173 173
174 case CREATOR: 174 case CREATOR:
175 bb_printf("------ Shared Memory %s --------\n", "Segment Creators/Owners"); 175 printf("------ Shared Memory %s --------\n", "Segment Creators/Owners");
176 bb_printf( "%-10s %-10s %-10s %-10s %-10s %-10s\n", 176 printf( "%-10s %-10s %-10s %-10s %-10s %-10s\n",
177 "shmid", "perms", "cuid", "cgid", "uid", "gid"); 177 "shmid", "perms", "cuid", "cgid", "uid", "gid");
178 break; 178 break;
179 179
180 case TIME: 180 case TIME:
181 bb_printf("------ Shared Memory %s --------\n", "Attach/Detach/Change Times"); 181 printf("------ Shared Memory %s --------\n", "Attach/Detach/Change Times");
182 bb_printf( "%-10s %-10s %-20s %-20s %-20s\n", 182 printf( "%-10s %-10s %-20s %-20s %-20s\n",
183 "shmid", "owner", "attached", "detached", "changed"); 183 "shmid", "owner", "attached", "detached", "changed");
184 break; 184 break;
185 185
186 case PID: 186 case PID:
187 bb_printf("------ Shared Memory %s --------\n", "Creator/Last-op"); 187 printf("------ Shared Memory %s --------\n", "Creator/Last-op");
188 bb_printf( "%-10s %-10s %-10s %-10s\n", 188 printf( "%-10s %-10s %-10s %-10s\n",
189 "shmid", "owner", "cpid", "lpid"); 189 "shmid", "owner", "cpid", "lpid");
190 break; 190 break;
191 191
192 default: 192 default:
193 bb_printf("------ Shared Memory %s --------\n", "Segments"); 193 printf("------ Shared Memory %s --------\n", "Segments");
194 bb_printf( "%-10s %-10s %-10s %-10s %-10s %-10s %-12s\n", 194 printf( "%-10s %-10s %-10s %-10s %-10s %-10s %-12s\n",
195 "key", "shmid", "owner", "perms", "bytes", "nattch", 195 "key", "shmid", "owner", "perms", "bytes", "nattch",
196 "status"); 196 "status");
197 break; 197 break;
@@ -209,32 +209,32 @@ static void do_shm(void)
209 switch (format) { 209 switch (format) {
210 case TIME: 210 case TIME:
211 if (pw) 211 if (pw)
212 bb_printf("%-10d %-10.10s", shmid, pw->pw_name); 212 printf("%-10d %-10.10s", shmid, pw->pw_name);
213 else 213 else
214 bb_printf("%-10d %-10d", shmid, ipcp->uid); 214 printf("%-10d %-10d", shmid, ipcp->uid);
215 /* ctime uses static buffer: use separate calls */ 215 /* ctime uses static buffer: use separate calls */
216 bb_printf(" %-20.16s", shmseg.shm_atime 216 printf(" %-20.16s", shmseg.shm_atime
217 ? ctime(&shmseg.shm_atime) + 4 : "Not set"); 217 ? ctime(&shmseg.shm_atime) + 4 : "Not set");
218 bb_printf(" %-20.16s", shmseg.shm_dtime 218 printf(" %-20.16s", shmseg.shm_dtime
219 ? ctime(&shmseg.shm_dtime) + 4 : "Not set"); 219 ? ctime(&shmseg.shm_dtime) + 4 : "Not set");
220 bb_printf(" %-20.16s\n", shmseg.shm_ctime 220 printf(" %-20.16s\n", shmseg.shm_ctime
221 ? ctime(&shmseg.shm_ctime) + 4 : "Not set"); 221 ? ctime(&shmseg.shm_ctime) + 4 : "Not set");
222 break; 222 break;
223 case PID: 223 case PID:
224 if (pw) 224 if (pw)
225 bb_printf("%-10d %-10.10s", shmid, pw->pw_name); 225 printf("%-10d %-10.10s", shmid, pw->pw_name);
226 else 226 else
227 bb_printf("%-10d %-10d", shmid, ipcp->uid); 227 printf("%-10d %-10d", shmid, ipcp->uid);
228 bb_printf(" %-10d %-10d\n", shmseg.shm_cpid, shmseg.shm_lpid); 228 printf(" %-10d %-10d\n", shmseg.shm_cpid, shmseg.shm_lpid);
229 break; 229 break;
230 230
231 default: 231 default:
232 bb_printf("0x%08x ", ipcp->KEY); 232 printf("0x%08x ", ipcp->KEY);
233 if (pw) 233 if (pw)
234 bb_printf("%-10d %-10.10s", shmid, pw->pw_name); 234 printf("%-10d %-10.10s", shmid, pw->pw_name);
235 else 235 else
236 bb_printf("%-10d %-10d", shmid, ipcp->uid); 236 printf("%-10d %-10d", shmid, ipcp->uid);
237 bb_printf(" %-10o %-10lu %-10ld %-6s %-6s\n", ipcp->mode & 0777, 237 printf(" %-10o %-10lu %-10ld %-6s %-6s\n", ipcp->mode & 0777,
238 /* 238 /*
239 * earlier: int, Austin has size_t 239 * earlier: int, Austin has size_t
240 */ 240 */
@@ -264,17 +264,17 @@ static void do_sem(void)
264 arg.array = (ushort *) (void *) &seminfo; 264 arg.array = (ushort *) (void *) &seminfo;
265 maxid = semctl(0, 0, SEM_INFO, arg); 265 maxid = semctl(0, 0, SEM_INFO, arg);
266 if (maxid < 0) { 266 if (maxid < 0) {
267 bb_printf("kernel not configured for %s\n", "semaphores"); 267 printf("kernel not configured for %s\n", "semaphores");
268 return; 268 return;
269 } 269 }
270 270
271 switch (format) { 271 switch (format) {
272 case LIMITS: 272 case LIMITS:
273 bb_printf("------ Semaphore %s --------\n", "Limits"); 273 printf("------ Semaphore %s --------\n", "Limits");
274 arg.array = (ushort *) (void *) &seminfo; /* damn union */ 274 arg.array = (ushort *) (void *) &seminfo; /* damn union */
275 if ((semctl(0, 0, IPC_INFO, arg)) < 0) 275 if ((semctl(0, 0, IPC_INFO, arg)) < 0)
276 return; 276 return;
277 bb_printf("max number of arrays = %d\n" 277 printf("max number of arrays = %d\n"
278 "max semaphores per array = %d\n" 278 "max semaphores per array = %d\n"
279 "max semaphores system wide = %d\n" 279 "max semaphores system wide = %d\n"
280 "max ops per semop call = %d\n" 280 "max ops per semop call = %d\n"
@@ -285,21 +285,21 @@ static void do_sem(void)
285 return; 285 return;
286 286
287 case STATUS: 287 case STATUS:
288 bb_printf("------ Semaphore %s --------\n", "Status"); 288 printf("------ Semaphore %s --------\n", "Status");
289 bb_printf( "used arrays = %d\n" 289 printf( "used arrays = %d\n"
290 "allocated semaphores = %d\n", 290 "allocated semaphores = %d\n",
291 seminfo.semusz, seminfo.semaem); 291 seminfo.semusz, seminfo.semaem);
292 return; 292 return;
293 293
294 case CREATOR: 294 case CREATOR:
295 bb_printf("------ Semaphore %s --------\n", "Arrays Creators/Owners"); 295 printf("------ Semaphore %s --------\n", "Arrays Creators/Owners");
296 bb_printf( "%-10s %-10s %-10s %-10s %-10s %-10s\n", 296 printf( "%-10s %-10s %-10s %-10s %-10s %-10s\n",
297 "semid", "perms", "cuid", "cgid", "uid", "gid"); 297 "semid", "perms", "cuid", "cgid", "uid", "gid");
298 break; 298 break;
299 299
300 case TIME: 300 case TIME:
301 bb_printf("------ Shared Memory %s --------\n", "Operation/Change Times"); 301 printf("------ Shared Memory %s --------\n", "Operation/Change Times");
302 bb_printf( "%-8s %-10s %-26.24s %-26.24s\n", 302 printf( "%-8s %-10s %-26.24s %-26.24s\n",
303 "shmid", "owner", "last-op", "last-changed"); 303 "shmid", "owner", "last-op", "last-changed");
304 break; 304 break;
305 305
@@ -307,8 +307,8 @@ static void do_sem(void)
307 break; 307 break;
308 308
309 default: 309 default:
310 bb_printf("------ Semaphore %s --------\n", "Arrays"); 310 printf("------ Semaphore %s --------\n", "Arrays");
311 bb_printf( "%-10s %-10s %-10s %-10s %-10s\n", 311 printf( "%-10s %-10s %-10s %-10s %-10s\n",
312 "key", "semid", "owner", "perms", "nsems"); 312 "key", "semid", "owner", "perms", "nsems");
313 break; 313 break;
314 } 314 }
@@ -326,25 +326,25 @@ static void do_sem(void)
326 switch (format) { 326 switch (format) {
327 case TIME: 327 case TIME:
328 if (pw) 328 if (pw)
329 bb_printf("%-8d %-10.10s", semid, pw->pw_name); 329 printf("%-8d %-10.10s", semid, pw->pw_name);
330 else 330 else
331 bb_printf("%-8d %-10d", semid, ipcp->uid); 331 printf("%-8d %-10d", semid, ipcp->uid);
332 /* ctime uses static buffer: use separate calls */ 332 /* ctime uses static buffer: use separate calls */
333 bb_printf(" %-26.24s", semary.sem_otime 333 printf(" %-26.24s", semary.sem_otime
334 ? ctime(&semary.sem_otime) : "Not set"); 334 ? ctime(&semary.sem_otime) : "Not set");
335 bb_printf(" %-26.24s\n", semary.sem_ctime 335 printf(" %-26.24s\n", semary.sem_ctime
336 ? ctime(&semary.sem_ctime) : "Not set"); 336 ? ctime(&semary.sem_ctime) : "Not set");
337 break; 337 break;
338 case PID: 338 case PID:
339 break; 339 break;
340 340
341 default: 341 default:
342 bb_printf("0x%08x ", ipcp->KEY); 342 printf("0x%08x ", ipcp->KEY);
343 if (pw) 343 if (pw)
344 bb_printf("%-10d %-10.9s", semid, pw->pw_name); 344 printf("%-10d %-10.9s", semid, pw->pw_name);
345 else 345 else
346 bb_printf("%-10d %-9d", semid, ipcp->uid); 346 printf("%-10d %-9d", semid, ipcp->uid);
347 bb_printf(" %-10o %-10ld\n", ipcp->mode & 0777, 347 printf(" %-10o %-10ld\n", ipcp->mode & 0777,
348 /* 348 /*
349 * glibc-2.1.3 and earlier has unsigned short; 349 * glibc-2.1.3 and earlier has unsigned short;
350 * glibc-2.1.91 has variation between 350 * glibc-2.1.91 has variation between
@@ -368,7 +368,7 @@ static void do_msg(void)
368 368
369 maxid = msgctl(0, MSG_INFO, (struct msqid_ds *) (void *) &msginfo); 369 maxid = msgctl(0, MSG_INFO, (struct msqid_ds *) (void *) &msginfo);
370 if (maxid < 0) { 370 if (maxid < 0) {
371 bb_printf("kernel not configured for %s\n", "message queues"); 371 printf("kernel not configured for %s\n", "message queues");
372 return; 372 return;
373 } 373 }
374 374
@@ -376,42 +376,42 @@ static void do_msg(void)
376 case LIMITS: 376 case LIMITS:
377 if ((msgctl(0, IPC_INFO, (struct msqid_ds *) (void *) &msginfo)) < 0) 377 if ((msgctl(0, IPC_INFO, (struct msqid_ds *) (void *) &msginfo)) < 0)
378 return; 378 return;
379 bb_printf("------ Message%s --------\n", "s: Limits"); 379 printf("------ Message%s --------\n", "s: Limits");
380 bb_printf( "max queues system wide = %d\n" 380 printf( "max queues system wide = %d\n"
381 "max size of message (bytes) = %d\n" 381 "max size of message (bytes) = %d\n"
382 "default max size of queue (bytes) = %d\n", 382 "default max size of queue (bytes) = %d\n",
383 msginfo.msgmni, msginfo.msgmax, msginfo.msgmnb); 383 msginfo.msgmni, msginfo.msgmax, msginfo.msgmnb);
384 return; 384 return;
385 385
386 case STATUS: 386 case STATUS:
387 bb_printf("------ Message%s --------\n", "s: Status"); 387 printf("------ Message%s --------\n", "s: Status");
388 bb_printf( "allocated queues = %d\n" 388 printf( "allocated queues = %d\n"
389 "used headers = %d\n" 389 "used headers = %d\n"
390 "used space = %d bytes\n", 390 "used space = %d bytes\n",
391 msginfo.msgpool, msginfo.msgmap, msginfo.msgtql); 391 msginfo.msgpool, msginfo.msgmap, msginfo.msgtql);
392 return; 392 return;
393 393
394 case CREATOR: 394 case CREATOR:
395 bb_printf("------ Message%s --------\n", " Queues: Creators/Owners"); 395 printf("------ Message%s --------\n", " Queues: Creators/Owners");
396 bb_printf( "%-10s %-10s %-10s %-10s %-10s %-10s\n", 396 printf( "%-10s %-10s %-10s %-10s %-10s %-10s\n",
397 "msqid", "perms", "cuid", "cgid", "uid", "gid"); 397 "msqid", "perms", "cuid", "cgid", "uid", "gid");
398 break; 398 break;
399 399
400 case TIME: 400 case TIME:
401 bb_printf("------ Message%s --------\n", " Queues Send/Recv/Change Times"); 401 printf("------ Message%s --------\n", " Queues Send/Recv/Change Times");
402 bb_printf( "%-8s %-10s %-20s %-20s %-20s\n", 402 printf( "%-8s %-10s %-20s %-20s %-20s\n",
403 "msqid", "owner", "send", "recv", "change"); 403 "msqid", "owner", "send", "recv", "change");
404 break; 404 break;
405 405
406 case PID: 406 case PID:
407 bb_printf("------ Message%s --------\n", " Queues PIDs"); 407 printf("------ Message%s --------\n", " Queues PIDs");
408 bb_printf( "%-10s %-10s %-10s %-10s\n", 408 printf( "%-10s %-10s %-10s %-10s\n",
409 "msqid", "owner", "lspid", "lrpid"); 409 "msqid", "owner", "lspid", "lrpid");
410 break; 410 break;
411 411
412 default: 412 default:
413 bb_printf("------ Message%s --------\n", " Queues"); 413 printf("------ Message%s --------\n", " Queues");
414 bb_printf( "%-10s %-10s %-10s %-10s %-12s %-12s\n", 414 printf( "%-10s %-10s %-10s %-10s %-12s %-12s\n",
415 "key", "msqid", "owner", "perms", "used-bytes", "messages"); 415 "key", "msqid", "owner", "perms", "used-bytes", "messages");
416 break; 416 break;
417 } 417 }
@@ -428,31 +428,31 @@ static void do_msg(void)
428 switch (format) { 428 switch (format) {
429 case TIME: 429 case TIME:
430 if (pw) 430 if (pw)
431 bb_printf("%-8d %-10.10s", msqid, pw->pw_name); 431 printf("%-8d %-10.10s", msqid, pw->pw_name);
432 else 432 else
433 bb_printf("%-8d %-10d", msqid, ipcp->uid); 433 printf("%-8d %-10d", msqid, ipcp->uid);
434 bb_printf(" %-20.16s", msgque.msg_stime 434 printf(" %-20.16s", msgque.msg_stime
435 ? ctime(&msgque.msg_stime) + 4 : "Not set"); 435 ? ctime(&msgque.msg_stime) + 4 : "Not set");
436 bb_printf(" %-20.16s", msgque.msg_rtime 436 printf(" %-20.16s", msgque.msg_rtime
437 ? ctime(&msgque.msg_rtime) + 4 : "Not set"); 437 ? ctime(&msgque.msg_rtime) + 4 : "Not set");
438 bb_printf(" %-20.16s\n", msgque.msg_ctime 438 printf(" %-20.16s\n", msgque.msg_ctime
439 ? ctime(&msgque.msg_ctime) + 4 : "Not set"); 439 ? ctime(&msgque.msg_ctime) + 4 : "Not set");
440 break; 440 break;
441 case PID: 441 case PID:
442 if (pw) 442 if (pw)
443 bb_printf("%-8d %-10.10s", msqid, pw->pw_name); 443 printf("%-8d %-10.10s", msqid, pw->pw_name);
444 else 444 else
445 bb_printf("%-8d %-10d", msqid, ipcp->uid); 445 printf("%-8d %-10d", msqid, ipcp->uid);
446 bb_printf(" %5d %5d\n", msgque.msg_lspid, msgque.msg_lrpid); 446 printf(" %5d %5d\n", msgque.msg_lspid, msgque.msg_lrpid);
447 break; 447 break;
448 448
449 default: 449 default:
450 bb_printf("0x%08x ", ipcp->KEY); 450 printf("0x%08x ", ipcp->KEY);
451 if (pw) 451 if (pw)
452 bb_printf("%-10d %-10.10s", msqid, pw->pw_name); 452 printf("%-10d %-10.10s", msqid, pw->pw_name);
453 else 453 else
454 bb_printf("%-10d %-10d", msqid, ipcp->uid); 454 printf("%-10d %-10d", msqid, ipcp->uid);
455 bb_printf(" %-10o %-12ld %-12ld\n", ipcp->mode & 0777, 455 printf(" %-10o %-12ld %-12ld\n", ipcp->mode & 0777,
456 /* 456 /*
457 * glibc-2.1.3 and earlier has unsigned short; 457 * glibc-2.1.3 and earlier has unsigned short;
458 * glibc-2.1.91 has variation between 458 * glibc-2.1.91 has variation between
@@ -476,7 +476,7 @@ static void print_shm(int shmid)
476 return; 476 return;
477 } 477 }
478 478
479 bb_printf("\nShared memory Segment shmid=%d\n" 479 printf("\nShared memory Segment shmid=%d\n"
480 "uid=%d\tgid=%d\tcuid=%d\tcgid=%d\n" 480 "uid=%d\tgid=%d\tcuid=%d\tcgid=%d\n"
481 "mode=%#o\taccess_perms=%#o\n" 481 "mode=%#o\taccess_perms=%#o\n"
482 "bytes=%ld\tlpid=%d\tcpid=%d\tnattch=%ld\n", 482 "bytes=%ld\tlpid=%d\tcpid=%d\tnattch=%ld\n",
@@ -485,11 +485,11 @@ static void print_shm(int shmid)
485 ipcp->mode, ipcp->mode & 0777, 485 ipcp->mode, ipcp->mode & 0777,
486 (long) shmds.shm_segsz, shmds.shm_lpid, shmds.shm_cpid, 486 (long) shmds.shm_segsz, shmds.shm_lpid, shmds.shm_cpid,
487 (long) shmds.shm_nattch); 487 (long) shmds.shm_nattch);
488 bb_printf("att_time=%-26.24s\n", 488 printf("att_time=%-26.24s\n",
489 shmds.shm_atime ? ctime(&shmds.shm_atime) : "Not set"); 489 shmds.shm_atime ? ctime(&shmds.shm_atime) : "Not set");
490 bb_printf("det_time=%-26.24s\n", 490 printf("det_time=%-26.24s\n",
491 shmds.shm_dtime ? ctime(&shmds.shm_dtime) : "Not set"); 491 shmds.shm_dtime ? ctime(&shmds.shm_dtime) : "Not set");
492 bb_printf("change_time=%-26.24s\n\n", ctime(&shmds.shm_ctime)); 492 printf("change_time=%-26.24s\n\n", ctime(&shmds.shm_ctime));
493} 493}
494 494
495 495
@@ -503,7 +503,7 @@ static void print_msg(int msqid)
503 return; 503 return;
504 } 504 }
505 505
506 bb_printf("\nMessage Queue msqid=%d\n" 506 printf("\nMessage Queue msqid=%d\n"
507 "uid=%d\tgid=%d\tcuid=%d\tcgid=%d\tmode=%#o\n" 507 "uid=%d\tgid=%d\tcuid=%d\tcgid=%d\tmode=%#o\n"
508 "cbytes=%ld\tqbytes=%ld\tqnum=%ld\tlspid=%d\tlrpid=%d\n", 508 "cbytes=%ld\tqbytes=%ld\tqnum=%ld\tlspid=%d\tlrpid=%d\n",
509 msqid, ipcp->uid, ipcp->gid, ipcp->cuid, ipcp->cgid, ipcp->mode, 509 msqid, ipcp->uid, ipcp->gid, ipcp->cuid, ipcp->cgid, ipcp->mode,
@@ -516,11 +516,11 @@ static void print_msg(int msqid)
516 (long) buf.msg_cbytes, (long) buf.msg_qbytes, 516 (long) buf.msg_cbytes, (long) buf.msg_qbytes,
517 (long) buf.msg_qnum, buf.msg_lspid, buf.msg_lrpid); 517 (long) buf.msg_qnum, buf.msg_lspid, buf.msg_lrpid);
518 518
519 bb_printf("send_time=%-26.24s\n", 519 printf("send_time=%-26.24s\n",
520 buf.msg_stime ? ctime(&buf.msg_stime) : "Not set"); 520 buf.msg_stime ? ctime(&buf.msg_stime) : "Not set");
521 bb_printf("rcv_time=%-26.24s\n", 521 printf("rcv_time=%-26.24s\n",
522 buf.msg_rtime ? ctime(&buf.msg_rtime) : "Not set"); 522 buf.msg_rtime ? ctime(&buf.msg_rtime) : "Not set");
523 bb_printf("change_time=%-26.24s\n\n", 523 printf("change_time=%-26.24s\n\n",
524 buf.msg_ctime ? ctime(&buf.msg_ctime) : "Not set"); 524 buf.msg_ctime ? ctime(&buf.msg_ctime) : "Not set");
525} 525}
526 526
@@ -537,7 +537,7 @@ static void print_sem(int semid)
537 return; 537 return;
538 } 538 }
539 539
540 bb_printf("\nSemaphore Array semid=%d\n" 540 printf("\nSemaphore Array semid=%d\n"
541 "uid=%d\t gid=%d\t cuid=%d\t cgid=%d\n" 541 "uid=%d\t gid=%d\t cuid=%d\t cgid=%d\n"
542 "mode=%#o, access_perms=%#o\n" 542 "mode=%#o, access_perms=%#o\n"
543 "nsems = %ld\n" 543 "nsems = %ld\n"
@@ -547,7 +547,7 @@ static void print_sem(int semid)
547 ipcp->mode, ipcp->mode & 0777, 547 ipcp->mode, ipcp->mode & 0777,
548 (long) semds.sem_nsems, 548 (long) semds.sem_nsems,
549 semds.sem_otime ? ctime(&semds.sem_otime) : "Not set"); 549 semds.sem_otime ? ctime(&semds.sem_otime) : "Not set");
550 bb_printf("ctime = %-26.24s\n" 550 printf("ctime = %-26.24s\n"
551 "%-10s %-10s %-10s %-10s %-10s\n", 551 "%-10s %-10s %-10s %-10s %-10s\n",
552 ctime(&semds.sem_ctime), 552 ctime(&semds.sem_ctime),
553 "semnum", "value", "ncount", "zcount", "pid"); 553 "semnum", "value", "ncount", "zcount", "pid");
@@ -563,9 +563,9 @@ static void print_sem(int semid)
563 if (val < 0 || ncnt < 0 || zcnt < 0 || pid < 0) { 563 if (val < 0 || ncnt < 0 || zcnt < 0 || pid < 0) {
564 bb_perror_msg_and_die("semctl"); 564 bb_perror_msg_and_die("semctl");
565 } 565 }
566 bb_printf("%-10d %-10d %-10d %-10d %-10d\n", i, val, ncnt, zcnt, pid); 566 printf("%-10d %-10d %-10d %-10d %-10d\n", i, val, ncnt, zcnt, pid);
567 } 567 }
568 bb_printf("\n"); 568 puts("");
569} 569}
570 570
571int ipcs_main(int argc, char **argv) 571int ipcs_main(int argc, char **argv)
@@ -597,34 +597,34 @@ int ipcs_main(int argc, char **argv)
597 if (flags & flag_print) { 597 if (flags & flag_print) {
598 if (flags & flag_shm) { 598 if (flags & flag_shm) {
599 print_shm(id); 599 print_shm(id);
600 bb_fflush_stdout_and_exit(0); 600 fflush_stdout_and_exit(0);
601 } 601 }
602 if (flags & flag_sem) { 602 if (flags & flag_sem) {
603 print_sem(id); 603 print_sem(id);
604 bb_fflush_stdout_and_exit(0); 604 fflush_stdout_and_exit(0);
605 } 605 }
606 if (flags & flag_msg) { 606 if (flags & flag_msg) {
607 print_msg(id); 607 print_msg(id);
608 bb_fflush_stdout_and_exit(0); 608 fflush_stdout_and_exit(0);
609 } 609 }
610 bb_show_usage(); 610 bb_show_usage();
611 } 611 }
612 612
613 if (!(flags & (flag_shm | flag_msg | flag_sem))) 613 if (!(flags & (flag_shm | flag_msg | flag_sem)))
614 flags |= flag_msg | flag_shm | flag_sem; 614 flags |= flag_msg | flag_shm | flag_sem;
615 bb_printf("\n"); 615 puts("");
616 616
617 if (flags & flag_shm) { 617 if (flags & flag_shm) {
618 do_shm(); 618 do_shm();
619 bb_printf("\n"); 619 puts("");
620 } 620 }
621 if (flags & flag_sem) { 621 if (flags & flag_sem) {
622 do_sem(); 622 do_sem();
623 bb_printf("\n"); 623 puts("");
624 } 624 }
625 if (flags & flag_msg) { 625 if (flags & flag_msg) {
626 do_msg(); 626 do_msg();
627 bb_printf("\n"); 627 puts("");
628 } 628 }
629 return EXIT_SUCCESS; 629 fflush_stdout_and_exit(0);
630} 630}