aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--archival/ar.c6
-rw-r--r--archival/bunzip2.c4
-rw-r--r--archival/cpio.c4
-rw-r--r--archival/dpkg_deb.c6
-rw-r--r--archival/gunzip.c4
-rw-r--r--archival/gzip.c6
-rw-r--r--archival/tar.c8
-rw-r--r--archival/uncompress.c2
-rw-r--r--archival/unlzma.c4
-rw-r--r--console-tools/setconsole.c4
-rw-r--r--coreutils/cal.c2
-rw-r--r--coreutils/cat.c2
-rw-r--r--coreutils/catv.c2
-rw-r--r--coreutils/chgrp.c2
-rw-r--r--coreutils/chown.c2
-rw-r--r--coreutils/cmp.c2
-rw-r--r--coreutils/comm.c2
-rw-r--r--coreutils/cp.c2
-rw-r--r--coreutils/cut.c10
-rw-r--r--coreutils/date.c6
-rw-r--r--coreutils/df.c8
-rw-r--r--coreutils/diff.c4
-rw-r--r--coreutils/dos2unix.c4
-rw-r--r--coreutils/du.c10
-rw-r--r--coreutils/env.c8
-rw-r--r--coreutils/fold.c2
-rw-r--r--coreutils/head.c2
-rw-r--r--coreutils/id.c4
-rw-r--r--coreutils/install.c6
-rw-r--r--coreutils/libcoreutils/getopt_mk_fifo_nod.c2
-rw-r--r--coreutils/ln.c2
-rw-r--r--coreutils/ls.c8
-rw-r--r--coreutils/md5_sha1_sum.c2
-rw-r--r--coreutils/mkdir.c6
-rw-r--r--coreutils/mv.c6
-rw-r--r--coreutils/rm.c6
-rw-r--r--coreutils/rmdir.c2
-rw-r--r--coreutils/stat.c2
-rw-r--r--coreutils/sum.c2
-rw-r--r--coreutils/tee.c2
-rw-r--r--coreutils/touch.c2
-rw-r--r--coreutils/tty.c2
-rw-r--r--coreutils/uname.c2
-rw-r--r--coreutils/uudecode.c2
-rw-r--r--coreutils/uuencode.c2
-rw-r--r--coreutils/wc.c2
-rw-r--r--debianutils/mktemp.c2
-rw-r--r--debianutils/readlink.c4
-rw-r--r--debianutils/start_stop_daemon.c8
-rw-r--r--docs/busybox.net/FAQ.html2
-rw-r--r--e2fsprogs/lsattr.c2
-rw-r--r--editors/awk.c4
-rw-r--r--editors/patch.c2
-rw-r--r--editors/sed.c10
-rw-r--r--findutils/grep.c10
-rw-r--r--findutils/xargs.c4
-rw-r--r--include/libbb.h8
-rw-r--r--init/halt.c2
-rw-r--r--libbb/Makefile.in2
-rw-r--r--libbb/getopt32.c (renamed from libbb/getopt_ulflags.c)145
-rw-r--r--loginutils/addgroup.c4
-rw-r--r--loginutils/adduser.c4
-rw-r--r--loginutils/getty.c2
-rw-r--r--loginutils/login.c4
-rw-r--r--loginutils/passwd.c4
-rw-r--r--loginutils/su.c2
-rw-r--r--loginutils/sulogin.c2
-rw-r--r--loginutils/vlock.c2
-rw-r--r--miscutils/adjtimex.c4
-rw-r--r--miscutils/crond.c8
-rw-r--r--miscutils/eject.c4
-rw-r--r--miscutils/hdparm.c44
-rw-r--r--miscutils/less.c2
-rw-r--r--miscutils/makedevs.c2
-rw-r--r--miscutils/mountpoint.c2
-rw-r--r--miscutils/strings.c4
-rw-r--r--miscutils/watchdog.c4
-rw-r--r--modutils/insmod.c2
-rw-r--r--modutils/modprobe.c4
-rw-r--r--modutils/rmmod.c2
-rw-r--r--networking/arping.c6
-rw-r--r--networking/dnsd.c2
-rw-r--r--networking/ether-wake.c2
-rw-r--r--networking/fakeidentd.c2
-rw-r--r--networking/ftpgetput.c6
-rw-r--r--networking/hostname.c4
-rw-r--r--networking/httpd.c4
-rw-r--r--networking/ifupdown.c2
-rw-r--r--networking/inetd.c2
-rw-r--r--networking/ipcalc.c4
-rw-r--r--networking/nameif.c2
-rw-r--r--networking/netstat.c6
-rw-r--r--networking/route.c4
-rw-r--r--networking/telnet.c2
-rw-r--r--networking/telnetd.c4
-rw-r--r--networking/tftp.c6
-rw-r--r--networking/traceroute.c6
-rw-r--r--networking/wget.c8
-rw-r--r--networking/zcip.c6
-rw-r--r--procps/pidof.c4
-rw-r--r--procps/ps.c8
-rw-r--r--procps/top.c4
-rw-r--r--runit/chpst.c4
-rw-r--r--shell/bbsh.c2
-rw-r--r--shell/lash.c4
-rw-r--r--sysklogd/klogd.c4
-rw-r--r--sysklogd/logger.c4
-rw-r--r--sysklogd/syslogd.c2
-rw-r--r--util-linux/dmesg.c2
-rw-r--r--util-linux/fdformat.c2
-rw-r--r--util-linux/getopt.c2
-rw-r--r--util-linux/hwclock.c8
-rw-r--r--util-linux/ipcs.c4
-rw-r--r--util-linux/losetup.c4
-rw-r--r--util-linux/mount.c4
-rw-r--r--util-linux/rdate.c4
-rw-r--r--util-linux/readprofile.c4
-rw-r--r--util-linux/swaponoff.c2
-rw-r--r--util-linux/switch_root.c4
-rw-r--r--util-linux/umount.c4
120 files changed, 322 insertions, 327 deletions
diff --git a/archival/ar.c b/archival/ar.c
index e10bf7c47..06a879b93 100644
--- a/archival/ar.c
+++ b/archival/ar.c
@@ -41,7 +41,7 @@ static void header_verbose_list_ar(const file_header_t *file_header)
int ar_main(int argc, char **argv)
{
archive_handle_t *archive_handle;
- unsigned long opt;
+ unsigned opt;
static const char msg_unsupported_err[] =
"Archive %s not supported. Install binutils 'ar'.";
char magic[8];
@@ -49,8 +49,8 @@ int ar_main(int argc, char **argv)
archive_handle = init_handle();
/* Prepend '-' to the first argument if required */
- bb_opt_complementally = "--:p:t:x:-1:?:p--tx:t--px:x--pt";
- opt = bb_getopt_ulflags(argc, argv, "ptxovcr");
+ opt_complementary = "--:p:t:x:-1:?:p--tx:t--px:x--pt";
+ opt = getopt32(argc, argv, "ptxovcr");
if (opt & AR_CTX_PRINT) {
archive_handle->action_data = data_extract_to_stdout;
diff --git a/archival/bunzip2.c b/archival/bunzip2.c
index 9d62366c3..faf997bbe 100644
--- a/archival/bunzip2.c
+++ b/archival/bunzip2.c
@@ -16,10 +16,10 @@ int bunzip2_main(int argc, char **argv)
{
USE_DESKTOP(long long) int status;
char *filename;
- unsigned long opt;
+ unsigned opt;
int src_fd, dst_fd;
- opt = bb_getopt_ulflags(argc, argv, "cf");
+ opt = getopt32(argc, argv, "cf");
/* Set input filename and number */
filename = argv[optind];
diff --git a/archival/cpio.c b/archival/cpio.c
index 48b688e79..d0d3288ff 100644
--- a/archival/cpio.c
+++ b/archival/cpio.c
@@ -30,7 +30,7 @@ int cpio_main(int argc, char **argv)
{
archive_handle_t *archive_handle;
char *cpio_filename = NULL;
- unsigned long opt;
+ unsigned opt;
/* Initialise */
archive_handle = init_handle();
@@ -38,7 +38,7 @@ int cpio_main(int argc, char **argv)
archive_handle->seek = seek_by_char;
archive_handle->flags = ARCHIVE_EXTRACT_NEWER | ARCHIVE_PRESERVE_DATE;
- opt = bb_getopt_ulflags(argc, argv, "ituvF:dm", &cpio_filename);
+ opt = getopt32(argc, argv, "ituvF:dm", &cpio_filename);
/* One of either extract or test options must be given */
if ((opt & (CPIO_OPT_TEST | CPIO_OPT_EXTRACT)) == 0) {
diff --git a/archival/dpkg_deb.c b/archival/dpkg_deb.c
index ce65e219a..80a5f3250 100644
--- a/archival/dpkg_deb.c
+++ b/archival/dpkg_deb.c
@@ -18,7 +18,7 @@ int dpkg_deb_main(int argc, char **argv)
archive_handle_t *ar_archive;
archive_handle_t *tar_archive;
llist_t *control_tar_llist = NULL;
- unsigned long opt;
+ unsigned opt;
char *extract_dir = NULL;
short argcount = 1;
@@ -40,8 +40,8 @@ int dpkg_deb_main(int argc, char **argv)
llist_add_to(&control_tar_llist, "control.tar.bz2");
#endif
- bb_opt_complementally = "?c--efXx:e--cfXx:f--ceXx:X--cefx:x--cefX";
- opt = bb_getopt_ulflags(argc, argv, "cefXx");
+ opt_complementary = "?c--efXx:e--cfXx:f--ceXx:X--cefx:x--cefX";
+ opt = getopt32(argc, argv, "cefXx");
if (opt & DPKG_DEB_OPT_CONTENTS) {
tar_archive->action_header = header_verbose_list;
diff --git a/archival/gunzip.c b/archival/gunzip.c
index 1b4968628..1cde08b4d 100644
--- a/archival/gunzip.c
+++ b/archival/gunzip.c
@@ -40,9 +40,9 @@ int gunzip_main(int argc, char **argv)
{
USE_DESKTOP(long long) int status;
int exitcode = 0;
- unsigned long opt;
+ unsigned opt;
- opt = bb_getopt_ulflags(argc, argv, "cftdv");
+ opt = getopt32(argc, argv, "cftdv");
/* if called as zcat */
if (strcmp(bb_applet_name, "zcat") == 0) {
opt |= GUNZIP_OPT_STDOUT;
diff --git a/archival/gzip.c b/archival/gzip.c
index 2fc9f7698..ef3724c34 100644
--- a/archival/gzip.c
+++ b/archival/gzip.c
@@ -1134,14 +1134,14 @@ int gzip_main(int argc, char **argv)
OPT_force = 0x2,
};
- unsigned long opt;
+ unsigned opt;
int result;
int inFileNum;
int outFileNum;
struct stat statBuf;
char *delFileName;
- opt = bb_getopt_ulflags(argc, argv, "cf123456789qv" USE_GUNZIP("d"));
+ opt = getopt32(argc, argv, "cf123456789qv" USE_GUNZIP("d"));
//if (opt & 0x1) // -c
//if (opt & 0x2) // -f
/* Ignore 1-9 (compression level) options */
@@ -1157,7 +1157,7 @@ int gzip_main(int argc, char **argv)
//if (opt & 0x800) // -q
//if (opt & 0x1000) // -v
if (ENABLE_GUNZIP && (opt & 0x2000)) { // -d
- /* FIXME: bb_getopt_ulflags should not depend on optind */
+ /* FIXME: getopt32 should not depend on optind */
optind = 1;
return gunzip_main(argc, argv);
}
diff --git a/archival/tar.c b/archival/tar.c
index bfee638b4..3775598cc 100644
--- a/archival/tar.c
+++ b/archival/tar.c
@@ -688,7 +688,7 @@ int tar_main(int argc, char **argv)
archive_handle_t *tar_handle;
char *base_dir = NULL;
const char *tar_filename = "-";
- unsigned long opt;
+ unsigned opt;
llist_t *excludes = NULL;
/* Initialise default values */
@@ -696,12 +696,12 @@ int tar_main(int argc, char **argv)
tar_handle->flags = ARCHIVE_CREATE_LEADING_DIRS | ARCHIVE_PRESERVE_DATE | ARCHIVE_EXTRACT_UNCONDITIONAL;
/* Prepend '-' to the first argument if required */
- bb_opt_complementally = ENABLE_FEATURE_TAR_CREATE ?
+ opt_complementary = ENABLE_FEATURE_TAR_CREATE ?
"--:X::T::\n::c:t:x:?:c--tx:t--cx:x--ct" :
"--:X::T::\n::t:x:?:t--x:x--t";
if (ENABLE_FEATURE_TAR_LONG_OPTIONS)
- bb_applet_long_options = tar_long_options;
- opt = bb_getopt_ulflags(argc, argv, tar_options,
+ applet_long_options = tar_long_options;
+ opt = getopt32(argc, argv, tar_options,
&base_dir, /* Change to dir <optarg> */
&tar_filename /* archive filename */
#ifdef CONFIG_FEATURE_TAR_FROM
diff --git a/archival/uncompress.c b/archival/uncompress.c
index 91568e45f..d1b0d2cb3 100644
--- a/archival/uncompress.c
+++ b/archival/uncompress.c
@@ -16,7 +16,7 @@ int uncompress_main(int argc, char **argv)
int status = EXIT_SUCCESS;
unsigned long flags;
- flags = bb_getopt_ulflags(argc, argv, "cf");
+ flags = getopt32(argc, argv, "cf");
while (optind < argc) {
char *compressed_file = argv[optind++];
diff --git a/archival/unlzma.c b/archival/unlzma.c
index b87a3fe79..20891e316 100644
--- a/archival/unlzma.c
+++ b/archival/unlzma.c
@@ -19,10 +19,10 @@ int unlzma_main(int argc, char **argv)
{
USE_DESKTOP(long long) int status;
char *filename;
- unsigned long opt;
+ unsigned opt;
int src_fd, dst_fd;
- opt = bb_getopt_ulflags(argc, argv, "c");
+ opt = getopt32(argc, argv, "c");
/* Set input filename and number */
filename = argv[optind];
diff --git a/console-tools/setconsole.c b/console-tools/setconsole.c
index 71fe928da..ef81f298b 100644
--- a/console-tools/setconsole.c
+++ b/console-tools/setconsole.c
@@ -24,9 +24,9 @@ int setconsole_main(int argc, char **argv)
const char *device = CURRENT_TTY;
#if ENABLE_FEATURE_SETCONSOLE_LONG_OPTIONS
- bb_applet_long_options = setconsole_long_options;
+ applet_long_options = setconsole_long_options;
#endif
- flags = bb_getopt_ulflags(argc, argv, "r");
+ flags = getopt32(argc, argv, "r");
if (argc - optind > 1)
bb_show_usage();
diff --git a/coreutils/cal.c b/coreutils/cal.c
index 8996aa8c7..ef914128c 100644
--- a/coreutils/cal.c
+++ b/coreutils/cal.c
@@ -91,7 +91,7 @@ int cal_main(int argc, char **argv)
setlocale(LC_TIME, "");
#endif
- flags = bb_getopt_ulflags(argc, argv, "jy");
+ flags = getopt32(argc, argv, "jy");
julian = flags & 1;
diff --git a/coreutils/cat.c b/coreutils/cat.c
index 37237ec1d..f3baf0a2d 100644
--- a/coreutils/cat.c
+++ b/coreutils/cat.c
@@ -18,7 +18,7 @@ int cat_main(int argc, char **argv)
FILE *f;
int retval = EXIT_SUCCESS;
- bb_getopt_ulflags(argc, argv, "u");
+ getopt32(argc, argv, "u");
argv += optind;
if (!*argv) {
diff --git a/coreutils/catv.c b/coreutils/catv.c
index f8229c20e..55656b4b2 100644
--- a/coreutils/catv.c
+++ b/coreutils/catv.c
@@ -17,7 +17,7 @@ int catv_main(int argc, char **argv)
int retval = EXIT_SUCCESS, fd;
unsigned long flags;
- flags = bb_getopt_ulflags(argc, argv, "etv");
+ flags = getopt32(argc, argv, "etv");
#define CATV_OPT_e (1<<0)
#define CATV_OPT_t (1<<1)
#define CATV_OPT_v (1<<2)
diff --git a/coreutils/chgrp.c b/coreutils/chgrp.c
index 5064f2d6e..e62bd16f0 100644
--- a/coreutils/chgrp.c
+++ b/coreutils/chgrp.c
@@ -31,7 +31,7 @@ int chgrp_main(int argc, char **argv)
int recursiveFlag;
int retval = EXIT_SUCCESS;
- recursiveFlag = bb_getopt_ulflags(argc, argv, "R");
+ recursiveFlag = getopt32(argc, argv, "R");
if (argc - optind < 2) {
bb_show_usage();
diff --git a/coreutils/chown.c b/coreutils/chown.c
index bb379ac20..b73f66a89 100644
--- a/coreutils/chown.c
+++ b/coreutils/chown.c
@@ -43,7 +43,7 @@ int chown_main(int argc, char **argv)
int retval = EXIT_SUCCESS;
char *groupName;
- flags = bb_getopt_ulflags(argc, argv, "Rh");
+ flags = getopt32(argc, argv, "Rh");
if (flags & FLAG_h) chown_func = lchown;
diff --git a/coreutils/cmp.c b/coreutils/cmp.c
index d0d976997..07858c64e 100644
--- a/coreutils/cmp.c
+++ b/coreutils/cmp.c
@@ -54,7 +54,7 @@ int cmp_main(int argc, char **argv)
xfunc_error_retval = 2; /* 1 is returned if files are different. */
- opt = bb_getopt_ulflags(argc, argv, opt_chars);
+ opt = getopt32(argc, argv, opt_chars);
if (((opt & (CMP_OPT_s|CMP_OPT_l)) == (CMP_OPT_s|CMP_OPT_l))
|| (((unsigned int)(--argc - optind)) > 1))
diff --git a/coreutils/comm.c b/coreutils/comm.c
index 7524a7b25..91f017753 100644
--- a/coreutils/comm.c
+++ b/coreutils/comm.c
@@ -112,7 +112,7 @@ int comm_main(int argc, char **argv)
{
unsigned long flags;
- flags = bb_getopt_ulflags(argc, argv, "123");
+ flags = getopt32(argc, argv, "123");
if (optind + 2 != argc)
bb_show_usage();
diff --git a/coreutils/cp.c b/coreutils/cp.c
index 85086aab5..fabfe58e0 100644
--- a/coreutils/cp.c
+++ b/coreutils/cp.c
@@ -39,7 +39,7 @@ int cp_main(int argc, char **argv)
int flags;
int status = 0;
- flags = bb_getopt_ulflags(argc, argv, "pdRfiarPHL");
+ flags = getopt32(argc, argv, "pdRfiarPHL");
if (flags & 32) {
flags |= (FILEUTILS_PRESERVE_STATUS | FILEUTILS_RECUR | FILEUTILS_DEREFERENCE);
diff --git a/coreutils/cut.c b/coreutils/cut.c
index d88a891b0..30dbc02db 100644
--- a/coreutils/cut.c
+++ b/coreutils/cut.c
@@ -12,14 +12,13 @@
#include "busybox.h"
/* option vars */
-static const char *const optstring = "b:c:f:d:sn";
-
+static const char optstring[] = "b:c:f:d:sn";
#define CUT_OPT_BYTE_FLGS (1<<0)
#define CUT_OPT_CHAR_FLGS (1<<1)
#define CUT_OPT_FIELDS_FLGS (1<<2)
#define CUT_OPT_DELIM_FLGS (1<<3)
#define CUT_OPT_SUPPRESS_FLGS (1<<4)
-static unsigned long opt;
+static unsigned opt;
static char delim = '\t'; /* delimiter, default is tab */
@@ -179,9 +178,8 @@ int cut_main(int argc, char **argv)
{
char *sopt, *ltok;
- bb_opt_complementally = "b--bcf:c--bcf:f--bcf";
- opt =
- bb_getopt_ulflags(argc, argv, optstring, &sopt, &sopt, &sopt, &ltok);
+ opt_complementary = "b--bcf:c--bcf:f--bcf";
+ opt = getopt32(argc, argv, optstring, &sopt, &sopt, &sopt, &ltok);
if (!(opt & (CUT_OPT_BYTE_FLGS | CUT_OPT_CHAR_FLGS | CUT_OPT_FIELDS_FLGS)))
bb_error_msg_and_die
("expected a list of bytes, characters, or fields");
diff --git a/coreutils/date.c b/coreutils/date.c
index 2a82e0413..74e99665d 100644
--- a/coreutils/date.c
+++ b/coreutils/date.c
@@ -42,7 +42,7 @@ int date_main(int argc, char **argv)
{
time_t tm;
struct tm tm_time;
- unsigned long opt;
+ unsigned opt;
int ifmt = -1;
char *date_str = NULL;
char *date_fmt = NULL;
@@ -50,9 +50,9 @@ int date_main(int argc, char **argv)
char *isofmt_arg;
char *hintfmt_arg;
- bb_opt_complementally = "?:d--s:s--d"
+ opt_complementary = "?:d--s:s--d"
USE_FEATURE_DATE_ISOFMT(":R--I:I--R");
- opt = bb_getopt_ulflags(argc, argv, "Rs:ud:r:"
+ opt = getopt32(argc, argv, "Rs:ud:r:"
USE_FEATURE_DATE_ISOFMT("I::D:"),
&date_str, &date_str, &filename
USE_FEATURE_DATE_ISOFMT(, &isofmt_arg, &hintfmt_arg));
diff --git a/coreutils/df.c b/coreutils/df.c
index 17ce634a7..94ead32eb 100644
--- a/coreutils/df.c
+++ b/coreutils/df.c
@@ -41,7 +41,7 @@ int df_main(int argc, char **argv)
unsigned long df_disp_hr = KILOBYTE;
#endif
int status = EXIT_SUCCESS;
- unsigned long opt;
+ unsigned opt;
FILE *mount_table;
struct mntent *mount_entry;
struct statfs s;
@@ -49,8 +49,8 @@ int df_main(int argc, char **argv)
const char *disp_units_hdr = hdr_1k;
#ifdef CONFIG_FEATURE_HUMAN_READABLE
- bb_opt_complementally = "h-km:k-hm:m-hk";
- opt = bb_getopt_ulflags(argc, argv, "hmk");
+ opt_complementary = "h-km:k-hm:m-hk";
+ opt = getopt32(argc, argv, "hmk");
if(opt & 1) {
df_disp_hr = 0;
disp_units_hdr = " Size";
@@ -60,7 +60,7 @@ int df_main(int argc, char **argv)
disp_units_hdr = "1M-blocks";
}
#else
- opt = bb_getopt_ulflags(argc, argv, "k");
+ opt = getopt32(argc, argv, "k");
#endif
bb_printf("Filesystem%11s%-15sUsed Available Use%% Mounted on\n",
diff --git a/coreutils/diff.c b/coreutils/diff.c
index 3c409b2cf..2edcd96ca 100644
--- a/coreutils/diff.c
+++ b/coreutils/diff.c
@@ -1164,9 +1164,9 @@ int diff_main(int argc, char **argv)
char *U_opt;
llist_t *L_arg = NULL;
- bb_opt_complementally = "L::";
+ opt_complementary = "L::";
cmd_flags =
- bb_getopt_ulflags(argc, argv, "abdiL:NqrsS:tTU:wu", &L_arg, &start,
+ getopt32(argc, argv, "abdiL:NqrsS:tTU:wu", &L_arg, &start,
&U_opt);
if (cmd_flags & FLAG_L) {
diff --git a/coreutils/dos2unix.c b/coreutils/dos2unix.c
index 19f1a3257..a8038a6dd 100644
--- a/coreutils/dos2unix.c
+++ b/coreutils/dos2unix.c
@@ -93,11 +93,11 @@ int dos2unix_main(int argc, char *argv[])
ConvType = CT_UNIX2DOS; /*1 */
}
/* -u and -d are mutally exclusive */
- bb_opt_complementally = "?:u--d:d--u";
+ opt_complementary = "?:u--d:d--u";
/* process parameters */
/* -u convert to unix */
/* -d convert to dos */
- o = bb_getopt_ulflags(argc, argv, "du");
+ o = getopt32(argc, argv, "du");
/* Do the conversion requested by an argument else do the default
* conversion depending on our name. */
diff --git a/coreutils/du.c b/coreutils/du.c
index 3cc935553..1452e5883 100644
--- a/coreutils/du.c
+++ b/coreutils/du.c
@@ -153,7 +153,7 @@ int du_main(int argc, char **argv)
int slink_depth_save;
int print_final_total;
char *smax_print_depth;
- unsigned long opt;
+ unsigned opt;
#ifdef CONFIG_FEATURE_DU_DEFUALT_BLOCKSIZE_1K
if (getenv("POSIXLY_CORRECT")) { /* TODO - a new libbb function? */
@@ -172,8 +172,8 @@ int du_main(int argc, char **argv)
* ignore -a. This is consistent with -s being equivalent to -d 0.
*/
#ifdef CONFIG_FEATURE_HUMAN_READABLE
- bb_opt_complementally = "h-km:k-hm:m-hk:H-L:L-H:s-d:d-s";
- opt = bb_getopt_ulflags(argc, argv, "aHkLsx" "d:" "lc" "hm", &smax_print_depth);
+ opt_complementary = "h-km:k-hm:m-hk:H-L:L-H:s-d:d-s";
+ opt = getopt32(argc, argv, "aHkLsx" "d:" "lc" "hm", &smax_print_depth);
if((opt & (1 << 9))) {
/* -h opt */
disp_hr = 0;
@@ -187,8 +187,8 @@ int du_main(int argc, char **argv)
disp_hr = KILOBYTE;
}
#else
- bb_opt_complementally = "H-L:L-H:s-d:d-s";
- opt = bb_getopt_ulflags(argc, argv, "aHkLsx" "d:" "lc", &smax_print_depth);
+ opt_complementary = "H-L:L-H:s-d:d-s";
+ opt = getopt32(argc, argv, "aHkLsx" "d:" "lc", &smax_print_depth);
#if !defined CONFIG_FEATURE_DU_DEFAULT_BLOCKSIZE_1K
if((opt & (1 << 2))) {
/* -k opt */
diff --git a/coreutils/env.c b/coreutils/env.c
index 2af15a37e..d03318fea 100644
--- a/coreutils/env.c
+++ b/coreutils/env.c
@@ -46,16 +46,16 @@ int env_main(int argc, char** argv)
static char *cleanenv[1] = { NULL };
char **ep;
- unsigned long opt;
+ unsigned opt;
llist_t *unset_env = NULL;
extern char **environ;
- bb_opt_complementally = "u::";
+ opt_complementary = "u::";
#if ENABLE_FEATURE_ENV_LONG_OPTIONS
- bb_applet_long_options = env_long_options;
+ applet_long_options = env_long_options;
#endif
- opt = bb_getopt_ulflags(argc, argv, "+iu:", &unset_env);
+ opt = getopt32(argc, argv, "+iu:", &unset_env);
argv += optind;
if (*argv && (argv[0][0] == '-') && !argv[0][1]) {
diff --git a/coreutils/fold.c b/coreutils/fold.c
index aff7bb1d9..3b5be64fe 100644
--- a/coreutils/fold.c
+++ b/coreutils/fold.c
@@ -60,7 +60,7 @@ int fold_main(int argc, char **argv)
}
}
- flags = bb_getopt_ulflags(argc, argv, "bsw:", &w_opt);
+ flags = getopt32(argc, argv, "bsw:", &w_opt);
if (flags & FLAG_WIDTH)
width = bb_xgetlarg(w_opt, 10, 1, 10000);
diff --git a/coreutils/head.c b/coreutils/head.c
index 50694bfef..7d5f219d2 100644
--- a/coreutils/head.c
+++ b/coreutils/head.c
@@ -60,7 +60,7 @@ int head_main(int argc, char **argv)
}
#endif
- /* No size benefit in converting this to bb_getopt_ulflags */
+ /* No size benefit in converting this to getopt32 */
while ((opt = getopt(argc, argv, head_opts)) > 0) {
switch (opt) {
#if ENABLE_FEATURE_FANCY_HEAD
diff --git a/coreutils/id.c b/coreutils/id.c
index 1bedff37a..dd825ab3c 100644
--- a/coreutils/id.c
+++ b/coreutils/id.c
@@ -50,8 +50,8 @@ int id_main(int argc, char **argv)
/* Don't allow -n -r -nr -ug -rug -nug -rnug */
/* Don't allow more than one username */
- bb_opt_complementally = "?1:?:u--g:g--u:r?ug:n?ug";
- flags = bb_getopt_ulflags(argc, argv, "rnug");
+ opt_complementary = "?1:?:u--g:g--u:r?ug:n?ug";
+ flags = getopt32(argc, argv, "rnug");
/* This values could be overwritten later */
uid = geteuid();
diff --git a/coreutils/install.c b/coreutils/install.c
index d3d6a58a1..2178d435d 100644
--- a/coreutils/install.c
+++ b/coreutils/install.c
@@ -45,11 +45,11 @@ int install_main(int argc, char **argv)
int ret = EXIT_SUCCESS, flags, i, isdir;
#if ENABLE_FEATURE_INSTALL_LONG_OPTIONS
- bb_applet_long_options = install_long_options;
+ applet_long_options = install_long_options;
#endif
- bb_opt_complementally = "?:s--d:d--s";
+ opt_complementary = "?:s--d:d--s";
/* -c exists for backwards compatibility, its needed */
- flags = bb_getopt_ulflags(argc, argv, "cdpsg:m:o:", &gid_str, &mode_str, &uid_str); /* 'a' must be 2nd */
+ flags = getopt32(argc, argv, "cdpsg:m:o:", &gid_str, &mode_str, &uid_str); /* 'a' must be 2nd */
/* preserve access and modification time, this is GNU behaviour, BSD only preserves modification time */
if (flags & INSTALL_OPT_PRESERVE_TIME) {
diff --git a/coreutils/libcoreutils/getopt_mk_fifo_nod.c b/coreutils/libcoreutils/getopt_mk_fifo_nod.c
index d1f5b1e89..3a3d34118 100644
--- a/coreutils/libcoreutils/getopt_mk_fifo_nod.c
+++ b/coreutils/libcoreutils/getopt_mk_fifo_nod.c
@@ -31,7 +31,7 @@ mode_t getopt_mk_fifo_nod(int argc, char **argv)
mode_t mode = 0666;
char *smode = NULL;
- bb_getopt_ulflags(argc, argv, "m:", &smode);
+ getopt32(argc, argv, "m:", &smode);
if(smode) {
if (bb_parse_mode(smode, &mode))
umask(0);
diff --git a/coreutils/ln.c b/coreutils/ln.c
index df183581e..cd6e470be 100644
--- a/coreutils/ln.c
+++ b/coreutils/ln.c
@@ -30,7 +30,7 @@ int ln_main(int argc, char **argv)
struct stat statbuf;
int (*link_func)(const char *, const char *);
- flag = bb_getopt_ulflags(argc, argv, "sfnbS:", &suffix);
+ flag = getopt32(argc, argv, "sfnbS:", &suffix);
if (argc == optind) {
bb_show_usage();
diff --git a/coreutils/ls.c b/coreutils/ls.c
index 0099f18fe..8ba4ab758 100644
--- a/coreutils/ls.c
+++ b/coreutils/ls.c
@@ -877,7 +877,7 @@ int ls_main(int argc, char **argv)
struct dnode **dnp;
struct dnode *dn;
struct dnode *cur;
- long opt;
+ unsigned opt;
int nfiles = 0;
int dnfiles;
int dndirs;
@@ -904,12 +904,12 @@ int ls_main(int argc, char **argv)
#endif
#ifdef CONFIG_FEATURE_LS_COLOR
- bb_applet_long_options = ls_color_opt;
+ applet_long_options = ls_color_opt;
#endif
/* process options */
#ifdef CONFIG_FEATURE_AUTOWIDTH
- opt = bb_getopt_ulflags(argc, argv, ls_options, &tabstops_str, &terminal_width_str
+ opt = getopt32(argc, argv, ls_options, &tabstops_str, &terminal_width_str
#ifdef CONFIG_FEATURE_LS_COLOR
, &color_opt
#endif
@@ -921,7 +921,7 @@ int ls_main(int argc, char **argv)
terminal_width = atoi(terminal_width_str);
}
#else
- opt = bb_getopt_ulflags(argc, argv, ls_options
+ opt = getopt32(argc, argv, ls_options
#ifdef CONFIG_FEATURE_LS_COLOR
, &color_opt
#endif
diff --git a/coreutils/md5_sha1_sum.c b/coreutils/md5_sha1_sum.c
index c10fac5d0..a99e45864 100644
--- a/coreutils/md5_sha1_sum.c
+++ b/coreutils/md5_sha1_sum.c
@@ -91,7 +91,7 @@ int md5_sha1_sum_main(int argc, char **argv)
: HASH_SHA1;
if (ENABLE_FEATURE_MD5_SHA1_SUM_CHECK)
- flags = bb_getopt_ulflags(argc, argv, "scw");
+ flags = getopt32(argc, argv, "scw");
else optind = 1;
if (ENABLE_FEATURE_MD5_SHA1_SUM_CHECK && !(flags & FLAG_CHECK)) {
diff --git a/coreutils/mkdir.c b/coreutils/mkdir.c
index c09c72f7d..3fe55c395 100644
--- a/coreutils/mkdir.c
+++ b/coreutils/mkdir.c
@@ -34,13 +34,13 @@ int mkdir_main (int argc, char **argv)
mode_t mode = (mode_t)(-1);
int status = EXIT_SUCCESS;
int flags = 0;
- unsigned long opt;
+ unsigned opt;
char *smode;
#if ENABLE_FEATURE_MKDIR_LONG_OPTIONS
- bb_applet_long_options = mkdir_long_options;
+ applet_long_options = mkdir_long_options;
#endif
- opt = bb_getopt_ulflags(argc, argv, "m:p", &smode);
+ opt = getopt32(argc, argv, "m:p", &smode);
if(opt & 1) {
mode = 0777;
if (!bb_parse_mode (smode, &mode)) {
diff --git a/coreutils/mv.c b/coreutils/mv.c
index 274aecb45..770b42417 100644
--- a/coreutils/mv.c
+++ b/coreutils/mv.c
@@ -45,10 +45,10 @@ int mv_main(int argc, char **argv)
int status = 0;
#if ENABLE_FEATURE_MV_LONG_OPTIONS
- bb_applet_long_options = mv_long_options;
+ applet_long_options = mv_long_options;
#endif
- bb_opt_complementally = "f-i:i-f";
- flags = bb_getopt_ulflags(argc, argv, "fi");
+ opt_complementary = "f-i:i-f";
+ flags = getopt32(argc, argv, "fi");
if (optind + 2 > argc) {
bb_show_usage();
}
diff --git a/coreutils/rm.c b/coreutils/rm.c
index c787ae342..490694a6e 100644
--- a/coreutils/rm.c
+++ b/coreutils/rm.c
@@ -22,10 +22,10 @@ int rm_main(int argc, char **argv)
{
int status = 0;
int flags = 0;
- unsigned long opt;
+ unsigned opt;
- bb_opt_complementally = "f-i:i-f";
- opt = bb_getopt_ulflags(argc, argv, "fiRr");
+ opt_complementary = "f-i:i-f";
+ opt = getopt32(argc, argv, "fiRr");
if(opt & 1)
flags |= FILEUTILS_FORCE;
if(opt & 2)
diff --git a/coreutils/rmdir.c b/coreutils/rmdir.c
index e1ed34c6e..05ea0e9ff 100644
--- a/coreutils/rmdir.c
+++ b/coreutils/rmdir.c
@@ -22,7 +22,7 @@ int rmdir_main(int argc, char **argv)
int do_dot;
char *path;
- flags = bb_getopt_ulflags(argc, argv, "p");
+ flags = getopt32(argc, argv, "p");
argv += optind;
diff --git a/coreutils/stat.c b/coreutils/stat.c
index 8e0121849..b9fd42f4a 100644
--- a/coreutils/stat.c
+++ b/coreutils/stat.c
@@ -516,7 +516,7 @@ int stat_main(int argc, char **argv)
int ok = 1;
int (*statfunc)(char const *, char const *) = do_stat;
- flags = bb_getopt_ulflags(argc, argv, "ftL"
+ flags = getopt32(argc, argv, "ftL"
USE_FEATURE_STAT_FORMAT("c:", &format)
);
diff --git a/coreutils/sum.c b/coreutils/sum.c
index 99d477fc3..61ca582a1 100644
--- a/coreutils/sum.c
+++ b/coreutils/sum.c
@@ -136,7 +136,7 @@ int sum_main(int argc, char **argv)
int (*sum_func)(const char *, int) = bsd_sum_file;
/* give the bsd func priority over sysv func */
- flags = bb_getopt_ulflags(argc, argv, "sr");
+ flags = getopt32(argc, argv, "sr");
if (flags & 1)
sum_func = sysv_sum_file;
if (flags & 2)
diff --git a/coreutils/tee.c b/coreutils/tee.c
index 1f59f0361..a194153e0 100644
--- a/coreutils/tee.c
+++ b/coreutils/tee.c
@@ -28,7 +28,7 @@ int tee_main(int argc, char **argv)
int c;
#endif
- flags = bb_getopt_ulflags(argc, argv, "ia"); /* 'a' must be 2nd */
+ flags = getopt32(argc, argv, "ia"); /* 'a' must be 2nd */
mode += (flags & 2); /* Since 'a' is the 2nd option... */
diff --git a/coreutils/touch.c b/coreutils/touch.c
index 76c05d8c8..e1af7d0dc 100644
--- a/coreutils/touch.c
+++ b/coreutils/touch.c
@@ -32,7 +32,7 @@ int touch_main(int argc, char **argv)
int flags;
int status = EXIT_SUCCESS;
- flags = bb_getopt_ulflags(argc, argv, "c");
+ flags = getopt32(argc, argv, "c");
argv += optind;
diff --git a/coreutils/tty.c b/coreutils/tty.c
index eb8c3dd0f..579e6f73c 100644
--- a/coreutils/tty.c
+++ b/coreutils/tty.c
@@ -23,7 +23,7 @@ int tty_main(int argc, char **argv)
xfunc_error_retval = 2; /* SUSv3 requires > 1 for error. */
- silent = bb_getopt_ulflags(argc, argv, "s");
+ silent = getopt32(argc, argv, "s");
/* gnu tty outputs a warning that it is ignoring all args. */
bb_warn_ignoring_args(argc - optind);
diff --git a/coreutils/uname.c b/coreutils/uname.c
index da12c3aee..575fb525c 100644
--- a/coreutils/uname.c
+++ b/coreutils/uname.c
@@ -63,7 +63,7 @@ int uname_main(int argc, char **argv)
const unsigned short int *delta;
char toprint;
- toprint = bb_getopt_ulflags(argc, argv, options);
+ toprint = getopt32(argc, argv, options);
if (argc != optind) {
bb_show_usage();
diff --git a/coreutils/uudecode.c b/coreutils/uudecode.c
index 21ebce3ac..921d29af0 100644
--- a/coreutils/uudecode.c
+++ b/coreutils/uudecode.c
@@ -129,7 +129,7 @@ int uudecode_main(int argc, char **argv)
char *outname = NULL;
char *line;
- bb_getopt_ulflags(argc, argv, "o:", &outname);
+ getopt32(argc, argv, "o:", &outname);
if (optind == argc) {
src_stream = stdin;
diff --git a/coreutils/uuencode.c b/coreutils/uuencode.c
index 1a8882fc7..58538365e 100644
--- a/coreutils/uuencode.c
+++ b/coreutils/uuencode.c
@@ -27,7 +27,7 @@ int uuencode_main(int argc, char **argv)
RESERVE_CONFIG_BUFFER(dst_buf, DST_BUF_SIZE + 1);
tbl = bb_uuenc_tbl_std;
- if (bb_getopt_ulflags(argc, argv, "m") & 1) {
+ if (getopt32(argc, argv, "m") & 1) {
tbl = bb_uuenc_tbl_base64;
}
diff --git a/coreutils/wc.c b/coreutils/wc.c
index 6ddac4dec..359d9fd6d 100644
--- a/coreutils/wc.c
+++ b/coreutils/wc.c
@@ -87,7 +87,7 @@ int wc_main(int argc, char **argv)
char in_word;
unsigned print_type;
- print_type = bb_getopt_ulflags(argc, argv, "lwcL");
+ print_type = getopt32(argc, argv, "lwcL");
if (print_type == 0) {
print_type = (1 << WC_LINES) | (1 << WC_WORDS) | (1 << WC_CHARS);
diff --git a/debianutils/mktemp.c b/debianutils/mktemp.c
index 495a2ea3a..546e030b0 100644
--- a/debianutils/mktemp.c
+++ b/debianutils/mktemp.c
@@ -18,7 +18,7 @@
int mktemp_main(int argc, char **argv)
{
- unsigned long flags = bb_getopt_ulflags(argc, argv, "dq");
+ unsigned long flags = getopt32(argc, argv, "dq");
if (optind + 1 != argc)
bb_show_usage();
diff --git a/debianutils/readlink.c b/debianutils/readlink.c
index bfe0db6c3..0d5ad94f4 100644
--- a/debianutils/readlink.c
+++ b/debianutils/readlink.c
@@ -18,8 +18,8 @@
int readlink_main(int argc, char **argv)
{
char *buf;
- unsigned long opt = ENABLE_FEATURE_READLINK_FOLLOW ?
- bb_getopt_ulflags(argc, argv, "f") : 0;
+ unsigned opt = ENABLE_FEATURE_READLINK_FOLLOW ?
+ getopt32(argc, argv, "f") : 0;
if (argc != (ENABLE_FEATURE_READLINK_FOLLOW ? optind + 1 : 2))
bb_show_usage();
diff --git a/debianutils/start_stop_daemon.c b/debianutils/start_stop_daemon.c
index dcff1dd86..57f42d8ef 100644
--- a/debianutils/start_stop_daemon.c
+++ b/debianutils/start_stop_daemon.c
@@ -227,7 +227,7 @@ static const struct option ssd_long_options[] = {
int start_stop_daemon_main(int argc, char **argv)
{
- unsigned long opt;
+ unsigned opt;
char *signame = NULL;
char *startas = NULL;
#if ENABLE_FEATURE_START_STOP_DAEMON_FANCY
@@ -235,12 +235,12 @@ int start_stop_daemon_main(int argc, char **argv)
// int retries = -1;
#endif
#if ENABLE_FEATURE_START_STOP_DAEMON_LONG_OPTIONS
- bb_applet_long_options = ssd_long_options;
+ applet_long_options = ssd_long_options;
#endif
/* Check required one context option was given */
- bb_opt_complementally = "K:S:?:K--S:S--K:m?p:K?xpun:S?xa";
- opt = bb_getopt_ulflags(argc, argv, "KSbqm"
+ opt_complementary = "K:S:?:K--S:S--K:m?p:K?xpun:S?xa";
+ opt = getopt32(argc, argv, "KSbqm"
// USE_FEATURE_START_STOP_DAEMON_FANCY("ovR:")
USE_FEATURE_START_STOP_DAEMON_FANCY("ov")
"a:n:s:u:c:x:p:"
diff --git a/docs/busybox.net/FAQ.html b/docs/busybox.net/FAQ.html
index fee207486..af20366b6 100644
--- a/docs/busybox.net/FAQ.html
+++ b/docs/busybox.net/FAQ.html
@@ -567,7 +567,7 @@ for failure and abort the program with an error message so the caller doesn't
have to test the return value (xmalloc(), xstrdup(), etc), wrapped versions
of open(), close(), read(), and write() that test for their own failures
and/or retry automatically, linked list management functions (llist.c),
-command line argument parsing (getopt_ulflags.c), and a whole lot more.</p>
+command line argument parsing (getopt32.c), and a whole lot more.</p>
<hr />
<p>
diff --git a/e2fsprogs/lsattr.c b/e2fsprogs/lsattr.c
index 5c20d25f3..e76f8d9d7 100644
--- a/e2fsprogs/lsattr.c
+++ b/e2fsprogs/lsattr.c
@@ -124,7 +124,7 @@ int lsattr_main(int argc, char **argv)
{
int i;
- flags = bb_getopt_ulflags(argc, argv, "Radlv");
+ flags = getopt32(argc, argv, "Radlv");
if (optind > argc - 1)
lsattr_args(".");
diff --git a/editors/awk.c b/editors/awk.c
index b46f25c0a..c1b56d9e5 100644
--- a/editors/awk.c
+++ b/editors/awk.c
@@ -2634,7 +2634,7 @@ static rstream *next_input_file(void)
int awk_main(int argc, char **argv)
{
- unsigned long opt;
+ unsigned opt;
char *opt_F, *opt_v, *opt_W;
char *s, *s1;
int i, j, c, flen;
@@ -2691,7 +2691,7 @@ keep_going:
free(s);
}
- opt = bb_getopt_ulflags(argc, argv, "F:v:f:W:", &opt_F, &opt_v, &programname, &opt_W);
+ opt = getopt32(argc, argv, "F:v:f:W:", &opt_F, &opt_v, &programname, &opt_W);
if (opt & 0x1) setvar_s(V[FS], opt_F); // -F
if (opt & 0x2) if (!is_assignment(opt_v)) bb_show_usage(); // -v
if (opt & 0x4) { // -f
diff --git a/editors/patch.c b/editors/patch.c
index a710d8224..c18659eda 100644
--- a/editors/patch.c
+++ b/editors/patch.c
@@ -85,7 +85,7 @@ int patch_main(int argc, char **argv)
{
char *p, *i;
- ret = bb_getopt_ulflags(argc, argv, "p:i:", &p, &i);
+ ret = getopt32(argc, argv, "p:i:", &p, &i);
if (ret & 1)
patch_level = bb_xgetlarg(p, 10, -1, USHRT_MAX);
if (ret & 2) {
diff --git a/editors/sed.c b/editors/sed.c
index 201665209..7dba8b456 100644
--- a/editors/sed.c
+++ b/editors/sed.c
@@ -1109,7 +1109,7 @@ static void add_files_link(llist_t *opt_f)
int sed_main(int argc, char **argv)
{
- unsigned long opt;
+ unsigned opt;
llist_t *opt_e, *opt_f;
int status = EXIT_SUCCESS;
@@ -1126,8 +1126,8 @@ int sed_main(int argc, char **argv)
/* do normal option parsing */
opt_e = opt_f = NULL;
- bb_opt_complementally = "e::f::"; /* can occur multiple times */
- opt = bb_getopt_ulflags(argc, argv, "irne:f:", &opt_e, &opt_f);
+ opt_complementary = "e::f::"; /* can occur multiple times */
+ opt = getopt32(argc, argv, "irne:f:", &opt_e, &opt_f);
if (opt & 0x1) { // -i
bbg.in_place++;
atexit(cleanup_outname);
@@ -1135,11 +1135,11 @@ int sed_main(int argc, char **argv)
if (opt & 0x2) bbg.regex_type|=REG_EXTENDED; // -r
if (opt & 0x4) bbg.be_quiet++; // -n
if (opt & 0x8) { // -e
- /* getopt_ulflags reverses order of arguments, handle it */
+ /* getopt32 reverses order of arguments, handle it */
add_cmds_link(opt_e);
}
if (opt & 0x10) { // -f
- /* getopt_ulflags reverses order of arguments, handle it */
+ /* getopt32 reverses order of arguments, handle it */
add_files_link(opt_f);
}
/* if we didn't get a pattern from -e or -f, use argv[optind] */
diff --git a/findutils/grep.c b/findutils/grep.c
index 5659a7d2b..35e6aff2d 100644
--- a/findutils/grep.c
+++ b/findutils/grep.c
@@ -24,7 +24,7 @@
/* options */
-static unsigned long opt;
+static unsigned opt;
#define GREP_OPTS "lnqvscFiHhe:f:Lo"
#define GREP_OPT_l (1<<0)
#define PRINT_FILES_WITH_MATCHES (opt & GREP_OPT_l)
@@ -302,8 +302,8 @@ int grep_main(int argc, char **argv)
char *slines_before;
char *Copt;
- bb_opt_complementally = "H-h:e::f::C-AB";
- opt = bb_getopt_ulflags(argc, argv,
+ opt_complementary = "H-h:e::f::C-AB";
+ opt = getopt32(argc, argv,
GREP_OPTS GREP_OPT_CONTEXT OPT_EGREP,
&pattern_head, &fopt,
&slines_after, &slines_before, &Copt);
@@ -336,8 +336,8 @@ int grep_main(int argc, char **argv)
before_buf = (char **)xzalloc(lines_before * sizeof(char *));
#else
/* with auto sanity checks */
- bb_opt_complementally = "H-h:e::f::c-n:q-n:l-n";
- opt = bb_getopt_ulflags(argc, argv, GREP_OPTS OPT_EGREP,
+ opt_complementary = "H-h:e::f::c-n:q-n:l-n";
+ opt = getopt32(argc, argv, GREP_OPTS OPT_EGREP,
&pattern_head, &fopt);
#endif
invert_search = (opt & GREP_OPT_v) != 0; /* 0 | 1 */
diff --git a/findutils/xargs.c b/findutils/xargs.c
index b6a154f15..278382373 100644
--- a/findutils/xargs.c
+++ b/findutils/xargs.c
@@ -399,7 +399,7 @@ int xargs_main(int argc, char **argv)
size_t n_chars = 0;
long orig_arg_max;
const char *eof_str = "_";
- unsigned long opt;
+ unsigned opt;
size_t n_max_chars;
#if ENABLE_FEATURE_XARGS_SUPPORT_ZERO_TERM
xlist_t* (*read_args)(xlist_t*, const char*, size_t, char*) = process_stdin;
@@ -407,7 +407,7 @@ int xargs_main(int argc, char **argv)
#define read_args process_stdin
#endif
- opt = bb_getopt_ulflags(argc, argv, OPTION_STR, &max_args, &max_chars, &eof_str);
+ opt = getopt32(argc, argv, OPTION_STR, &max_args, &max_chars, &eof_str);
if (opt & OPT_ZEROTERM)
USE_FEATURE_XARGS_SUPPORT_ZERO_TERM(read_args = process0_stdin);
diff --git a/include/libbb.h b/include/libbb.h
index c0de92190..4e96ea415 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -207,9 +207,9 @@ extern void xsetuid(uid_t uid);
extern off_t fdlength(int fd);
#define BB_GETOPT_ERROR 0x80000000UL
-extern const char *bb_opt_complementally;
-extern const struct option *bb_applet_long_options;
-extern unsigned long bb_getopt_ulflags(int argc, char **argv, const char *applet_opts, ...);
+extern const char *opt_complementary;
+extern const struct option *applet_long_options;
+extern uint32_t getopt32(int argc, char **argv, const char *applet_opts, ...);
extern int bb_vfprintf(FILE * __restrict stream, const char * __restrict format,
va_list arg) __attribute__ ((format (printf, 2, 0)));
@@ -232,7 +232,7 @@ extern char *skip_whitespace(const char *);
#ifndef BUILD_INDIVIDUAL
extern struct BB_applet *find_applet_by_name(const char *name);
-void run_applet_by_name(const char *name, int argc, char **argv);
+extern void run_applet_by_name(const char *name, int argc, char **argv);
#endif
/* dmalloc will redefine these to it's own implementation. It is safe
diff --git a/init/halt.c b/init/halt.c
index 7bd27896c..d796a4aea 100644
--- a/init/halt.c
+++ b/init/halt.c
@@ -34,7 +34,7 @@ RB_AUTOBOOT
for(which=0;delay[which]!=*bb_applet_name;which++);
/* Parse and handle arguments */
- flags = bb_getopt_ulflags(argc, argv, "d:nf", &delay);
+ flags = getopt32(argc, argv, "d:nf", &delay);
if (flags&1) sleep(atoi(delay));
if (!(flags&2)) sync();
diff --git a/libbb/Makefile.in b/libbb/Makefile.in
index f731e6e03..ef5c6b97a 100644
--- a/libbb/Makefile.in
+++ b/libbb/Makefile.in
@@ -30,7 +30,7 @@ LIBBB-y:= \
vherror_msg.c vperror_msg.c wfopen.c xconnect.c xgetcwd.c \
xgethostbyname.c xgethostbyname2.c xreadlink.c xgetlarg.c \
fclose_nonstdin.c fflush_stdout_and_exit.c \
- getopt_ulflags.c default_error_retval.c wfopen_input.c speed_table.c \
+ getopt32.c default_error_retval.c wfopen_input.c speed_table.c \
perror_nomsg_and_die.c perror_nomsg.c skip_whitespace.c bb_askpass.c \
warn_ignoring_args.c concat_subpath_file.c vfork_daemon_rexec.c \
bb_do_delay.c
diff --git a/libbb/getopt_ulflags.c b/libbb/getopt32.c
index 9d27c1f11..e08496578 100644
--- a/libbb/getopt_ulflags.c
+++ b/libbb/getopt32.c
@@ -1,6 +1,6 @@
/* vi: set sw=4 ts=4: */
/*
- * universal getopt_ulflags implementation for busybox
+ * universal getopt32 implementation for busybox
*
* Copyright (C) 2003-2005 Vladimir Oleynik <dzo@simtreas.ru>
*
@@ -12,13 +12,13 @@
/* Documentation
-unsigned long
-bb_getopt_ulflags(int argc, char **argv, const char *applet_opts, ...)
+uint32_t
+getopt32(int argc, char **argv, const char *applet_opts, ...)
The command line options must be declared in const char
*applet_opts as a string of chars, for example:
- flags = bb_getopt_ulflags(argc, argv, "rnug");
+ flags = getopt32(argc, argv, "rnug");
If one of the given options is found, a flag value is added to
the return value (an unsigned long).
@@ -26,7 +26,7 @@ bb_getopt_ulflags(int argc, char **argv, const char *applet_opts, ...)
The flag value is determined by the position of the char in
applet_opts string. For example, in the above case:
- flags = bb_getopt_ulflags(argc, argv, "rnug");
+ flags = getopt32(argc, argv, "rnug");
"r" will add 1 (bit 0)
"n" will add 2 (bit 1)
@@ -52,13 +52,13 @@ bb_getopt_ulflags(int argc, char **argv, const char *applet_opts, ...)
char *pointer_to_arg_for_c;
char *pointer_to_arg_for_d;
- flags = bb_getopt_ulflags(argc, argv, "a:b:c:d:",
+ flags = getopt32(argc, argv, "a:b:c:d:",
&pointer_to_arg_for_a, &pointer_to_arg_for_b,
&pointer_to_arg_for_c, &pointer_to_arg_for_d);
The type of the pointer (char* or llist_t*) may be controlled
by the "::" special separator that is set in the external string
- bb_opt_complementally (see below for more info).
+ opt_complementary (see below for more info).
"::" If option can have an *optional* argument, then add a "::"
after its char in applet_opts and provide a pointer to store
@@ -72,7 +72,7 @@ bb_getopt_ulflags(int argc, char **argv, const char *applet_opts, ...)
env -i ls -d /
Here we want env to process just the '-i', not the '-d'.
-const struct option *bb_applet_long_options
+const struct option *applet_long_options
This struct allows you to define long options. The syntax for
declaring the array is just like that of getopt's longopts.
@@ -83,23 +83,20 @@ const struct option *bb_applet_long_options
{ "verbose", 0, 0, 'v' },
{ 0, 0, 0, 0 }
};
- bb_applet_long_options = applet_long_options;
+ applet_long_options = applet_long_options;
The last member of struct option (val) typically is set to
matching short option from applet_opts. If there is no matching
char in applet_opts, then:
- return bit have next position after short options
- if has_arg is not "no_argument", use ptr for arg also
- - bb_opt_complementally affects it too
+ - opt_complementary affects it too
Note: a good applet will make long options configurable via the
config process and not a required feature. The current standard
is to name the config option CONFIG_FEATURE_<applet>_LONG_OPTIONS.
-const char *bb_opt_complementally
-
- this should be bb_opt_complementary, but we'll just keep it as
- bb_opt_complementally due to the Russian origins
+const char *opt_complementary
":" The colon (":") is used to separate groups of two or more chars
and/or groups of chars and special characters (stating some
@@ -110,11 +107,11 @@ const char *bb_opt_complementally
Their flags will be turned on if the main option is found even
if they are not specifed on the command line. For example:
- bb_opt_complementally = "abc";
- flags = bb_getopt_ulflags(argc, argv, "abcd")
+ opt_complementary = "abc";
+ flags = getopt32(argc, argv, "abcd")
If getopt() finds "-a" on the command line, then
- bb_getopt_ulflags's return value will be as if "-a -b -c" were
+ getopt32's return value will be as if "-a -b -c" were
found.
"ww" Adjacent double options have a counter associated which indicates
@@ -124,15 +121,15 @@ const char *bb_opt_complementally
if w is given more than once, it is "unlimited"
int w_counter = 0;
- bb_opt_complementally = "ww";
- bb_getopt_ulflags(argc, argv, "w", &w_counter);
+ opt_complementary = "ww";
+ getopt32(argc, argv, "w", &w_counter);
if (w_counter)
width = (w_counter == 1) ? 132 : INT_MAX;
else
get_terminal_width(...&width...);
w_counter is a pointer to an integer. It has to be passed to
- bb_getopt_ulflags() after all other option argument sinks.
+ getopt32() after all other option argument sinks.
For example: accept multiple -v to indicate the level of verbosity
and for each -b optarg, add optarg to my_b. Finally, if b is given,
@@ -140,8 +137,8 @@ const char *bb_opt_complementally
llist_t *my_b = NULL;
int verbose_level = 0;
- bb_opt_complementally = "vv:b::b-c:c-b";
- f = bb_getopt_ulflags(argc, argv, "vb:c", &my_b, &verbose_level);
+ opt_complementary = "vv:b::b-c:c-b";
+ f = getopt32(argc, argv, "vb:c", &my_b, &verbose_level);
if (f & 2) // -c after -b unsets -b flag
while (my_b) { dosomething_with(my_b->data); my_b = my_b->link; }
if (my_b) // but llist is stored if -b is specified
@@ -157,37 +154,37 @@ Special characters:
For example:
The du applet has the options "-s" and "-d depth". If
- bb_getopt_ulflags finds -s, then -d is unset or if it finds -d
+ getopt32 finds -s, then -d is unset or if it finds -d
then -s is unset. (Note: busybox implements the GNU
"--max-depth" option as "-d".) To obtain this behavior, you
- set bb_opt_complementally = "s-d:d-s". Only one flag value is
- added to bb_getopt_ulflags's return value depending on the
+ set opt_complementary = "s-d:d-s". Only one flag value is
+ added to getopt32's return value depending on the
position of the options on the command line. If one of the
two options requires an argument pointer (":" in applet_opts
as in "d:") optarg is set accordingly.
char *smax_print_depth;
- bb_opt_complementally = "s-d:d-s:x-x";
- opt = bb_getopt_ulflags(argc, argv, "sd:x", &smax_print_depth);
+ opt_complementary = "s-d:d-s:x-x";
+ opt = getopt32(argc, argv, "sd:x", &smax_print_depth);
if (opt & 2)
max_print_depth = atoi(smax_print_depth);
if (opt & 4)
printf("Detected odd -x usage\n");
- "-" A dash as the first char in a bb_opt_complementally group forces
+ "-" A dash as the first char in a opt_complementary group forces
all arguments to be treated as options, even if they have
no leading dashes. Next char in this case can't be a digit (0-9),
use ':' or end of line. For example:
- bb_opt_complementally = "-:w-x:x-w";
- bb_getopt_ulflags(argc, argv, "wx");
+ opt_complementary = "-:w-x:x-w";
+ getopt32(argc, argv, "wx");
Allows any arguments to be given without a dash (./program w x)
as well as with a dash (./program -x).
- "-N" A dash as the first char in a bb_opt_complementally group followed
+ "-N" A dash as the first char in a opt_complementary group followed
by a single digit (0-9) means that at least N non-option
arguments must be present on the command line
@@ -205,8 +202,8 @@ Special characters:
The cut applet must have only one type of list specified, so
-b, -c and -f are mutally exclusive and should raise an error
if specified together. In this case you must set
- bb_opt_complementally = "b--cf:c--bf:f--bc". If two of the
- mutually exclusive options are found, bb_getopt_ulflags's
+ opt_complementary = "b--cf:c--bf:f--bc". If two of the
+ mutually exclusive options are found, getopt32's
return value will have the error flag set (BB_GETOPT_ERROR) so
that we can check for it:
@@ -216,35 +213,35 @@ Special characters:
"x--x" Variation of the above, it means that -x option should occur
at most once.
- "?" A "?" as the first char in a bb_opt_complementally group means:
+ "?" A "?" as the first char in a opt_complementary group means:
if BB_GETOPT_ERROR is detected, don't return, call bb_show_usage
and exit instead. Next char after '?' can't be a digit.
- "?N" A "?" as the first char in a bb_opt_complementally group followed
+ "?N" A "?" as the first char in a opt_complementary group followed
by a single digit (0-9) means that at most N arguments must be present
on the command line.
- "::" A double colon after a char in bb_opt_complementally means that the
+ "::" A double colon after a char in opt_complementary means that the
option can occur multiple times. Each occurrence will be saved as
a llist_t element instead of char*.
For example:
The grep applet can have one or more "-e pattern" arguments.
- In this case you should use bb_getopt_ulflags() as follows:
+ In this case you should use getopt32() as follows:
llist_t *patterns = NULL;
(this pointer must be initializated to NULL if the list is empty
as required by *llist_add_to(llist_t *old_head, char *new_item).)
- bb_opt_complementally = "e::";
+ opt_complementary = "e::";
- bb_getopt_ulflags(argc, argv, "e:", &patterns);
+ getopt32(argc, argv, "e:", &patterns);
$ grep -e user -e root /etc/passwd
root:x:0:0:root:/root:/bin/bash
user:x:500:500::/home/user:/bin/bash
- "--" A double dash at the beginning of bb_opt_complementally means the
+ "--" A double dash at the beginning of opt_complementary means the
argv[1] string should always be treated as options, even if it isn't
prefixed with a "-". This is useful for special syntax in applets
such as "ar" and "tar":
@@ -257,20 +254,20 @@ Special characters:
For example from "id" applet:
// Don't allow -n -r -rn -ug -rug -nug -rnug
- bb_opt_complementally = "r?ug:n?ug:?u--g:g--u";
- flags = bb_getopt_ulflags(argc, argv, "rnug");
+ opt_complementary = "r?ug:n?ug:?u--g:g--u";
+ flags = getopt32(argc, argv, "rnug");
This example allowed only:
$ id; id -u; id -g; id -ru; id -nu; id -rg; id -ng; id -rnu; id -rng
- "X" A bb_opt_complementally group with just a single letter means
+ "X" A opt_complementary group with just a single letter means
that this option is required. If more than one such group exists,
at least one option is required to occur (not all of them).
For example from "start-stop-daemon" applet:
// Don't allow -KS -SK, but -S or -K is required
- bb_opt_complementally = "K:S:?K--S:S--K";
- flags = bb_getopt_ulflags(argc, argv, "KS...);
+ opt_complementary = "K:S:?K--S:S--K";
+ flags = getopt32(argc, argv, "KS...);
Don't forget to use ':'. For example, "?322-22-23X-x-a"
@@ -280,45 +277,45 @@ Special characters:
a '-2' and after it a '-x' then error out.
*/
-/* this should be bb_opt_complementary, but we'll just keep it as
- bb_opt_complementally due to the Russian origins */
-const char *bb_opt_complementally;
+/* Code here assumes that 'unsigned' is at least 32 bits wide */
+
+const char *opt_complementary;
typedef struct {
int opt;
int list_flg;
- unsigned long switch_on;
- unsigned long switch_off;
- unsigned long incongruously;
- unsigned long requires;
+ unsigned switch_on;
+ unsigned switch_off;
+ unsigned incongruously;
+ unsigned requires;
void **optarg; /* char **optarg or llist_t **optarg */
int *counter;
-} t_complementally;
+} t_complementary;
-/* You can set bb_applet_long_options for parse called long options */
+/* You can set applet_long_options for parse called long options */
#if ENABLE_GETOPT_LONG
static const struct option bb_default_long_options[] = {
/* { "help", 0, NULL, '?' }, */
{ 0, 0, 0, 0 }
};
-const struct option *bb_applet_long_options = bb_default_long_options;
+const struct option *applet_long_options = bb_default_long_options;
#endif
-unsigned long
-bb_getopt_ulflags(int argc, char **argv, const char *applet_opts, ...)
+uint32_t
+getopt32(int argc, char **argv, const char *applet_opts, ...)
{
- unsigned long flags = 0;
- unsigned long requires = 0;
- t_complementally complementally[sizeof(flags) * 8 + 1];
+ unsigned flags = 0;
+ unsigned requires = 0;
+ t_complementary complementary[sizeof(flags) * 8 + 1];
int c;
const unsigned char *s;
- t_complementally *on_off;
+ t_complementary *on_off;
va_list p;
#if ENABLE_GETOPT_LONG
const struct option *l_o;
#endif
- unsigned long trigger;
+ unsigned trigger;
char **pargv = NULL;
int min_arg = 0;
int max_arg = -1;
@@ -332,8 +329,8 @@ bb_getopt_ulflags(int argc, char **argv, const char *applet_opts, ...)
va_start(p, applet_opts);
c = 0;
- on_off = complementally;
- memset(on_off, 0, sizeof(complementally));
+ on_off = complementary;
+ memset(on_off, 0, sizeof(complementary));
/* skip GNU extension */
s = (const unsigned char *)applet_opts;
@@ -355,10 +352,10 @@ bb_getopt_ulflags(int argc, char **argv, const char *applet_opts, ...)
}
#if ENABLE_GETOPT_LONG
- for (l_o = bb_applet_long_options; l_o->name; l_o++) {
+ for (l_o = applet_long_options; l_o->name; l_o++) {
if (l_o->flag)
continue;
- for (on_off = complementally; on_off->opt != 0; on_off++)
+ for (on_off = complementary; on_off->opt != 0; on_off++)
if (on_off->opt == l_o->val)
break;
if (on_off->opt == 0) {
@@ -372,9 +369,9 @@ bb_getopt_ulflags(int argc, char **argv, const char *applet_opts, ...)
}
}
#endif /* ENABLE_GETOPT_LONG */
- for (s = (const unsigned char *)bb_opt_complementally; s && *s; s++) {
- t_complementally *pair;
- unsigned long *pair_switch;
+ for (s = (const unsigned char *)opt_complementary; s && *s; s++) {
+ t_complementary *pair;
+ unsigned *pair_switch;
if (*s == ':')
continue;
@@ -401,7 +398,7 @@ bb_getopt_ulflags(int argc, char **argv, const char *applet_opts, ...)
}
continue;
}
- for (on_off = complementally; on_off->opt; on_off++)
+ for (on_off = complementary; on_off->opt; on_off++)
if (on_off->opt == *s)
break;
if (c == ':' && s[2] == ':') {
@@ -433,7 +430,7 @@ bb_getopt_ulflags(int argc, char **argv, const char *applet_opts, ...)
else
pair_switch = &(pair->switch_off);
} else {
- for (on_off = complementally; on_off->opt; on_off++)
+ for (on_off = complementary; on_off->opt; on_off++)
if (on_off->opt == *s) {
*pair_switch |= on_off->switch_on;
break;
@@ -455,12 +452,12 @@ bb_getopt_ulflags(int argc, char **argv, const char *applet_opts, ...)
#endif
#if ENABLE_GETOPT_LONG
while ((c = getopt_long(argc, argv, applet_opts,
- bb_applet_long_options, NULL)) >= 0) {
+ applet_long_options, NULL)) >= 0) {
#else
while ((c = getopt(argc, argv, applet_opts)) >= 0) {
#endif /* ENABLE_GETOPT_LONG */
loop_arg_is_opt:
- for (on_off = complementally; on_off->opt != c; on_off++) {
+ for (on_off = complementary; on_off->opt != c; on_off++) {
/* c==0 if long opt have non NULL flag */
if (on_off->opt == 0 && c != 0)
bb_show_usage();
@@ -505,7 +502,7 @@ loop_arg_is_opt:
free(argv[1]);
#endif
/* check depending requires for given options */
- for (on_off = complementally; on_off->opt; on_off++) {
+ for (on_off = complementary; on_off->opt; on_off++) {
if (on_off->requires && (flags & on_off->switch_on) &&
(flags & on_off->requires) == 0)
bb_show_usage();
diff --git a/loginutils/addgroup.c b/loginutils/addgroup.c
index 13f29bfa3..236dc1099 100644
--- a/loginutils/addgroup.c
+++ b/loginutils/addgroup.c
@@ -90,9 +90,9 @@ int addgroup_main(int argc, char **argv)
gid_t gid = 0;
/* check for min, max and missing args and exit on error */
- bb_opt_complementally = "-1:?2:?";
+ opt_complementary = "-1:?2:?";
- if (bb_getopt_ulflags(argc, argv, "g:", &group)) {
+ if (getopt32(argc, argv, "g:", &group)) {
gid = bb_xgetlarg(group, 10, 0, LONG_MAX);
}
/* move past the commandline options */
diff --git a/loginutils/adduser.c b/loginutils/adduser.c
index 936e48e0a..8101b20b4 100644
--- a/loginutils/adduser.c
+++ b/loginutils/adduser.c
@@ -169,8 +169,8 @@ int adduser_main(int argc, char **argv)
pw.pw_dir = NULL;
/* check for min, max and missing args and exit on error */
- bb_opt_complementally = "-1:?1:?";
- flags = bb_getopt_ulflags(argc, argv, "h:g:s:G:DSH", &pw.pw_dir, &pw.pw_gecos, &pw.pw_shell, &usegroup);
+ opt_complementary = "-1:?1:?";
+ flags = getopt32(argc, argv, "h:g:s:G:DSH", &pw.pw_dir, &pw.pw_gecos, &pw.pw_shell, &usegroup);
/* got root? */
if(geteuid()) {
diff --git a/loginutils/getty.c b/loginutils/getty.c
index 22601c74e..6730fa85c 100644
--- a/loginutils/getty.c
+++ b/loginutils/getty.c
@@ -258,7 +258,7 @@ static void parse_args(int argc, char **argv, struct options *op)
{
char *ts;
- op->flags = bb_getopt_ulflags(argc, argv, opt_string,
+ op->flags = getopt32(argc, argv, opt_string,
&(op->initstring), &fakehost, &(op->issue),
&(op->login), &ts);
if(op->flags & F_INITSTRING) {
diff --git a/loginutils/login.c b/loginutils/login.c
index 1b13fa0cc..1f392c10f 100644
--- a/loginutils/login.c
+++ b/loginutils/login.c
@@ -222,7 +222,7 @@ int login_main(int argc, char **argv)
char username[USERNAME_SIZE];
const char *tmp;
int amroot;
- unsigned long opt;
+ unsigned opt;
int count = 0;
struct passwd *pw;
char *opt_host = NULL;
@@ -234,7 +234,7 @@ int login_main(int argc, char **argv)
signal(SIGALRM, alarm_handler);
alarm(TIMEOUT);
- opt = bb_getopt_ulflags(argc, argv, "f:h:p", &opt_user, &opt_host);
+ opt = getopt32(argc, argv, "f:h:p", &opt_user, &opt_host);
if (opt & LOGIN_OPT_f) {
if (!amroot)
bb_error_msg_and_die("-f is for root only");
diff --git a/loginutils/passwd.c b/loginutils/passwd.c
index 211a49ea3..54f35d2d5 100644
--- a/loginutils/passwd.c
+++ b/loginutils/passwd.c
@@ -134,7 +134,7 @@ int passwd_main(int argc, char **argv)
OPT_delete = 0x8, /* -d - delete password */
OPT_lud = 0xe,
};
- unsigned long opt;
+ unsigned opt;
char *opt_a;
int amroot;
char *cp;
@@ -146,7 +146,7 @@ int passwd_main(int argc, char **argv)
amroot = (getuid() == 0);
openlog("passwd", LOG_PID | LOG_CONS | LOG_NOWAIT, LOG_AUTH);
- opt = bb_getopt_ulflags(argc, argv, "a:lud", &opt_a);
+ opt = getopt32(argc, argv, "a:lud", &opt_a);
argc -= optind;
argv += optind;
if (opt & OPT_algo) algo = get_algo(opt_a); // -a
diff --git a/loginutils/su.c b/loginutils/su.c
index c51359ae1..78942014e 100644
--- a/loginutils/su.c
+++ b/loginutils/su.c
@@ -20,7 +20,7 @@ int su_main(int argc, char **argv)
const char *tty;
char *old_user;
- flags = bb_getopt_ulflags(argc, argv, "mplc:s:", &opt_command, &opt_shell);
+ flags = getopt32(argc, argv, "mplc:s:", &opt_command, &opt_shell);
#define SU_OPT_mp (3)
#define SU_OPT_l (4)
diff --git a/loginutils/sulogin.c b/loginutils/sulogin.c
index 8cfb64e9a..6edd2582b 100644
--- a/loginutils/sulogin.c
+++ b/loginutils/sulogin.c
@@ -46,7 +46,7 @@ int sulogin_main(int argc, char **argv)
logmode = LOGMODE_BOTH;
openlog(bb_applet_name, 0, LOG_AUTH);
- if (bb_getopt_ulflags (argc, argv, "t:", &timeout_arg)) {
+ if (getopt32 (argc, argv, "t:", &timeout_arg)) {
if (safe_strtoi(timeout_arg, &timeout)) {
timeout = 0;
}
diff --git a/loginutils/vlock.c b/loginutils/vlock.c
index d472c0925..02d1ea772 100644
--- a/loginutils/vlock.c
+++ b/loginutils/vlock.c
@@ -55,7 +55,7 @@ int vlock_main(int argc, char **argv)
bb_show_usage();
}
- o_lock_all = bb_getopt_ulflags (argc, argv, "a");
+ o_lock_all = getopt32 (argc, argv, "a");
if((pw = getpwuid(getuid())) == NULL) {
bb_error_msg_and_die("Unknown uid %d", getuid());
diff --git a/miscutils/adjtimex.c b/miscutils/adjtimex.c
index 9662bbea9..47af1a5d2 100644
--- a/miscutils/adjtimex.c
+++ b/miscutils/adjtimex.c
@@ -47,14 +47,14 @@ int adjtimex_main(int argc, char **argv)
enum {
OPT_quiet = 0x1
};
- unsigned long opt;
+ unsigned opt;
char *opt_o, *opt_f, *opt_p, *opt_t;
struct timex txc;
int i, ret, sep;
const char *descript;
txc.modes=0;
- opt = bb_getopt_ulflags(argc, argv, "qo:f:p:t:",
+ opt = getopt32(argc, argv, "qo:f:p:t:",
&opt_o, &opt_f, &opt_p, &opt_t);
//if (opt & 0x1) // -q
if (opt & 0x2) { // -o
diff --git a/miscutils/crond.c b/miscutils/crond.c
index 3e12fedc8..4f25486dd 100644
--- a/miscutils/crond.c
+++ b/miscutils/crond.c
@@ -133,19 +133,19 @@ static void crondlog(const char *ctl, ...)
int crond_main(int ac, char **av)
{
- unsigned long opt;
+ unsigned opt;
char *lopt, *Lopt, *copt;
#if ENABLE_DEBUG_CROND_OPTION
char *dopt;
- bb_opt_complementally = "f-b:b-f:S-L:L-S:d-l";
+ opt_complementary = "f-b:b-f:S-L:L-S:d-l";
#else
- bb_opt_complementally = "f-b:b-f:S-L:L-S";
+ opt_complementary = "f-b:b-f:S-L:L-S";
#endif
opterr = 0; /* disable getopt 'errors' message. */
- opt = bb_getopt_ulflags(ac, av, "l:L:fbSc:"
+ opt = getopt32(ac, av, "l:L:fbSc:"
#if ENABLE_DEBUG_CROND_OPTION
"d:"
#endif
diff --git a/miscutils/eject.c b/miscutils/eject.c
index 272d95980..d49396be6 100644
--- a/miscutils/eject.c
+++ b/miscutils/eject.c
@@ -31,8 +31,8 @@ int eject_main(int argc, char **argv)
struct mntent *m;
int dev;
- /*bb_opt_complementally = "t--T:T--t";*/
- flags = bb_getopt_ulflags(argc, argv, "tT");
+ /*opt_complementary = "t--T:T--t";*/
+ flags = getopt32(argc, argv, "tT");
device = argv[optind] ? : DEFAULT_CDROM;
m = find_mount_point(device, bb_path_mtab_file);
diff --git a/miscutils/hdparm.c b/miscutils/hdparm.c
index b90142362..6c46f6a92 100644
--- a/miscutils/hdparm.c
+++ b/miscutils/hdparm.c
@@ -575,18 +575,18 @@ static void identify(uint16_t *id_supplied)
/* check if we recognise the device type */
printf("\n");
- if(!(val[GEN_CONFIG] & NOT_ATA))
+ if (!(val[GEN_CONFIG] & NOT_ATA))
{
dev = ATA_DEV;
printf("ATA device, with ");
}
- else if(val[GEN_CONFIG]==CFA_SUPPORT_VAL)
+ else if (val[GEN_CONFIG]==CFA_SUPPORT_VAL)
{
dev = ATA_DEV;
like_std = 4;
printf("CompactFlash ATA device, with ");
}
- else if(!(val[GEN_CONFIG] & NOT_ATAPI))
+ else if (!(val[GEN_CONFIG] & NOT_ATAPI))
{
dev = ATAPI_DEV;
eqpt = (val[GEN_CONFIG] & EQPT_TYPE) >> SHIFT_EQPT;
@@ -609,9 +609,9 @@ static void identify(uint16_t *id_supplied)
(val[CONFIG]==PWRD_NID_VAL) || (val[CONFIG]==PWRD_ID_VAL) )
{
like_std = 5;
- if((val[CONFIG]==STBY_NID_VAL) || (val[CONFIG]==STBY_ID_VAL))
+ if ((val[CONFIG]==STBY_NID_VAL) || (val[CONFIG]==STBY_ID_VAL))
printf("powers-up in standby; SET FEATURES subcmd spins-up.\n");
- if(((val[CONFIG]==STBY_NID_VAL) || (val[CONFIG]==PWRD_NID_VAL)) && (val[GEN_CONFIG] & INCOMPLETE))
+ if (((val[CONFIG]==STBY_NID_VAL) || (val[CONFIG]==PWRD_NID_VAL)) && (val[GEN_CONFIG] & INCOMPLETE))
printf("\n\tWARNING: ID response incomplete.\n\tFollowing data may be incorrect.\n\n");
}
@@ -629,9 +629,9 @@ static void identify(uint16_t *id_supplied)
{
if (val[MINOR] && (val[MINOR] <= MINOR_MAX))
{
- if(like_std < 3) like_std = 3;
+ if (like_std < 3) like_std = 3;
std = actual_ver[val[MINOR]];
- if(std) printf("\n\tUsed: %s ",minor_str[val[MINOR]]);
+ if (std) printf("\n\tUsed: %s ",minor_str[val[MINOR]]);
}
/* looks like when they up-issue the std, they obsolete one;
@@ -652,17 +652,17 @@ static void identify(uint16_t *id_supplied)
like_std = ii;
kk = like_std >4 ? like_std-4: 0;
}
- if(min_std > ii) min_std = ii;
+ if (min_std > ii) min_std = ii;
}
jj <<= 1;
}
- if(like_std < 3) like_std = 3;
+ if (like_std < 3) like_std = 3;
}
/* Figure out what standard the device is using if it hasn't told
* us. If we know the std, check if the device is using any of
* the words from the next level up. It happens.
*/
- if(like_std < std) like_std = std;
+ if (like_std < std) like_std = std;
if (((std == 5) || (!std && (like_std < 6))) &&
((((val[CMDS_SUPP_1] & VALID) == VALID_VAL) &&
@@ -724,7 +724,7 @@ static void identify(uint16_t *id_supplied)
jj = val[CDR_MAJOR] >> 1;
for (ii = 1; ii <15; ii++)
{
- if(jj & 0x0001) printf("-%u ", ii);
+ if (jj & 0x0001) printf("-%u ", ii);
jj >>= 1;
}
}
@@ -743,7 +743,7 @@ static void identify(uint16_t *id_supplied)
jj = val[GEN_CONFIG] >> 1;
for (ii = 1; ii < 15; ii++)
{
- if(jj & 0x0001) printf("\t%s\n",ata1_cfg_str[ii]);
+ if (jj & 0x0001) printf("\t%s\n",ata1_cfg_str[ii]);
jj >>=1;
}
}
@@ -1018,7 +1018,7 @@ static void identify(uint16_t *id_supplied)
}
}
/* Removable Media Status Notification feature set */
- if((val[RM_STAT] & RM_STAT_BITS) == RM_STAT_SUP)
+ if ((val[RM_STAT] & RM_STAT_BITS) == RM_STAT_SUP)
printf("\t%s supported\n", cmd_feat_str[27]);
@@ -1196,7 +1196,7 @@ static void dump_identity(const struct hd_driveid *id)
}
printf("\n");
- if(!(id->field_valid&1))
+ if (!(id->field_valid&1))
printf(" (maybe):");
printf(" CurCHS=%u/%u/%u, CurSects=%lu, LBA=%s",id->cur_cyls, id->cur_heads,
@@ -1589,7 +1589,7 @@ static void interpret_xfermode(unsigned int xfermode)
static void print_flag(unsigned long flag, char *s, unsigned long value)
{
- if(flag)
+ if (flag)
printf(" setting %s to %ld\n", s, value);
}
@@ -2078,18 +2078,18 @@ static void parse_xfermode(int flag, unsigned long *get, unsigned long *set, int
}
/*------- getopt short options --------*/
-static const char hdparm_options[]= "gfu::n::p:r::m::c::k::a::B:tTh"\
+static const char hdparm_options[] = "gfu::n::p:r::m::c::k::a::B:tTh"
USE_FEATURE_HDPARM_GET_IDENTITY("iI")
USE_FEATURE_HDPARM_HDIO_GETSET_DMA("d::")
#ifdef HDIO_DRIVE_CMD
- "S:D:P:X:K:A:L:W:CyYzZ"
+ "S:D:P:X:K:A:L:W:CyYzZ"
#endif
USE_FEATURE_HDPARM_HDIO_UNREGISTER_HWIF("U:")
#ifdef HDIO_GET_QDMA
#ifdef HDIO_SET_QDMA
- "Q:"
+ "Q:"
#else
- "Q"
+ "Q"
#endif
#endif
USE_FEATURE_HDPARM_HDIO_DRIVE_RESET("w")
@@ -2154,8 +2154,8 @@ int hdparm_main(int argc, char **argv)
#if ENABLE_FEATURE_HDPARM_HDIO_SCAN_HWIF
if (c == 'R') {
parse_opts(NULL, &scan_hwif, &hwif_data, 0, INT_MAX);
- hwif_ctrl = bb_xgetlarg((argv[optind]) ? argv[optind] : "", 10, 0, INT_MAX);
- hwif_irq = bb_xgetlarg((argv[optind+1]) ? argv[optind+1] : "", 10, 0, INT_MAX);
+ hwif_ctrl = bb_xgetlarg((argv[optind]) ? argv[optind] : "", 10, 0, INT_MAX);
+ hwif_irq = bb_xgetlarg((argv[optind+1]) ? argv[optind+1] : "", 10, 0, INT_MAX);
/* Move past the 2 additional arguments */
argv += 2;
argc -= 2;
@@ -2163,7 +2163,7 @@ int hdparm_main(int argc, char **argv)
#endif
}
/* When no flags are given (flagcount = 0), -acdgkmnru is assumed. */
- if (!flagcount){
+ if (!flagcount) {
get_mult = get_io32bit = get_unmask = get_keep = get_readonly = get_readahead = get_geom = 1;
USE_FEATURE_HDPARM_HDIO_GETSET_DMA(get_dma = 1);
}
diff --git a/miscutils/less.c b/miscutils/less.c
index bde2a4527..63389dcd7 100644
--- a/miscutils/less.c
+++ b/miscutils/less.c
@@ -1102,7 +1102,7 @@ int less_main(int argc, char **argv) {
int keypress;
- flags = bb_getopt_ulflags(argc, argv, "EMmN~");
+ flags = getopt32(argc, argv, "EMmN~");
argc -= optind;
argv += optind;
diff --git a/miscutils/makedevs.c b/miscutils/makedevs.c
index 66b4ce00d..4619e4dd5 100644
--- a/miscutils/makedevs.c
+++ b/miscutils/makedevs.c
@@ -76,7 +76,7 @@ int makedevs_main(int argc, char **argv)
int linenum = 0;
int ret = EXIT_SUCCESS;
- bb_getopt_ulflags(argc, argv, "d:", &line);
+ getopt32(argc, argv, "d:", &line);
if (line)
table = xfopen(line, "r");
diff --git a/miscutils/mountpoint.c b/miscutils/mountpoint.c
index 3e5fb4b46..dbc8fe0e9 100644
--- a/miscutils/mountpoint.c
+++ b/miscutils/mountpoint.c
@@ -13,7 +13,7 @@
int mountpoint_main(int argc, char **argv)
{
- int opt = bb_getopt_ulflags(argc, argv, "qdx");
+ int opt = getopt32(argc, argv, "qdx");
#define OPT_q (1)
#define OPT_d (2)
#define OPT_x (4)
diff --git a/miscutils/strings.c b/miscutils/strings.c
index e9f335ebd..36bcf8b17 100644
--- a/miscutils/strings.c
+++ b/miscutils/strings.c
@@ -21,14 +21,14 @@
int strings_main(int argc, char **argv)
{
int n, c, i = 0, status = EXIT_SUCCESS;
- unsigned long opt;
+ unsigned opt;
unsigned long count;
FILE *file = stdin;
char *string;
const char *fmt = "%s: ";
char *n_arg = "4";
- opt = bb_getopt_ulflags(argc, argv, "afon:", &n_arg);
+ opt = getopt32(argc, argv, "afon:", &n_arg);
/* -a is our default behaviour */
argc -= optind;
diff --git a/miscutils/watchdog.c b/miscutils/watchdog.c
index ebbab2df3..ae51aba7b 100644
--- a/miscutils/watchdog.c
+++ b/miscutils/watchdog.c
@@ -25,11 +25,11 @@ static void watchdog_shutdown(int ATTRIBUTE_UNUSED unused)
int watchdog_main(int argc, char **argv)
{
- unsigned long opts;
+ unsigned opts;
unsigned long timer_duration = 30; /* Userspace timer duration, in seconds */
char *t_arg;
- opts = bb_getopt_ulflags(argc, argv, "Ft:", &t_arg);
+ opts = getopt32(argc, argv, "Ft:", &t_arg);
if (opts & OPT_TIMER)
timer_duration = bb_xgetlarg(t_arg, 10, 0, INT_MAX);
diff --git a/modutils/insmod.c b/modutils/insmod.c
index 314e87325..0554def06 100644
--- a/modutils/insmod.c
+++ b/modutils/insmod.c
@@ -3983,7 +3983,7 @@ int insmod_main( int argc, char **argv)
struct utsname myuname;
/* Parse any options */
- option_mask = bb_getopt_ulflags(argc, argv, OPTION_STR, &opt_o);
+ option_mask = getopt32(argc, argv, OPTION_STR, &opt_o);
if (option_mask & OPT_o) { // -o /* name the output module */
free(m_name);
m_name = xstrdup(opt_o);
diff --git a/modutils/modprobe.c b/modutils/modprobe.c
index f51de56be..b629390e4 100644
--- a/modutils/modprobe.c
+++ b/modutils/modprobe.c
@@ -902,8 +902,8 @@ int modprobe_main(int argc, char** argv)
int rc = EXIT_SUCCESS;
char *unused;
- bb_opt_complementally = "?V-:q-v:v-q";
- main_opts = bb_getopt_ulflags(argc, argv, "acdklnqrst:vVC:",
+ opt_complementary = "?V-:q-v:v-q";
+ main_opts = getopt32(argc, argv, "acdklnqrst:vVC:",
&unused, &unused);
if((main_opts & (DUMP_CONF_EXIT | LIST_ALL)))
return EXIT_SUCCESS;
diff --git a/modutils/rmmod.c b/modutils/rmmod.c
index f87fb5e24..ce239a21f 100644
--- a/modutils/rmmod.c
+++ b/modutils/rmmod.c
@@ -44,7 +44,7 @@ int rmmod_main(int argc, char **argv)
unsigned int flags = O_NONBLOCK|O_EXCL;
/* Parse command line. */
- n = bb_getopt_ulflags(argc, argv, "wfa");
+ n = getopt32(argc, argv, "wfa");
if((n & 1)) // --wait
flags &= ~O_NONBLOCK;
if((n & 2)) // --force
diff --git a/networking/arping.c b/networking/arping.c
index f84c8a75c..1ff6f90be 100644
--- a/networking/arping.c
+++ b/networking/arping.c
@@ -265,14 +265,14 @@ int arping_main(int argc, char **argv)
xsetuid(getuid());
{
- unsigned long opt;
+ unsigned opt;
char *_count, *_timeout;
/* Dad also sets quit_on_reply.
* Advert also sets unsolicited.
*/
- bb_opt_complementally = "Df:AU";
- opt = bb_getopt_ulflags(argc, argv, "DUAqfbc:w:i:s:",
+ opt_complementary = "Df:AU";
+ opt = getopt32(argc, argv, "DUAqfbc:w:i:s:",
&_count, &_timeout, &device, &source);
cfg |= opt & 0x3f; /* set respective flags */
if (opt & 0x40) /* -c: count */
diff --git a/networking/dnsd.c b/networking/dnsd.c
index b0e74d770..ab3704707 100644
--- a/networking/dnsd.c
+++ b/networking/dnsd.c
@@ -372,7 +372,7 @@ int dnsd_main(int argc, char **argv)
char *sttl=NULL, *sport=NULL;
if(argc > 1)
- flags = bb_getopt_ulflags(argc, argv, "i:c:t:p:dv", &listen_interface, &fileconf, &sttl, &sport);
+ flags = getopt32(argc, argv, "i:c:t:p:dv", &listen_interface, &fileconf, &sttl, &sport);
if(sttl)
if(!(ttl = atol(sttl)))
bb_show_usage();
diff --git a/networking/ether-wake.c b/networking/ether-wake.c
index f4ca889fa..294a9dd3c 100644
--- a/networking/ether-wake.c
+++ b/networking/ether-wake.c
@@ -120,7 +120,7 @@ int ether_wake_main(int argc, char *argv[])
struct whereto_t whereto; /* who to wake up */
/* handle misc user options */
- flags = bb_getopt_ulflags(argc, argv, "bi:p:", &ifname, &pass);
+ flags = getopt32(argc, argv, "bi:p:", &ifname, &pass);
if (optind == argc)
bb_show_usage();
if (pass)
diff --git a/networking/fakeidentd.c b/networking/fakeidentd.c
index 2d690edba..6070e5f2d 100644
--- a/networking/fakeidentd.c
+++ b/networking/fakeidentd.c
@@ -228,7 +228,7 @@ int fakeidentd_main(int argc, char **argv)
FD_SET(0, &G.readfds);
/* handle -b <ip> parameter */
- bb_getopt_ulflags(argc, argv, "b:", &bind_ip_address);
+ getopt32(argc, argv, "b:", &bind_ip_address);
/* handle optional REPLY STRING */
if (optind < argc)
G.identuser = argv[optind];
diff --git a/networking/ftpgetput.c b/networking/ftpgetput.c
index 453cce571..25b7f1427 100644
--- a/networking/ftpgetput.c
+++ b/networking/ftpgetput.c
@@ -275,7 +275,7 @@ static const struct option ftpgetput_long_options[] = {
int ftpgetput_main(int argc, char **argv)
{
/* content-length of the file */
- unsigned long opt;
+ unsigned opt;
char *port = "ftp";
/* socket to ftp server */
@@ -305,9 +305,9 @@ int ftpgetput_main(int argc, char **argv)
* Decipher the command line
*/
if (ENABLE_FEATURE_FTPGETPUT_LONG_OPTIONS)
- bb_applet_long_options = ftpgetput_long_options;
+ applet_long_options = ftpgetput_long_options;
- opt = bb_getopt_ulflags(argc, argv, "cvu:p:P:", &server->user, &server->password, &port);
+ opt = getopt32(argc, argv, "cvu:p:P:", &server->user, &server->password, &port);
/* Process the non-option command line arguments */
if (argc - optind != 3) {
diff --git a/networking/hostname.c b/networking/hostname.c
index 2850bd5bd..4fe28d740 100644
--- a/networking/hostname.c
+++ b/networking/hostname.c
@@ -55,13 +55,13 @@ int hostname_main(int argc, char **argv)
};
char buf[256];
- unsigned long opt;
+ unsigned opt;
char *hostname_str = NULL;
if (argc < 1)
bb_show_usage();
- opt = bb_getopt_ulflags(argc, argv, "dfisF:", &hostname_str);
+ opt = getopt32(argc, argv, "dfisF:", &hostname_str);
/* Output in desired format */
if (opt & OPT_dfis) {
diff --git a/networking/httpd.c b/networking/httpd.c
index e533594f2..ac9eac6bf 100644
--- a/networking/httpd.c
+++ b/networking/httpd.c
@@ -1909,7 +1909,7 @@ static const char httpd_opts[] = "c:d:h:"
int httpd_main(int argc, char *argv[])
{
- unsigned long opt;
+ unsigned opt;
const char *home_httpd = home;
char *url_for_decode;
USE_FEATURE_HTTPD_ENCODE_URL_STR(const char *url_for_encode;)
@@ -1932,7 +1932,7 @@ int httpd_main(int argc, char *argv[])
config->ContentLength = -1;
- opt = bb_getopt_ulflags(argc, argv, httpd_opts,
+ opt = getopt32(argc, argv, httpd_opts,
&(config->configFile), &url_for_decode, &home_httpd
USE_FEATURE_HTTPD_ENCODE_URL_STR(, &url_for_encode)
USE_FEATURE_HTTPD_BASIC_AUTH(, &(config->realm))
diff --git a/networking/ifupdown.c b/networking/ifupdown.c
index 9dd1c9926..f34287580 100644
--- a/networking/ifupdown.c
+++ b/networking/ifupdown.c
@@ -1088,7 +1088,7 @@ int ifupdown_main(int argc, char **argv)
cmds = iface_down;
}
- option_mask = bb_getopt_ulflags(argc, argv, OPTION_STR, &interfaces);
+ option_mask = getopt32(argc, argv, OPTION_STR, &interfaces);
if (argc - optind > 0) {
if (DO_ALL) bb_show_usage();
} else
diff --git a/networking/inetd.c b/networking/inetd.c
index 8c8843b9b..350f91dc4 100644
--- a/networking/inetd.c
+++ b/networking/inetd.c
@@ -1253,7 +1253,7 @@ inetd_main(int argc, char *argv[])
openlog(bb_applet_name, LOG_PID | LOG_NOWAIT, LOG_DAEMON);
- opt = bb_getopt_ulflags(argc, argv, "R:f", &stoomany);
+ opt = getopt32(argc, argv, "R:f", &stoomany);
if(opt & 1) {
char *e;
diff --git a/networking/ipcalc.c b/networking/ipcalc.c
index aafb7869b..576dfc853 100644
--- a/networking/ipcalc.c
+++ b/networking/ipcalc.c
@@ -90,9 +90,9 @@ int ipcalc_main(int argc, char **argv)
char *ipstr;
if (ENABLE_FEATURE_IPCALC_LONG_OPTIONS)
- bb_applet_long_options = long_options;
+ applet_long_options = long_options;
- mode = bb_getopt_ulflags(argc, argv, "mbn" USE_FEATURE_IPCALC_FANCY("phs"));
+ mode = getopt32(argc, argv, "mbn" USE_FEATURE_IPCALC_FANCY("phs"));
argc -= optind;
argv += optind;
diff --git a/networking/nameif.c b/networking/nameif.c
index 3fa257263..146eccea9 100644
--- a/networking/nameif.c
+++ b/networking/nameif.c
@@ -65,7 +65,7 @@ int nameif_main(int argc, char **argv)
int if_index = 1;
mactable_t *ch;
- if (1 & bb_getopt_ulflags(argc, argv, "sc:", &fname)) {
+ if (1 & getopt32(argc, argv, "sc:", &fname)) {
openlog(bb_applet_name, 0, LOG_LOCAL0);
logmode = LOGMODE_SYSLOG;
}
diff --git a/networking/netstat.c b/networking/netstat.c
index cadcb0e31..bc5c61974 100644
--- a/networking/netstat.c
+++ b/networking/netstat.c
@@ -21,7 +21,7 @@ extern void displayroutes(int noresolve, int netstatfmt);
#define NETSTAT_CONNECTED 0x01
#define NETSTAT_LISTENING 0x02
#define NETSTAT_NUMERIC 0x04
-/* Must match getopt_ulflags option string */
+/* Must match getopt32 option string */
#define NETSTAT_TCP 0x10
#define NETSTAT_UDP 0x20
#define NETSTAT_RAW 0x40
@@ -526,7 +526,7 @@ int netstat_main(int argc, char **argv)
OPT_extended = 0x4,
OPT_showroute = 0x100,
};
- unsigned long opt;
+ unsigned opt;
#ifdef CONFIG_FEATURE_IPV6
int inet = 1;
int inet6 = 1;
@@ -536,7 +536,7 @@ int netstat_main(int argc, char **argv)
#endif
/* Option string must match NETSTAT_xxx constants */
- opt = bb_getopt_ulflags(argc, argv, "laentuwxr");
+ opt = getopt32(argc, argv, "laentuwxr");
if (opt & 0x1) { // -l
flags &= ~NETSTAT_CONNECTED;
flags |= NETSTAT_LISTENING;
diff --git a/networking/route.c b/networking/route.c
index 5fd888617..2e6e017b6 100644
--- a/networking/route.c
+++ b/networking/route.c
@@ -647,7 +647,7 @@ static const char tbl_verb[] = /* 2nd byte matches RTACTION_* code */
int route_main(int argc, char **argv)
{
- unsigned long opt;
+ unsigned opt;
int what;
char *family;
@@ -662,7 +662,7 @@ int route_main(int argc, char **argv)
}
}
- opt = bb_getopt_ulflags(argc, argv, "A:ne", &family);
+ opt = getopt32(argc, argv, "A:ne", &family);
if ((opt & ROUTE_OPT_A) && strcmp(family, "inet")) {
#ifdef CONFIG_FEATURE_IPV6
diff --git a/networking/telnet.c b/networking/telnet.c
index fd0f84d50..cd4c33a86 100644
--- a/networking/telnet.c
+++ b/networking/telnet.c
@@ -623,7 +623,7 @@ int telnet_main(int argc, char** argv)
bb_show_usage();
#ifdef CONFIG_FEATURE_TELNET_AUTOLOGIN
- if (1 & bb_getopt_ulflags(argc, argv, "al:", &autologin))
+ if (1 & getopt32(argc, argv, "al:", &autologin))
autologin = getenv("USER");
if (optind < argc) {
diff --git a/networking/telnetd.c b/networking/telnetd.c
index 9fa8faf66..808d4be51 100644
--- a/networking/telnetd.c
+++ b/networking/telnetd.c
@@ -362,7 +362,7 @@ free_session(struct tsession *ts)
int
telnetd_main(int argc, char **argv)
{
- unsigned long opt;
+ unsigned opt;
fd_set rdfdset, wrfdset;
int selret;
#ifndef CONFIG_FEATURE_TELNETD_INETD
@@ -387,7 +387,7 @@ telnetd_main(int argc, char **argv)
openlog(bb_applet_name, 0, LOG_USER);
logmode = LOGMODE_SYSLOG;
- opt = bb_getopt_ulflags(argc, argv, "f:l:" USE_FEATURE_TELNETD_INETD("p:b:"),
+ opt = getopt32(argc, argv, "f:l:" USE_FEATURE_TELNETD_INETD("p:b:"),
&issuefile, &loginpath
SKIP_FEATURE_TELNETD_INETD(, &opt_portnbr, &opt_bindaddr));
//if (opt & 1) // -f
diff --git a/networking/tftp.c b/networking/tftp.c
index 42fd9d2ca..5f0c190e2 100644
--- a/networking/tftp.c
+++ b/networking/tftp.c
@@ -497,13 +497,13 @@ int tftp_main(int argc, char **argv)
#endif
#if defined(CONFIG_FEATURE_TFTP_GET) && defined(CONFIG_FEATURE_TFTP_PUT)
- bb_opt_complementally = GET_COMPL PUT_COMPL ":?g--p:p--g";
+ opt_complementary = GET_COMPL PUT_COMPL ":?g--p:p--g";
#elif defined(CONFIG_FEATURE_TFTP_GET) || defined(CONFIG_FEATURE_TFTP_PUT)
- bb_opt_complementally = GET_COMPL PUT_COMPL;
+ opt_complementary = GET_COMPL PUT_COMPL;
#endif
- cmd = bb_getopt_ulflags(argc, argv, GET PUT "l:r:" BS,
+ cmd = getopt32(argc, argv, GET PUT "l:r:" BS,
&localfile, &remotefile BS_ARG);
cmd &= (tftp_cmd_get | tftp_cmd_put);
diff --git a/networking/traceroute.c b/networking/traceroute.c
index e7e131149..042cbe35a 100644
--- a/networking/traceroute.c
+++ b/networking/traceroute.c
@@ -949,12 +949,12 @@ traceroute_main(int argc, char *argv[])
opterr = 0;
#ifdef CONFIG_FEATURE_TRACEROUTE_SOURCE_ROUTE
- bb_opt_complementally = "x-x:g::";
+ opt_complementary = "x-x:g::";
#else
- bb_opt_complementally = "x-x";
+ opt_complementary = "x-x";
#endif
- op = bb_getopt_ulflags(argc, argv, "FIlnrdvxt:i:m:p:q:s:w:z:f:"
+ op = getopt32(argc, argv, "FIlnrdvxt:i:m:p:q:s:w:z:f:"
#define USAGE_OP_DONT_FRAGMNT (1<<0) /* F */
#define USAGE_OP_USE_ICMP (1<<1) /* I */
#define USAGE_OP_TTL_FLAG (1<<2) /* l */
diff --git a/networking/wget.c b/networking/wget.c
index bbe1bba9a..0054a9876 100644
--- a/networking/wget.c
+++ b/networking/wget.c
@@ -124,7 +124,7 @@ static const struct option wget_long_options[] = {
int wget_main(int argc, char **argv)
{
int n, try=5, status;
- unsigned long opt;
+ unsigned opt;
int port;
char *proxy = 0;
char *dir_prefix=NULL;
@@ -148,11 +148,11 @@ int wget_main(int argc, char **argv)
/*
* Crack command line.
*/
- bb_opt_complementally = "-1:\203::";
+ opt_complementary = "-1:\203::";
#if ENABLE_FEATURE_WGET_LONG_OPTIONS
- bb_applet_long_options = wget_long_options;
+ applet_long_options = wget_long_options;
#endif
- opt = bb_getopt_ulflags(argc, argv, "cq\213O:\203:P:Y:U:",
+ opt = getopt32(argc, argv, "cq\213O:\203:P:Y:U:",
&fname_out, &headers_llist,
&dir_prefix, &proxy_flag, &user_agent);
if (strcmp(proxy_flag, "off") == 0) {
diff --git a/networking/zcip.c b/networking/zcip.c
index c6b0d2d80..d9c1adf19 100644
--- a/networking/zcip.c
+++ b/networking/zcip.c
@@ -75,7 +75,7 @@ enum {
#define VDBG(fmt,args...) \
do { } while (0)
-static unsigned long opts;
+static unsigned opts;
#define FOREGROUND (opts & 1)
#define QUIT (opts & 2)
@@ -217,8 +217,8 @@ int zcip_main(int argc, char *argv[])
// parse commandline: prog [options] ifname script
char *r_opt;
- bb_opt_complementally = "vv:vf"; // -v accumulates and implies -f
- opts = bb_getopt_ulflags(argc, argv, "fqr:v", &r_opt, &verbose);
+ opt_complementary = "vv:vf"; // -v accumulates and implies -f
+ opts = getopt32(argc, argv, "fqr:v", &r_opt, &verbose);
if (!FOREGROUND) {
/* Do it early, before all bb_xx_msg calls */
logmode = LOGMODE_SYSLOG;
diff --git a/procps/pidof.c b/procps/pidof.c
index c686245ea..e6c954843 100644
--- a/procps/pidof.c
+++ b/procps/pidof.c
@@ -39,11 +39,11 @@ int pidof_main(int argc, char **argv)
unsigned long int opt;
#if ENABLE_FEATURE_PIDOF_OMIT
llist_t *omits = NULL; /* list of pids to omit */
- bb_opt_complementally = _OMIT_COMPL("o::");
+ opt_complementary = _OMIT_COMPL("o::");
#endif
/* do unconditional option parsing */
- opt = bb_getopt_ulflags(argc, argv,
+ opt = getopt32(argc, argv,
_SINGLE_COMPL("s") _OMIT_COMPL("o:")
_OMIT(&omits));
diff --git a/procps/ps.c b/procps/ps.c
index 95502b284..0452a5046 100644
--- a/procps/ps.c
+++ b/procps/ps.c
@@ -23,7 +23,7 @@ int ps_main(int argc, char **argv)
int terminal_width;
int w_count = 0;
- bb_opt_complementally = "-:ww";
+ opt_complementary = "-:ww";
#else
# define terminal_width 79
#endif
@@ -31,11 +31,11 @@ int ps_main(int argc, char **argv)
#if ENABLE_FEATURE_PS_WIDE || ENABLE_SELINUX
/* handle arguments */
#if ENABLE_FEATURE_PS_WIDE && ENABLE_SELINUX
- i = bb_getopt_ulflags(argc, argv, "wc", &w_count);
+ i = getopt32(argc, argv, "wc", &w_count);
#elif ENABLE_FEATURE_PS_WIDE && !ENABLE_SELINUX
- bb_getopt_ulflags(argc, argv, "w", &w_count);
+ getopt32(argc, argv, "w", &w_count);
#else /* !ENABLE_FEATURE_PS_WIDE && ENABLE_SELINUX */
- i = bb_getopt_ulflags(argc, argv, "c");
+ i = getopt32(argc, argv, "c");
#endif
#if ENABLE_FEATURE_PS_WIDE
/* if w is given once, GNU ps sets the width to 132,
diff --git a/procps/top.c b/procps/top.c
index be8ac195b..ebfbcb80c 100644
--- a/procps/top.c
+++ b/procps/top.c
@@ -397,8 +397,8 @@ int top_main(int argc, char **argv)
/* do normal option parsing */
interval = 5;
- bb_opt_complementally = "-";
- option_mask = bb_getopt_ulflags(argc, argv, "d:n:b",
+ opt_complementary = "-";
+ option_mask = getopt32(argc, argv, "d:n:b",
&sinterval, &siterations);
if (option_mask & 0x1) interval = atoi(sinterval); // -d
if (option_mask & 0x2) iterations = atoi(siterations); // -n
diff --git a/runit/chpst.c b/runit/chpst.c
index 11ee3d733..ced28387d 100644
--- a/runit/chpst.c
+++ b/runit/chpst.c
@@ -238,7 +238,7 @@ int chpst_main(int argc, char **argv)
{
char *m,*d,*o,*p,*f,*c,*r,*t,*n;
- option_mask = bb_getopt_ulflags(argc, argv, "u:U:e:m:d:o:p:f:c:r:t:/:n:vP012",
+ option_mask = getopt32(argc, argv, "u:U:e:m:d:o:p:f:c:r:t:/:n:vP012",
&set_user,&env_user,&env_dir,
&m,&d,&o,&p,&f,&c,&r,&t,&root,&n);
// if (option_mask & 0x1) // -u
@@ -324,7 +324,7 @@ static void envdir(int argc, char **argv)
static void softlimit(int argc, char **argv)
{
char *a,*c,*d,*f,*l,*m,*o,*p,*r,*s,*t;
- option_mask = bb_getopt_ulflags(argc, argv, "a:c:d:f:l:m:o:p:r:s:t:",
+ option_mask = getopt32(argc, argv, "a:c:d:f:l:m:o:p:r:s:t:",
&a,&c,&d,&f,&l,&m,&o,&p,&r,&s,&t);
if (option_mask & 0x001) limita = bb_xgetularg10(a); // -a
if (option_mask & 0x002) limitc = bb_xgetularg10(c); // -c
diff --git a/shell/bbsh.c b/shell/bbsh.c
index 2194bdad6..77e186d35 100644
--- a/shell/bbsh.c
+++ b/shell/bbsh.c
@@ -203,7 +203,7 @@ int bbsh_main(int argc, char *argv[])
char *command=NULL;
FILE *f;
- bb_getopt_ulflags(argc, argv, "c:", &command);
+ getopt32(argc, argv, "c:", &command);
f = argv[optind] ? xfopen(argv[optind],"r") : NULL;
if (command) handle(command);
diff --git a/shell/lash.c b/shell/lash.c
index fd6bea177..9c862a17f 100644
--- a/shell/lash.c
+++ b/shell/lash.c
@@ -1503,7 +1503,7 @@ static inline void setup_job_control(void)
int lash_main(int argc_l, char **argv_l)
{
- unsigned long opt;
+ unsigned opt;
FILE *input = stdin;
argc = argc_l;
argv = argv_l;
@@ -1527,7 +1527,7 @@ int lash_main(int argc_l, char **argv_l)
}
}
- opt = bb_getopt_ulflags(argc_l, argv_l, "+ic:", &local_pending_command);
+ opt = getopt32(argc_l, argv_l, "+ic:", &local_pending_command);
#define LASH_OPT_i (1<<0)
#define LASH_OPT_c (1<<2)
if (opt & LASH_OPT_c) {
diff --git a/sysklogd/klogd.c b/sysklogd/klogd.c
index 677c9e607..e629bec5d 100644
--- a/sysklogd/klogd.c
+++ b/sysklogd/klogd.c
@@ -45,10 +45,10 @@ int klogd_main(int argc, char **argv)
{
- unsigned long opt;
+ unsigned opt;
/* do normal option parsing */
- opt = bb_getopt_ulflags(argc, argv, "c:n", &start);
+ opt = getopt32(argc, argv, "c:n", &start);
if (opt & OPT_LEVEL) {
/* Valid levels are between 1 and 8 */
diff --git a/sysklogd/logger.c b/sysklogd/logger.c
index a78cf77b9..15a4bfb82 100644
--- a/sysklogd/logger.c
+++ b/sysklogd/logger.c
@@ -89,7 +89,7 @@ static int pencode(char *s)
int logger_main(int argc, char **argv)
{
- unsigned long opt;
+ unsigned opt;
char *opt_p, *opt_t;
int pri = LOG_USER | LOG_NOTICE;
int option = 0;
@@ -100,7 +100,7 @@ int logger_main(int argc, char **argv)
bb_getpwuid(name, geteuid(), sizeof(name));
/* Parse any options */
- opt = bb_getopt_ulflags(argc, argv, "p:st:", &opt_p, &opt_t);
+ opt = getopt32(argc, argv, "p:st:", &opt_p, &opt_t);
if (opt & 0x1) pri = pencode(opt_p); // -p
if (opt & 0x2) option |= LOG_PERROR; // -s
if (opt & 0x4) safe_strncpy(name, opt_t, sizeof(name)); // -t
diff --git a/sysklogd/syslogd.c b/sysklogd/syslogd.c
index 888082924..40b98c1cb 100644
--- a/sysklogd/syslogd.c
+++ b/sysklogd/syslogd.c
@@ -575,7 +575,7 @@ int syslogd_main(int argc, char **argv)
char *p;
/* do normal option parsing */
- option_mask = bb_getopt_ulflags(argc, argv, OPTION_STR, OPTION_PARAM);
+ option_mask = getopt32(argc, argv, OPTION_STR, OPTION_PARAM);
if (option_mask & OPT_mark) MarkInterval = atoi(opt_m) * 60; // -m
//if (option_mask & OPT_nofork) // -n
//if (option_mask & OPT_outfile) // -O
diff --git a/util-linux/dmesg.c b/util-linux/dmesg.c
index 682c4f696..277415a2d 100644
--- a/util-linux/dmesg.c
+++ b/util-linux/dmesg.c
@@ -16,7 +16,7 @@
int dmesg_main(int argc, char *argv[])
{
char *size, *level;
- int flags = bb_getopt_ulflags(argc, argv, "cs:n:", &size, &level);
+ int flags = getopt32(argc, argv, "cs:n:", &size, &level);
if (flags & 4) {
if (klogctl(8, NULL, bb_xgetlarg(level, 10, 0, 10)))
diff --git a/util-linux/fdformat.c b/util-linux/fdformat.c
index 9b97e6873..0242d8d3a 100644
--- a/util-linux/fdformat.c
+++ b/util-linux/fdformat.c
@@ -63,7 +63,7 @@ int fdformat_main(int argc,char **argv)
if (argc < 2) {
bb_show_usage();
}
- verify = !bb_getopt_ulflags(argc, argv, "n");
+ verify = !getopt32(argc, argv, "n");
argv += optind;
xstat(*argv, &st);
diff --git a/util-linux/getopt.c b/util-linux/getopt.c
index a4968b72e..02bb218b3 100644
--- a/util-linux/getopt.c
+++ b/util-linux/getopt.c
@@ -184,7 +184,7 @@ enum { LONG_OPTIONS_INCR = 10 };
#define init_longopt() add_longopt(NULL,0)
/* Register a long option. The contents of name is copied. */
-void add_longopt(const char *name,int has_arg)
+void add_longopt(const char *name, int has_arg)
{
if (!name) { /* init */
free(long_options);
diff --git a/util-linux/hwclock.c b/util-linux/hwclock.c
index e1a67f290..cce31335e 100644
--- a/util-linux/hwclock.c
+++ b/util-linux/hwclock.c
@@ -182,7 +182,7 @@ static int check_utc(void)
int hwclock_main ( int argc, char **argv )
{
- unsigned long opt;
+ unsigned opt;
int utc;
#if ENABLE_FEATURE_HWCLOCK_LONG_OPTIONS
@@ -194,11 +194,11 @@ static const struct option hwclock_long_options[] = {
{ "systohc", 0, 0, 'w' },
{ 0, 0, 0, 0 }
};
- bb_applet_long_options = hwclock_long_options;
+ applet_long_options = hwclock_long_options;
#endif
- bb_opt_complementally = "?:r--ws:w--rs:s--wr:l--u:u--l";
- opt = bb_getopt_ulflags(argc, argv, "lursw");
+ opt_complementary = "?:r--ws:w--rs:s--wr:l--u:u--l";
+ opt = getopt32(argc, argv, "lursw");
/* If -u or -l wasn't given check if we are using utc */
if (opt & (HWCLOCK_OPT_UTC | HWCLOCK_OPT_LOCALTIME))
diff --git a/util-linux/ipcs.c b/util-linux/ipcs.c
index 857065983..5e58e81da 100644
--- a/util-linux/ipcs.c
+++ b/util-linux/ipcs.c
@@ -572,14 +572,14 @@ int ipcs_main(int argc, char **argv)
{
int id = 0;
unsigned flags = 0;
- unsigned long opt;
+ unsigned opt;
char *opt_i;
#define flag_print (1<<0)
#define flag_msg (1<<1)
#define flag_sem (1<<2)
#define flag_shm (1<<3)
- opt = bb_getopt_ulflags(argc, argv, "i:aqsmtcplu", &opt_i);
+ opt = getopt32(argc, argv, "i:aqsmtcplu", &opt_i);
if (opt & 0x1) { // -i
id = atoi(opt_i);
flags |= flag_print;
diff --git a/util-linux/losetup.c b/util-linux/losetup.c
index 54a160119..8882ee4da 100644
--- a/util-linux/losetup.c
+++ b/util-linux/losetup.c
@@ -14,11 +14,11 @@
int losetup_main(int argc, char **argv)
{
- unsigned long opt;
+ unsigned opt;
char *opt_o;
int offset = 0;
- opt = bb_getopt_ulflags(argc, argv, "do:", &opt_o);
+ opt = getopt32(argc, argv, "do:", &opt_o);
argc -= optind;
argv += optind;
diff --git a/util-linux/mount.c b/util-linux/mount.c
index 565dccd9a..899bf8557 100644
--- a/util-linux/mount.c
+++ b/util-linux/mount.c
@@ -1428,7 +1428,7 @@ int mount_main(int argc, char **argv)
const char *fstabname;
FILE *fstab;
int i, j, rc = 0;
- unsigned long opt;
+ unsigned opt;
struct mntent mtpair[2], *mtcur = mtpair;
/* parse long options, like --bind and --move. Note that -o option
@@ -1444,7 +1444,7 @@ int mount_main(int argc, char **argv)
// Parse remaining options
- opt = bb_getopt_ulflags(argc, argv, "o:t:rwanfvs", &opt_o, &fstype);
+ opt = getopt32(argc, argv, "o:t:rwanfvs", &opt_o, &fstype);
if (opt & 0x1) append_mount_options(&cmdopts, opt_o); // -o
//if (opt & 0x2) // -t
if (opt & 0x4) append_mount_options(&cmdopts, "ro"); // -r
diff --git a/util-linux/rdate.c b/util-linux/rdate.c
index c740a691e..c24465dc3 100644
--- a/util-linux/rdate.c
+++ b/util-linux/rdate.c
@@ -63,8 +63,8 @@ int rdate_main(int argc, char **argv)
time_t remote_time;
unsigned long flags;
- bb_opt_complementally = "-1";
- flags = bb_getopt_ulflags(argc, argv, "sp");
+ opt_complementary = "-1";
+ flags = getopt32(argc, argv, "sp");
remote_time = askremotedate(argv[optind]);
diff --git a/util-linux/readprofile.c b/util-linux/readprofile.c
index 29e9f3e42..ff70bf79b 100644
--- a/util-linux/readprofile.c
+++ b/util-linux/readprofile.c
@@ -64,8 +64,8 @@ int readprofile_main(int argc, char **argv)
proFile = defaultpro;
mapFile = defaultmap;
- bb_opt_complementally = "nn:aa:bb:ss:ii:rr:vv";
- bb_getopt_ulflags(argc, argv, "M:m:p:nabsirv",
+ opt_complementary = "nn:aa:bb:ss:ii:rr:vv";
+ getopt32(argc, argv, "M:m:p:nabsirv",
&mult, &mapFile, &proFile,
&optNative, &optAll, &optBins, &optSub,
&optInfo, &optReset, &optVerbose);
diff --git a/util-linux/swaponoff.c b/util-linux/swaponoff.c
index ab754848e..4fcb239b6 100644
--- a/util-linux/swaponoff.c
+++ b/util-linux/swaponoff.c
@@ -66,7 +66,7 @@ int swap_on_off_main(int argc, char **argv)
if (argc == 1)
bb_show_usage();
- ret = bb_getopt_ulflags(argc, argv, "a");
+ ret = getopt32(argc, argv, "a");
if (ret & DO_ALL)
return do_em_all();
diff --git a/util-linux/switch_root.c b/util-linux/switch_root.c
index 1a599073e..f2d9b6e69 100644
--- a/util-linux/switch_root.c
+++ b/util-linux/switch_root.c
@@ -71,8 +71,8 @@ int switch_root_main(int argc, char *argv[])
// Parse args (-c console)
- bb_opt_complementally="-2";
- bb_getopt_ulflags(argc,argv,"c:",&console);
+ opt_complementary="-2";
+ getopt32(argc,argv,"c:",&console);
// Change to new root directory and verify it's a different fs.
diff --git a/util-linux/umount.c b/util-linux/umount.c
index e4308e547..9c551f986 100644
--- a/util-linux/umount.c
+++ b/util-linux/umount.c
@@ -27,7 +27,7 @@ int umount_main(int argc, char **argv)
struct mntent me;
FILE *fp;
int status = EXIT_SUCCESS;
- unsigned long opt;
+ unsigned opt;
struct mtab_list {
char *dir;
char *device;
@@ -36,7 +36,7 @@ int umount_main(int argc, char **argv)
/* Parse any options */
- opt = bb_getopt_ulflags(argc, argv, OPTION_STRING);
+ opt = getopt32(argc, argv, OPTION_STRING);
argc -= optind;
argv += optind;