aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>1999-10-18 22:28:26 +0000
committerEric Andersen <andersen@codepoet.org>1999-10-18 22:28:26 +0000
commitb0e9a709ba1ae1724d413a77f5b67b1a3e6c6cb7 (patch)
treeb951f34000ebdef0491eecd9386e5ea3e535171a
parent703c62da63aa31d665a8215f373b26e4b54f1bf4 (diff)
downloadbusybox-w32-b0e9a709ba1ae1724d413a77f5b67b1a3e6c6cb7.tar.gz
busybox-w32-b0e9a709ba1ae1724d413a77f5b67b1a3e6c6cb7.tar.bz2
busybox-w32-b0e9a709ba1ae1724d413a77f5b67b1a3e6c6cb7.zip
More stuff.
-Erik
-rw-r--r--applets/busybox.c3
-rw-r--r--busybox.c3
-rw-r--r--busybox.def.h21
-rw-r--r--cat.c3
-rw-r--r--chroot.c3
-rw-r--r--console-tools/loadkmap.c2
-rw-r--r--coreutils/cat.c3
-rw-r--r--coreutils/chroot.c3
-rw-r--r--coreutils/cp.c6
-rw-r--r--coreutils/date.c16
-rw-r--r--coreutils/length.c3
-rw-r--r--coreutils/ln.c6
-rw-r--r--coreutils/ls.c9
-rw-r--r--coreutils/mkdir.c6
-rw-r--r--coreutils/mknod.c15
-rw-r--r--coreutils/mv.c3
-rw-r--r--coreutils/printf.c14
-rw-r--r--coreutils/rm.c8
-rw-r--r--coreutils/rmdir.c3
-rw-r--r--coreutils/sleep.c3
-rw-r--r--coreutils/sync.c5
-rw-r--r--coreutils/touch.c3
-rw-r--r--cp.c6
-rw-r--r--date.c16
-rw-r--r--dmesg.c2
-rw-r--r--dutmp.c3
-rw-r--r--fdflush.c3
-rw-r--r--find.c6
-rw-r--r--findutils/find.c6
-rw-r--r--internal.h2
-rw-r--r--kill.c3
-rw-r--r--length.c3
-rw-r--r--ln.c6
-rw-r--r--loadkmap.c2
-rw-r--r--ls.c9
-rw-r--r--makedevs.c4
-rw-r--r--miscutils/dutmp.c3
-rw-r--r--miscutils/makedevs.c4
-rw-r--r--miscutils/mt.c17
-rw-r--r--mkdir.c6
-rw-r--r--mknod.c15
-rw-r--r--mkswap.c17
-rw-r--r--more.c3
-rw-r--r--mt.c17
-rw-r--r--mv.c3
-rw-r--r--printf.c14
-rw-r--r--procps/kill.c3
-rw-r--r--rm.c8
-rw-r--r--rmdir.c3
-rw-r--r--sleep.c3
-rw-r--r--swaponoff.c10
-rw-r--r--sync.c5
-rw-r--r--touch.c3
-rw-r--r--umount.c6
-rw-r--r--util-linux/dmesg.c2
-rw-r--r--util-linux/fdflush.c3
-rw-r--r--util-linux/mkswap.c17
-rw-r--r--util-linux/more.c3
-rw-r--r--util-linux/swaponoff.c10
-rw-r--r--util-linux/umount.c6
-rw-r--r--utility.c8
61 files changed, 168 insertions, 233 deletions
diff --git a/applets/busybox.c b/applets/busybox.c
index 6bc223a1d..16ccce67e 100644
--- a/applets/busybox.c
+++ b/applets/busybox.c
@@ -75,9 +75,6 @@ static const struct Applet applets[] = {
75#ifdef BB_LOADKMAP //sbin 75#ifdef BB_LOADKMAP //sbin
76 {"loadkmap", loadkmap_main}, 76 {"loadkmap", loadkmap_main},
77#endif 77#endif
78#ifdef BB_LOSETUP //sbin
79 {"losetup", losetup_main},
80#endif
81#ifdef BB_LS //bin 78#ifdef BB_LS //bin
82 {"ls", ls_main}, 79 {"ls", ls_main},
83#endif 80#endif
diff --git a/busybox.c b/busybox.c
index 6bc223a1d..16ccce67e 100644
--- a/busybox.c
+++ b/busybox.c
@@ -75,9 +75,6 @@ static const struct Applet applets[] = {
75#ifdef BB_LOADKMAP //sbin 75#ifdef BB_LOADKMAP //sbin
76 {"loadkmap", loadkmap_main}, 76 {"loadkmap", loadkmap_main},
77#endif 77#endif
78#ifdef BB_LOSETUP //sbin
79 {"losetup", losetup_main},
80#endif
81#ifdef BB_LS //bin 78#ifdef BB_LS //bin
82 {"ls", ls_main}, 79 {"ls", ls_main},
83#endif 80#endif
diff --git a/busybox.def.h b/busybox.def.h
index c278f4ce0..7ca522b3a 100644
--- a/busybox.def.h
+++ b/busybox.def.h
@@ -18,25 +18,24 @@
18#define BB_FDFLUSH 18#define BB_FDFLUSH
19#define BB_FIND 19#define BB_FIND
20#define BB_GREP 20#define BB_GREP
21#define BB_HALT 21//#define BB_HALT
22#define BB_INIT 22#define BB_INIT
23#define BB_KILL 23#define BB_KILL
24#define BB_LENGTH 24//#define BB_LENGTH
25#define BB_LN 25#define BB_LN
26//#define BB_LOADKMAP 26#define BB_LOADKMAP
27////#define BB_LOSETUP
28#define BB_LS 27#define BB_LS
29//#define BB_MAKEDEVS 28#define BB_MAKEDEVS
30#define BB_MATH 29//#define BB_MATH
31#define BB_MKDIR 30#define BB_MKDIR
32//#define BB_MKNOD 31#define BB_MKNOD
33////#define BB_MKSWAP 32//#define BB_MKSWAP
34#define BB_MNC 33#define BB_MNC
35#define BB_MORE 34#define BB_MORE
36#define BB_MOUNT 35#define BB_MOUNT
37////#define BB_MT 36//#define BB_MT
38#define BB_MV 37#define BB_MV
39//#define BB_PRINTF 38#define BB_PRINTF
40#define BB_PWD 39#define BB_PWD
41#define BB_REBOOT 40#define BB_REBOOT
42#define BB_RM 41#define BB_RM
@@ -51,4 +50,4 @@
51#define BB_UPDATE 50#define BB_UPDATE
52#define BB_UTILITY 51#define BB_UTILITY
53#define BB_ZCAT 52#define BB_ZCAT
54//#define BB_GZIP 53#define BB_GZIP
diff --git a/cat.c b/cat.c
index 5c54c4941..38078d505 100644
--- a/cat.c
+++ b/cat.c
@@ -42,8 +42,7 @@ extern int cat_more_main(int argc, char **argv)
42 } 42 }
43 43
44 if ( **(argv+1) == '-' ) { 44 if ( **(argv+1) == '-' ) {
45 fprintf(stderr, "Usage: cat [file ...]\n"); 45 usage ("cat [file ...]\n");
46 exit(FALSE);
47 } 46 }
48 argc--; 47 argc--;
49 argv++; 48 argv++;
diff --git a/chroot.c b/chroot.c
index 3b6fdae3b..15f446881 100644
--- a/chroot.c
+++ b/chroot.c
@@ -33,8 +33,7 @@ static const char chroot_usage[] = "NEWROOT [COMMAND...]\n"
33int chroot_main(int argc, char **argv) 33int chroot_main(int argc, char **argv)
34{ 34{
35 if ( (argc < 2) || (**(argv+1) == '-') ) { 35 if ( (argc < 2) || (**(argv+1) == '-') ) {
36 fprintf(stderr, "Usage: %s %s", *argv, chroot_usage); 36 usage( chroot_usage);
37 exit( FALSE);
38 } 37 }
39 argc--; 38 argc--;
40 argv++; 39 argv++;
diff --git a/console-tools/loadkmap.c b/console-tools/loadkmap.c
index 0f092d193..eb5a5dd4a 100644
--- a/console-tools/loadkmap.c
+++ b/console-tools/loadkmap.c
@@ -14,7 +14,7 @@ const char loadkmap_usage[] = "loadkmap\n"
14 14
15 15
16int 16int
17loadkmap_main(struct FileInfo * info, int argc, char * * argv) 17loadkmap_main(int argc, char * * argv)
18{ 18{
19 struct kbentry ke; 19 struct kbentry ke;
20 u_short *ibuff; 20 u_short *ibuff;
diff --git a/coreutils/cat.c b/coreutils/cat.c
index 5c54c4941..38078d505 100644
--- a/coreutils/cat.c
+++ b/coreutils/cat.c
@@ -42,8 +42,7 @@ extern int cat_more_main(int argc, char **argv)
42 } 42 }
43 43
44 if ( **(argv+1) == '-' ) { 44 if ( **(argv+1) == '-' ) {
45 fprintf(stderr, "Usage: cat [file ...]\n"); 45 usage ("cat [file ...]\n");
46 exit(FALSE);
47 } 46 }
48 argc--; 47 argc--;
49 argv++; 48 argv++;
diff --git a/coreutils/chroot.c b/coreutils/chroot.c
index 3b6fdae3b..15f446881 100644
--- a/coreutils/chroot.c
+++ b/coreutils/chroot.c
@@ -33,8 +33,7 @@ static const char chroot_usage[] = "NEWROOT [COMMAND...]\n"
33int chroot_main(int argc, char **argv) 33int chroot_main(int argc, char **argv)
34{ 34{
35 if ( (argc < 2) || (**(argv+1) == '-') ) { 35 if ( (argc < 2) || (**(argv+1) == '-') ) {
36 fprintf(stderr, "Usage: %s %s", *argv, chroot_usage); 36 usage( chroot_usage);
37 exit( FALSE);
38 } 37 }
39 argc--; 38 argc--;
40 argv++; 39 argv++;
diff --git a/coreutils/cp.c b/coreutils/cp.c
index c5e34d333..11c76825c 100644
--- a/coreutils/cp.c
+++ b/coreutils/cp.c
@@ -60,8 +60,7 @@ extern int cp_main(int argc, char **argv)
60{ 60{
61 61
62 if (argc < 3) { 62 if (argc < 3) {
63 fprintf(stderr, "Usage: %s", cp_usage); 63 usage (cp_usage);
64 exit (FALSE);
65 } 64 }
66 argc--; 65 argc--;
67 argv++; 66 argv++;
@@ -85,8 +84,7 @@ extern int cp_main(int argc, char **argv)
85 recursiveFlag = TRUE; 84 recursiveFlag = TRUE;
86 break; 85 break;
87 default: 86 default:
88 fprintf(stderr, "Usage: %s\n", cp_usage); 87 usage (cp_usage);
89 exit(FALSE);
90 } 88 }
91 argc--; 89 argc--;
92 argv++; 90 argv++;
diff --git a/coreutils/date.c b/coreutils/date.c
index 2df9e0cc7..70d5dd5c6 100644
--- a/coreutils/date.c
+++ b/coreutils/date.c
@@ -34,7 +34,7 @@
34 an RFC 822 complient date output for shell scripting 34 an RFC 822 complient date output for shell scripting
35 mail commands */ 35 mail commands */
36 36
37const char date_usage[] = "Usage: date [OPTION]... [+FORMAT]\n" 37const char date_usage[] = "date [OPTION]... [+FORMAT]\n"
38" or: date [OPTION] [MMDDhhmm[[CC]YY][.ss]]\n" 38" or: date [OPTION] [MMDDhhmm[[CC]YY][.ss]]\n"
39"Display the current time in the given FORMAT, or set the system date.\n" 39"Display the current time in the given FORMAT, or set the system date.\n"
40"\nOptions:\n\t-R\t\toutput RFC-822 compliant date string\n" 40"\nOptions:\n\t-R\t\toutput RFC-822 compliant date string\n"
@@ -159,12 +159,6 @@ date_conv_ftime(struct tm *tm_time, const char *t_string) {
159} 159}
160 160
161 161
162void
163date_err(void) {
164 fprintf (stderr, "%s\n", date_usage);
165 exit( FALSE);
166}
167
168int 162int
169date_main(int argc, char * * argv) 163date_main(int argc, char * * argv)
170{ 164{
@@ -190,7 +184,7 @@ date_main(int argc, char * * argv)
190 break; 184 break;
191 case 's': 185 case 's':
192 set_time = 1; 186 set_time = 1;
193 if(date_str != NULL) date_err(); 187 if(date_str != NULL) usage ( date_usage);
194 date_str = optarg; 188 date_str = optarg;
195 break; 189 break;
196 case 'u': 190 case 'u':
@@ -202,11 +196,11 @@ date_main(int argc, char * * argv)
202 /* Look ma, no break. Don't fix it either. */ 196 /* Look ma, no break. Don't fix it either. */
203 case 'd': 197 case 'd':
204 use_arg = 1; 198 use_arg = 1;
205 if(date_str != NULL) date_err(); 199 if(date_str != NULL) usage ( date_usage);
206 date_str = optarg; 200 date_str = optarg;
207 break; 201 break;
208 case '-': 202 case '-':
209 date_err(); 203 usage ( date_usage);
210 } 204 }
211 } else { 205 } else {
212 if ( (date_fmt == NULL) && (strcmp(*argv, "+")==0) ) 206 if ( (date_fmt == NULL) && (strcmp(*argv, "+")==0) )
@@ -215,7 +209,7 @@ date_main(int argc, char * * argv)
215 set_time = 1; 209 set_time = 1;
216 date_str=*argv; 210 date_str=*argv;
217 } else { 211 } else {
218 date_err(); 212 usage ( date_usage);
219 } 213 }
220 } 214 }
221 i--; 215 i--;
diff --git a/coreutils/length.c b/coreutils/length.c
index f2dadd25c..46242b529 100644
--- a/coreutils/length.c
+++ b/coreutils/length.c
@@ -7,8 +7,7 @@ extern int
7length_main(int argc, char * * argv) 7length_main(int argc, char * * argv)
8{ 8{
9 if ( **(argv+1) == '-' ) { 9 if ( **(argv+1) == '-' ) {
10 fprintf(stderr, "Usage: length string\n"); 10 usage("length string\n");
11 exit(FALSE);
12 } 11 }
13 printf("%d\n", strlen(argv[1])); 12 printf("%d\n", strlen(argv[1]));
14 return( TRUE); 13 return( TRUE);
diff --git a/coreutils/ln.c b/coreutils/ln.c
index cd3cb4e45..8f7719fa4 100644
--- a/coreutils/ln.c
+++ b/coreutils/ln.c
@@ -44,8 +44,7 @@ extern int ln_main(int argc, char **argv)
44 char newdestName[NAME_MAX]; 44 char newdestName[NAME_MAX];
45 45
46 if (argc < 3) { 46 if (argc < 3) {
47 fprintf(stderr, "Usage: %s", ln_usage); 47 usage (ln_usage);
48 exit (FALSE);
49 } 48 }
50 argc--; 49 argc--;
51 argv++; 50 argv++;
@@ -61,8 +60,7 @@ extern int ln_main(int argc, char **argv)
61 removeoldFlag = TRUE; 60 removeoldFlag = TRUE;
62 break; 61 break;
63 default: 62 default:
64 fprintf(stderr, "Usage: %s\n", ln_usage); 63 usage (ln_usage);
65 exit(FALSE);
66 } 64 }
67 argc--; 65 argc--;
68 argv++; 66 argv++;
diff --git a/coreutils/ls.c b/coreutils/ls.c
index 2e3d50e9f..0adc35de1 100644
--- a/coreutils/ls.c
+++ b/coreutils/ls.c
@@ -19,6 +19,8 @@
19 * 19 *
20 */ 20 */
21 21
22// I started writing a newer small one, but it isn't done yet....
23// -Erik
22#if fooBar 24#if fooBar
23 25
24#include <stdio.h> 26#include <stdio.h>
@@ -110,8 +112,7 @@ int ls_main(int argc, char **argv)
110 recursiveFlag = TRUE; 112 recursiveFlag = TRUE;
111 break; 113 break;
112 default: 114 default:
113 fprintf(stderr, "Usage: %s\n", ls_usage); 115 usage (ls_usage);
114 exit( FALSE);
115 } 116 }
116 argc--; 117 argc--;
117 argv++; 118 argv++;
@@ -571,7 +572,7 @@ listerr:
571 return 1; 572 return 1;
572} 573}
573 574
574const char ls_usage[] = "Usage: ls [-1a" 575const char ls_usage[] = "ls [-1a"
575#ifdef FEATURE_TIMESTAMPS 576#ifdef FEATURE_TIMESTAMPS
576 "c" 577 "c"
577#endif 578#endif
@@ -668,7 +669,7 @@ ls_main(int argc, char * * argv)
668 exit( i); 669 exit( i);
669 670
670print_usage_message: 671print_usage_message:
671 fprintf(stderr, "Usage: %s\n", ls_usage); 672 usage (ls_usage);
672 exit( FALSE); 673 exit( FALSE);
673} 674}
674 675
diff --git a/coreutils/mkdir.c b/coreutils/mkdir.c
index 61d35d5cd..b42899a4a 100644
--- a/coreutils/mkdir.c
+++ b/coreutils/mkdir.c
@@ -51,8 +51,7 @@ extern int mkdir_main(int argc, char **argv)
51 parentFlag = TRUE; 51 parentFlag = TRUE;
52 break; 52 break;
53 default: 53 default:
54 fprintf(stderr, "%s\n", mkdir_usage); 54 usage( mkdir_usage);
55 exit(FALSE);
56 } 55 }
57 argc--; 56 argc--;
58 argv++; 57 argv++;
@@ -60,8 +59,7 @@ extern int mkdir_main(int argc, char **argv)
60 59
61 60
62 if (argc < 1) { 61 if (argc < 1) {
63 fprintf(stderr, "%s\n", mkdir_usage); 62 usage( mkdir_usage);
64 exit (FALSE);
65 } 63 }
66 64
67 while (--argc > 0) { 65 while (--argc > 0) {
diff --git a/coreutils/mknod.c b/coreutils/mknod.c
index b18394bec..95d7de360 100644
--- a/coreutils/mknod.c
+++ b/coreutils/mknod.c
@@ -1,4 +1,5 @@
1#include "internal.h" 1#include "internal.h"
2#include <stdio.h>
2#include <errno.h> 3#include <errno.h>
3#include <sys/types.h> 4#include <sys/types.h>
4#include <sys/stat.h> 5#include <sys/stat.h>
@@ -13,7 +14,7 @@ const char mknod_usage[] = "mknod file b|c|u|p major minor\n"
13"\tp:\tMake a named pipe. Major and minor are ignored for named pipes.\n"; 14"\tp:\tMake a named pipe. Major and minor are ignored for named pipes.\n";
14 15
15int 16int
16mknod_main(struct FileInfo * i, int argc, char * * argv) 17mknod_main(int argc, char** argv)
17{ 18{
18 mode_t mode = 0; 19 mode_t mode = 0;
19 dev_t dev = 0; 20 dev_t dev = 0;
@@ -30,23 +31,21 @@ mknod_main(struct FileInfo * i, int argc, char * * argv)
30 mode = S_IFIFO; 31 mode = S_IFIFO;
31 break; 32 break;
32 default: 33 default:
33 usage(mknod_usage); 34 usage (mknod_usage);
34 return 1;
35 } 35 }
36 36
37 if ( mode == S_IFCHR || mode == S_IFBLK ) { 37 if ( mode == S_IFCHR || mode == S_IFBLK ) {
38 dev = (atoi(argv[3]) << 8) | atoi(argv[4]); 38 dev = (atoi(argv[3]) << 8) | atoi(argv[4]);
39 if ( argc != 5 ) { 39 if ( argc != 5 ) {
40 usage(mknod_usage); 40 usage (mknod_usage);
41 return 1;
42 } 41 }
43 } 42 }
44 43
45 mode |= 0666; 44 mode |= 0666;
46 45
47 if ( mknod(argv[1], mode, dev) != 0 ) { 46 if ( mknod(argv[1], mode, dev) != 0 ) {
48 name_and_error(argv[1]); 47 perror(argv[1]);
49 return 1; 48 return( FALSE);
50 } 49 }
51 return 0; 50 return( TRUE);
52} 51}
diff --git a/coreutils/mv.c b/coreutils/mv.c
index 2a7c8c1f3..ab3fc2bd5 100644
--- a/coreutils/mv.c
+++ b/coreutils/mv.c
@@ -42,8 +42,7 @@ extern int mv_main(int argc, char **argv)
42 char newdestName[NAME_MAX]; 42 char newdestName[NAME_MAX];
43 43
44 if (argc < 3) { 44 if (argc < 3) {
45 fprintf(stderr, "Usage: %s", mv_usage); 45 usage (mv_usage);
46 exit (FALSE);
47 } 46 }
48 argc--; 47 argc--;
49 argv++; 48 argv++;
diff --git a/coreutils/printf.c b/coreutils/printf.c
index e79843c80..4d4465943 100644
--- a/coreutils/printf.c
+++ b/coreutils/printf.c
@@ -1,8 +1,3 @@
1// I may still need some more cleaning...fix my error checking
2
3#include "internal.h"
4#ifdef BB_PRINTF
5
6/* printf - format and print data 1/* printf - format and print data
7 Copyright (C) 90, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc. 2 Copyright (C) 90, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
8 3
@@ -51,6 +46,7 @@
51 46
52// 19990508 Busy Boxed! Dave Cinege 47// 19990508 Busy Boxed! Dave Cinege
53 48
49#include "internal.h"
54#include <unistd.h> 50#include <unistd.h>
55#include <stdio.h> 51#include <stdio.h>
56#include <sys/types.h> 52#include <sys/types.h>
@@ -140,15 +136,18 @@ static void verify __P ((char *s, char *end));
140/* The value to return to the calling program. */ 136/* The value to return to the calling program. */
141static int exit_status; 137static int exit_status;
142 138
143const char printf_usage[] = "Usage: printf format [argument...]\n"; 139const char printf_usage[] = "printf format [argument...]\n";
144 140
145int 141int
146printf_main(struct FileInfo * i, int argc, char * * argv) 142printf_main(int argc, char** argv)
147{ 143{
148 char *format; 144 char *format;
149 int args_used; 145 int args_used;
150 146
151 exit_status = 0; 147 exit_status = 0;
148 if ( **(argv+1) == '-' ) {
149 usage (printf_usage);
150 }
152 151
153 format = argv[1]; 152 format = argv[1];
154 argc -= 2; 153 argc -= 2;
@@ -528,4 +527,3 @@ verify (char *s, char *end)
528 } 527 }
529} 528}
530 529
531#endif
diff --git a/coreutils/rm.c b/coreutils/rm.c
index 477d3af59..dd8dfa4e6 100644
--- a/coreutils/rm.c
+++ b/coreutils/rm.c
@@ -25,7 +25,7 @@
25#include <utime.h> 25#include <utime.h>
26#include <dirent.h> 26#include <dirent.h>
27 27
28static const char* rm_usage = "Usage: rm [OPTION]... FILE...\n" 28static const char* rm_usage = "rm [OPTION]... FILE...\n"
29"Remove (unlink) the FILE(s).\n\n" 29"Remove (unlink) the FILE(s).\n\n"
30"\t-f\tremove existing destinations, never prompt\n" 30"\t-f\tremove existing destinations, never prompt\n"
31"\t-r\tremove the contents of directories recursively\n"; 31"\t-r\tremove the contents of directories recursively\n";
@@ -58,8 +58,7 @@ extern int rm_main(int argc, char **argv)
58{ 58{
59 59
60 if (argc < 2) { 60 if (argc < 2) {
61 fprintf(stderr, "Usage: %s", rm_usage); 61 usage( rm_usage);
62 exit (FALSE);
63 } 62 }
64 argc--; 63 argc--;
65 argv++; 64 argv++;
@@ -75,8 +74,7 @@ extern int rm_main(int argc, char **argv)
75 forceFlag = TRUE; 74 forceFlag = TRUE;
76 break; 75 break;
77 default: 76 default:
78 fprintf(stderr, "Usage: %s\n", rm_usage); 77 usage( rm_usage);
79 exit(FALSE);
80 } 78 }
81 argc--; 79 argc--;
82 argv++; 80 argv++;
diff --git a/coreutils/rmdir.c b/coreutils/rmdir.c
index b4da03f12..666e0476a 100644
--- a/coreutils/rmdir.c
+++ b/coreutils/rmdir.c
@@ -27,8 +27,7 @@
27extern int rmdir_main(int argc, char **argv) 27extern int rmdir_main(int argc, char **argv)
28{ 28{
29 if ( argc==1 || **(argv+1) == '-' ) { 29 if ( argc==1 || **(argv+1) == '-' ) {
30 fprintf(stderr, "Usage: rmdir [OPTION]... DIRECTORY...\nRemove the DIRECTORY(ies), if they are empty."); 30 usage( "rmdir [OPTION]... DIRECTORY...\nRemove the DIRECTORY(ies), if they are empty.");
31 exit(FALSE);
32 } 31 }
33 32
34 while (--argc > 0) { 33 while (--argc > 0) {
diff --git a/coreutils/sleep.c b/coreutils/sleep.c
index 53fe5a0c2..7e38a3667 100644
--- a/coreutils/sleep.c
+++ b/coreutils/sleep.c
@@ -8,8 +8,7 @@ extern int
8sleep_main(int argc, char * * argv) 8sleep_main(int argc, char * * argv)
9{ 9{
10 if ( (argc < 2) || (**(argv+1) == '-') ) { 10 if ( (argc < 2) || (**(argv+1) == '-') ) {
11 fprintf(stderr, "Usage: %s %s", *argv, sleep_usage); 11 usage( sleep_usage );
12 exit(FALSE);
13 } 12 }
14 13
15 if ( sleep(atoi(*(++argv))) != 0 ) { 14 if ( sleep(atoi(*(++argv))) != 0 ) {
diff --git a/coreutils/sync.c b/coreutils/sync.c
index 572d74924..8800f2e76 100644
--- a/coreutils/sync.c
+++ b/coreutils/sync.c
@@ -5,9 +5,8 @@ extern int
5sync_main(int argc, char * * argv) 5sync_main(int argc, char * * argv)
6{ 6{
7 if ( **(argv+1) == '-' ) { 7 if ( **(argv+1) == '-' ) {
8 fprintf(stderr, "Usage: sync\nWrite all buffered filesystem blocks to disk.\n"); 8 usage( "sync\nWrite all buffered filesystem blocks to disk.\n");
9 exit(FALSE);
10 } 9 }
11 return sync(); 10 return sync();
12} 11}
13 12
diff --git a/coreutils/touch.c b/coreutils/touch.c
index 8dac10294..c36ffca90 100644
--- a/coreutils/touch.c
+++ b/coreutils/touch.c
@@ -40,8 +40,7 @@ touch_main(int argc, char **argv)
40 int create=TRUE; 40 int create=TRUE;
41 41
42 if (argc < 2) { 42 if (argc < 2) {
43 fprintf(stderr, "Usage: %s %s", *argv, touch_usage); 43 usage( touch_usage);
44 exit( FALSE);
45 } 44 }
46 argc--; 45 argc--;
47 argv++; 46 argv++;
diff --git a/cp.c b/cp.c
index c5e34d333..11c76825c 100644
--- a/cp.c
+++ b/cp.c
@@ -60,8 +60,7 @@ extern int cp_main(int argc, char **argv)
60{ 60{
61 61
62 if (argc < 3) { 62 if (argc < 3) {
63 fprintf(stderr, "Usage: %s", cp_usage); 63 usage (cp_usage);
64 exit (FALSE);
65 } 64 }
66 argc--; 65 argc--;
67 argv++; 66 argv++;
@@ -85,8 +84,7 @@ extern int cp_main(int argc, char **argv)
85 recursiveFlag = TRUE; 84 recursiveFlag = TRUE;
86 break; 85 break;
87 default: 86 default:
88 fprintf(stderr, "Usage: %s\n", cp_usage); 87 usage (cp_usage);
89 exit(FALSE);
90 } 88 }
91 argc--; 89 argc--;
92 argv++; 90 argv++;
diff --git a/date.c b/date.c
index 2df9e0cc7..70d5dd5c6 100644
--- a/date.c
+++ b/date.c
@@ -34,7 +34,7 @@
34 an RFC 822 complient date output for shell scripting 34 an RFC 822 complient date output for shell scripting
35 mail commands */ 35 mail commands */
36 36
37const char date_usage[] = "Usage: date [OPTION]... [+FORMAT]\n" 37const char date_usage[] = "date [OPTION]... [+FORMAT]\n"
38" or: date [OPTION] [MMDDhhmm[[CC]YY][.ss]]\n" 38" or: date [OPTION] [MMDDhhmm[[CC]YY][.ss]]\n"
39"Display the current time in the given FORMAT, or set the system date.\n" 39"Display the current time in the given FORMAT, or set the system date.\n"
40"\nOptions:\n\t-R\t\toutput RFC-822 compliant date string\n" 40"\nOptions:\n\t-R\t\toutput RFC-822 compliant date string\n"
@@ -159,12 +159,6 @@ date_conv_ftime(struct tm *tm_time, const char *t_string) {
159} 159}
160 160
161 161
162void
163date_err(void) {
164 fprintf (stderr, "%s\n", date_usage);
165 exit( FALSE);
166}
167
168int 162int
169date_main(int argc, char * * argv) 163date_main(int argc, char * * argv)
170{ 164{
@@ -190,7 +184,7 @@ date_main(int argc, char * * argv)
190 break; 184 break;
191 case 's': 185 case 's':
192 set_time = 1; 186 set_time = 1;
193 if(date_str != NULL) date_err(); 187 if(date_str != NULL) usage ( date_usage);
194 date_str = optarg; 188 date_str = optarg;
195 break; 189 break;
196 case 'u': 190 case 'u':
@@ -202,11 +196,11 @@ date_main(int argc, char * * argv)
202 /* Look ma, no break. Don't fix it either. */ 196 /* Look ma, no break. Don't fix it either. */
203 case 'd': 197 case 'd':
204 use_arg = 1; 198 use_arg = 1;
205 if(date_str != NULL) date_err(); 199 if(date_str != NULL) usage ( date_usage);
206 date_str = optarg; 200 date_str = optarg;
207 break; 201 break;
208 case '-': 202 case '-':
209 date_err(); 203 usage ( date_usage);
210 } 204 }
211 } else { 205 } else {
212 if ( (date_fmt == NULL) && (strcmp(*argv, "+")==0) ) 206 if ( (date_fmt == NULL) && (strcmp(*argv, "+")==0) )
@@ -215,7 +209,7 @@ date_main(int argc, char * * argv)
215 set_time = 1; 209 set_time = 1;
216 date_str=*argv; 210 date_str=*argv;
217 } else { 211 } else {
218 date_err(); 212 usage ( date_usage);
219 } 213 }
220 } 214 }
221 i--; 215 i--;
diff --git a/dmesg.c b/dmesg.c
index 64265b473..e5d403f7a 100644
--- a/dmesg.c
+++ b/dmesg.c
@@ -93,6 +93,6 @@ int dmesg_main (int argc, char **argv)
93 exit (TRUE); 93 exit (TRUE);
94 94
95 end: 95 end:
96 fprintf (stderr, "Usage: %s\n", dmesg_usage); 96 usage( dmesg_usage);
97 exit (FALSE); 97 exit (FALSE);
98} 98}
diff --git a/dutmp.c b/dutmp.c
index 2dad7d4a5..7dd5b91fa 100644
--- a/dutmp.c
+++ b/dutmp.c
@@ -26,8 +26,7 @@ extern int dutmp_fn (int argc, char **argv)
26 struct utmp ut; 26 struct utmp ut;
27 27
28 if ((argc < 2) || (**(argv + 1) == '-')) { 28 if ((argc < 2) || (**(argv + 1) == '-')) {
29 fprintf (stderr, "Usage: %s %s\n", *argv, dutmp_usage); 29 usage( dutmp_usage);
30 exit (FALSE);
31 } 30 }
32 31
33 if ( **(++argv) == 0 ) { 32 if ( **(++argv) == 0 ) {
diff --git a/fdflush.c b/fdflush.c
index ce6870cd1..58b8b37d6 100644
--- a/fdflush.c
+++ b/fdflush.c
@@ -32,8 +32,7 @@ extern int fdflush_main(int argc, char **argv)
32 int value; 32 int value;
33 int fd; 33 int fd;
34 if ( **(argv+1) == '-' ) { 34 if ( **(argv+1) == '-' ) {
35 fprintf(stderr, "Usage: fdflush device\n"); 35 usage( "fdflush device\n");
36 exit(FALSE);
37 } 36 }
38 37
39 fd = open(*argv, 0); 38 fd = open(*argv, 0);
diff --git a/find.c b/find.c
index 1fb219496..51b8707da 100644
--- a/find.c
+++ b/find.c
@@ -100,8 +100,7 @@ int find_main(int argc, char **argv)
100 pattern=*(++argv); 100 pattern=*(++argv);
101 stopit=-TRUE; 101 stopit=-TRUE;
102 } else { 102 } else {
103 fprintf(stderr, "Usage: %s\n", find_usage); 103 usage (find_usage);
104 exit( FALSE);
105 } 104 }
106 } 105 }
107 break; 106 break;
@@ -109,8 +108,7 @@ int find_main(int argc, char **argv)
109 /* Ignore all long options */ 108 /* Ignore all long options */
110 break; 109 break;
111 default: 110 default:
112 fprintf(stderr, "Usage: %s\n", find_usage); 111 usage (find_usage);
113 exit( FALSE);
114 } 112 }
115 if (argc-- > 1) 113 if (argc-- > 1)
116 argv++; 114 argv++;
diff --git a/findutils/find.c b/findutils/find.c
index 1fb219496..51b8707da 100644
--- a/findutils/find.c
+++ b/findutils/find.c
@@ -100,8 +100,7 @@ int find_main(int argc, char **argv)
100 pattern=*(++argv); 100 pattern=*(++argv);
101 stopit=-TRUE; 101 stopit=-TRUE;
102 } else { 102 } else {
103 fprintf(stderr, "Usage: %s\n", find_usage); 103 usage (find_usage);
104 exit( FALSE);
105 } 104 }
106 } 105 }
107 break; 106 break;
@@ -109,8 +108,7 @@ int find_main(int argc, char **argv)
109 /* Ignore all long options */ 108 /* Ignore all long options */
110 break; 109 break;
111 default: 110 default:
112 fprintf(stderr, "Usage: %s\n", find_usage); 111 usage (find_usage);
113 exit( FALSE);
114 } 112 }
115 if (argc-- > 1) 113 if (argc-- > 1)
116 argv++; 114 argv++;
diff --git a/internal.h b/internal.h
index b676e5f86..a77ac38bb 100644
--- a/internal.h
+++ b/internal.h
@@ -130,6 +130,8 @@ const char* timeString(time_t timeVal);
130 130
131extern void createPath (const char *name, int mode); 131extern void createPath (const char *name, int mode);
132extern int parse_mode( const char* s, mode_t* theMode); 132extern int parse_mode( const char* s, mode_t* theMode);
133extern volatile void usage(const char *usage);
134
133 135
134#endif 136#endif
135 137
diff --git a/kill.c b/kill.c
index 58dc8a986..00f10f91f 100644
--- a/kill.c
+++ b/kill.c
@@ -130,8 +130,7 @@ extern int kill_main (int argc, char **argv)
130 } 130 }
131 if (had_error) { 131 if (had_error) {
132end: 132end:
133 fprintf(stderr, "Usage: %s\n", kill_usage); 133 usage (kill_usage);
134 exit ( FALSE);
135 } 134 }
136 exit (TRUE); 135 exit (TRUE);
137} 136}
diff --git a/length.c b/length.c
index f2dadd25c..46242b529 100644
--- a/length.c
+++ b/length.c
@@ -7,8 +7,7 @@ extern int
7length_main(int argc, char * * argv) 7length_main(int argc, char * * argv)
8{ 8{
9 if ( **(argv+1) == '-' ) { 9 if ( **(argv+1) == '-' ) {
10 fprintf(stderr, "Usage: length string\n"); 10 usage("length string\n");
11 exit(FALSE);
12 } 11 }
13 printf("%d\n", strlen(argv[1])); 12 printf("%d\n", strlen(argv[1]));
14 return( TRUE); 13 return( TRUE);
diff --git a/ln.c b/ln.c
index cd3cb4e45..8f7719fa4 100644
--- a/ln.c
+++ b/ln.c
@@ -44,8 +44,7 @@ extern int ln_main(int argc, char **argv)
44 char newdestName[NAME_MAX]; 44 char newdestName[NAME_MAX];
45 45
46 if (argc < 3) { 46 if (argc < 3) {
47 fprintf(stderr, "Usage: %s", ln_usage); 47 usage (ln_usage);
48 exit (FALSE);
49 } 48 }
50 argc--; 49 argc--;
51 argv++; 50 argv++;
@@ -61,8 +60,7 @@ extern int ln_main(int argc, char **argv)
61 removeoldFlag = TRUE; 60 removeoldFlag = TRUE;
62 break; 61 break;
63 default: 62 default:
64 fprintf(stderr, "Usage: %s\n", ln_usage); 63 usage (ln_usage);
65 exit(FALSE);
66 } 64 }
67 argc--; 65 argc--;
68 argv++; 66 argv++;
diff --git a/loadkmap.c b/loadkmap.c
index 0f092d193..eb5a5dd4a 100644
--- a/loadkmap.c
+++ b/loadkmap.c
@@ -14,7 +14,7 @@ const char loadkmap_usage[] = "loadkmap\n"
14 14
15 15
16int 16int
17loadkmap_main(struct FileInfo * info, int argc, char * * argv) 17loadkmap_main(int argc, char * * argv)
18{ 18{
19 struct kbentry ke; 19 struct kbentry ke;
20 u_short *ibuff; 20 u_short *ibuff;
diff --git a/ls.c b/ls.c
index 2e3d50e9f..0adc35de1 100644
--- a/ls.c
+++ b/ls.c
@@ -19,6 +19,8 @@
19 * 19 *
20 */ 20 */
21 21
22// I started writing a newer small one, but it isn't done yet....
23// -Erik
22#if fooBar 24#if fooBar
23 25
24#include <stdio.h> 26#include <stdio.h>
@@ -110,8 +112,7 @@ int ls_main(int argc, char **argv)
110 recursiveFlag = TRUE; 112 recursiveFlag = TRUE;
111 break; 113 break;
112 default: 114 default:
113 fprintf(stderr, "Usage: %s\n", ls_usage); 115 usage (ls_usage);
114 exit( FALSE);
115 } 116 }
116 argc--; 117 argc--;
117 argv++; 118 argv++;
@@ -571,7 +572,7 @@ listerr:
571 return 1; 572 return 1;
572} 573}
573 574
574const char ls_usage[] = "Usage: ls [-1a" 575const char ls_usage[] = "ls [-1a"
575#ifdef FEATURE_TIMESTAMPS 576#ifdef FEATURE_TIMESTAMPS
576 "c" 577 "c"
577#endif 578#endif
@@ -668,7 +669,7 @@ ls_main(int argc, char * * argv)
668 exit( i); 669 exit( i);
669 670
670print_usage_message: 671print_usage_message:
671 fprintf(stderr, "Usage: %s\n", ls_usage); 672 usage (ls_usage);
672 exit( FALSE); 673 exit( FALSE);
673} 674}
674 675
diff --git a/makedevs.c b/makedevs.c
index 691236e29..00f0066ff 100644
--- a/makedevs.c
+++ b/makedevs.c
@@ -21,7 +21,7 @@ const char makedevs_usage[] =
21"\tmakedevs /dev/hda b 3 0 0 8 s (hda,hda1-hda8)\n"; 21"\tmakedevs /dev/hda b 3 0 0 8 s (hda,hda1-hda8)\n";
22 22
23int 23int
24makedevs_main(struct FileInfo * i, int argc, char * * argv) 24makedevs_main(int argc, char * * argv)
25{ 25{
26 26
27const char *basedev = argv[1]; 27const char *basedev = argv[1];
@@ -45,7 +45,7 @@ char buf[255];
45 case 'f': 45 case 'f':
46 mode = S_IFIFO; break; 46 mode = S_IFIFO; break;
47 default: 47 default:
48 usage(makedevs_usage); 48 fprintf(stderr, "Usage: %s\n", makedevs_usage);
49 return 2; 49 return 2;
50 } 50 }
51 mode |= 0660; 51 mode |= 0660;
diff --git a/miscutils/dutmp.c b/miscutils/dutmp.c
index 2dad7d4a5..7dd5b91fa 100644
--- a/miscutils/dutmp.c
+++ b/miscutils/dutmp.c
@@ -26,8 +26,7 @@ extern int dutmp_fn (int argc, char **argv)
26 struct utmp ut; 26 struct utmp ut;
27 27
28 if ((argc < 2) || (**(argv + 1) == '-')) { 28 if ((argc < 2) || (**(argv + 1) == '-')) {
29 fprintf (stderr, "Usage: %s %s\n", *argv, dutmp_usage); 29 usage( dutmp_usage);
30 exit (FALSE);
31 } 30 }
32 31
33 if ( **(++argv) == 0 ) { 32 if ( **(++argv) == 0 ) {
diff --git a/miscutils/makedevs.c b/miscutils/makedevs.c
index 691236e29..00f0066ff 100644
--- a/miscutils/makedevs.c
+++ b/miscutils/makedevs.c
@@ -21,7 +21,7 @@ const char makedevs_usage[] =
21"\tmakedevs /dev/hda b 3 0 0 8 s (hda,hda1-hda8)\n"; 21"\tmakedevs /dev/hda b 3 0 0 8 s (hda,hda1-hda8)\n";
22 22
23int 23int
24makedevs_main(struct FileInfo * i, int argc, char * * argv) 24makedevs_main(int argc, char * * argv)
25{ 25{
26 26
27const char *basedev = argv[1]; 27const char *basedev = argv[1];
@@ -45,7 +45,7 @@ char buf[255];
45 case 'f': 45 case 'f':
46 mode = S_IFIFO; break; 46 mode = S_IFIFO; break;
47 default: 47 default:
48 usage(makedevs_usage); 48 fprintf(stderr, "Usage: %s\n", makedevs_usage);
49 return 2; 49 return 2;
50 } 50 }
51 mode |= 0660; 51 mode |= 0660;
diff --git a/miscutils/mt.c b/miscutils/mt.c
index 7d75fbd3d..a61ad5a40 100644
--- a/miscutils/mt.c
+++ b/miscutils/mt.c
@@ -50,7 +50,7 @@ static const struct mt_opcodes opcodes[] = {
50}; 50};
51 51
52extern int 52extern int
53mt_main(struct FileInfo * i, int argc, char * * argv) 53mt_main(int argc, char** argv)
54{ 54{
55 const char * file = "/dev/tape"; 55 const char * file = "/dev/tape";
56 const struct mt_opcodes * code = opcodes; 56 const struct mt_opcodes * code = opcodes;
@@ -59,8 +59,7 @@ mt_main(struct FileInfo * i, int argc, char * * argv)
59 59
60 if ( strcmp(argv[1], "-f") == 0 ) { 60 if ( strcmp(argv[1], "-f") == 0 ) {
61 if ( argc < 4 ) { 61 if ( argc < 4 ) {
62 usage(mt_usage); 62 usage (mt_usage);
63 return 1;
64 } 63 }
65 file = argv[2]; 64 file = argv[2];
66 argv += 2; 65 argv += 2;
@@ -75,7 +74,7 @@ mt_main(struct FileInfo * i, int argc, char * * argv)
75 74
76 if ( code->name == 0 ) { 75 if ( code->name == 0 ) {
77 fprintf(stderr, "mt: unrecognized opcode %s.\n", argv[1]); 76 fprintf(stderr, "mt: unrecognized opcode %s.\n", argv[1]);
78 return 1; 77 return( FALSE);
79 } 78 }
80 79
81 op.mt_op = code->value; 80 op.mt_op = code->value;
@@ -85,14 +84,14 @@ mt_main(struct FileInfo * i, int argc, char * * argv)
85 op.mt_count = 1; /* One, not zero, right? */ 84 op.mt_count = 1; /* One, not zero, right? */
86 85
87 if ( (fd = open(file, O_RDONLY, 0)) < 0 ) { 86 if ( (fd = open(file, O_RDONLY, 0)) < 0 ) {
88 name_and_error(file); 87 perror(file);
89 return 1; 88 return( FALSE);
90 } 89 }
91 90
92 if ( ioctl(fd, MTIOCTOP, &op) != 0 ) { 91 if ( ioctl(fd, MTIOCTOP, &op) != 0 ) {
93 name_and_error(file); 92 perror(file);
94 return 1; 93 return( FALSE);
95 } 94 }
96 95
97 return 0; 96 return( TRUE);
98} 97}
diff --git a/mkdir.c b/mkdir.c
index 61d35d5cd..b42899a4a 100644
--- a/mkdir.c
+++ b/mkdir.c
@@ -51,8 +51,7 @@ extern int mkdir_main(int argc, char **argv)
51 parentFlag = TRUE; 51 parentFlag = TRUE;
52 break; 52 break;
53 default: 53 default:
54 fprintf(stderr, "%s\n", mkdir_usage); 54 usage( mkdir_usage);
55 exit(FALSE);
56 } 55 }
57 argc--; 56 argc--;
58 argv++; 57 argv++;
@@ -60,8 +59,7 @@ extern int mkdir_main(int argc, char **argv)
60 59
61 60
62 if (argc < 1) { 61 if (argc < 1) {
63 fprintf(stderr, "%s\n", mkdir_usage); 62 usage( mkdir_usage);
64 exit (FALSE);
65 } 63 }
66 64
67 while (--argc > 0) { 65 while (--argc > 0) {
diff --git a/mknod.c b/mknod.c
index b18394bec..95d7de360 100644
--- a/mknod.c
+++ b/mknod.c
@@ -1,4 +1,5 @@
1#include "internal.h" 1#include "internal.h"
2#include <stdio.h>
2#include <errno.h> 3#include <errno.h>
3#include <sys/types.h> 4#include <sys/types.h>
4#include <sys/stat.h> 5#include <sys/stat.h>
@@ -13,7 +14,7 @@ const char mknod_usage[] = "mknod file b|c|u|p major minor\n"
13"\tp:\tMake a named pipe. Major and minor are ignored for named pipes.\n"; 14"\tp:\tMake a named pipe. Major and minor are ignored for named pipes.\n";
14 15
15int 16int
16mknod_main(struct FileInfo * i, int argc, char * * argv) 17mknod_main(int argc, char** argv)
17{ 18{
18 mode_t mode = 0; 19 mode_t mode = 0;
19 dev_t dev = 0; 20 dev_t dev = 0;
@@ -30,23 +31,21 @@ mknod_main(struct FileInfo * i, int argc, char * * argv)
30 mode = S_IFIFO; 31 mode = S_IFIFO;
31 break; 32 break;
32 default: 33 default:
33 usage(mknod_usage); 34 usage (mknod_usage);
34 return 1;
35 } 35 }
36 36
37 if ( mode == S_IFCHR || mode == S_IFBLK ) { 37 if ( mode == S_IFCHR || mode == S_IFBLK ) {
38 dev = (atoi(argv[3]) << 8) | atoi(argv[4]); 38 dev = (atoi(argv[3]) << 8) | atoi(argv[4]);
39 if ( argc != 5 ) { 39 if ( argc != 5 ) {
40 usage(mknod_usage); 40 usage (mknod_usage);
41 return 1;
42 } 41 }
43 } 42 }
44 43
45 mode |= 0666; 44 mode |= 0666;
46 45
47 if ( mknod(argv[1], mode, dev) != 0 ) { 46 if ( mknod(argv[1], mode, dev) != 0 ) {
48 name_and_error(argv[1]); 47 perror(argv[1]);
49 return 1; 48 return( FALSE);
50 } 49 }
51 return 0; 50 return( TRUE);
52} 51}
diff --git a/mkswap.c b/mkswap.c
index f797d1395..8c0c4dec7 100644
--- a/mkswap.c
+++ b/mkswap.c
@@ -83,7 +83,7 @@ static int bit_test_and_clear (unsigned int *addr, unsigned int nr)
83volatile void fatal_error(const char * fmt_string) 83volatile void fatal_error(const char * fmt_string)
84{ 84{
85 fprintf(stderr,fmt_string,program_name,device_name); 85 fprintf(stderr,fmt_string,program_name,device_name);
86 exit(1); 86 exit(FALSE);
87} 87}
88 88
89#define die(str) fatal_error("%s: " str "\n") 89#define die(str) fatal_error("%s: " str "\n")
@@ -170,7 +170,7 @@ static int get_size(const char *file)
170} 170}
171 171
172int 172int
173mkswap(char *device_name, int pages, int check) 173mkswap(const char *device_name, int pages, int check)
174 { 174 {
175 struct stat statbuf; 175 struct stat statbuf;
176 int goodpages; 176 int goodpages;
@@ -219,10 +219,10 @@ mkswap(char *device_name, int pages, int check)
219 die("unable to write signature page"); 219 die("unable to write signature page");
220 220
221 close(DEV); 221 close(DEV);
222 return 0; 222 return (TRUE);
223} 223}
224 224
225int mkswap_main(struct FileInfo * unnecessary, int argc, char ** argv) 225int mkswap_main(int argc, char ** argv)
226{ 226{
227 char * tmp; 227 char * tmp;
228 long int pages=0; 228 long int pages=0;
@@ -237,17 +237,16 @@ int mkswap_main(struct FileInfo * unnecessary, int argc, char ** argv)
237 if (device_name) { 237 if (device_name) {
238 pages = strtol(argv[0],&tmp,0)>>(PAGE_SHIFT-10); 238 pages = strtol(argv[0],&tmp,0)>>(PAGE_SHIFT-10);
239 if (*tmp) { 239 if (*tmp) {
240 usage(mkswap_usage); 240 usage (mkswap_usage);
241 exit(1);
242 } 241 }
243 } else 242 } else
244 device_name = argv[0]; 243 device_name = argv[0];
245 else while (*++argv[0]) 244 else while (*++argv[0])
246 switch (argv[0][0]) { 245 switch (argv[0][0]) {
247 case 'c': check=1; break; 246 case 'c': check=1; break;
248 default: usage(mkswap_usage); 247 default: usage (mkswap_usage);
249 exit(1); 248 exit( TRUE);
250 } 249 }
251 } 250 }
252 return mkswap(device_name, pages, check); 251 exit( mkswap(device_name, pages, check));
253} 252}
diff --git a/more.c b/more.c
index a56ce97d7..53437ed58 100644
--- a/more.c
+++ b/more.c
@@ -59,8 +59,7 @@ extern int more_main(int argc, char **argv)
59 FILE *file = stdin; 59 FILE *file = stdin;
60 60
61 if ( strcmp(*argv,"--help")==0 || strcmp(*argv,"-h")==0 ) { 61 if ( strcmp(*argv,"--help")==0 || strcmp(*argv,"-h")==0 ) {
62 fprintf(stderr, "Usage: %s %s", *argv, more_usage); 62 usage (more_usage);
63 exit(FALSE);
64 } 63 }
65 argc--; 64 argc--;
66 argv++; 65 argv++;
diff --git a/mt.c b/mt.c
index 7d75fbd3d..a61ad5a40 100644
--- a/mt.c
+++ b/mt.c
@@ -50,7 +50,7 @@ static const struct mt_opcodes opcodes[] = {
50}; 50};
51 51
52extern int 52extern int
53mt_main(struct FileInfo * i, int argc, char * * argv) 53mt_main(int argc, char** argv)
54{ 54{
55 const char * file = "/dev/tape"; 55 const char * file = "/dev/tape";
56 const struct mt_opcodes * code = opcodes; 56 const struct mt_opcodes * code = opcodes;
@@ -59,8 +59,7 @@ mt_main(struct FileInfo * i, int argc, char * * argv)
59 59
60 if ( strcmp(argv[1], "-f") == 0 ) { 60 if ( strcmp(argv[1], "-f") == 0 ) {
61 if ( argc < 4 ) { 61 if ( argc < 4 ) {
62 usage(mt_usage); 62 usage (mt_usage);
63 return 1;
64 } 63 }
65 file = argv[2]; 64 file = argv[2];
66 argv += 2; 65 argv += 2;
@@ -75,7 +74,7 @@ mt_main(struct FileInfo * i, int argc, char * * argv)
75 74
76 if ( code->name == 0 ) { 75 if ( code->name == 0 ) {
77 fprintf(stderr, "mt: unrecognized opcode %s.\n", argv[1]); 76 fprintf(stderr, "mt: unrecognized opcode %s.\n", argv[1]);
78 return 1; 77 return( FALSE);
79 } 78 }
80 79
81 op.mt_op = code->value; 80 op.mt_op = code->value;
@@ -85,14 +84,14 @@ mt_main(struct FileInfo * i, int argc, char * * argv)
85 op.mt_count = 1; /* One, not zero, right? */ 84 op.mt_count = 1; /* One, not zero, right? */
86 85
87 if ( (fd = open(file, O_RDONLY, 0)) < 0 ) { 86 if ( (fd = open(file, O_RDONLY, 0)) < 0 ) {
88 name_and_error(file); 87 perror(file);
89 return 1; 88 return( FALSE);
90 } 89 }
91 90
92 if ( ioctl(fd, MTIOCTOP, &op) != 0 ) { 91 if ( ioctl(fd, MTIOCTOP, &op) != 0 ) {
93 name_and_error(file); 92 perror(file);
94 return 1; 93 return( FALSE);
95 } 94 }
96 95
97 return 0; 96 return( TRUE);
98} 97}
diff --git a/mv.c b/mv.c
index 2a7c8c1f3..ab3fc2bd5 100644
--- a/mv.c
+++ b/mv.c
@@ -42,8 +42,7 @@ extern int mv_main(int argc, char **argv)
42 char newdestName[NAME_MAX]; 42 char newdestName[NAME_MAX];
43 43
44 if (argc < 3) { 44 if (argc < 3) {
45 fprintf(stderr, "Usage: %s", mv_usage); 45 usage (mv_usage);
46 exit (FALSE);
47 } 46 }
48 argc--; 47 argc--;
49 argv++; 48 argv++;
diff --git a/printf.c b/printf.c
index e79843c80..4d4465943 100644
--- a/printf.c
+++ b/printf.c
@@ -1,8 +1,3 @@
1// I may still need some more cleaning...fix my error checking
2
3#include "internal.h"
4#ifdef BB_PRINTF
5
6/* printf - format and print data 1/* printf - format and print data
7 Copyright (C) 90, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc. 2 Copyright (C) 90, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
8 3
@@ -51,6 +46,7 @@
51 46
52// 19990508 Busy Boxed! Dave Cinege 47// 19990508 Busy Boxed! Dave Cinege
53 48
49#include "internal.h"
54#include <unistd.h> 50#include <unistd.h>
55#include <stdio.h> 51#include <stdio.h>
56#include <sys/types.h> 52#include <sys/types.h>
@@ -140,15 +136,18 @@ static void verify __P ((char *s, char *end));
140/* The value to return to the calling program. */ 136/* The value to return to the calling program. */
141static int exit_status; 137static int exit_status;
142 138
143const char printf_usage[] = "Usage: printf format [argument...]\n"; 139const char printf_usage[] = "printf format [argument...]\n";
144 140
145int 141int
146printf_main(struct FileInfo * i, int argc, char * * argv) 142printf_main(int argc, char** argv)
147{ 143{
148 char *format; 144 char *format;
149 int args_used; 145 int args_used;
150 146
151 exit_status = 0; 147 exit_status = 0;
148 if ( **(argv+1) == '-' ) {
149 usage (printf_usage);
150 }
152 151
153 format = argv[1]; 152 format = argv[1];
154 argc -= 2; 153 argc -= 2;
@@ -528,4 +527,3 @@ verify (char *s, char *end)
528 } 527 }
529} 528}
530 529
531#endif
diff --git a/procps/kill.c b/procps/kill.c
index 58dc8a986..00f10f91f 100644
--- a/procps/kill.c
+++ b/procps/kill.c
@@ -130,8 +130,7 @@ extern int kill_main (int argc, char **argv)
130 } 130 }
131 if (had_error) { 131 if (had_error) {
132end: 132end:
133 fprintf(stderr, "Usage: %s\n", kill_usage); 133 usage (kill_usage);
134 exit ( FALSE);
135 } 134 }
136 exit (TRUE); 135 exit (TRUE);
137} 136}
diff --git a/rm.c b/rm.c
index 477d3af59..dd8dfa4e6 100644
--- a/rm.c
+++ b/rm.c
@@ -25,7 +25,7 @@
25#include <utime.h> 25#include <utime.h>
26#include <dirent.h> 26#include <dirent.h>
27 27
28static const char* rm_usage = "Usage: rm [OPTION]... FILE...\n" 28static const char* rm_usage = "rm [OPTION]... FILE...\n"
29"Remove (unlink) the FILE(s).\n\n" 29"Remove (unlink) the FILE(s).\n\n"
30"\t-f\tremove existing destinations, never prompt\n" 30"\t-f\tremove existing destinations, never prompt\n"
31"\t-r\tremove the contents of directories recursively\n"; 31"\t-r\tremove the contents of directories recursively\n";
@@ -58,8 +58,7 @@ extern int rm_main(int argc, char **argv)
58{ 58{
59 59
60 if (argc < 2) { 60 if (argc < 2) {
61 fprintf(stderr, "Usage: %s", rm_usage); 61 usage( rm_usage);
62 exit (FALSE);
63 } 62 }
64 argc--; 63 argc--;
65 argv++; 64 argv++;
@@ -75,8 +74,7 @@ extern int rm_main(int argc, char **argv)
75 forceFlag = TRUE; 74 forceFlag = TRUE;
76 break; 75 break;
77 default: 76 default:
78 fprintf(stderr, "Usage: %s\n", rm_usage); 77 usage( rm_usage);
79 exit(FALSE);
80 } 78 }
81 argc--; 79 argc--;
82 argv++; 80 argv++;
diff --git a/rmdir.c b/rmdir.c
index b4da03f12..666e0476a 100644
--- a/rmdir.c
+++ b/rmdir.c
@@ -27,8 +27,7 @@
27extern int rmdir_main(int argc, char **argv) 27extern int rmdir_main(int argc, char **argv)
28{ 28{
29 if ( argc==1 || **(argv+1) == '-' ) { 29 if ( argc==1 || **(argv+1) == '-' ) {
30 fprintf(stderr, "Usage: rmdir [OPTION]... DIRECTORY...\nRemove the DIRECTORY(ies), if they are empty."); 30 usage( "rmdir [OPTION]... DIRECTORY...\nRemove the DIRECTORY(ies), if they are empty.");
31 exit(FALSE);
32 } 31 }
33 32
34 while (--argc > 0) { 33 while (--argc > 0) {
diff --git a/sleep.c b/sleep.c
index 53fe5a0c2..7e38a3667 100644
--- a/sleep.c
+++ b/sleep.c
@@ -8,8 +8,7 @@ extern int
8sleep_main(int argc, char * * argv) 8sleep_main(int argc, char * * argv)
9{ 9{
10 if ( (argc < 2) || (**(argv+1) == '-') ) { 10 if ( (argc < 2) || (**(argv+1) == '-') ) {
11 fprintf(stderr, "Usage: %s %s", *argv, sleep_usage); 11 usage( sleep_usage );
12 exit(FALSE);
13 } 12 }
14 13
15 if ( sleep(atoi(*(++argv))) != 0 ) { 14 if ( sleep(atoi(*(++argv))) != 0 ) {
diff --git a/swaponoff.c b/swaponoff.c
index 56f93b393..5a2d735ad 100644
--- a/swaponoff.c
+++ b/swaponoff.c
@@ -33,10 +33,10 @@ static int whichApp;
33static const char* appName; 33static const char* appName;
34 34
35static const char swapoff_usage[] = 35static const char swapoff_usage[] =
36"Usage: swapoff device\n" 36"swapoff device\n"
37"\nStop swapping virtual memory pages on the given device.\n"; 37"\nStop swapping virtual memory pages on the given device.\n";
38static const char swapon_usage[] = 38static const char swapon_usage[] =
39"Usage: swapon device\n" 39"swapon device\n"
40"\nStart swapping virtual memory pages on the given device.\n"; 40"\nStart swapping virtual memory pages on the given device.\n";
41 41
42 42
@@ -112,10 +112,10 @@ swap_on_off_main(int argc, char * * argv)
112 } 112 }
113 } 113 }
114 swap_enable_disable(*argv); 114 swap_enable_disable(*argv);
115 //exit( TRUE); 115 exit( TRUE);
116 116
117usage_and_exit: 117usage_and_exit:
118 fprintf(stderr, "Usage: %s", (whichApp==SWAPON_APP)? swapon_usage : swapoff_usage); 118 usage( (whichApp==SWAPON_APP)? swapon_usage : swapoff_usage);
119 exit(FALSE); 119 exit( FALSE);
120} 120}
121 121
diff --git a/sync.c b/sync.c
index 572d74924..8800f2e76 100644
--- a/sync.c
+++ b/sync.c
@@ -5,9 +5,8 @@ extern int
5sync_main(int argc, char * * argv) 5sync_main(int argc, char * * argv)
6{ 6{
7 if ( **(argv+1) == '-' ) { 7 if ( **(argv+1) == '-' ) {
8 fprintf(stderr, "Usage: sync\nWrite all buffered filesystem blocks to disk.\n"); 8 usage( "sync\nWrite all buffered filesystem blocks to disk.\n");
9 exit(FALSE);
10 } 9 }
11 return sync(); 10 return sync();
12} 11}
13 12
diff --git a/touch.c b/touch.c
index 8dac10294..c36ffca90 100644
--- a/touch.c
+++ b/touch.c
@@ -40,8 +40,7 @@ touch_main(int argc, char **argv)
40 int create=TRUE; 40 int create=TRUE;
41 41
42 if (argc < 2) { 42 if (argc < 2) {
43 fprintf(stderr, "Usage: %s %s", *argv, touch_usage); 43 usage( touch_usage);
44 exit( FALSE);
45 } 44 }
46 argc--; 45 argc--;
47 argv++; 46 argv++;
diff --git a/umount.c b/umount.c
index a83a508f7..625fcfab9 100644
--- a/umount.c
+++ b/umount.c
@@ -71,8 +71,7 @@ umount_main(int argc, char * * argv)
71{ 71{
72 72
73 if (argc < 2) { 73 if (argc < 2) {
74 fprintf(stderr, "Usage: %s", umount_usage); 74 usage( umount_usage);
75 exit(FALSE);
76 } 75 }
77 argc--; 76 argc--;
78 argv++; 77 argv++;
@@ -84,8 +83,7 @@ umount_main(int argc, char * * argv)
84 exit ( umount_all() ); 83 exit ( umount_all() );
85 break; 84 break;
86 default: 85 default:
87 fprintf(stderr, "Usage: %s\n", umount_usage); 86 usage( umount_usage);
88 exit( FALSE);
89 } 87 }
90 } 88 }
91 if ( umount(*argv) == 0 ) 89 if ( umount(*argv) == 0 )
diff --git a/util-linux/dmesg.c b/util-linux/dmesg.c
index 64265b473..e5d403f7a 100644
--- a/util-linux/dmesg.c
+++ b/util-linux/dmesg.c
@@ -93,6 +93,6 @@ int dmesg_main (int argc, char **argv)
93 exit (TRUE); 93 exit (TRUE);
94 94
95 end: 95 end:
96 fprintf (stderr, "Usage: %s\n", dmesg_usage); 96 usage( dmesg_usage);
97 exit (FALSE); 97 exit (FALSE);
98} 98}
diff --git a/util-linux/fdflush.c b/util-linux/fdflush.c
index ce6870cd1..58b8b37d6 100644
--- a/util-linux/fdflush.c
+++ b/util-linux/fdflush.c
@@ -32,8 +32,7 @@ extern int fdflush_main(int argc, char **argv)
32 int value; 32 int value;
33 int fd; 33 int fd;
34 if ( **(argv+1) == '-' ) { 34 if ( **(argv+1) == '-' ) {
35 fprintf(stderr, "Usage: fdflush device\n"); 35 usage( "fdflush device\n");
36 exit(FALSE);
37 } 36 }
38 37
39 fd = open(*argv, 0); 38 fd = open(*argv, 0);
diff --git a/util-linux/mkswap.c b/util-linux/mkswap.c
index f797d1395..8c0c4dec7 100644
--- a/util-linux/mkswap.c
+++ b/util-linux/mkswap.c
@@ -83,7 +83,7 @@ static int bit_test_and_clear (unsigned int *addr, unsigned int nr)
83volatile void fatal_error(const char * fmt_string) 83volatile void fatal_error(const char * fmt_string)
84{ 84{
85 fprintf(stderr,fmt_string,program_name,device_name); 85 fprintf(stderr,fmt_string,program_name,device_name);
86 exit(1); 86 exit(FALSE);
87} 87}
88 88
89#define die(str) fatal_error("%s: " str "\n") 89#define die(str) fatal_error("%s: " str "\n")
@@ -170,7 +170,7 @@ static int get_size(const char *file)
170} 170}
171 171
172int 172int
173mkswap(char *device_name, int pages, int check) 173mkswap(const char *device_name, int pages, int check)
174 { 174 {
175 struct stat statbuf; 175 struct stat statbuf;
176 int goodpages; 176 int goodpages;
@@ -219,10 +219,10 @@ mkswap(char *device_name, int pages, int check)
219 die("unable to write signature page"); 219 die("unable to write signature page");
220 220
221 close(DEV); 221 close(DEV);
222 return 0; 222 return (TRUE);
223} 223}
224 224
225int mkswap_main(struct FileInfo * unnecessary, int argc, char ** argv) 225int mkswap_main(int argc, char ** argv)
226{ 226{
227 char * tmp; 227 char * tmp;
228 long int pages=0; 228 long int pages=0;
@@ -237,17 +237,16 @@ int mkswap_main(struct FileInfo * unnecessary, int argc, char ** argv)
237 if (device_name) { 237 if (device_name) {
238 pages = strtol(argv[0],&tmp,0)>>(PAGE_SHIFT-10); 238 pages = strtol(argv[0],&tmp,0)>>(PAGE_SHIFT-10);
239 if (*tmp) { 239 if (*tmp) {
240 usage(mkswap_usage); 240 usage (mkswap_usage);
241 exit(1);
242 } 241 }
243 } else 242 } else
244 device_name = argv[0]; 243 device_name = argv[0];
245 else while (*++argv[0]) 244 else while (*++argv[0])
246 switch (argv[0][0]) { 245 switch (argv[0][0]) {
247 case 'c': check=1; break; 246 case 'c': check=1; break;
248 default: usage(mkswap_usage); 247 default: usage (mkswap_usage);
249 exit(1); 248 exit( TRUE);
250 } 249 }
251 } 250 }
252 return mkswap(device_name, pages, check); 251 exit( mkswap(device_name, pages, check));
253} 252}
diff --git a/util-linux/more.c b/util-linux/more.c
index a56ce97d7..53437ed58 100644
--- a/util-linux/more.c
+++ b/util-linux/more.c
@@ -59,8 +59,7 @@ extern int more_main(int argc, char **argv)
59 FILE *file = stdin; 59 FILE *file = stdin;
60 60
61 if ( strcmp(*argv,"--help")==0 || strcmp(*argv,"-h")==0 ) { 61 if ( strcmp(*argv,"--help")==0 || strcmp(*argv,"-h")==0 ) {
62 fprintf(stderr, "Usage: %s %s", *argv, more_usage); 62 usage (more_usage);
63 exit(FALSE);
64 } 63 }
65 argc--; 64 argc--;
66 argv++; 65 argv++;
diff --git a/util-linux/swaponoff.c b/util-linux/swaponoff.c
index 56f93b393..5a2d735ad 100644
--- a/util-linux/swaponoff.c
+++ b/util-linux/swaponoff.c
@@ -33,10 +33,10 @@ static int whichApp;
33static const char* appName; 33static const char* appName;
34 34
35static const char swapoff_usage[] = 35static const char swapoff_usage[] =
36"Usage: swapoff device\n" 36"swapoff device\n"
37"\nStop swapping virtual memory pages on the given device.\n"; 37"\nStop swapping virtual memory pages on the given device.\n";
38static const char swapon_usage[] = 38static const char swapon_usage[] =
39"Usage: swapon device\n" 39"swapon device\n"
40"\nStart swapping virtual memory pages on the given device.\n"; 40"\nStart swapping virtual memory pages on the given device.\n";
41 41
42 42
@@ -112,10 +112,10 @@ swap_on_off_main(int argc, char * * argv)
112 } 112 }
113 } 113 }
114 swap_enable_disable(*argv); 114 swap_enable_disable(*argv);
115 //exit( TRUE); 115 exit( TRUE);
116 116
117usage_and_exit: 117usage_and_exit:
118 fprintf(stderr, "Usage: %s", (whichApp==SWAPON_APP)? swapon_usage : swapoff_usage); 118 usage( (whichApp==SWAPON_APP)? swapon_usage : swapoff_usage);
119 exit(FALSE); 119 exit( FALSE);
120} 120}
121 121
diff --git a/util-linux/umount.c b/util-linux/umount.c
index a83a508f7..625fcfab9 100644
--- a/util-linux/umount.c
+++ b/util-linux/umount.c
@@ -71,8 +71,7 @@ umount_main(int argc, char * * argv)
71{ 71{
72 72
73 if (argc < 2) { 73 if (argc < 2) {
74 fprintf(stderr, "Usage: %s", umount_usage); 74 usage( umount_usage);
75 exit(FALSE);
76 } 75 }
77 argc--; 76 argc--;
78 argv++; 77 argv++;
@@ -84,8 +83,7 @@ umount_main(int argc, char * * argv)
84 exit ( umount_all() ); 83 exit ( umount_all() );
85 break; 84 break;
86 default: 85 default:
87 fprintf(stderr, "Usage: %s\n", umount_usage); 86 usage( umount_usage);
88 exit( FALSE);
89 } 87 }
90 } 88 }
91 if ( umount(*argv) == 0 ) 89 if ( umount(*argv) == 0 )
diff --git a/utility.c b/utility.c
index c6121cb11..f86216eb1 100644
--- a/utility.c
+++ b/utility.c
@@ -34,6 +34,14 @@
34#include <unistd.h> 34#include <unistd.h>
35 35
36 36
37/* volatile so gcc knows this is the enod of the line */
38volatile void usage(const char *usage)
39{
40 fprintf(stderr, "Usage: %s\n", usage);
41 exit(FALSE);
42}
43
44
37 45
38#if defined (BB_CP) || defined (BB_MV) 46#if defined (BB_CP) || defined (BB_MV)
39/* 47/*