getopt32: remove applet_long_options
FEATURE_GETOPT_LONG made dependent on LONG_OPTS. The folloving options are removed, now LONG_OPTS enables long options for affected applets: FEATURE_ENV_LONG_OPTIONS FEATURE_EXPAND_LONG_OPTIONS FEATURE_UNEXPAND_LONG_OPTIONS FEATURE_MKDIR_LONG_OPTIONS FEATURE_MV_LONG_OPTIONS FEATURE_RMDIR_LONG_OPTIONS FEATURE_ADDGROUP_LONG_OPTIONS FEATURE_ADDUSER_LONG_OPTIONS FEATURE_HWCLOCK_LONG_OPTIONS FEATURE_NSENTER_LONG_OPTS FEATURE_CHCON_LONG_OPTIONS FEATURE_RUNCON_LONG_OPTIONS They either had a small number of long options, or their long options are essential. Example: upstream addgroup and adduser have ONLY longopts, we should probably go further and get rid of non-standard short options. To this end, make addgroup and adduser "select LONG_OPTS". We had this breakage caused by us even in our own package! #if ENABLE_LONG_OPTS || !ENABLE_ADDGROUP /* We try to use --gid, not -g, because "standard" addgroup * has no short option -g, it has only long --gid. */ argv[1] = (char*)"--gid"; #else /* Breaks if system in fact does NOT use busybox addgroup */ argv[1] = (char*)"-g"; #endif xargs: its lone longopt no longer depends on DESKTOP, only on LONG_OPTS. hwclock TODO: get rid of incompatible -t, -l aliases to --systz, --localtime Shorten help texts by omitting long option when short opt alternative exists. Reduction of size comes from the fact that store of an immediate (an address of longopts) to a fixed address (global variable) is a longer insn than pushing that immediate or passing it in a register. This effect is CPU-agnostic. function old new delta getopt32 1350 22 -1328 vgetopt32 - 1318 +1318 getopt32long - 24 +24 tftpd_main 562 567 +5 scan_recursive 376 380 +4 collect_cpu 545 546 +1 date_main 1096 1095 -1 hostname_main 262 259 -3 uname_main 259 255 -4 setpriv_main 362 358 -4 rmdir_main 191 187 -4 mv_main 562 558 -4 ipcalc_main 548 544 -4 ifenslave_main 641 637 -4 gzip_main 192 188 -4 gunzip_main 77 73 -4 fsfreeze_main 81 77 -4 flock_main 318 314 -4 deluser_main 337 333 -4 cp_main 374 370 -4 chown_main 175 171 -4 applet_long_options 4 - -4 xargs_main 894 889 -5 wget_main 2540 2535 -5 udhcpc_main 2767 2762 -5 touch_main 436 431 -5 tar_main 1014 1009 -5 start_stop_daemon_main 1033 1028 -5 sed_main 682 677 -5 script_main 1082 1077 -5 run_parts_main 330 325 -5 rtcwake_main 459 454 -5 od_main 2169 2164 -5 nl_main 201 196 -5 modprobe_main 773 768 -5 mkdir_main 160 155 -5 ls_main 568 563 -5 install_main 773 768 -5 hwclock_main 411 406 -5 getopt_main 622 617 -5 fstrim_main 256 251 -5 env_main 198 193 -5 dumpleases_main 635 630 -5 dpkg_main 3991 3986 -5 diff_main 1355 1350 -5 cryptpw_main 233 228 -5 cpio_main 593 588 -5 conspy_main 1135 1130 -5 chpasswd_main 313 308 -5 adduser_main 887 882 -5 addgroup_main 416 411 -5 ftpgetput_main 351 345 -6 get_terminal_width_height 242 234 -8 expand_main 690 680 -10 static.expand_longopts 18 - -18 static.unexpand_longopts 27 - -27 mkdir_longopts 28 - -28 env_longopts 30 - -30 static.ifenslave_longopts 34 - -34 mv_longopts 46 - -46 static.rmdir_longopts 48 - -48 packed_usage 31739 31687 -52 ------------------------------------------------------------------------------ (add/remove: 2/8 grow/shrink: 3/49 up/down: 1352/-1840) Total: -488 bytes text data bss dec hex filename 915681 485 6880 923046 e15a6 busybox_old 915428 485 6876 922789 e14a5 busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
00677b5e35
commit
036585a911
@ -389,9 +389,10 @@ int gunzip_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int gunzip_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
#if ENABLE_FEATURE_GUNZIP_LONG_OPTIONS
|
||||
applet_long_options = gunzip_longopts;
|
||||
#endif
|
||||
getopt32long(argv, "cfkvqdtn", gunzip_longopts);
|
||||
#else
|
||||
getopt32(argv, "cfkvqdtn");
|
||||
#endif
|
||||
argv += optind;
|
||||
|
||||
/* If called as zcat...
|
||||
|
@ -360,9 +360,8 @@ int cpio_main(int argc UNUSED_PARAM, char **argv)
|
||||
char *cpio_owner;
|
||||
IF_FEATURE_CPIO_O(const char *cpio_fmt = "";)
|
||||
unsigned opt;
|
||||
|
||||
#if ENABLE_LONG_OPTS
|
||||
applet_long_options =
|
||||
const char *long_opts =
|
||||
"extract\0" No_argument "i"
|
||||
"list\0" No_argument "t"
|
||||
#if ENABLE_FEATURE_CPIO_O
|
||||
@ -390,9 +389,9 @@ int cpio_main(int argc UNUSED_PARAM, char **argv)
|
||||
/* -L makes sense only with -o or -p */
|
||||
|
||||
#if !ENABLE_FEATURE_CPIO_O
|
||||
opt = getopt32(argv, OPTION_STR, &cpio_filename, &cpio_owner);
|
||||
opt = getopt32long(argv, OPTION_STR, long_opts, &cpio_filename, &cpio_owner);
|
||||
#else
|
||||
opt = getopt32(argv, OPTION_STR "oH:" IF_FEATURE_CPIO_P("p"),
|
||||
opt = getopt32long(argv, OPTION_STR "oH:" IF_FEATURE_CPIO_P("p"), long_opts,
|
||||
&cpio_filename, &cpio_owner, &cpio_fmt);
|
||||
#endif
|
||||
argv += optind;
|
||||
|
@ -1766,8 +1766,7 @@ int dpkg_main(int argc UNUSED_PARAM, char **argv)
|
||||
|
||||
INIT_G();
|
||||
|
||||
IF_LONG_OPTS(applet_long_options = dpkg_longopts);
|
||||
opt = getopt32(argv, "CilPruF:", &str_f);
|
||||
opt = getopt32long(argv, "CilPruF:", dpkg_longopts, &str_f);
|
||||
argv += optind;
|
||||
//if (opt & OPT_configure) ... // -C
|
||||
if (opt & OPT_force) { // -F (--force in official dpkg)
|
||||
|
@ -2216,11 +2216,12 @@ int gzip_main(int argc UNUSED_PARAM, char **argv)
|
||||
SET_PTR_TO_GLOBALS((char *)xzalloc(sizeof(struct globals)+sizeof(struct globals2))
|
||||
+ sizeof(struct globals));
|
||||
|
||||
#if ENABLE_FEATURE_GZIP_LONG_OPTIONS
|
||||
applet_long_options = gzip_longopts;
|
||||
#endif
|
||||
/* Must match bbunzip's constants OPT_STDOUT, OPT_FORCE! */
|
||||
#if ENABLE_FEATURE_GZIP_LONG_OPTIONS
|
||||
opt = getopt32long(argv, "cfkv" IF_FEATURE_GZIP_DECOMPRESS("dt") "qn123456789", gzip_longopts);
|
||||
#else
|
||||
opt = getopt32(argv, "cfkv" IF_FEATURE_GZIP_DECOMPRESS("dt") "qn123456789");
|
||||
#endif
|
||||
#if ENABLE_FEATURE_GZIP_DECOMPRESS /* gunzip_main may not be visible... */
|
||||
if (opt & 0x30) // -d and/or -t
|
||||
return gunzip_main(argc, argv);
|
||||
|
@ -940,6 +940,11 @@ static const char tar_longopts[] ALIGN1 =
|
||||
"exclude\0" Required_argument "\xff"
|
||||
# endif
|
||||
;
|
||||
# define GETOPT32 getopt32long
|
||||
# define LONGOPTS ,tar_longopts
|
||||
#else
|
||||
# define GETOPT32 getopt32
|
||||
# define LONGOPTS
|
||||
#endif
|
||||
|
||||
int tar_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
@ -980,9 +985,6 @@ int tar_main(int argc UNUSED_PARAM, char **argv)
|
||||
":\xf9+" // --strip-components=NUM
|
||||
#endif
|
||||
;
|
||||
#if ENABLE_FEATURE_TAR_LONG_OPTIONS
|
||||
applet_long_options = tar_longopts;
|
||||
#endif
|
||||
#if ENABLE_DESKTOP
|
||||
/* Lie to buildroot when it starts asking stupid questions. */
|
||||
if (argv[1] && strcmp(argv[1], "--version") == 0) {
|
||||
@ -1019,7 +1021,7 @@ int tar_main(int argc UNUSED_PARAM, char **argv)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
opt = getopt32(argv,
|
||||
opt = GETOPT32(argv,
|
||||
"txC:f:Oopvk"
|
||||
IF_FEATURE_TAR_CREATE( "ch" )
|
||||
IF_FEATURE_SEAMLESS_BZ2( "j" )
|
||||
@ -1030,6 +1032,7 @@ int tar_main(int argc UNUSED_PARAM, char **argv)
|
||||
IF_FEATURE_SEAMLESS_Z( "Z" )
|
||||
IF_FEATURE_TAR_NOPRESERVE_TIME("m")
|
||||
IF_FEATURE_TAR_LONG_OPTIONS("\xf9:") // --strip-components
|
||||
LONGOPTS
|
||||
, &base_dir // -C dir
|
||||
, &tar_filename // -f filename
|
||||
IF_FEATURE_TAR_FROM(, &(tar_handle->accept)) // T
|
||||
|
@ -127,11 +127,12 @@ int chown_main(int argc UNUSED_PARAM, char **argv)
|
||||
int opt, flags;
|
||||
struct param_t param;
|
||||
|
||||
#if ENABLE_FEATURE_CHOWN_LONG_OPTIONS
|
||||
applet_long_options = chown_longopts;
|
||||
#endif
|
||||
opt_complementary = "-2";
|
||||
#if ENABLE_FEATURE_CHOWN_LONG_OPTIONS
|
||||
opt = getopt32long(argv, OPT_STR, chown_longopts);
|
||||
#else
|
||||
opt = getopt32(argv, OPT_STR);
|
||||
#endif
|
||||
argv += optind;
|
||||
|
||||
/* This matches coreutils behavior (almost - see below) */
|
||||
|
@ -81,7 +81,7 @@ int cp_main(int argc, char **argv)
|
||||
// -a = -pdR
|
||||
opt_complementary = "-2:l--s:s--l:Pd:rRd:Rd:apdR";
|
||||
#if ENABLE_FEATURE_CP_LONG_OPTIONS
|
||||
applet_long_options =
|
||||
flags = getopt32long(argv, FILEUTILS_CP_OPTSTR,
|
||||
"archive\0" No_argument "a"
|
||||
"force\0" No_argument "f"
|
||||
"interactive\0" No_argument "i"
|
||||
@ -94,9 +94,10 @@ int cp_main(int argc, char **argv)
|
||||
"update\0" No_argument "u"
|
||||
"remove-destination\0" No_argument "\xff"
|
||||
"parents\0" No_argument "\xfe"
|
||||
;
|
||||
#endif
|
||||
);
|
||||
#else
|
||||
flags = getopt32(argv, FILEUTILS_CP_OPTSTR);
|
||||
#endif
|
||||
/* Options of cp from GNU coreutils 6.10:
|
||||
* -a, --archive
|
||||
* -f, --force
|
||||
|
@ -194,9 +194,8 @@ int date_main(int argc UNUSED_PARAM, char **argv)
|
||||
|
||||
opt_complementary = "d--s:s--d"
|
||||
IF_FEATURE_DATE_ISOFMT(":R--I:I--R");
|
||||
IF_LONG_OPTS(applet_long_options = date_longopts;)
|
||||
opt = getopt32(argv, "Rs:ud:r:"
|
||||
IF_FEATURE_DATE_ISOFMT("I::D:"),
|
||||
opt = getopt32long(argv, "Rs:ud:r:"
|
||||
IF_FEATURE_DATE_ISOFMT("I::D:"), date_longopts,
|
||||
&date_str, &date_str, &filename
|
||||
IF_FEATURE_DATE_ISOFMT(, &isofmt_arg, &fmt_str2dt));
|
||||
argv += optind;
|
||||
|
@ -30,11 +30,6 @@
|
||||
//config: env is used to set an environment variable and run
|
||||
//config: a command; without options it displays the current
|
||||
//config: environment.
|
||||
//config:
|
||||
//config:config FEATURE_ENV_LONG_OPTIONS
|
||||
//config: bool "Enable long options"
|
||||
//config: default y
|
||||
//config: depends on ENV && LONG_OPTS
|
||||
|
||||
//applet:IF_ENV(APPLET_NOEXEC(env, env, BB_DIR_USR_BIN, BB_SUID_DROP, env))
|
||||
|
||||
@ -53,23 +48,17 @@
|
||||
|
||||
#include "libbb.h"
|
||||
|
||||
#if ENABLE_FEATURE_ENV_LONG_OPTIONS
|
||||
static const char env_longopts[] ALIGN1 =
|
||||
"ignore-environment\0" No_argument "i"
|
||||
"unset\0" Required_argument "u"
|
||||
;
|
||||
#endif
|
||||
|
||||
int env_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int env_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
unsigned opts;
|
||||
llist_t *unset_env = NULL;
|
||||
|
||||
#if ENABLE_FEATURE_ENV_LONG_OPTIONS
|
||||
applet_long_options = env_longopts;
|
||||
#endif
|
||||
opts = getopt32(argv, "+iu:+", &unset_env);
|
||||
opts = getopt32long(argv, "+iu:+",
|
||||
"ignore-environment\0" No_argument "i"
|
||||
"unset\0" Required_argument "u"
|
||||
, &unset_env
|
||||
);
|
||||
argv += optind;
|
||||
if (argv[0] && LONE_DASH(argv[0])) {
|
||||
opts |= 1;
|
||||
|
@ -26,21 +26,11 @@
|
||||
//config: help
|
||||
//config: By default, convert all tabs to spaces.
|
||||
//config:
|
||||
//config:config FEATURE_EXPAND_LONG_OPTIONS
|
||||
//config: bool "Enable long options"
|
||||
//config: default y
|
||||
//config: depends on EXPAND && LONG_OPTS
|
||||
//config:
|
||||
//config:config UNEXPAND
|
||||
//config: bool "unexpand (6 kb)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: By default, convert only leading sequences of blanks to tabs.
|
||||
//config:
|
||||
//config:config FEATURE_UNEXPAND_LONG_OPTIONS
|
||||
//config: bool "Enable long options"
|
||||
//config: default y
|
||||
//config: depends on UNEXPAND && LONG_OPTS
|
||||
|
||||
//applet:IF_EXPAND(APPLET(expand, BB_DIR_USR_BIN, BB_SUID_DROP))
|
||||
// APPLET_ODDNAME:name main location suid_type help
|
||||
@ -53,29 +43,16 @@
|
||||
//usage: "[-i] [-t N] [FILE]..."
|
||||
//usage:#define expand_full_usage "\n\n"
|
||||
//usage: "Convert tabs to spaces, writing to stdout\n"
|
||||
//usage: IF_FEATURE_EXPAND_LONG_OPTIONS(
|
||||
//usage: "\n -i,--initial Don't convert tabs after non blanks"
|
||||
//usage: "\n -t,--tabs N Tabstops every N chars"
|
||||
//usage: )
|
||||
//usage: IF_NOT_FEATURE_EXPAND_LONG_OPTIONS(
|
||||
//usage: "\n -i Don't convert tabs after non blanks"
|
||||
//usage: "\n -t Tabstops every N chars"
|
||||
//usage: )
|
||||
|
||||
//usage:#define unexpand_trivial_usage
|
||||
//usage: "[-fa][-t N] [FILE]..."
|
||||
//usage:#define unexpand_full_usage "\n\n"
|
||||
//usage: "Convert spaces to tabs, writing to stdout\n"
|
||||
//usage: IF_FEATURE_UNEXPAND_LONG_OPTIONS(
|
||||
//usage: "\n -a,--all Convert all blanks"
|
||||
//usage: "\n -f,--first-only Convert only leading blanks"
|
||||
//usage: "\n -t,--tabs N Tabstops every N chars"
|
||||
//usage: )
|
||||
//usage: IF_NOT_FEATURE_UNEXPAND_LONG_OPTIONS(
|
||||
//usage: "\n -a Convert all blanks"
|
||||
//usage: "\n -f Convert only leading blanks"
|
||||
//usage: "\n -t N Tabstops every N chars"
|
||||
//usage: )
|
||||
|
||||
#include "libbb.h"
|
||||
#include "unicode.h"
|
||||
@ -188,31 +165,23 @@ int expand_main(int argc UNUSED_PARAM, char **argv)
|
||||
unsigned opt;
|
||||
int exit_status = EXIT_SUCCESS;
|
||||
|
||||
#if ENABLE_FEATURE_EXPAND_LONG_OPTIONS
|
||||
static const char expand_longopts[] ALIGN1 =
|
||||
/* name, has_arg, val */
|
||||
"initial\0" No_argument "i"
|
||||
"tabs\0" Required_argument "t"
|
||||
;
|
||||
#endif
|
||||
#if ENABLE_FEATURE_UNEXPAND_LONG_OPTIONS
|
||||
static const char unexpand_longopts[] ALIGN1 =
|
||||
/* name, has_arg, val */
|
||||
"first-only\0" No_argument "i"
|
||||
"tabs\0" Required_argument "t"
|
||||
"all\0" No_argument "a"
|
||||
;
|
||||
#endif
|
||||
init_unicode();
|
||||
|
||||
if (ENABLE_EXPAND && (!ENABLE_UNEXPAND || applet_name[0] == 'e')) {
|
||||
IF_FEATURE_EXPAND_LONG_OPTIONS(applet_long_options = expand_longopts);
|
||||
opt = getopt32(argv, "it:", &opt_t);
|
||||
opt = getopt32long(argv, "it:",
|
||||
"initial\0" No_argument "i"
|
||||
"tabs\0" Required_argument "t"
|
||||
, &opt_t
|
||||
);
|
||||
} else {
|
||||
IF_FEATURE_UNEXPAND_LONG_OPTIONS(applet_long_options = unexpand_longopts);
|
||||
/* -t NUM sets also -a */
|
||||
opt_complementary = "ta";
|
||||
opt = getopt32(argv, "ft:a", &opt_t);
|
||||
opt = getopt32long(argv, "ft:a",
|
||||
"first-only\0" No_argument "i"
|
||||
"tabs\0" Required_argument "t"
|
||||
"all\0" No_argument "a"
|
||||
, &opt_t
|
||||
);
|
||||
/* -f --first-only is the default */
|
||||
if (!(opt & OPT_ALL)) opt |= OPT_INITIAL;
|
||||
}
|
||||
|
@ -55,12 +55,17 @@ static const char install_longopts[] ALIGN1 =
|
||||
"target-directory\0" Required_argument "t"
|
||||
/* autofs build insists of using -b --suffix=.orig */
|
||||
/* TODO? (short option for --suffix is -S) */
|
||||
#if ENABLE_SELINUX
|
||||
# if ENABLE_SELINUX
|
||||
"context\0" Required_argument "Z"
|
||||
"preserve_context\0" No_argument "\xff"
|
||||
"preserve-context\0" No_argument "\xff"
|
||||
#endif
|
||||
# endif
|
||||
;
|
||||
# define GETOPT32 getopt32long
|
||||
# define LONGOPTS install_longopts,
|
||||
#else
|
||||
# define GETOPT32 getopt32
|
||||
# define LONGOPTS
|
||||
#endif
|
||||
|
||||
|
||||
@ -135,15 +140,14 @@ int install_main(int argc, char **argv)
|
||||
#endif
|
||||
};
|
||||
|
||||
#if ENABLE_FEATURE_INSTALL_LONG_OPTIONS
|
||||
applet_long_options = install_longopts;
|
||||
#endif
|
||||
opt_complementary = "t--d:d--t:s--d:d--s" IF_FEATURE_INSTALL_LONG_OPTIONS(IF_SELINUX(":Z--\xff:\xff--Z"));
|
||||
/* -c exists for backwards compatibility, it's needed */
|
||||
/* -b is ignored ("make a backup of each existing destination file") */
|
||||
opts = getopt32(argv, "cvb" "Ddpsg:m:o:t:" IF_SELINUX("Z:"),
|
||||
opts = GETOPT32(argv, "cvb" "Ddpsg:m:o:t:" IF_SELINUX("Z:"),
|
||||
LONGOPTS
|
||||
&gid_str, &mode_str, &uid_str, &last
|
||||
IF_SELINUX(, &scontext));
|
||||
IF_SELINUX(, &scontext)
|
||||
);
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
|
@ -1093,7 +1093,6 @@ int ls_main(int argc UNUSED_PARAM, char **argv)
|
||||
#endif
|
||||
|
||||
/* process options */
|
||||
IF_LONG_OPTS(applet_long_options = ls_longopts;)
|
||||
opt_complementary =
|
||||
/* -n and -g imply -l */
|
||||
"nl:gl"
|
||||
@ -1111,7 +1110,7 @@ int ls_main(int argc UNUSED_PARAM, char **argv)
|
||||
IF_FEATURE_LS_TIMESTAMPS(":c-u:u-c") /* mtime/atime */
|
||||
/* -w NUM: */
|
||||
IF_FEATURE_LS_WIDTH(":w+");
|
||||
opt = getopt32(argv, ls_options
|
||||
opt = getopt32long(argv, ls_options, ls_longopts
|
||||
IF_FEATURE_LS_WIDTH(, /*-T*/ NULL, /*-w*/ &G_terminal_width)
|
||||
IF_FEATURE_LS_COLOR(, &color_opt)
|
||||
);
|
||||
|
@ -18,11 +18,6 @@
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: mkdir is used to create directories with the specified names.
|
||||
//config:
|
||||
//config:config FEATURE_MKDIR_LONG_OPTIONS
|
||||
//config: bool "Enable long options"
|
||||
//config: default y
|
||||
//config: depends on MKDIR && LONG_OPTS
|
||||
|
||||
//applet:IF_MKDIR(APPLET_NOFORK(mkdir, mkdir, BB_DIR_BIN, BB_SUID_DROP, mkdir))
|
||||
|
||||
@ -53,19 +48,6 @@
|
||||
|
||||
/* This is a NOFORK applet. Be very careful! */
|
||||
|
||||
#if ENABLE_FEATURE_MKDIR_LONG_OPTIONS
|
||||
static const char mkdir_longopts[] ALIGN1 =
|
||||
"mode\0" Required_argument "m"
|
||||
"parents\0" No_argument "p"
|
||||
#if ENABLE_SELINUX
|
||||
"context\0" Required_argument "Z"
|
||||
#endif
|
||||
#if ENABLE_FEATURE_VERBOSE
|
||||
"verbose\0" No_argument "v"
|
||||
#endif
|
||||
;
|
||||
#endif
|
||||
|
||||
int mkdir_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int mkdir_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
@ -78,10 +60,17 @@ int mkdir_main(int argc UNUSED_PARAM, char **argv)
|
||||
security_context_t scontext;
|
||||
#endif
|
||||
|
||||
#if ENABLE_FEATURE_MKDIR_LONG_OPTIONS
|
||||
applet_long_options = mkdir_longopts;
|
||||
#endif
|
||||
opt = getopt32(argv, "m:pv" IF_SELINUX("Z:"), &smode IF_SELINUX(,&scontext));
|
||||
opt = getopt32long(argv, "m:pv" IF_SELINUX("Z:"),
|
||||
"mode\0" Required_argument "m"
|
||||
"parents\0" No_argument "p"
|
||||
# if ENABLE_SELINUX
|
||||
"context\0" Required_argument "Z"
|
||||
# endif
|
||||
# if ENABLE_FEATURE_VERBOSE
|
||||
"verbose\0" No_argument "v"
|
||||
# endif
|
||||
, &smode IF_SELINUX(,&scontext)
|
||||
);
|
||||
if (opt & 1) {
|
||||
mode_t mmode = bb_parse_mode(smode, 0777);
|
||||
if (mmode == (mode_t)-1) {
|
||||
|
@ -16,11 +16,6 @@
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: mv is used to move or rename files or directories.
|
||||
//config:
|
||||
//config:config FEATURE_MV_LONG_OPTIONS
|
||||
//config: bool "Enable long options"
|
||||
//config: default y
|
||||
//config: depends on MV && LONG_OPTS
|
||||
|
||||
//applet:IF_MV(APPLET(mv, BB_DIR_BIN, BB_SUID_DROP))
|
||||
|
||||
@ -41,23 +36,6 @@
|
||||
#include "libbb.h"
|
||||
#include "libcoreutils/coreutils.h"
|
||||
|
||||
#if ENABLE_FEATURE_MV_LONG_OPTIONS
|
||||
static const char mv_longopts[] ALIGN1 =
|
||||
"interactive\0" No_argument "i"
|
||||
"force\0" No_argument "f"
|
||||
"no-clobber\0" No_argument "n"
|
||||
IF_FEATURE_VERBOSE(
|
||||
"verbose\0" No_argument "v"
|
||||
)
|
||||
;
|
||||
#endif
|
||||
|
||||
#define OPT_FORCE (1 << 0)
|
||||
#define OPT_INTERACTIVE (1 << 1)
|
||||
#define OPT_NOCLOBBER (1 << 2)
|
||||
#define OPT_VERBOSE ((1 << 3) * ENABLE_FEATURE_VERBOSE)
|
||||
|
||||
|
||||
int mv_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int mv_main(int argc, char **argv)
|
||||
{
|
||||
@ -69,15 +47,23 @@ int mv_main(int argc, char **argv)
|
||||
int status = 0;
|
||||
int copy_flag = 0;
|
||||
|
||||
#if ENABLE_FEATURE_MV_LONG_OPTIONS
|
||||
applet_long_options = mv_longopts;
|
||||
#endif
|
||||
#define OPT_FORCE (1 << 0)
|
||||
#define OPT_INTERACTIVE (1 << 1)
|
||||
#define OPT_NOCLOBBER (1 << 2)
|
||||
#define OPT_VERBOSE ((1 << 3) * ENABLE_FEATURE_VERBOSE)
|
||||
/* Need at least two arguments.
|
||||
* If more than one of -f, -i, -n is specified , only the final one
|
||||
* takes effect (it unsets previous options).
|
||||
*/
|
||||
opt_complementary = "-2:f-in:i-fn:n-fi";
|
||||
flags = getopt32(argv, "finv");
|
||||
flags = getopt32long(argv, "finv",
|
||||
"interactive\0" No_argument "i"
|
||||
"force\0" No_argument "f"
|
||||
"no-clobber\0" No_argument "n"
|
||||
IF_FEATURE_VERBOSE(
|
||||
"verbose\0" No_argument "v"
|
||||
)
|
||||
);
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
last = argv[argc - 1];
|
||||
|
@ -57,14 +57,13 @@ int nl_main(int argc UNUSED_PARAM, char **argv)
|
||||
"starting-line-number\0"Required_argument "v"
|
||||
"number-width\0" Required_argument "w"
|
||||
;
|
||||
|
||||
applet_long_options = nl_longopts;
|
||||
#endif
|
||||
ns.width = 6;
|
||||
ns.start = 1;
|
||||
ns.inc = 1;
|
||||
ns.sep = "\t";
|
||||
getopt32(argv, "pw:+s:v:+i:+b:", &ns.width, &ns.sep, &ns.start, &ns.inc, &opt_b);
|
||||
getopt32long(argv, "pw:+s:v:+i:+b:", nl_longopts,
|
||||
&ns.width, &ns.sep, &ns.start, &ns.inc, &opt_b);
|
||||
ns.all = (opt_b[0] == 'a');
|
||||
ns.nonempty = (opt_b[0] == 't');
|
||||
ns.empty_str = xasprintf("%*s\n", ns.width + (int)strlen(ns.sep), "");
|
||||
|
@ -28,7 +28,6 @@ int nproc_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
|
||||
unsigned long mask[1024];
|
||||
unsigned i, count = 0;
|
||||
|
||||
//applet_long_options = ...;
|
||||
//getopt32(argv, "");
|
||||
|
||||
//if --all, count /sys/devices/system/cpu/cpuN dirs, else:
|
||||
|
@ -61,8 +61,8 @@ enum {
|
||||
OPT_traditional = (1 << 18) * ENABLE_LONG_OPTS,
|
||||
};
|
||||
|
||||
#define OD_GETOPT32() getopt32(argv, \
|
||||
"A:N:abcdfhij:lot:*vxsS:w:+:", \
|
||||
#define OD_GETOPT32() getopt32long(argv, \
|
||||
"A:N:abcdfhij:lot:*vxsS:w:+:", od_longopts, \
|
||||
/* -w with optional param */ \
|
||||
/* -S was -s and also had optional parameter */ \
|
||||
/* but in coreutils 6.3 it was renamed and now has */ \
|
||||
@ -1213,9 +1213,6 @@ int od_main(int argc UNUSED_PARAM, char **argv)
|
||||
address_pad_len_char = '7';
|
||||
|
||||
/* Parse command line */
|
||||
#if ENABLE_LONG_OPTS
|
||||
applet_long_options = od_longopts;
|
||||
#endif
|
||||
opt = OD_GETOPT32();
|
||||
argv += optind;
|
||||
if (opt & OPT_A) {
|
||||
|
@ -11,14 +11,6 @@
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: rmdir is used to remove empty directories.
|
||||
//config:
|
||||
//config:config FEATURE_RMDIR_LONG_OPTIONS
|
||||
//config: bool "Enable long options"
|
||||
//config: default y
|
||||
//config: depends on RMDIR && LONG_OPTS
|
||||
//config: help
|
||||
//config: Support long options for the rmdir applet, including
|
||||
//config: --ignore-fail-on-non-empty for compatibility with GNU rmdir.
|
||||
|
||||
//applet:IF_RMDIR(APPLET_NOFORK(rmdir, rmdir, BB_DIR_BIN, BB_SUID_DROP, rmdir))
|
||||
|
||||
@ -31,12 +23,9 @@
|
||||
//usage: "[OPTIONS] DIRECTORY..."
|
||||
//usage:#define rmdir_full_usage "\n\n"
|
||||
//usage: "Remove DIRECTORY if it is empty\n"
|
||||
//usage: IF_FEATURE_RMDIR_LONG_OPTIONS(
|
||||
//usage: "\n -p|--parents Include parents"
|
||||
//usage: "\n --ignore-fail-on-non-empty"
|
||||
//usage: )
|
||||
//usage: IF_NOT_FEATURE_RMDIR_LONG_OPTIONS(
|
||||
//usage: "\n -p Include parents"
|
||||
//usage: IF_LONG_OPTS(
|
||||
//usage: "\n --ignore-fail-on-non-empty"
|
||||
//usage: )
|
||||
//usage:
|
||||
//usage:#define rmdir_example_usage
|
||||
@ -49,7 +38,7 @@
|
||||
|
||||
#define PARENTS (1 << 0)
|
||||
#define VERBOSE ((1 << 1) * ENABLE_FEATURE_VERBOSE)
|
||||
#define IGNORE_NON_EMPTY (1 << 2)
|
||||
#define IGNORE_NON_EMPTY ((1 << 2) * ENABLE_LONG_OPTS)
|
||||
|
||||
int rmdir_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int rmdir_main(int argc UNUSED_PARAM, char **argv)
|
||||
@ -58,8 +47,7 @@ int rmdir_main(int argc UNUSED_PARAM, char **argv)
|
||||
int flags;
|
||||
char *path;
|
||||
|
||||
#if ENABLE_FEATURE_RMDIR_LONG_OPTIONS
|
||||
static const char rmdir_longopts[] ALIGN1 =
|
||||
flags = getopt32long(argv, "pv",
|
||||
"parents\0" No_argument "p"
|
||||
/* Debian etch: many packages fail to be purged or installed
|
||||
* because they desperately want this option: */
|
||||
@ -67,10 +55,7 @@ int rmdir_main(int argc UNUSED_PARAM, char **argv)
|
||||
IF_FEATURE_VERBOSE(
|
||||
"verbose\0" No_argument "v"
|
||||
)
|
||||
;
|
||||
applet_long_options = rmdir_longopts;
|
||||
#endif
|
||||
flags = getopt32(argv, "pv");
|
||||
);
|
||||
argv += optind;
|
||||
|
||||
if (!*argv) {
|
||||
@ -86,7 +71,7 @@ int rmdir_main(int argc UNUSED_PARAM, char **argv)
|
||||
}
|
||||
|
||||
if (rmdir(path) < 0) {
|
||||
#if ENABLE_FEATURE_RMDIR_LONG_OPTIONS
|
||||
#if ENABLE_LONG_OPTS
|
||||
if ((flags & IGNORE_NON_EMPTY) && errno == ENOTEMPTY)
|
||||
break;
|
||||
#endif
|
||||
|
@ -103,6 +103,11 @@ int touch_main(int argc UNUSED_PARAM, char **argv)
|
||||
"date\0" Required_argument "d"
|
||||
IF_FEATURE_TOUCH_NODEREF("no-dereference\0" No_argument "h")
|
||||
;
|
||||
# define GETOPT32 getopt32long
|
||||
# define LONGOPTS ,touch_longopts
|
||||
# else
|
||||
# define GETOPT32 getopt32
|
||||
# define LONGOPTS
|
||||
# endif
|
||||
char *reference_file = NULL;
|
||||
char *date_str = NULL;
|
||||
@ -112,17 +117,17 @@ int touch_main(int argc UNUSED_PARAM, char **argv)
|
||||
# define reference_file NULL
|
||||
# define date_str NULL
|
||||
# define timebuf ((struct timeval*)NULL)
|
||||
# define GETOPT32 getopt32
|
||||
# define LONGOPTS
|
||||
#endif
|
||||
|
||||
#if ENABLE_FEATURE_TOUCH_SUSV3 && ENABLE_LONG_OPTS
|
||||
applet_long_options = touch_longopts;
|
||||
#endif
|
||||
/* -d and -t both set time. In coreutils,
|
||||
* accepted data format differs a bit between -d and -t.
|
||||
* We accept the same formats for both */
|
||||
opts = getopt32(argv, "c" IF_FEATURE_TOUCH_SUSV3("r:d:t:")
|
||||
opts = GETOPT32(argv, "c" IF_FEATURE_TOUCH_SUSV3("r:d:t:")
|
||||
IF_FEATURE_TOUCH_NODEREF("h")
|
||||
/*ignored:*/ "fma"
|
||||
LONGOPTS
|
||||
IF_FEATURE_TOUCH_SUSV3(, &reference_file)
|
||||
IF_FEATURE_TOUCH_SUSV3(, &date_str)
|
||||
IF_FEATURE_TOUCH_SUSV3(, &date_str)
|
||||
|
@ -147,8 +147,7 @@ int uname_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
|
||||
"operating-system\0" No_argument "o"
|
||||
;
|
||||
# endif
|
||||
IF_LONG_OPTS(applet_long_options = uname_longopts);
|
||||
toprint = getopt32(argv, options);
|
||||
toprint = getopt32long(argv, options, uname_longopts);
|
||||
if (argv[optind]) { /* coreutils-6.9 compat */
|
||||
bb_show_usage();
|
||||
}
|
||||
|
@ -159,10 +159,15 @@ static const char runparts_longopts[] ALIGN1 =
|
||||
"reverse\0" No_argument "\xf0"
|
||||
"test\0" No_argument "\xf1"
|
||||
"exit-on-error\0" No_argument "\xf2"
|
||||
#if ENABLE_FEATURE_RUN_PARTS_FANCY
|
||||
# if ENABLE_FEATURE_RUN_PARTS_FANCY
|
||||
"list\0" No_argument "\xf3"
|
||||
#endif
|
||||
# endif
|
||||
;
|
||||
# define GETOPT32 getopt32long
|
||||
# define LONGOPTS ,runparts_longopts
|
||||
#else
|
||||
# define GETOPT32 getopt32
|
||||
# define LONGOPTS
|
||||
#endif
|
||||
|
||||
int run_parts_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
@ -175,12 +180,9 @@ int run_parts_main(int argc UNUSED_PARAM, char **argv)
|
||||
|
||||
INIT_G();
|
||||
|
||||
#if ENABLE_FEATURE_RUN_PARTS_LONG_OPTIONS
|
||||
applet_long_options = runparts_longopts;
|
||||
#endif
|
||||
/* We require exactly one argument: the directory name */
|
||||
opt_complementary = "=1";
|
||||
getopt32(argv, "a:*u:", &arg_list, &umask_p);
|
||||
GETOPT32(argv, "a:*u:" LONGOPTS, &arg_list, &umask_p);
|
||||
|
||||
umask(xstrtou_range(umask_p, 8, 0, 07777));
|
||||
|
||||
|
@ -426,6 +426,11 @@ static const char start_stop_daemon_longopts[] ALIGN1 =
|
||||
"retry\0" Required_argument "R"
|
||||
# endif
|
||||
;
|
||||
# define GETOPT32 getopt32long
|
||||
# define LONGOPTS start_stop_daemon_longopts,
|
||||
#else
|
||||
# define GETOPT32 getopt32
|
||||
# define LONGOPTS
|
||||
#endif
|
||||
|
||||
int start_stop_daemon_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
@ -446,10 +451,6 @@ int start_stop_daemon_main(int argc UNUSED_PARAM, char **argv)
|
||||
|
||||
INIT_G();
|
||||
|
||||
#if ENABLE_FEATURE_START_STOP_DAEMON_LONG_OPTIONS
|
||||
applet_long_options = start_stop_daemon_longopts;
|
||||
#endif
|
||||
|
||||
/* -K or -S is required; they are mutually exclusive */
|
||||
/* -p is required if -m is given */
|
||||
/* -xpun (at least one) is required if -K is given */
|
||||
@ -457,8 +458,9 @@ int start_stop_daemon_main(int argc UNUSED_PARAM, char **argv)
|
||||
/* -q turns off -v */
|
||||
opt_complementary = "K:S:K--S:S--K:m?p:K?xpun:S?xa"
|
||||
IF_FEATURE_START_STOP_DAEMON_FANCY("q-v");
|
||||
opt = getopt32(argv, "KSbqtma:n:s:u:c:x:p:"
|
||||
opt = GETOPT32(argv, "KSbqtma:n:s:u:c:x:p:"
|
||||
IF_FEATURE_START_STOP_DAEMON_FANCY("ovN:R:"),
|
||||
LONGOPTS
|
||||
&startas, &cmdname, &signame, &userspec, &chuid, &execname, &pidfile
|
||||
IF_FEATURE_START_STOP_DAEMON_FANCY(,&opt_N)
|
||||
/* We accept and ignore -R <param> / --retry <param> */
|
||||
|
@ -967,6 +967,11 @@ static const char diff_longopts[] ALIGN1 =
|
||||
"starting-file\0" Required_argument "S"
|
||||
"minimal\0" No_argument "d"
|
||||
;
|
||||
# define GETOPT32 getopt32long
|
||||
# define LONGOPTS ,diff_longopts
|
||||
#else
|
||||
# define GETOPT32 getopt32
|
||||
# define LONGOPTS
|
||||
#endif
|
||||
|
||||
int diff_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
@ -980,10 +985,7 @@ int diff_main(int argc UNUSED_PARAM, char **argv)
|
||||
|
||||
/* exactly 2 params; collect multiple -L <label>; -U N */
|
||||
opt_complementary = "=2";
|
||||
#if ENABLE_FEATURE_DIFF_LONG_OPTIONS
|
||||
applet_long_options = diff_longopts;
|
||||
#endif
|
||||
getopt32(argv, "abdiL:*NqrsS:tTU:+wupBE",
|
||||
GETOPT32(argv, "abdiL:*NqrsS:tTU:+wupBE" LONGOPTS,
|
||||
&L_arg, &s_start, &opt_U_context);
|
||||
argv += optind;
|
||||
while (L_arg)
|
||||
|
@ -111,10 +111,9 @@ int patch_main(int argc UNUSED_PARAM, char **argv)
|
||||
"no-backup-if-mismatch\0" No_argument "\xff" /*ignored*/
|
||||
# endif
|
||||
;
|
||||
applet_long_options = patch_longopts;
|
||||
#endif
|
||||
/* -f,-E,-g are ignored */
|
||||
opt = getopt32(argv, "p:i:RN""fEg:", &p, &i, NULL);
|
||||
opt = getopt32long(argv, "p:i:RN""fEg:", patch_longopts, &p, &i, NULL);
|
||||
if (opt & OPT_R)
|
||||
plus = '-';
|
||||
patch_level = xatoi(p); /* can be negative! */
|
||||
|
@ -1508,16 +1508,14 @@ int sed_main(int argc UNUSED_PARAM, char **argv)
|
||||
opt_e = opt_f = NULL;
|
||||
opt_i = NULL;
|
||||
opt_complementary = "nn"; /* count -n */
|
||||
|
||||
IF_LONG_OPTS(applet_long_options = sed_longopts);
|
||||
|
||||
/* -i must be first, to match OPT_in_place definition */
|
||||
/* -E is a synonym of -r:
|
||||
* GNU sed 4.2.1 mentions it in neither --help
|
||||
* nor manpage, but does recognize it.
|
||||
*/
|
||||
opt = getopt32(argv, "i::rEne:*f:*", &opt_i, &opt_e, &opt_f,
|
||||
&G.be_quiet); /* counter for -n */
|
||||
opt = getopt32long(argv, "i::rEne:*f:*", sed_longopts,
|
||||
&opt_i, &opt_e, &opt_f,
|
||||
&G.be_quiet); /* counter for -n */
|
||||
//argc -= optind;
|
||||
argv += optind;
|
||||
if (opt & OPT_in_place) { // -i
|
||||
|
@ -495,13 +495,8 @@ int xargs_main(int argc, char **argv)
|
||||
|
||||
INIT_G();
|
||||
|
||||
#if ENABLE_DESKTOP && ENABLE_LONG_OPTS
|
||||
/* For example, Fedora's build system uses --no-run-if-empty */
|
||||
applet_long_options =
|
||||
"no-run-if-empty\0" No_argument "r"
|
||||
;
|
||||
#endif
|
||||
opt = getopt32(argv, OPTION_STR,
|
||||
opt = getopt32long(argv, OPTION_STR,
|
||||
"no-run-if-empty\0" No_argument "r",
|
||||
&max_args, &max_chars, &G.eof_str, &G.eof_str
|
||||
IF_FEATURE_XARGS_SUPPORT_REPL_STR(, &G.repl_str, &G.repl_str)
|
||||
);
|
||||
|
@ -1180,19 +1180,24 @@ void bb_sanitize_stdio(void) FAST_FUNC;
|
||||
int sanitize_env_if_suid(void) FAST_FUNC;
|
||||
|
||||
|
||||
char* single_argv(char **argv) FAST_FUNC;
|
||||
extern const char *const bb_argv_dash[]; /* "-", NULL */
|
||||
extern const char *opt_complementary;
|
||||
#if ENABLE_LONG_OPTS || ENABLE_FEATURE_GETOPT_LONG
|
||||
#define No_argument "\0"
|
||||
#define Required_argument "\001"
|
||||
#define Optional_argument "\002"
|
||||
extern const char *applet_long_options;
|
||||
#endif
|
||||
extern uint32_t option_mask32;
|
||||
uint32_t getopt32(char **argv, const char *applet_opts, ...) FAST_FUNC;
|
||||
/* For top, ps. Some argv[i] are replaced by malloced "-opt" strings */
|
||||
void make_all_argv_opts(char **argv) FAST_FUNC;
|
||||
char* single_argv(char **argv) FAST_FUNC;
|
||||
extern const char *const bb_argv_dash[]; /* { "-", NULL } */
|
||||
extern uint32_t option_mask32;
|
||||
//TODO: get rid of this global variable. How about a trick where optstring can be
|
||||
// "^optchars""\0""complementary" (the leading "^" is an indicator)?
|
||||
extern const char *opt_complementary;
|
||||
uint32_t getopt32(char **argv, const char *applet_opts, ...) FAST_FUNC;
|
||||
# define No_argument "\0"
|
||||
# define Required_argument "\001"
|
||||
# define Optional_argument "\002"
|
||||
#if ENABLE_LONG_OPTS
|
||||
uint32_t getopt32long(char **argv, const char *optstring, const char *longopts, ...) FAST_FUNC;
|
||||
#else
|
||||
#define getopt32long(argv,optstring,longopts,...) \
|
||||
getopt32(argv,optstring,##__VA_ARGS__)
|
||||
#endif
|
||||
/* BSD-derived getopt() functions require that optind be set to 1 in
|
||||
* order to reset getopt() state. This used to be generally accepted
|
||||
* way of resetting getopt(). However, glibc's getopt()
|
||||
|
@ -6,7 +6,7 @@
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
#if ENABLE_LONG_OPTS || ENABLE_FEATURE_GETOPT_LONG
|
||||
#if ENABLE_LONG_OPTS
|
||||
# include <getopt.h>
|
||||
#endif
|
||||
#include "libbb.h"
|
||||
@ -99,17 +99,18 @@ getopt32(char **argv, const char *applet_opts, ...)
|
||||
"!" Report bad option, missing required options,
|
||||
inconsistent options with all-ones return value (instead of abort).
|
||||
|
||||
const char *applet_long_options
|
||||
uint32_t
|
||||
getopt32long(char **argv, const char *applet_opts, const char *logopts...)
|
||||
|
||||
This struct allows you to define long options:
|
||||
This allows you to define long options:
|
||||
|
||||
static const char applet_longopts[] ALIGN1 =
|
||||
//"name\0" has_arg val
|
||||
"verbose\0" No_argument "v"
|
||||
;
|
||||
applet_long_options = applet_longopts;
|
||||
opt = getopt32long(argv, applet_opts, applet_longopts, ...);
|
||||
|
||||
The last member of struct option (val) typically is set to
|
||||
The last element (val) typically is set to
|
||||
matching short option from applet_opts. If there is no matching
|
||||
char in applet_opts, then:
|
||||
- return bit has next position after short options
|
||||
@ -317,20 +318,21 @@ typedef struct {
|
||||
int *counter;
|
||||
} t_complementary;
|
||||
|
||||
/* You can set applet_long_options for parse called long options */
|
||||
#if ENABLE_LONG_OPTS || ENABLE_FEATURE_GETOPT_LONG
|
||||
uint32_t option_mask32;
|
||||
|
||||
#if ENABLE_LONG_OPTS
|
||||
static const struct option bb_null_long_options[1] = {
|
||||
{ 0, 0, 0, 0 }
|
||||
};
|
||||
const char *applet_long_options;
|
||||
#else
|
||||
#define vgetopt32(argv,applet_opts,applet_long_options,p) \
|
||||
vgetopt32(argv,applet_opts,p)
|
||||
#endif
|
||||
|
||||
uint32_t option_mask32;
|
||||
|
||||
/* Please keep getopt32 free from xmalloc */
|
||||
|
||||
uint32_t FAST_FUNC
|
||||
getopt32(char **argv, const char *applet_opts, ...)
|
||||
static uint32_t
|
||||
vgetopt32(char **argv, const char *applet_opts, const char *applet_long_options, va_list p)
|
||||
{
|
||||
int argc;
|
||||
unsigned flags = 0;
|
||||
@ -340,8 +342,7 @@ getopt32(char **argv, const char *applet_opts, ...)
|
||||
int c;
|
||||
const unsigned char *s;
|
||||
t_complementary *on_off;
|
||||
va_list p;
|
||||
#if ENABLE_LONG_OPTS || ENABLE_FEATURE_GETOPT_LONG
|
||||
#if ENABLE_LONG_OPTS
|
||||
const struct option *l_o;
|
||||
struct option *long_options = (struct option *) &bb_null_long_options;
|
||||
#endif
|
||||
@ -356,8 +357,6 @@ getopt32(char **argv, const char *applet_opts, ...)
|
||||
/* skip 0: some applets cheat: they do not actually HAVE argv[0] */
|
||||
argc = 1 + string_array_len(argv + 1);
|
||||
|
||||
va_start(p, applet_opts);
|
||||
|
||||
on_off = complementary;
|
||||
memset(on_off, 0, sizeof(complementary));
|
||||
|
||||
@ -394,7 +393,7 @@ getopt32(char **argv, const char *applet_opts, ...)
|
||||
c++;
|
||||
}
|
||||
|
||||
#if ENABLE_LONG_OPTS || ENABLE_FEATURE_GETOPT_LONG
|
||||
#if ENABLE_LONG_OPTS
|
||||
if (applet_long_options) {
|
||||
const char *optstr;
|
||||
unsigned i, count;
|
||||
@ -433,12 +432,8 @@ getopt32(char **argv, const char *applet_opts, ...)
|
||||
c++;
|
||||
next_long: ;
|
||||
}
|
||||
/* Make it unnecessary to clear applet_long_options
|
||||
* by hand after each call to getopt32
|
||||
*/
|
||||
applet_long_options = NULL;
|
||||
}
|
||||
#endif /* ENABLE_LONG_OPTS || ENABLE_FEATURE_GETOPT_LONG */
|
||||
#endif /* ENABLE_LONG_OPTS */
|
||||
|
||||
for (s = (const unsigned char *)opt_complementary; s && *s; s++) {
|
||||
t_complementary *pair;
|
||||
@ -517,9 +512,9 @@ getopt32(char **argv, const char *applet_opts, ...)
|
||||
}
|
||||
s--;
|
||||
}
|
||||
opt_complementary = NULL;
|
||||
va_end(p);
|
||||
|
||||
/* Make it unnecessary to clear it by hand after each getopt32 call */
|
||||
opt_complementary = NULL;
|
||||
/* In case getopt32 was already called:
|
||||
* reset the libc getopt() function, which keeps internal state.
|
||||
* run_nofork_applet() does this, but we might end up here
|
||||
@ -531,7 +526,7 @@ getopt32(char **argv, const char *applet_opts, ...)
|
||||
* "fake" short options, like this one:
|
||||
* wget $'-\203' "Test: test" http://kernel.org/
|
||||
* (supposed to act as --header, but doesn't) */
|
||||
#if ENABLE_LONG_OPTS || ENABLE_FEATURE_GETOPT_LONG
|
||||
#if ENABLE_LONG_OPTS
|
||||
while ((c = getopt_long(argc, argv, applet_opts,
|
||||
long_options, NULL)) != -1) {
|
||||
#else
|
||||
@ -592,3 +587,29 @@ getopt32(char **argv, const char *applet_opts, ...)
|
||||
bb_show_usage();
|
||||
return (int32_t)-1;
|
||||
}
|
||||
|
||||
uint32_t FAST_FUNC
|
||||
getopt32(char **argv, const char *applet_opts, ...)
|
||||
{
|
||||
uint32_t opt;
|
||||
va_list p;
|
||||
|
||||
va_start(p, applet_opts);
|
||||
opt = vgetopt32(argv, applet_opts, NULL, p);
|
||||
va_end(p);
|
||||
return opt;
|
||||
}
|
||||
|
||||
#if ENABLE_LONG_OPTS
|
||||
uint32_t FAST_FUNC
|
||||
getopt32long(char **argv, const char *applet_opts, const char *longopts, ...)
|
||||
{
|
||||
uint32_t opt;
|
||||
va_list p;
|
||||
|
||||
va_start(p, longopts);
|
||||
opt = vgetopt32(argv, applet_opts, longopts, p);
|
||||
va_end(p);
|
||||
return opt;
|
||||
}
|
||||
#endif
|
||||
|
@ -45,14 +45,15 @@ static void jump(void)
|
||||
{
|
||||
/* Special case. We arrive here if NOFORK applet
|
||||
* calls xfunc, which then decides to die.
|
||||
* We don't die, but jump instead back to caller.
|
||||
* We don't die, but instead jump back to caller.
|
||||
* NOFORK applets still cannot carelessly call xfuncs:
|
||||
* p = xmalloc(10);
|
||||
* q = xmalloc(10); // BUG! if this dies, we leak p!
|
||||
*/
|
||||
/* | 0x100 allows to pass zero exitcode (longjmp can't pass 0).
|
||||
* This works because exitcodes are bytes,
|
||||
* run_nofork_applet() ensures that by "& 0xff" */
|
||||
* run_nofork_applet() ensures that by "& 0xff"
|
||||
*/
|
||||
longjmp(die_jmp, xfunc_error_retval | 0x100);
|
||||
}
|
||||
|
||||
@ -92,12 +93,12 @@ int FAST_FUNC run_nofork_applet(int applet_no, char **argv)
|
||||
|
||||
logmode = LOGMODE_STDIO;
|
||||
xfunc_error_retval = EXIT_FAILURE;
|
||||
/* In case getopt() or getopt32() was already called:
|
||||
/* In case getopt() was already called:
|
||||
* reset the libc getopt() function, which keeps internal state.
|
||||
* (getopt32() does it itself, but getopt() doesn't (and can't))
|
||||
*/
|
||||
GETOPT_RESET();
|
||||
//? applet_long_options = NULL;
|
||||
//? opt_complementary = NULL;
|
||||
/* opt_complementary = NULL; - cleared by each getopt32() call anyway */
|
||||
|
||||
argc = string_array_len(argv);
|
||||
|
||||
@ -122,8 +123,7 @@ int FAST_FUNC run_nofork_applet(int applet_no, char **argv)
|
||||
restore_nofork_data(&old);
|
||||
/* Other globals can be simply reset to defaults */
|
||||
GETOPT_RESET();
|
||||
//? applet_long_options = NULL;
|
||||
//? opt_complementary = NULL;
|
||||
/* opt_complementary = NULL; - cleared by each getopt32() call anyway */
|
||||
|
||||
return rc & 0xff; /* don't confuse people with "exitcodes" >255 */
|
||||
}
|
||||
@ -138,8 +138,7 @@ void FAST_FUNC run_noexec_applet_and_exit(int a, const char *name, char **argv)
|
||||
xfunc_error_retval = EXIT_FAILURE;
|
||||
die_func = NULL;
|
||||
GETOPT_RESET();
|
||||
//? applet_long_options = NULL;
|
||||
//? opt_complementary = NULL;
|
||||
/* opt_complementary = NULL; - cleared by each getopt32() call anyway */
|
||||
|
||||
//TODO: think pidof, pgrep, pkill!
|
||||
//set_task_comm() makes our pidof find NOEXECs (e.g. "yes >/dev/null"),
|
||||
|
@ -12,14 +12,10 @@
|
||||
//config:config ADDGROUP
|
||||
//config: bool "addgroup (8.2 kb)"
|
||||
//config: default y
|
||||
//config: select LONG_OPTS
|
||||
//config: help
|
||||
//config: Utility for creating a new group account.
|
||||
//config:
|
||||
//config:config FEATURE_ADDGROUP_LONG_OPTIONS
|
||||
//config: bool "Enable long options"
|
||||
//config: default y
|
||||
//config: depends on ADDGROUP && LONG_OPTS
|
||||
//config:
|
||||
//config:config FEATURE_ADDUSER_TO_GROUP
|
||||
//config: bool "Support adding users to groups"
|
||||
//config: default y
|
||||
@ -131,12 +127,11 @@ static void new_group(char *group, gid_t gid)
|
||||
#endif
|
||||
}
|
||||
|
||||
#if ENABLE_FEATURE_ADDGROUP_LONG_OPTIONS
|
||||
//FIXME: upstream addgroup has no short options! NOT COMPATIBLE!
|
||||
static const char addgroup_longopts[] ALIGN1 =
|
||||
"gid\0" Required_argument "g"
|
||||
"system\0" No_argument "S"
|
||||
;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* addgroup will take a login_name as its first parameter.
|
||||
@ -155,16 +150,13 @@ int addgroup_main(int argc UNUSED_PARAM, char **argv)
|
||||
if (geteuid()) {
|
||||
bb_error_msg_and_die(bb_msg_perm_denied_are_you_root);
|
||||
}
|
||||
#if ENABLE_FEATURE_ADDGROUP_LONG_OPTIONS
|
||||
applet_long_options = addgroup_longopts;
|
||||
#endif
|
||||
/* Syntax:
|
||||
* addgroup group
|
||||
* addgroup -g num group
|
||||
* addgroup user group
|
||||
* Check for min, max and missing args */
|
||||
opt_complementary = "-1:?2";
|
||||
opts = getopt32(argv, "g:S", &gid);
|
||||
opts = getopt32long(argv, "g:S", addgroup_longopts, &gid);
|
||||
/* move past the commandline options */
|
||||
argv += optind;
|
||||
//argc -= optind;
|
||||
|
@ -10,14 +10,10 @@
|
||||
//config:config ADDUSER
|
||||
//config: bool "adduser (15 kb)"
|
||||
//config: default y
|
||||
//config: select LONG_OPTS
|
||||
//config: help
|
||||
//config: Utility for creating a new user account.
|
||||
//config:
|
||||
//config:config FEATURE_ADDUSER_LONG_OPTIONS
|
||||
//config: bool "Enable long options"
|
||||
//config: default y
|
||||
//config: depends on ADDUSER && LONG_OPTS
|
||||
//config:
|
||||
//config:config FEATURE_CHECK_NAMES
|
||||
//config: bool "Enable sanity check on user/group names in adduser and addgroup"
|
||||
//config: default n
|
||||
@ -148,15 +144,7 @@ static int addgroup_wrapper(struct passwd *p, const char *group_name)
|
||||
/* Add user to his own group with the first free gid
|
||||
* found in passwd_study.
|
||||
*/
|
||||
#if ENABLE_FEATURE_ADDGROUP_LONG_OPTIONS || !ENABLE_ADDGROUP
|
||||
/* We try to use --gid, not -g, because "standard" addgroup
|
||||
* has no short option -g, it has only long --gid.
|
||||
*/
|
||||
argv[1] = (char*)"--gid";
|
||||
#else
|
||||
/* Breaks if system in fact does NOT use busybox addgroup */
|
||||
argv[1] = (char*)"-g";
|
||||
#endif
|
||||
argv[2] = utoa(p->pw_gid);
|
||||
argv[3] = (char*)"--";
|
||||
argv[4] = p->pw_name;
|
||||
@ -174,7 +162,7 @@ static void passwd_wrapper(const char *login_name)
|
||||
bb_error_msg_and_die("can't execute passwd, you must set password manually");
|
||||
}
|
||||
|
||||
#if ENABLE_FEATURE_ADDUSER_LONG_OPTIONS
|
||||
//FIXME: upstream adduser has no short options! NOT COMPATIBLE!
|
||||
static const char adduser_longopts[] ALIGN1 =
|
||||
"home\0" Required_argument "h"
|
||||
"gecos\0" Required_argument "g"
|
||||
@ -187,7 +175,6 @@ static const char adduser_longopts[] ALIGN1 =
|
||||
"uid\0" Required_argument "u"
|
||||
"skel\0" Required_argument "k"
|
||||
;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* adduser will take a login_name as its first parameter.
|
||||
@ -204,10 +191,6 @@ int adduser_main(int argc UNUSED_PARAM, char **argv)
|
||||
char *uid;
|
||||
const char *skel = "/etc/skel";
|
||||
|
||||
#if ENABLE_FEATURE_ADDUSER_LONG_OPTIONS
|
||||
applet_long_options = adduser_longopts;
|
||||
#endif
|
||||
|
||||
/* got root? */
|
||||
if (geteuid()) {
|
||||
bb_error_msg_and_die(bb_msg_perm_denied_are_you_root);
|
||||
@ -221,7 +204,9 @@ int adduser_main(int argc UNUSED_PARAM, char **argv)
|
||||
/* at least one and at most two non-option args */
|
||||
/* disable interactive passwd for system accounts */
|
||||
opt_complementary = "-1:?2:SD";
|
||||
opts = getopt32(argv, "h:g:s:G:DSHu:k:", &pw.pw_dir, &pw.pw_gecos, &pw.pw_shell, &usegroup, &uid, &skel);
|
||||
opts = getopt32long(argv, "h:g:s:G:DSHu:k:", adduser_longopts,
|
||||
&pw.pw_dir, &pw.pw_gecos, &pw.pw_shell,
|
||||
&usegroup, &uid, &skel);
|
||||
if (opts & OPT_UID)
|
||||
pw.pw_uid = xatou_range(uid, 0, CONFIG_LAST_ID);
|
||||
|
||||
|
@ -62,8 +62,7 @@ int chpasswd_main(int argc UNUSED_PARAM, char **argv)
|
||||
bb_error_msg_and_die(bb_msg_perm_denied_are_you_root);
|
||||
|
||||
opt_complementary = "m--ec:e--mc:c--em";
|
||||
IF_LONG_OPTS(applet_long_options = chpasswd_longopts;)
|
||||
opt = getopt32(argv, "emc:", &algo);
|
||||
opt = getopt32long(argv, "emc:", chpasswd_longopts, &algo);
|
||||
|
||||
while ((name = xmalloc_fgetline(stdin)) != NULL) {
|
||||
char *free_me;
|
||||
|
@ -106,14 +106,14 @@ int cryptpw_main(int argc UNUSED_PARAM, char **argv)
|
||||
"salt\0" Required_argument "S"
|
||||
"method\0" Required_argument "m"
|
||||
;
|
||||
applet_long_options = mkpasswd_longopts;
|
||||
#endif
|
||||
fd = STDIN_FILENO;
|
||||
opt_m = CONFIG_FEATURE_DEFAULT_PASSWD_ALGO;
|
||||
opt_S = NULL;
|
||||
/* at most two non-option arguments; -P NUM */
|
||||
opt_complementary = "?2";
|
||||
getopt32(argv, "sP:+S:m:a:", &fd, &opt_S, &opt_m, &opt_m);
|
||||
getopt32long(argv, "sP:+S:m:a:", mkpasswd_longopts,
|
||||
&fd, &opt_S, &opt_m, &opt_m);
|
||||
argv += optind;
|
||||
|
||||
/* have no idea how to handle -s... */
|
||||
|
@ -68,9 +68,8 @@ int deluser_main(int argc, char **argv)
|
||||
#else
|
||||
int opt_delhome = 0;
|
||||
if (do_deluser) {
|
||||
applet_long_options =
|
||||
"remove-home\0" No_argument "\xff";
|
||||
opt_delhome = getopt32(argv, "");
|
||||
opt_delhome = getopt32long(argv, "",
|
||||
"remove-home\0" No_argument "\xff");
|
||||
argv += opt_delhome;
|
||||
argc -= opt_delhome;
|
||||
}
|
||||
|
@ -377,8 +377,6 @@ int conspy_main(int argc UNUSED_PARAM, char **argv)
|
||||
"follow\0" No_argument "f"
|
||||
"framebuffer\0" No_argument "F"
|
||||
;
|
||||
|
||||
applet_long_options = conspy_longopts;
|
||||
#endif
|
||||
#define keybuf bb_common_bufsiz1
|
||||
setup_common_bufsiz();
|
||||
@ -387,7 +385,7 @@ int conspy_main(int argc UNUSED_PARAM, char **argv)
|
||||
strcpy(G.vcsa_name, DEV_VCSA);
|
||||
|
||||
// numeric params
|
||||
opts = getopt32(argv, "vcQsndfFx:+y:+", &G.x, &G.y);
|
||||
opts = getopt32long(argv, "vcQsndfFx:+y:+", conspy_longopts, &G.x, &G.y);
|
||||
argv += optind;
|
||||
ttynum = 0;
|
||||
if (argv[0]) {
|
||||
|
@ -124,11 +124,9 @@ int nandwrite_main(int argc UNUSED_PARAM, char **argv)
|
||||
|
||||
if (IS_NANDDUMP) {
|
||||
opt_complementary = "=1";
|
||||
#if ENABLE_LONG_OPTS
|
||||
applet_long_options =
|
||||
"bb\0" Required_argument "\xff"; /* no short equivalent */
|
||||
#endif
|
||||
opts = getopt32(argv, "ons:f:l:", &opt_s, &opt_f, &opt_l, &opt_bb);
|
||||
opts = getopt32long(argv, "ons:f:l:",
|
||||
"bb\0" Required_argument "\xff", /* no short equivalent */
|
||||
&opt_s, &opt_f, &opt_l, &opt_bb);
|
||||
} else { /* nandwrite */
|
||||
opt_complementary = "-1:?2";
|
||||
opts = getopt32(argv, "pns:", &opt_s);
|
||||
|
@ -566,9 +566,8 @@ int modprobe_main(int argc UNUSED_PARAM, char **argv)
|
||||
|
||||
INIT_G();
|
||||
|
||||
IF_LONG_OPTS(applet_long_options = modprobe_longopts;)
|
||||
opt_complementary = MODPROBE_COMPLEMENTARY;
|
||||
opt = getopt32(argv, INSMOD_OPTS MODPROBE_OPTS INSMOD_ARGS);
|
||||
opt = getopt32long(argv, INSMOD_OPTS MODPROBE_OPTS, modprobe_longopts INSMOD_ARGS);
|
||||
argv += optind;
|
||||
|
||||
/* Goto modules location */
|
||||
|
@ -361,12 +361,14 @@ int ftpgetput_main(int argc UNUSED_PARAM, char **argv)
|
||||
/*
|
||||
* Decipher the command line
|
||||
*/
|
||||
#if ENABLE_FEATURE_FTPGETPUT_LONG_OPTIONS
|
||||
applet_long_options = ftpgetput_longopts;
|
||||
#endif
|
||||
opt_complementary = "-2:vv:cc"; /* must have 2 to 3 params; -v and -c count */
|
||||
getopt32(argv, "cvu:p:P:", &user, &password, &port,
|
||||
&verbose_flag, &do_continue);
|
||||
#if ENABLE_FEATURE_FTPGETPUT_LONG_OPTIONS
|
||||
getopt32long(argv, "cvu:p:P:", ftpgetput_longopts,
|
||||
#else
|
||||
getopt32(argv, "cvu:p:P:",
|
||||
#endif
|
||||
&user, &password, &port, &verbose_flag, &do_continue
|
||||
);
|
||||
argv += optind;
|
||||
|
||||
/* We want to do exactly _one_ DNS lookup, since some
|
||||
|
@ -132,8 +132,9 @@ int hostname_main(int argc UNUSED_PARAM, char **argv)
|
||||
char *buf;
|
||||
char *hostname_str;
|
||||
|
||||
#if ENABLE_LONG_OPTS
|
||||
applet_long_options =
|
||||
/* dnsdomainname from net-tools 1.60, hostname 1.100 (2001-04-14),
|
||||
* supports hostname's options too (not just -v as manpage says) */
|
||||
opts = getopt32(argv, "dfisF:v", &hostname_str,
|
||||
"domain\0" No_argument "d"
|
||||
"fqdn\0" No_argument "f"
|
||||
//Enable if seen in active use in some distro:
|
||||
@ -142,12 +143,7 @@ int hostname_main(int argc UNUSED_PARAM, char **argv)
|
||||
// "short\0" No_argument "s"
|
||||
// "verbose\0" No_argument "v"
|
||||
"file\0" No_argument "F"
|
||||
;
|
||||
|
||||
#endif
|
||||
/* dnsdomainname from net-tools 1.60, hostname 1.100 (2001-04-14),
|
||||
* supports hostname's options too (not just -v as manpage says) */
|
||||
opts = getopt32(argv, "dfisF:v", &hostname_str);
|
||||
);
|
||||
argv += optind;
|
||||
buf = safe_gethostname();
|
||||
if (ENABLE_DNSDOMAINNAME) {
|
||||
|
@ -493,19 +493,15 @@ int ifenslave_main(int argc UNUSED_PARAM, char **argv)
|
||||
OPT_d = (1 << 1),
|
||||
OPT_f = (1 << 2),
|
||||
};
|
||||
#if ENABLE_LONG_OPTS
|
||||
static const char ifenslave_longopts[] ALIGN1 =
|
||||
|
||||
INIT_G();
|
||||
|
||||
opt = getopt32long(argv, "cdfa",
|
||||
"change-active\0" No_argument "c"
|
||||
"detach\0" No_argument "d"
|
||||
"force\0" No_argument "f"
|
||||
/* "all-interfaces\0" No_argument "a" */
|
||||
;
|
||||
|
||||
applet_long_options = ifenslave_longopts;
|
||||
#endif
|
||||
INIT_G();
|
||||
|
||||
opt = getopt32(argv, "cdfa");
|
||||
);
|
||||
argv += optind;
|
||||
if (opt & (opt-1)) /* Only one option can be given */
|
||||
bb_show_usage();
|
||||
|
@ -108,6 +108,11 @@ int get_prefix(unsigned long netmask);
|
||||
"silent\0" No_argument "s" // don’t ever display error messages
|
||||
# endif
|
||||
;
|
||||
# define GETOPT32 getopt32long
|
||||
# define LONGOPTS ,ipcalc_longopts
|
||||
#else
|
||||
# define GETOPT32 getopt32
|
||||
# define LONGOPTS
|
||||
#endif
|
||||
|
||||
int ipcalc_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
@ -125,11 +130,8 @@ int ipcalc_main(int argc UNUSED_PARAM, char **argv)
|
||||
#define ipaddr (s_ipaddr.s_addr)
|
||||
char *ipstr;
|
||||
|
||||
#if ENABLE_FEATURE_IPCALC_LONG_OPTIONS
|
||||
applet_long_options = ipcalc_longopts;
|
||||
#endif
|
||||
opt_complementary = "-1:?2"; /* minimum 1 arg, maximum 2 args */
|
||||
opt = getopt32(argv, "mbn" IF_FEATURE_IPCALC_FANCY("phs"));
|
||||
opt = GETOPT32(argv, "mbn" IF_FEATURE_IPCALC_FANCY("phs") LONGOPTS);
|
||||
argv += optind;
|
||||
if (opt & SILENT)
|
||||
logmode = LOGMODE_NONE; /* suppress error_msg() output */
|
||||
|
@ -1103,12 +1103,12 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv)
|
||||
/* Parse command line */
|
||||
/* O,x: list; -T,-t,-A take numeric param */
|
||||
IF_UDHCP_VERBOSE(opt_complementary = "vv";)
|
||||
IF_LONG_OPTS(applet_long_options = udhcpc6_longopts;)
|
||||
opt = getopt32(argv, "i:np:qRr:s:T:+t:+SA:+O:*ox:*f"
|
||||
opt = getopt32long(argv, "i:np:qRr:s:T:+t:+SA:+O:*ox:*f"
|
||||
USE_FOR_MMU("b")
|
||||
///IF_FEATURE_UDHCPC_ARPING("a")
|
||||
IF_FEATURE_UDHCP_PORT("P:")
|
||||
"v"
|
||||
, udhcpc6_longopts
|
||||
, &client_config.interface, &client_config.pidfile, &str_r /* i,p */
|
||||
, &client_config.script /* s */
|
||||
, &discover_timeout, &discover_retries, &tryagain_timeout /* T,t,A */
|
||||
|
@ -1297,12 +1297,12 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
|
||||
/* Parse command line */
|
||||
/* O,x: list; -T,-t,-A take numeric param */
|
||||
IF_UDHCP_VERBOSE(opt_complementary = "vv";)
|
||||
IF_LONG_OPTS(applet_long_options = udhcpc_longopts;)
|
||||
opt = getopt32(argv, "CV:H:h:F:i:np:qRr:s:T:+t:+SA:+O:*ox:*fB"
|
||||
opt = getopt32long(argv, "CV:H:h:F:i:np:qRr:s:T:+t:+SA:+O:*ox:*fB"
|
||||
USE_FOR_MMU("b")
|
||||
IF_FEATURE_UDHCPC_ARPING("a::")
|
||||
IF_FEATURE_UDHCP_PORT("P:")
|
||||
"v"
|
||||
, udhcpc_longopts
|
||||
, &str_V, &str_h, &str_h, &str_F
|
||||
, &client_config.interface, &client_config.pidfile, &str_r /* i,p */
|
||||
, &client_config.script /* s */
|
||||
|
@ -51,12 +51,11 @@ int dumpleases_main(int argc UNUSED_PARAM, char **argv)
|
||||
"decimal\0" No_argument "d"
|
||||
;
|
||||
|
||||
applet_long_options = dumpleases_longopts;
|
||||
#endif
|
||||
init_unicode();
|
||||
|
||||
opt_complementary = "=0:a--r:r--a";
|
||||
opt = getopt32(argv, "arf:d", &file);
|
||||
opt = getopt32long(argv, "arf:d", dumpleases_longopts, &file);
|
||||
|
||||
fd = xopen(file, O_RDONLY);
|
||||
|
||||
|
@ -1365,6 +1365,11 @@ IF_DESKTOP( "no-clobber\0" No_argument "\xf0")
|
||||
IF_DESKTOP( "no-host-directories\0" No_argument "\xf0")
|
||||
IF_DESKTOP( "no-parent\0" No_argument "\xf0")
|
||||
;
|
||||
# define GETOPT32 getopt32long
|
||||
# define LONGOPTS ,wget_longopts
|
||||
#else
|
||||
# define GETOPT32 getopt32
|
||||
# define LONGOPTS
|
||||
#endif
|
||||
|
||||
#if ENABLE_FEATURE_WGET_LONG_OPTIONS
|
||||
@ -1381,11 +1386,10 @@ IF_DESKTOP( "no-parent\0" No_argument "\xf0")
|
||||
G.user_agent = "Wget"; /* "User-Agent" header field */
|
||||
|
||||
#if ENABLE_FEATURE_WGET_LONG_OPTIONS
|
||||
applet_long_options = wget_longopts;
|
||||
#endif
|
||||
opt_complementary = "-1" /* at least one URL */
|
||||
IF_FEATURE_WGET_LONG_OPTIONS(":\xff::"); /* --header is a list */
|
||||
getopt32(argv, "cqSO:P:Y:U:T:+"
|
||||
GETOPT32(argv, "cqSO:P:Y:U:T:+"
|
||||
/*ignored:*/ "t:"
|
||||
/*ignored:*/ "n::"
|
||||
/* wget has exactly four -n<letter> opts, all of which we can ignore:
|
||||
@ -1396,6 +1400,7 @@ IF_DESKTOP( "no-parent\0" No_argument "\xf0")
|
||||
* "n::" above says that we accept -n[ARG].
|
||||
* Specifying "n:" would be a bug: "-n ARG" would eat ARG!
|
||||
*/
|
||||
LONGOPTS
|
||||
, &G.fname_out, &G.dir_prefix,
|
||||
&G.proxy_flag, &G.user_agent,
|
||||
IF_FEATURE_WGET_TIMEOUT(&G.timeout_seconds) IF_NOT_FEATURE_WGET_TIMEOUT(NULL),
|
||||
|
@ -13,11 +13,6 @@
|
||||
//config: depends on SELINUX
|
||||
//config: help
|
||||
//config: Enable support to change the security context of file.
|
||||
//config:
|
||||
//config:config FEATURE_CHCON_LONG_OPTIONS
|
||||
//config: bool "Enable long options"
|
||||
//config: default y
|
||||
//config: depends on CHCON && LONG_OPTS
|
||||
|
||||
//applet:IF_CHCON(APPLET(chcon, BB_DIR_USR_BIN, BB_SUID_DROP))
|
||||
|
||||
@ -26,34 +21,22 @@
|
||||
//usage:#define chcon_trivial_usage
|
||||
//usage: "[OPTIONS] CONTEXT FILE..."
|
||||
//usage: "\n chcon [OPTIONS] [-u USER] [-r ROLE] [-l RANGE] [-t TYPE] FILE..."
|
||||
//usage: IF_FEATURE_CHCON_LONG_OPTIONS(
|
||||
//usage: "\n chcon [OPTIONS] --reference=RFILE FILE..."
|
||||
//usage: )
|
||||
//usage:
|
||||
//usage:#define chcon_full_usage "\n\n"
|
||||
//usage: "Change the security context of each FILE to CONTEXT\n"
|
||||
//usage: IF_FEATURE_CHCON_LONG_OPTIONS(
|
||||
//usage: "\n -v,--verbose Verbose"
|
||||
//usage: "\n -c,--changes Report changes made"
|
||||
//usage: "\n -h,--no-dereference Affect symlinks instead of their targets"
|
||||
//usage: "\n -f,--silent,--quiet Suppress most error messages"
|
||||
//usage: "\n --reference RFILE Use RFILE's group instead of using a CONTEXT value"
|
||||
//usage: "\n -u,--user USER Set user/role/type/range in the target"
|
||||
//usage: "\n -r,--role ROLE security context"
|
||||
//usage: "\n -t,--type TYPE"
|
||||
//usage: "\n -l,--range RANGE"
|
||||
//usage: "\n -R,--recursive Recurse"
|
||||
//usage: )
|
||||
//usage: IF_NOT_FEATURE_CHCON_LONG_OPTIONS(
|
||||
//usage: "\n -v Verbose"
|
||||
//usage: "\n -c Report changes made"
|
||||
//usage: "\n -h Affect symlinks instead of their targets"
|
||||
//usage: "\n -f Suppress most error messages"
|
||||
//usage: IF_LONG_OPTS(
|
||||
//usage: "\n --reference RFILE Use RFILE's group instead of using a CONTEXT value"
|
||||
//usage: )
|
||||
//usage: "\n -u USER Set user/role/type/range in the target security context"
|
||||
//usage: "\n -r ROLE"
|
||||
//usage: "\n -t TYPE"
|
||||
//usage: "\n -l RNG"
|
||||
//usage: "\n -R Recurse"
|
||||
//usage: )
|
||||
|
||||
#include <selinux/context.h>
|
||||
|
||||
@ -68,7 +51,7 @@
|
||||
#define OPT_TYPE (1<<6) /* 't' */
|
||||
#define OPT_RANGE (1<<7) /* 'l' */
|
||||
#define OPT_VERBOSE (1<<8) /* 'v' */
|
||||
#define OPT_REFERENCE ((1<<9) * ENABLE_FEATURE_CHCON_LONG_OPTIONS)
|
||||
#define OPT_REFERENCE ((1<<9) * ENABLE_LONG_OPTS)
|
||||
#define OPT_COMPONENT_SPECIFIED (OPT_USER | OPT_ROLE | OPT_TYPE | OPT_RANGE)
|
||||
|
||||
static char *user = NULL;
|
||||
@ -157,7 +140,7 @@ skip:
|
||||
return rc;
|
||||
}
|
||||
|
||||
#if ENABLE_FEATURE_CHCON_LONG_OPTIONS
|
||||
#if ENABLE_LONG_OPTS
|
||||
static const char chcon_longopts[] ALIGN1 =
|
||||
"recursive\0" No_argument "R"
|
||||
"changes\0" No_argument "c"
|
||||
@ -180,20 +163,18 @@ int chcon_main(int argc UNUSED_PARAM, char **argv)
|
||||
char *fname;
|
||||
int i, errors = 0;
|
||||
|
||||
#if ENABLE_FEATURE_CHCON_LONG_OPTIONS
|
||||
applet_long_options = chcon_longopts;
|
||||
#endif
|
||||
opt_complementary = "-1" /* at least 1 param */
|
||||
":?" /* error if exclusivity constraints are violated */
|
||||
#if ENABLE_FEATURE_CHCON_LONG_OPTIONS
|
||||
#if ENABLE_LONG_OPTS
|
||||
":\xff--urtl:u--\xff:r--\xff:t--\xff:l--\xff"
|
||||
#endif
|
||||
":f--v:v--f"; /* 'verbose' and 'quiet' are exclusive */
|
||||
getopt32(argv, "Rchfu:r:t:l:v",
|
||||
&user, &role, &type, &range, &reference_file);
|
||||
getopt32long(argv, "Rchfu:r:t:l:v", chcon_longopts,
|
||||
&user, &role, &type, &range, &reference_file
|
||||
);
|
||||
argv += optind;
|
||||
|
||||
#if ENABLE_FEATURE_CHCON_LONG_OPTIONS
|
||||
#if ENABLE_LONG_OPTS
|
||||
if (option_mask32 & OPT_REFERENCE) {
|
||||
/* FIXME: lgetfilecon() should be used when '-h' is specified.
|
||||
* But current implementation follows the original one. */
|
||||
|
@ -34,11 +34,6 @@
|
||||
//config: depends on SELINUX
|
||||
//config: help
|
||||
//config: Enable support to run command in specified security context.
|
||||
//config:
|
||||
//config:config FEATURE_RUNCON_LONG_OPTIONS
|
||||
//config: bool "Enable long options"
|
||||
//config: default y
|
||||
//config: depends on RUNCON && LONG_OPTS
|
||||
|
||||
//applet:IF_RUNCON(APPLET(runcon, BB_DIR_USR_BIN, BB_SUID_DROP))
|
||||
|
||||
@ -50,20 +45,11 @@
|
||||
//usage:#define runcon_full_usage "\n\n"
|
||||
//usage: "Run PROG in a different security context\n"
|
||||
//usage: "\n CONTEXT Complete security context\n"
|
||||
//usage: IF_FEATURE_RUNCON_LONG_OPTIONS(
|
||||
//usage: "\n -c,--compute Compute process transition context before modifying"
|
||||
//usage: "\n -t,--type TYPE Type (for same role as parent)"
|
||||
//usage: "\n -u,--user USER User identity"
|
||||
//usage: "\n -r,--role ROLE Role"
|
||||
//usage: "\n -l,--range RNG Levelrange"
|
||||
//usage: )
|
||||
//usage: IF_NOT_FEATURE_RUNCON_LONG_OPTIONS(
|
||||
//usage: "\n -c Compute process transition context before modifying"
|
||||
//usage: "\n -t TYPE Type (for same role as parent)"
|
||||
//usage: "\n -u USER User identity"
|
||||
//usage: "\n -r ROLE Role"
|
||||
//usage: "\n -l RNG Levelrange"
|
||||
//usage: )
|
||||
|
||||
#include <selinux/context.h>
|
||||
/* from deprecated <selinux/flask.h>: */
|
||||
@ -108,7 +94,7 @@ static context_t runcon_compute_new_context(char *user, char *role, char *type,
|
||||
return con;
|
||||
}
|
||||
|
||||
#if ENABLE_FEATURE_RUNCON_LONG_OPTIONS
|
||||
#if ENABLE_LONG_OPTS
|
||||
static const char runcon_longopts[] ALIGN1 =
|
||||
"user\0" Required_argument "u"
|
||||
"role\0" Required_argument "r"
|
||||
@ -140,11 +126,9 @@ int runcon_main(int argc UNUSED_PARAM, char **argv)
|
||||
|
||||
selinux_or_die();
|
||||
|
||||
#if ENABLE_FEATURE_RUNCON_LONG_OPTIONS
|
||||
applet_long_options = runcon_longopts;
|
||||
#endif
|
||||
opt_complementary = "-1";
|
||||
opts = getopt32(argv, "r:t:u:l:ch", &role, &type, &user, &range);
|
||||
opts = getopt32long(argv, "r:t:u:l:ch", runcon_longopts,
|
||||
&role, &type, &user, &range);
|
||||
argv += optind;
|
||||
|
||||
if (!(opts & OPTS_CONTEXT_COMPONENT)) {
|
||||
|
@ -44,11 +44,10 @@ int flock_main(int argc UNUSED_PARAM, char **argv)
|
||||
"unlock\0" No_argument "u"
|
||||
"nonblock\0" No_argument "n"
|
||||
;
|
||||
applet_long_options = flock_longopts;
|
||||
#endif
|
||||
opt_complementary = "-1";
|
||||
|
||||
opt = getopt32(argv, "+sxnu");
|
||||
opt = getopt32long(argv, "+sxnu", flock_longopts);
|
||||
argv += optind;
|
||||
|
||||
if (argv[1]) {
|
||||
|
@ -36,15 +36,14 @@ int fsfreeze_main(int argc UNUSED_PARAM, char **argv)
|
||||
unsigned opts;
|
||||
int fd;
|
||||
|
||||
applet_long_options =
|
||||
"freeze\0" No_argument "\xff"
|
||||
"unfreeze\0" No_argument "\xfe"
|
||||
;
|
||||
/* exactly one non-option arg: the mountpoint */
|
||||
/* one of opts is required */
|
||||
/* opts are mutually exclusive */
|
||||
opt_complementary = "=1:""\xff:\xfe:""\xff--\xfe:\xfe--\xff";
|
||||
opts = getopt32(argv, "");
|
||||
opts = getopt32long(argv, "",
|
||||
"freeze\0" No_argument "\xff"
|
||||
"unfreeze\0" No_argument "\xfe"
|
||||
);
|
||||
|
||||
fd = xopen(argv[optind], O_RDONLY);
|
||||
/* Works with NULL arg on linux-4.8.0 */
|
||||
|
@ -69,11 +69,10 @@ int fstrim_main(int argc UNUSED_PARAM, char **argv)
|
||||
"minimum\0" Required_argument "m"
|
||||
"verbose\0" No_argument "v"
|
||||
;
|
||||
applet_long_options = fstrim_longopts;
|
||||
#endif
|
||||
|
||||
opt_complementary = "=1"; /* exactly one non-option arg: the mountpoint */
|
||||
opts = getopt32(argv, "o:l:m:v", &arg_o, &arg_l, &arg_m);
|
||||
opts = getopt32long(argv, "o:l:m:v", fstrim_longopts, &arg_o, &arg_l, &arg_m);
|
||||
|
||||
memset(&range, 0, sizeof(range));
|
||||
range.len = ULLONG_MAX;
|
||||
|
@ -42,8 +42,8 @@
|
||||
//config:
|
||||
//config:config FEATURE_GETOPT_LONG
|
||||
//config: bool "Support -l LONGOPTs"
|
||||
//config: default y if LONG_OPTS
|
||||
//config: depends on GETOPT
|
||||
//config: default y
|
||||
//config: depends on GETOPT && LONG_OPTS
|
||||
//config: help
|
||||
//config: Enable support for long options (option -l).
|
||||
|
||||
@ -54,20 +54,6 @@
|
||||
//usage:#define getopt_trivial_usage
|
||||
//usage: "[OPTIONS] [--] OPTSTRING PARAMS"
|
||||
//usage:#define getopt_full_usage "\n\n"
|
||||
//usage: IF_LONG_OPTS(
|
||||
//usage: IF_FEATURE_GETOPT_LONG(
|
||||
//usage: " -a,--alternative Allow long options starting with single -\n"
|
||||
//usage: " -l,--longoptions LOPT[,...] Long options to recognize\n"
|
||||
//usage: )
|
||||
//usage: " -n,--name PROGNAME The name under which errors are reported"
|
||||
//usage: "\n -o,--options OPTSTRING Short options to recognize"
|
||||
//usage: "\n -q,--quiet No error messages on unrecognized options"
|
||||
//usage: "\n -Q,--quiet-output No normal output"
|
||||
//usage: "\n -s,--shell SHELL Set shell quoting conventions"
|
||||
//usage: "\n -T,--test Version test (exits with 4)"
|
||||
//usage: "\n -u,--unquoted Don't quote output"
|
||||
//usage: )
|
||||
//usage: IF_NOT_LONG_OPTS(
|
||||
//usage: IF_FEATURE_GETOPT_LONG(
|
||||
//usage: " -a Allow long options starting with single -\n"
|
||||
//usage: " -l LOPT[,...] Long options to recognize\n"
|
||||
@ -79,7 +65,6 @@
|
||||
//usage: "\n -s SHELL Set shell quoting conventions"
|
||||
//usage: "\n -T Version test (exits with 4)"
|
||||
//usage: "\n -u Don't quote output"
|
||||
//usage: )
|
||||
//usage: IF_FEATURE_GETOPT_LONG( /* example uses -l, needs FEATURE_GETOPT_LONG */
|
||||
//usage: "\n"
|
||||
//usage: "\nExample:"
|
||||
@ -411,8 +396,7 @@ int getopt_main(int argc, char **argv)
|
||||
#if !ENABLE_FEATURE_GETOPT_LONG
|
||||
opt = getopt32(argv, "+o:n:qQs:Tu", &optstr, &name, &s_arg);
|
||||
#else
|
||||
applet_long_options = getopt_longopts;
|
||||
opt = getopt32(argv, "+o:n:qQs:Tual:*",
|
||||
opt = getopt32long(argv, "+o:n:qQs:Tual:*", getopt_longopts,
|
||||
&optstr, &name, &s_arg, &l_arg);
|
||||
/* Effectuate the read options for the applet itself */
|
||||
while (l_arg) {
|
||||
|
@ -16,11 +16,6 @@
|
||||
//config: shutdown in the hardware clock, so the hardware will keep the
|
||||
//config: correct time when Linux is _not_ running.
|
||||
//config:
|
||||
//config:config FEATURE_HWCLOCK_LONG_OPTIONS
|
||||
//config: bool "Support long options (--hctosys,...)"
|
||||
//config: default y
|
||||
//config: depends on HWCLOCK && LONG_OPTS
|
||||
//config:
|
||||
//config:config FEATURE_HWCLOCK_ADJTIME_FHS
|
||||
//config: bool "Use FHS /var/lib/hwclock/adjtime"
|
||||
//config: default n # util-linux-ng in Fedora 13 still uses /etc/adjtime
|
||||
@ -293,12 +288,12 @@ static void set_system_clock_timezone(int utc)
|
||||
}
|
||||
|
||||
//usage:#define hwclock_trivial_usage
|
||||
//usage: IF_FEATURE_HWCLOCK_LONG_OPTIONS(
|
||||
//usage: "[-r|--show] [-s|--hctosys] [-w|--systohc] [-t|--systz]"
|
||||
//usage: " [-l|--localtime] [-u|--utc]"
|
||||
//usage: IF_LONG_OPTS(
|
||||
//usage: "[-r|--show] [-s|--hctosys] [-w|--systohc] [--systz]"
|
||||
//usage: " [--localtime] [-u|--utc]"
|
||||
//usage: " [-f|--rtc FILE]"
|
||||
//usage: )
|
||||
//usage: IF_NOT_FEATURE_HWCLOCK_LONG_OPTIONS(
|
||||
//usage: IF_NOT_LONG_OPTS(
|
||||
//usage: "[-r] [-s] [-w] [-t] [-l] [-u] [-f FILE]"
|
||||
//usage: )
|
||||
//usage:#define hwclock_full_usage "\n\n"
|
||||
@ -306,12 +301,18 @@ static void set_system_clock_timezone(int utc)
|
||||
//usage: "\n -r Show hardware clock time"
|
||||
//usage: "\n -s Set system time from hardware clock"
|
||||
//usage: "\n -w Set hardware clock from system time"
|
||||
//usage: "\n -t Set in-kernel timezone, correct system time"
|
||||
//usage: IF_LONG_OPTS(
|
||||
//usage: "\n --systz Set in-kernel timezone, correct system time"
|
||||
//usage: )
|
||||
//usage: "\n if hardware clock is in local time"
|
||||
//usage: "\n -u Assume hardware clock is kept in UTC"
|
||||
//usage: "\n -l Assume hardware clock is kept in local time"
|
||||
//usage: IF_LONG_OPTS(
|
||||
//usage: "\n --localtime Assume hardware clock is kept in local time"
|
||||
//usage: )
|
||||
//usage: "\n -f FILE Use specified device (e.g. /dev/rtc2)"
|
||||
|
||||
//TODO: get rid of incompatible -t and -l aliases to --systz and --localtime
|
||||
|
||||
#define HWCLOCK_OPT_LOCALTIME 0x01
|
||||
#define HWCLOCK_OPT_UTC 0x02
|
||||
#define HWCLOCK_OPT_SHOW 0x04
|
||||
@ -327,7 +328,7 @@ int hwclock_main(int argc UNUSED_PARAM, char **argv)
|
||||
unsigned opt;
|
||||
int utc;
|
||||
|
||||
#if ENABLE_FEATURE_HWCLOCK_LONG_OPTIONS
|
||||
#if ENABLE_LONG_OPTS
|
||||
static const char hwclock_longopts[] ALIGN1 =
|
||||
"localtime\0" No_argument "l" /* short opt is non-standard */
|
||||
"utc\0" No_argument "u"
|
||||
@ -337,14 +338,13 @@ int hwclock_main(int argc UNUSED_PARAM, char **argv)
|
||||
"systz\0" No_argument "t" /* short opt is non-standard */
|
||||
"rtc\0" Required_argument "f"
|
||||
;
|
||||
applet_long_options = hwclock_longopts;
|
||||
#endif
|
||||
|
||||
/* Initialize "timezone" (libc global variable) */
|
||||
tzset();
|
||||
|
||||
opt_complementary = "r--wst:w--rst:s--wrt:t--rsw:l--u:u--l";
|
||||
opt = getopt32(argv, "lurswtf:", &rtcname);
|
||||
opt = getopt32long(argv, "lurswtf:", hwclock_longopts, &rtcname);
|
||||
|
||||
/* If -u or -l wasn't given check if we are using utc */
|
||||
if (opt & (HWCLOCK_OPT_UTC | HWCLOCK_OPT_LOCALTIME))
|
||||
|
@ -13,14 +13,6 @@
|
||||
//config: select PLATFORM_LINUX
|
||||
//config: help
|
||||
//config: Run program with namespaces of other processes.
|
||||
//config:
|
||||
//config:config FEATURE_NSENTER_LONG_OPTS
|
||||
//config: bool "Enable long options"
|
||||
//config: default y
|
||||
//config: depends on NSENTER && LONG_OPTS
|
||||
//config: help
|
||||
//config: Support long options for the nsenter applet. This makes
|
||||
//config: the busybox implementation more compatible with upstream.
|
||||
|
||||
//applet:IF_NSENTER(APPLET(nsenter, BB_DIR_USR_BIN, BB_SUID_DROP))
|
||||
|
||||
@ -28,22 +20,6 @@
|
||||
|
||||
//usage:#define nsenter_trivial_usage
|
||||
//usage: "[OPTIONS] [PROG [ARGS]]"
|
||||
//usage:#if ENABLE_FEATURE_NSENTER_LONG_OPTS
|
||||
//usage:#define nsenter_full_usage "\n"
|
||||
//usage: "\n -t,--target PID Target process to get namespaces from"
|
||||
//usage: "\n -m,--mount[=FILE] Enter mount namespace"
|
||||
//usage: "\n -u,--uts[=FILE] Enter UTS namespace (hostname etc)"
|
||||
//usage: "\n -i,--ipc[=FILE] Enter System V IPC namespace"
|
||||
//usage: "\n -n,--net[=FILE] Enter network namespace"
|
||||
//usage: "\n -p,--pid[=FILE] Enter pid namespace"
|
||||
//usage: "\n -U,--user[=FILE] Enter user namespace"
|
||||
//usage: "\n -S,--setuid UID Set uid in entered namespace"
|
||||
//usage: "\n -G,--setgid GID Set gid in entered namespace"
|
||||
//usage: "\n --preserve-credentials Don't touch uids or gids"
|
||||
//usage: "\n -r,--root[=DIR] Set root directory"
|
||||
//usage: "\n -w,--wd[=DIR] Set working directory"
|
||||
//usage: "\n -F,--no-fork Don't fork before exec'ing PROG"
|
||||
//usage:#else
|
||||
//usage:#define nsenter_full_usage "\n"
|
||||
//usage: "\n -t PID Target process to get namespaces from"
|
||||
//usage: "\n -m[FILE] Enter mount namespace"
|
||||
@ -54,10 +30,12 @@
|
||||
//usage: "\n -U[FILE] Enter user namespace"
|
||||
//usage: "\n -S UID Set uid in entered namespace"
|
||||
//usage: "\n -G GID Set gid in entered namespace"
|
||||
//usage: IF_LONG_OPTS(
|
||||
//usage: "\n --preserve-credentials Don't touch uids or gids"
|
||||
//usage: )
|
||||
//usage: "\n -r[DIR] Set root directory"
|
||||
//usage: "\n -w[DIR] Set working directory"
|
||||
//usage: "\n -F Don't fork before exec'ing PROG"
|
||||
//usage:#endif
|
||||
|
||||
#include <sched.h>
|
||||
#ifndef CLONE_NEWUTS
|
||||
@ -101,7 +79,7 @@ enum {
|
||||
OPT_root = 1 << 9,
|
||||
OPT_wd = 1 << 10,
|
||||
OPT_nofork = 1 << 11,
|
||||
OPT_prescred = (1 << 12) * ENABLE_FEATURE_NSENTER_LONG_OPTS,
|
||||
OPT_prescred = (1 << 12) * ENABLE_LONG_OPTS,
|
||||
};
|
||||
enum {
|
||||
NS_USR_POS = 0,
|
||||
@ -130,7 +108,7 @@ static const struct namespace_descr ns_list[] = {
|
||||
*/
|
||||
static const char opt_str[] ALIGN1 = "U::i::u::n::p::m::""t+S+G+r::w::F";
|
||||
|
||||
#if ENABLE_FEATURE_NSENTER_LONG_OPTS
|
||||
#if ENABLE_LONG_OPTS
|
||||
static const char nsenter_longopts[] ALIGN1 =
|
||||
"user\0" Optional_argument "U"
|
||||
"ipc\0" Optional_argument "i"
|
||||
@ -190,8 +168,7 @@ int nsenter_main(int argc UNUSED_PARAM, char **argv)
|
||||
|
||||
memset(ns_ctx_list, 0, sizeof(ns_ctx_list));
|
||||
|
||||
IF_FEATURE_NSENTER_LONG_OPTS(applet_long_options = nsenter_longopts);
|
||||
opts = getopt32(argv, opt_str,
|
||||
opts = getopt32long(argv, opt_str, nsenter_longopts,
|
||||
&ns_ctx_list[NS_USR_POS].path,
|
||||
&ns_ctx_list[NS_IPC_POS].path,
|
||||
&ns_ctx_list[NS_UTS_POS].path,
|
||||
|
@ -154,11 +154,11 @@ int rtcwake_main(int argc UNUSED_PARAM, char **argv)
|
||||
"seconds\0" Required_argument "s"
|
||||
"time\0" Required_argument "t"
|
||||
;
|
||||
applet_long_options = rtcwake_longopts;
|
||||
#endif
|
||||
/* Must have -s or -t, exclusive */
|
||||
opt_complementary = "s:t:s--t:t--s";
|
||||
opt = getopt32(argv, "alud:m:s:t:", &rtcname, &suspend, &opt_seconds, &opt_time);
|
||||
opt = getopt32long(argv, "alud:m:s:t:", rtcwake_longopts,
|
||||
&rtcname, &suspend, &opt_seconds, &opt_time);
|
||||
|
||||
/* this is the default
|
||||
if (opt & RTCWAKE_OPT_AUTO)
|
||||
|
@ -78,12 +78,10 @@ int script_main(int argc UNUSED_PARAM, char **argv)
|
||||
"quiet\0" No_argument "q"
|
||||
"timing\0" Optional_argument "t"
|
||||
;
|
||||
|
||||
applet_long_options = script_longopts;
|
||||
#endif
|
||||
|
||||
opt_complementary = "?1"; /* max one arg */
|
||||
opt = getopt32(argv, "ac:fqt::", &shell_arg, &str_t);
|
||||
opt = getopt32long(argv, "ac:fqt::", script_longopts, &shell_arg, &str_t);
|
||||
//argc -= optind;
|
||||
argv += optind;
|
||||
if (argv[0]) {
|
||||
|
@ -421,9 +421,12 @@ int setpriv_main(int argc UNUSED_PARAM, char **argv)
|
||||
int opts;
|
||||
IF_FEATURE_SETPRIV_CAPABILITIES(char *inh_caps, *ambient_caps;)
|
||||
|
||||
applet_long_options = setpriv_longopts;
|
||||
opts = getopt32(argv, "+"IF_FEATURE_SETPRIV_DUMP("d")
|
||||
IF_FEATURE_SETPRIV_CAPABILITIES("\xfe:\xfd:", &inh_caps, &ambient_caps));
|
||||
opts = getopt32long(argv,
|
||||
"+"IF_FEATURE_SETPRIV_DUMP("d")
|
||||
IF_FEATURE_SETPRIV_CAPABILITIES("\xfe:\xfd:"),
|
||||
setpriv_longopts
|
||||
IF_FEATURE_SETPRIV_CAPABILITIES(, &inh_caps, &ambient_caps)
|
||||
);
|
||||
argv += optind;
|
||||
|
||||
#if ENABLE_FEATURE_SETPRIV_DUMP
|
||||
|
@ -220,8 +220,7 @@ int unshare_main(int argc UNUSED_PARAM, char **argv)
|
||||
":ru" /* --map-root-user or -r implies -u */
|
||||
":\xfd""m" /* --mount-proc implies -m */
|
||||
;
|
||||
applet_long_options = unshare_longopts;
|
||||
opts = getopt32(argv, opt_str,
|
||||
opts = getopt32long(argv, opt_str, unshare_longopts,
|
||||
&proc_mnt_target, &prop_str, &setgrp_str,
|
||||
&ns_ctx_list[NS_MNT_POS].path,
|
||||
&ns_ctx_list[NS_UTS_POS].path,
|
||||
|
Loading…
Reference in New Issue
Block a user