updated docs/busybox.pod accordingly. -beppu
* Added mktemp, contributed by Daniel Jacobowitz <dan@debian.org>
* Added setkeycodes, for those that have wierd keyboard buttons.
+ * Added cut and tr from minix, since due to the license change,
+ we can now use minix code. Minix tr saves 4k.
* Fix for ping warnings from Sascha Ziemann <szi@aibon.ping.de>
* Fixed update segfault
* Fixed mknod -- minor number was always 0
* added a simple id implementation; doesn't support sup. groups yet
* logname used getlogin(3) which uses utmp. Now it doesn't.
* whoami used getpwuid(3) which uses libc NSS. Now it behaves.
- * Due to the license change, I can now use minix code. Minux tr
- replaces the BSD derived tr, saving 4k and eliminating bsearch(3)
- from the list of used Libc symbols.
* Add support for "noatime" and "nodiratime" mount flags to mount.
* Changed 'umount -f' to mean force, and actually use umount2.
* Changed 'umount -l' to mean "Do not free loop device".
* More doc updates
* cp -fa now works as expected for symlinks (it didn't before)
* zcat now works (wasn't working since option parsing was broken)
+ * Renamed "mnc" to the more correct "nc".
+ * Added BB_FEATURE_TRIVIAL_HELP which compiles out most all of the
+ help messages (i.e --help). Saves 17k over a full compile.
-Erik
# Set the following to `true' to make a debuggable build.
# Leave this set to `false' for production use.
# eg: `make DODEBUG=true tests'
-DODEBUG = true
+DODEBUG = false
# If you want a static binary, turn this on.
DOSTATIC = false
#ifdef BB_CP_MV
{"cp", cp_mv_main, _BB_DIR_BIN},
#endif
+#ifdef BB_CUT
+ {"cut", cut_main, _BB_DIR_USR_BIN},
+#endif
#ifdef BB_DATE
{"date", date_main, _BB_DIR_BIN},
#endif
#ifdef BB_MKTEMP
{"mktemp", mktemp_main, _BB_DIR_BIN},
#endif
-#ifdef BB_MNC
- {"mnc", mnc_main, _BB_DIR_USR_BIN},
+#ifdef BB_NC
+ {"nc", nc_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_MORE
{"more", more_main, _BB_DIR_BIN},
*/
#include "internal.h"
+
static const char gunzip_usage[] =
- "gunzip [OPTION]... FILE\n\n"
- "Uncompress FILE (or standard input if FILE is '-').\n\n"
+ "gunzip [OPTION]... FILE\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nUncompress FILE (or standard input if FILE is '-').\n\n"
"Options:\n"
"\t-c\tWrite output to standard output\n"
- "\t-t\tTest compressed file integrity\n";
+ "\t-t\tTest compressed file integrity\n"
+#endif
+ ;
/* These defines are very important for BusyBox. Without these,
#define SMALL_MEM
#define DYN_ALLOC
-#define bb_need_name_too_long
#define BB_DECLARE_EXTERN
+#define bb_need_memory_exhausted
+#define bb_need_name_too_long
#include "messages.c"
# define DECLARE(type, array, size) type * array
# define ALLOC(type, array, size) { \
array = (type*)calloc((size_t)(((size)+1L)/2), 2*sizeof(type)); \
- if (array == NULL) errorMsg("insufficient memory"); \
+ if (array == NULL) errorMsg(memory_exhausted, "gunzip"); \
}
# define FREE(array) {if (array != NULL) free(array), array=NULL;}
#else
int res = inflate();
if (res == 3) {
- errorMsg("out of memory");
+ errorMsg(memory_exhausted, "gunzip");
} else if (res != 0) {
errorMsg("invalid compressed data--format violated");
}
*/
#include "internal.h"
+#define BB_DECLARE_EXTERN
+#define bb_need_memory_exhausted
+#include "messages.c"
/* These defines are very important for BusyBox. Without these,
* huge chunks of ram are pre-allocated making the BusyBox bss
static const char gzip_usage[] =
- "gzip [OPTION]... FILE\n\n"
- "Compress FILE with maximum compression.\n"
+ "gzip [OPTION]... FILE\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nCompress FILE with maximum compression.\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";
+ "\t-c\tWrite output to standard output instead of FILE.gz\n"
+#endif
+ ;
/* I don't like nested includes, but the string and io functions are used
# define DECLARE(type, array, size) type * array
# define ALLOC(type, array, size) { \
array = (type*)calloc((size_t)(((size)+1L)/2), 2*sizeof(type)); \
- if (array == NULL) errorMsg("insufficient memory"); \
+ if (array == NULL) errorMsg(memory_exhausted, "gzip"); \
}
# define FREE(array) {if (array != NULL) free(array), array=NULL;}
#else
long time_stamp; /* original time stamp (modification time) */
long ifile_size; /* input file size, -1 for devices (debug only) */
char *env; /* contents of GZIP env variable */
-char **args = NULL; /* argv pointer if GZIP env variable defined */
char z_suffix[MAX_SUFFIX + 1]; /* default suffix (can be set with --suffix) */
int z_len; /* strlen(z_suffix) */
nargv = (char **) calloc(*argcp + 1, sizeof(char *));
if (nargv == NULL)
- errorMsg("out of memory");
+ errorMsg(memory_exhausted, "gzip");
oargv = *argvp;
*argvp = nargv;
#if defined BB_FEATURE_TAR_EXCLUDE
"[--exclude File] "
#endif
- "[-f tarFile] [FILE] ...\n\n"
- "Create, extract, or list files from a tar file. Note that\n"
+ "[-f tarFile] [FILE] ...\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nCreate, extract, or list files from a tar file. Note that\n"
"this version of tar treats hard links as separate files.\n\n"
"Main operation mode:\n"
#ifdef BB_FEATURE_TAR_CREATE
#endif
"\nInformative output:\n"
"\tv\t\tverbosely list files processed\n"
+#endif
;
/* Tar file constants */
#ifdef BB_CP_MV
{"cp", cp_mv_main, _BB_DIR_BIN},
#endif
+#ifdef BB_CUT
+ {"cut", cut_main, _BB_DIR_USR_BIN},
+#endif
#ifdef BB_DATE
{"date", date_main, _BB_DIR_BIN},
#endif
#ifdef BB_MKTEMP
{"mktemp", mktemp_main, _BB_DIR_BIN},
#endif
-#ifdef BB_MNC
- {"mnc", mnc_main, _BB_DIR_USR_BIN},
+#ifdef BB_NC
+ {"nc", nc_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_MORE
{"more", more_main, _BB_DIR_BIN},
#define BB_CHVT
#define BB_CLEAR
#define BB_CP_MV
+#define BB_CUT
#define BB_DATE
#define BB_DD
#define BB_DEALLOCVT
#define BB_MKNOD
#define BB_MKSWAP
#define BB_MKTEMP
-#define BB_MNC
+#define BB_NC
#define BB_MORE
#define BB_MOUNT
#define BB_MT
//
// This compiles out everything but the most
// trivial --help usage information (i.e. reduces binary size)
-//#define BB_FEATURE_TRIVIAL_HELP
+#define BB_FEATURE_TRIVIAL_HELP
//
// Use termios to manipulate the screen ('more' is prettier with this on)
//#define BB_FEATURE_USE_TERMIOS
#include <sys/ioctl.h>
#include <sys/kd.h>
-static const char loadacm_usage[] = "loadacm\n\n"
- "Loads an acm from standard input.\n";
+static const char loadacm_usage[] = "loadacm\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nLoads an acm from standard input.\n"
+#endif
+ ;
typedef unsigned short unicode;
#define PSF_MAXMODE 0x03
#define PSF_SEPARATOR 0xFFFF
-static const char loadfont_usage[] = "loadfont\n\n"
- "Loads a console font from standard input.\n";
+static const char loadfont_usage[] = "loadfont\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "Loads a console font from standard input.\n"
+#endif
+ ;
struct psf_header {
unsigned char magic1, magic2; /* Magic number */
#include <sys/ioctl.h>
-static const char loadkmap_usage[] = "loadkmap\n\n"
- "Loads a binary keyboard translation table from standard input.\n";
+static const char loadkmap_usage[] = "loadkmap\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "Loads a binary keyboard translation table from standard input.\n"
+#endif
+ ;
int loadkmap_main(int argc, char **argv)
--- /dev/null
+/* vi: set sw=4 ts=4: */
+/*
+ * cut implementation for busybox
+ *
+ * Copyright (c) Michael J. Holme
+ *
+ * This version of cut is adapted from Minix cut and was modified
+ * by Erik Andersen <andersee@debian.org> to be used in busybox.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Original copyright notice is retained at the end of this file.
+ */
+
+#include "internal.h"
+#include <sys/types.h>
+#include <ctype.h>
+#include <string.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <stdio.h>
+#define BB_DECLARE_EXTERN
+#define bb_need_help
+#include "messages.c"
+
+#define MAX_FIELD 80 /* Pointers to the beginning of each field
+ * are stored in columns[], if a line holds
+ * more than MAX_FIELD columns the array
+ * boundary is exceed. But unlikely at 80 */
+
+#define MAX_ARGS 32 /* Maximum number of fields following -f or
+ * -c switches */
+int args[MAX_ARGS * 2];
+int num_args;
+
+/* Lots of new defines, should easen maintainance... */
+#define DUMP_STDIN 0 /* define for mode: no options */
+#define OPTIONF 1 /* define for mode: option -f */
+#define OPTIONC 2 /* define for mode: option -c */
+#define OPTIONB 3 /* define for mode: option -b */
+#define NOTSET 0 /* option not selected */
+#define SET 1 /* option selected */
+
+/* Defines for the warnings */
+#define DELIMITER_NOT_APPLICABLE 0
+#define OVERRIDING_PREVIOUS_MODE 1
+#define OPTION_NOT_APPLICABLE 2
+#define UNKNOWN_OPTION 3
+#define FILE_NOT_READABLE 4
+
+/* Defines for the fatal errors */
+#define SYNTAX_ERROR 101
+#define POSITION_ERROR 102
+#define LINE_TO_LONG_ERROR 103
+#define RANGE_ERROR 104
+#define MAX_FIELDS_EXEEDED_ERROR 105
+#define MAX_ARGS_EXEEDED_ERROR 106
+
+
+int mode; /* 0 = dump stdin to stdout, 1=-f, 2=-c */
+char delim = '\t'; /* default delimiting character */
+FILE *fd;
+char *name;
+char line[BUFSIZ];
+int exit_status;
+
+int cut_main(int argc, char **argv);
+void warn(int warn_number, char *option);
+void cuterror(int err);
+void get_args(void);
+void cut(void);
+
+void warn(int warn_number, char *option)
+{
+ static char *warn_msg[] = {
+ "%s: Option -d allowed only with -f\n",
+ "%s: -%s overrides earlier option\n",
+ "%s: -%s not allowed in current mode\n",
+ "%s: Cannot open %s\n"
+ };
+
+ fprintf(stderr, warn_msg[warn_number], name, option);
+ exit_status = warn_number + 1;
+
+}
+
+void cuterror(int err)
+{
+ static char *err_mes[] = {
+ "%s: syntax error\n",
+ "%s: position must be >0\n",
+ "%s: line longer than BUFSIZ\n",
+ "%s: range must not decrease from left to right\n",
+ "%s: MAX_FIELD exceeded\n",
+ "%s: MAX_ARGS exceeded\n"
+ };
+
+ fprintf(stderr, err_mes[err - 101], name);
+ exit(err);
+}
+
+
+void get_args()
+{
+ int i = 0;
+ int arg_ptr = 0;
+ int flag;
+
+ num_args = 0;
+ do {
+ if (num_args == MAX_ARGS)
+ cuterror(MAX_ARGS_EXEEDED_ERROR);
+ if (!isdigit(line[i]) && line[i] != '-')
+ cuterror(SYNTAX_ERROR);
+
+ args[arg_ptr] = 1;
+ args[arg_ptr + 1] = BUFSIZ;
+ flag = 1;
+
+ while (line[i] != ',' && line[i] != 0) {
+ if (isdigit(line[i])) {
+ args[arg_ptr] = 0;
+ while (isdigit(line[i]))
+ args[arg_ptr] = 10 * args[arg_ptr] + line[i++] - '0';
+ if (!args[arg_ptr])
+ cuterror(POSITION_ERROR);
+ arg_ptr++;
+ }
+ if (line[i] == '-') {
+ arg_ptr |= 1;
+ i++;
+ flag = 0;
+ }
+ }
+ if (flag && arg_ptr & 1)
+ args[arg_ptr] = args[arg_ptr - 1];
+ if (args[num_args * 2] > args[num_args * 2 + 1])
+ cuterror(RANGE_ERROR);
+ num_args++;
+ arg_ptr = num_args * 2;
+ }
+ while (line[i++]);
+}
+
+
+void cut()
+{
+ int i, j, length, maxcol=0;
+ char *columns[MAX_FIELD];
+
+ while (fgets(line, BUFSIZ, fd)) {
+ length = strlen(line) - 1;
+ *(line + length) = 0;
+ switch (mode) {
+ case DUMP_STDIN:
+ printf("%s", line);
+ break;
+ case OPTIONF:
+ columns[maxcol++] = line;
+ for (i = 0; i < length; i++) {
+ if (*(line + i) == delim) {
+ *(line + i) = 0;
+ if (maxcol == MAX_FIELD)
+ cuterror(MAX_FIELDS_EXEEDED_ERROR);
+ columns[maxcol] = line + i + 1;
+ maxcol++;
+ }
+ }
+ if (maxcol != 1) {
+ for (i = 0; i < num_args; i++) {
+ for (j = args[i * 2]; j <= args[i * 2 + 1]; j++)
+ if (j <= maxcol) {
+ printf("%s", columns[j - 1]);
+ if (i != num_args - 1 || j != args[i * 2 + 1])
+ putchar(delim);
+ }
+ }
+ }
+ break;
+ case OPTIONC:
+ for (i = 0; i < num_args; i++) {
+ for (j = args[i * 2];
+ j <= (args[i * 2 + 1] >
+ length ? length : args[i * 2 + 1]); j++)
+ putchar(*(line + j - 1));
+ }
+ }
+ if (maxcol != 1)
+ putchar('\n');
+ }
+}
+
+
+int cut_main(int argc, char **argv)
+{
+ int i = 1;
+ int numberFilenames = 0;
+
+ name = argv[0];
+
+ if (argc == 1 || strcmp(argv[1], dash_dash_help)==0)
+ usage( "cut [OPTION]... [FILE]...\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nPrints selected fields from each input FILE to standard output.\n\n"
+ "Options:\n"
+ "\t-b LIST\tOutput only bytes from LIST\n"
+ "\t-c LIST\tOutput only characters from LIST\n"
+ "\t-d DELIM\tUse DELIM instead of tab as the field delimiter\n"
+ "\t-f N\tPrint only these fields\n"
+ "\t-n\tIgnored\n"
+#endif
+ );
+
+ while (i < argc) {
+ if (argv[i][0] == '-') {
+ switch (argv[i++][1]) {
+ case 'd':
+ if (mode == OPTIONC || mode == OPTIONB)
+ warn(DELIMITER_NOT_APPLICABLE, "d");
+ delim = argv[i++][0];
+ break;
+ case 'f':
+ sprintf(line, "%s", argv[i++]);
+ if (mode == OPTIONC || mode == OPTIONB)
+ warn(OVERRIDING_PREVIOUS_MODE, "f");
+ mode = OPTIONF;
+ break;
+ case 'b':
+ sprintf(line, "%s", argv[i++]);
+ if (mode == OPTIONF || mode == OPTIONC)
+ warn(OVERRIDING_PREVIOUS_MODE, "b");
+ mode = OPTIONB;
+ break;
+ case 'c':
+ sprintf(line, "%s", argv[i++]);
+ if (mode == OPTIONF || mode == OPTIONB)
+ warn(OVERRIDING_PREVIOUS_MODE, "c");
+ mode = OPTIONC;
+ break;
+ case '\0': /* - means: read from stdin */
+ numberFilenames++;
+ break;
+ case 'n': /* needed for Posix, but no effect here */
+ if (mode != OPTIONB)
+ warn(OPTION_NOT_APPLICABLE, "n");
+ break;
+ default:
+ warn(UNKNOWN_OPTION, &(argv[i - 1][1]));
+ }
+ } else {
+ i++;
+ numberFilenames++;
+ }
+ }
+
+/* Here follow the checks, if the selected options are reasonable. */
+ if (mode == OPTIONB) /* since in Minix char := byte */
+ mode = OPTIONC;
+ get_args();
+ if (numberFilenames != 0) {
+ i = 1;
+ while (i < argc) {
+ if (argv[i][0] == '-') {
+ switch (argv[i][1]) {
+ case 'f':
+ case 'c':
+ case 'b':
+ case 'd':
+ i += 2;
+ break;
+ case 'n':
+ case 'i':
+ case 's':
+ i++;
+ break;
+ case '\0':
+ fd = stdin;
+ i++;
+ cut();
+ break;
+ default:
+ i++;
+ }
+ } else {
+ if ((fd = fopen(argv[i++], "r")) == NULL) {
+ warn(FILE_NOT_READABLE, argv[i - 1]);
+ } else {
+ cut();
+ fclose(fd);
+ }
+ }
+ }
+ } else {
+ fd = stdin;
+ cut();
+ }
+
+ exit(exit_status);
+}
+
+/* cut - extract columns from a file or stdin. Author: Michael J. Holme
+ *
+ * Copyright 1989, Michael John Holme, All rights reserved.
+ * This code may be freely distributed, provided that this notice
+ * remains intact.
+ *
+ * V1.1: 6th September 1989
+ *
+ * Bugs, criticisms, etc,
+ * c/o Mark Powell
+ * JANET sq79@uk.ac.liv
+ * ARPA sq79%liv.ac.uk@nsfnet-relay.ac.uk
+ * UUCP ...!mcvax!ukc!liv.ac.uk!sq79
+ *-------------------------------------------------------------------------
+ * Changed for POSIX1003.2/Draft10 conformance
+ * Thomas Brupbacher (tobr@mw.lpc.ethz.ch), September 1990.
+ * Changes:
+ * - separation of error messages ( stderr) and output (stdout).
+ * - support for -b and -n (no effect, -b acts as -c)
+ * - support for -s
+ *-------------------------------------------------------------------------
+ */
+
+/*
+ * Copyright (c) 1987,1997, Prentice Hall
+ * All rights reserved.
+ *
+ * Redistribution and use of the MINIX operating system in source and
+ * binary forms, with or without modification, are permitted provided
+ * that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * Neither the name of Prentice Hall nor the names of the software
+ * authors or contributors may be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS, AUTHORS, AND
+ * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL PRENTICE HALL OR ANY AUTHORS OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+
#include <stdio.h>
const char head_usage[] =
- "head [OPTION] [FILE]...\n\n"
- "Print first 10 lines of each FILE to standard output.\n"
+ "head [OPTION] [FILE]...\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nPrint first 10 lines of each FILE to standard output.\n"
"With more than one FILE, precede each with a header giving the\n"
"file name. With no FILE, or when FILE is -, read standard input.\n\n"
- "Options:\n" "\t-n NUM\t\tPrint first NUM lines instead of first 10\n";
+ "Options:\n" "\t-n NUM\t\tPrint first NUM lines instead of first 10\n"
+#endif
+ ;
int head(int len, FILE * src)
{
exit(0);
}
-/* $Id: head.c,v 1.9 2000/04/13 01:18:56 erik Exp $ */
+/* $Id: head.c,v 1.10 2000/05/12 19:41:47 erik Exp $ */
#include <sys/types.h>
static const char id_usage[] =
- "id [OPTIONS]... [USERNAME]\n\n"
- "Print information for USERNAME or the current user\n\n"
+ "id [OPTIONS]... [USERNAME]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nPrint information for USERNAME or the current user\n\n"
"\t-g\tprints only the group ID\n"
"\t-u\tprints only the user ID\n"
- "\t-r\tprints the real user ID instead of the effective ID (with -ug)\n\n";
+ "\t-r\tprints the real user ID instead of the effective ID (with -ug)\n\n"
+#endif
+ ;
extern int id_main(int argc, char **argv)
{
extern int length_main(int argc, char **argv)
{
if (argc != 2 || **(argv + 1) == '-') {
- usage("length string\n");
+ usage("length STRING\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nPrints out the length of the specified STRING.\n"
+#endif
+ );
}
printf("%lu\n", (long)strlen(argv[1]));
return (TRUE);
#include <errno.h>
static const char ln_usage[] =
- "ln [OPTION] TARGET... LINK_NAME|DIRECTORY\n\n"
- "Create a link named LINK_NAME or DIRECTORY to the specified TARGET\n\n"
+ "ln [OPTION] TARGET... LINK_NAME|DIRECTORY\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nCreate a link named LINK_NAME or DIRECTORY to the specified TARGET\n\n"
"Options:\n"
"\t-s\tmake symbolic links instead of hard links\n"
"\t-f\tremove existing destination files\n"
- "\t-n\tno dereference symlinks - treat like normal file\n";
+ "\t-n\tno dereference symlinks - treat like normal file\n"
+#endif
+ ;
static int symlinkFlag = FALSE;
static int removeoldFlag = FALSE;
#include "internal.h"
#include <stdio.h>
-static const char logname_usage[] = "logname\n\n"
-
- "Print the name of the current user.\n";
+static const char logname_usage[] = "logname\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nPrint the name of the current user.\n"
+#endif
+ ;
extern int logname_main(int argc, char **argv)
{
#ifdef BB_FEATURE_LS_FILETYPES
"F"
#endif
- "] [filenames...]\n\n"
+ "] [filenames...]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nList directory contents\n\n"
"Options:\n"
"\t-a\tdo not hide entries starting with .\n"
#ifdef BB_FEATURE_LS_TIMESTAMPS
"\t-C\tlist entries by columns\n"
#ifdef BB_FEATURE_LS_FILETYPES
"\t-F\tappend indicator (one of */=@|) to entries\n"
+#endif
#endif
;
#include <errno.h>
static const char mkdir_usage[] =
- "mkdir [OPTION] DIRECTORY...\n\n"
- "Create the DIRECTORY(ies), if they do not already exist\n\n"
+ "mkdir [OPTION] DIRECTORY...\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nCreate the DIRECTORY(ies), if they do not already exist\n\n"
"Options:\n"
"\t-m\tset permission mode (as in chmod), not rwxrwxrwx - umask\n"
- "\t-p\tno error if existing, make parent directories as needed\n";
+ "\t-p\tno error if existing, make parent directories as needed\n"
+#endif
+ ;
static int parentFlag = FALSE;
#include <sys/stat.h>
#include <errno.h>
-static const char mkfifo_usage[] = "mkfifo [OPTIONS] name\n\n"
- "Creates a named pipe (identical to 'mknod name p')\n\n"
-
+static const char mkfifo_usage[] = "mkfifo [OPTIONS] name\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nCreates a named pipe (identical to 'mknod name p')\n\n"
"Options:\n"
- "\t-m\tcreate the pipe using the specified mode (default a=rw)\n";
+ "\t-m\tcreate the pipe using the specified mode (default a=rw)\n"
+#endif
+ ;
extern int mkfifo_main(int argc, char **argv)
{
#include <fcntl.h>
#include <unistd.h>
-static const char mknod_usage[] = "mknod [OPTIONS] NAME TYPE MAJOR MINOR\n\n"
- "Create a special file (block, character, or pipe).\n\n"
+static const char mknod_usage[] = "mknod [OPTIONS] NAME TYPE MAJOR MINOR\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nCreate 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"
+#endif
+ ;
int mknod_main(int argc, char **argv)
{
/* The value to return to the calling program. */
static int exit_status;
-static const char printf_usage[] = "printf format [argument...]\n\nFormats and prints the given data.\n";
+static const char printf_usage[] = "printf FORMAT [ARGUMENT...]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nFormats and prints ARGUMENT(s) according to FORMAT,\n"
+ "Where FORMAT controls the output exactly as in C printf.\n"
+#endif
+ ;
int printf_main(int argc, char **argv)
{
#include "internal.h"
#include <stdio.h>
#include <dirent.h>
+#include <errno.h>
extern int pwd_main(int argc, char **argv)
{
char buf[BUFSIZ + 1];
- if (getcwd(buf, sizeof(buf)) == NULL) {
- perror("get working directory");
- exit(FALSE);
- }
+ if (getcwd(buf, sizeof(buf)) == NULL)
+ fatalError("pwd: %s", strerror(errno));
printf("%s\n", buf);
exit(TRUE);
#include <dirent.h>
#include <errno.h>
-static const char *rm_usage = "rm [OPTION]... FILE...\n\n"
- "Remove (unlink) the FILE(s).\n\n"
+static const char *rm_usage = "rm [OPTION]... FILE...\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nRemove (unlink) the FILE(s).\n\n"
"Options:\n"
-
"\t-f\t\tremove existing destinations, never prompt\n"
- "\t-r or -R\tremove the contents of directories recursively\n";
+ "\t-r or -R\tremove the contents of directories recursively\n"
+#endif
+ ;
static int recursiveFlag = FALSE;
{
if (argc == 1 || **(argv + 1) == '-') {
usage
- ("rmdir [OPTION]... DIRECTORY...\n\nRemove the DIRECTORY(ies), if they are empty.\n");
+ ("rmdir [OPTION]... DIRECTORY...\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nRemove the DIRECTORY(ies), if they are empty.\n"
+#endif
+ );
}
while (--argc > 0) {
#include "internal.h"
#include <stdio.h>
-const char sleep_usage[] = "sleep N\n\n" "Pause for N seconds.\n";
+const char sleep_usage[] = "sleep N\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nPause for N seconds.\n"
+#endif
+ ;
extern int sleep_main(int argc, char **argv)
{
#ifdef BB_FEATURE_SORT_REVERSE
" [-r]"
#endif
-" [FILE]...\n\nSorts lines of text in the specified files\n";
+" [FILE]...\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+"\nSorts lines of text in the specified files\n"
+#endif
+;
#ifdef BB_FEATURE_SORT_REVERSE
#define APPLY_REVERSE(x) (reverse ? -(x) : (x))
exit(0);
}
-/* $Id: sort.c,v 1.15 2000/04/17 04:22:09 beppu Exp $ */
+/* $Id: sort.c,v 1.16 2000/05/12 19:41:47 erik Exp $ */
extern int sync_main(int argc, char **argv)
{
if (argc > 1 && **(argv + 1) == '-') {
- usage("sync\n\nWrite all buffered filesystem blocks to disk.\n");
+ usage("sync\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nWrite all buffered filesystem blocks to disk.\n"
+#endif
+ );
}
exit(sync());
}
#include <sys/stat.h>
#include <fcntl.h>
#include <ctype.h>
+#define BB_DECLARE_EXTERN
+#define bb_need_help
+#include "messages.c"
#define XWRITE(fd, buffer, n_bytes) \
static int print_headers;
const char tail_usage[] =
- "tail [OPTION] [FILE]...\n\n"
- "Print last 10 lines of each FILE to standard output.\n"
+ "tail [OPTION] [FILE]...\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nPrint last 10 lines of each FILE to standard output.\n"
"With more than one FILE, precede each with a header giving the\n"
"file name. With no FILE, or when FILE is -, read standard input.\n\n"
"Options:\n"
"\t-n NUM\t\tPrint last NUM lines instead of first 10\n"
"\t-f\t\tOutput data as the file grows. This version\n"
- "\t\t\tof 'tail -f' supports only one file at a time.\n";
+ "\t\t\tof 'tail -f' supports only one file at a time.\n"
+#endif
+ ;
static void write_header(const char *filename)
static int have_read_stdin;
-static const char tail_usage[] = "tail [OPTION]... [FILE]...\n\
-\n\
-Print last 10 lines of each FILE to standard output.\n\
+static const char tail_usage[] = "tail [OPTION]... [FILE]...\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+"\nPrint last 10 lines of each FILE to standard output.\n\
With more than one FILE, precede each with a header giving the file name.\n\
With no FILE, or when FILE is -, read standard input.\n\
\n\
-n=N output the last N lines, instead of last 10\n\
-q never output headers giving file names\n\
-v always output headers giving file names\n\
- --help display this help and exit\n\
\n\
If the first character of N (bytes or lines) is a `+', output begins with \n\
the Nth item from the start of each file, otherwise, print the last N items\n\
-in the file. N bytes may be suffixed by k (x1024), b (x512), or m (1024^2).\n\n";
+in the file. N bytes may be suffixed by k (x1024), b (x512), or m (1024^2).\n"
+#endif
+;
static void write_header(const char *filename, const char *comment)
{
#include <stdio.h>
static const char tee_usage[] =
- "tee [OPTION]... [FILE]...\n\n"
- "Copy standard input to each FILE, and also to standard output.\n\n"
+ "tee [OPTION]... [FILE]...\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nCopy standard input to each FILE, and also to standard output.\n\n"
"Options:\n" "\t-a\tappend to the given FILEs, do not overwrite\n"
#if 0
"\t-i\tignore interrupt signals\n"
#endif
+#endif
;
exit(0);
}
-/* $Id: tee.c,v 1.9 2000/04/13 01:18:56 erik Exp $ */
+/* $Id: tee.c,v 1.10 2000/05/12 19:41:47 erik Exp $ */
#include <errno.h>
#include <stdlib.h>
#include <string.h>
+#define BB_DECLARE_EXTERN
+#define bb_need_help
+#include "messages.c"
/* test(1) accepts the following grammar:
oexpr ::= aexpr | aexpr "-o" oexpr ;
fatalError("missing ]");
argv[argc] = NULL;
}
- if (strcmp(argv[1], "--help") == 0) {
+ if (strcmp(argv[1], dash_dash_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");
+ "or [ EXPRESSION ]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nChecks file types and compares values returning an exit\n"
+ "code determined by the value of EXPRESSION.\n"
+#endif
+ );
}
/* Implement special cases from POSIX.2, section 4.62.4 */
#include <errno.h>
-static const char touch_usage[] = "touch [-c] file [file ...]\n\n"
-
- "Update the last-modified date on the given file[s].\n";
+static const char touch_usage[] = "touch [-c] file [file ...]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nUpdate the last-modified date on the given file[s].\n"
+#endif
+ ;
#include <stdio.h>
#include <sys/types.h>
-static const char tty_usage[] = "tty\n\n"
- "Print the file name of the terminal connected to standard input.\n\n"
+static const char tty_usage[] = "tty\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nPrint the file name of the terminal connected to standard input.\n\n"
"Options:\n"
- "\t-s\tprint nothing, only return an exit status\n";
+ "\t-s\tprint nothing, only return an exit status\n"
+#endif
+ ;
extern int tty_main(int argc, char **argv)
{
#include <errno.h>
static const char uniq_usage[] =
- "uniq [OPTION]... [INPUT [OUTPUT]]\n\n"
- "Discard all but one of successive identical lines from INPUT\n"
- "(or standard input), writing to OUTPUT (or standard output).\n";
+ "uniq [OPTION]... [INPUT [OUTPUT]]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nDiscard all but one of successive identical lines from INPUT\n"
+ "(or standard input), writing to OUTPUT (or standard output).\n"
+#endif
+ ;
/* max chars in line */
#define UNIQ_MAX 4096
exit(0);
}
-/* $Id: uniq.c,v 1.9 2000/04/17 16:16:10 erik Exp $ */
+/* $Id: uniq.c,v 1.10 2000/05/12 19:41:47 erik Exp $ */
#include <stdlib.h>
#include <unistd.h>
-const char usleep_usage[] = "usleep N\n\n" "Pause for N microseconds.\n";
+const char usleep_usage[] = "usleep N\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nPause for N microseconds.\n"
+#endif
+ ;
extern int usleep_main(int argc, char **argv)
{
#include "internal.h"
#include <stdio.h>
-static const char wc_usage[] = "wc [OPTION]... [FILE]...\n\n"
- "Print line, word, and byte counts for each FILE, and a total line if\n"
+static const char wc_usage[] = "wc [OPTION]... [FILE]...\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nPrint line, word, and byte counts for each FILE, and a total line if\n"
"more than one FILE is specified. With no FILE, read standard input.\n\n"
"Options:\n"
"\t-c\tprint the byte counts\n"
"\t-l\tprint the newline counts\n"
"\t-L\tprint the length of the longest line\n"
- "\t-w\tprint the word counts\n";
+ "\t-w\tprint the word counts\n"
+#endif
+ ;
static int total_lines, total_words, total_chars, max_length;
static int print_lines, print_words, print_chars, print_length;
#include <stdio.h>
#include <pwd.h>
-static const char whoami_usage[] = "whoami\n\n"
- "Prints the user name associated with the current effective user id.\n";
+static const char whoami_usage[] = "whoami\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nPrints the user name associated with the current effective user id.\n"
+#endif
+ ;
extern int whoami_main(int argc, char **argv)
{
int i;
if (argc >=1 && *argv[1]=='-') {
- usage("yes [OPTION]... [STRING]...\n\n"
- "Repeatedly outputs a line with all specified STRING(s), or `y'.\n");
+ usage("yes [OPTION]... [STRING]...\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nRepeatedly outputs a line with all specified STRING(s), or `y'.\n"
+#endif
+ );
}
if (argc == 1) {
--- /dev/null
+/* vi: set sw=4 ts=4: */
+/*
+ * cut implementation for busybox
+ *
+ * Copyright (c) Michael J. Holme
+ *
+ * This version of cut is adapted from Minix cut and was modified
+ * by Erik Andersen <andersee@debian.org> to be used in busybox.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Original copyright notice is retained at the end of this file.
+ */
+
+#include "internal.h"
+#include <sys/types.h>
+#include <ctype.h>
+#include <string.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <stdio.h>
+#define BB_DECLARE_EXTERN
+#define bb_need_help
+#include "messages.c"
+
+#define MAX_FIELD 80 /* Pointers to the beginning of each field
+ * are stored in columns[], if a line holds
+ * more than MAX_FIELD columns the array
+ * boundary is exceed. But unlikely at 80 */
+
+#define MAX_ARGS 32 /* Maximum number of fields following -f or
+ * -c switches */
+int args[MAX_ARGS * 2];
+int num_args;
+
+/* Lots of new defines, should easen maintainance... */
+#define DUMP_STDIN 0 /* define for mode: no options */
+#define OPTIONF 1 /* define for mode: option -f */
+#define OPTIONC 2 /* define for mode: option -c */
+#define OPTIONB 3 /* define for mode: option -b */
+#define NOTSET 0 /* option not selected */
+#define SET 1 /* option selected */
+
+/* Defines for the warnings */
+#define DELIMITER_NOT_APPLICABLE 0
+#define OVERRIDING_PREVIOUS_MODE 1
+#define OPTION_NOT_APPLICABLE 2
+#define UNKNOWN_OPTION 3
+#define FILE_NOT_READABLE 4
+
+/* Defines for the fatal errors */
+#define SYNTAX_ERROR 101
+#define POSITION_ERROR 102
+#define LINE_TO_LONG_ERROR 103
+#define RANGE_ERROR 104
+#define MAX_FIELDS_EXEEDED_ERROR 105
+#define MAX_ARGS_EXEEDED_ERROR 106
+
+
+int mode; /* 0 = dump stdin to stdout, 1=-f, 2=-c */
+char delim = '\t'; /* default delimiting character */
+FILE *fd;
+char *name;
+char line[BUFSIZ];
+int exit_status;
+
+int cut_main(int argc, char **argv);
+void warn(int warn_number, char *option);
+void cuterror(int err);
+void get_args(void);
+void cut(void);
+
+void warn(int warn_number, char *option)
+{
+ static char *warn_msg[] = {
+ "%s: Option -d allowed only with -f\n",
+ "%s: -%s overrides earlier option\n",
+ "%s: -%s not allowed in current mode\n",
+ "%s: Cannot open %s\n"
+ };
+
+ fprintf(stderr, warn_msg[warn_number], name, option);
+ exit_status = warn_number + 1;
+
+}
+
+void cuterror(int err)
+{
+ static char *err_mes[] = {
+ "%s: syntax error\n",
+ "%s: position must be >0\n",
+ "%s: line longer than BUFSIZ\n",
+ "%s: range must not decrease from left to right\n",
+ "%s: MAX_FIELD exceeded\n",
+ "%s: MAX_ARGS exceeded\n"
+ };
+
+ fprintf(stderr, err_mes[err - 101], name);
+ exit(err);
+}
+
+
+void get_args()
+{
+ int i = 0;
+ int arg_ptr = 0;
+ int flag;
+
+ num_args = 0;
+ do {
+ if (num_args == MAX_ARGS)
+ cuterror(MAX_ARGS_EXEEDED_ERROR);
+ if (!isdigit(line[i]) && line[i] != '-')
+ cuterror(SYNTAX_ERROR);
+
+ args[arg_ptr] = 1;
+ args[arg_ptr + 1] = BUFSIZ;
+ flag = 1;
+
+ while (line[i] != ',' && line[i] != 0) {
+ if (isdigit(line[i])) {
+ args[arg_ptr] = 0;
+ while (isdigit(line[i]))
+ args[arg_ptr] = 10 * args[arg_ptr] + line[i++] - '0';
+ if (!args[arg_ptr])
+ cuterror(POSITION_ERROR);
+ arg_ptr++;
+ }
+ if (line[i] == '-') {
+ arg_ptr |= 1;
+ i++;
+ flag = 0;
+ }
+ }
+ if (flag && arg_ptr & 1)
+ args[arg_ptr] = args[arg_ptr - 1];
+ if (args[num_args * 2] > args[num_args * 2 + 1])
+ cuterror(RANGE_ERROR);
+ num_args++;
+ arg_ptr = num_args * 2;
+ }
+ while (line[i++]);
+}
+
+
+void cut()
+{
+ int i, j, length, maxcol=0;
+ char *columns[MAX_FIELD];
+
+ while (fgets(line, BUFSIZ, fd)) {
+ length = strlen(line) - 1;
+ *(line + length) = 0;
+ switch (mode) {
+ case DUMP_STDIN:
+ printf("%s", line);
+ break;
+ case OPTIONF:
+ columns[maxcol++] = line;
+ for (i = 0; i < length; i++) {
+ if (*(line + i) == delim) {
+ *(line + i) = 0;
+ if (maxcol == MAX_FIELD)
+ cuterror(MAX_FIELDS_EXEEDED_ERROR);
+ columns[maxcol] = line + i + 1;
+ maxcol++;
+ }
+ }
+ if (maxcol != 1) {
+ for (i = 0; i < num_args; i++) {
+ for (j = args[i * 2]; j <= args[i * 2 + 1]; j++)
+ if (j <= maxcol) {
+ printf("%s", columns[j - 1]);
+ if (i != num_args - 1 || j != args[i * 2 + 1])
+ putchar(delim);
+ }
+ }
+ }
+ break;
+ case OPTIONC:
+ for (i = 0; i < num_args; i++) {
+ for (j = args[i * 2];
+ j <= (args[i * 2 + 1] >
+ length ? length : args[i * 2 + 1]); j++)
+ putchar(*(line + j - 1));
+ }
+ }
+ if (maxcol != 1)
+ putchar('\n');
+ }
+}
+
+
+int cut_main(int argc, char **argv)
+{
+ int i = 1;
+ int numberFilenames = 0;
+
+ name = argv[0];
+
+ if (argc == 1 || strcmp(argv[1], dash_dash_help)==0)
+ usage( "cut [OPTION]... [FILE]...\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nPrints selected fields from each input FILE to standard output.\n\n"
+ "Options:\n"
+ "\t-b LIST\tOutput only bytes from LIST\n"
+ "\t-c LIST\tOutput only characters from LIST\n"
+ "\t-d DELIM\tUse DELIM instead of tab as the field delimiter\n"
+ "\t-f N\tPrint only these fields\n"
+ "\t-n\tIgnored\n"
+#endif
+ );
+
+ while (i < argc) {
+ if (argv[i][0] == '-') {
+ switch (argv[i++][1]) {
+ case 'd':
+ if (mode == OPTIONC || mode == OPTIONB)
+ warn(DELIMITER_NOT_APPLICABLE, "d");
+ delim = argv[i++][0];
+ break;
+ case 'f':
+ sprintf(line, "%s", argv[i++]);
+ if (mode == OPTIONC || mode == OPTIONB)
+ warn(OVERRIDING_PREVIOUS_MODE, "f");
+ mode = OPTIONF;
+ break;
+ case 'b':
+ sprintf(line, "%s", argv[i++]);
+ if (mode == OPTIONF || mode == OPTIONC)
+ warn(OVERRIDING_PREVIOUS_MODE, "b");
+ mode = OPTIONB;
+ break;
+ case 'c':
+ sprintf(line, "%s", argv[i++]);
+ if (mode == OPTIONF || mode == OPTIONB)
+ warn(OVERRIDING_PREVIOUS_MODE, "c");
+ mode = OPTIONC;
+ break;
+ case '\0': /* - means: read from stdin */
+ numberFilenames++;
+ break;
+ case 'n': /* needed for Posix, but no effect here */
+ if (mode != OPTIONB)
+ warn(OPTION_NOT_APPLICABLE, "n");
+ break;
+ default:
+ warn(UNKNOWN_OPTION, &(argv[i - 1][1]));
+ }
+ } else {
+ i++;
+ numberFilenames++;
+ }
+ }
+
+/* Here follow the checks, if the selected options are reasonable. */
+ if (mode == OPTIONB) /* since in Minix char := byte */
+ mode = OPTIONC;
+ get_args();
+ if (numberFilenames != 0) {
+ i = 1;
+ while (i < argc) {
+ if (argv[i][0] == '-') {
+ switch (argv[i][1]) {
+ case 'f':
+ case 'c':
+ case 'b':
+ case 'd':
+ i += 2;
+ break;
+ case 'n':
+ case 'i':
+ case 's':
+ i++;
+ break;
+ case '\0':
+ fd = stdin;
+ i++;
+ cut();
+ break;
+ default:
+ i++;
+ }
+ } else {
+ if ((fd = fopen(argv[i++], "r")) == NULL) {
+ warn(FILE_NOT_READABLE, argv[i - 1]);
+ } else {
+ cut();
+ fclose(fd);
+ }
+ }
+ }
+ } else {
+ fd = stdin;
+ cut();
+ }
+
+ exit(exit_status);
+}
+
+/* cut - extract columns from a file or stdin. Author: Michael J. Holme
+ *
+ * Copyright 1989, Michael John Holme, All rights reserved.
+ * This code may be freely distributed, provided that this notice
+ * remains intact.
+ *
+ * V1.1: 6th September 1989
+ *
+ * Bugs, criticisms, etc,
+ * c/o Mark Powell
+ * JANET sq79@uk.ac.liv
+ * ARPA sq79%liv.ac.uk@nsfnet-relay.ac.uk
+ * UUCP ...!mcvax!ukc!liv.ac.uk!sq79
+ *-------------------------------------------------------------------------
+ * Changed for POSIX1003.2/Draft10 conformance
+ * Thomas Brupbacher (tobr@mw.lpc.ethz.ch), September 1990.
+ * Changes:
+ * - separation of error messages ( stderr) and output (stdout).
+ * - support for -b and -n (no effect, -b acts as -c)
+ * - support for -s
+ *-------------------------------------------------------------------------
+ */
+
+/*
+ * Copyright (c) 1987,1997, Prentice Hall
+ * All rights reserved.
+ *
+ * Redistribution and use of the MINIX operating system in source and
+ * binary forms, with or without modification, are permitted provided
+ * that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * Neither the name of Prentice Hall nor the names of the software
+ * authors or contributors may be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS, AUTHORS, AND
+ * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL PRENTICE HALL OR ANY AUTHORS OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+
Usage: free
-Displays the amount of free and used memory in the system.
+Displays the amount of free and used system memory.
Example:
Usage: freeramdisk DEVICE
-Free all memory used by the specified ramdisk.
+Frees all memory used by the specified ramdisk.
Example:
=item length
-Usage: length string
+Usage: length STRING
-Prints out the length of the specified string.
+Prints out the length of the specified STRING.
Example:
-t fs-type: Specify the filesystem type.
-w: Mount for reading and writing (default).
-Options for use with the "-o" flag:
+Options for use with the "B<-o>" flag:
async/sync: Writes are asynchronous / synchronous.
atime/noatime: Enable / disable updates to inode access times.
=cut
-# $Id: busybox.pod,v 1.29 2000/05/10 05:00:31 erik Exp $
+# $Id: busybox.pod,v 1.30 2000/05/12 19:41:47 erik Exp $
#include <ctype.h>
static const char sed_usage[] =
- "sed [-n] -e script [file...]\n\n"
- "Allowed sed scripts come in the following form:\n"
+ "sed [-n] -e script [file...]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nAllowed sed scripts come in the following form:\n"
"\t'ADDR [!] COMMAND'\n\n"
"\twhere address ADDR can be:\n"
"\t NUMBER Match specified line number\n"
#if defined BB_REGEXP
"This version of sed matches full regular expresions.\n";
#else
- "This version of sed matches strings (not full regular expresions).\n";
+ "This version of sed matches strings (not full regular expresions).\n"
#endif
+#endif
+ ;
/* Flags & variables */
"-vsync", 1, CMD_VSYNC}, {
"-laced", 1, CMD_LACED}, {
"-double", 1, CMD_DOUBLE}, {
- "--help", 0, CMD_HELP}, {
+ "-help", 0, CMD_HELP}, {
#ifdef BB_FEATURE_FBSET_FANCY
- "--help", 0, CMD_HELP}, {
+ "-help", 0, CMD_HELP}, {
"-all", 0, CMD_ALL}, {
"-xres", 1, CMD_XRES}, {
"-yres", 1, CMD_YRES}, {
"-vyres", 1, CMD_VYRES}, {
"-depth", 1, CMD_DEPTH}, {
"-match", 0, CMD_MATCH}, {
- "--geometry", 5, CMD_GEOMETRY}, {
+ "-geometry", 5, CMD_GEOMETRY}, {
"-pixclock", 1, CMD_PIXCLOCK}, {
"-left", 1, CMD_LEFT}, {
"-right", 1, CMD_RIGHT}, {
"-lower", 1, CMD_LOWER}, {
"-hslen", 1, CMD_HSLEN}, {
"-vslen", 1, CMD_VSLEN}, {
- "--timings", 7, CMD_TIMING}, {
+ "-timings", 7, CMD_TIMING}, {
"-csync", 1, CMD_CSYNC}, {
"-gsync", 1, CMD_GSYNC}, {
"-extsync", 1, CMD_EXTSYNC}, {
static void fbset_usage(void)
{
+#ifndef BB_FEATURE_TRIVIAL_HELP
int i;
+#endif
#ifndef STANDALONE
fprintf(stderr, "BusyBox v%s (%s) multi-call binary -- GPL2\n\n",
BB_VER, BB_BT);
#endif
- fprintf(stderr, "Usage: fbset [options] [mode]\n\n");
- fprintf(stderr, "Show and modify frame buffer device settings\n\n");
+ fprintf(stderr, "Usage: fbset [options] [mode]\n");
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ fprintf(stderr, "\nShows and modifies frame buffer device settings\n\n");
fprintf(stderr, "The following options are recognized:\n");
for (i = 0; g_cmdoptions[i].name; i++)
fprintf(stderr, "\t%s\n", g_cmdoptions[i].name);
+#endif
exit(-1);
}
int fd;
if (argc <= 1 || **(++argv) == '-') {
- usage("fdflush device\n\nForce floppy disk drive to detect disk change\n");
+ usage("fdflush DEVICE\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nForces floppy disk drive to detect disk change\n"
+#endif
+ );
}
fd = open(*argv, 0);
static char *directory = ".";
static int dereferenceFlag = FALSE;
-static const char find_usage[] = "find [PATH...] [EXPRESSION]\n\n"
- "Search for files in a directory hierarchy. The default PATH is\n"
+static const char find_usage[] = "find [PATH...] [EXPRESSION]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nSearch for files in a directory hierarchy. The default PATH is\n"
"the current directory; default EXPRESSION is '-print'\n\n"
"\nEXPRESSION may consist of:\n"
"\t-follow\t\tDereference symbolic links.\n"
"\t-name PATTERN\tFile name (leading directories removed) matches PATTERN.\n"
- "\t-print\t\tprint the full file name followed by a newline to stdout.\n";
+ "\t-print\t\tprint the full file name followed by a newline to stdout.\n"
+#endif
+ ;
static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
static char *directory = ".";
static int dereferenceFlag = FALSE;
-static const char find_usage[] = "find [PATH...] [EXPRESSION]\n\n"
- "Search for files in a directory hierarchy. The default PATH is\n"
+static const char find_usage[] = "find [PATH...] [EXPRESSION]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nSearch for files in a directory hierarchy. The default PATH is\n"
"the current directory; default EXPRESSION is '-print'\n\n"
"\nEXPRESSION may consist of:\n"
"\t-follow\t\tDereference symbolic links.\n"
"\t-name PATTERN\tFile name (leading directories removed) matches PATTERN.\n"
- "\t-print\t\tprint the full file name followed by a newline to stdout.\n";
+ "\t-print\t\tprint the full file name followed by a newline to stdout.\n"
+#endif
+ ;
static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
#include <ctype.h>
static const char grep_usage[] =
- "grep [OPTIONS]... PATTERN [FILE]...\n\n"
- "Search for PATTERN in each FILE or standard input.\n\n"
+ "grep [OPTIONS]... PATTERN [FILE]...\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nSearch for PATTERN in each FILE or standard input.\n\n"
"OPTIONS:\n"
"\t-h\tsuppress the prefixing filename on output\n"
"\t-i\tignore case distinctions\n"
#if defined BB_REGEXP
"This version of grep matches full regular expresions.\n";
#else
- "This version of grep matches strings (not regular expresions).\n";
+ "This version of grep matches strings (not regular expresions).\n"
#endif
+#endif
+ ;
static int match = FALSE, beQuiet = FALSE;
info.sharedram/=DIVISOR;
info.bufferram/=DIVISOR;
+ if (argc > 1 && **(argv + 1) == '-') {
+ usage("free\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nDisplays the amount of free and used system memory\n"
+#endif
+ );
+ }
+
printf("%6s%13s%13s%13s%13s%13s\n", "", "total", "used", "free",
"shared", "buffers");
static const char freeramdisk_usage[] =
- "freeramdisk DEVICE\n\n"
- "Free all memory used by the specified ramdisk.\n";
+ "freeramdisk DEVICE\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nFrees all memory used by the specified ramdisk.\n"
+#endif
+ ;
extern int
freeramdisk_main(int argc, char **argv)
{
fprintf(stderr, "BusyBox v%s (%s) multi-call binary -- GPL2\n\n",
BB_VER, BB_BT);
- fprintf(stderr, "Usage: %s [-larvsmf] /dev/name\n\n", program_name);
+ fprintf(stderr, "Usage: %s [-larvsmf] /dev/name\n", program_name);
+#ifndef BB_FEATURE_TRIVIAL_HELP
fprintf(stderr,
- "Performs a consistency check for MINIX filesystems.\n\n");
+ "\nPerforms a consistency check for MINIX filesystems.\n\n");
fprintf(stderr, "OPTIONS:\n");
fprintf(stderr, "\t-l\tLists all filenames\n");
fprintf(stderr, "\t-r\tPerform interactive repairs\n");
fprintf(stderr,
"\t-m\tActivates MINIX-like \"mode not cleared\" warnings\n");
fprintf(stderr, "\t-f\tForce file system check.\n\n");
+#endif
leave(16);
}
#include <ctype.h>
static const char grep_usage[] =
- "grep [OPTIONS]... PATTERN [FILE]...\n\n"
- "Search for PATTERN in each FILE or standard input.\n\n"
+ "grep [OPTIONS]... PATTERN [FILE]...\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nSearch for PATTERN in each FILE or standard input.\n\n"
"OPTIONS:\n"
"\t-h\tsuppress the prefixing filename on output\n"
"\t-i\tignore case distinctions\n"
#if defined BB_REGEXP
"This version of grep matches full regular expresions.\n";
#else
- "This version of grep matches strings (not regular expresions).\n";
+ "This version of grep matches strings (not regular expresions).\n"
#endif
+#endif
+ ;
static int match = FALSE, beQuiet = FALSE;
*/
#include "internal.h"
+
static const char gunzip_usage[] =
- "gunzip [OPTION]... FILE\n\n"
- "Uncompress FILE (or standard input if FILE is '-').\n\n"
+ "gunzip [OPTION]... FILE\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nUncompress FILE (or standard input if FILE is '-').\n\n"
"Options:\n"
"\t-c\tWrite output to standard output\n"
- "\t-t\tTest compressed file integrity\n";
+ "\t-t\tTest compressed file integrity\n"
+#endif
+ ;
/* These defines are very important for BusyBox. Without these,
#define SMALL_MEM
#define DYN_ALLOC
-#define bb_need_name_too_long
#define BB_DECLARE_EXTERN
+#define bb_need_memory_exhausted
+#define bb_need_name_too_long
#include "messages.c"
# define DECLARE(type, array, size) type * array
# define ALLOC(type, array, size) { \
array = (type*)calloc((size_t)(((size)+1L)/2), 2*sizeof(type)); \
- if (array == NULL) errorMsg("insufficient memory"); \
+ if (array == NULL) errorMsg(memory_exhausted, "gunzip"); \
}
# define FREE(array) {if (array != NULL) free(array), array=NULL;}
#else
int res = inflate();
if (res == 3) {
- errorMsg("out of memory");
+ errorMsg(memory_exhausted, "gunzip");
} else if (res != 0) {
errorMsg("invalid compressed data--format violated");
}
*/
#include "internal.h"
+#define BB_DECLARE_EXTERN
+#define bb_need_memory_exhausted
+#include "messages.c"
/* These defines are very important for BusyBox. Without these,
* huge chunks of ram are pre-allocated making the BusyBox bss
static const char gzip_usage[] =
- "gzip [OPTION]... FILE\n\n"
- "Compress FILE with maximum compression.\n"
+ "gzip [OPTION]... FILE\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nCompress FILE with maximum compression.\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";
+ "\t-c\tWrite output to standard output instead of FILE.gz\n"
+#endif
+ ;
/* I don't like nested includes, but the string and io functions are used
# define DECLARE(type, array, size) type * array
# define ALLOC(type, array, size) { \
array = (type*)calloc((size_t)(((size)+1L)/2), 2*sizeof(type)); \
- if (array == NULL) errorMsg("insufficient memory"); \
+ if (array == NULL) errorMsg(memory_exhausted, "gzip"); \
}
# define FREE(array) {if (array != NULL) free(array), array=NULL;}
#else
long time_stamp; /* original time stamp (modification time) */
long ifile_size; /* input file size, -1 for devices (debug only) */
char *env; /* contents of GZIP env variable */
-char **args = NULL; /* argv pointer if GZIP env variable defined */
char z_suffix[MAX_SUFFIX + 1]; /* default suffix (can be set with --suffix) */
int z_len; /* strlen(z_suffix) */
nargv = (char **) calloc(*argcp + 1, sizeof(char *));
if (nargv == NULL)
- errorMsg("out of memory");
+ errorMsg(memory_exhausted, "gzip");
oargv = *argvp;
*argvp = nargv;
#include <stdio.h>
const char head_usage[] =
- "head [OPTION] [FILE]...\n\n"
- "Print first 10 lines of each FILE to standard output.\n"
+ "head [OPTION] [FILE]...\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nPrint first 10 lines of each FILE to standard output.\n"
"With more than one FILE, precede each with a header giving the\n"
"file name. With no FILE, or when FILE is -, read standard input.\n\n"
- "Options:\n" "\t-n NUM\t\tPrint first NUM lines instead of first 10\n";
+ "Options:\n" "\t-n NUM\t\tPrint first NUM lines instead of first 10\n"
+#endif
+ ;
int head(int len, FILE * src)
{
exit(0);
}
-/* $Id: head.c,v 1.9 2000/04/13 01:18:56 erik Exp $ */
+/* $Id: head.c,v 1.10 2000/05/12 19:41:47 erik Exp $ */
/* vi: set sw=4 ts=4: */
/*
- * $Id: hostname.c,v 1.7 2000/02/08 19:58:47 erik Exp $
+ * $Id: hostname.c,v 1.8 2000/05/12 19:41:47 erik Exp $
* Mini hostname implementation for busybox
*
* Copyright (C) 1999 by Randolph Chung <tausq@debian.org>
#include <stdio.h>
static const char *hostname_usage =
- "hostname [OPTION] {hostname | -F file}\n\n"
- "Get or set the hostname or DNS domain name. If a hostname is given\n"
+ "hostname [OPTION] {hostname | -F file}\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nGet or set the hostname or DNS domain name. If a hostname is given\n"
"(or a file with the -F parameter), the host name will be set.\n\n"
"Options:\n"
"\t-s\t\tShort\n"
"\t-i\t\tAddresses for the hostname\n"
"\t-d\t\tDNS domain name\n"
- "\t-F FILE\t\tUse the contents of FILE to specify the hostname\n";
+ "\t-F FILE\t\tUse the contents of FILE to specify the hostname\n"
+#endif
+ ;
void do_sethostname(char *s, int isfile)
#include <sys/types.h>
static const char id_usage[] =
- "id [OPTIONS]... [USERNAME]\n\n"
- "Print information for USERNAME or the current user\n\n"
+ "id [OPTIONS]... [USERNAME]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nPrint information for USERNAME or the current user\n\n"
"\t-g\tprints only the group ID\n"
"\t-u\tprints only the user ID\n"
- "\t-r\tprints the real user ID instead of the effective ID (with -ug)\n\n";
+ "\t-r\tprints the real user ID instead of the effective ID (with -ug)\n\n"
+#endif
+ ;
extern int id_main(int argc, char **argv)
{
static char m_filename[BUFSIZ + 1] = "\0";
static char m_fullName[BUFSIZ + 1] = "\0";
static const char insmod_usage[] =
- "insmod [OPTION]... MODULE [symbol=value]...\n\n"
- "Loads the specified kernel modules into the kernel.\n\n"
+ "insmod [OPTION]... MODULE [symbol=value]...\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nLoads the specified kernel modules into the kernel.\n\n"
"Options:\n"
"\t-f\tForce module to load into the wrong kernel version.\n"
- "\t-k\tMake module autoclean-able.\n";
+ "\t-k\tMake module autoclean-able.\n"
+#endif
+ ;
static int findNamedModule(const char *fileName, struct stat *statbuf)
extern int busybox_main(int argc, char** argv);
extern int block_device_main(int argc, char** argv);
extern int cat_main(int argc, char** argv);
-extern int cp_mv_main(int argc, char** argv);
extern int chmod_chown_chgrp_main(int argc, char** argv);
extern int chroot_main(int argc, char** argv);
extern int chvt_main(int argc, char** argv);
extern int clear_main(int argc, char** argv);
+extern int cp_mv_main(int argc, char** argv);
+extern int cut_main(int argc, char** argv);
extern int date_main(int argc, char** argv);
extern int dd_main(int argc, char** argv);
extern int dirname_main(int argc, char** argv);
extern int mknod_main(int argc, char** argv);
extern int mkswap_main(int argc, char** argv);
extern int mktemp_main(int argc, char **argv);
-extern int mnc_main(int argc, char** argv);
+extern int nc_main(int argc, char** argv);
extern int more_main(int argc, char** argv);
extern int mount_main(int argc, char** argv);
extern int mt_main(int argc, char** argv);
#include <unistd.h>
static const char *kill_usage =
- "kill [-signal] process-id [process-id ...]\n\n"
- "Send a signal (default is SIGTERM) to the specified process(es).\n\n"
- "Options:\n" "\t-l\tList all signal names and numbers.\n\n";
+ "kill [-signal] process-id [process-id ...]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nSend a signal (default is SIGTERM) to the specified process(es).\n\n"
+ "Options:\n" "\t-l\tList all signal names and numbers.\n\n"
+#endif
+ ;
#ifdef BB_KILLALL
static const char *killall_usage =
- "killall [-signal] process-name [process-name ...]\n\n"
- "Send a signal (default is SIGTERM) to the specified process(es).\n\n"
- "Options:\n" "\t-l\tList all signal names and numbers.\n\n";
+ "killall [-signal] process-name [process-name ...]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nSend a signal (default is SIGTERM) to the specified process(es).\n\n"
+ "Options:\n" "\t-l\tList all signal names and numbers.\n\n"
+#endif
#endif
+ ;
#define KILL 0
#define KILLALL 1
static const char shell_usage[] =
- "sh [FILE]...\n\n" "The BusyBox command interpreter (shell).\n\n";
-
+ "sh [FILE]...\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nlash: The BusyBox command interpreter (shell).\n\n"
+#endif
+ ;
static char cwd[1024];
static char *prompt = "# ";
extern int length_main(int argc, char **argv)
{
if (argc != 2 || **(argv + 1) == '-') {
- usage("length string\n");
+ usage("length STRING\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nPrints out the length of the specified STRING.\n"
+#endif
+ );
}
printf("%lu\n", (long)strlen(argv[1]));
return (TRUE);
#include <errno.h>
static const char ln_usage[] =
- "ln [OPTION] TARGET... LINK_NAME|DIRECTORY\n\n"
- "Create a link named LINK_NAME or DIRECTORY to the specified TARGET\n\n"
+ "ln [OPTION] TARGET... LINK_NAME|DIRECTORY\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nCreate a link named LINK_NAME or DIRECTORY to the specified TARGET\n\n"
"Options:\n"
"\t-s\tmake symbolic links instead of hard links\n"
"\t-f\tremove existing destination files\n"
- "\t-n\tno dereference symlinks - treat like normal file\n";
+ "\t-n\tno dereference symlinks - treat like normal file\n"
+#endif
+ ;
static int symlinkFlag = FALSE;
static int removeoldFlag = FALSE;
#include <sys/ioctl.h>
#include <sys/kd.h>
-static const char loadacm_usage[] = "loadacm\n\n"
- "Loads an acm from standard input.\n";
+static const char loadacm_usage[] = "loadacm\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nLoads an acm from standard input.\n"
+#endif
+ ;
typedef unsigned short unicode;
#define PSF_MAXMODE 0x03
#define PSF_SEPARATOR 0xFFFF
-static const char loadfont_usage[] = "loadfont\n\n"
- "Loads a console font from standard input.\n";
+static const char loadfont_usage[] = "loadfont\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "Loads a console font from standard input.\n"
+#endif
+ ;
struct psf_header {
unsigned char magic1, magic2; /* Magic number */
#include <sys/ioctl.h>
-static const char loadkmap_usage[] = "loadkmap\n\n"
- "Loads a binary keyboard translation table from standard input.\n";
+static const char loadkmap_usage[] = "loadkmap\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "Loads a binary keyboard translation table from standard input.\n"
+#endif
+ ;
int loadkmap_main(int argc, char **argv)
#endif
static const char logger_usage[] =
- "logger [OPTION]... [MESSAGE]\n\n"
- "Write MESSAGE to the system log. If MESSAGE is '-', log stdin.\n\n"
+ "logger [OPTION]... [MESSAGE]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nWrite MESSAGE to the system log. If MESSAGE is '-', log stdin.\n\n"
"Options:\n"
"\t-s\tLog to stderr as well as the system log.\n"
"\t-t\tLog using the specified tag (defaults to user name).\n"
"\t-p\tEnter the message with the specified priority.\n"
- "\t\tThis may be numerical or a ``facility.level'' pair.\n";
+ "\t\tThis may be numerical or a ``facility.level'' pair.\n"
+#endif
+ ;
/* Decode a symbolic name to a numeric value
#include "internal.h"
#include <stdio.h>
-static const char logname_usage[] = "logname\n\n"
-
- "Print the name of the current user.\n";
+static const char logname_usage[] = "logname\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nPrint the name of the current user.\n"
+#endif
+ ;
extern int logname_main(int argc, char **argv)
{
#ifdef BB_FEATURE_LS_FILETYPES
"F"
#endif
- "] [filenames...]\n\n"
+ "] [filenames...]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nList directory contents\n\n"
"Options:\n"
"\t-a\tdo not hide entries starting with .\n"
#ifdef BB_FEATURE_LS_TIMESTAMPS
"\t-C\tlist entries by columns\n"
#ifdef BB_FEATURE_LS_FILETYPES
"\t-F\tappend indicator (one of */=@|) to entries\n"
+#endif
#endif
;
#include <sys/stat.h>
static const char makedevs_usage[] =
- "makedevs NAME TYPE MAJOR MINOR FIRST LAST [s]\n\n"
- "Creates a range of block or character special files\n\n"
+ "makedevs NAME TYPE MAJOR MINOR FIRST LAST [s]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nCreates 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"
"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";
+ "\tmakedevs /dev/hda b 3 0 0 8 s -> hda,hda1-hda8\n"
+#endif
+ ;
int makedevs_main(int argc, char **argv)
{
/* Tiny RPN calculator, because "expr" didn't give me bitwise operations. */
-static const char math_usage[] = "math expression ...\n\n"
- "This is a Tiny RPN calculator that understands the\n"
+static const char math_usage[] = "math expression ...\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nThis 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";
+ "i.e. 'math 2 2 add' -> 4, and 'math 8 8 \\* 2 2 + /' -> 16\n"
+#endif
+ ;
static double stack[100];
static unsigned int pointer;
* Perhaps this will make it simpler to internationalize also, and
* may make the binary slightly smaller.
*/
+
+// TO use, do something like this
+//
+//#define BB_DECLARE_EXTERN
+//#define bb_need_memory_exhausted
+//#include "messages.c"
+//
#ifndef _BB_MESSAGES_C
#define _BB_MESSAGES_C
#if defined bb_need_io_error || ! defined BB_DECLARE_EXTERN
BB_DEF_MESSAGE(io_error, "%s: input/output error -- %s\n")
#endif
+#if defined bb_need_help || ! defined BB_DECLARE_EXTERN
+ BB_DEF_MESSAGE(dash_dash_help, "--help")
+#endif
+
#endif /* _BB_MESSAGES_C */
+
#include <sys/stat.h>
static const char makedevs_usage[] =
- "makedevs NAME TYPE MAJOR MINOR FIRST LAST [s]\n\n"
- "Creates a range of block or character special files\n\n"
+ "makedevs NAME TYPE MAJOR MINOR FIRST LAST [s]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nCreates 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"
"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";
+ "\tmakedevs /dev/hda b 3 0 0 8 s -> hda,hda1-hda8\n"
+#endif
+ ;
int makedevs_main(int argc, char **argv)
{
#include <sys/mtio.h>
#include <sys/fcntl.h>
-static const char mt_usage[] = "mt [-f device] opcode value\n\n"
- "Control magnetic tape drive operation\n";
+static const char mt_usage[] = "mt [-f device] opcode value\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nControl magnetic tape drive operation\n"
+#endif
+ ;
struct mt_opcodes {
char *name;
#endif /* __GLIBC__ */
static char update_usage[] =
- "update [options]\n\n"
- "Periodically flushes filesystem buffers.\n\n"
+ "update [options]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nPeriodically flushes filesystem buffers.\n\n"
"Options:\n"
"\t-S\tforce use of sync(2) instead of flushing\n"
"\t-s SECS\tcall sync this often (default 30)\n"
- "\t-f SECS\tflush some buffers this often (default 5)\n";
+ "\t-f SECS\tflush some buffers this often (default 5)\n"
+#endif
+ ;
static unsigned int sync_duration = 30;
static unsigned int flush_duration = 5;
#include <errno.h>
static const char mkdir_usage[] =
- "mkdir [OPTION] DIRECTORY...\n\n"
- "Create the DIRECTORY(ies), if they do not already exist\n\n"
+ "mkdir [OPTION] DIRECTORY...\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nCreate the DIRECTORY(ies), if they do not already exist\n\n"
"Options:\n"
"\t-m\tset permission mode (as in chmod), not rwxrwxrwx - umask\n"
- "\t-p\tno error if existing, make parent directories as needed\n";
+ "\t-p\tno error if existing, make parent directories as needed\n"
+#endif
+ ;
static int parentFlag = FALSE;
#include <sys/stat.h>
#include <errno.h>
-static const char mkfifo_usage[] = "mkfifo [OPTIONS] name\n\n"
- "Creates a named pipe (identical to 'mknod name p')\n\n"
-
+static const char mkfifo_usage[] = "mkfifo [OPTIONS] name\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nCreates a named pipe (identical to 'mknod name p')\n\n"
"Options:\n"
- "\t-m\tcreate the pipe using the specified mode (default a=rw)\n";
+ "\t-m\tcreate the pipe using the specified mode (default a=rw)\n"
+#endif
+ ;
extern int mkfifo_main(int argc, char **argv)
{
fprintf(stderr, "BusyBox v%s (%s) multi-call binary -- GPL2\n\n",
BB_VER, BB_BT);
fprintf(stderr,
- "Usage: %s [-c | -l filename] [-nXX] [-iXX] /dev/name [blocks]\n\n",
+ "Usage: %s [-c | -l filename] [-nXX] [-iXX] /dev/name [blocks]\n",
program_name);
- fprintf(stderr, "Make a MINIX filesystem.\n\n");
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ fprintf(stderr, "\nMake a MINIX filesystem.\n\n");
fprintf(stderr, "OPTIONS:\n");
fprintf(stderr, "\t-c\t\tCheck the device for bad blocks\n");
fprintf(stderr,
fprintf(stderr,
"\t-l FILENAME\tRead the bad blocks list from FILENAME\n");
fprintf(stderr, "\t-v\t\tMake a Minix version 2 filesystem\n\n");
+#endif
exit(16);
}
#include <fcntl.h>
#include <unistd.h>
-static const char mknod_usage[] = "mknod [OPTIONS] NAME TYPE MAJOR MINOR\n\n"
- "Create a special file (block, character, or pipe).\n\n"
+static const char mknod_usage[] = "mknod [OPTIONS] NAME TYPE MAJOR MINOR\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nCreate 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"
+#endif
+ ;
int mknod_main(int argc, char **argv)
{
static const char mkswap_usage[] =
- "mkswap [-c] [-v0|-v1] device [block-count]\n\n"
- "Prepare a disk partition to be used as a swap partition.\n\n"
+ "mkswap [-c] [-v0|-v1] device [block-count]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nPrepare a disk partition to be used as a swap partition.\n\n"
"Options:\n" "\t-c\t\tCheck for read-ability.\n"
"\t-v0\t\tMake version 0 swap [max 128 Megs].\n"
"\t-v1\t\tMake version 1 swap [big!] (default for kernels > 2.1.117).\n"
- "\tblock-count\tNumber of block to use (default is entire partition).\n";
+ "\tblock-count\tNumber of block to use (default is entire partition).\n"
+#endif
+ ;
#ifndef _IO
+++ /dev/null
-/* vi: set sw=4 ts=4: */
-/* mnc: mini-netcat - built from the ground up for LRP
- Copyright (C) 1998 Charles P. Wright
-
- 0.0.1 6K It works.
- 0.0.2 5K Smaller and you can also check the exit condition if you wish.
- 0.0.3 Uses select()
-
- 19980918 Busy Boxed! Dave Cinege
- 19990512 Uses Select. Charles P. Wright
- 19990513 Fixes stdin stupidity and uses buffers. Charles P. Wright
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-*/
-#include "internal.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-#include <sys/time.h>
-#include <sys/ioctl.h>
-
-#define BUFSIZE 100
-
-static const char mnc_usage[] =
-
- "mnc [IP] [port]\n\n" "mini-netcat opens a pipe to IP:port\n";
-
-int mnc_main(int argc, char **argv)
-{
- int sfd;
- int result;
- int len;
- char ch[BUFSIZE];
-
- struct sockaddr_in address;
- struct hostent *hostinfo;
-
- fd_set readfds, testfds;
-
- argc--;
- argv++;
- if (argc < 2 || **(argv + 1) == '-') {
- usage(mnc_usage);
- }
-
- sfd = socket(AF_INET, SOCK_STREAM, 0);
-
- hostinfo = (struct hostent *) gethostbyname(*argv);
-
- if (!hostinfo) {
- exit(1);
- }
-
- address.sin_family = AF_INET;
- address.sin_addr = *(struct in_addr *) *hostinfo->h_addr_list;
- address.sin_port = htons(atoi(*(++argv)));
-
- len = sizeof(address);
-
- result = connect(sfd, (struct sockaddr *) &address, len);
-
- if (result < 0) {
- exit(2);
- }
-
- FD_ZERO(&readfds);
- FD_SET(sfd, &readfds);
- FD_SET(fileno(stdin), &readfds);
-
- while (1) {
- int fd;
- int ofd;
- int nread;
-
- testfds = readfds;
-
- result =
- select(FD_SETSIZE, &testfds, (fd_set *) NULL, (fd_set *) NULL,
- (struct timeval *) 0);
-
- if (result < 1) {
- exit(3);
- }
-
- for (fd = 0; fd < FD_SETSIZE; fd++) {
- if (FD_ISSET(fd, &testfds)) {
- int trn = 0;
- int rn;
-
- ioctl(fd, FIONREAD, &nread);
-
- if (fd == sfd) {
- if (nread == 0)
- exit(0);
- ofd = fileno(stdout);
- } else {
- ofd = sfd;
- }
-
-
-
- do {
- rn = (BUFSIZE < nread - trn) ? BUFSIZE : nread - trn;
- trn += rn;
- read(fd, ch, rn);
- write(ofd, ch, rn);
- }
- while (trn < nread);
- }
- }
- }
-}
static char m_filename[BUFSIZ + 1] = "\0";
static char m_fullName[BUFSIZ + 1] = "\0";
static const char insmod_usage[] =
- "insmod [OPTION]... MODULE [symbol=value]...\n\n"
- "Loads the specified kernel modules into the kernel.\n\n"
+ "insmod [OPTION]... MODULE [symbol=value]...\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nLoads the specified kernel modules into the kernel.\n\n"
"Options:\n"
"\t-f\tForce module to load into the wrong kernel version.\n"
- "\t-k\tMake module autoclean-able.\n";
+ "\t-k\tMake module autoclean-able.\n"
+#endif
+ ;
static int findNamedModule(const char *fileName, struct stat *statbuf)
static const char rmmod_usage[] =
- "rmmod [OPTION]... [MODULE]...\n\n"
- "Unloads the specified kernel modules from the kernel.\n\n"
-
- "Options:\n" "\t-a\tTry to remove all unused kernel modules.\n";
+ "rmmod [OPTION]... [MODULE]...\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nUnloads the specified kernel modules from the kernel.\n\n"
+ "Options:\n"
+ "\t-a\tTry to remove all unused kernel modules.\n"
+#endif
+ ;
#include <fcntl.h>
#include <signal.h>
#include <sys/ioctl.h>
+#define BB_DECLARE_EXTERN
+#define bb_need_help
+#include "messages.c"
-static const char more_usage[] = "more [file ...]\n";
+static const char more_usage[] = "more [FILE ...]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nMore is a filter for viewing FILE one screenful at a time.\n"
+#endif
+ ;
/* ED: sparc termios is broken: revert back to old termio handling. */
#ifdef BB_FEATURE_USE_TERMIOS
argv++;
if (argc > 0
- && (strcmp(*argv, "--help") == 0 || strcmp(*argv, "-h") == 0)) {
+ && (strcmp(*argv, dash_dash_help) == 0 || strcmp(*argv, "-h") == 0)) {
usage(more_usage);
}
do {
extern const char mtab_file[]; /* Defined in utility.c */
-static const char mount_usage[] = "\tmount [flags]\n"
- "\tmount [flags] device directory [-o options,more-options]\n"
- "\n" "Flags:\n"
- "\t-a:\t\tMount all file systems in fstab.\n"
+static const char mount_usage[] =
+ "mount [flags] device directory [-o options,more-options]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nMount a filesystem\n\n"
+ "Flags:\n"
+ "\t-a:\t\tMount all filesystems in fstab.\n"
#ifdef BB_MTAB
"\t-f:\t\t\"Fake\" mount. Add entry to mount table but don't mount it.\n"
"\t-n:\t\tDon't write a mount table entry.\n"
"\tsuid/nosuid:\tAllow set-user-id-root programs / disallow them.\n"
"\tremount:\tRe-mount a currently-mounted filesystem, changing its flags.\n"
"\tro/rw:\t\tMount for read-only / read-write.\n"
- "There are EVEN MORE flags that are specific to each filesystem.\n"
- "You'll have to see the written documentation for those.\n";
+ "\nThere are EVEN MORE flags that are specific to each filesystem.\n"
+ "You'll have to see the written documentation for those.\n"
+#endif
+ ;
struct mount_options {
fatalError( "\nCannot read /etc/fstab: %s\n", strerror (errno));
while ((m = getmntent(f)) != NULL) {
- // If the file system isn't noauto,
+ // If the filesystem isn't noauto,
// and isn't swap or nfs, then mount it
if ((!strstr(m->mnt_opts, "noauto")) &&
(!strstr(m->mnt_type, "swap")) &&
#include <sys/mtio.h>
#include <sys/fcntl.h>
-static const char mt_usage[] = "mt [-f device] opcode value\n\n"
- "Control magnetic tape drive operation\n";
+static const char mt_usage[] = "mt [-f device] opcode value\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nControl magnetic tape drive operation\n"
+#endif
+ ;
struct mt_opcodes {
char *name;
--- /dev/null
+/* vi: set sw=4 ts=4: */
+/* nc: mini-netcat - built from the ground up for LRP
+ Copyright (C) 1998 Charles P. Wright
+
+ 0.0.1 6K It works.
+ 0.0.2 5K Smaller and you can also check the exit condition if you wish.
+ 0.0.3 Uses select()
+
+ 19980918 Busy Boxed! Dave Cinege
+ 19990512 Uses Select. Charles P. Wright
+ 19990513 Fixes stdin stupidity and uses buffers. Charles P. Wright
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+*/
+#include "internal.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <netdb.h>
+#include <sys/time.h>
+#include <sys/ioctl.h>
+
+#define BUFSIZE 100
+
+static const char nc_usage[] = "nc [IP] [port]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nNetcat opens a pipe to IP:port\n"
+#endif
+ ;
+
+int nc_main(int argc, char **argv)
+{
+ int sfd;
+ int result;
+ int len;
+ char ch[BUFSIZE];
+
+ struct sockaddr_in address;
+ struct hostent *hostinfo;
+
+ fd_set readfds, testfds;
+
+ argc--;
+ argv++;
+ if (argc < 2 || **(argv + 1) == '-') {
+ usage(nc_usage);
+ }
+
+ sfd = socket(AF_INET, SOCK_STREAM, 0);
+
+ hostinfo = (struct hostent *) gethostbyname(*argv);
+
+ if (!hostinfo) {
+ exit(1);
+ }
+
+ address.sin_family = AF_INET;
+ address.sin_addr = *(struct in_addr *) *hostinfo->h_addr_list;
+ address.sin_port = htons(atoi(*(++argv)));
+
+ len = sizeof(address);
+
+ result = connect(sfd, (struct sockaddr *) &address, len);
+
+ if (result < 0) {
+ exit(2);
+ }
+
+ FD_ZERO(&readfds);
+ FD_SET(sfd, &readfds);
+ FD_SET(fileno(stdin), &readfds);
+
+ while (1) {
+ int fd;
+ int ofd;
+ int nread;
+
+ testfds = readfds;
+
+ result =
+ select(FD_SETSIZE, &testfds, (fd_set *) NULL, (fd_set *) NULL,
+ (struct timeval *) 0);
+
+ if (result < 1) {
+ exit(3);
+ }
+
+ for (fd = 0; fd < FD_SETSIZE; fd++) {
+ if (FD_ISSET(fd, &testfds)) {
+ int trn = 0;
+ int rn;
+
+ ioctl(fd, FIONREAD, &nread);
+
+ if (fd == sfd) {
+ if (nread == 0)
+ exit(0);
+ ofd = fileno(stdout);
+ } else {
+ ofd = sfd;
+ }
+
+
+
+ do {
+ rn = (BUFSIZE < nread - trn) ? BUFSIZE : nread - trn;
+ trn += rn;
+ read(fd, ch, rn);
+ write(ofd, ch, rn);
+ }
+ while (trn < nread);
+ }
+ }
+ }
+}
/* vi: set sw=4 ts=4: */
/*
- * $Id: hostname.c,v 1.7 2000/02/08 19:58:47 erik Exp $
+ * $Id: hostname.c,v 1.8 2000/05/12 19:41:47 erik Exp $
* Mini hostname implementation for busybox
*
* Copyright (C) 1999 by Randolph Chung <tausq@debian.org>
#include <stdio.h>
static const char *hostname_usage =
- "hostname [OPTION] {hostname | -F file}\n\n"
- "Get or set the hostname or DNS domain name. If a hostname is given\n"
+ "hostname [OPTION] {hostname | -F file}\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nGet or set the hostname or DNS domain name. If a hostname is given\n"
"(or a file with the -F parameter), the host name will be set.\n\n"
"Options:\n"
"\t-s\t\tShort\n"
"\t-i\t\tAddresses for the hostname\n"
"\t-d\t\tDNS domain name\n"
- "\t-F FILE\t\tUse the contents of FILE to specify the hostname\n";
+ "\t-F FILE\t\tUse the contents of FILE to specify the hostname\n"
+#endif
+ ;
void do_sethostname(char *s, int isfile)
--- /dev/null
+/* vi: set sw=4 ts=4: */
+/* nc: mini-netcat - built from the ground up for LRP
+ Copyright (C) 1998 Charles P. Wright
+
+ 0.0.1 6K It works.
+ 0.0.2 5K Smaller and you can also check the exit condition if you wish.
+ 0.0.3 Uses select()
+
+ 19980918 Busy Boxed! Dave Cinege
+ 19990512 Uses Select. Charles P. Wright
+ 19990513 Fixes stdin stupidity and uses buffers. Charles P. Wright
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+*/
+#include "internal.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <netdb.h>
+#include <sys/time.h>
+#include <sys/ioctl.h>
+
+#define BUFSIZE 100
+
+static const char nc_usage[] = "nc [IP] [port]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nNetcat opens a pipe to IP:port\n"
+#endif
+ ;
+
+int nc_main(int argc, char **argv)
+{
+ int sfd;
+ int result;
+ int len;
+ char ch[BUFSIZE];
+
+ struct sockaddr_in address;
+ struct hostent *hostinfo;
+
+ fd_set readfds, testfds;
+
+ argc--;
+ argv++;
+ if (argc < 2 || **(argv + 1) == '-') {
+ usage(nc_usage);
+ }
+
+ sfd = socket(AF_INET, SOCK_STREAM, 0);
+
+ hostinfo = (struct hostent *) gethostbyname(*argv);
+
+ if (!hostinfo) {
+ exit(1);
+ }
+
+ address.sin_family = AF_INET;
+ address.sin_addr = *(struct in_addr *) *hostinfo->h_addr_list;
+ address.sin_port = htons(atoi(*(++argv)));
+
+ len = sizeof(address);
+
+ result = connect(sfd, (struct sockaddr *) &address, len);
+
+ if (result < 0) {
+ exit(2);
+ }
+
+ FD_ZERO(&readfds);
+ FD_SET(sfd, &readfds);
+ FD_SET(fileno(stdin), &readfds);
+
+ while (1) {
+ int fd;
+ int ofd;
+ int nread;
+
+ testfds = readfds;
+
+ result =
+ select(FD_SETSIZE, &testfds, (fd_set *) NULL, (fd_set *) NULL,
+ (struct timeval *) 0);
+
+ if (result < 1) {
+ exit(3);
+ }
+
+ for (fd = 0; fd < FD_SETSIZE; fd++) {
+ if (FD_ISSET(fd, &testfds)) {
+ int trn = 0;
+ int rn;
+
+ ioctl(fd, FIONREAD, &nread);
+
+ if (fd == sfd) {
+ if (nread == 0)
+ exit(0);
+ ofd = fileno(stdout);
+ } else {
+ ofd = sfd;
+ }
+
+
+
+ do {
+ rn = (BUFSIZE < nread - trn) ? BUFSIZE : nread - trn;
+ trn += rn;
+ read(fd, ch, rn);
+ write(ofd, ch, rn);
+ }
+ while (trn < nread);
+ }
+ }
+ }
+}
| + find out how the real nslookup gets the default name server
*/
-static const char nslookup_usage[] = "nslookup [HOST]\n\nQueries the nameserver for the IP address of the given HOST\n";
+static const char nslookup_usage[] = "nslookup [HOST]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nQueries the nameserver for the IP address of the given HOST\n"
+#endif
+;
/* I have to see how the real nslookup does this.
exit( TRUE);
}
-/* $Id: nslookup.c,v 1.8 2000/05/02 00:07:56 erik Exp $ */
+/* $Id: nslookup.c,v 1.9 2000/05/12 19:41:47 erik Exp $ */
/* vi: set sw=4 ts=4: */
/*
- * $Id: ping.c,v 1.14 2000/04/25 23:24:55 erik Exp $
+ * $Id: ping.c,v 1.15 2000/05/12 19:41:47 erik Exp $
* Mini ping implementation for busybox
*
* Copyright (C) 1999 by Randolph Chung <tausq@debian.org>
/* simple version */
#ifdef BB_SIMPLE_PING
-static const char *ping_usage = "ping host\n\n";
+static const char *ping_usage = "ping host\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nSend ICMP ECHO_REQUEST packets to network hosts\n"
+#endif
+ ;
static char *hostname = NULL;
#else
/* full(er) version */
-static const char *ping_usage = "ping [OPTION]... host\n\n"
- "Send ICMP ECHO_REQUEST packets to network hosts.\n\n"
+static const char *ping_usage = "ping [OPTION]... host\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nSend ICMP ECHO_REQUEST packets to network hosts.\n\n"
"Options:\n"
"\t-c COUNT\tSend only COUNT pings.\n"
"\t-q\t\tQuiet mode, only displays output at start\n"
- "\t\t\tand when finished.\n";
+ "\t\t\tand when finished.\n"
+#endif
+ ;
static char *hostname = NULL;
static struct sockaddr_in pingaddr;
/*
- * $Id: telnet.c,v 1.2 2000/05/01 19:10:52 erik Exp $
+ * $Id: telnet.c,v 1.3 2000/05/12 19:41:47 erik Exp $
* Mini telnet implementation for busybox
*
* Copyright (C) 2000 by Randolph Chung <tausq@debian.org>
static int STDIN = 0;
static int STDOUT = 1;
-static const char *telnet_usage = "telnet host [port]\n\n";
+static const char *telnet_usage = "telnet host [port]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nProvides interactive communication with another\n"
+ "networked host using the TELNET protocol\n"
+#endif
+ ;
static struct termios saved_tc;
static unsigned char options[NTELOPTS];
static char tr_state = 0; /* telnet send and receive state */
| + find out how the real nslookup gets the default name server
*/
-static const char nslookup_usage[] = "nslookup [HOST]\n\nQueries the nameserver for the IP address of the given HOST\n";
+static const char nslookup_usage[] = "nslookup [HOST]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nQueries the nameserver for the IP address of the given HOST\n"
+#endif
+;
/* I have to see how the real nslookup does this.
exit( TRUE);
}
-/* $Id: nslookup.c,v 1.8 2000/05/02 00:07:56 erik Exp $ */
+/* $Id: nslookup.c,v 1.9 2000/05/12 19:41:47 erik Exp $ */
/* vi: set sw=4 ts=4: */
/*
- * $Id: ping.c,v 1.14 2000/04/25 23:24:55 erik Exp $
+ * $Id: ping.c,v 1.15 2000/05/12 19:41:47 erik Exp $
* Mini ping implementation for busybox
*
* Copyright (C) 1999 by Randolph Chung <tausq@debian.org>
/* simple version */
#ifdef BB_SIMPLE_PING
-static const char *ping_usage = "ping host\n\n";
+static const char *ping_usage = "ping host\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nSend ICMP ECHO_REQUEST packets to network hosts\n"
+#endif
+ ;
static char *hostname = NULL;
#else
/* full(er) version */
-static const char *ping_usage = "ping [OPTION]... host\n\n"
- "Send ICMP ECHO_REQUEST packets to network hosts.\n\n"
+static const char *ping_usage = "ping [OPTION]... host\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nSend ICMP ECHO_REQUEST packets to network hosts.\n\n"
"Options:\n"
"\t-c COUNT\tSend only COUNT pings.\n"
"\t-q\t\tQuiet mode, only displays output at start\n"
- "\t\t\tand when finished.\n";
+ "\t\t\tand when finished.\n"
+#endif
+ ;
static char *hostname = NULL;
static struct sockaddr_in pingaddr;
/* The value to return to the calling program. */
static int exit_status;
-static const char printf_usage[] = "printf format [argument...]\n\nFormats and prints the given data.\n";
+static const char printf_usage[] = "printf FORMAT [ARGUMENT...]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nFormats and prints ARGUMENT(s) according to FORMAT,\n"
+ "Where FORMAT controls the output exactly as in C printf.\n"
+#endif
+ ;
int printf_main(int argc, char **argv)
{
info.sharedram/=DIVISOR;
info.bufferram/=DIVISOR;
+ if (argc > 1 && **(argv + 1) == '-') {
+ usage("free\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nDisplays the amount of free and used system memory\n"
+#endif
+ );
+ }
+
printf("%6s%13s%13s%13s%13s%13s\n", "", "total", "used", "free",
"shared", "buffers");
#include <unistd.h>
static const char *kill_usage =
- "kill [-signal] process-id [process-id ...]\n\n"
- "Send a signal (default is SIGTERM) to the specified process(es).\n\n"
- "Options:\n" "\t-l\tList all signal names and numbers.\n\n";
+ "kill [-signal] process-id [process-id ...]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nSend a signal (default is SIGTERM) to the specified process(es).\n\n"
+ "Options:\n" "\t-l\tList all signal names and numbers.\n\n"
+#endif
+ ;
#ifdef BB_KILLALL
static const char *killall_usage =
- "killall [-signal] process-name [process-name ...]\n\n"
- "Send a signal (default is SIGTERM) to the specified process(es).\n\n"
- "Options:\n" "\t-l\tList all signal names and numbers.\n\n";
+ "killall [-signal] process-name [process-name ...]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nSend a signal (default is SIGTERM) to the specified process(es).\n\n"
+ "Options:\n" "\t-l\tList all signal names and numbers.\n\n"
+#endif
#endif
+ ;
#define KILL 0
#define KILLALL 1
#include <fcntl.h>
#include <ctype.h>
#include <sys/ioctl.h>
+#define BB_DECLARE_EXTERN
+#define bb_need_help
+#include "messages.c"
#if ! defined BB_FEATURE_USE_DEVPS_PATCH
- if (argc > 1 && strcmp(argv[1], "--help") == 0) {
- usage ("ps\n\nReport process status\n\nThis version of ps accepts no options.\n");
+ if (argc > 1 && strcmp(argv[1], dash_dash_help) == 0) {
+ usage ("ps\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nReport process status\n"
+ "\nThis version of ps accepts no options.\n"
+#endif
+ );
}
dir = opendir("/proc");
#include <fcntl.h>
#include <ctype.h>
#include <sys/ioctl.h>
+#define BB_DECLARE_EXTERN
+#define bb_need_help
+#include "messages.c"
#if ! defined BB_FEATURE_USE_DEVPS_PATCH
- if (argc > 1 && strcmp(argv[1], "--help") == 0) {
- usage ("ps\n\nReport process status\n\nThis version of ps accepts no options.\n");
+ if (argc > 1 && strcmp(argv[1], dash_dash_help) == 0) {
+ usage ("ps\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nReport process status\n"
+ "\nThis version of ps accepts no options.\n"
+#endif
+ );
}
dir = opendir("/proc");
#include "internal.h"
#include <stdio.h>
#include <dirent.h>
+#include <errno.h>
extern int pwd_main(int argc, char **argv)
{
char buf[BUFSIZ + 1];
- if (getcwd(buf, sizeof(buf)) == NULL) {
- perror("get working directory");
- exit(FALSE);
- }
+ if (getcwd(buf, sizeof(buf)) == NULL)
+ fatalError("pwd: %s", strerror(errno));
printf("%s\n", buf);
exit(TRUE);
#include <dirent.h>
#include <errno.h>
-static const char *rm_usage = "rm [OPTION]... FILE...\n\n"
- "Remove (unlink) the FILE(s).\n\n"
+static const char *rm_usage = "rm [OPTION]... FILE...\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nRemove (unlink) the FILE(s).\n\n"
"Options:\n"
-
"\t-f\t\tremove existing destinations, never prompt\n"
- "\t-r or -R\tremove the contents of directories recursively\n";
+ "\t-r or -R\tremove the contents of directories recursively\n"
+#endif
+ ;
static int recursiveFlag = FALSE;
{
if (argc == 1 || **(argv + 1) == '-') {
usage
- ("rmdir [OPTION]... DIRECTORY...\n\nRemove the DIRECTORY(ies), if they are empty.\n");
+ ("rmdir [OPTION]... DIRECTORY...\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nRemove the DIRECTORY(ies), if they are empty.\n"
+#endif
+ );
}
while (--argc > 0) {
static const char rmmod_usage[] =
- "rmmod [OPTION]... [MODULE]...\n\n"
- "Unloads the specified kernel modules from the kernel.\n\n"
-
- "Options:\n" "\t-a\tTry to remove all unused kernel modules.\n";
+ "rmmod [OPTION]... [MODULE]...\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nUnloads the specified kernel modules from the kernel.\n\n"
+ "Options:\n"
+ "\t-a\tTry to remove all unused kernel modules.\n"
+#endif
+ ;
#include <ctype.h>
static const char sed_usage[] =
- "sed [-n] -e script [file...]\n\n"
- "Allowed sed scripts come in the following form:\n"
+ "sed [-n] -e script [file...]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nAllowed sed scripts come in the following form:\n"
"\t'ADDR [!] COMMAND'\n\n"
"\twhere address ADDR can be:\n"
"\t NUMBER Match specified line number\n"
#if defined BB_REGEXP
"This version of sed matches full regular expresions.\n";
#else
- "This version of sed matches strings (not full regular expresions).\n";
+ "This version of sed matches strings (not full regular expresions).\n"
#endif
+#endif
+ ;
/* Flags & variables */
#include <linux/hdreg.h> /* HDIO_GETGEO */
#include <linux/fs.h> /* BLKGETSIZE */
+#define BB_DECLARE_EXTERN
+#define bb_need_memory_exhausted
+#include "messages.c"
static const char sfdisk_usage[] =
"sfdisk [options] device ...\n"
- "device: something like /dev/hda or /dev/sda\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\ndevice: something like /dev/hda or /dev/sda\n"
"useful options:\n"
" -s [or --show-size]: list size of a partition\n"
" -c [or --id]: print or change partition Id\n"
" -S# [or --sectors #]: set the number of sectors to use\n"
"You can disable all consistency checking with:\n"
- " -f [or --force]: do what I say, even if it is stupid\n";
+ " -f [or --force]: do what I say, even if it is stupid\n"
+#endif
+ ;
return 0;
}
if (!(ss = (char *) malloc(statbuf.st_size))) {
- errorMsg("out of memory?\n");
+ errorMsg(memory_exhausted, "sfdisk");
return 0;
}
fdin = open(restore_sector_file, O_RDONLY);
static const char shell_usage[] =
- "sh [FILE]...\n\n" "The BusyBox command interpreter (shell).\n\n";
-
+ "sh [FILE]...\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nlash: The BusyBox command interpreter (shell).\n\n"
+#endif
+ ;
static char cwd[1024];
static char *prompt = "# ";
static const char shell_usage[] =
- "sh [FILE]...\n\n" "The BusyBox command interpreter (shell).\n\n";
-
+ "sh [FILE]...\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nlash: The BusyBox command interpreter (shell).\n\n"
+#endif
+ ;
static char cwd[1024];
static char *prompt = "# ";
#include "internal.h"
#include <stdio.h>
-const char sleep_usage[] = "sleep N\n\n" "Pause for N seconds.\n";
+const char sleep_usage[] = "sleep N\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nPause for N seconds.\n"
+#endif
+ ;
extern int sleep_main(int argc, char **argv)
{
#ifdef BB_FEATURE_SORT_REVERSE
" [-r]"
#endif
-" [FILE]...\n\nSorts lines of text in the specified files\n";
+" [FILE]...\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+"\nSorts lines of text in the specified files\n"
+#endif
+;
#ifdef BB_FEATURE_SORT_REVERSE
#define APPLY_REVERSE(x) (reverse ? -(x) : (x))
exit(0);
}
-/* $Id: sort.c,v 1.15 2000/04/17 04:22:09 beppu Exp $ */
+/* $Id: sort.c,v 1.16 2000/05/12 19:41:47 erik Exp $ */
static const char *appName;
static const char swapoff_usage[] =
- "swapoff [OPTION] [device]\n\n"
- "Stop swapping virtual memory pages on the given device.\n\n"
+ "swapoff [OPTION] [device]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nStop swapping virtual memory pages on the given device.\n\n"
"Options:\n"
- "\t-a\tStop swapping on all swap devices\n";
+ "\t-a\tStop swapping on all swap devices\n"
+#endif
+ ;
static const char swapon_usage[] =
- "swapon [OPTION] [device]\n\n"
- "Start swapping virtual memory pages on the given device.\n\n"
+ "swapon [OPTION] [device]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nStart swapping virtual memory pages on the given device.\n\n"
"Options:\n"
- "\t-a\tStart swapping on all swap devices\n";
+ "\t-a\tStart swapping on all swap devices\n"
+#endif
+ ;
#define SWAPON_APP 1
extern int sync_main(int argc, char **argv)
{
if (argc > 1 && **(argv + 1) == '-') {
- usage("sync\n\nWrite all buffered filesystem blocks to disk.\n");
+ usage("sync\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nWrite all buffered filesystem blocks to disk.\n"
+#endif
+ );
}
exit(sync());
}
#endif
static const char logger_usage[] =
- "logger [OPTION]... [MESSAGE]\n\n"
- "Write MESSAGE to the system log. If MESSAGE is '-', log stdin.\n\n"
+ "logger [OPTION]... [MESSAGE]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nWrite MESSAGE to the system log. If MESSAGE is '-', log stdin.\n\n"
"Options:\n"
"\t-s\tLog to stderr as well as the system log.\n"
"\t-t\tLog using the specified tag (defaults to user name).\n"
"\t-p\tEnter the message with the specified priority.\n"
- "\t\tThis may be numerical or a ``facility.level'' pair.\n";
+ "\t\tThis may be numerical or a ``facility.level'' pair.\n"
+#endif
+ ;
/* Decode a symbolic name to a numeric value
static char LocalHostName[32];
static const char syslogd_usage[] =
- "syslogd [OPTION]...\n\n"
- "Linux system and kernel (provides klogd) logging utility.\n"
+ "syslogd [OPTION]...\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nLinux system and kernel (provides klogd) logging utility.\n"
"Note that this version of syslogd/klogd ignores /etc/syslog.conf.\n\n"
"Options:\n"
"\t-m\tChange the mark timestamp interval. default=20min. 0=off\n"
#ifdef BB_KLOGD
"\t-K\tDo not start up the klogd process (by default syslogd spawns klogd).\n"
#endif
- "\t-O\tSpecify an alternate log file. default=/var/log/messages\n";
+ "\t-O\tSpecify an alternate log file. default=/var/log/messages\n"
+#endif
+ ;
/* Note: There is also a function called "message()" in init.c */
/* Print a message to the log file. */
static char LocalHostName[32];
static const char syslogd_usage[] =
- "syslogd [OPTION]...\n\n"
- "Linux system and kernel (provides klogd) logging utility.\n"
+ "syslogd [OPTION]...\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nLinux system and kernel (provides klogd) logging utility.\n"
"Note that this version of syslogd/klogd ignores /etc/syslog.conf.\n\n"
"Options:\n"
"\t-m\tChange the mark timestamp interval. default=20min. 0=off\n"
#ifdef BB_KLOGD
"\t-K\tDo not start up the klogd process (by default syslogd spawns klogd).\n"
#endif
- "\t-O\tSpecify an alternate log file. default=/var/log/messages\n";
+ "\t-O\tSpecify an alternate log file. default=/var/log/messages\n"
+#endif
+ ;
/* Note: There is also a function called "message()" in init.c */
/* Print a message to the log file. */
#include <sys/stat.h>
#include <fcntl.h>
#include <ctype.h>
+#define BB_DECLARE_EXTERN
+#define bb_need_help
+#include "messages.c"
#define XWRITE(fd, buffer, n_bytes) \
static int print_headers;
const char tail_usage[] =
- "tail [OPTION] [FILE]...\n\n"
- "Print last 10 lines of each FILE to standard output.\n"
+ "tail [OPTION] [FILE]...\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nPrint last 10 lines of each FILE to standard output.\n"
"With more than one FILE, precede each with a header giving the\n"
"file name. With no FILE, or when FILE is -, read standard input.\n\n"
"Options:\n"
"\t-n NUM\t\tPrint last NUM lines instead of first 10\n"
"\t-f\t\tOutput data as the file grows. This version\n"
- "\t\t\tof 'tail -f' supports only one file at a time.\n";
+ "\t\t\tof 'tail -f' supports only one file at a time.\n"
+#endif
+ ;
static void write_header(const char *filename)
static int have_read_stdin;
-static const char tail_usage[] = "tail [OPTION]... [FILE]...\n\
-\n\
-Print last 10 lines of each FILE to standard output.\n\
+static const char tail_usage[] = "tail [OPTION]... [FILE]...\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+"\nPrint last 10 lines of each FILE to standard output.\n\
With more than one FILE, precede each with a header giving the file name.\n\
With no FILE, or when FILE is -, read standard input.\n\
\n\
-n=N output the last N lines, instead of last 10\n\
-q never output headers giving file names\n\
-v always output headers giving file names\n\
- --help display this help and exit\n\
\n\
If the first character of N (bytes or lines) is a `+', output begins with \n\
the Nth item from the start of each file, otherwise, print the last N items\n\
-in the file. N bytes may be suffixed by k (x1024), b (x512), or m (1024^2).\n\n";
+in the file. N bytes may be suffixed by k (x1024), b (x512), or m (1024^2).\n"
+#endif
+;
static void write_header(const char *filename, const char *comment)
{
#if defined BB_FEATURE_TAR_EXCLUDE
"[--exclude File] "
#endif
- "[-f tarFile] [FILE] ...\n\n"
- "Create, extract, or list files from a tar file. Note that\n"
+ "[-f tarFile] [FILE] ...\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nCreate, extract, or list files from a tar file. Note that\n"
"this version of tar treats hard links as separate files.\n\n"
"Main operation mode:\n"
#ifdef BB_FEATURE_TAR_CREATE
#endif
"\nInformative output:\n"
"\tv\t\tverbosely list files processed\n"
+#endif
;
/* Tar file constants */
#include <stdio.h>
static const char tee_usage[] =
- "tee [OPTION]... [FILE]...\n\n"
- "Copy standard input to each FILE, and also to standard output.\n\n"
+ "tee [OPTION]... [FILE]...\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nCopy standard input to each FILE, and also to standard output.\n\n"
"Options:\n" "\t-a\tappend to the given FILEs, do not overwrite\n"
#if 0
"\t-i\tignore interrupt signals\n"
#endif
+#endif
;
exit(0);
}
-/* $Id: tee.c,v 1.9 2000/04/13 01:18:56 erik Exp $ */
+/* $Id: tee.c,v 1.10 2000/05/12 19:41:47 erik Exp $ */
/*
- * $Id: telnet.c,v 1.2 2000/05/01 19:10:52 erik Exp $
+ * $Id: telnet.c,v 1.3 2000/05/12 19:41:47 erik Exp $
* Mini telnet implementation for busybox
*
* Copyright (C) 2000 by Randolph Chung <tausq@debian.org>
static int STDIN = 0;
static int STDOUT = 1;
-static const char *telnet_usage = "telnet host [port]\n\n";
+static const char *telnet_usage = "telnet host [port]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nProvides interactive communication with another\n"
+ "networked host using the TELNET protocol\n"
+#endif
+ ;
static struct termios saved_tc;
static unsigned char options[NTELOPTS];
static char tr_state = 0; /* telnet send and receive state */
#include <errno.h>
#include <stdlib.h>
#include <string.h>
+#define BB_DECLARE_EXTERN
+#define bb_need_help
+#include "messages.c"
/* test(1) accepts the following grammar:
oexpr ::= aexpr | aexpr "-o" oexpr ;
fatalError("missing ]");
argv[argc] = NULL;
}
- if (strcmp(argv[1], "--help") == 0) {
+ if (strcmp(argv[1], dash_dash_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");
+ "or [ EXPRESSION ]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nChecks file types and compares values returning an exit\n"
+ "code determined by the value of EXPRESSION.\n"
+#endif
+ );
}
/* Implement special cases from POSIX.2, section 4.62.4 */
#include <errno.h>
-static const char touch_usage[] = "touch [-c] file [file ...]\n\n"
-
- "Update the last-modified date on the given file[s].\n";
+static const char touch_usage[] = "touch [-c] file [file ...]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nUpdate the last-modified date on the given file[s].\n"
+#endif
+ ;
#include <stdio.h>
#include <sys/types.h>
-static const char tty_usage[] = "tty\n\n"
- "Print the file name of the terminal connected to standard input.\n\n"
+static const char tty_usage[] = "tty\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nPrint the file name of the terminal connected to standard input.\n\n"
"Options:\n"
- "\t-s\tprint nothing, only return an exit status\n";
+ "\t-s\tprint nothing, only return an exit status\n"
+#endif
+ ;
extern int tty_main(int argc, char **argv)
{
static const char umount_usage[] =
- "umount [flags] filesystem|directory\n\n"
- "Flags:\n" "\t-a:\tUnmount all file systems"
+ "umount [flags] filesystem|directory\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "Unmount file systems\n"
+ "\nFlags:\n" "\t-a:\tUnmount all file systems"
#ifdef BB_MTAB
" in /etc/mtab\n\t-n:\tDon't erase /etc/mtab entries\n"
#else
#if defined BB_FEATURE_MOUNT_LOOP
"\t-l:\tDo not free loop device (if a loop device has been used)\n"
#endif
+#endif
;
struct _mtab_entry_t {
#include <errno.h>
static const char uniq_usage[] =
- "uniq [OPTION]... [INPUT [OUTPUT]]\n\n"
- "Discard all but one of successive identical lines from INPUT\n"
- "(or standard input), writing to OUTPUT (or standard output).\n";
+ "uniq [OPTION]... [INPUT [OUTPUT]]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nDiscard all but one of successive identical lines from INPUT\n"
+ "(or standard input), writing to OUTPUT (or standard output).\n"
+#endif
+ ;
/* max chars in line */
#define UNIQ_MAX 4096
exit(0);
}
-/* $Id: uniq.c,v 1.9 2000/04/17 16:16:10 erik Exp $ */
+/* $Id: uniq.c,v 1.10 2000/05/12 19:41:47 erik Exp $ */
#endif /* __GLIBC__ */
static char update_usage[] =
- "update [options]\n\n"
- "Periodically flushes filesystem buffers.\n\n"
+ "update [options]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nPeriodically flushes filesystem buffers.\n\n"
"Options:\n"
"\t-S\tforce use of sync(2) instead of flushing\n"
"\t-s SECS\tcall sync this often (default 30)\n"
- "\t-f SECS\tflush some buffers this often (default 5)\n";
+ "\t-f SECS\tflush some buffers this often (default 5)\n"
+#endif
+ ;
static unsigned int sync_duration = 30;
static unsigned int flush_duration = 5;
#include <stdlib.h>
#include <unistd.h>
-const char usleep_usage[] = "usleep N\n\n" "Pause for N microseconds.\n";
+const char usleep_usage[] = "usleep N\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nPause for N microseconds.\n"
+#endif
+ ;
extern int usleep_main(int argc, char **argv)
{
"-vsync", 1, CMD_VSYNC}, {
"-laced", 1, CMD_LACED}, {
"-double", 1, CMD_DOUBLE}, {
- "--help", 0, CMD_HELP}, {
+ "-help", 0, CMD_HELP}, {
#ifdef BB_FEATURE_FBSET_FANCY
- "--help", 0, CMD_HELP}, {
+ "-help", 0, CMD_HELP}, {
"-all", 0, CMD_ALL}, {
"-xres", 1, CMD_XRES}, {
"-yres", 1, CMD_YRES}, {
"-vyres", 1, CMD_VYRES}, {
"-depth", 1, CMD_DEPTH}, {
"-match", 0, CMD_MATCH}, {
- "--geometry", 5, CMD_GEOMETRY}, {
+ "-geometry", 5, CMD_GEOMETRY}, {
"-pixclock", 1, CMD_PIXCLOCK}, {
"-left", 1, CMD_LEFT}, {
"-right", 1, CMD_RIGHT}, {
"-lower", 1, CMD_LOWER}, {
"-hslen", 1, CMD_HSLEN}, {
"-vslen", 1, CMD_VSLEN}, {
- "--timings", 7, CMD_TIMING}, {
+ "-timings", 7, CMD_TIMING}, {
"-csync", 1, CMD_CSYNC}, {
"-gsync", 1, CMD_GSYNC}, {
"-extsync", 1, CMD_EXTSYNC}, {
static void fbset_usage(void)
{
+#ifndef BB_FEATURE_TRIVIAL_HELP
int i;
+#endif
#ifndef STANDALONE
fprintf(stderr, "BusyBox v%s (%s) multi-call binary -- GPL2\n\n",
BB_VER, BB_BT);
#endif
- fprintf(stderr, "Usage: fbset [options] [mode]\n\n");
- fprintf(stderr, "Show and modify frame buffer device settings\n\n");
+ fprintf(stderr, "Usage: fbset [options] [mode]\n");
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ fprintf(stderr, "\nShows and modifies frame buffer device settings\n\n");
fprintf(stderr, "The following options are recognized:\n");
for (i = 0; g_cmdoptions[i].name; i++)
fprintf(stderr, "\t%s\n", g_cmdoptions[i].name);
+#endif
exit(-1);
}
int fd;
if (argc <= 1 || **(++argv) == '-') {
- usage("fdflush device\n\nForce floppy disk drive to detect disk change\n");
+ usage("fdflush DEVICE\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nForces floppy disk drive to detect disk change\n"
+#endif
+ );
}
fd = open(*argv, 0);
static const char freeramdisk_usage[] =
- "freeramdisk DEVICE\n\n"
- "Free all memory used by the specified ramdisk.\n";
+ "freeramdisk DEVICE\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nFrees all memory used by the specified ramdisk.\n"
+#endif
+ ;
extern int
freeramdisk_main(int argc, char **argv)
{
fprintf(stderr, "BusyBox v%s (%s) multi-call binary -- GPL2\n\n",
BB_VER, BB_BT);
- fprintf(stderr, "Usage: %s [-larvsmf] /dev/name\n\n", program_name);
+ fprintf(stderr, "Usage: %s [-larvsmf] /dev/name\n", program_name);
+#ifndef BB_FEATURE_TRIVIAL_HELP
fprintf(stderr,
- "Performs a consistency check for MINIX filesystems.\n\n");
+ "\nPerforms a consistency check for MINIX filesystems.\n\n");
fprintf(stderr, "OPTIONS:\n");
fprintf(stderr, "\t-l\tLists all filenames\n");
fprintf(stderr, "\t-r\tPerform interactive repairs\n");
fprintf(stderr,
"\t-m\tActivates MINIX-like \"mode not cleared\" warnings\n");
fprintf(stderr, "\t-f\tForce file system check.\n\n");
+#endif
leave(16);
}
fprintf(stderr, "BusyBox v%s (%s) multi-call binary -- GPL2\n\n",
BB_VER, BB_BT);
fprintf(stderr,
- "Usage: %s [-c | -l filename] [-nXX] [-iXX] /dev/name [blocks]\n\n",
+ "Usage: %s [-c | -l filename] [-nXX] [-iXX] /dev/name [blocks]\n",
program_name);
- fprintf(stderr, "Make a MINIX filesystem.\n\n");
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ fprintf(stderr, "\nMake a MINIX filesystem.\n\n");
fprintf(stderr, "OPTIONS:\n");
fprintf(stderr, "\t-c\t\tCheck the device for bad blocks\n");
fprintf(stderr,
fprintf(stderr,
"\t-l FILENAME\tRead the bad blocks list from FILENAME\n");
fprintf(stderr, "\t-v\t\tMake a Minix version 2 filesystem\n\n");
+#endif
exit(16);
}
static const char mkswap_usage[] =
- "mkswap [-c] [-v0|-v1] device [block-count]\n\n"
- "Prepare a disk partition to be used as a swap partition.\n\n"
+ "mkswap [-c] [-v0|-v1] device [block-count]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nPrepare a disk partition to be used as a swap partition.\n\n"
"Options:\n" "\t-c\t\tCheck for read-ability.\n"
"\t-v0\t\tMake version 0 swap [max 128 Megs].\n"
"\t-v1\t\tMake version 1 swap [big!] (default for kernels > 2.1.117).\n"
- "\tblock-count\tNumber of block to use (default is entire partition).\n";
+ "\tblock-count\tNumber of block to use (default is entire partition).\n"
+#endif
+ ;
#ifndef _IO
#include <fcntl.h>
#include <signal.h>
#include <sys/ioctl.h>
+#define BB_DECLARE_EXTERN
+#define bb_need_help
+#include "messages.c"
-static const char more_usage[] = "more [file ...]\n";
+static const char more_usage[] = "more [FILE ...]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nMore is a filter for viewing FILE one screenful at a time.\n"
+#endif
+ ;
/* ED: sparc termios is broken: revert back to old termio handling. */
#ifdef BB_FEATURE_USE_TERMIOS
argv++;
if (argc > 0
- && (strcmp(*argv, "--help") == 0 || strcmp(*argv, "-h") == 0)) {
+ && (strcmp(*argv, dash_dash_help) == 0 || strcmp(*argv, "-h") == 0)) {
usage(more_usage);
}
do {
extern const char mtab_file[]; /* Defined in utility.c */
-static const char mount_usage[] = "\tmount [flags]\n"
- "\tmount [flags] device directory [-o options,more-options]\n"
- "\n" "Flags:\n"
- "\t-a:\t\tMount all file systems in fstab.\n"
+static const char mount_usage[] =
+ "mount [flags] device directory [-o options,more-options]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nMount a filesystem\n\n"
+ "Flags:\n"
+ "\t-a:\t\tMount all filesystems in fstab.\n"
#ifdef BB_MTAB
"\t-f:\t\t\"Fake\" mount. Add entry to mount table but don't mount it.\n"
"\t-n:\t\tDon't write a mount table entry.\n"
"\tsuid/nosuid:\tAllow set-user-id-root programs / disallow them.\n"
"\tremount:\tRe-mount a currently-mounted filesystem, changing its flags.\n"
"\tro/rw:\t\tMount for read-only / read-write.\n"
- "There are EVEN MORE flags that are specific to each filesystem.\n"
- "You'll have to see the written documentation for those.\n";
+ "\nThere are EVEN MORE flags that are specific to each filesystem.\n"
+ "You'll have to see the written documentation for those.\n"
+#endif
+ ;
struct mount_options {
fatalError( "\nCannot read /etc/fstab: %s\n", strerror (errno));
while ((m = getmntent(f)) != NULL) {
- // If the file system isn't noauto,
+ // If the filesystem isn't noauto,
// and isn't swap or nfs, then mount it
if ((!strstr(m->mnt_opts, "noauto")) &&
(!strstr(m->mnt_type, "swap")) &&
static const char *appName;
static const char swapoff_usage[] =
- "swapoff [OPTION] [device]\n\n"
- "Stop swapping virtual memory pages on the given device.\n\n"
+ "swapoff [OPTION] [device]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nStop swapping virtual memory pages on the given device.\n\n"
"Options:\n"
- "\t-a\tStop swapping on all swap devices\n";
+ "\t-a\tStop swapping on all swap devices\n"
+#endif
+ ;
static const char swapon_usage[] =
- "swapon [OPTION] [device]\n\n"
- "Start swapping virtual memory pages on the given device.\n\n"
+ "swapon [OPTION] [device]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nStart swapping virtual memory pages on the given device.\n\n"
"Options:\n"
- "\t-a\tStart swapping on all swap devices\n";
+ "\t-a\tStart swapping on all swap devices\n"
+#endif
+ ;
#define SWAPON_APP 1
static const char umount_usage[] =
- "umount [flags] filesystem|directory\n\n"
- "Flags:\n" "\t-a:\tUnmount all file systems"
+ "umount [flags] filesystem|directory\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "Unmount file systems\n"
+ "\nFlags:\n" "\t-a:\tUnmount all file systems"
#ifdef BB_MTAB
" in /etc/mtab\n\t-n:\tDon't erase /etc/mtab entries\n"
#else
#if defined BB_FEATURE_MOUNT_LOOP
"\t-l:\tDo not free loop device (if a loop device has been used)\n"
#endif
+#endif
;
struct _mtab_entry_t {
|| defined (BB_INSMOD)
/* same conditions as recursiveAction */
#define bb_need_name_too_long
+#define bb_need_memory_exhausted
#endif
#define BB_DECLARE_EXTERN
#include "messages.c"
exit( FALSE);
}
-#if defined BB_INIT
/* Returns kernel version encoded as major*65536 + minor*256 + patch,
* so, for example, to check if the kernel is greater than 2.2.11:
* if (get_kernel_revision() <= 2*65536+2*256+11) { <stuff> }
sscanf(name.version, "%d.%d.%d", &major, &minor, &patch);
return major * 65536 + minor * 256 + patch;
}
-#endif /* BB_INIT */
-#if defined (BB_CP_MV) || defined (BB_DU)
#define HASH_SIZE 311 /* Should be prime */
#define hash_inode(i) ((i) % HASH_SIZE)
}
}
-#endif /* BB_CP_MV || BB_DU */
-#if defined (BB_CP_MV) || defined (BB_DU) || defined (BB_LN)
/*
* Return TRUE if a fileName is a directory.
* Nonexistant files return FALSE.
}
return status;
}
-#endif
-#if defined (BB_CP_MV)
/*
* Copy one file to another, while possibly preserving its modes, times, and
* modes. Returns TRUE if successful, or FALSE on a failure with an error
return FALSE;
}
-#endif /* BB_CP_MV */
-
-#if defined BB_TAR || defined BB_LS
#define TYPEINDEX(mode) (((mode) >> 12) & 0x0f)
#define TYPECHAR(mode) ("0pcCd?bB-?l?s???" [TYPEINDEX(mode)])
}
return buf;
}
-#endif /* BB_TAR || BB_LS */
-#if defined BB_TAR
/*
* Return the standard ls-like time string from a time_t
* This is static and so is overwritten on each call.
return buf;
}
-#endif /* BB_TAR */
-#if defined BB_TAR || defined BB_CP_MV
/*
* Write all of the supplied buffer out to a file.
* This does multiple writes as necessary.
return total;
}
-#endif /* BB_TAR || BB_CP_MV */
-#if defined BB_TAR || defined BB_TAIL
/*
* Read all of the supplied buffer from a file.
* This does multiple reads as necessary.
return total;
}
-#endif /* BB_TAR || BB_TAIL */
-#if defined (BB_CHMOD_CHOWN_CHGRP) \
- || defined (BB_CP_MV) \
- || defined (BB_FIND) \
- || defined (BB_INSMOD) \
- || defined (BB_RM) \
- || defined (BB_TAR)
-
/*
* Walk down all the directories under the specified
* location, and do something (something specified
return TRUE;
}
-#endif /* BB_CHMOD_CHOWN_CHGRP || BB_CP_MV || BB_FIND || BB_LS || BB_INSMOD */
-#if defined (BB_TAR) || defined (BB_MKDIR)
/*
* Attempt to create the directories along the specified path, except for
* the final component. The mode is given for the final directory only,
}
return TRUE;
}
-#endif /* BB_TAR || BB_MKDIR */
-#if defined (BB_CHMOD_CHOWN_CHGRP) || defined (BB_MKDIR)
/* [ugoa]{+|-|=}[rwxst] */
-
-
-
extern int parse_mode(const char *s, mode_t * theMode)
{
mode_t andMode =
}
-#endif /* BB_CHMOD_CHOWN_CHGRP || BB_MKDIR */
-
-
-#if defined BB_CHMOD_CHOWN_CHGRP || defined BB_PS || defined BB_LS || defined BB_TAR || defined BB_ID
-
/* This parses entries in /etc/passwd and /etc/group. This is desirable
* for BusyBox, since we want to avoid using the glibc NSS stuff, which
* increases target size and is often not needed or wanted for embedded
return gid;
}
-#endif /* BB_CHMOD_CHOWN_CHGRP || BB_PS || BB_LS || BB_TAR || BB_ID */
-
-
-#if (defined BB_CHVT) || (defined BB_DEALLOCVT)
#include <linux/kd.h>
}
-#endif /* BB_CHVT || BB_DEALLOCVT */
-#if !defined BB_REGEXP && (defined BB_GREP || defined BB_SED)
-
+#if !defined BB_REGEXP
/* Do a case insensitive strstr() */
char *stristr(char *haystack, const char *needle)
{
else
return FALSE;
}
-
-#endif /* ! BB_REGEXP && (BB_GREP || BB_SED) */
+#endif /* ! BB_REGEXP */
-#if defined BB_FIND
/*
* Routine to see if a text string is matched by a wildcard pattern.
* Returns TRUE if the text is matched, or FALSE if it is not matched
return TRUE;
}
-#endif /* BB_FIND */
-#if defined BB_DF || defined BB_MTAB
/*
* Given a block device, find the mount table entry if that block device
* is mounted.
endmntent(mountTable);
return mountEntry;
}
-#endif /* BB_DF || BB_MTAB */
-#if defined BB_DD || defined BB_TAIL
/*
* Read a number with a possible multiplier.
* Returns -1 if the number format is illegal.
return value;
}
-#endif /* BB_DD || BB_TAIL */
-#if defined BB_INIT || defined BB_SYSLOGD
/* try to open up the specified device */
extern int device_open(char *device, int mode)
{
fcntl(fd, F_SETFL, mode);
return fd;
}
-#endif /* BB_INIT BB_SYSLOGD */
-#if defined BB_KILLALL || ( defined BB_FEATURE_LINUXRC && ( defined BB_HALT || defined BB_REBOOT || defined BB_POWEROFF ))
#ifdef BB_FEATURE_USE_DEVPS_PATCH
#include <linux/devps.h>
-#endif
-#if defined BB_FEATURE_USE_DEVPS_PATCH
/* findPidByName()
*
* This finds the pid of the specified process,
&& (strlen(pidName) == strlen(info.command_line))) {
pidList=realloc( pidList, sizeof(pid_t) * (j+2));
if (pidList==NULL)
- fatalError("out of memory\n");
+ fatalError(memory_exhausted, "");
pidList[j++]=info.pid;
}
}
&& (strlen(pidName) == strlen(p))) {
pidList=realloc( pidList, sizeof(pid_t) * (i+2));
if (pidList==NULL)
- fatalError("out of memory\n");
+ fatalError(memory_exhausted, "");
pidList[i++]=strtol(next->d_name, NULL, 0);
}
}
return pidList;
}
#endif /* BB_FEATURE_USE_DEVPS_PATCH */
-#endif /* BB_KILLALL || ( BB_FEATURE_LINUXRC && ( BB_HALT || BB_REBOOT || BB_POWEROFF )) */
/* this should really be farmed out to libbusybox.a */
extern void *xmalloc(size_t size)
void *cp = malloc(size);
if (cp == NULL)
- fatalError("out of memory\n");
+ fatalError(memory_exhausted, "");
return cp;
}
-#if (__GLIBC__ < 2) && (defined BB_SYSLOGD || defined BB_INIT)
+#if (__GLIBC__ < 2)
extern int vdprintf(int d, const char *format, va_list ap)
{
char buf[BUF_SIZE];
len = vsprintf(buf, format, ap);
return write(d, buf, len);
}
-#endif /* BB_SYSLOGD */
+#endif
-#if defined BB_FEATURE_MOUNT_LOOP
extern int del_loop(const char *device)
{
int fd;
}
return NULL;
}
-#endif /* BB_FEATURE_MOUNT_LOOP */
-#if defined BB_MOUNT || defined BB_DF || ( defined BB_UMOUNT && ! defined BB_MTAB)
extern int find_real_root_device_name(char* name)
{
DIR *dir;
return( FALSE);
}
-#endif
const unsigned int CSTRING_BUFFER_LENGTH = 128;
/* recursive parser that returns cstrings of arbitrary length
#include "internal.h"
#include <stdio.h>
-static const char wc_usage[] = "wc [OPTION]... [FILE]...\n\n"
- "Print line, word, and byte counts for each FILE, and a total line if\n"
+static const char wc_usage[] = "wc [OPTION]... [FILE]...\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nPrint line, word, and byte counts for each FILE, and a total line if\n"
"more than one FILE is specified. With no FILE, read standard input.\n\n"
"Options:\n"
"\t-c\tprint the byte counts\n"
"\t-l\tprint the newline counts\n"
"\t-L\tprint the length of the longest line\n"
- "\t-w\tprint the word counts\n";
+ "\t-w\tprint the word counts\n"
+#endif
+ ;
static int total_lines, total_words, total_chars, max_length;
static int print_lines, print_words, print_chars, print_length;
#include <stdio.h>
#include <pwd.h>
-static const char whoami_usage[] = "whoami\n\n"
- "Prints the user name associated with the current effective user id.\n";
+static const char whoami_usage[] = "whoami\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nPrints the user name associated with the current effective user id.\n"
+#endif
+ ;
extern int whoami_main(int argc, char **argv)
{
int i;
if (argc >=1 && *argv[1]=='-') {
- usage("yes [OPTION]... [STRING]...\n\n"
- "Repeatedly outputs a line with all specified STRING(s), or `y'.\n");
+ usage("yes [OPTION]... [STRING]...\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nRepeatedly outputs a line with all specified STRING(s), or `y'.\n"
+#endif
+ );
}
if (argc == 1) {