Enable this if your system has locale support and you would like
busybox to support locale settings.
-config GETOPT_LONG
+config LONG_OPTS
bool "Support for --long-options"
default y
help
CONFIG_FEATURE_COMPRESS_USAGE=y
CONFIG_FEATURE_INSTALLER=y
# CONFIG_LOCALE_SUPPORT is not set
-CONFIG_GETOPT_LONG=y
+CONFIG_LONG_OPTS=y
CONFIG_FEATURE_DEVPTS=y
# CONFIG_FEATURE_CLEAN_UP is not set
CONFIG_FEATURE_PIDFILE=y
config FEATURE_TAR_LONG_OPTIONS
bool "Enable long options"
default n
- depends on TAR && GETOPT_LONG
+ depends on TAR && LONG_OPTS
help
Enable use of long options, increases size by about 400 Bytes
IF_FEATURE_CPIO_O(const char *cpio_fmt = "";)
unsigned opt;
-#if ENABLE_GETOPT_LONG
+#if ENABLE_LONG_OPTS
applet_long_options =
"extract\0" No_argument "i"
"list\0" No_argument "t"
config FEATURE_SETCONSOLE_LONG_OPTIONS
bool "Enable long options"
default n
- depends on SETCONSOLE && GETOPT_LONG
+ depends on SETCONSOLE && LONG_OPTS
help
Support long options for the setconsole applet.
config FEATURE_ENV_LONG_OPTIONS
bool "Enable long options"
default n
- depends on ENV && GETOPT_LONG
+ depends on ENV && LONG_OPTS
help
Support long options for the env applet.
config FEATURE_EXPAND_LONG_OPTIONS
bool "Enable long options"
default n
- depends on EXPAND && GETOPT_LONG
+ depends on EXPAND && LONG_OPTS
help
Support long options for the expand applet.
config FEATURE_INSTALL_LONG_OPTIONS
bool "Enable long options"
default n
- depends on INSTALL && GETOPT_LONG
+ depends on INSTALL && LONG_OPTS
help
Support long options for the install applet.
config FEATURE_LS_COLOR
bool "Allow use of color to identify file types"
default y
- depends on LS && GETOPT_LONG
+ depends on LS && LONG_OPTS
help
This enables the --color option to ls.
config FEATURE_MKDIR_LONG_OPTIONS
bool "Enable long options"
default n
- depends on MKDIR && GETOPT_LONG
+ depends on MKDIR && LONG_OPTS
help
Support long options for the mkdir applet.
config FEATURE_MV_LONG_OPTIONS
bool "Enable long options"
default n
- depends on MV && GETOPT_LONG
+ depends on MV && LONG_OPTS
help
Support long options for the mv applet.
config FEATURE_RMDIR_LONG_OPTIONS
bool "Enable long options"
default n
- depends on RMDIR && GETOPT_LONG
+ depends on RMDIR && LONG_OPTS
help
Support long options for the rmdir applet, including
--ignore-fail-on-non-empty for compatibility with GNU rmdir.
config FEATURE_UNEXPAND_LONG_OPTIONS
bool "Enable long options"
default n
- depends on UNEXPAND && GETOPT_LONG
+ depends on UNEXPAND && LONG_OPTS
help
Support long options for the unexpand applet.
printf(address_fmt, address);
}
-#if ENABLE_GETOPT_LONG
+#if ENABLE_LONG_OPTS
/* only used with --traditional */
static void
format_address_paren(off_t address, char c)
return l_c_m;
}
-#if ENABLE_GETOPT_LONG
+#if ENABLE_LONG_OPTS
/* If S is a valid traditional offset specification with an optional
leading '+' return nonzero and set *OFFSET to the offset it denotes. */
OPT_s = 1 << 15,
OPT_S = 1 << 16,
OPT_w = 1 << 17,
- OPT_traditional = (1 << 18) * ENABLE_GETOPT_LONG,
+ OPT_traditional = (1 << 18) * ENABLE_LONG_OPTS,
};
-#if ENABLE_GETOPT_LONG
+#if ENABLE_LONG_OPTS
static const char od_longopts[] ALIGN1 =
"skip-bytes\0" Required_argument "j"
"address-radix\0" Required_argument "A"
/* Parse command line */
opt_complementary = "w+:t::"; /* -w N, -t is a list */
-#if ENABLE_GETOPT_LONG
+#if ENABLE_LONG_OPTS
applet_long_options = od_longopts;
#endif
opt = getopt32(argv, "A:N:abcdfhij:lot:vxsS:"
* FIXME: POSIX 1003.1-2001 with XSI requires support for the
* traditional syntax even if --traditional is not given. */
-#if ENABLE_GETOPT_LONG
+#if ENABLE_LONG_OPTS
if (opt & OPT_traditional) {
off_t o1, o2;
int touch_main(int argc UNUSED_PARAM, char **argv)
{
#if ENABLE_DESKTOP
-#if ENABLE_GETOPT_LONG
+#if ENABLE_LONG_OPTS
static const char longopts[] ALIGN1 =
/* name, has_arg, val */
"no-create\0" No_argument "c"
int opts;
#if ENABLE_DESKTOP
-#if ENABLE_GETOPT_LONG
+#if ENABLE_LONG_OPTS
applet_long_options = longopts;
#endif
#endif
int uname_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int uname_main(int argc UNUSED_PARAM, char **argv)
{
-#if ENABLE_GETOPT_LONG
+#if ENABLE_LONG_OPTS
static const char longopts[] ALIGN1 =
/* name, has_arg, val */
"all\0" No_argument "a"
const unsigned short *delta;
unsigned toprint;
- IF_GETOPT_LONG(applet_long_options = longopts);
+ IF_LONG_OPTS(applet_long_options = longopts);
toprint = getopt32(argv, options);
if (argv[optind]) { /* coreutils-6.9 compat */
config FEATURE_RUN_PARTS_LONG_OPTIONS
bool "Enable long options"
default n
- depends on RUN_PARTS && GETOPT_LONG
+ depends on RUN_PARTS && LONG_OPTS
help
Support long options for the run-parts applet.
config FEATURE_START_STOP_DAEMON_LONG_OPTIONS
bool "Enable long options"
default n
- depends on START_STOP_DAEMON && GETOPT_LONG
+ depends on START_STOP_DAEMON && LONG_OPTS
help
Support long options for the start-stop-daemon applet.
extern const char *const bb_argv_dash[]; /* "-", NULL */
extern const char *opt_complementary;
-#if ENABLE_GETOPT_LONG
+#if ENABLE_LONG_OPTS || ENABLE_FEATURE_GETOPT_LONG
#define No_argument "\0"
#define Required_argument "\001"
#define Optional_argument "\002"
#define cryptpw_full_usage "\n\n" \
"Crypt the PASSWORD using crypt(3)\n" \
"\nOptions:" \
- IF_GETOPT_LONG( \
+ IF_LONG_OPTS( \
"\n -P,--password-fd=NUM Read password from fd NUM" \
/* "\n -s,--stdin Use stdin; like -P0" */ \
"\n -m,--method=TYPE Encryption method TYPE" \
"\n -S,--salt=SALT" \
) \
- IF_NOT_GETOPT_LONG( \
+ IF_NOT_LONG_OPTS( \
"\n -P NUM Read password from fd NUM" \
/* "\n -s Use stdin; like -P0" */ \
"\n -m TYPE Encryption method TYPE" \
#define mkpasswd_full_usage "\n\n" \
"Crypt the PASSWORD using crypt(3)\n" \
"\nOptions:" \
- IF_GETOPT_LONG( \
+ IF_LONG_OPTS( \
"\n -P,--password-fd=NUM Read password from fd NUM" \
/* "\n -s,--stdin Use stdin; like -P0" */ \
"\n -m,--method=TYPE Encryption method TYPE" \
"\n -S,--salt=SALT" \
) \
- IF_NOT_GETOPT_LONG( \
+ IF_NOT_LONG_OPTS( \
"\n -P NUM Read password from fd NUM" \
/* "\n -s Use stdin; like -P0" */ \
"\n -m TYPE Encryption method TYPE" \
#define dumpleases_full_usage "\n\n" \
"Display DHCP leases granted by udhcpd\n" \
"\nOptions:" \
- IF_GETOPT_LONG( \
+ IF_LONG_OPTS( \
"\n -f,--file=FILE Leases file to load" \
"\n -r,--remaining Interpret lease times as time remaining" \
"\n -a,--absolute Interpret lease times as expire time" \
) \
- IF_NOT_GETOPT_LONG( \
+ IF_NOT_LONG_OPTS( \
"\n -f FILE Leases file to load" \
"\n -r Interpret lease times as time remaining" \
"\n -a Interpret lease times as expire time" \
"[OPTIONS]..."
#define getopt_full_usage "\n\n" \
"Parse command options\n" \
- IF_GETOPT_LONG( \
+ IF_LONG_OPTS( \
"\n -a,--alternative Allow long options starting with single -" \
"\n -l,--longoptions=longopts Long options to be recognized" \
"\n -n,--name=progname The name under which errors are reported" \
"\n -T,--test Test for getopt(1) version" \
"\n -u,--unquoted Don't quote the output" \
) \
- IF_NOT_GETOPT_LONG( \
+ IF_NOT_LONG_OPTS( \
"\n -a Allow long options starting with single -" \
"\n -l longopts Long options to be recognized" \
"\n -n progname The name under which errors are reported" \
"\n -u Unlock (re-enable) account" \
#define chpasswd_trivial_usage \
- IF_GETOPT_LONG("[--md5|--encrypted]") IF_NOT_GETOPT_LONG("[-m|-e]")
+ IF_LONG_OPTS("[--md5|--encrypted]") IF_NOT_LONG_OPTS("[-m|-e]")
#define chpasswd_full_usage "\n\n" \
"Read user:password information from stdin " \
"and update /etc/passwd accordingly.\n" \
"\nOptions:" \
- IF_GETOPT_LONG( \
+ IF_LONG_OPTS( \
"\n -e,--encrypted Supplied passwords are in encrypted form" \
"\n -m,--md5 Use MD5 encryption instead of DES" \
) \
- IF_NOT_GETOPT_LONG( \
+ IF_NOT_LONG_OPTS( \
"\n -e Supplied passwords are in encrypted form" \
"\n -m Use MD5 encryption instead of DES" \
)
"[-a | -l | -u] [-d DEV] [-m MODE] [-s SEC | -t TIME]"
#define rtcwake_full_usage "\n\n" \
"Enter a system sleep state until specified wakeup time\n" \
- IF_GETOPT_LONG( \
+ IF_LONG_OPTS( \
"\n -a,--auto Read clock mode from adjtime" \
"\n -l,--local Clock is set to local time" \
"\n -u,--utc Clock is set to UTC time" \
"\n -s,--seconds=SEC Set the timeout in SEC seconds from now" \
"\n -t,--time=TIME Set the timeout to TIME seconds from epoch" \
) \
- IF_NOT_GETOPT_LONG( \
+ IF_NOT_LONG_OPTS( \
"\n -a Read clock mode from adjtime" \
"\n -l Clock is set to local time" \
"\n -u Clock is set to UTC time" \
"[-Cfbnqtvo] [-c CID] [-V VCLS] [-H HOSTNAME] [-i INTERFACE]\n" \
" [-p pidfile] [-r IP] [-s script] [-O dhcp-option]..." IF_FEATURE_UDHCP_PORT(" [-P N]")
#define udhcpc_full_usage "\n\n" \
- IF_GETOPT_LONG( \
+ IF_LONG_OPTS( \
" -V,--vendorclass=CLASSID Vendor class identifier" \
"\n -i,--interface=INTERFACE Interface to use (default eth0)" \
"\n -H,-h,--hostname=HOSTNAME Client hostname" \
"\n -a,--arping Use arping to validate offered address" \
) \
) \
- IF_NOT_GETOPT_LONG( \
+ IF_NOT_LONG_OPTS( \
" -V CLASSID Vendor class identifier" \
"\n -i INTERFACE Interface to use (default: eth0)" \
"\n -H,-h HOSTNAME Client hostname" \
} t_complementary;
/* You can set applet_long_options for parse called long options */
-#if ENABLE_GETOPT_LONG
+#if ENABLE_LONG_OPTS || ENABLE_FEATURE_GETOPT_LONG
static const struct option bb_null_long_options[1] = {
{ 0, 0, 0, 0 }
};
const unsigned char *s;
t_complementary *on_off;
va_list p;
-#if ENABLE_GETOPT_LONG
+#if ENABLE_LONG_OPTS || ENABLE_FEATURE_GETOPT_LONG
const struct option *l_o;
struct option *long_options = (struct option *) &bb_null_long_options;
#endif
c++;
}
-#if ENABLE_GETOPT_LONG
+#if ENABLE_LONG_OPTS || ENABLE_FEATURE_GETOPT_LONG
if (applet_long_options) {
const char *optstr;
unsigned i, count;
next_long: ;
}
}
-#endif /* ENABLE_GETOPT_LONG */
+#endif /* ENABLE_LONG_OPTS || ENABLE_FEATURE_GETOPT_LONG */
for (s = (const unsigned char *)opt_complementary; s && *s; s++) {
t_complementary *pair;
unsigned *pair_switch;
* "fake" short options, like this one:
* wget $'-\203' "Test: test" http://kernel.org/
* (supposed to act as --header, but doesn't) */
-#if ENABLE_GETOPT_LONG
+#if ENABLE_LONG_OPTS || ENABLE_FEATURE_GETOPT_LONG
while ((c = getopt_long(argc, argv, applet_opts,
long_options, NULL)) != -1) {
#else
config FEATURE_ADDGROUP_LONG_OPTIONS
bool "Enable long options"
default n
- depends on ADDGROUP && GETOPT_LONG
+ depends on ADDGROUP && LONG_OPTS
help
Support long options for the addgroup applet.
config FEATURE_ADDUSER_LONG_OPTIONS
bool "Enable long options"
default n
- depends on ADDUSER && GETOPT_LONG
+ depends on ADDUSER && LONG_OPTS
help
Support long options for the adduser applet.
*/
#include "libbb.h"
-#if ENABLE_GETOPT_LONG
+#if ENABLE_LONG_OPTS
static const char chpasswd_longopts[] ALIGN1 =
"encrypted\0" No_argument "e"
"md5\0" No_argument "m"
bb_error_msg_and_die(bb_msg_perm_denied_are_you_root);
opt_complementary = "m--e:e--m";
- IF_GETOPT_LONG(applet_long_options = chpasswd_longopts;)
+ IF_LONG_OPTS(applet_long_options = chpasswd_longopts;)
opt = getopt32(argv, "em");
while ((name = xmalloc_fgetline(stdin)) != NULL) {
int len;
int fd;
-#if ENABLE_GETOPT_LONG
+#if ENABLE_LONG_OPTS
static const char mkpasswd_longopts[] ALIGN1 =
"stdin\0" No_argument "s"
"password-fd\0" Required_argument "P"
config FEATURE_FTPGETPUT_LONG_OPTIONS
bool "Enable long options in ftpget/ftpput"
default n
- depends on GETOPT_LONG && (FTPGET || FTPPUT)
+ depends on LONG_OPTS && (FTPGET || FTPPUT)
help
Support long options for the ftpget/ftpput applet.
config FEATURE_IPCALC_LONG_OPTIONS
bool "Enable long options"
default n
- depends on IPCALC && GETOPT_LONG
+ depends on IPCALC && LONG_OPTS
help
Support long options for the ipcalc applet.
config FEATURE_WGET_LONG_OPTIONS
bool "Enable long options"
default n
- depends on WGET && GETOPT_LONG
+ depends on WGET && LONG_OPTS
help
Support long options for the wget applet.
OPT_d = (1 << 1),
OPT_f = (1 << 2),
};
-#if ENABLE_GETOPT_LONG
+#if ENABLE_LONG_OPTS
static const char ifenslave_longopts[] ALIGN1 =
"change-active\0" No_argument "c"
"detach\0" No_argument "d"
struct dhcp_packet packet;
fd_set rfds;
-#if ENABLE_GETOPT_LONG
+#if ENABLE_LONG_OPTS
static const char udhcpc_longopts[] ALIGN1 =
"clientid\0" Required_argument "c"
"clientid-none\0" No_argument "C"
":vv"
#endif
;
- IF_GETOPT_LONG(applet_long_options = udhcpc_longopts;)
+ IF_LONG_OPTS(applet_long_options = udhcpc_longopts;)
opt = getopt32(argv, "c:CV:H:h:F:i:np:qRr:s:T:t:SA:O:of"
USE_FOR_MMU("b")
IF_FEATURE_UDHCPC_ARPING("a")
OPT_r = 0x2, // -r
OPT_f = 0x4, // -f
};
-#if ENABLE_GETOPT_LONG
+#if ENABLE_LONG_OPTS
static const char dumpleases_longopts[] ALIGN1 =
"absolute\0" No_argument "a"
"remaining\0" No_argument "r"
CONFIG_FEATURE_COMPRESS_USAGE=y
CONFIG_FEATURE_INSTALLER=y
CONFIG_LOCALE_SUPPORT=y
-CONFIG_GETOPT_LONG=y
+CONFIG_LONG_OPTS=y
CONFIG_FEATURE_DEVPTS=y
# CONFIG_FEATURE_CLEAN_UP is not set
CONFIG_FEATURE_PIDFILE=y
CONFIG_FEATURE_MINIX2=y
CONFIG_MKFS_VFAT=y
CONFIG_GETOPT=y
+CONFIG_FEATURE_GETOPT_LONG=y
CONFIG_HEXDUMP=y
CONFIG_FEATURE_HEXDUMP_REVERSE=y
CONFIG_HD=y
config FEATURE_CHCON_LONG_OPTIONS
bool "Enable long options"
default y
- depends on CHCON && GETOPT_LONG
+ depends on CHCON && LONG_OPTS
help
Support long options for the chcon applet.
config FEATURE_RUNCON_LONG_OPTIONS
bool "Enable long options"
default y
- depends on RUNCON && GETOPT_LONG
+ depends on RUNCON && LONG_OPTS
help
Support long options for the runcon applet.
written by others, this utility may be for you. Most people will
wisely leave this disabled.
+config FEATURE_GETOPT_LONG
+ bool "Support option -l"
+ default y if LONG_OPTS
+ help
+ Enable support for recognising long options using the -l option to
+ getopt.
+
config HEXDUMP
bool "hexdump"
default n
config FEATURE_HWCLOCK_LONG_OPTIONS
bool "Support long options (--hctosys,...)"
default n
- depends on HWCLOCK && GETOPT_LONG
+ depends on HWCLOCK && LONG_OPTS
help
By default, the hwclock utility only uses short options. If you
are overly fond of its long options, such as --hctosys, --utc, etc)
mode */
enum {
NON_OPT = 1,
-#if ENABLE_GETOPT_LONG
+#if ENABLE_FEATURE_GETOPT_LONG
/* LONG_OPT is the code that is returned when a long option is found. */
LONG_OPT = 2
#endif
OPT_s = 0x10, // -s
OPT_T = 0x20, // -T
OPT_u = 0x40, // -u
-#if ENABLE_GETOPT_LONG
+#if ENABLE_FEATURE_GETOPT_LONG
OPT_a = 0x80, // -a
OPT_l = 0x100, // -l
#endif
* optstr must contain the short options, and longopts the long options.
* Other settings are found in global variables.
*/
-#if !ENABLE_GETOPT_LONG
+#if !ENABLE_FEATURE_GETOPT_LONG
#define generate_output(argv,argc,optstr,longopts) \
generate_output(argv,argc,optstr)
#endif
{
int exit_code = 0; /* We assume everything will be OK */
int opt;
-#if ENABLE_GETOPT_LONG
+#if ENABLE_FEATURE_GETOPT_LONG
int longindex;
#endif
const char *charptr;
while (1) {
opt =
-#if ENABLE_GETOPT_LONG
+#if ENABLE_FEATURE_GETOPT_LONG
alternative ?
getopt_long_only(argc, argv, optstr, longopts, &longindex) :
getopt_long(argc, argv, optstr, longopts, &longindex);
if (opt == '?' || opt == ':' )
exit_code = 1;
else if (!quiet_output) {
-#if ENABLE_GETOPT_LONG
+#if ENABLE_FEATURE_GETOPT_LONG
if (opt == LONG_OPT) {
printf(" --%s", longopts[longindex].name);
if (longopts[longindex].has_arg)
return exit_code;
}
-#if ENABLE_GETOPT_LONG
+#if ENABLE_FEATURE_GETOPT_LONG
/*
* Register several long options. options is a string of long options,
* separated by commas or whitespace.
* 4) Returned for -T
*/
-#if ENABLE_GETOPT_LONG
+#if ENABLE_FEATURE_GETOPT_LONG
static const char getopt_longopts[] ALIGN1 =
"options\0" Required_argument "o"
"longoptions\0" Required_argument "l"
unsigned opt;
const char *compatible;
char *s_arg;
-#if ENABLE_GETOPT_LONG
+#if ENABLE_FEATURE_GETOPT_LONG
struct option *long_options = NULL;
llist_t *l_arg = NULL;
#endif
return generate_output(argv+1, argc-1, s, long_options);
}
-#if !ENABLE_GETOPT_LONG
+#if !ENABLE_FEATURE_GETOPT_LONG
opt = getopt32(argv, "+o:n:qQs:Tu", &optstr, &name, &s_arg);
#else
applet_long_options = getopt_longopts;
int utc = -1;
int fd;
-#if ENABLE_GETOPT_LONG
+#if ENABLE_LONG_OPTS
static const char rtcwake_longopts[] ALIGN1 =
"auto\0" No_argument "a"
"local\0" No_argument "l"
OPT_t = (1 << 4),
};
-#if ENABLE_GETOPT_LONG
+#if ENABLE_LONG_OPTS
static const char getopt_longopts[] ALIGN1 =
"append\0" No_argument "a"
"command\0" Required_argument "c"