More documentation updates, and minor fixes to make things sync

up with the docs.
 -Erik
This commit is contained in:
Erik Andersen 2000-04-15 16:34:54 +00:00
parent 95c1c1e05f
commit 5e1189e187
27 changed files with 968 additions and 238 deletions

5
TODO
View File

@ -28,6 +28,11 @@ around to it some time. If you have any good ideas, please let me know.
* ftp
-----------------------
Add a compile option to turn off all the compiled in help
andusage information. Some folks don't need or want it...
-----------------------
Compile with debugging on, run 'nm --size-sort ./busybox'

View File

@ -44,15 +44,15 @@ static const struct Applet applets[] = {
#ifdef BB_CAT
{"cat", cat_main, _BB_DIR_BIN},
#endif
#ifdef BB_CHMOD_CHOWN_CHGRP
{"chgrp", chmod_chown_chgrp_main, _BB_DIR_BIN},
#endif
#ifdef BB_CHMOD_CHOWN_CHGRP
{"chmod", chmod_chown_chgrp_main, _BB_DIR_BIN},
#endif
#ifdef BB_CHMOD_CHOWN_CHGRP
{"chown", chmod_chown_chgrp_main, _BB_DIR_BIN},
#endif
#ifdef BB_CHMOD_CHOWN_CHGRP
{"chgrp", chmod_chown_chgrp_main, _BB_DIR_BIN},
#endif
#ifdef BB_CHROOT
{"chroot", chroot_main, _BB_DIR_SBIN},
#endif
@ -65,9 +65,6 @@ static const struct Applet applets[] = {
#ifdef BB_CP_MV
{"cp", cp_mv_main, _BB_DIR_BIN},
#endif
#ifdef BB_CP_MV
{"mv", cp_mv_main, _BB_DIR_BIN},
#endif
#ifdef BB_DATE
{"date", date_main, _BB_DIR_BIN},
#endif
@ -92,6 +89,9 @@ static const struct Applet applets[] = {
#ifdef BB_ECHO
{"echo", echo_main, _BB_DIR_BIN},
#endif
#ifdef BB_TRUE_FALSE
{"false", false_main, _BB_DIR_BIN},
#endif
#ifdef BB_FBSET
{"fbset", fbset_main, _BB_DIR_USR_SBIN},
#endif
@ -113,12 +113,15 @@ static const struct Applet applets[] = {
#ifdef BB_FSCK_MINIX
{"fsck.minix", fsck_minix_main, _BB_DIR_SBIN},
#endif
#ifdef BB_MKFS_MINIX
{"mkfs.minix", mkfs_minix_main, _BB_DIR_SBIN},
#endif
#ifdef BB_GREP
{"grep", grep_main, _BB_DIR_BIN},
#endif
#ifdef BB_GUNZIP
{"gunzip", gunzip_main, _BB_DIR_BIN},
#endif
#ifdef BB_GZIP
{"gzip", gzip_main, _BB_DIR_BIN},
#endif
#ifdef BB_HALT
{"halt", halt_main, _BB_DIR_SBIN},
#endif
@ -137,9 +140,6 @@ static const struct Applet applets[] = {
#ifdef BB_INSMOD
{"insmod", insmod_main, _BB_DIR_SBIN},
#endif
#ifdef BB_FEATURE_LINUXRC //
{"linuxrc", init_main, _BB_DIR_ROOT},
#endif
#ifdef BB_KILL
{"kill", kill_main, _BB_DIR_BIN},
#endif
@ -149,6 +149,9 @@ static const struct Applet applets[] = {
#ifdef BB_LENGTH
{"length", length_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_FEATURE_LINUXRC //
{"linuxrc", init_main, _BB_DIR_ROOT},
#endif
#ifdef BB_LN
{"ln", ln_main, _BB_DIR_BIN},
#endif
@ -161,6 +164,12 @@ static const struct Applet applets[] = {
#ifdef BB_LOADKMAP
{"loadkmap", loadkmap_main, _BB_DIR_SBIN},
#endif
#ifdef BB_LOGGER
{"logger", logger_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_LOGNAME
{"logname", logname_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_LS
{"ls", ls_main, _BB_DIR_BIN},
#endif
@ -179,6 +188,9 @@ static const struct Applet applets[] = {
#ifdef BB_MKFIFO
{"mkfifo", mkfifo_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_MKFS_MINIX
{"mkfs.minix", mkfs_minix_main, _BB_DIR_SBIN},
#endif
#ifdef BB_MKNOD
{"mknod", mknod_main, _BB_DIR_BIN},
#endif
@ -197,6 +209,9 @@ static const struct Applet applets[] = {
#ifdef BB_MT
{"mt", mt_main, _BB_DIR_BIN},
#endif
#ifdef BB_CP_MV
{"mv", cp_mv_main, _BB_DIR_BIN},
#endif
#ifdef BB_NSLOOKUP
{"nslookup", nslookup_main, _BB_DIR_USR_BIN},
#endif
@ -248,12 +263,6 @@ static const struct Applet applets[] = {
#ifdef BB_SYSLOGD
{"syslogd", syslogd_main, _BB_DIR_SBIN},
#endif
#ifdef BB_LOGGER
{"logger", logger_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_LOGNAME
{"logname", logname_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_SWAPONOFF
{"swapon", swap_on_off_main, _BB_DIR_SBIN},
#endif
@ -269,9 +278,6 @@ static const struct Applet applets[] = {
#ifdef BB_TELNET
{"telnet", telnet_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_TEST
{"[", test_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_TEST
{"test", test_main, _BB_DIR_USR_BIN},
#endif
@ -287,9 +293,6 @@ static const struct Applet applets[] = {
#ifdef BB_TRUE_FALSE
{"true", true_main, _BB_DIR_BIN},
#endif
#ifdef BB_TRUE_FALSE
{"false", false_main, _BB_DIR_BIN},
#endif
#ifdef BB_TTY
{"tty", tty_main, _BB_DIR_USR_BIN},
#endif
@ -299,15 +302,15 @@ static const struct Applet applets[] = {
#ifdef BB_UNAME
{"uname", uname_main, _BB_DIR_BIN},
#endif
#ifdef BB_UPTIME
{"uptime", uptime_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_UNIQ
{"uniq", uniq_main, _BB_DIR_BIN},
#endif
#ifdef BB_UPDATE
{"update", update_main, _BB_DIR_SBIN},
#endif
#ifdef BB_UPTIME
{"uptime", uptime_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_USLEEP
{"usleep", usleep_main, _BB_DIR_BIN},
#endif
@ -323,11 +326,8 @@ static const struct Applet applets[] = {
#ifdef BB_GUNZIP
{"zcat", gunzip_main, _BB_DIR_BIN},
#endif
#ifdef BB_GUNZIP
{"gunzip", gunzip_main, _BB_DIR_BIN},
#endif
#ifdef BB_GZIP
{"gzip", gzip_main, _BB_DIR_BIN},
#ifdef BB_TEST
{"[", test_main, _BB_DIR_USR_BIN},
#endif
{0}
};

View File

@ -41,7 +41,7 @@
static const char gzip_usage[] =
"gzip [OPTION]... FILE\n\n"
"Compress FILE with maximum compression.\n"
"When FILE is -, reads standard input. Implies -c.\n\n"
"When FILE is '-', reads standard input. Implies -c.\n\n"
"Options:\n"
"\t-c\tWrite output to standard output instead of FILE.gz\n";

View File

@ -44,15 +44,15 @@ static const struct Applet applets[] = {
#ifdef BB_CAT
{"cat", cat_main, _BB_DIR_BIN},
#endif
#ifdef BB_CHMOD_CHOWN_CHGRP
{"chgrp", chmod_chown_chgrp_main, _BB_DIR_BIN},
#endif
#ifdef BB_CHMOD_CHOWN_CHGRP
{"chmod", chmod_chown_chgrp_main, _BB_DIR_BIN},
#endif
#ifdef BB_CHMOD_CHOWN_CHGRP
{"chown", chmod_chown_chgrp_main, _BB_DIR_BIN},
#endif
#ifdef BB_CHMOD_CHOWN_CHGRP
{"chgrp", chmod_chown_chgrp_main, _BB_DIR_BIN},
#endif
#ifdef BB_CHROOT
{"chroot", chroot_main, _BB_DIR_SBIN},
#endif
@ -65,9 +65,6 @@ static const struct Applet applets[] = {
#ifdef BB_CP_MV
{"cp", cp_mv_main, _BB_DIR_BIN},
#endif
#ifdef BB_CP_MV
{"mv", cp_mv_main, _BB_DIR_BIN},
#endif
#ifdef BB_DATE
{"date", date_main, _BB_DIR_BIN},
#endif
@ -92,6 +89,9 @@ static const struct Applet applets[] = {
#ifdef BB_ECHO
{"echo", echo_main, _BB_DIR_BIN},
#endif
#ifdef BB_TRUE_FALSE
{"false", false_main, _BB_DIR_BIN},
#endif
#ifdef BB_FBSET
{"fbset", fbset_main, _BB_DIR_USR_SBIN},
#endif
@ -113,12 +113,15 @@ static const struct Applet applets[] = {
#ifdef BB_FSCK_MINIX
{"fsck.minix", fsck_minix_main, _BB_DIR_SBIN},
#endif
#ifdef BB_MKFS_MINIX
{"mkfs.minix", mkfs_minix_main, _BB_DIR_SBIN},
#endif
#ifdef BB_GREP
{"grep", grep_main, _BB_DIR_BIN},
#endif
#ifdef BB_GUNZIP
{"gunzip", gunzip_main, _BB_DIR_BIN},
#endif
#ifdef BB_GZIP
{"gzip", gzip_main, _BB_DIR_BIN},
#endif
#ifdef BB_HALT
{"halt", halt_main, _BB_DIR_SBIN},
#endif
@ -137,9 +140,6 @@ static const struct Applet applets[] = {
#ifdef BB_INSMOD
{"insmod", insmod_main, _BB_DIR_SBIN},
#endif
#ifdef BB_FEATURE_LINUXRC //
{"linuxrc", init_main, _BB_DIR_ROOT},
#endif
#ifdef BB_KILL
{"kill", kill_main, _BB_DIR_BIN},
#endif
@ -149,6 +149,9 @@ static const struct Applet applets[] = {
#ifdef BB_LENGTH
{"length", length_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_FEATURE_LINUXRC //
{"linuxrc", init_main, _BB_DIR_ROOT},
#endif
#ifdef BB_LN
{"ln", ln_main, _BB_DIR_BIN},
#endif
@ -161,6 +164,12 @@ static const struct Applet applets[] = {
#ifdef BB_LOADKMAP
{"loadkmap", loadkmap_main, _BB_DIR_SBIN},
#endif
#ifdef BB_LOGGER
{"logger", logger_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_LOGNAME
{"logname", logname_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_LS
{"ls", ls_main, _BB_DIR_BIN},
#endif
@ -179,6 +188,9 @@ static const struct Applet applets[] = {
#ifdef BB_MKFIFO
{"mkfifo", mkfifo_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_MKFS_MINIX
{"mkfs.minix", mkfs_minix_main, _BB_DIR_SBIN},
#endif
#ifdef BB_MKNOD
{"mknod", mknod_main, _BB_DIR_BIN},
#endif
@ -197,6 +209,9 @@ static const struct Applet applets[] = {
#ifdef BB_MT
{"mt", mt_main, _BB_DIR_BIN},
#endif
#ifdef BB_CP_MV
{"mv", cp_mv_main, _BB_DIR_BIN},
#endif
#ifdef BB_NSLOOKUP
{"nslookup", nslookup_main, _BB_DIR_USR_BIN},
#endif
@ -248,12 +263,6 @@ static const struct Applet applets[] = {
#ifdef BB_SYSLOGD
{"syslogd", syslogd_main, _BB_DIR_SBIN},
#endif
#ifdef BB_LOGGER
{"logger", logger_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_LOGNAME
{"logname", logname_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_SWAPONOFF
{"swapon", swap_on_off_main, _BB_DIR_SBIN},
#endif
@ -269,9 +278,6 @@ static const struct Applet applets[] = {
#ifdef BB_TELNET
{"telnet", telnet_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_TEST
{"[", test_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_TEST
{"test", test_main, _BB_DIR_USR_BIN},
#endif
@ -287,9 +293,6 @@ static const struct Applet applets[] = {
#ifdef BB_TRUE_FALSE
{"true", true_main, _BB_DIR_BIN},
#endif
#ifdef BB_TRUE_FALSE
{"false", false_main, _BB_DIR_BIN},
#endif
#ifdef BB_TTY
{"tty", tty_main, _BB_DIR_USR_BIN},
#endif
@ -299,15 +302,15 @@ static const struct Applet applets[] = {
#ifdef BB_UNAME
{"uname", uname_main, _BB_DIR_BIN},
#endif
#ifdef BB_UPTIME
{"uptime", uptime_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_UNIQ
{"uniq", uniq_main, _BB_DIR_BIN},
#endif
#ifdef BB_UPDATE
{"update", update_main, _BB_DIR_SBIN},
#endif
#ifdef BB_UPTIME
{"uptime", uptime_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_USLEEP
{"usleep", usleep_main, _BB_DIR_BIN},
#endif
@ -323,11 +326,8 @@ static const struct Applet applets[] = {
#ifdef BB_GUNZIP
{"zcat", gunzip_main, _BB_DIR_BIN},
#endif
#ifdef BB_GUNZIP
{"gunzip", gunzip_main, _BB_DIR_BIN},
#endif
#ifdef BB_GZIP
{"gzip", gzip_main, _BB_DIR_BIN},
#ifdef BB_TEST
{"[", test_main, _BB_DIR_USR_BIN},
#endif
{0}
};

View File

@ -32,12 +32,12 @@
#define BB_GREP
#define BB_GUNZIP
#define BB_GZIP
//#define BB_HALT
#define BB_HALT
#define BB_HEAD
#define BB_HOSTID
#define BB_HOSTNAME
#define BB_INIT
// Don't bother turning BB_INSMOD on. It doesn't work.
// Don't bother turning BB_INSMOD on. It doesn't work yet.
//#define BB_INSMOD
#define BB_KILL
#define BB_KILLALL
@ -65,11 +65,11 @@
#define BB_MT
#define BB_NSLOOKUP
#define BB_PING
//#define BB_POWEROFF
#define BB_POWEROFF
#define BB_PRINTF
#define BB_PS
#define BB_PWD
//#define BB_REBOOT
#define BB_REBOOT
#define BB_RM
#define BB_RMDIR
#define BB_RMMOD
@ -85,7 +85,7 @@
#define BB_TAR
#define BB_TEE
#define BB_TEST
// Don't turn BB_TELNET on. It doesn't work.
// Don't bother turning BB_TELNET on. It doesn't work properly yet.
//#define BB_TELNET
#define BB_TOUCH
#define BB_TR
@ -115,6 +115,7 @@
// the /proc filesystem and thereby saving lots and lots
// memory for more important things.
// You can't use this and USE_PROCFS at the same time...
// (BTW, I emailed Linus and this patch will not be going into the stock kernel)
//#define BB_FEATURE_USE_DEVPS_PATCH
//
// enable features that use the /proc filesystem (apps that

View File

@ -27,10 +27,10 @@
#include <errno.h>
static const char mkfifo_usage[] = "mkfifo [OPTIONS] name\n\n"
"Create the named fifo\n\n"
"Creates a named pipe (identical to 'mknod name p')\n\n"
"Options:\n"
"\t-m\tcreate the fifo with the specified mode; default = a=rw-umask\n";
"\t-m\tcreate the pipe using the specified mode (default a=rw)\n";
extern int mkfifo_main(int argc, char **argv)
{

View File

@ -28,23 +28,47 @@
#include <fcntl.h>
#include <unistd.h>
static const char mknod_usage[] = "mknod NAME TYPE MAJOR MINOR\n\n"
"Make block or character special files.\n\n"
static const char mknod_usage[] = "mknod [OPTIONS] NAME TYPE MAJOR MINOR\n\n"
"Create a special file (block, character, or pipe).\n\n"
"Options:\n"
"\t-m\tcreate the special file using the specified mode (default a=rw)\n\n"
"TYPEs include:\n"
"\tb:\tMake a block (buffered) device.\n"
"\tc or u:\tMake a character (un-buffered) device.\n"
"\tp:\tMake a named pipe. Major and minor are ignored for named pipes.\n";
"\tp:\tMake a named pipe. MAJOR and MINOR are ignored for named pipes.\n";
int mknod_main(int argc, char **argv)
{
char *thisarg;
mode_t mode = 0;
mode_t perm = 0666;
dev_t dev = 0;
if (argc != 5 || **(argv + 1) == '-') {
argc--;
argv++;
/* Parse any options */
while (argc > 1) {
if (**argv != '-')
break;
thisarg = *argv;
thisarg++;
switch (*thisarg) {
case 'm':
argc--;
argv++;
parse_mode(*argv, &perm);
break;
default:
usage(mknod_usage);
}
argc--;
argv++;
}
if (argc != 4 && argc != 2) {
usage(mknod_usage);
}
switch (argv[2][0]) {
switch (argv[1][0]) {
case 'c':
case 'u':
mode = S_IFCHR;
@ -54,23 +78,22 @@ int mknod_main(int argc, char **argv)
break;
case 'p':
mode = S_IFIFO;
if (argc!=2) {
usage(mknod_usage);
}
break;
default:
usage(mknod_usage);
}
if (mode == S_IFCHR || mode == S_IFBLK) {
dev = (atoi(argv[3]) << 8) | atoi(argv[4]);
if (argc != 5) {
usage(mknod_usage);
}
dev = (atoi(argv[2]) << 8) | atoi(argv[1]);
}
mode |= 0666;
mode |= perm;
if (mknod(argv[1], mode, dev) != 0) {
perror(argv[1]);
exit (FALSE);
}
if (mknod(argv[0], mode, dev) != 0)
fatalError("%s: %s\n", argv[0], strerror(errno));
exit (TRUE);
}

View File

@ -139,7 +139,7 @@ static void verify __P((char *s, char *end));
/* The value to return to the calling program. */
static int exit_status;
static const char printf_usage[] = "printf format [argument...]\n";
static const char printf_usage[] = "printf format [argument...]\n\nFormats and prints the given data.\n";
int printf_main(int argc, char **argv)
{

View File

@ -33,7 +33,7 @@ static const char sort_usage[] = "sort [-n]"
#ifdef BB_FEATURE_SORT_REVERSE
" [-r]"
#endif
" [FILE]...\n\n";
" [FILE]...\n\nSorts lines of text in the specified files\n";
#ifdef BB_FEATURE_SORT_REVERSE
#define APPLY_REVERSE(x) (reverse ? -(x) : (x))
@ -320,4 +320,4 @@ int sort_main(int argc, char **argv)
exit(0);
}
/* $Id: sort.c,v 1.13 2000/04/13 01:18:56 erik Exp $ */
/* $Id: sort.c,v 1.14 2000/04/15 16:34:54 erik Exp $ */

View File

@ -1,6 +1,6 @@
/* vi: set sw=4 ts=4: */
/*
* echo implementation for busybox
* test implementation for busybox
*
* Copyright (c) by a whole pile of folks:
*
@ -185,6 +185,12 @@ test_main(int argc, char** argv)
fatalError("missing ]");
argv[argc] = NULL;
}
if (strcmp(argv[1], "--help") == 0) {
usage("test EXPRESSION\n"
"or [ EXPRESSION ]\n\n"
"Checks file types and compares values returning an exit\n"
"code determined by the value of EXPRESSION.\n");
}
/* Implement special cases from POSIX.2, section 4.62.4 */
switch (argc) {

View File

@ -44,7 +44,7 @@ static char sccsid[] = "@(#)tr.c 8.2 (Berkeley) 5/4/95";
#endif
static const char rcsid[] =
"$Id: tr.c,v 1.2 2000/03/21 22:32:57 erik Exp $";
"$Id: tr.c,v 1.3 2000/04/15 16:34:54 erik Exp $";
#endif /* not lint */
#endif /* #if 0 */
@ -138,12 +138,12 @@ int cflag;
static void tr_usage()
{
(void) fprintf(stderr, "%s\n%s\n%s\n%s\n",
"usage: tr [-csu] string1 string2",
" tr [-cu] -d string1",
" tr [-cu] -s string1",
" tr [-cu] -ds string1 string2");
exit(1);
usage( "\ttr [-csu] string1 string2\n"
"\ttr [-cu] -d string1\n"
"\ttr [-cu] -s string1\n"
"\ttr [-cu] -ds string1 string2\n\n"
"Translate, squeeze, and/or delete characters from standard\n"
"input, writing to standard output.\n");
}

File diff suppressed because it is too large Load Diff

2
gzip.c
View File

@ -41,7 +41,7 @@
static const char gzip_usage[] =
"gzip [OPTION]... FILE\n\n"
"Compress FILE with maximum compression.\n"
"When FILE is -, reads standard input. Implies -c.\n\n"
"When FILE is '-', reads standard input. Implies -c.\n\n"
"Options:\n"
"\t-c\tWrite output to standard output instead of FILE.gz\n";

View File

@ -17,10 +17,18 @@
#include <sys/stat.h>
static const char makedevs_usage[] =
"makedevs 0.01 -- Create an entire range of device files\n\n"
"\tmakedevs /dev/ttyS c 4 64 0 63 (ttyS0-ttyS63)\n"
"\tmakedevs /dev/hda b 3 0 0 8 s (hda,hda1-hda8)\n";
"makedevs NAME TYPE MAJOR MINOR FIRST LAST [s]\n\n"
"Creates a range of block or character special files\n\n"
"TYPEs include:\n"
"\tb:\tMake a block (buffered) device.\n"
"\tc or u:\tMake a character (un-buffered) device.\n"
"\tp:\tMake a named pipe. MAJOR and MINOR are ignored for named pipes.\n\n"
"FIRST specifies the number appended to NAME to create the first device.\n"
"LAST specifies the number of the last item that should be created.\n"
"If 's' is the last argument, the base device is created as well.\n\n"
"For example:\n"
"\tmakedevs /dev/ttyS c 4 66 2 63 -> ttyS2-ttyS63\n"
"\tmakedevs /dev/hda b 3 0 0 8 s -> hda,hda1-hda8\n";
int makedevs_main(int argc, char **argv)
{
@ -38,6 +46,9 @@ int makedevs_main(int argc, char **argv)
char devname[255];
char buf[255];
if (argc < 7 || *argv[1]=='-')
usage(makedevs_usage);
switch (type[0]) {
case 'c':
mode = S_IFCHR;

21
math.c
View File

@ -7,7 +7,10 @@
/* Tiny RPN calculator, because "expr" didn't give me bitwise operations. */
static const char math_usage[] = "math expression ...";
static const char math_usage[] = "math expression ...\n\n"
"This is a Tiny RPN calculator that understands the\n"
"following operations: +, -, /, *, and, or, not, eor.\n"
"i.e. 'math 2 2 add' -> 4, and 'math 8 8 \\* 2 2 + /' -> 16\n";
static double stack[100];
static unsigned int pointer;
@ -85,14 +88,14 @@ struct op {
};
static const struct op operators[] = {
{"add", add},
{"+", add},
{"-", sub},
{"*", mul},
{"/", divide},
{"and", and},
{"div", divide},
{"eor", eor},
{"mul", mul},
{"not", not},
{"or", or},
{"sub", sub},
{"not", not},
{"eor", eor},
{0, 0}
};
@ -127,11 +130,13 @@ static void stack_machine(const char *argument)
int math_main(int argc, char **argv)
{
if (argc < 1 || *argv[1]=='-')
usage(math_usage);
while (argc >= 2) {
stack_machine(argv[1]);
argv++;
argc--;
}
stack_machine(0);
return 0;
exit( TRUE);
}

View File

@ -17,10 +17,18 @@
#include <sys/stat.h>
static const char makedevs_usage[] =
"makedevs 0.01 -- Create an entire range of device files\n\n"
"\tmakedevs /dev/ttyS c 4 64 0 63 (ttyS0-ttyS63)\n"
"\tmakedevs /dev/hda b 3 0 0 8 s (hda,hda1-hda8)\n";
"makedevs NAME TYPE MAJOR MINOR FIRST LAST [s]\n\n"
"Creates a range of block or character special files\n\n"
"TYPEs include:\n"
"\tb:\tMake a block (buffered) device.\n"
"\tc or u:\tMake a character (un-buffered) device.\n"
"\tp:\tMake a named pipe. MAJOR and MINOR are ignored for named pipes.\n\n"
"FIRST specifies the number appended to NAME to create the first device.\n"
"LAST specifies the number of the last item that should be created.\n"
"If 's' is the last argument, the base device is created as well.\n\n"
"For example:\n"
"\tmakedevs /dev/ttyS c 4 66 2 63 -> ttyS2-ttyS63\n"
"\tmakedevs /dev/hda b 3 0 0 8 s -> hda,hda1-hda8\n";
int makedevs_main(int argc, char **argv)
{
@ -38,6 +46,9 @@ int makedevs_main(int argc, char **argv)
char devname[255];
char buf[255];
if (argc < 7 || *argv[1]=='-')
usage(makedevs_usage);
switch (type[0]) {
case 'c':
mode = S_IFCHR;

View File

@ -4,7 +4,8 @@
#include <sys/mtio.h>
#include <sys/fcntl.h>
static const char mt_usage[] = "mt [-f device] opcode value\n";
static const char mt_usage[] = "mt [-f device] opcode value\n\n"
"Control magnetic tape drive operation\n";
struct mt_opcodes {
char *name;
@ -56,6 +57,10 @@ extern int mt_main(int argc, char **argv)
const struct mt_opcodes *code = opcodes;
struct mtop op;
int fd;
if ((argc != 2 && argc != 3) || **(argv + 1) == '-') {
usage(mt_usage);
}
if (strcmp(argv[1], "-f") == 0) {
if (argc < 4) {
@ -74,7 +79,7 @@ extern int mt_main(int argc, char **argv)
if (code->name == 0) {
fprintf(stderr, "mt: unrecognized opcode %s.\n", argv[1]);
return (FALSE);
exit (FALSE);
}
op.mt_op = code->value;
@ -85,13 +90,13 @@ extern int mt_main(int argc, char **argv)
if ((fd = open(file, O_RDONLY, 0)) < 0) {
perror(file);
return (FALSE);
exit (FALSE);
}
if (ioctl(fd, MTIOCTOP, &op) != 0) {
perror(file);
return (FALSE);
exit (FALSE);
}
return (TRUE);
exit (TRUE);
}

View File

@ -27,10 +27,10 @@
#include <errno.h>
static const char mkfifo_usage[] = "mkfifo [OPTIONS] name\n\n"
"Create the named fifo\n\n"
"Creates a named pipe (identical to 'mknod name p')\n\n"
"Options:\n"
"\t-m\tcreate the fifo with the specified mode; default = a=rw-umask\n";
"\t-m\tcreate the pipe using the specified mode (default a=rw)\n";
extern int mkfifo_main(int argc, char **argv)
{

53
mknod.c
View File

@ -28,23 +28,47 @@
#include <fcntl.h>
#include <unistd.h>
static const char mknod_usage[] = "mknod NAME TYPE MAJOR MINOR\n\n"
"Make block or character special files.\n\n"
static const char mknod_usage[] = "mknod [OPTIONS] NAME TYPE MAJOR MINOR\n\n"
"Create a special file (block, character, or pipe).\n\n"
"Options:\n"
"\t-m\tcreate the special file using the specified mode (default a=rw)\n\n"
"TYPEs include:\n"
"\tb:\tMake a block (buffered) device.\n"
"\tc or u:\tMake a character (un-buffered) device.\n"
"\tp:\tMake a named pipe. Major and minor are ignored for named pipes.\n";
"\tp:\tMake a named pipe. MAJOR and MINOR are ignored for named pipes.\n";
int mknod_main(int argc, char **argv)
{
char *thisarg;
mode_t mode = 0;
mode_t perm = 0666;
dev_t dev = 0;
if (argc != 5 || **(argv + 1) == '-') {
argc--;
argv++;
/* Parse any options */
while (argc > 1) {
if (**argv != '-')
break;
thisarg = *argv;
thisarg++;
switch (*thisarg) {
case 'm':
argc--;
argv++;
parse_mode(*argv, &perm);
break;
default:
usage(mknod_usage);
}
argc--;
argv++;
}
if (argc != 4 && argc != 2) {
usage(mknod_usage);
}
switch (argv[2][0]) {
switch (argv[1][0]) {
case 'c':
case 'u':
mode = S_IFCHR;
@ -54,23 +78,22 @@ int mknod_main(int argc, char **argv)
break;
case 'p':
mode = S_IFIFO;
if (argc!=2) {
usage(mknod_usage);
}
break;
default:
usage(mknod_usage);
}
if (mode == S_IFCHR || mode == S_IFBLK) {
dev = (atoi(argv[3]) << 8) | atoi(argv[4]);
if (argc != 5) {
usage(mknod_usage);
}
dev = (atoi(argv[2]) << 8) | atoi(argv[1]);
}
mode |= 0666;
mode |= perm;
if (mknod(argv[1], mode, dev) != 0) {
perror(argv[1]);
exit (FALSE);
}
if (mknod(argv[0], mode, dev) != 0)
fatalError("%s: %s\n", argv[0], strerror(errno));
exit (TRUE);
}

6
mnc.c
View File

@ -56,11 +56,11 @@ int mnc_main(int argc, char **argv)
fd_set readfds, testfds;
if (argc <= 1 || **(argv + 1) == '-') {
usage(mnc_usage);
}
argc--;
argv++;
if (argc < 2 || **(argv + 1) == '-') {
usage(mnc_usage);
}
sfd = socket(AF_INET, SOCK_STREAM, 0);

15
mt.c
View File

@ -4,7 +4,8 @@
#include <sys/mtio.h>
#include <sys/fcntl.h>
static const char mt_usage[] = "mt [-f device] opcode value\n";
static const char mt_usage[] = "mt [-f device] opcode value\n\n"
"Control magnetic tape drive operation\n";
struct mt_opcodes {
char *name;
@ -56,6 +57,10 @@ extern int mt_main(int argc, char **argv)
const struct mt_opcodes *code = opcodes;
struct mtop op;
int fd;
if ((argc != 2 && argc != 3) || **(argv + 1) == '-') {
usage(mt_usage);
}
if (strcmp(argv[1], "-f") == 0) {
if (argc < 4) {
@ -74,7 +79,7 @@ extern int mt_main(int argc, char **argv)
if (code->name == 0) {
fprintf(stderr, "mt: unrecognized opcode %s.\n", argv[1]);
return (FALSE);
exit (FALSE);
}
op.mt_op = code->value;
@ -85,13 +90,13 @@ extern int mt_main(int argc, char **argv)
if ((fd = open(file, O_RDONLY, 0)) < 0) {
perror(file);
return (FALSE);
exit (FALSE);
}
if (ioctl(fd, MTIOCTOP, &op) != 0) {
perror(file);
return (FALSE);
exit (FALSE);
}
return (TRUE);
exit (TRUE);
}

View File

@ -41,7 +41,7 @@
| + find out how the real nslookup gets the default name server
*/
static const char nslookup_usage[] = "nslookup [HOST]\n\n";
static const char nslookup_usage[] = "nslookup [HOST]\n\nQueries the nameserver for the IP address of the given HOST\n";
/* I have to see how the real nslookup does this.
@ -50,8 +50,8 @@ static const char nslookup_usage[] = "nslookup [HOST]\n\n";
*/
static void server_fprint(FILE * dst)
{
fprintf(dst, "Server: %s\n", "something");
fprintf(dst, "Address: %s\n\n", "something");
fprintf(dst, "Server: %s\n", "default");
fprintf(dst, "Address: %s\n\n", "default");
}
/* only works for IPv4 */
@ -96,9 +96,9 @@ static int addr_list_fprint(char **h_addr_list, FILE * dst)
{
int i, j;
char *addr_string = (h_addr_list[1])
? "Addresses" : "Address";
? "Addresses: " : "Address: ";
fprintf(dst, "%s: ", addr_string);
fprintf(dst, "%s ", addr_string);
for (i = 0, j = 0; h_addr_list[i]; i++, j++) {
addr_fprint(h_addr_list[i], dst);
@ -132,7 +132,7 @@ static struct hostent *gethostbyaddr_wrapper(const char *address)
static struct hostent *hostent_fprint(struct hostent *host, FILE * dst)
{
if (host) {
fprintf(dst, "Name: %s\n", host->h_name);
fprintf(dst, "Name: %s\n", host->h_name);
addr_list_fprint(host->h_addr_list, dst);
} else {
fprintf(dst, "*** %s\n", hstrerror(h_errno));
@ -159,7 +159,7 @@ int nslookup_main(int argc, char **argv)
{
struct hostent *host;
if (argc < 2) {
if (argc < 2 || *argv[1]=='-') {
usage(nslookup_usage);
}
@ -170,7 +170,7 @@ int nslookup_main(int argc, char **argv)
host = gethostbyname(argv[1]);
}
hostent_fprint(host, stdout);
return 0;
exit( TRUE);
}
/* $Id: nslookup.c,v 1.6 2000/04/13 01:18:56 erik Exp $ */
/* $Id: nslookup.c,v 1.7 2000/04/15 16:34:54 erik Exp $ */

View File

@ -41,7 +41,7 @@
| + find out how the real nslookup gets the default name server
*/
static const char nslookup_usage[] = "nslookup [HOST]\n\n";
static const char nslookup_usage[] = "nslookup [HOST]\n\nQueries the nameserver for the IP address of the given HOST\n";
/* I have to see how the real nslookup does this.
@ -50,8 +50,8 @@ static const char nslookup_usage[] = "nslookup [HOST]\n\n";
*/
static void server_fprint(FILE * dst)
{
fprintf(dst, "Server: %s\n", "something");
fprintf(dst, "Address: %s\n\n", "something");
fprintf(dst, "Server: %s\n", "default");
fprintf(dst, "Address: %s\n\n", "default");
}
/* only works for IPv4 */
@ -96,9 +96,9 @@ static int addr_list_fprint(char **h_addr_list, FILE * dst)
{
int i, j;
char *addr_string = (h_addr_list[1])
? "Addresses" : "Address";
? "Addresses: " : "Address: ";
fprintf(dst, "%s: ", addr_string);
fprintf(dst, "%s ", addr_string);
for (i = 0, j = 0; h_addr_list[i]; i++, j++) {
addr_fprint(h_addr_list[i], dst);
@ -132,7 +132,7 @@ static struct hostent *gethostbyaddr_wrapper(const char *address)
static struct hostent *hostent_fprint(struct hostent *host, FILE * dst)
{
if (host) {
fprintf(dst, "Name: %s\n", host->h_name);
fprintf(dst, "Name: %s\n", host->h_name);
addr_list_fprint(host->h_addr_list, dst);
} else {
fprintf(dst, "*** %s\n", hstrerror(h_errno));
@ -159,7 +159,7 @@ int nslookup_main(int argc, char **argv)
{
struct hostent *host;
if (argc < 2) {
if (argc < 2 || *argv[1]=='-') {
usage(nslookup_usage);
}
@ -170,7 +170,7 @@ int nslookup_main(int argc, char **argv)
host = gethostbyname(argv[1]);
}
hostent_fprint(host, stdout);
return 0;
exit( TRUE);
}
/* $Id: nslookup.c,v 1.6 2000/04/13 01:18:56 erik Exp $ */
/* $Id: nslookup.c,v 1.7 2000/04/15 16:34:54 erik Exp $ */

View File

@ -139,7 +139,7 @@ static void verify __P((char *s, char *end));
/* The value to return to the calling program. */
static int exit_status;
static const char printf_usage[] = "printf format [argument...]\n";
static const char printf_usage[] = "printf format [argument...]\n\nFormats and prints the given data.\n";
int printf_main(int argc, char **argv)
{

4
sort.c
View File

@ -33,7 +33,7 @@ static const char sort_usage[] = "sort [-n]"
#ifdef BB_FEATURE_SORT_REVERSE
" [-r]"
#endif
" [FILE]...\n\n";
" [FILE]...\n\nSorts lines of text in the specified files\n";
#ifdef BB_FEATURE_SORT_REVERSE
#define APPLY_REVERSE(x) (reverse ? -(x) : (x))
@ -320,4 +320,4 @@ int sort_main(int argc, char **argv)
exit(0);
}
/* $Id: sort.c,v 1.13 2000/04/13 01:18:56 erik Exp $ */
/* $Id: sort.c,v 1.14 2000/04/15 16:34:54 erik Exp $ */

8
test.c
View File

@ -1,6 +1,6 @@
/* vi: set sw=4 ts=4: */
/*
* echo implementation for busybox
* test implementation for busybox
*
* Copyright (c) by a whole pile of folks:
*
@ -185,6 +185,12 @@ test_main(int argc, char** argv)
fatalError("missing ]");
argv[argc] = NULL;
}
if (strcmp(argv[1], "--help") == 0) {
usage("test EXPRESSION\n"
"or [ EXPRESSION ]\n\n"
"Checks file types and compares values returning an exit\n"
"code determined by the value of EXPRESSION.\n");
}
/* Implement special cases from POSIX.2, section 4.62.4 */
switch (argc) {

14
tr.c
View File

@ -44,7 +44,7 @@ static char sccsid[] = "@(#)tr.c 8.2 (Berkeley) 5/4/95";
#endif
static const char rcsid[] =
"$Id: tr.c,v 1.2 2000/03/21 22:32:57 erik Exp $";
"$Id: tr.c,v 1.3 2000/04/15 16:34:54 erik Exp $";
#endif /* not lint */
#endif /* #if 0 */
@ -138,12 +138,12 @@ int cflag;
static void tr_usage()
{
(void) fprintf(stderr, "%s\n%s\n%s\n%s\n",
"usage: tr [-csu] string1 string2",
" tr [-cu] -d string1",
" tr [-cu] -s string1",
" tr [-cu] -ds string1 string2");
exit(1);
usage( "\ttr [-csu] string1 string2\n"
"\ttr [-cu] -d string1\n"
"\ttr [-cu] -s string1\n"
"\ttr [-cu] -ds string1 string2\n\n"
"Translate, squeeze, and/or delete characters from standard\n"
"input, writing to standard output.\n");
}