Don't use strings directly in calls to usage(). This is in preparation
for their extraction to a separate file.
This commit is contained in:
parent
464c5de00d
commit
3bd8bd89ee
15
chvt.c
15
chvt.c
@ -15,18 +15,19 @@
|
||||
#define VT_ACTIVATE 0x5606 /* make vt active */
|
||||
#define VT_WAITACTIVE 0x5607 /* wait for vt active */
|
||||
|
||||
const char chvt_usage[] =
|
||||
"chvt N\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nChanges the foreground virtual terminal to /dev/ttyN\n"
|
||||
#endif
|
||||
;
|
||||
|
||||
int chvt_main(int argc, char **argv)
|
||||
{
|
||||
int fd, num;
|
||||
|
||||
if ((argc != 2) || (**(argv + 1) == '-')) {
|
||||
usage ("chvt N\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nChanges the foreground virtual terminal to /dev/ttyN\n"
|
||||
#endif
|
||||
);
|
||||
}
|
||||
if ((argc != 2) || (**(argv + 1) == '-'))
|
||||
usage (chvt_usage);
|
||||
fd = get_console_fd("/dev/console");
|
||||
num = atoi(argv[1]);
|
||||
if (ioctl(fd, VT_ACTIVATE, num)) {
|
||||
|
@ -15,18 +15,19 @@
|
||||
#define VT_ACTIVATE 0x5606 /* make vt active */
|
||||
#define VT_WAITACTIVE 0x5607 /* wait for vt active */
|
||||
|
||||
const char chvt_usage[] =
|
||||
"chvt N\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nChanges the foreground virtual terminal to /dev/ttyN\n"
|
||||
#endif
|
||||
;
|
||||
|
||||
int chvt_main(int argc, char **argv)
|
||||
{
|
||||
int fd, num;
|
||||
|
||||
if ((argc != 2) || (**(argv + 1) == '-')) {
|
||||
usage ("chvt N\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nChanges the foreground virtual terminal to /dev/ttyN\n"
|
||||
#endif
|
||||
);
|
||||
}
|
||||
if ((argc != 2) || (**(argv + 1) == '-'))
|
||||
usage (chvt_usage);
|
||||
fd = get_console_fd("/dev/console");
|
||||
num = atoi(argv[1]);
|
||||
if (ioctl(fd, VT_ACTIVATE, num)) {
|
||||
|
@ -13,19 +13,19 @@
|
||||
/* From <linux/vt.h> */
|
||||
#define VT_DISALLOCATE 0x5608 /* free memory associated to vt */
|
||||
|
||||
const char deallocvt_usage[] =
|
||||
"deallocvt N\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nDeallocate unused virtual terminal /dev/ttyN\n"
|
||||
#endif
|
||||
;
|
||||
|
||||
int deallocvt_main(int argc, char *argv[])
|
||||
{
|
||||
int fd, num, i;
|
||||
|
||||
if ((argc != 2) || (**(argv + 1) == '-')) {
|
||||
usage
|
||||
("deallocvt N\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nDeallocate unused virtual terminal /dev/ttyN\n"
|
||||
#endif
|
||||
);
|
||||
}
|
||||
if ((argc != 2) || (**(argv + 1) == '-'))
|
||||
usage(deallocvt_usage);
|
||||
|
||||
fd = get_console_fd("/dev/console");
|
||||
|
||||
|
@ -206,6 +206,19 @@ void cut()
|
||||
}
|
||||
}
|
||||
|
||||
const char cut_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 CHAR\tUse CHAR instead of tab as the field delimiter\n"
|
||||
"\t-s\tOnly output Lines if the include DELIM\n"
|
||||
"\t-f N\tPrint only these fields\n"
|
||||
"\t-n\tIgnored\n"
|
||||
#endif
|
||||
;
|
||||
|
||||
int cut_main(int argc, char **argv)
|
||||
{
|
||||
@ -213,18 +226,7 @@ int cut_main(int argc, char **argv)
|
||||
int numberFilenames = 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 CHAR\tUse CHAR instead of tab as the field delimiter\n"
|
||||
"\t-s\tOnly output Lines if the include DELIM\n"
|
||||
"\t-f N\tPrint only these fields\n"
|
||||
"\t-n\tIgnored\n"
|
||||
#endif
|
||||
);
|
||||
usage(cut_usage);
|
||||
|
||||
while (i < argc) {
|
||||
if (argv[i][0] == '-') {
|
||||
|
@ -23,17 +23,19 @@
|
||||
#include "internal.h"
|
||||
#include <stdio.h>
|
||||
|
||||
const char dirname_usage[] =
|
||||
"dirname [FILENAME ...]\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nStrips non-directory suffix from FILENAME\n"
|
||||
#endif
|
||||
;
|
||||
|
||||
extern int dirname_main(int argc, char **argv)
|
||||
{
|
||||
char* s;
|
||||
|
||||
if ((argc < 2) || (**(argv + 1) == '-')) {
|
||||
usage("dirname [FILENAME ...]\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nStrips non-directory suffix from FILENAME\n"
|
||||
#endif
|
||||
);
|
||||
}
|
||||
if ((argc < 2) || (**(argv + 1) == '-'))
|
||||
usage(dirname_usage);
|
||||
argv++;
|
||||
|
||||
s=*argv+strlen(*argv)-1;
|
||||
|
@ -4,15 +4,17 @@
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
const char length_usage[] =
|
||||
"length STRING\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nPrints out the length of the specified STRING.\n"
|
||||
#endif
|
||||
;
|
||||
|
||||
extern int length_main(int argc, char **argv)
|
||||
{
|
||||
if (argc != 2 || **(argv + 1) == '-') {
|
||||
usage("length STRING\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nPrints out the length of the specified STRING.\n"
|
||||
#endif
|
||||
);
|
||||
}
|
||||
if (argc != 2 || **(argv + 1) == '-')
|
||||
usage(length_usage);
|
||||
printf("%lu\n", (long)strlen(argv[1]));
|
||||
return (TRUE);
|
||||
}
|
||||
|
@ -26,17 +26,17 @@
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
const char rmdir_usage[] =
|
||||
"rmdir [OPTION]... DIRECTORY...\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nRemove the DIRECTORY(ies), if they are empty.\n"
|
||||
#endif
|
||||
;
|
||||
|
||||
extern int rmdir_main(int argc, char **argv)
|
||||
{
|
||||
if (argc == 1 || **(argv + 1) == '-') {
|
||||
usage
|
||||
("rmdir [OPTION]... DIRECTORY...\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nRemove the DIRECTORY(ies), if they are empty.\n"
|
||||
#endif
|
||||
);
|
||||
}
|
||||
if (argc == 1 || **(argv + 1) == '-')
|
||||
usage(rmdir_usage);
|
||||
|
||||
while (--argc > 0) {
|
||||
if (rmdir(*(++argv)) == -1) {
|
||||
|
@ -24,14 +24,16 @@
|
||||
#include "internal.h"
|
||||
#include <stdio.h>
|
||||
|
||||
const char sync_usage[] =
|
||||
"sync\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nWrite all buffered filesystem blocks to disk.\n"
|
||||
#endif
|
||||
;
|
||||
|
||||
extern int sync_main(int argc, char **argv)
|
||||
{
|
||||
if (argc > 1 && **(argv + 1) == '-') {
|
||||
usage("sync\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nWrite all buffered filesystem blocks to disk.\n"
|
||||
#endif
|
||||
);
|
||||
}
|
||||
if (argc > 1 && **(argv + 1) == '-')
|
||||
usage(sync_usage);
|
||||
return(sync());
|
||||
}
|
||||
|
@ -178,6 +178,15 @@ static int test_eaccess();
|
||||
static int is_a_group_member();
|
||||
static void initialize_group_array();
|
||||
|
||||
const char test_usage[] =
|
||||
"test 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
|
||||
;
|
||||
|
||||
extern int
|
||||
test_main(int argc, char** argv)
|
||||
{
|
||||
@ -188,15 +197,8 @@ test_main(int argc, char** argv)
|
||||
fatalError("missing ]\n");
|
||||
argv[argc] = NULL;
|
||||
}
|
||||
if (strcmp(argv[1], dash_dash_help) == 0) {
|
||||
usage("test 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
|
||||
);
|
||||
}
|
||||
if (strcmp(argv[1], dash_dash_help) == 0)
|
||||
usage(test_usage);
|
||||
|
||||
/* Implement special cases from POSIX.2, section 4.62.4 */
|
||||
switch (argc) {
|
||||
|
@ -23,17 +23,19 @@
|
||||
#include "internal.h"
|
||||
#include <stdio.h>
|
||||
|
||||
const char yes_usage[] =
|
||||
"yes [OPTION]... [STRING]...\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nRepeatedly outputs a line with all specified STRING(s), or `y'.\n"
|
||||
#endif
|
||||
;
|
||||
|
||||
extern int yes_main(int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (argc >= 2 && *argv[1] == '-') {
|
||||
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 >= 2 && *argv[1] == '-')
|
||||
usage(yes_usage);
|
||||
|
||||
if (argc == 1) {
|
||||
while (1)
|
||||
|
42
cp_mv.c
42
cp_mv.c
@ -46,25 +46,33 @@
|
||||
#define is_cp 0
|
||||
#define is_mv 1
|
||||
static int dz_i; /* index into cp_mv_usage */
|
||||
|
||||
const char cp_usage[] =
|
||||
"cp [OPTION]... SOURCE DEST\n"
|
||||
" or: cp [OPTION]... SOURCE... DIRECTORY\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nCopies SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.\n"
|
||||
"\n"
|
||||
"\t-a\tSame as -dpR\n"
|
||||
"\t-d\tPreserves links\n"
|
||||
"\t-p\tPreserves file attributes if possible\n"
|
||||
"\t-f\tforce (implied; ignored) - always set\n"
|
||||
"\t-R\tCopies directories recursively\n"
|
||||
#endif
|
||||
;
|
||||
|
||||
const char mv_usage[] =
|
||||
"mv SOURCE DEST\n"
|
||||
" or: mv SOURCE... DIRECTORY\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nRename SOURCE to DEST, or move SOURCE(s) to DIRECTORY.\n"
|
||||
#endif
|
||||
;
|
||||
|
||||
static const char *cp_mv_usage[] = /* .rodata */
|
||||
{
|
||||
"cp [OPTION]... SOURCE DEST\n"
|
||||
" or: cp [OPTION]... SOURCE... DIRECTORY\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nCopies SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.\n"
|
||||
"\n"
|
||||
"\t-a\tSame as -dpR\n"
|
||||
"\t-d\tPreserves links\n"
|
||||
"\t-p\tPreserves file attributes if possible\n"
|
||||
"\t-f\tforce (implied; ignored) - always set\n"
|
||||
"\t-R\tCopies directories recursively\n"
|
||||
#endif
|
||||
,
|
||||
"mv SOURCE DEST\n"
|
||||
" or: mv SOURCE... DIRECTORY\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nRename SOURCE to DEST, or move SOURCE(s) to DIRECTORY.\n"
|
||||
#endif
|
||||
cp_usage,
|
||||
mv_usage
|
||||
};
|
||||
|
||||
static int recursiveFlag;
|
||||
|
26
cut.c
26
cut.c
@ -206,6 +206,19 @@ void cut()
|
||||
}
|
||||
}
|
||||
|
||||
const char cut_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 CHAR\tUse CHAR instead of tab as the field delimiter\n"
|
||||
"\t-s\tOnly output Lines if the include DELIM\n"
|
||||
"\t-f N\tPrint only these fields\n"
|
||||
"\t-n\tIgnored\n"
|
||||
#endif
|
||||
;
|
||||
|
||||
int cut_main(int argc, char **argv)
|
||||
{
|
||||
@ -213,18 +226,7 @@ int cut_main(int argc, char **argv)
|
||||
int numberFilenames = 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 CHAR\tUse CHAR instead of tab as the field delimiter\n"
|
||||
"\t-s\tOnly output Lines if the include DELIM\n"
|
||||
"\t-f N\tPrint only these fields\n"
|
||||
"\t-n\tIgnored\n"
|
||||
#endif
|
||||
);
|
||||
usage(cut_usage);
|
||||
|
||||
while (i < argc) {
|
||||
if (argv[i][0] == '-') {
|
||||
|
16
deallocvt.c
16
deallocvt.c
@ -13,19 +13,19 @@
|
||||
/* From <linux/vt.h> */
|
||||
#define VT_DISALLOCATE 0x5608 /* free memory associated to vt */
|
||||
|
||||
const char deallocvt_usage[] =
|
||||
"deallocvt N\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nDeallocate unused virtual terminal /dev/ttyN\n"
|
||||
#endif
|
||||
;
|
||||
|
||||
int deallocvt_main(int argc, char *argv[])
|
||||
{
|
||||
int fd, num, i;
|
||||
|
||||
if ((argc != 2) || (**(argv + 1) == '-')) {
|
||||
usage
|
||||
("deallocvt N\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nDeallocate unused virtual terminal /dev/ttyN\n"
|
||||
#endif
|
||||
);
|
||||
}
|
||||
if ((argc != 2) || (**(argv + 1) == '-'))
|
||||
usage(deallocvt_usage);
|
||||
|
||||
fd = get_console_fd("/dev/console");
|
||||
|
||||
|
16
dirname.c
16
dirname.c
@ -23,17 +23,19 @@
|
||||
#include "internal.h"
|
||||
#include <stdio.h>
|
||||
|
||||
const char dirname_usage[] =
|
||||
"dirname [FILENAME ...]\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nStrips non-directory suffix from FILENAME\n"
|
||||
#endif
|
||||
;
|
||||
|
||||
extern int dirname_main(int argc, char **argv)
|
||||
{
|
||||
char* s;
|
||||
|
||||
if ((argc < 2) || (**(argv + 1) == '-')) {
|
||||
usage("dirname [FILENAME ...]\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nStrips non-directory suffix from FILENAME\n"
|
||||
#endif
|
||||
);
|
||||
}
|
||||
if ((argc < 2) || (**(argv + 1) == '-'))
|
||||
usage(dirname_usage);
|
||||
argv++;
|
||||
|
||||
s=*argv+strlen(*argv)-1;
|
||||
|
@ -26,6 +26,12 @@
|
||||
#include <sys/stat.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
const char which_usage[] =
|
||||
"which [COMMAND ...]\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nLocates a COMMAND.\n"
|
||||
#endif
|
||||
;
|
||||
|
||||
extern int which_main(int argc, char **argv)
|
||||
{
|
||||
@ -34,13 +40,8 @@ extern int which_main(int argc, char **argv)
|
||||
struct stat filestat;
|
||||
int count = 0;
|
||||
|
||||
if (argc <= 1 || **(argv + 1) == '-') {
|
||||
usage("which [COMMAND ...]\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nLocates a COMMAND.\n"
|
||||
#endif
|
||||
);
|
||||
}
|
||||
if (argc <= 1 || **(argv + 1) == '-')
|
||||
usage(which_usage);
|
||||
argc--;
|
||||
|
||||
path_list = getenv("PATH");
|
||||
|
16
free.c
16
free.c
@ -25,6 +25,12 @@
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
const char free_usage[] =
|
||||
"free\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nDisplays the amount of free and used system memory\n"
|
||||
#endif
|
||||
;
|
||||
|
||||
extern int free_main(int argc, char **argv)
|
||||
{
|
||||
@ -53,14 +59,8 @@ extern int free_main(int argc, char **argv)
|
||||
info.sharedram*=info.mem_unit;
|
||||
info.bufferram*=info.mem_unit;
|
||||
}
|
||||
if (argc > 1 && **(argv + 1) == '-') {
|
||||
usage("free\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nDisplays the amount of free and used system memory\n"
|
||||
#endif
|
||||
);
|
||||
}
|
||||
|
||||
if (argc > 1 && **(argv + 1) == '-')
|
||||
usage(free_usage);
|
||||
|
||||
printf("%6s%13s%13s%13s%13s%13s\n", "", "total", "used", "free",
|
||||
"shared", "buffers");
|
||||
|
33
fsck_minix.c
33
fsck_minix.c
@ -288,25 +288,24 @@ static void leave(int status)
|
||||
exit(status);
|
||||
}
|
||||
|
||||
const char fsck_minix_usage[] =
|
||||
"Usage: fsck.minix [-larvsmf] /dev/name\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nPerforms a consistency check for MINIX filesystems.\n\n"
|
||||
"Options:\n"
|
||||
"\t-l\tLists all filenames\n"
|
||||
"\t-r\tPerform interactive repairs\n"
|
||||
"\t-a\tPerform automatic repairs\n"
|
||||
"\t-v\tverbose\n"
|
||||
"\t-s\tOutputs super-block information\n"
|
||||
"\t-m\tActivates MINIX-like \"mode not cleared\" warnings\n"
|
||||
"\t-f\tForce file system check.\n\n"
|
||||
#endif
|
||||
;
|
||||
|
||||
static void show_usage(void)
|
||||
{
|
||||
fprintf(stderr, "BusyBox v%s (%s) multi-call binary -- GPL2\n\n",
|
||||
BB_VER, BB_BT);
|
||||
fprintf(stderr, "Usage: %s [-larvsmf] /dev/name\n", applet_name);
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
fprintf(stderr,
|
||||
"\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-a\tPerform automatic repairs\n");
|
||||
fprintf(stderr, "\t-v\tverbose\n");
|
||||
fprintf(stderr, "\t-s\tOutputs super-block information\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);
|
||||
usage(fsck_minix_usage);
|
||||
}
|
||||
|
||||
static void die(const char *str)
|
||||
|
16
length.c
16
length.c
@ -4,15 +4,17 @@
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
const char length_usage[] =
|
||||
"length STRING\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nPrints out the length of the specified STRING.\n"
|
||||
#endif
|
||||
;
|
||||
|
||||
extern int length_main(int argc, char **argv)
|
||||
{
|
||||
if (argc != 2 || **(argv + 1) == '-') {
|
||||
usage("length STRING\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nPrints out the length of the specified STRING.\n"
|
||||
#endif
|
||||
);
|
||||
}
|
||||
if (argc != 2 || **(argv + 1) == '-')
|
||||
usage(length_usage);
|
||||
printf("%lu\n", (long)strlen(argv[1]));
|
||||
return (TRUE);
|
||||
}
|
||||
|
@ -26,18 +26,20 @@
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
const char mktemp_usage[] =
|
||||
"mktemp [-q] TEMPLATE\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nCreates a temporary file with its name based on TEMPLATE.\n"
|
||||
"TEMPLATE is any name with six `Xs' (i.e. /tmp/temp.XXXXXX).\n"
|
||||
#endif
|
||||
;
|
||||
|
||||
extern int mktemp_main(int argc, char **argv)
|
||||
{
|
||||
if (argc != 2 && (argc != 3 || strcmp(argv[1], "-q")))
|
||||
usage ("mktemp [-q] TEMPLATE\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nCreates a temporary file with its name based on TEMPLATE.\n"
|
||||
"TEMPLATE is any name with six `Xs' (i.e. /tmp/temp.XXXXXX).\n"
|
||||
#endif
|
||||
);
|
||||
usage(mktemp_usage);
|
||||
if(mkstemp(argv[argc-1]) < 0)
|
||||
exit(FALSE);
|
||||
exit(FALSE);
|
||||
(void) puts(argv[argc-1]);
|
||||
return(TRUE);
|
||||
}
|
||||
|
32
mkfs_minix.c
32
mkfs_minix.c
@ -267,27 +267,23 @@ static volatile void die(char *str)
|
||||
exit(8);
|
||||
}
|
||||
|
||||
const char mkfs_minix_usage[] =
|
||||
"mkfs.minix [-c | -l filename] [-nXX] [-iXX] /dev/name [blocks]\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nMake a MINIX filesystem.\n\n"
|
||||
"Options:\n"
|
||||
"\t-c\t\tCheck the device for bad blocks\n"
|
||||
"\t-n [14|30]\tSpecify the maximum length of filenames\n"
|
||||
"\t-i INODES\tSpecify the number of inodes for the filesystem\n"
|
||||
"\t-l FILENAME\tRead the bad blocks list from FILENAME\n"
|
||||
"\t-v\t\tMake a Minix version 2 filesystem\n\n"
|
||||
#endif
|
||||
;
|
||||
|
||||
static volatile void show_usage() __attribute__ ((noreturn));
|
||||
static volatile void show_usage()
|
||||
{
|
||||
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",
|
||||
applet_name);
|
||||
#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,
|
||||
"\t-n [14|30]\tSpecify the maximum length of filenames\n");
|
||||
fprintf(stderr,
|
||||
"\t-i INODES\tSpecify the number of inodes for the filesystem\n");
|
||||
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);
|
||||
usage(mkfs_minix_usage);
|
||||
}
|
||||
|
||||
/*
|
||||
|
16
mktemp.c
16
mktemp.c
@ -26,18 +26,20 @@
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
const char mktemp_usage[] =
|
||||
"mktemp [-q] TEMPLATE\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nCreates a temporary file with its name based on TEMPLATE.\n"
|
||||
"TEMPLATE is any name with six `Xs' (i.e. /tmp/temp.XXXXXX).\n"
|
||||
#endif
|
||||
;
|
||||
|
||||
extern int mktemp_main(int argc, char **argv)
|
||||
{
|
||||
if (argc != 2 && (argc != 3 || strcmp(argv[1], "-q")))
|
||||
usage ("mktemp [-q] TEMPLATE\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nCreates a temporary file with its name based on TEMPLATE.\n"
|
||||
"TEMPLATE is any name with six `Xs' (i.e. /tmp/temp.XXXXXX).\n"
|
||||
#endif
|
||||
);
|
||||
usage(mktemp_usage);
|
||||
if(mkstemp(argv[argc-1]) < 0)
|
||||
exit(FALSE);
|
||||
exit(FALSE);
|
||||
(void) puts(argv[argc-1]);
|
||||
return(TRUE);
|
||||
}
|
||||
|
@ -25,6 +25,12 @@
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
const char free_usage[] =
|
||||
"free\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nDisplays the amount of free and used system memory\n"
|
||||
#endif
|
||||
;
|
||||
|
||||
extern int free_main(int argc, char **argv)
|
||||
{
|
||||
@ -53,14 +59,8 @@ extern int free_main(int argc, char **argv)
|
||||
info.sharedram*=info.mem_unit;
|
||||
info.bufferram*=info.mem_unit;
|
||||
}
|
||||
if (argc > 1 && **(argv + 1) == '-') {
|
||||
usage("free\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nDisplays the amount of free and used system memory\n"
|
||||
#endif
|
||||
);
|
||||
}
|
||||
|
||||
if (argc > 1 && **(argv + 1) == '-')
|
||||
usage(free_usage);
|
||||
|
||||
printf("%6s%13s%13s%13s%13s%13s\n", "", "total", "used", "free",
|
||||
"shared", "buffers");
|
||||
|
19
procps/ps.c
19
procps/ps.c
@ -114,6 +114,13 @@ static void parse_proc_status(char *S, proc_t * P)
|
||||
|
||||
}
|
||||
|
||||
const char ps_usage[] =
|
||||
"ps\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nReport process status\n"
|
||||
"\nThis version of ps accepts no options.\n"
|
||||
#endif
|
||||
;
|
||||
|
||||
extern int ps_main(int argc, char **argv)
|
||||
{
|
||||
@ -134,14 +141,8 @@ extern int ps_main(int argc, char **argv)
|
||||
|
||||
|
||||
|
||||
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
|
||||
);
|
||||
}
|
||||
if (argc > 1 && strcmp(argv[1], dash_dash_help) == 0)
|
||||
usage(ps_usage);
|
||||
|
||||
dir = opendir("/proc");
|
||||
if (!dir)
|
||||
@ -223,7 +224,7 @@ extern int ps_main(int argc, char **argv)
|
||||
#endif
|
||||
|
||||
if (argc > 1 && **(argv + 1) == '-')
|
||||
usage("ps-devps\n\nReport process status\n\nThis version of ps accepts no options.\n\n");
|
||||
usage(ps_usage);
|
||||
|
||||
/* open device */
|
||||
fd = open(device, O_RDONLY);
|
||||
|
19
ps.c
19
ps.c
@ -114,6 +114,13 @@ static void parse_proc_status(char *S, proc_t * P)
|
||||
|
||||
}
|
||||
|
||||
const char ps_usage[] =
|
||||
"ps\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nReport process status\n"
|
||||
"\nThis version of ps accepts no options.\n"
|
||||
#endif
|
||||
;
|
||||
|
||||
extern int ps_main(int argc, char **argv)
|
||||
{
|
||||
@ -134,14 +141,8 @@ extern int ps_main(int argc, char **argv)
|
||||
|
||||
|
||||
|
||||
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
|
||||
);
|
||||
}
|
||||
if (argc > 1 && strcmp(argv[1], dash_dash_help) == 0)
|
||||
usage(ps_usage);
|
||||
|
||||
dir = opendir("/proc");
|
||||
if (!dir)
|
||||
@ -223,7 +224,7 @@ extern int ps_main(int argc, char **argv)
|
||||
#endif
|
||||
|
||||
if (argc > 1 && **(argv + 1) == '-')
|
||||
usage("ps-devps\n\nReport process status\n\nThis version of ps accepts no options.\n\n");
|
||||
usage(ps_usage);
|
||||
|
||||
/* open device */
|
||||
fd = open(device, O_RDONLY);
|
||||
|
16
rmdir.c
16
rmdir.c
@ -26,17 +26,17 @@
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
const char rmdir_usage[] =
|
||||
"rmdir [OPTION]... DIRECTORY...\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nRemove the DIRECTORY(ies), if they are empty.\n"
|
||||
#endif
|
||||
;
|
||||
|
||||
extern int rmdir_main(int argc, char **argv)
|
||||
{
|
||||
if (argc == 1 || **(argv + 1) == '-') {
|
||||
usage
|
||||
("rmdir [OPTION]... DIRECTORY...\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nRemove the DIRECTORY(ies), if they are empty.\n"
|
||||
#endif
|
||||
);
|
||||
}
|
||||
if (argc == 1 || **(argv + 1) == '-')
|
||||
usage(rmdir_usage);
|
||||
|
||||
while (--argc > 0) {
|
||||
if (rmdir(*(++argv)) == -1) {
|
||||
|
16
sync.c
16
sync.c
@ -24,14 +24,16 @@
|
||||
#include "internal.h"
|
||||
#include <stdio.h>
|
||||
|
||||
const char sync_usage[] =
|
||||
"sync\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nWrite all buffered filesystem blocks to disk.\n"
|
||||
#endif
|
||||
;
|
||||
|
||||
extern int sync_main(int argc, char **argv)
|
||||
{
|
||||
if (argc > 1 && **(argv + 1) == '-') {
|
||||
usage("sync\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nWrite all buffered filesystem blocks to disk.\n"
|
||||
#endif
|
||||
);
|
||||
}
|
||||
if (argc > 1 && **(argv + 1) == '-')
|
||||
usage(sync_usage);
|
||||
return(sync());
|
||||
}
|
||||
|
20
test.c
20
test.c
@ -178,6 +178,15 @@ static int test_eaccess();
|
||||
static int is_a_group_member();
|
||||
static void initialize_group_array();
|
||||
|
||||
const char test_usage[] =
|
||||
"test 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
|
||||
;
|
||||
|
||||
extern int
|
||||
test_main(int argc, char** argv)
|
||||
{
|
||||
@ -188,15 +197,8 @@ test_main(int argc, char** argv)
|
||||
fatalError("missing ]\n");
|
||||
argv[argc] = NULL;
|
||||
}
|
||||
if (strcmp(argv[1], dash_dash_help) == 0) {
|
||||
usage("test 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
|
||||
);
|
||||
}
|
||||
if (strcmp(argv[1], dash_dash_help) == 0)
|
||||
usage(test_usage);
|
||||
|
||||
/* Implement special cases from POSIX.2, section 4.62.4 */
|
||||
switch (argc) {
|
||||
|
@ -288,25 +288,24 @@ static void leave(int status)
|
||||
exit(status);
|
||||
}
|
||||
|
||||
const char fsck_minix_usage[] =
|
||||
"Usage: fsck.minix [-larvsmf] /dev/name\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nPerforms a consistency check for MINIX filesystems.\n\n"
|
||||
"Options:\n"
|
||||
"\t-l\tLists all filenames\n"
|
||||
"\t-r\tPerform interactive repairs\n"
|
||||
"\t-a\tPerform automatic repairs\n"
|
||||
"\t-v\tverbose\n"
|
||||
"\t-s\tOutputs super-block information\n"
|
||||
"\t-m\tActivates MINIX-like \"mode not cleared\" warnings\n"
|
||||
"\t-f\tForce file system check.\n\n"
|
||||
#endif
|
||||
;
|
||||
|
||||
static void show_usage(void)
|
||||
{
|
||||
fprintf(stderr, "BusyBox v%s (%s) multi-call binary -- GPL2\n\n",
|
||||
BB_VER, BB_BT);
|
||||
fprintf(stderr, "Usage: %s [-larvsmf] /dev/name\n", applet_name);
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
fprintf(stderr,
|
||||
"\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-a\tPerform automatic repairs\n");
|
||||
fprintf(stderr, "\t-v\tverbose\n");
|
||||
fprintf(stderr, "\t-s\tOutputs super-block information\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);
|
||||
usage(fsck_minix_usage);
|
||||
}
|
||||
|
||||
static void die(const char *str)
|
||||
|
@ -267,27 +267,23 @@ static volatile void die(char *str)
|
||||
exit(8);
|
||||
}
|
||||
|
||||
const char mkfs_minix_usage[] =
|
||||
"mkfs.minix [-c | -l filename] [-nXX] [-iXX] /dev/name [blocks]\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nMake a MINIX filesystem.\n\n"
|
||||
"Options:\n"
|
||||
"\t-c\t\tCheck the device for bad blocks\n"
|
||||
"\t-n [14|30]\tSpecify the maximum length of filenames\n"
|
||||
"\t-i INODES\tSpecify the number of inodes for the filesystem\n"
|
||||
"\t-l FILENAME\tRead the bad blocks list from FILENAME\n"
|
||||
"\t-v\t\tMake a Minix version 2 filesystem\n\n"
|
||||
#endif
|
||||
;
|
||||
|
||||
static volatile void show_usage() __attribute__ ((noreturn));
|
||||
static volatile void show_usage()
|
||||
{
|
||||
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",
|
||||
applet_name);
|
||||
#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,
|
||||
"\t-n [14|30]\tSpecify the maximum length of filenames\n");
|
||||
fprintf(stderr,
|
||||
"\t-i INODES\tSpecify the number of inodes for the filesystem\n");
|
||||
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);
|
||||
usage(mkfs_minix_usage);
|
||||
}
|
||||
|
||||
/*
|
||||
|
15
which.c
15
which.c
@ -26,6 +26,12 @@
|
||||
#include <sys/stat.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
const char which_usage[] =
|
||||
"which [COMMAND ...]\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nLocates a COMMAND.\n"
|
||||
#endif
|
||||
;
|
||||
|
||||
extern int which_main(int argc, char **argv)
|
||||
{
|
||||
@ -34,13 +40,8 @@ extern int which_main(int argc, char **argv)
|
||||
struct stat filestat;
|
||||
int count = 0;
|
||||
|
||||
if (argc <= 1 || **(argv + 1) == '-') {
|
||||
usage("which [COMMAND ...]\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nLocates a COMMAND.\n"
|
||||
#endif
|
||||
);
|
||||
}
|
||||
if (argc <= 1 || **(argv + 1) == '-')
|
||||
usage(which_usage);
|
||||
argc--;
|
||||
|
||||
path_list = getenv("PATH");
|
||||
|
16
yes.c
16
yes.c
@ -23,17 +23,19 @@
|
||||
#include "internal.h"
|
||||
#include <stdio.h>
|
||||
|
||||
const char yes_usage[] =
|
||||
"yes [OPTION]... [STRING]...\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nRepeatedly outputs a line with all specified STRING(s), or `y'.\n"
|
||||
#endif
|
||||
;
|
||||
|
||||
extern int yes_main(int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (argc >= 2 && *argv[1] == '-') {
|
||||
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 >= 2 && *argv[1] == '-')
|
||||
usage(yes_usage);
|
||||
|
||||
if (argc == 1) {
|
||||
while (1)
|
||||
|
Loading…
Reference in New Issue
Block a user