More stuff.

-Erik
This commit is contained in:
Eric Andersen
1999-10-18 22:28:26 +00:00
parent 703c62da63
commit b0e9a709ba
61 changed files with 168 additions and 233 deletions

View File

@ -42,8 +42,7 @@ extern int cat_more_main(int argc, char **argv)
}
if ( **(argv+1) == '-' ) {
fprintf(stderr, "Usage: cat [file ...]\n");
exit(FALSE);
usage ("cat [file ...]\n");
}
argc--;
argv++;

View File

@ -33,8 +33,7 @@ static const char chroot_usage[] = "NEWROOT [COMMAND...]\n"
int chroot_main(int argc, char **argv)
{
if ( (argc < 2) || (**(argv+1) == '-') ) {
fprintf(stderr, "Usage: %s %s", *argv, chroot_usage);
exit( FALSE);
usage( chroot_usage);
}
argc--;
argv++;

View File

@ -60,8 +60,7 @@ extern int cp_main(int argc, char **argv)
{
if (argc < 3) {
fprintf(stderr, "Usage: %s", cp_usage);
exit (FALSE);
usage (cp_usage);
}
argc--;
argv++;
@ -85,8 +84,7 @@ extern int cp_main(int argc, char **argv)
recursiveFlag = TRUE;
break;
default:
fprintf(stderr, "Usage: %s\n", cp_usage);
exit(FALSE);
usage (cp_usage);
}
argc--;
argv++;

View File

@ -34,7 +34,7 @@
an RFC 822 complient date output for shell scripting
mail commands */
const char date_usage[] = "Usage: date [OPTION]... [+FORMAT]\n"
const char date_usage[] = "date [OPTION]... [+FORMAT]\n"
" or: date [OPTION] [MMDDhhmm[[CC]YY][.ss]]\n"
"Display the current time in the given FORMAT, or set the system date.\n"
"\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) {
}
void
date_err(void) {
fprintf (stderr, "%s\n", date_usage);
exit( FALSE);
}
int
date_main(int argc, char * * argv)
{
@ -190,7 +184,7 @@ date_main(int argc, char * * argv)
break;
case 's':
set_time = 1;
if(date_str != NULL) date_err();
if(date_str != NULL) usage ( date_usage);
date_str = optarg;
break;
case 'u':
@ -202,11 +196,11 @@ date_main(int argc, char * * argv)
/* Look ma, no break. Don't fix it either. */
case 'd':
use_arg = 1;
if(date_str != NULL) date_err();
if(date_str != NULL) usage ( date_usage);
date_str = optarg;
break;
case '-':
date_err();
usage ( date_usage);
}
} else {
if ( (date_fmt == NULL) && (strcmp(*argv, "+")==0) )
@ -215,7 +209,7 @@ date_main(int argc, char * * argv)
set_time = 1;
date_str=*argv;
} else {
date_err();
usage ( date_usage);
}
}
i--;

View File

@ -7,8 +7,7 @@ extern int
length_main(int argc, char * * argv)
{
if ( **(argv+1) == '-' ) {
fprintf(stderr, "Usage: length string\n");
exit(FALSE);
usage("length string\n");
}
printf("%d\n", strlen(argv[1]));
return( TRUE);

View File

@ -44,8 +44,7 @@ extern int ln_main(int argc, char **argv)
char newdestName[NAME_MAX];
if (argc < 3) {
fprintf(stderr, "Usage: %s", ln_usage);
exit (FALSE);
usage (ln_usage);
}
argc--;
argv++;
@ -61,8 +60,7 @@ extern int ln_main(int argc, char **argv)
removeoldFlag = TRUE;
break;
default:
fprintf(stderr, "Usage: %s\n", ln_usage);
exit(FALSE);
usage (ln_usage);
}
argc--;
argv++;

View File

@ -19,6 +19,8 @@
*
*/
// I started writing a newer small one, but it isn't done yet....
// -Erik
#if fooBar
#include <stdio.h>
@ -110,8 +112,7 @@ int ls_main(int argc, char **argv)
recursiveFlag = TRUE;
break;
default:
fprintf(stderr, "Usage: %s\n", ls_usage);
exit( FALSE);
usage (ls_usage);
}
argc--;
argv++;
@ -571,7 +572,7 @@ listerr:
return 1;
}
const char ls_usage[] = "Usage: ls [-1a"
const char ls_usage[] = "ls [-1a"
#ifdef FEATURE_TIMESTAMPS
"c"
#endif
@ -668,7 +669,7 @@ ls_main(int argc, char * * argv)
exit( i);
print_usage_message:
fprintf(stderr, "Usage: %s\n", ls_usage);
usage (ls_usage);
exit( FALSE);
}

View File

