diff options
author | Rob Landley <rob@landley.net> | 2006-08-03 15:41:12 +0000 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2006-08-03 15:41:12 +0000 |
commit | d921b2ecc0d294ad4bf8c7458fc52a60c28727d2 (patch) | |
tree | e4a2769349867c441cf2983d83097bb66701a733 /miscutils | |
parent | 6dce0b6fa79f2d4bb7e9d90e1fbc0f6beb25f855 (diff) | |
download | busybox-w32-d921b2ecc0d294ad4bf8c7458fc52a60c28727d2.tar.gz busybox-w32-d921b2ecc0d294ad4bf8c7458fc52a60c28727d2.tar.bz2 busybox-w32-d921b2ecc0d294ad4bf8c7458fc52a60c28727d2.zip |
Remove bb_ prefixes from xfuncs.c (and a few other places), consolidate
things like xasprintf() into xfuncs.c, remove xprint_file_by_name() (it only
had one user), clean up lots of #includes... General cleanup pass. What I've
been doing for the last couple days.
And it conflicts! I've removed httpd.c from this checkin due to somebody else
touching that file. It builds for me. I have to catch a bus. (Now you know
why I'm looking forward to Mercurial.)
Diffstat (limited to 'miscutils')
-rw-r--r-- | miscutils/crond.c | 21 | ||||
-rw-r--r-- | miscutils/crontab.c | 36 | ||||
-rw-r--r-- | miscutils/devfsd.c | 8 | ||||
-rw-r--r-- | miscutils/hdparm.c | 16 | ||||
-rw-r--r-- | miscutils/last.c | 10 | ||||
-rw-r--r-- | miscutils/less.c | 54 | ||||
-rw-r--r-- | miscutils/makedevs.c | 13 | ||||
-rw-r--r-- | miscutils/mountpoint.c | 6 | ||||
-rw-r--r-- | miscutils/mt.c | 6 | ||||
-rw-r--r-- | miscutils/rx.c | 16 | ||||
-rw-r--r-- | miscutils/watchdog.c | 9 |
11 files changed, 49 insertions, 146 deletions
diff --git a/miscutils/crond.c b/miscutils/crond.c index 3f60468de..3e12fedc8 100644 --- a/miscutils/crond.c +++ b/miscutils/crond.c | |||
@@ -13,22 +13,7 @@ | |||
13 | #define VERSION "2.3.2" | 13 | #define VERSION "2.3.2" |
14 | 14 | ||
15 | #include "busybox.h" | 15 | #include "busybox.h" |
16 | #include <stdio.h> | 16 | #include <sys/syslog.h> |
17 | #include <stdlib.h> | ||
18 | #include <stdarg.h> | ||
19 | #include <string.h> | ||
20 | #include <errno.h> | ||
21 | #include <time.h> | ||
22 | #include <dirent.h> | ||
23 | #include <fcntl.h> | ||
24 | #include <unistd.h> | ||
25 | #include <syslog.h> | ||
26 | #include <signal.h> | ||
27 | #include <getopt.h> | ||
28 | #include <sys/ioctl.h> | ||
29 | #include <sys/wait.h> | ||
30 | #include <sys/stat.h> | ||
31 | #include <sys/resource.h> | ||
32 | 17 | ||
33 | #define arysize(ary) (sizeof(ary)/sizeof((ary)[0])) | 18 | #define arysize(ary) (sizeof(ary)/sizeof((ary)[0])) |
34 | 19 | ||
@@ -193,7 +178,7 @@ int crond_main(int ac, char **av) | |||
193 | * change directory | 178 | * change directory |
194 | */ | 179 | */ |
195 | 180 | ||
196 | bb_xchdir(CDir); | 181 | xchdir(CDir); |
197 | signal(SIGHUP, SIG_IGN); /* hmm.. but, if kill -HUP original | 182 | signal(SIGHUP, SIG_IGN); /* hmm.. but, if kill -HUP original |
198 | * version - his died. ;( | 183 | * version - his died. ;( |
199 | */ | 184 | */ |
@@ -208,7 +193,7 @@ int crond_main(int ac, char **av) | |||
208 | /* reexec for vfork() do continue parent */ | 193 | /* reexec for vfork() do continue parent */ |
209 | vfork_daemon_rexec(1, 0, ac, av, "-f"); | 194 | vfork_daemon_rexec(1, 0, ac, av, "-f"); |
210 | #else | 195 | #else |
211 | bb_xdaemon(1, 0); | 196 | xdaemon(1, 0); |
212 | #endif | 197 | #endif |
213 | } | 198 | } |
214 | 199 | ||
diff --git a/miscutils/crontab.c b/miscutils/crontab.c index 0ed59b0dc..a8e650c60 100644 --- a/miscutils/crontab.c +++ b/miscutils/crontab.c | |||
@@ -11,22 +11,6 @@ | |||
11 | */ | 11 | */ |
12 | 12 | ||
13 | #include "busybox.h" | 13 | #include "busybox.h" |
14 | #include <stdio.h> | ||
15 | #include <stdlib.h> | ||
16 | #include <stdarg.h> | ||
17 | #include <string.h> | ||
18 | #include <errno.h> | ||
19 | #include <time.h> | ||
20 | #include <dirent.h> | ||
21 | #include <fcntl.h> | ||
22 | #include <unistd.h> | ||
23 | #include <syslog.h> | ||
24 | #include <signal.h> | ||
25 | #include <getopt.h> | ||
26 | #include <sys/ioctl.h> | ||
27 | #include <sys/wait.h> | ||
28 | #include <sys/stat.h> | ||
29 | #include <sys/resource.h> | ||
30 | 14 | ||
31 | #ifndef CRONTABS | 15 | #ifndef CRONTABS |
32 | #define CRONTABS "/var/spool/cron/crontabs" | 16 | #define CRONTABS "/var/spool/cron/crontabs" |
@@ -47,8 +31,7 @@ static void EditFile(const char *user, const char *file); | |||
47 | static int GetReplaceStream(const char *user, const char *file); | 31 | static int GetReplaceStream(const char *user, const char *file); |
48 | static int ChangeUser(const char *user, short dochdir); | 32 | static int ChangeUser(const char *user, short dochdir); |
49 | 33 | ||
50 | int | 34 | int crontab_main(int ac, char **av) |
51 | crontab_main(int ac, char **av) | ||
52 | { | 35 | { |
53 | enum { NONE, EDIT, LIST, REPLACE, DELETE } option = NONE; | 36 | enum { NONE, EDIT, LIST, REPLACE, DELETE } option = NONE; |
54 | const struct passwd *pas; | 37 | const struct passwd *pas; |
@@ -147,7 +130,7 @@ crontab_main(int ac, char **av) | |||
147 | * Change directory to our crontab directory | 130 | * Change directory to our crontab directory |
148 | */ | 131 | */ |
149 | 132 | ||
150 | bb_xchdir(CDir); | 133 | xchdir(CDir); |
151 | 134 | ||
152 | /* | 135 | /* |
153 | * Handle options as appropriate | 136 | * Handle options as appropriate |
@@ -177,7 +160,7 @@ crontab_main(int ac, char **av) | |||
177 | char buf[1024]; | 160 | char buf[1024]; |
178 | 161 | ||
179 | snprintf(tmp, sizeof(tmp), TMPDIR "/crontab.%d", getpid()); | 162 | snprintf(tmp, sizeof(tmp), TMPDIR "/crontab.%d", getpid()); |
180 | fd = bb_xopen3(tmp, O_RDWR|O_CREAT|O_TRUNC|O_EXCL, 0600); | 163 | fd = xopen3(tmp, O_RDWR|O_CREAT|O_TRUNC|O_EXCL, 0600); |
181 | chown(tmp, getuid(), getgid()); | 164 | chown(tmp, getuid(), getgid()); |
182 | if ((fi = fopen(pas->pw_name, "r"))) { | 165 | if ((fi = fopen(pas->pw_name, "r"))) { |
183 | while ((n = fread(buf, 1, sizeof(buf), fi)) > 0) | 166 | while ((n = fread(buf, 1, sizeof(buf), fi)) > 0) |
@@ -244,8 +227,7 @@ crontab_main(int ac, char **av) | |||
244 | return 0; | 227 | return 0; |
245 | } | 228 | } |
246 | 229 | ||
247 | static int | 230 | static int GetReplaceStream(const char *user, const char *file) |
248 | GetReplaceStream(const char *user, const char *file) | ||
249 | { | 231 | { |
250 | int filedes[2]; | 232 | int filedes[2]; |
251 | int pid; | 233 | int pid; |
@@ -284,7 +266,7 @@ GetReplaceStream(const char *user, const char *file) | |||
284 | exit(0); | 266 | exit(0); |
285 | 267 | ||
286 | bb_default_error_retval = 0; | 268 | bb_default_error_retval = 0; |
287 | fd = bb_xopen3(file, O_RDONLY, 0); | 269 | fd = xopen3(file, O_RDONLY, 0); |
288 | buf[0] = 0; | 270 | buf[0] = 0; |
289 | write(filedes[1], buf, 1); | 271 | write(filedes[1], buf, 1); |
290 | while ((n = read(fd, buf, sizeof(buf))) > 0) { | 272 | while ((n = read(fd, buf, sizeof(buf))) > 0) { |
@@ -293,8 +275,7 @@ GetReplaceStream(const char *user, const char *file) | |||
293 | exit(0); | 275 | exit(0); |
294 | } | 276 | } |
295 | 277 | ||
296 | static void | 278 | static void EditFile(const char *user, const char *file) |
297 | EditFile(const char *user, const char *file) | ||
298 | { | 279 | { |
299 | int pid; | 280 | int pid; |
300 | 281 | ||
@@ -324,8 +305,7 @@ EditFile(const char *user, const char *file) | |||
324 | wait4(pid, NULL, 0, NULL); | 305 | wait4(pid, NULL, 0, NULL); |
325 | } | 306 | } |
326 | 307 | ||
327 | static int | 308 | static int ChangeUser(const char *user, short dochdir) |
328 | ChangeUser(const char *user, short dochdir) | ||
329 | { | 309 | { |
330 | struct passwd *pas; | 310 | struct passwd *pas; |
331 | 311 | ||
@@ -349,7 +329,7 @@ ChangeUser(const char *user, short dochdir) | |||
349 | if (dochdir) { | 329 | if (dochdir) { |
350 | if (chdir(pas->pw_dir) < 0) { | 330 | if (chdir(pas->pw_dir) < 0) { |
351 | bb_perror_msg("chdir failed: %s %s", user, pas->pw_dir); | 331 | bb_perror_msg("chdir failed: %s %s", user, pas->pw_dir); |
352 | bb_xchdir(TMPDIR); | 332 | xchdir(TMPDIR); |
353 | } | 333 | } |
354 | } | 334 | } |
355 | return(pas->pw_uid); | 335 | return(pas->pw_uid); |
diff --git a/miscutils/devfsd.c b/miscutils/devfsd.c index 39f04780a..0f36970f9 100644 --- a/miscutils/devfsd.c +++ b/miscutils/devfsd.c | |||
@@ -475,7 +475,7 @@ int devfsd_main (int argc, char **argv) | |||
475 | if (chdir (mount_point) != 0) | 475 | if (chdir (mount_point) != 0) |
476 | devfsd_perror_msg_and_die(mount_point); | 476 | devfsd_perror_msg_and_die(mount_point); |
477 | 477 | ||
478 | fd = bb_xopen (".devfsd", O_RDONLY); | 478 | fd = xopen (".devfsd", O_RDONLY); |
479 | 479 | ||
480 | if (fcntl (fd, F_SETFD, FD_CLOEXEC) != 0) | 480 | if (fcntl (fd, F_SETFD, FD_CLOEXEC) != 0) |
481 | devfsd_perror_msg_and_die("FD_CLOEXEC"); | 481 | devfsd_perror_msg_and_die("FD_CLOEXEC"); |
@@ -704,7 +704,7 @@ static void process_config_line (const char *line, unsigned long *event_mask) | |||
704 | num_args -= 3; | 704 | num_args -= 3; |
705 | 705 | ||
706 | for (count = 0; count < num_args; ++count) | 706 | for (count = 0; count < num_args; ++count) |
707 | new->u.execute.argv[count] = bb_xstrdup (p[count]); | 707 | new->u.execute.argv[count] = xstrdup (p[count]); |
708 | 708 | ||
709 | new->u.execute.argv[num_args] = NULL; | 709 | new->u.execute.argv[num_args] = NULL; |
710 | break; | 710 | break; |
@@ -714,8 +714,8 @@ static void process_config_line (const char *line, unsigned long *event_mask) | |||
714 | if (num_args != 2) | 714 | if (num_args != 2) |
715 | goto process_config_line_err; /* missing path and function in line */ | 715 | goto process_config_line_err; /* missing path and function in line */ |
716 | 716 | ||
717 | new->u.copy.source = bb_xstrdup (p[0]); | 717 | new->u.copy.source = xstrdup (p[0]); |
718 | new->u.copy.destination = bb_xstrdup (p[1]); | 718 | new->u.copy.destination = xstrdup (p[1]); |
719 | break; | 719 | break; |
720 | case 8: /* IGNORE */ | 720 | case 8: /* IGNORE */ |
721 | /* FALLTROUGH */ | 721 | /* FALLTROUGH */ |
diff --git a/miscutils/hdparm.c b/miscutils/hdparm.c index 925644e1f..aea96d622 100644 --- a/miscutils/hdparm.c +++ b/miscutils/hdparm.c | |||
@@ -13,22 +13,8 @@ | |||
13 | */ | 13 | */ |
14 | 14 | ||
15 | #include "busybox.h" | 15 | #include "busybox.h" |
16 | #include <string.h> | ||
17 | #include <fcntl.h> | ||
18 | #include <errno.h> | ||
19 | #include <ctype.h> | ||
20 | #include <sys/ioctl.h> | ||
21 | #include <sys/sysmacros.h> | ||
22 | #include <sys/times.h> | ||
23 | #include <sys/mman.h> | ||
24 | #include <linux/types.h> | ||
25 | #include <linux/hdreg.h> | 16 | #include <linux/hdreg.h> |
26 | 17 | ||
27 | #if BB_BIG_ENDIAN && !defined(__USE_XOPEN) | ||
28 | # define __USE_XOPEN | ||
29 | #endif | ||
30 | #include <unistd.h> | ||
31 | |||
32 | /* device types */ | 18 | /* device types */ |
33 | /* ------------ */ | 19 | /* ------------ */ |
34 | #define NO_DEV 0xffff | 20 | #define NO_DEV 0xffff |
@@ -1619,7 +1605,7 @@ static void process_dev(char *devname) | |||
1619 | unsigned char args[4] = {WIN_SETFEATURES,0,0,0}; | 1605 | unsigned char args[4] = {WIN_SETFEATURES,0,0,0}; |
1620 | const char *fmt = " %s\t= %2ld"; | 1606 | const char *fmt = " %s\t= %2ld"; |
1621 | 1607 | ||
1622 | fd = bb_xopen(devname, O_RDONLY|O_NONBLOCK); | 1608 | fd = xopen(devname, O_RDONLY|O_NONBLOCK); |
1623 | printf("\n%s:\n", devname); | 1609 | printf("\n%s:\n", devname); |
1624 | 1610 | ||
1625 | if (set_readahead) | 1611 | if (set_readahead) |
diff --git a/miscutils/last.c b/miscutils/last.c index 47c18ffa0..6e35879f3 100644 --- a/miscutils/last.c +++ b/miscutils/last.c | |||
@@ -8,15 +8,7 @@ | |||
8 | */ | 8 | */ |
9 | 9 | ||
10 | #include "busybox.h" | 10 | #include "busybox.h" |
11 | #include <sys/types.h> | ||
12 | #include <fcntl.h> | ||
13 | #include <unistd.h> | ||
14 | #include <stdlib.h> | ||
15 | #include <utmp.h> | 11 | #include <utmp.h> |
16 | #include <sys/stat.h> | ||
17 | #include <errno.h> | ||
18 | #include <string.h> | ||
19 | #include <time.h> | ||
20 | 12 | ||
21 | #ifndef SHUTDOWN_TIME | 13 | #ifndef SHUTDOWN_TIME |
22 | # define SHUTDOWN_TIME 254 | 14 | # define SHUTDOWN_TIME 254 |
@@ -43,7 +35,7 @@ int last_main(int argc, char **argv) | |||
43 | if (argc > 1) { | 35 | if (argc > 1) { |
44 | bb_show_usage(); | 36 | bb_show_usage(); |
45 | } | 37 | } |
46 | file = bb_xopen(bb_path_wtmp_file, O_RDONLY); | 38 | file = xopen(bb_path_wtmp_file, O_RDONLY); |
47 | 39 | ||
48 | printf("%-10s %-14s %-18s %-12.12s %s\n", "USER", "TTY", "HOST", "LOGIN", "TIME"); | 40 | printf("%-10s %-14s %-18s %-12.12s %s\n", "USER", "TTY", "HOST", "LOGIN", "TIME"); |
49 | while ((n = safe_read(file, (void*)&ut, sizeof(struct utmp))) != 0) { | 41 | while ((n = safe_read(file, (void*)&ut, sizeof(struct utmp))) != 0) { |
diff --git a/miscutils/less.c b/miscutils/less.c index 596490483..9dd9b9e56 100644 --- a/miscutils/less.c +++ b/miscutils/less.c | |||
@@ -31,12 +31,6 @@ | |||
31 | */ | 31 | */ |
32 | 32 | ||
33 | #include "busybox.h" | 33 | #include "busybox.h" |
34 | #include <stdio.h> | ||
35 | #include <stdlib.h> | ||
36 | #include <string.h> | ||
37 | #include <termios.h> | ||
38 | #include <unistd.h> | ||
39 | #include <ctype.h> | ||
40 | 34 | ||
41 | #ifdef CONFIG_FEATURE_LESS_REGEXP | 35 | #ifdef CONFIG_FEATURE_LESS_REGEXP |
42 | #include "xregex.h" | 36 | #include "xregex.h" |
@@ -196,7 +190,7 @@ static void add_linenumbers(void) | |||
196 | 190 | ||
197 | for (i = 0; i <= num_flines; i++) { | 191 | for (i = 0; i <= num_flines; i++) { |
198 | safe_strncpy(current_line, flines[i], 256); | 192 | safe_strncpy(current_line, flines[i], 256); |
199 | flines[i] = bb_xasprintf("%5d %s", i + 1, current_line); | 193 | flines[i] = xasprintf("%5d %s", i + 1, current_line); |
200 | } | 194 | } |
201 | } | 195 | } |
202 | 196 | ||
@@ -206,15 +200,15 @@ static void data_readlines(void) | |||
206 | char current_line[256]; | 200 | char current_line[256]; |
207 | FILE *fp; | 201 | FILE *fp; |
208 | 202 | ||
209 | fp = (inp_stdin) ? stdin : bb_xfopen(filename, "r"); | 203 | fp = (inp_stdin) ? stdin : xfopen(filename, "r"); |
210 | flines = NULL; | 204 | flines = NULL; |
211 | for (i = 0; (feof(fp)==0) && (i <= MAXLINES); i++) { | 205 | for (i = 0; (feof(fp)==0) && (i <= MAXLINES); i++) { |
212 | strcpy(current_line, ""); | 206 | strcpy(current_line, ""); |
213 | fgets(current_line, 256, fp); | 207 | fgets(current_line, 256, fp); |
214 | if (fp != stdin) | 208 | if (fp != stdin) |
215 | bb_xferror(fp, filename); | 209 | xferror(fp, filename); |
216 | flines = xrealloc(flines, (i+1) * sizeof(char *)); | 210 | flines = xrealloc(flines, (i+1) * sizeof(char *)); |
217 | flines[i] = bb_xstrdup(current_line); | 211 | flines[i] = xstrdup(current_line); |
218 | } | 212 | } |
219 | num_flines = i - 2; | 213 | num_flines = i - 2; |
220 | 214 | ||
@@ -226,7 +220,7 @@ static void data_readlines(void) | |||
226 | fclose(fp); | 220 | fclose(fp); |
227 | 221 | ||
228 | if (inp == NULL) | 222 | if (inp == NULL) |
229 | inp = (inp_stdin) ? bb_xfopen(CURRENT_TTY, "r") : stdin; | 223 | inp = (inp_stdin) ? xfopen(CURRENT_TTY, "r") : stdin; |
230 | 224 | ||
231 | if (flags & FLAG_N) | 225 | if (flags & FLAG_N) |
232 | add_linenumbers(); | 226 | add_linenumbers(); |
@@ -357,12 +351,12 @@ static void buffer_init(void) | |||
357 | /* Fill the buffer until the end of the file or the | 351 | /* Fill the buffer until the end of the file or the |
358 | end of the buffer is reached */ | 352 | end of the buffer is reached */ |
359 | for (i = 0; (i < (height - 1)) && (i <= num_flines); i++) { | 353 | for (i = 0; (i < (height - 1)) && (i <= num_flines); i++) { |
360 | buffer[i] = bb_xstrdup(flines[i]); | 354 | buffer[i] = xstrdup(flines[i]); |
361 | } | 355 | } |
362 | 356 | ||
363 | /* If the buffer still isn't full, fill it with blank lines */ | 357 | /* If the buffer still isn't full, fill it with blank lines */ |
364 | for (; i < (height - 1); i++) { | 358 | for (; i < (height - 1); i++) { |
365 | buffer[i] = bb_xstrdup(""); | 359 | buffer[i] = xstrdup(""); |
366 | } | 360 | } |
367 | } | 361 | } |
368 | 362 | ||
@@ -376,7 +370,7 @@ static void buffer_down(int nlines) | |||
376 | line_pos += nlines; | 370 | line_pos += nlines; |
377 | for (i = 0; i < (height - 1); i++) { | 371 | for (i = 0; i < (height - 1); i++) { |
378 | free(buffer[i]); | 372 | free(buffer[i]); |
379 | buffer[i] = bb_xstrdup(flines[line_pos + i]); | 373 | buffer[i] = xstrdup(flines[line_pos + i]); |
380 | } | 374 | } |
381 | } | 375 | } |
382 | else { | 376 | else { |
@@ -386,7 +380,7 @@ static void buffer_down(int nlines) | |||
386 | line_pos += 1; | 380 | line_pos += 1; |
387 | for (i = 0; i < (height - 1); i++) { | 381 | for (i = 0; i < (height - 1); i++) { |
388 | free(buffer[i]); | 382 | free(buffer[i]); |
389 | buffer[i] = bb_xstrdup(flines[line_pos + i]); | 383 | buffer[i] = xstrdup(flines[line_pos + i]); |
390 | } | 384 | } |
391 | } | 385 | } |
392 | } | 386 | } |
@@ -407,7 +401,7 @@ static void buffer_up(int nlines) | |||
407 | line_pos -= nlines; | 401 | line_pos -= nlines; |
408 | for (i = 0; i < (height - 1); i++) { | 402 | for (i = 0; i < (height - 1); i++) { |
409 | free(buffer[i]); | 403 | free(buffer[i]); |
410 | buffer[i] = bb_xstrdup(flines[line_pos + i]); | 404 | buffer[i] = xstrdup(flines[line_pos + i]); |
411 | } | 405 | } |
412 | } | 406 | } |
413 | else { | 407 | else { |
@@ -417,7 +411,7 @@ static void buffer_up(int nlines) | |||
417 | line_pos -= 1; | 411 | line_pos -= 1; |
418 | for (i = 0; i < (height - 1); i++) { | 412 | for (i = 0; i < (height - 1); i++) { |
419 | free(buffer[i]); | 413 | free(buffer[i]); |
420 | buffer[i] = bb_xstrdup(flines[line_pos + i]); | 414 | buffer[i] = xstrdup(flines[line_pos + i]); |
421 | } | 415 | } |
422 | } | 416 | } |
423 | } | 417 | } |
@@ -439,10 +433,10 @@ static void buffer_up(int nlines) | |||
439 | for (i = 0; i < (height - 1); i++) { | 433 | for (i = 0; i < (height - 1); i++) { |
440 | free(buffer[i]); | 434 | free(buffer[i]); |
441 | if (i < tilde_line - nlines + 1) | 435 | if (i < tilde_line - nlines + 1) |
442 | buffer[i] = bb_xstrdup(flines[line_pos + i]); | 436 | buffer[i] = xstrdup(flines[line_pos + i]); |
443 | else { | 437 | else { |
444 | if (line_pos >= num_flines - height + 2) | 438 | if (line_pos >= num_flines - height + 2) |
445 | buffer[i] = bb_xstrdup("~\n"); | 439 | buffer[i] = xstrdup("~\n"); |
446 | } | 440 | } |
447 | } | 441 | } |
448 | } | 442 | } |
@@ -461,7 +455,7 @@ static void buffer_line(int linenum) | |||
461 | else if (linenum < (num_flines - height - 2)) { | 455 | else if (linenum < (num_flines - height - 2)) { |
462 | for (i = 0; i < (height - 1); i++) { | 456 | for (i = 0; i < (height - 1); i++) { |
463 | free(buffer[i]); | 457 | free(buffer[i]); |
464 | buffer[i] = bb_xstrdup(flines[linenum + i]); | 458 | buffer[i] = xstrdup(flines[linenum + i]); |
465 | } | 459 | } |
466 | line_pos = linenum; | 460 | line_pos = linenum; |
467 | buffer_print(); | 461 | buffer_print(); |
@@ -470,9 +464,9 @@ static void buffer_line(int linenum) | |||
470 | for (i = 0; i < (height - 1); i++) { | 464 | for (i = 0; i < (height - 1); i++) { |
471 | free(buffer[i]); | 465 | free(buffer[i]); |
472 | if (linenum + i < num_flines + 2) | 466 | if (linenum + i < num_flines + 2) |
473 | buffer[i] = bb_xstrdup(flines[linenum + i]); | 467 | buffer[i] = xstrdup(flines[linenum + i]); |
474 | else | 468 | else |
475 | buffer[i] = bb_xstrdup((flags & FLAG_TILDE) ? "\n" : "~\n"); | 469 | buffer[i] = xstrdup((flags & FLAG_TILDE) ? "\n" : "~\n"); |
476 | } | 470 | } |
477 | line_pos = linenum; | 471 | line_pos = linenum; |
478 | /* Set past_eof so buffer_down and buffer_up act differently */ | 472 | /* Set past_eof so buffer_down and buffer_up act differently */ |
@@ -508,7 +502,7 @@ static void examine_file(void) | |||
508 | newline_offset = strlen(filename) - 1; | 502 | newline_offset = strlen(filename) - 1; |
509 | filename[newline_offset] = '\0'; | 503 | filename[newline_offset] = '\0'; |
510 | 504 | ||
511 | files[num_files] = bb_xstrdup(filename); | 505 | files[num_files] = xstrdup(filename); |
512 | current_file = num_files + 1; | 506 | current_file = num_files + 1; |
513 | num_files++; | 507 | num_files++; |
514 | 508 | ||
@@ -612,7 +606,7 @@ static char *process_regex_on_line(char *line, regex_t *pattern, int action) | |||
612 | char *growline = ""; | 606 | char *growline = ""; |
613 | regmatch_t match_structs; | 607 | regmatch_t match_structs; |
614 | 608 | ||
615 | line2 = bb_xstrdup(line); | 609 | line2 = xstrdup(line); |
616 | 610 | ||
617 | match_found = 0; | 611 | match_found = 0; |
618 | match_status = regexec(pattern, line2, 1, &match_structs, 0); | 612 | match_status = regexec(pattern, line2, 1, &match_structs, 0); |
@@ -622,17 +616,17 @@ static char *process_regex_on_line(char *line, regex_t *pattern, int action) | |||
622 | match_found = 1; | 616 | match_found = 1; |
623 | 617 | ||
624 | if (action) { | 618 | if (action) { |
625 | growline = bb_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); | 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 | } | 620 | } |
627 | else { | 621 | else { |
628 | growline = bb_xasprintf("%s%.*s%.*s", growline, match_structs.rm_so - 4, line2, match_structs.rm_eo - match_structs.rm_so, line2 + match_structs.rm_so); | 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); |
629 | } | 623 | } |
630 | 624 | ||
631 | line2 += match_structs.rm_eo; | 625 | line2 += match_structs.rm_eo; |
632 | match_status = regexec(pattern, line2, 1, &match_structs, REG_NOTBOL); | 626 | match_status = regexec(pattern, line2, 1, &match_structs, REG_NOTBOL); |
633 | } | 627 | } |
634 | 628 | ||
635 | growline = bb_xasprintf("%s%s", growline, line2); | 629 | growline = xasprintf("%s%s", growline, line2); |
636 | 630 | ||
637 | return (match_found ? growline : line); | 631 | return (match_found ? growline : line); |
638 | 632 | ||
@@ -679,7 +673,7 @@ static void regex_process(void) | |||
679 | /* Get rid of all the highlights we added previously */ | 673 | /* Get rid of all the highlights we added previously */ |
680 | for (i = 0; i <= num_flines; i++) { | 674 | for (i = 0; i <= num_flines; i++) { |
681 | current_line = process_regex_on_line(flines[i], &old_pattern, 0); | 675 | current_line = process_regex_on_line(flines[i], &old_pattern, 0); |
682 | flines[i] = bb_xstrdup(current_line); | 676 | flines[i] = xstrdup(current_line); |
683 | } | 677 | } |
684 | } | 678 | } |
685 | old_pattern = pattern; | 679 | old_pattern = pattern; |
@@ -693,7 +687,7 @@ static void regex_process(void) | |||
693 | /* Run the regex on each line of the current file here */ | 687 | /* Run the regex on each line of the current file here */ |
694 | for (i = 0; i <= num_flines; i++) { | 688 | for (i = 0; i <= num_flines; i++) { |
695 | current_line = process_regex_on_line(flines[i], &pattern, 1); | 689 | current_line = process_regex_on_line(flines[i], &pattern, 1); |
696 | flines[i] = bb_xstrdup(current_line); | 690 | flines[i] = xstrdup(current_line); |
697 | if (match_found) { | 691 | if (match_found) { |
698 | match_lines = xrealloc(match_lines, (j + 1) * sizeof(int)); | 692 | match_lines = xrealloc(match_lines, (j + 1) * sizeof(int)); |
699 | match_lines[j] = i; | 693 | match_lines[j] = i; |
@@ -864,7 +858,7 @@ static void save_input_to_file(void) | |||
864 | fgets(current_line, 256, inp); | 858 | fgets(current_line, 256, inp); |
865 | current_line[strlen(current_line) - 1] = '\0'; | 859 | current_line[strlen(current_line) - 1] = '\0'; |
866 | if (strlen(current_line) > 1) { | 860 | if (strlen(current_line) > 1) { |
867 | fp = bb_xfopen(current_line, "w"); | 861 | fp = xfopen(current_line, "w"); |
868 | for (i = 0; i < num_flines; i++) | 862 | for (i = 0; i < num_flines; i++) |
869 | fprintf(fp, "%s", flines[i]); | 863 | fprintf(fp, "%s", flines[i]); |
870 | fclose(fp); | 864 | fclose(fp); |
diff --git a/miscutils/makedevs.c b/miscutils/makedevs.c index 776bcaa8d..0ebb0538f 100644 --- a/miscutils/makedevs.c +++ b/miscutils/makedevs.c | |||
@@ -8,15 +8,6 @@ | |||
8 | */ | 8 | */ |
9 | 9 | ||
10 | #include "busybox.h" | 10 | #include "busybox.h" |
11 | #include <stdio.h> | ||
12 | #include <stdlib.h> | ||
13 | #include <string.h> | ||
14 | #include <fcntl.h> | ||
15 | #include <time.h> | ||
16 | #include <ctype.h> | ||
17 | #include <unistd.h> | ||
18 | #include <sys/types.h> | ||
19 | #include <sys/sysmacros.h> /* major() and minor() */ | ||
20 | 11 | ||
21 | #ifdef CONFIG_FEATURE_MAKEDEVS_LEAF | 12 | #ifdef CONFIG_FEATURE_MAKEDEVS_LEAF |
22 | int makedevs_main(int argc, char **argv) | 13 | int makedevs_main(int argc, char **argv) |
@@ -88,13 +79,13 @@ int makedevs_main(int argc, char **argv) | |||
88 | unsigned long flags; | 79 | unsigned long flags; |
89 | flags = bb_getopt_ulflags(argc, argv, "d:", &line); | 80 | flags = bb_getopt_ulflags(argc, argv, "d:", &line); |
90 | if (line) | 81 | if (line) |
91 | table = bb_xfopen(line, "r"); | 82 | table = xfopen(line, "r"); |
92 | 83 | ||
93 | if (optind >= argc || (rootdir=argv[optind])==NULL) { | 84 | if (optind >= argc || (rootdir=argv[optind])==NULL) { |
94 | bb_error_msg_and_die("root directory not specified"); | 85 | bb_error_msg_and_die("root directory not specified"); |
95 | } | 86 | } |
96 | 87 | ||
97 | bb_xchdir(rootdir); | 88 | xchdir(rootdir); |
98 | 89 | ||
99 | umask(0); | 90 | umask(0); |
100 | 91 | ||
diff --git a/miscutils/mountpoint.c b/miscutils/mountpoint.c index 6265a20e1..3e5fb4b46 100644 --- a/miscutils/mountpoint.c +++ b/miscutils/mountpoint.c | |||
@@ -10,10 +10,6 @@ | |||
10 | */ | 10 | */ |
11 | 11 | ||
12 | #include "busybox.h" | 12 | #include "busybox.h" |
13 | #include <sys/stat.h> | ||
14 | #include <errno.h> /* errno */ | ||
15 | #include <string.h> /* strerror */ | ||
16 | #include <getopt.h> /* optind */ | ||
17 | 13 | ||
18 | int mountpoint_main(int argc, char **argv) | 14 | int mountpoint_main(int argc, char **argv) |
19 | { | 15 | { |
@@ -46,7 +42,7 @@ int mountpoint_main(int argc, char **argv) | |||
46 | if (S_ISDIR(st.st_mode)) { | 42 | if (S_ISDIR(st.st_mode)) { |
47 | dev_t st_dev = st.st_dev; | 43 | dev_t st_dev = st.st_dev; |
48 | ino_t st_ino = st.st_ino; | 44 | ino_t st_ino = st.st_ino; |
49 | char *p = bb_xasprintf("%s/..", arg); | 45 | char *p = xasprintf("%s/..", arg); |
50 | 46 | ||
51 | if (stat(p, &st) == 0) { | 47 | if (stat(p, &st) == 0) { |
52 | short ret = (st_dev != st.st_dev) || | 48 | short ret = (st_dev != st.st_dev) || |
diff --git a/miscutils/mt.c b/miscutils/mt.c index 2720f7eab..f562a91a2 100644 --- a/miscutils/mt.c +++ b/miscutils/mt.c | |||
@@ -4,11 +4,7 @@ | |||
4 | */ | 4 | */ |
5 | 5 | ||
6 | #include "busybox.h" | 6 | #include "busybox.h" |
7 | #include <stdio.h> | ||
8 | #include <stdlib.h> | ||
9 | #include <string.h> | ||
10 | #include <sys/mtio.h> | 7 | #include <sys/mtio.h> |
11 | #include <fcntl.h> | ||
12 | 8 | ||
13 | struct mt_opcodes { | 9 | struct mt_opcodes { |
14 | char *name; | 10 | char *name; |
@@ -105,7 +101,7 @@ int mt_main(int argc, char **argv) | |||
105 | break; | 101 | break; |
106 | } | 102 | } |
107 | 103 | ||
108 | fd = bb_xopen3(file, mode, 0); | 104 | fd = xopen3(file, mode, 0); |
109 | 105 | ||
110 | switch (code->value) { | 106 | switch (code->value) { |
111 | case MTTELL: | 107 | case MTTELL: |
diff --git a/miscutils/rx.c b/miscutils/rx.c index 41673b60e..4cc4913e6 100644 --- a/miscutils/rx.c +++ b/miscutils/rx.c | |||
@@ -21,18 +21,6 @@ | |||
21 | */ | 21 | */ |
22 | 22 | ||
23 | #include "busybox.h" | 23 | #include "busybox.h" |
24 | #include <stdlib.h> | ||
25 | #include <stdarg.h> | ||
26 | #include <stdio.h> | ||
27 | #include <unistd.h> | ||
28 | #include <errno.h> | ||
29 | #include <termios.h> | ||
30 | #include <signal.h> | ||
31 | #include <sys/types.h> | ||
32 | #include <sys/stat.h> | ||
33 | #include <fcntl.h> | ||
34 | #include <string.h> | ||
35 | |||
36 | 24 | ||
37 | #define SOH 0x01 | 25 | #define SOH 0x01 |
38 | #define STX 0x02 | 26 | #define STX 0x02 |
@@ -274,8 +262,8 @@ int rx_main(int argc, char **argv) | |||
274 | bb_show_usage(); | 262 | bb_show_usage(); |
275 | 263 | ||
276 | fn = argv[1]; | 264 | fn = argv[1]; |
277 | ttyfd = bb_xopen3(CURRENT_TTY, O_RDWR, 0); | 265 | ttyfd = xopen3(CURRENT_TTY, O_RDWR, 0); |
278 | filefd = bb_xopen3(fn, O_RDWR|O_CREAT|O_TRUNC, 0666); | 266 | filefd = xopen3(fn, O_RDWR|O_CREAT|O_TRUNC, 0666); |
279 | 267 | ||
280 | if (tcgetattr(ttyfd, &tty) < 0) | 268 | if (tcgetattr(ttyfd, &tty) < 0) |
281 | bb_error_msg_and_die("%s: tcgetattr failed: %m\n", argv[0]); | 269 | bb_error_msg_and_die("%s: tcgetattr failed: %m\n", argv[0]); |
diff --git a/miscutils/watchdog.c b/miscutils/watchdog.c index ddd349d9b..ebbab2df3 100644 --- a/miscutils/watchdog.c +++ b/miscutils/watchdog.c | |||
@@ -9,11 +9,6 @@ | |||
9 | */ | 9 | */ |
10 | 10 | ||
11 | #include "busybox.h" | 11 | #include "busybox.h" |
12 | #include <stdio.h> | ||
13 | #include <fcntl.h> | ||
14 | #include <unistd.h> | ||
15 | #include <stdlib.h> | ||
16 | #include <signal.h> | ||
17 | 12 | ||
18 | #define OPT_FOREGROUND 0x01 | 13 | #define OPT_FOREGROUND 0x01 |
19 | #define OPT_TIMER 0x02 | 14 | #define OPT_TIMER 0x02 |
@@ -47,13 +42,13 @@ int watchdog_main(int argc, char **argv) | |||
47 | if (!(opts & OPT_FOREGROUND)) | 42 | if (!(opts & OPT_FOREGROUND)) |
48 | vfork_daemon_rexec(0, 1, argc, argv, "-F"); | 43 | vfork_daemon_rexec(0, 1, argc, argv, "-F"); |
49 | #else | 44 | #else |
50 | bb_xdaemon(0, 1); | 45 | xdaemon(0, 1); |
51 | #endif | 46 | #endif |
52 | 47 | ||
53 | signal(SIGHUP, watchdog_shutdown); | 48 | signal(SIGHUP, watchdog_shutdown); |
54 | signal(SIGINT, watchdog_shutdown); | 49 | signal(SIGINT, watchdog_shutdown); |
55 | 50 | ||
56 | fd = bb_xopen(argv[argc - 1], O_WRONLY); | 51 | fd = xopen(argv[argc - 1], O_WRONLY); |
57 | 52 | ||
58 | while (1) { | 53 | while (1) { |
59 | /* | 54 | /* |