@ -51,8 +51,7 @@ extern int mkdir_main(int argc, char **argv)
parentFlag = TRUE;
break;
default:
fprintf(stderr, "%s\n", mkdir_usage);
exit(FALSE);
usage( mkdir_usage);
}
argc--;
argv++;
@ -60,8 +59,7 @@ extern int mkdir_main(int argc, char **argv)
if (argc < 1) {
fprintf(stderr, "%s\n", mkdir_usage);
exit (FALSE);
usage( mkdir_usage);
}
while (--argc > 0) {

View File

@ -1,4 +1,5 @@
#include "internal.h"
#include <stdio.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
@ -13,7 +14,7 @@ const char mknod_usage[] = "mknod file b|c|u|p major minor\n"
"\tp:\tMake a named pipe. Major and minor are ignored for named pipes.\n";
int
mknod_main(struct FileInfo * i, int argc, char * * argv)
mknod_main(int argc, char** argv)
{
mode_t mode = 0;
dev_t dev = 0;
@ -30,23 +31,21 @@ mknod_main(struct FileInfo * i, int argc, char * * argv)
mode = S_IFIFO;
break;
default:
usage(mknod_usage);
return 1;
usage (mknod_usage);
}
if ( mode == S_IFCHR || mode == S_IFBLK ) {
dev = (atoi(argv[3]) << 8) | atoi(argv[4]);
if ( argc != 5 ) {
usage(mknod_usage);
return 1;
usage (mknod_usage);
}
}
mode |= 0666;
if ( mknod(argv[1], mode, dev) != 0 ) {
name_and_error(argv[1]);
return 1;
perror(argv[1]);
return( FALSE);
}
return 0;
return( TRUE);
}

View File

@ -42,8 +42,7 @@ extern int mv_main(int argc, char **argv)
char newdestName[NAME_MAX];
if (argc < 3) {
fprintf(stderr, "Usage: %s", mv_usage);
exit (FALSE);
usage (mv_usage);
}
argc--;
argv++;

View File

@ -1,8 +1,3 @@
// I may still need some more cleaning...fix my error checking
#include "internal.h"
#ifdef BB_PRINTF
/* printf - format and print data
Copyright (C) 90, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
@ -51,6 +46,7 @@
// 19990508 Busy Boxed! Dave Cinege
#include "internal.h"
#include <unistd.h>
#include <stdio.h>
#include <sys/types.h>
@ -140,15 +136,18 @@ static void verify __P ((char *s, char *end));
/* The value to return to the calling program. */
static int exit_status;
const char printf_usage[] = "Usage: printf format [argument...]\n";
const char printf_usage[] = "printf format [argument...]\n";
int
printf_main(struct FileInfo * i, int argc, char * * argv)
printf_main(int argc, char** argv)
{
char *format;
int args_used;
exit_status = 0;
if ( **(argv+1) == '-' ) {
usage (printf_usage);
}
format = argv[1];
argc -= 2;
@ -528,4 +527,3 @@ verify (char *s, char *end)
}
}
#endif

View File

@ -25,7 +25,7 @@
#include <utime.h>
#include <dirent.h>
static const char* rm_usage = "Usage: rm [OPTION]... FILE...\n"
static const char* rm_usage = "rm [OPTION]... FILE...\n"
"Remove (unlink) the FILE(s).\n\n"
"\t-f\tremove existing destinations, never prompt\n"
"\t-r\tremove the contents of directories recursively\n";
@ -58,8 +58,7 @@ extern int rm_main(int argc, char **argv)
{
if (argc < 2) {
fprintf(stderr, "Usage: %s", rm_usage);
exit (FALSE);
usage( rm_usage);
}
argc--;
argv++;
@ -75,8 +74,7 @@ extern int rm_main(int argc, char **argv)
forceFlag = TRUE;
break;
default:
fprintf(stderr, "Usage: %s\n", rm_usage);
exit(FALSE);
usage( rm_usage);
}
argc--;
argv++;

View File

@ -27,8 +27,7 @@
extern int rmdir_main(int argc, char **argv)
{
if ( argc==1 || **(argv+1) == '-' ) {
fprintf(stderr, "Usage: rmdir [OPTION]... DIRECTORY...\nRemove the DIRECTORY(ies), if they are empty.");
exit(FALSE);
usage( "rmdir [OPTION]... DIRECTORY...\nRemove the DIRECTORY(ies), if they are empty.");
}
while (--argc > 0) {

View File

@ -8,8 +8,7 @@ extern int
sleep_main(int argc, char * * argv)
{
if ( (argc < 2) || (**(argv+1) == '-') ) {
fprintf(stderr, "Usage: %s %s", *argv, sleep_usage);
exit(FALSE);
usage( sleep_usage );
}
if ( sleep(atoi(*(++argv))) != 0 ) {

View File

@ -5,9 +5,8 @@ extern int
sync_main(int argc, char * * argv)
{
if ( **(argv+1) == '-' ) {
fprintf(stderr, "Usage: sync\nWrite all buffered filesystem blocks to disk.\n");
exit(FALSE);
usage( "sync\nWrite all buffered filesystem blocks to disk.\n");
}
return sync();
return sync();
}

View File

@ -40,8 +40,7 @@ touch_main(int argc, char **argv)
int create=TRUE;
if (argc < 2) {
fprintf(stderr, "Usage: %s %s", *argv, touch_usage);
exit( FALSE);
usage( touch_usage);
}
argc--;
argv++;