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)
41int ar_main(int argc, char **argv) 41int ar_main(int argc, char **argv)
42{ 42{
43 archive_handle_t *archive_handle; 43 archive_handle_t *archive_handle;
44 unsigned long opt; 44 unsigned opt;
45 static const char msg_unsupported_err[] = 45 static const char msg_unsupported_err[] =
46 "Archive %s not supported. Install binutils 'ar'."; 46 "Archive %s not supported. Install binutils 'ar'.";
47 char magic[8]; 47 char magic[8];
@@ -49,8 +49,8 @@ int ar_main(int argc, char **argv)
49 archive_handle = init_handle(); 49 archive_handle = init_handle();
50 50
51 /* Prepend '-' to the first argument if required */ 51 /* Prepend '-' to the first argument if required */
52 bb_opt_complementally = "--:p:t:x:-1:?:p--tx:t--px:x--pt"; 52 opt_complementary = "--:p:t:x:-1:?:p--tx:t--px:x--pt";
53 opt = bb_getopt_ulflags(argc, argv, "ptxovcr"); 53 opt = getopt32(argc, argv, "ptxovcr");
54 54
55 if (opt & AR_CTX_PRINT) { 55 if (opt & AR_CTX_PRINT) {
56 archive_handle->action_data = data_extract_to_stdout; 56 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)
16{ 16{
17 USE_DESKTOP(long long) int status; 17 USE_DESKTOP(long long) int status;
18 char *filename; 18 char *filename;
19 unsigned long opt; 19 unsigned opt;
20 int src_fd, dst_fd; 20 int src_fd, dst_fd;
21 21
22 opt = bb_getopt_ulflags(argc, argv, "cf"); 22 opt = getopt32(argc, argv, "cf");
23 23
24 /* Set input filename and number */ 24 /* Set input filename and number */
25 filename = argv[optind]; 25 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)
30{ 30{
31 archive_handle_t *archive_handle; 31 archive_handle_t *archive_handle;
32 char *cpio_filename = NULL; 32 char *cpio_filename = NULL;
33 unsigned long opt; 33 unsigned opt;
34 34
35 /* Initialise */ 35 /* Initialise */
36 archive_handle = init_handle(); 36 archive_handle = init_handle();
@@ -38,7 +38,7 @@ int cpio_main(int argc, char **argv)
38 archive_handle->seek = seek_by_char; 38 archive_handle->seek = seek_by_char;
39 archive_handle->flags = ARCHIVE_EXTRACT_NEWER | ARCHIVE_PRESERVE_DATE; 39 archive_handle->flags = ARCHIVE_EXTRACT_NEWER | ARCHIVE_PRESERVE_DATE;
40 40
41 opt = bb_getopt_ulflags(argc, argv, "ituvF:dm", &cpio_filename); 41 opt = getopt32(argc, argv, "ituvF:dm", &cpio_filename);
42 42
43 /* One of either extract or test options must be given */ 43 /* One of either extract or test options must be given */
44 if ((opt & (CPIO_OPT_TEST | CPIO_OPT_EXTRACT)) == 0) { 44 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)
18 archive_handle_t *ar_archive; 18 archive_handle_t *ar_archive;
19 archive_handle_t *tar_archive; 19 archive_handle_t *tar_archive;
20 llist_t *control_tar_llist = NULL; 20 llist_t *control_tar_llist = NULL;
21 unsigned long opt; 21 unsigned opt;
22 char *extract_dir = NULL; 22 char *extract_dir = NULL;
23 short argcount = 1; 23 short argcount = 1;
24 24
@@ -40,8 +40,8 @@ int dpkg_deb_main(int argc, char **argv)
40 llist_add_to(&control_tar_llist, "control.tar.bz2"); 40 llist_add_to(&control_tar_llist, "control.tar.bz2");
41#endif 41#endif
42 42
43 bb_opt_complementally = "?c--efXx:e--cfXx:f--ceXx:X--cefx:x--cefX"; 43 opt_complementary = "?c--efXx:e--cfXx:f--ceXx:X--cefx:x--cefX";
44 opt = bb_getopt_ulflags(argc, argv, "cefXx"); 44 opt = getopt32(argc, argv, "cefXx");
45 45
46 if (opt & DPKG_DEB_OPT_CONTENTS) { 46 if (opt & DPKG_DEB_OPT_CONTENTS) {
47 tar_archive->action_header = header_verbose_list; 47 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)
40{ 40{
41 USE_DESKTOP(long long) int status; 41 USE_DESKTOP(long long) int status;
42 int exitcode = 0; 42 int exitcode = 0;
43 unsigned long opt; 43 unsigned opt;
44 44
45 opt = bb_getopt_ulflags(argc, argv, "cftdv"); 45 opt = getopt32(argc, argv, "cftdv");
46 /* if called as zcat */ 46 /* if called as zcat */
47 if (strcmp(bb_applet_name, "zcat") == 0) { 47 if (strcmp(bb_applet_name, "zcat") == 0) {
48 opt |= GUNZIP_OPT_STDOUT; 48 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)
1134 OPT_force = 0x2, 1134 OPT_force = 0x2,
1135 }; 1135 };
1136 1136
1137 unsigned long opt; 1137 unsigned opt;
1138 int result; 1138 int result;
1139 int inFileNum; 1139 int inFileNum;
1140 int outFileNum; 1140 int outFileNum;
1141 struct stat statBuf; 1141 struct stat statBuf;
1142 char *delFileName; 1142 char *delFileName;
1143 1143
1144 opt = bb_getopt_ulflags(argc, argv, "cf123456789qv" USE_GUNZIP("d")); 1144 opt = getopt32(argc, argv, "cf123456789qv" USE_GUNZIP("d"));
1145 //if (opt & 0x1) // -c 1145 //if (opt & 0x1) // -c
1146 //if (opt & 0x2) // -f 1146 //if (opt & 0x2) // -f
1147 /* Ignore 1-9 (compression level) options */ 1147 /* Ignore 1-9 (compression level) options */
@@ -1157,7 +1157,7 @@ int gzip_main(int argc, char **argv)
1157 //if (opt & 0x800) // -q 1157 //if (opt & 0x800) // -q
1158 //if (opt & 0x1000) // -v 1158 //if (opt & 0x1000) // -v
1159 if (ENABLE_GUNZIP && (opt & 0x2000)) { // -d 1159 if (ENABLE_GUNZIP && (opt & 0x2000)) { // -d
1160 /* FIXME: bb_getopt_ulflags should not depend on optind */ 1160 /* FIXME: getopt32 should not depend on optind */
1161 optind = 1; 1161 optind = 1;
1162 return gunzip_main(argc, argv); 1162 return gunzip_main(argc, argv);
1163 } 1163 }
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)
688 archive_handle_t *tar_handle; 688 archive_handle_t *tar_handle;
689 char *base_dir = NULL; 689 char *base_dir = NULL;
690 const char *tar_filename = "-"; 690 const char *tar_filename = "-";
691 unsigned long opt; 691 unsigned opt;
692 llist_t *excludes = NULL; 692 llist_t *excludes = NULL;
693 693
694 /* Initialise default values */ 694 /* Initialise default values */
@@ -696,12 +696,12 @@ int tar_main(int argc, char **argv)
696 tar_handle->flags = ARCHIVE_CREATE_LEADING_DIRS | ARCHIVE_PRESERVE_DATE | ARCHIVE_EXTRACT_UNCONDITIONAL; 696 tar_handle->flags = ARCHIVE_CREATE_LEADING_DIRS | ARCHIVE_PRESERVE_DATE | ARCHIVE_EXTRACT_UNCONDITIONAL;
697 697
698 /* Prepend '-' to the first argument if required */ 698 /* Prepend '-' to the first argument if required */
699 bb_opt_complementally = ENABLE_FEATURE_TAR_CREATE ? 699 opt_complementary = ENABLE_FEATURE_TAR_CREATE ?
700 "--:X::T::\n::c:t:x:?:c--tx:t--cx:x--ct" : 700 "--:X::T::\n::c:t:x:?:c--tx:t--cx:x--ct" :
701 "--:X::T::\n::t:x:?:t--x:x--t"; 701 "--:X::T::\n::t:x:?:t--x:x--t";
702 if (ENABLE_FEATURE_TAR_LONG_OPTIONS) 702 if (ENABLE_FEATURE_TAR_LONG_OPTIONS)
703 bb_applet_long_options = tar_long_options; 703 applet_long_options = tar_long_options;
704 opt = bb_getopt_ulflags(argc, argv, tar_options, 704 opt = getopt32(argc, argv, tar_options,
705 &base_dir, /* Change to dir <optarg> */ 705 &base_dir, /* Change to dir <optarg> */
706 &tar_filename /* archive filename */ 706 &tar_filename /* archive filename */
707#ifdef CONFIG_FEATURE_TAR_FROM 707#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)
16 int status = EXIT_SUCCESS; 16 int status = EXIT_SUCCESS;
17 unsigned long flags; 17 unsigned long flags;
18 18
19 flags = bb_getopt_ulflags(argc, argv, "cf"); 19 flags = getopt32(argc, argv, "cf");
20 20
21 while (optind < argc) { 21 while (optind < argc) {
22 char *compressed_file = argv[optind++]; 22 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)
19{ 19{
20 USE_DESKTOP(long long) int status; 20 USE_DESKTOP(long long) int status;
21 char *filename; 21 char *filename;
22 unsigned long opt; 22 unsigned opt;
23 int src_fd, dst_fd; 23 int src_fd, dst_fd;
24 24
25 opt = bb_getopt_ulflags(argc, argv, "c"); 25 opt = getopt32(argc, argv, "c");
26 26
27 /* Set input filename and number */ 27 /* Set input filename and number */
28 filename = argv[optind]; 28 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)
24 const char *device = CURRENT_TTY; 24 const char *device = CURRENT_TTY;
25 25
26#if ENABLE_FEATURE_SETCONSOLE_LONG_OPTIONS 26#if ENABLE_FEATURE_SETCONSOLE_LONG_OPTIONS
27 bb_applet_long_options = setconsole_long_options; 27 applet_long_options = setconsole_long_options;
28#endif 28#endif
29 flags = bb_getopt_ulflags(argc, argv, "r"); 29 flags = getopt32(argc, argv, "r");
30 30
31 if (argc - optind > 1) 31 if (argc - optind > 1)
32 bb_show_usage(); 32 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)
91 setlocale(LC_TIME, ""); 91 setlocale(LC_TIME, "");
92#endif 92#endif
93 93
94 flags = bb_getopt_ulflags(argc, argv, "jy"); 94 flags = getopt32(argc, argv, "jy");
95 95
96 julian = flags & 1; 96 julian = flags & 1;
97 97
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)
18 FILE *f; 18 FILE *f;
19 int retval = EXIT_SUCCESS; 19 int retval = EXIT_SUCCESS;
20 20
21 bb_getopt_ulflags(argc, argv, "u"); 21 getopt32(argc, argv, "u");
22 22
23 argv += optind; 23 argv += optind;
24 if (!*argv) { 24 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)
17 int retval = EXIT_SUCCESS, fd; 17 int retval = EXIT_SUCCESS, fd;
18 unsigned long flags; 18 unsigned long flags;
19 19
20 flags = bb_getopt_ulflags(argc, argv, "etv"); 20 flags = getopt32(argc, argv, "etv");
21#define CATV_OPT_e (1<<0) 21#define CATV_OPT_e (1<<0)
22#define CATV_OPT_t (1<<1) 22#define CATV_OPT_t (1<<1)
23#define CATV_OPT_v (1<<2) 23#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)
31 int recursiveFlag; 31 int recursiveFlag;
32 int retval = EXIT_SUCCESS; 32 int retval = EXIT_SUCCESS;
33 33
34 recursiveFlag = bb_getopt_ulflags(argc, argv, "R"); 34 recursiveFlag = getopt32(argc, argv, "R");
35 35
36 if (argc - optind < 2) { 36 if (argc - optind < 2) {
37 bb_show_usage(); 37 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)
43 int retval = EXIT_SUCCESS; 43 int retval = EXIT_SUCCESS;
44 char *groupName; 44 char *groupName;
45 45
46 flags = bb_getopt_ulflags(argc, argv, "Rh"); 46 flags = getopt32(argc, argv, "Rh");
47 47
48 if (flags & FLAG_h) chown_func = lchown; 48 if (flags & FLAG_h) chown_func = lchown;
49 49
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)
54 54
55 xfunc_error_retval = 2; /* 1 is returned if files are different. */ 55 xfunc_error_retval = 2; /* 1 is returned if files are different. */
56 56
57 opt = bb_getopt_ulflags(argc, argv, opt_chars); 57 opt = getopt32(argc, argv, opt_chars);
58 58
59 if (((opt & (CMP_OPT_s|CMP_OPT_l)) == (CMP_OPT_s|CMP_OPT_l)) 59 if (((opt & (CMP_OPT_s|CMP_OPT_l)) == (CMP_OPT_s|CMP_OPT_l))
60 || (((unsigned int)(--argc - optind)) > 1)) 60 || (((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)
112{ 112{
113 unsigned long flags; 113 unsigned long flags;
114 114
115 flags = bb_getopt_ulflags(argc, argv, "123"); 115 flags = getopt32(argc, argv, "123");
116 116
117 if (optind + 2 != argc) 117 if (optind + 2 != argc)
118 bb_show_usage(); 118 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)
39 int flags; 39 int flags;
40 int status = 0; 40 int status = 0;
41 41
42 flags = bb_getopt_ulflags(argc, argv, "pdRfiarPHL"); 42 flags = getopt32(argc, argv, "pdRfiarPHL");
43 43
44 if (flags & 32) { 44 if (flags & 32) {
45 flags |= (FILEUTILS_PRESERVE_STATUS | FILEUTILS_RECUR | FILEUTILS_DEREFERENCE); 45 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 @@
12#include "busybox.h" 12#include "busybox.h"
13 13
14/* option vars */ 14/* option vars */
15static const char *const optstring = "b:c:f:d:sn"; 15static const char optstring[] = "b:c:f:d:sn";
16
17#define CUT_OPT_BYTE_FLGS (1<<0) 16#define CUT_OPT_BYTE_FLGS (1<<0)
18#define CUT_OPT_CHAR_FLGS (1<<1) 17#define CUT_OPT_CHAR_FLGS (1<<1)
19#define CUT_OPT_FIELDS_FLGS (1<<2) 18#define CUT_OPT_FIELDS_FLGS (1<<2)
20#define CUT_OPT_DELIM_FLGS (1<<3) 19#define CUT_OPT_DELIM_FLGS (1<<3)
21#define CUT_OPT_SUPPRESS_FLGS (1<<4) 20#define CUT_OPT_SUPPRESS_FLGS (1<<4)
22static unsigned long opt; 21static unsigned opt;
23 22
24static char delim = '\t'; /* delimiter, default is tab */ 23static char delim = '\t'; /* delimiter, default is tab */
25 24
@@ -179,9 +178,8 @@ int cut_main(int argc, char **argv)
179{ 178{
180 char *sopt, *ltok; 179 char *sopt, *ltok;
181 180
182 bb_opt_complementally = "b--bcf:c--bcf:f--bcf"; 181 opt_complementary = "b--bcf:c--bcf:f--bcf";
183 opt = 182 opt = getopt32(argc, argv, optstring, &sopt, &sopt, &sopt, &ltok);
184 bb_getopt_ulflags(argc, argv, optstring, &sopt, &sopt, &sopt, &ltok);
185 if (!(opt & (CUT_OPT_BYTE_FLGS | CUT_OPT_CHAR_FLGS | CUT_OPT_FIELDS_FLGS))) 183 if (!(opt & (CUT_OPT_BYTE_FLGS | CUT_OPT_CHAR_FLGS | CUT_OPT_FIELDS_FLGS)))
186 bb_error_msg_and_die 184 bb_error_msg_and_die
187 ("expected a list of bytes, characters, or fields"); 185 ("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)
42{ 42{
43 time_t tm; 43 time_t tm;
44 struct tm tm_time; 44 struct tm tm_time;
45 unsigned long opt; 45 unsigned opt;
46 int ifmt = -1; 46 int ifmt = -1;
47 char *date_str = NULL; 47 char *date_str = NULL;
48 char *date_fmt = NULL; 48 char *date_fmt = NULL;
@@ -50,9 +50,9 @@ int date_main(int argc, char **argv)
50 char *isofmt_arg; 50 char *isofmt_arg;
51 char *hintfmt_arg; 51 char *hintfmt_arg;
52 52
53 bb_opt_complementally = "?:d--s:s--d" 53 opt_complementary = "?:d--s:s--d"
54 USE_FEATURE_DATE_ISOFMT(":R--I:I--R"); 54 USE_FEATURE_DATE_ISOFMT(":R--I:I--R");
55 opt = bb_getopt_ulflags(argc, argv, "Rs:ud:r:" 55 opt = getopt32(argc, argv, "Rs:ud:r:"
56 USE_FEATURE_DATE_ISOFMT("I::D:"), 56 USE_FEATURE_DATE_ISOFMT("I::D:"),
57 &date_str, &date_str, &filename 57 &date_str, &date_str, &filename
58 USE_FEATURE_DATE_ISOFMT(, &isofmt_arg, &hintfmt_arg)); 58 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)
41 unsigned long df_disp_hr = KILOBYTE; 41 unsigned long df_disp_hr = KILOBYTE;
42#endif 42#endif
43 int status = EXIT_SUCCESS; 43 int status = EXIT_SUCCESS;
44 unsigned long opt; 44 unsigned opt;
45 FILE *mount_table; 45 FILE *mount_table;
46 struct mntent *mount_entry; 46 struct mntent *mount_entry;
47 struct statfs s; 47 struct statfs s;
@@ -49,8 +49,8 @@ int df_main(int argc, char **argv)
49 const char *disp_units_hdr = hdr_1k; 49 const char *disp_units_hdr = hdr_1k;
50 50
51#ifdef CONFIG_FEATURE_HUMAN_READABLE 51#ifdef CONFIG_FEATURE_HUMAN_READABLE
52 bb_opt_complementally = "h-km:k-hm:m-hk"; 52 opt_complementary = "h-km:k-hm:m-hk";
53 opt = bb_getopt_ulflags(argc, argv, "hmk"); 53 opt = getopt32(argc, argv, "hmk");
54 if(opt & 1) { 54 if(opt & 1) {
55 df_disp_hr = 0; 55 df_disp_hr = 0;
56 disp_units_hdr = " Size"; 56 disp_units_hdr = " Size";
@@ -60,7 +60,7 @@ int df_main(int argc, char **argv)
60 disp_units_hdr = "1M-blocks"; 60 disp_units_hdr = "1M-blocks";
61 } 61 }
62#else 62#else
63 opt = bb_getopt_ulflags(argc, argv, "k"); 63 opt = getopt32(argc, argv, "k");
64#endif 64#endif
65 65
66 bb_printf("Filesystem%11s%-15sUsed Available Use%% Mounted on\n", 66 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)
1164 char *U_opt; 1164 char *U_opt;
1165 llist_t *L_arg = NULL; 1165 llist_t *L_arg = NULL;
1166 1166
1167 bb_opt_complementally = "L::"; 1167 opt_complementary = "L::";
1168 cmd_flags = 1168 cmd_flags =
1169 bb_getopt_ulflags(argc, argv, "abdiL:NqrsS:tTU:wu", &L_arg, &start, 1169 getopt32(argc, argv, "abdiL:NqrsS:tTU:wu", &L_arg, &start,
1170 &U_opt); 1170 &U_opt);
1171 1171
1172 if (cmd_flags & FLAG_L) { 1172 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[])
93 ConvType = CT_UNIX2DOS; /*1 */ 93 ConvType = CT_UNIX2DOS; /*1 */
94 } 94 }
95 /* -u and -d are mutally exclusive */ 95 /* -u and -d are mutally exclusive */
96 bb_opt_complementally = "?:u--d:d--u"; 96 opt_complementary = "?:u--d:d--u";
97 /* process parameters */ 97 /* process parameters */
98 /* -u convert to unix */ 98 /* -u convert to unix */
99 /* -d convert to dos */ 99 /* -d convert to dos */
100 o = bb_getopt_ulflags(argc, argv, "du"); 100 o = getopt32(argc, argv, "du");
101 101
102 /* Do the conversion requested by an argument else do the default 102 /* Do the conversion requested by an argument else do the default
103 * conversion depending on our name. */ 103 * 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)
153 int slink_depth_save; 153 int slink_depth_save;
154 int print_final_total; 154 int print_final_total;
155 char *smax_print_depth; 155 char *smax_print_depth;
156 unsigned long opt; 156 unsigned opt;
157 157
158#ifdef CONFIG_FEATURE_DU_DEFUALT_BLOCKSIZE_1K 158#ifdef CONFIG_FEATURE_DU_DEFUALT_BLOCKSIZE_1K
159 if (getenv("POSIXLY_CORRECT")) { /* TODO - a new libbb function? */ 159 if (getenv("POSIXLY_CORRECT")) { /* TODO - a new libbb function? */
@@ -172,8 +172,8 @@ int du_main(int argc, char **argv)
172 * ignore -a. This is consistent with -s being equivalent to -d 0. 172 * ignore -a. This is consistent with -s being equivalent to -d 0.
173 */ 173 */
174#ifdef CONFIG_FEATURE_HUMAN_READABLE 174#ifdef CONFIG_FEATURE_HUMAN_READABLE
175 bb_opt_complementally = "h-km:k-hm:m-hk:H-L:L-H:s-d:d-s"; 175 opt_complementary = "h-km:k-hm:m-hk:H-L:L-H:s-d:d-s";
176 opt = bb_getopt_ulflags(argc, argv, "aHkLsx" "d:" "lc" "hm", &smax_print_depth); 176 opt = getopt32(argc, argv, "aHkLsx" "d:" "lc" "hm", &smax_print_depth);
177 if((opt & (1 << 9))) { 177 if((opt & (1 << 9))) {
178 /* -h opt */ 178 /* -h opt */
179 disp_hr = 0; 179 disp_hr = 0;
@@ -187,8 +187,8 @@ int du_main(int argc, char **argv)
187 disp_hr = KILOBYTE; 187 disp_hr = KILOBYTE;
188 } 188 }
189#else 189#else
190 bb_opt_complementally = "H-L:L-H:s-d:d-s"; 190 opt_complementary = "H-L:L-H:s-d:d-s";
191 opt = bb_getopt_ulflags(argc, argv, "aHkLsx" "d:" "lc", &smax_print_depth); 191 opt = getopt32(argc, argv, "aHkLsx" "d:" "lc", &smax_print_depth);
192#if !defined CONFIG_FEATURE_DU_DEFAULT_BLOCKSIZE_1K 192#if !defined CONFIG_FEATURE_DU_DEFAULT_BLOCKSIZE_1K
193 if((opt & (1 << 2))) { 193 if((opt & (1 << 2))) {
194 /* -k opt */ 194 /* -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)
46 static char *cleanenv[1] = { NULL }; 46 static char *cleanenv[1] = { NULL };
47 47
48 char **ep; 48 char **ep;
49 unsigned long opt; 49 unsigned opt;
50 llist_t *unset_env = NULL; 50 llist_t *unset_env = NULL;
51 extern char **environ; 51 extern char **environ;
52 52
53 bb_opt_complementally = "u::"; 53 opt_complementary = "u::";
54#if ENABLE_FEATURE_ENV_LONG_OPTIONS 54#if ENABLE_FEATURE_ENV_LONG_OPTIONS
55 bb_applet_long_options = env_long_options; 55 applet_long_options = env_long_options;
56#endif 56#endif
57 57
58 opt = bb_getopt_ulflags(argc, argv, "+iu:", &unset_env); 58 opt = getopt32(argc, argv, "+iu:", &unset_env);
59 59
60 argv += optind; 60 argv += optind;
61 if (*argv && (argv[0][0] == '-') && !argv[0][1]) { 61 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)
60 } 60 }
61 } 61 }
62 62
63 flags = bb_getopt_ulflags(argc, argv, "bsw:", &w_opt); 63 flags = getopt32(argc, argv, "bsw:", &w_opt);
64 if (flags & FLAG_WIDTH) 64 if (flags & FLAG_WIDTH)
65 width = bb_xgetlarg(w_opt, 10, 1, 10000); 65 width = bb_xgetlarg(w_opt, 10, 1, 10000);
66 66
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)
60 } 60 }
61#endif 61#endif
62 62
63 /* No size benefit in converting this to bb_getopt_ulflags */ 63 /* No size benefit in converting this to getopt32 */
64 while ((opt = getopt(argc, argv, head_opts)) > 0) { 64 while ((opt = getopt(argc, argv, head_opts)) > 0) {
65 switch (opt) { 65 switch (opt) {
66#if ENABLE_FEATURE_FANCY_HEAD 66#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)
50 50
51 /* Don't allow -n -r -nr -ug -rug -nug -rnug */ 51 /* Don't allow -n -r -nr -ug -rug -nug -rnug */
52 /* Don't allow more than one username */ 52 /* Don't allow more than one username */
53 bb_opt_complementally = "?1:?:u--g:g--u:r?ug:n?ug"; 53 opt_complementary = "?1:?:u--g:g--u:r?ug:n?ug";
54 flags = bb_getopt_ulflags(argc, argv, "rnug"); 54 flags = getopt32(argc, argv, "rnug");
55 55
56 /* This values could be overwritten later */ 56 /* This values could be overwritten later */
57 uid = geteuid(); 57 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)
45 int ret = EXIT_SUCCESS, flags, i, isdir; 45 int ret = EXIT_SUCCESS, flags, i, isdir;
46 46
47#if ENABLE_FEATURE_INSTALL_LONG_OPTIONS 47#if ENABLE_FEATURE_INSTALL_LONG_OPTIONS
48 bb_applet_long_options = install_long_options; 48 applet_long_options = install_long_options;
49#endif 49#endif
50 bb_opt_complementally = "?:s--d:d--s"; 50 opt_complementary = "?:s--d:d--s";
51 /* -c exists for backwards compatibility, its needed */ 51 /* -c exists for backwards compatibility, its needed */
52 flags = bb_getopt_ulflags(argc, argv, "cdpsg:m:o:", &gid_str, &mode_str, &uid_str); /* 'a' must be 2nd */ 52 flags = getopt32(argc, argv, "cdpsg:m:o:", &gid_str, &mode_str, &uid_str); /* 'a' must be 2nd */
53 53
54 /* preserve access and modification time, this is GNU behaviour, BSD only preserves modification time */ 54 /* preserve access and modification time, this is GNU behaviour, BSD only preserves modification time */
55 if (flags & INSTALL_OPT_PRESERVE_TIME) { 55 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)
31 mode_t mode = 0666; 31 mode_t mode = 0666;
32 char *smode = NULL; 32 char *smode = NULL;
33 33
34 bb_getopt_ulflags(argc, argv, "m:", &smode); 34 getopt32(argc, argv, "m:", &smode);
35 if(smode) { 35 if(smode) {
36 if (bb_parse_mode(smode, &mode)) 36 if (bb_parse_mode(smode, &mode))
37 umask(0); 37 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)
30 struct stat statbuf; 30 struct stat statbuf;
31 int (*link_func)(const char *, const char *); 31 int (*link_func)(const char *, const char *);
32 32
33 flag = bb_getopt_ulflags(argc, argv, "sfnbS:", &suffix); 33 flag = getopt32(argc, argv, "sfnbS:", &suffix);
34 34
35 if (argc == optind) { 35 if (argc == optind) {
36 bb_show_usage(); 36 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)
877 struct dnode **dnp; 877 struct dnode **dnp;
878 struct dnode *dn; 878 struct dnode *dn;
879 struct dnode *cur; 879 struct dnode *cur;
880 long opt; 880 unsigned opt;
881 int nfiles = 0; 881 int nfiles = 0;
882 int dnfiles; 882 int dnfiles;
883 int dndirs; 883 int dndirs;
@@ -904,12 +904,12 @@ int ls_main(int argc, char **argv)
904#endif 904#endif
905 905
906#ifdef CONFIG_FEATURE_LS_COLOR 906#ifdef CONFIG_FEATURE_LS_COLOR
907 bb_applet_long_options = ls_color_opt; 907 applet_long_options = ls_color_opt;
908#endif 908#endif
909 909
910 /* process options */ 910 /* process options */
911#ifdef CONFIG_FEATURE_AUTOWIDTH 911#ifdef CONFIG_FEATURE_AUTOWIDTH
912 opt = bb_getopt_ulflags(argc, argv, ls_options, &tabstops_str, &terminal_width_str 912 opt = getopt32(argc, argv, ls_options, &tabstops_str, &terminal_width_str
913#ifdef CONFIG_FEATURE_LS_COLOR 913#ifdef CONFIG_FEATURE_LS_COLOR
914 , &color_opt 914 , &color_opt
915#endif 915#endif
@@ -921,7 +921,7 @@ int ls_main(int argc, char **argv)
921 terminal_width = atoi(terminal_width_str); 921 terminal_width = atoi(terminal_width_str);
922 } 922 }
923#else 923#else
924 opt = bb_getopt_ulflags(argc, argv, ls_options 924 opt = getopt32(argc, argv, ls_options
925#ifdef CONFIG_FEATURE_LS_COLOR 925#ifdef CONFIG_FEATURE_LS_COLOR
926 , &color_opt 926 , &color_opt
927#endif 927#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)
91 : HASH_SHA1; 91 : HASH_SHA1;
92 92
93 if (ENABLE_FEATURE_MD5_SHA1_SUM_CHECK) 93 if (ENABLE_FEATURE_MD5_SHA1_SUM_CHECK)
94 flags = bb_getopt_ulflags(argc, argv, "scw"); 94 flags = getopt32(argc, argv, "scw");
95 else optind = 1; 95 else optind = 1;
96 96
97 if (ENABLE_FEATURE_MD5_SHA1_SUM_CHECK && !(flags & FLAG_CHECK)) { 97 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)
34 mode_t mode = (mode_t)(-1); 34 mode_t mode = (mode_t)(-1);
35 int status = EXIT_SUCCESS; 35 int status = EXIT_SUCCESS;
36 int flags = 0; 36 int flags = 0;
37 unsigned long opt; 37 unsigned opt;
38 char *smode; 38 char *smode;
39 39
40#if ENABLE_FEATURE_MKDIR_LONG_OPTIONS 40#if ENABLE_FEATURE_MKDIR_LONG_OPTIONS
41 bb_applet_long_options = mkdir_long_options; 41 applet_long_options = mkdir_long_options;
42#endif 42#endif
43 opt = bb_getopt_ulflags(argc, argv, "m:p", &smode); 43 opt = getopt32(argc, argv, "m:p", &smode);
44 if(opt & 1) { 44 if(opt & 1) {
45 mode = 0777; 45 mode = 0777;
46 if (!bb_parse_mode (smode, &mode)) { 46 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)
45 int status = 0; 45 int status = 0;
46 46
47#if ENABLE_FEATURE_MV_LONG_OPTIONS 47#if ENABLE_FEATURE_MV_LONG_OPTIONS
48 bb_applet_long_options = mv_long_options; 48 applet_long_options = mv_long_options;
49#endif 49#endif
50 bb_opt_complementally = "f-i:i-f"; 50 opt_complementary = "f-i:i-f";
51 flags = bb_getopt_ulflags(argc, argv, "fi"); 51 flags = getopt32(argc, argv, "fi");
52 if (optind + 2 > argc) { 52 if (optind + 2 > argc) {
53 bb_show_usage(); 53 bb_show_usage();
54 } 54 }
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)
22{ 22{
23 int status = 0; 23 int status = 0;
24 int flags = 0; 24 int flags = 0;
25 unsigned long opt; 25 unsigned opt;
26 26
27 bb_opt_complementally = "f-i:i-f"; 27 opt_complementary = "f-i:i-f";
28 opt = bb_getopt_ulflags(argc, argv, "fiRr"); 28 opt = getopt32(argc, argv, "fiRr");
29 if(opt & 1) 29 if(opt & 1)
30 flags |= FILEUTILS_FORCE; 30 flags |= FILEUTILS_FORCE;
31 if(opt & 2) 31 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)
22 int do_dot; 22 int do_dot;
23 char *path; 23 char *path;
24 24
25 flags = bb_getopt_ulflags(argc, argv, "p"); 25 flags = getopt32(argc, argv, "p");
26 26
27 argv += optind; 27 argv += optind;
28 28
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)
516 int ok = 1; 516 int ok = 1;
517 int (*statfunc)(char const *, char const *) = do_stat; 517 int (*statfunc)(char const *, char const *) = do_stat;
518 518
519 flags = bb_getopt_ulflags(argc, argv, "ftL" 519 flags = getopt32(argc, argv, "ftL"
520 USE_FEATURE_STAT_FORMAT("c:", &format) 520 USE_FEATURE_STAT_FORMAT("c:", &format)
521 ); 521 );
522 522
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)
136 int (*sum_func)(const char *, int) = bsd_sum_file; 136 int (*sum_func)(const char *, int) = bsd_sum_file;
137 137
138 /* give the bsd func priority over sysv func */ 138 /* give the bsd func priority over sysv func */
139 flags = bb_getopt_ulflags(argc, argv, "sr"); 139 flags = getopt32(argc, argv, "sr");
140 if (flags & 1) 140 if (flags & 1)
141 sum_func = sysv_sum_file; 141 sum_func = sysv_sum_file;
142 if (flags & 2) 142 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)
28 int c; 28 int c;
29#endif 29#endif
30 30
31 flags = bb_getopt_ulflags(argc, argv, "ia"); /* 'a' must be 2nd */ 31 flags = getopt32(argc, argv, "ia"); /* 'a' must be 2nd */
32 32
33 mode += (flags & 2); /* Since 'a' is the 2nd option... */ 33 mode += (flags & 2); /* Since 'a' is the 2nd option... */
34 34
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)
32 int flags; 32 int flags;
33 int status = EXIT_SUCCESS; 33 int status = EXIT_SUCCESS;
34 34
35 flags = bb_getopt_ulflags(argc, argv, "c"); 35 flags = getopt32(argc, argv, "c");
36 36
37 argv += optind; 37 argv += optind;
38 38
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)
23 23
24 xfunc_error_retval = 2; /* SUSv3 requires > 1 for error. */ 24 xfunc_error_retval = 2; /* SUSv3 requires > 1 for error. */
25 25
26 silent = bb_getopt_ulflags(argc, argv, "s"); 26 silent = getopt32(argc, argv, "s");
27 27
28 /* gnu tty outputs a warning that it is ignoring all args. */ 28 /* gnu tty outputs a warning that it is ignoring all args. */
29 bb_warn_ignoring_args(argc - optind); 29 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)
63 const unsigned short int *delta; 63 const unsigned short int *delta;
64 char toprint; 64 char toprint;
65 65
66 toprint = bb_getopt_ulflags(argc, argv, options); 66 toprint = getopt32(argc, argv, options);
67 67
68 if (argc != optind) { 68 if (argc != optind) {
69 bb_show_usage(); 69 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)
129 char *outname = NULL; 129 char *outname = NULL;
130 char *line; 130 char *line;
131 131
132 bb_getopt_ulflags(argc, argv, "o:", &outname); 132 getopt32(argc, argv, "o:", &outname);
133 133
134 if (optind == argc) { 134 if (optind == argc) {
135 src_stream = stdin; 135 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)
27 RESERVE_CONFIG_BUFFER(dst_buf, DST_BUF_SIZE + 1); 27 RESERVE_CONFIG_BUFFER(dst_buf, DST_BUF_SIZE + 1);
28 28
29 tbl = bb_uuenc_tbl_std; 29 tbl = bb_uuenc_tbl_std;
30 if (bb_getopt_ulflags(argc, argv, "m") & 1) { 30 if (getopt32(argc, argv, "m") & 1) {
31 tbl = bb_uuenc_tbl_base64; 31 tbl = bb_uuenc_tbl_base64;
32 } 32 }
33 33
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)
87 char in_word; 87 char in_word;
88 unsigned print_type; 88 unsigned print_type;
89 89
90 print_type = bb_getopt_ulflags(argc, argv, "lwcL"); 90 print_type = getopt32(argc, argv, "lwcL");
91 91
92 if (print_type == 0) { 92 if (print_type == 0) {
93 print_type = (1 << WC_LINES) | (1 << WC_WORDS) | (1 << WC_CHARS); 93 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 @@
18 18
19int mktemp_main(int argc, char **argv) 19int mktemp_main(int argc, char **argv)
20{ 20{
21 unsigned long flags = bb_getopt_ulflags(argc, argv, "dq"); 21 unsigned long flags = getopt32(argc, argv, "dq");
22 22
23 if (optind + 1 != argc) 23 if (optind + 1 != argc)
24 bb_show_usage(); 24 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 @@
18int readlink_main(int argc, char **argv) 18int readlink_main(int argc, char **argv)
19{ 19{
20 char *buf; 20 char *buf;
21 unsigned long opt = ENABLE_FEATURE_READLINK_FOLLOW ? 21 unsigned opt = ENABLE_FEATURE_READLINK_FOLLOW ?
22 bb_getopt_ulflags(argc, argv, "f") : 0; 22 getopt32(argc, argv, "f") : 0;
23 23
24 if (argc != (ENABLE_FEATURE_READLINK_FOLLOW ? optind + 1 : 2)) 24 if (argc != (ENABLE_FEATURE_READLINK_FOLLOW ? optind + 1 : 2))
25 bb_show_usage(); 25 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[] = {
227 227
228int start_stop_daemon_main(int argc, char **argv) 228int start_stop_daemon_main(int argc, char **argv)
229{ 229{
230 unsigned long opt; 230 unsigned opt;
231 char *signame = NULL; 231 char *signame = NULL;
232 char *startas = NULL; 232 char *startas = NULL;
233#if ENABLE_FEATURE_START_STOP_DAEMON_FANCY 233#if ENABLE_FEATURE_START_STOP_DAEMON_FANCY
@@ -235,12 +235,12 @@ int start_stop_daemon_main(int argc, char **argv)
235// int retries = -1; 235// int retries = -1;
236#endif 236#endif
237#if ENABLE_FEATURE_START_STOP_DAEMON_LONG_OPTIONS 237#if ENABLE_FEATURE_START_STOP_DAEMON_LONG_OPTIONS
238 bb_applet_long_options = ssd_long_options; 238 applet_long_options = ssd_long_options;
239#endif 239#endif
240 240
241 /* Check required one context option was given */ 241 /* Check required one context option was given */
242 bb_opt_complementally = "K:S:?:K--S:S--K:m?p:K?xpun:S?xa"; 242 opt_complementary = "K:S:?:K--S:S--K:m?p:K?xpun:S?xa";
243 opt = bb_getopt_ulflags(argc, argv, "KSbqm" 243 opt = getopt32(argc, argv, "KSbqm"
244// USE_FEATURE_START_STOP_DAEMON_FANCY("ovR:") 244// USE_FEATURE_START_STOP_DAEMON_FANCY("ovR:")
245 USE_FEATURE_START_STOP_DAEMON_FANCY("ov") 245 USE_FEATURE_START_STOP_DAEMON_FANCY("ov")
246 "a:n:s:u:c:x:p:" 246 "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
567have to test the return value (xmalloc(), xstrdup(), etc), wrapped versions 567have to test the return value (xmalloc(), xstrdup(), etc), wrapped versions
568of open(), close(), read(), and write() that test for their own failures 568of open(), close(), read(), and write() that test for their own failures
569and/or retry automatically, linked list management functions (llist.c), 569and/or retry automatically, linked list management functions (llist.c),
570command line argument parsing (getopt_ulflags.c), and a whole lot more.</p> 570command line argument parsing (getopt32.c), and a whole lot more.</p>
571 571
572<hr /> 572<hr />
573<p> 573<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)
124{ 124{
125 int i; 125 int i;
126 126
127 flags = bb_getopt_ulflags(argc, argv, "Radlv"); 127 flags = getopt32(argc, argv, "Radlv");
128 128
129 if (optind > argc - 1) 129 if (optind > argc - 1)
130 lsattr_args("."); 130 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)
2634 2634
2635int awk_main(int argc, char **argv) 2635int awk_main(int argc, char **argv)
2636{ 2636{
2637 unsigned long opt; 2637 unsigned opt;
2638 char *opt_F, *opt_v, *opt_W; 2638 char *opt_F, *opt_v, *opt_W;
2639 char *s, *s1; 2639 char *s, *s1;
2640 int i, j, c, flen; 2640 int i, j, c, flen;
@@ -2691,7 +2691,7 @@ keep_going:
2691 free(s); 2691 free(s);
2692 } 2692 }
2693 2693
2694 opt = bb_getopt_ulflags(argc, argv, "F:v:f:W:", &opt_F, &opt_v, &programname, &opt_W); 2694 opt = getopt32(argc, argv, "F:v:f:W:", &opt_F, &opt_v, &programname, &opt_W);
2695 if (opt & 0x1) setvar_s(V[FS], opt_F); // -F 2695 if (opt & 0x1) setvar_s(V[FS], opt_F); // -F
2696 if (opt & 0x2) if (!is_assignment(opt_v)) bb_show_usage(); // -v 2696 if (opt & 0x2) if (!is_assignment(opt_v)) bb_show_usage(); // -v
2697 if (opt & 0x4) { // -f 2697 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)
85 85
86 { 86 {
87 char *p, *i; 87 char *p, *i;
88 ret = bb_getopt_ulflags(argc, argv, "p:i:", &p, &i); 88 ret = getopt32(argc, argv, "p:i:", &p, &i);
89 if (ret & 1) 89 if (ret & 1)
90 patch_level = bb_xgetlarg(p, 10, -1, USHRT_MAX); 90 patch_level = bb_xgetlarg(p, 10, -1, USHRT_MAX);
91 if (ret & 2) { 91 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)
1109 1109
1110int sed_main(int argc, char **argv) 1110int sed_main(int argc, char **argv)
1111{ 1111{
1112 unsigned long opt; 1112 unsigned opt;
1113 llist_t *opt_e, *opt_f; 1113 llist_t *opt_e, *opt_f;
1114 int status = EXIT_SUCCESS; 1114 int status = EXIT_SUCCESS;
1115 1115
@@ -1126,8 +1126,8 @@ int sed_main(int argc, char **argv)
1126 1126
1127 /* do normal option parsing */ 1127 /* do normal option parsing */
1128 opt_e = opt_f = NULL; 1128 opt_e = opt_f = NULL;
1129 bb_opt_complementally = "e::f::"; /* can occur multiple times */ 1129 opt_complementary = "e::f::"; /* can occur multiple times */
1130 opt = bb_getopt_ulflags(argc, argv, "irne:f:", &opt_e, &opt_f); 1130 opt = getopt32(argc, argv, "irne:f:", &opt_e, &opt_f);
1131 if (opt & 0x1) { // -i 1131 if (opt & 0x1) { // -i
1132 bbg.in_place++; 1132 bbg.in_place++;
1133 atexit(cleanup_outname); 1133 atexit(cleanup_outname);
@@ -1135,11 +1135,11 @@ int sed_main(int argc, char **argv)
1135 if (opt & 0x2) bbg.regex_type|=REG_EXTENDED; // -r 1135 if (opt & 0x2) bbg.regex_type|=REG_EXTENDED; // -r
1136 if (opt & 0x4) bbg.be_quiet++; // -n 1136 if (opt & 0x4) bbg.be_quiet++; // -n
1137 if (opt & 0x8) { // -e 1137 if (opt & 0x8) { // -e
1138 /* getopt_ulflags reverses order of arguments, handle it */ 1138 /* getopt32 reverses order of arguments, handle it */
1139 add_cmds_link(opt_e); 1139 add_cmds_link(opt_e);
1140 } 1140 }
1141 if (opt & 0x10) { // -f 1141 if (opt & 0x10) { // -f
1142 /* getopt_ulflags reverses order of arguments, handle it */ 1142 /* getopt32 reverses order of arguments, handle it */
1143 add_files_link(opt_f); 1143 add_files_link(opt_f);
1144 } 1144 }
1145 /* if we didn't get a pattern from -e or -f, use argv[optind] */ 1145 /* 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 @@
24 24
25 25
26/* options */ 26/* options */
27static unsigned long opt; 27static unsigned opt;
28#define GREP_OPTS "lnqvscFiHhe:f:Lo" 28#define GREP_OPTS "lnqvscFiHhe:f:Lo"
29#define GREP_OPT_l (1<<0) 29#define GREP_OPT_l (1<<0)
30#define PRINT_FILES_WITH_MATCHES (opt & GREP_OPT_l) 30#define PRINT_FILES_WITH_MATCHES (opt & GREP_OPT_l)
@@ -302,8 +302,8 @@ int grep_main(int argc, char **argv)
302 char *slines_before; 302 char *slines_before;
303 char *Copt; 303 char *Copt;
304 304
305 bb_opt_complementally = "H-h:e::f::C-AB"; 305 opt_complementary = "H-h:e::f::C-AB";
306 opt = bb_getopt_ulflags(argc, argv, 306 opt = getopt32(argc, argv,
307 GREP_OPTS GREP_OPT_CONTEXT OPT_EGREP, 307 GREP_OPTS GREP_OPT_CONTEXT OPT_EGREP,
308 &pattern_head, &fopt, 308 &pattern_head, &fopt,
309 &slines_after, &slines_before, &Copt); 309 &slines_after, &slines_before, &Copt);
@@ -336,8 +336,8 @@ int grep_main(int argc, char **argv)
336 before_buf = (char **)xzalloc(lines_before * sizeof(char *)); 336 before_buf = (char **)xzalloc(lines_before * sizeof(char *));
337#else 337#else
338 /* with auto sanity checks */ 338 /* with auto sanity checks */
339 bb_opt_complementally = "H-h:e::f::c-n:q-n:l-n"; 339 opt_complementary = "H-h:e::f::c-n:q-n:l-n";
340 opt = bb_getopt_ulflags(argc, argv, GREP_OPTS OPT_EGREP, 340 opt = getopt32(argc, argv, GREP_OPTS OPT_EGREP,
341 &pattern_head, &fopt); 341 &pattern_head, &fopt);
342#endif 342#endif
343 invert_search = (opt & GREP_OPT_v) != 0; /* 0 | 1 */ 343 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)
399 size_t n_chars = 0; 399 size_t n_chars = 0;
400 long orig_arg_max; 400 long orig_arg_max;
401 const char *eof_str = "_"; 401 const char *eof_str = "_";
402 unsigned long opt; 402 unsigned opt;
403 size_t n_max_chars; 403 size_t n_max_chars;
404#if ENABLE_FEATURE_XARGS_SUPPORT_ZERO_TERM 404#if ENABLE_FEATURE_XARGS_SUPPORT_ZERO_TERM
405 xlist_t* (*read_args)(xlist_t*, const char*, size_t, char*) = process_stdin; 405 xlist_t* (*read_args)(xlist_t*, const char*, size_t, char*) = process_stdin;
@@ -407,7 +407,7 @@ int xargs_main(int argc, char **argv)
407#define read_args process_stdin 407#define read_args process_stdin
408#endif 408#endif
409 409
410 opt = bb_getopt_ulflags(argc, argv, OPTION_STR, &max_args, &max_chars, &eof_str); 410 opt = getopt32(argc, argv, OPTION_STR, &max_args, &max_chars, &eof_str);
411 411
412 if (opt & OPT_ZEROTERM) 412 if (opt & OPT_ZEROTERM)
413 USE_FEATURE_XARGS_SUPPORT_ZERO_TERM(read_args = process0_stdin); 413 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);
207extern off_t fdlength(int fd); 207extern off_t fdlength(int fd);
208 208
209#define BB_GETOPT_ERROR 0x80000000UL 209#define BB_GETOPT_ERROR 0x80000000UL
210extern const char *bb_opt_complementally; 210extern const char *opt_complementary;
211extern const struct option *bb_applet_long_options; 211extern const struct option *applet_long_options;
212extern unsigned long bb_getopt_ulflags(int argc, char **argv, const char *applet_opts, ...); 212extern uint32_t getopt32(int argc, char **argv, const char *applet_opts, ...);
213 213
214extern int bb_vfprintf(FILE * __restrict stream, const char * __restrict format, 214extern int bb_vfprintf(FILE * __restrict stream, const char * __restrict format,
215 va_list arg) __attribute__ ((format (printf, 2, 0))); 215 va_list arg) __attribute__ ((format (printf, 2, 0)));
@@ -232,7 +232,7 @@ extern char *skip_whitespace(const char *);
232 232
233#ifndef BUILD_INDIVIDUAL 233#ifndef BUILD_INDIVIDUAL
234extern struct BB_applet *find_applet_by_name(const char *name); 234extern struct BB_applet *find_applet_by_name(const char *name);
235void run_applet_by_name(const char *name, int argc, char **argv); 235extern void run_applet_by_name(const char *name, int argc, char **argv);
236#endif 236#endif
237 237
238/* dmalloc will redefine these to it's own implementation. It is safe 238/* 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
34 for(which=0;delay[which]!=*bb_applet_name;which++); 34 for(which=0;delay[which]!=*bb_applet_name;which++);
35 35
36 /* Parse and handle arguments */ 36 /* Parse and handle arguments */
37 flags = bb_getopt_ulflags(argc, argv, "d:nf", &delay); 37 flags = getopt32(argc, argv, "d:nf", &delay);
38 if (flags&1) sleep(atoi(delay)); 38 if (flags&1) sleep(atoi(delay));
39 if (!(flags&2)) sync(); 39 if (!(flags&2)) sync();
40 40
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:= \
30 vherror_msg.c vperror_msg.c wfopen.c xconnect.c xgetcwd.c \ 30 vherror_msg.c vperror_msg.c wfopen.c xconnect.c xgetcwd.c \
31 xgethostbyname.c xgethostbyname2.c xreadlink.c xgetlarg.c \ 31 xgethostbyname.c xgethostbyname2.c xreadlink.c xgetlarg.c \
32 fclose_nonstdin.c fflush_stdout_and_exit.c \ 32 fclose_nonstdin.c fflush_stdout_and_exit.c \
33 getopt_ulflags.c default_error_retval.c wfopen_input.c speed_table.c \ 33 getopt32.c default_error_retval.c wfopen_input.c speed_table.c \
34 perror_nomsg_and_die.c perror_nomsg.c skip_whitespace.c bb_askpass.c \ 34 perror_nomsg_and_die.c perror_nomsg.c skip_whitespace.c bb_askpass.c \
35 warn_ignoring_args.c concat_subpath_file.c vfork_daemon_rexec.c \ 35 warn_ignoring_args.c concat_subpath_file.c vfork_daemon_rexec.c \
36 bb_do_delay.c 36 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 @@
1/* vi: set sw=4 ts=4: */ 1/* vi: set sw=4 ts=4: */
2/* 2/*
3 * universal getopt_ulflags implementation for busybox 3 * universal getopt32 implementation for busybox
4 * 4 *
5 * Copyright (C) 2003-2005 Vladimir Oleynik <dzo@simtreas.ru> 5 * Copyright (C) 2003-2005 Vladimir Oleynik <dzo@simtreas.ru>
6 * 6 *
@@ -12,13 +12,13 @@
12 12
13/* Documentation 13/* Documentation
14 14
15unsigned long 15uint32_t
16bb_getopt_ulflags(int argc, char **argv, const char *applet_opts, ...) 16getopt32(int argc, char **argv, const char *applet_opts, ...)
17 17
18 The command line options must be declared in const char 18 The command line options must be declared in const char
19 *applet_opts as a string of chars, for example: 19 *applet_opts as a string of chars, for example:
20 20
21 flags = bb_getopt_ulflags(argc, argv, "rnug"); 21 flags = getopt32(argc, argv, "rnug");
22 22
23 If one of the given options is found, a flag value is added to 23 If one of the given options is found, a flag value is added to
24 the return value (an unsigned long). 24 the return value (an unsigned long).
@@ -26,7 +26,7 @@ bb_getopt_ulflags(int argc, char **argv, const char *applet_opts, ...)
26 The flag value is determined by the position of the char in 26 The flag value is determined by the position of the char in
27 applet_opts string. For example, in the above case: 27 applet_opts string. For example, in the above case:
28 28
29 flags = bb_getopt_ulflags(argc, argv, "rnug"); 29 flags = getopt32(argc, argv, "rnug");
30 30
31 "r" will add 1 (bit 0) 31 "r" will add 1 (bit 0)
32 "n" will add 2 (bit 1) 32 "n" will add 2 (bit 1)
@@ -52,13 +52,13 @@ bb_getopt_ulflags(int argc, char **argv, const char *applet_opts, ...)
52 char *pointer_to_arg_for_c; 52 char *pointer_to_arg_for_c;
53 char *pointer_to_arg_for_d; 53 char *pointer_to_arg_for_d;
54 54
55 flags = bb_getopt_ulflags(argc, argv, "a:b:c:d:", 55 flags = getopt32(argc, argv, "a:b:c:d:",
56 &pointer_to_arg_for_a, &pointer_to_arg_for_b, 56 &pointer_to_arg_for_a, &pointer_to_arg_for_b,
57 &pointer_to_arg_for_c, &pointer_to_arg_for_d); 57 &pointer_to_arg_for_c, &pointer_to_arg_for_d);
58 58
59 The type of the pointer (char* or llist_t*) may be controlled 59 The type of the pointer (char* or llist_t*) may be controlled
60 by the "::" special separator that is set in the external string 60 by the "::" special separator that is set in the external string
61 bb_opt_complementally (see below for more info). 61 opt_complementary (see below for more info).
62 62
63 "::" If option can have an *optional* argument, then add a "::" 63 "::" If option can have an *optional* argument, then add a "::"
64 after its char in applet_opts and provide a pointer to store 64 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, ...)
72 env -i ls -d / 72 env -i ls -d /
73 Here we want env to process just the '-i', not the '-d'. 73 Here we want env to process just the '-i', not the '-d'.
74 74
75const struct option *bb_applet_long_options 75const struct option *applet_long_options
76 76
77 This struct allows you to define long options. The syntax for 77 This struct allows you to define long options. The syntax for
78 declaring the array is just like that of getopt's longopts. 78 declaring the array is just like that of getopt's longopts.
@@ -83,23 +83,20 @@ const struct option *bb_applet_long_options
83 { "verbose", 0, 0, 'v' }, 83 { "verbose", 0, 0, 'v' },
84 { 0, 0, 0, 0 } 84 { 0, 0, 0, 0 }
85 }; 85 };
86 bb_applet_long_options = applet_long_options; 86 applet_long_options = applet_long_options;
87 87
88 The last member of struct option (val) typically is set to 88 The last member of struct option (val) typically is set to
89 matching short option from applet_opts. If there is no matching 89 matching short option from applet_opts. If there is no matching
90 char in applet_opts, then: 90 char in applet_opts, then:
91 - return bit have next position after short options 91 - return bit have next position after short options
92 - if has_arg is not "no_argument", use ptr for arg also 92 - if has_arg is not "no_argument", use ptr for arg also
93 - bb_opt_complementally affects it too 93 - opt_complementary affects it too
94 94
95 Note: a good applet will make long options configurable via the 95 Note: a good applet will make long options configurable via the
96 config process and not a required feature. The current standard 96 config process and not a required feature. The current standard
97 is to name the config option CONFIG_FEATURE_<applet>_LONG_OPTIONS. 97 is to name the config option CONFIG_FEATURE_<applet>_LONG_OPTIONS.
98 98
99const char *bb_opt_complementally 99const char *opt_complementary
100
101 this should be bb_opt_complementary, but we'll just keep it as
102 bb_opt_complementally due to the Russian origins
103 100
104 ":" The colon (":") is used to separate groups of two or more chars 101 ":" The colon (":") is used to separate groups of two or more chars
105 and/or groups of chars and special characters (stating some 102 and/or groups of chars and special characters (stating some
@@ -110,11 +107,11 @@ const char *bb_opt_complementally
110 Their flags will be turned on if the main option is found even 107 Their flags will be turned on if the main option is found even
111 if they are not specifed on the command line. For example: 108 if they are not specifed on the command line. For example:
112 109
113 bb_opt_complementally = "abc"; 110 opt_complementary = "abc";
114 flags = bb_getopt_ulflags(argc, argv, "abcd") 111 flags = getopt32(argc, argv, "abcd")
115 112
116 If getopt() finds "-a" on the command line, then 113 If getopt() finds "-a" on the command line, then
117 bb_getopt_ulflags's return value will be as if "-a -b -c" were 114 getopt32's return value will be as if "-a -b -c" were
118 found. 115 found.
119 116
120 "ww" Adjacent double options have a counter associated which indicates 117 "ww" Adjacent double options have a counter associated which indicates
@@ -124,15 +121,15 @@ const char *bb_opt_complementally
124 if w is given more than once, it is "unlimited" 121 if w is given more than once, it is "unlimited"
125 122
126 int w_counter = 0; 123 int w_counter = 0;
127 bb_opt_complementally = "ww"; 124 opt_complementary = "ww";
128 bb_getopt_ulflags(argc, argv, "w", &w_counter); 125 getopt32(argc, argv, "w", &w_counter);
129 if (w_counter) 126 if (w_counter)
130 width = (w_counter == 1) ? 132 : INT_MAX; 127 width = (w_counter == 1) ? 132 : INT_MAX;
131 else 128 else
132 get_terminal_width(...&width...); 129 get_terminal_width(...&width...);
133 130
134 w_counter is a pointer to an integer. It has to be passed to 131 w_counter is a pointer to an integer. It has to be passed to
135 bb_getopt_ulflags() after all other option argument sinks. 132 getopt32() after all other option argument sinks.
136 133
137 For example: accept multiple -v to indicate the level of verbosity 134 For example: accept multiple -v to indicate the level of verbosity
138 and for each -b optarg, add optarg to my_b. Finally, if b is given, 135 and for each -b optarg, add optarg to my_b. Finally, if b is given,
@@ -140,8 +137,8 @@ const char *bb_opt_complementally
140 137
141 llist_t *my_b = NULL; 138 llist_t *my_b = NULL;
142 int verbose_level = 0; 139 int verbose_level = 0;
143 bb_opt_complementally = "vv:b::b-c:c-b"; 140 opt_complementary = "vv:b::b-c:c-b";
144 f = bb_getopt_ulflags(argc, argv, "vb:c", &my_b, &verbose_level); 141 f = getopt32(argc, argv, "vb:c", &my_b, &verbose_level);
145 if (f & 2) // -c after -b unsets -b flag 142 if (f & 2) // -c after -b unsets -b flag
146 while (my_b) { dosomething_with(my_b->data); my_b = my_b->link; } 143 while (my_b) { dosomething_with(my_b->data); my_b = my_b->link; }
147 if (my_b) // but llist is stored if -b is specified 144 if (my_b) // but llist is stored if -b is specified
@@ -157,37 +154,37 @@ Special characters:
157 154
158 For example: 155 For example:
159 The du applet has the options "-s" and "-d depth". If 156 The du applet has the options "-s" and "-d depth". If
160 bb_getopt_ulflags finds -s, then -d is unset or if it finds -d 157 getopt32 finds -s, then -d is unset or if it finds -d
161 then -s is unset. (Note: busybox implements the GNU 158 then -s is unset. (Note: busybox implements the GNU
162 "--max-depth" option as "-d".) To obtain this behavior, you 159 "--max-depth" option as "-d".) To obtain this behavior, you
163 set bb_opt_complementally = "s-d:d-s". Only one flag value is 160 set opt_complementary = "s-d:d-s". Only one flag value is
164 added to bb_getopt_ulflags's return value depending on the 161 added to getopt32's return value depending on the
165 position of the options on the command line. If one of the 162 position of the options on the command line. If one of the
166 two options requires an argument pointer (":" in applet_opts 163 two options requires an argument pointer (":" in applet_opts
167 as in "d:") optarg is set accordingly. 164 as in "d:") optarg is set accordingly.
168 165
169 char *smax_print_depth; 166 char *smax_print_depth;
170 167
171 bb_opt_complementally = "s-d:d-s:x-x"; 168 opt_complementary = "s-d:d-s:x-x";
172 opt = bb_getopt_ulflags(argc, argv, "sd:x", &smax_print_depth); 169 opt = getopt32(argc, argv, "sd:x", &smax_print_depth);
173 170
174 if (opt & 2) 171 if (opt & 2)
175 max_print_depth = atoi(smax_print_depth); 172 max_print_depth = atoi(smax_print_depth);
176 if (opt & 4) 173 if (opt & 4)
177 printf("Detected odd -x usage\n"); 174 printf("Detected odd -x usage\n");
178 175
179 "-" A dash as the first char in a bb_opt_complementally group forces 176 "-" A dash as the first char in a opt_complementary group forces
180 all arguments to be treated as options, even if they have 177 all arguments to be treated as options, even if they have
181 no leading dashes. Next char in this case can't be a digit (0-9), 178 no leading dashes. Next char in this case can't be a digit (0-9),
182 use ':' or end of line. For example: 179 use ':' or end of line. For example:
183 180
184 bb_opt_complementally = "-:w-x:x-w"; 181 opt_complementary = "-:w-x:x-w";
185 bb_getopt_ulflags(argc, argv, "wx"); 182 getopt32(argc, argv, "wx");
186 183
187 Allows any arguments to be given without a dash (./program w x) 184 Allows any arguments to be given without a dash (./program w x)
188 as well as with a dash (./program -x). 185 as well as with a dash (./program -x).
189 186
190 "-N" A dash as the first char in a bb_opt_complementally group followed 187 "-N" A dash as the first char in a opt_complementary group followed
191 by a single digit (0-9) means that at least N non-option 188 by a single digit (0-9) means that at least N non-option
192 arguments must be present on the command line 189 arguments must be present on the command line
193 190
@@ -205,8 +202,8 @@ Special characters:
205 The cut applet must have only one type of list specified, so 202 The cut applet must have only one type of list specified, so
206 -b, -c and -f are mutally exclusive and should raise an error 203 -b, -c and -f are mutally exclusive and should raise an error
207 if specified together. In this case you must set 204 if specified together. In this case you must set
208 bb_opt_complementally = "b--cf:c--bf:f--bc". If two of the 205 opt_complementary = "b--cf:c--bf:f--bc". If two of the
209 mutually exclusive options are found, bb_getopt_ulflags's 206 mutually exclusive options are found, getopt32's
210 return value will have the error flag set (BB_GETOPT_ERROR) so 207 return value will have the error flag set (BB_GETOPT_ERROR) so
211 that we can check for it: 208 that we can check for it:
212 209
@@ -216,35 +213,35 @@ Special characters:
216 "x--x" Variation of the above, it means that -x option should occur 213 "x--x" Variation of the above, it means that -x option should occur
217 at most once. 214 at most once.
218 215
219 "?" A "?" as the first char in a bb_opt_complementally group means: 216 "?" A "?" as the first char in a opt_complementary group means:
220 if BB_GETOPT_ERROR is detected, don't return, call bb_show_usage 217 if BB_GETOPT_ERROR is detected, don't return, call bb_show_usage
221 and exit instead. Next char after '?' can't be a digit. 218 and exit instead. Next char after '?' can't be a digit.
222 219
223 "?N" A "?" as the first char in a bb_opt_complementally group followed 220 "?N" A "?" as the first char in a opt_complementary group followed
224 by a single digit (0-9) means that at most N arguments must be present 221 by a single digit (0-9) means that at most N arguments must be present
225 on the command line. 222 on the command line.
226 223
227 "::" A double colon after a char in bb_opt_complementally means that the 224 "::" A double colon after a char in opt_complementary means that the
228 option can occur multiple times. Each occurrence will be saved as 225 option can occur multiple times. Each occurrence will be saved as
229 a llist_t element instead of char*. 226 a llist_t element instead of char*.
230 227
231 For example: 228 For example:
232 The grep applet can have one or more "-e pattern" arguments. 229 The grep applet can have one or more "-e pattern" arguments.
233 In this case you should use bb_getopt_ulflags() as follows: 230 In this case you should use getopt32() as follows:
234 231
235 llist_t *patterns = NULL; 232 llist_t *patterns = NULL;
236 233
237 (this pointer must be initializated to NULL if the list is empty 234 (this pointer must be initializated to NULL if the list is empty
238 as required by *llist_add_to(llist_t *old_head, char *new_item).) 235 as required by *llist_add_to(llist_t *old_head, char *new_item).)
239 236
240 bb_opt_complementally = "e::"; 237 opt_complementary = "e::";
241 238
242 bb_getopt_ulflags(argc, argv, "e:", &patterns); 239 getopt32(argc, argv, "e:", &patterns);
243 $ grep -e user -e root /etc/passwd 240 $ grep -e user -e root /etc/passwd
244 root:x:0:0:root:/root:/bin/bash 241 root:x:0:0:root:/root:/bin/bash
245 user:x:500:500::/home/user:/bin/bash 242 user:x:500:500::/home/user:/bin/bash
246 243
247 "--" A double dash at the beginning of bb_opt_complementally means the 244 "--" A double dash at the beginning of opt_complementary means the
248 argv[1] string should always be treated as options, even if it isn't 245 argv[1] string should always be treated as options, even if it isn't
249 prefixed with a "-". This is useful for special syntax in applets 246 prefixed with a "-". This is useful for special syntax in applets
250 such as "ar" and "tar": 247 such as "ar" and "tar":
@@ -257,20 +254,20 @@ Special characters:
257 For example from "id" applet: 254 For example from "id" applet:
258 255
259 // Don't allow -n -r -rn -ug -rug -nug -rnug 256 // Don't allow -n -r -rn -ug -rug -nug -rnug
260 bb_opt_complementally = "r?ug:n?ug:?u--g:g--u"; 257 opt_complementary = "r?ug:n?ug:?u--g:g--u";
261 flags = bb_getopt_ulflags(argc, argv, "rnug"); 258 flags = getopt32(argc, argv, "rnug");
262 259
263 This example allowed only: 260 This example allowed only:
264 $ id; id -u; id -g; id -ru; id -nu; id -rg; id -ng; id -rnu; id -rng 261 $ id; id -u; id -g; id -ru; id -nu; id -rg; id -ng; id -rnu; id -rng
265 262
266 "X" A bb_opt_complementally group with just a single letter means 263 "X" A opt_complementary group with just a single letter means
267 that this option is required. If more than one such group exists, 264 that this option is required. If more than one such group exists,
268 at least one option is required to occur (not all of them). 265 at least one option is required to occur (not all of them).
269 For example from "start-stop-daemon" applet: 266 For example from "start-stop-daemon" applet:
270 267
271 // Don't allow -KS -SK, but -S or -K is required 268 // Don't allow -KS -SK, but -S or -K is required
272 bb_opt_complementally = "K:S:?K--S:S--K"; 269 opt_complementary = "K:S:?K--S:S--K";
273 flags = bb_getopt_ulflags(argc, argv, "KS...); 270 flags = getopt32(argc, argv, "KS...);
274 271
275 272
276 Don't forget to use ':'. For example, "?322-22-23X-x-a" 273 Don't forget to use ':'. For example, "?322-22-23X-x-a"
@@ -280,45 +277,45 @@ Special characters:
280 a '-2' and after it a '-x' then error out. 277 a '-2' and after it a '-x' then error out.
281*/ 278*/
282 279
283/* this should be bb_opt_complementary, but we'll just keep it as 280/* Code here assumes that 'unsigned' is at least 32 bits wide */
284 bb_opt_complementally due to the Russian origins */ 281
285const char *bb_opt_complementally; 282const char *opt_complementary;
286 283
287typedef struct { 284typedef struct {
288 int opt; 285 int opt;
289 int list_flg; 286 int list_flg;
290 unsigned long switch_on; 287 unsigned switch_on;
291 unsigned long switch_off; 288 unsigned switch_off;
292 unsigned long incongruously; 289 unsigned incongruously;
293 unsigned long requires; 290 unsigned requires;
294 void **optarg; /* char **optarg or llist_t **optarg */ 291 void **optarg; /* char **optarg or llist_t **optarg */
295 int *counter; 292 int *counter;
296} t_complementally; 293} t_complementary;
297 294
298/* You can set bb_applet_long_options for parse called long options */ 295/* You can set applet_long_options for parse called long options */
299#if ENABLE_GETOPT_LONG 296#if ENABLE_GETOPT_LONG
300static const struct option bb_default_long_options[] = { 297static const struct option bb_default_long_options[] = {
301/* { "help", 0, NULL, '?' }, */ 298/* { "help", 0, NULL, '?' }, */
302 { 0, 0, 0, 0 } 299 { 0, 0, 0, 0 }
303}; 300};
304 301
305const struct option *bb_applet_long_options = bb_default_long_options; 302const struct option *applet_long_options = bb_default_long_options;
306#endif 303#endif
307 304
308unsigned long 305uint32_t
309bb_getopt_ulflags(int argc, char **argv, const char *applet_opts, ...) 306getopt32(int argc, char **argv, const char *applet_opts, ...)
310{ 307{
311 unsigned long flags = 0; 308 unsigned flags = 0;
312 unsigned long requires = 0; 309 unsigned requires = 0;
313 t_complementally complementally[sizeof(flags) * 8 + 1]; 310 t_complementary complementary[sizeof(flags) * 8 + 1];
314 int c; 311 int c;
315 const unsigned char *s; 312 const unsigned char *s;
316 t_complementally *on_off; 313 t_complementary *on_off;
317 va_list p; 314 va_list p;
318#if ENABLE_GETOPT_LONG 315#if ENABLE_GETOPT_LONG
319 const struct option *l_o; 316 const struct option *l_o;
320#endif 317#endif
321 unsigned long trigger; 318 unsigned trigger;
322 char **pargv = NULL; 319 char **pargv = NULL;
323 int min_arg = 0; 320 int min_arg = 0;
324 int max_arg = -1; 321 int max_arg = -1;
@@ -332,8 +329,8 @@ bb_getopt_ulflags(int argc, char **argv, const char *applet_opts, ...)
332 va_start(p, applet_opts); 329 va_start(p, applet_opts);
333 330
334 c = 0; 331 c = 0;
335 on_off = complementally; 332 on_off = complementary;
336 memset(on_off, 0, sizeof(complementally)); 333 memset(on_off, 0, sizeof(complementary));
337 334
338 /* skip GNU extension */ 335 /* skip GNU extension */
339 s = (const unsigned char *)applet_opts; 336 s = (const unsigned char *)applet_opts;
@@ -355,10 +352,10 @@ bb_getopt_ulflags(int argc, char **argv, const char *applet_opts, ...)
355 } 352 }
356 353
357#if ENABLE_GETOPT_LONG 354#if ENABLE_GETOPT_LONG
358 for (l_o = bb_applet_long_options; l_o->name; l_o++) { 355 for (l_o = applet_long_options; l_o->name; l_o++) {
359 if (l_o->flag) 356 if (l_o->flag)
360 continue; 357 continue;
361 for (on_off = complementally; on_off->opt != 0; on_off++) 358 for (on_off = complementary; on_off->opt != 0; on_off++)
362 if (on_off->opt == l_o->val) 359 if (on_off->opt == l_o->val)
363 break; 360 break;
364 if (on_off->opt == 0) { 361 if (on_off->opt == 0) {
@@ -372,9 +369,9 @@ bb_getopt_ulflags(int argc, char **argv, const char *applet_opts, ...)
372 } 369 }
373 } 370 }
374#endif /* ENABLE_GETOPT_LONG */ 371#endif /* ENABLE_GETOPT_LONG */
375 for (s = (const unsigned char *)bb_opt_complementally; s && *s; s++) { 372 for (s = (const unsigned char *)opt_complementary; s && *s; s++) {
376 t_complementally *pair; 373 t_complementary *pair;
377 unsigned long *pair_switch; 374 unsigned *pair_switch;
378 375
379 if (*s == ':') 376 if (*s == ':')
380 continue; 377 continue;
@@ -401,7 +398,7 @@ bb_getopt_ulflags(int argc, char **argv, const char *applet_opts, ...)
401 } 398 }
402 continue; 399 continue;
403 } 400 }
404 for (on_off = complementally; on_off->opt; on_off++) 401 for (on_off = complementary; on_off->opt; on_off++)
405 if (on_off->opt == *s) 402 if (on_off->opt == *s)
406 break; 403 break;
407 if (c == ':' && s[2] == ':') { 404 if (c == ':' && s[2] == ':') {
@@ -433,7 +430,7 @@ bb_getopt_ulflags(int argc, char **argv, const char *applet_opts, ...)
433 else 430 else
434 pair_switch = &(pair->switch_off); 431 pair_switch = &(pair->switch_off);
435 } else { 432 } else {
436 for (on_off = complementally; on_off->opt; on_off++) 433 for (on_off = complementary; on_off->opt; on_off++)
437 if (on_off->opt == *s) { 434 if (on_off->opt == *s) {
438 *pair_switch |= on_off->switch_on; 435 *pair_switch |= on_off->switch_on;
439 break; 436 break;
@@ -455,12 +452,12 @@ bb_getopt_ulflags(int argc, char **argv, const char *applet_opts, ...)
455#endif 452#endif
456#if ENABLE_GETOPT_LONG 453#if ENABLE_GETOPT_LONG
457 while ((c = getopt_long(argc, argv, applet_opts, 454 while ((c = getopt_long(argc, argv, applet_opts,
458 bb_applet_long_options, NULL)) >= 0) { 455 applet_long_options, NULL)) >= 0) {
459#else 456#else
460 while ((c = getopt(argc, argv, applet_opts)) >= 0) { 457 while ((c = getopt(argc, argv, applet_opts)) >= 0) {
461#endif /* ENABLE_GETOPT_LONG */ 458#endif /* ENABLE_GETOPT_LONG */
462loop_arg_is_opt: 459loop_arg_is_opt:
463 for (on_off = complementally; on_off->opt != c; on_off++) { 460 for (on_off = complementary; on_off->opt != c; on_off++) {
464 /* c==0 if long opt have non NULL flag */ 461 /* c==0 if long opt have non NULL flag */
465 if (on_off->opt == 0 && c != 0) 462 if (on_off->opt == 0 && c != 0)
466 bb_show_usage(); 463 bb_show_usage();
@@ -505,7 +502,7 @@ loop_arg_is_opt:
505 free(argv[1]); 502 free(argv[1]);
506#endif 503#endif
507 /* check depending requires for given options */ 504 /* check depending requires for given options */
508 for (on_off = complementally; on_off->opt; on_off++) { 505 for (on_off = complementary; on_off->opt; on_off++) {
509 if (on_off->requires && (flags & on_off->switch_on) && 506 if (on_off->requires && (flags & on_off->switch_on) &&
510 (flags & on_off->requires) == 0) 507 (flags & on_off->requires) == 0)
511 bb_show_usage(); 508 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)
90 gid_t gid = 0; 90 gid_t gid = 0;
91 91
92 /* check for min, max and missing args and exit on error */ 92 /* check for min, max and missing args and exit on error */
93 bb_opt_complementally = "-1:?2:?"; 93 opt_complementary = "-1:?2:?";
94 94
95 if (bb_getopt_ulflags(argc, argv, "g:", &group)) { 95 if (getopt32(argc, argv, "g:", &group)) {
96 gid = bb_xgetlarg(group, 10, 0, LONG_MAX); 96 gid = bb_xgetlarg(group, 10, 0, LONG_MAX);
97 } 97 }
98 /* move past the commandline options */ 98 /* 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)
169 pw.pw_dir = NULL; 169 pw.pw_dir = NULL;
170 170
171 /* check for min, max and missing args and exit on error */ 171 /* check for min, max and missing args and exit on error */
172 bb_opt_complementally = "-1:?1:?"; 172 opt_complementary = "-1:?1:?";
173 flags = bb_getopt_ulflags(argc, argv, "h:g:s:G:DSH", &pw.pw_dir, &pw.pw_gecos, &pw.pw_shell, &usegroup); 173 flags = getopt32(argc, argv, "h:g:s:G:DSH", &pw.pw_dir, &pw.pw_gecos, &pw.pw_shell, &usegroup);
174 174
175 /* got root? */ 175 /* got root? */
176 if(geteuid()) { 176 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)
258{ 258{
259 char *ts; 259 char *ts;
260 260
261 op->flags = bb_getopt_ulflags(argc, argv, opt_string, 261 op->flags = getopt32(argc, argv, opt_string,
262 &(op->initstring), &fakehost, &(op->issue), 262 &(op->initstring), &fakehost, &(op->issue),
263 &(op->login), &ts); 263 &(op->login), &ts);
264 if(op->flags & F_INITSTRING) { 264 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)
222 char username[USERNAME_SIZE]; 222 char username[USERNAME_SIZE];
223 const char *tmp; 223 const char *tmp;
224 int amroot; 224 int amroot;
225 unsigned long opt; 225 unsigned opt;
226 int count = 0; 226 int count = 0;
227 struct passwd *pw; 227 struct passwd *pw;
228 char *opt_host = NULL; 228 char *opt_host = NULL;
@@ -234,7 +234,7 @@ int login_main(int argc, char **argv)
234 signal(SIGALRM, alarm_handler); 234 signal(SIGALRM, alarm_handler);
235 alarm(TIMEOUT); 235 alarm(TIMEOUT);
236 236
237 opt = bb_getopt_ulflags(argc, argv, "f:h:p", &opt_user, &opt_host); 237 opt = getopt32(argc, argv, "f:h:p", &opt_user, &opt_host);
238 if (opt & LOGIN_OPT_f) { 238 if (opt & LOGIN_OPT_f) {
239 if (!amroot) 239 if (!amroot)
240 bb_error_msg_and_die("-f is for root only"); 240 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)
134 OPT_delete = 0x8, /* -d - delete password */ 134 OPT_delete = 0x8, /* -d - delete password */
135 OPT_lud = 0xe, 135 OPT_lud = 0xe,
136 }; 136 };
137 unsigned long opt; 137 unsigned opt;
138 char *opt_a; 138 char *opt_a;
139 int amroot; 139 int amroot;
140 char *cp; 140 char *cp;
@@ -146,7 +146,7 @@ int passwd_main(int argc, char **argv)
146 146
147 amroot = (getuid() == 0); 147 amroot = (getuid() == 0);
148 openlog("passwd", LOG_PID | LOG_CONS | LOG_NOWAIT, LOG_AUTH); 148 openlog("passwd", LOG_PID | LOG_CONS | LOG_NOWAIT, LOG_AUTH);
149 opt = bb_getopt_ulflags(argc, argv, "a:lud", &opt_a); 149 opt = getopt32(argc, argv, "a:lud", &opt_a);
150 argc -= optind; 150 argc -= optind;
151 argv += optind; 151 argv += optind;
152 if (opt & OPT_algo) algo = get_algo(opt_a); // -a 152 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)
20 const char *tty; 20 const char *tty;
21 char *old_user; 21 char *old_user;
22 22
23 flags = bb_getopt_ulflags(argc, argv, "mplc:s:", &opt_command, &opt_shell); 23 flags = getopt32(argc, argv, "mplc:s:", &opt_command, &opt_shell);
24#define SU_OPT_mp (3) 24#define SU_OPT_mp (3)
25#define SU_OPT_l (4) 25#define SU_OPT_l (4)
26 26
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)
46 logmode = LOGMODE_BOTH; 46 logmode = LOGMODE_BOTH;
47 openlog(bb_applet_name, 0, LOG_AUTH); 47 openlog(bb_applet_name, 0, LOG_AUTH);
48 48
49 if (bb_getopt_ulflags (argc, argv, "t:", &timeout_arg)) { 49 if (getopt32 (argc, argv, "t:", &timeout_arg)) {
50 if (safe_strtoi(timeout_arg, &timeout)) { 50 if (safe_strtoi(timeout_arg, &timeout)) {
51 timeout = 0; 51 timeout = 0;
52 } 52 }
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)
55 bb_show_usage(); 55 bb_show_usage();
56 } 56 }
57 57
58 o_lock_all = bb_getopt_ulflags (argc, argv, "a"); 58 o_lock_all = getopt32 (argc, argv, "a");
59 59
60 if((pw = getpwuid(getuid())) == NULL) { 60 if((pw = getpwuid(getuid())) == NULL) {
61 bb_error_msg_and_die("Unknown uid %d", getuid()); 61 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)
47 enum { 47 enum {
48 OPT_quiet = 0x1 48 OPT_quiet = 0x1
49 }; 49 };
50 unsigned long opt; 50 unsigned opt;
51 char *opt_o, *opt_f, *opt_p, *opt_t; 51 char *opt_o, *opt_f, *opt_p, *opt_t;
52 struct timex txc; 52 struct timex txc;
53 int i, ret, sep; 53 int i, ret, sep;
54 const char *descript; 54 const char *descript;
55 txc.modes=0; 55 txc.modes=0;
56 56
57 opt = bb_getopt_ulflags(argc, argv, "qo:f:p:t:", 57 opt = getopt32(argc, argv, "qo:f:p:t:",
58 &opt_o, &opt_f, &opt_p, &opt_t); 58 &opt_o, &opt_f, &opt_p, &opt_t);
59 //if (opt & 0x1) // -q 59 //if (opt & 0x1) // -q
60 if (opt & 0x2) { // -o 60 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, ...)
133 133
134int crond_main(int ac, char **av) 134int crond_main(int ac, char **av)
135{ 135{
136 unsigned long opt; 136 unsigned opt;
137 char *lopt, *Lopt, *copt; 137 char *lopt, *Lopt, *copt;
138 138
139#if ENABLE_DEBUG_CROND_OPTION 139#if ENABLE_DEBUG_CROND_OPTION
140 char *dopt; 140 char *dopt;
141 141
142 bb_opt_complementally = "f-b:b-f:S-L:L-S:d-l"; 142 opt_complementary = "f-b:b-f:S-L:L-S:d-l";
143#else 143#else
144 bb_opt_complementally = "f-b:b-f:S-L:L-S"; 144 opt_complementary = "f-b:b-f:S-L:L-S";
145#endif 145#endif
146 146
147 opterr = 0; /* disable getopt 'errors' message. */ 147 opterr = 0; /* disable getopt 'errors' message. */
148 opt = bb_getopt_ulflags(ac, av, "l:L:fbSc:" 148 opt = getopt32(ac, av, "l:L:fbSc:"
149#if ENABLE_DEBUG_CROND_OPTION 149#if ENABLE_DEBUG_CROND_OPTION
150 "d:" 150 "d:"
151#endif 151#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)
31 struct mntent *m; 31 struct mntent *m;
32 int dev; 32 int dev;
33 33
34 /*bb_opt_complementally = "t--T:T--t";*/ 34 /*opt_complementary = "t--T:T--t";*/
35 flags = bb_getopt_ulflags(argc, argv, "tT"); 35 flags = getopt32(argc, argv, "tT");
36 device = argv[optind] ? : DEFAULT_CDROM; 36 device = argv[optind] ? : DEFAULT_CDROM;
37 37
38 m = find_mount_point(device, bb_path_mtab_file); 38 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)
575 575
576 /* check if we recognise the device type */ 576 /* check if we recognise the device type */
577 printf("\n"); 577 printf("\n");
578 if(!(val[GEN_CONFIG] & NOT_ATA)) 578 if (!(val[GEN_CONFIG] & NOT_ATA))
579 { 579 {
580 dev = ATA_DEV; 580 dev = ATA_DEV;
581 printf("ATA device, with "); 581 printf("ATA device, with ");
582 } 582 }
583 else if(val[GEN_CONFIG]==CFA_SUPPORT_VAL) 583 else if (val[GEN_CONFIG]==CFA_SUPPORT_VAL)
584 { 584 {
585 dev = ATA_DEV; 585 dev = ATA_DEV;
586 like_std = 4; 586 like_std = 4;
587 printf("CompactFlash ATA device, with "); 587 printf("CompactFlash ATA device, with ");
588 } 588 }
589 else if(!(val[GEN_CONFIG] & NOT_ATAPI)) 589 else if (!(val[GEN_CONFIG] & NOT_ATAPI))
590 { 590 {
591 dev = ATAPI_DEV; 591 dev = ATAPI_DEV;
592 eqpt = (val[GEN_CONFIG] & EQPT_TYPE) >> SHIFT_EQPT; 592 eqpt = (val[GEN_CONFIG] & EQPT_TYPE) >> SHIFT_EQPT;
@@ -609,9 +609,9 @@ static void identify(uint16_t *id_supplied)
609 (val[CONFIG]==PWRD_NID_VAL) || (val[CONFIG]==PWRD_ID_VAL) ) 609 (val[CONFIG]==PWRD_NID_VAL) || (val[CONFIG]==PWRD_ID_VAL) )
610 { 610 {
611 like_std = 5; 611 like_std = 5;
612 if((val[CONFIG]==STBY_NID_VAL) || (val[CONFIG]==STBY_ID_VAL)) 612 if ((val[CONFIG]==STBY_NID_VAL) || (val[CONFIG]==STBY_ID_VAL))
613 printf("powers-up in standby; SET FEATURES subcmd spins-up.\n"); 613 printf("powers-up in standby; SET FEATURES subcmd spins-up.\n");
614 if(((val[CONFIG]==STBY_NID_VAL) || (val[CONFIG]==PWRD_NID_VAL)) && (val[GEN_CONFIG] & INCOMPLETE)) 614 if (((val[CONFIG]==STBY_NID_VAL) || (val[CONFIG]==PWRD_NID_VAL)) && (val[GEN_CONFIG] & INCOMPLETE))
615 printf("\n\tWARNING: ID response incomplete.\n\tFollowing data may be incorrect.\n\n"); 615 printf("\n\tWARNING: ID response incomplete.\n\tFollowing data may be incorrect.\n\n");
616 } 616 }
617 617
@@ -629,9 +629,9 @@ static void identify(uint16_t *id_supplied)
629 { 629 {
630 if (val[MINOR] && (val[MINOR] <= MINOR_MAX)) 630 if (val[MINOR] && (val[MINOR] <= MINOR_MAX))
631 { 631 {
632 if(like_std < 3) like_std = 3; 632 if (like_std < 3) like_std = 3;
633 std = actual_ver[val[MINOR]]; 633 std = actual_ver[val[MINOR]];
634 if(std) printf("\n\tUsed: %s ",minor_str[val[MINOR]]); 634 if (std) printf("\n\tUsed: %s ",minor_str[val[MINOR]]);
635 635
636 } 636 }
637 /* looks like when they up-issue the std, they obsolete one; 637 /* looks like when they up-issue the std, they obsolete one;
@@ -652,17 +652,17 @@ static void identify(uint16_t *id_supplied)
652 like_std = ii; 652 like_std = ii;
653 kk = like_std >4 ? like_std-4: 0; 653 kk = like_std >4 ? like_std-4: 0;
654 } 654 }
655 if(min_std > ii) min_std = ii; 655 if (min_std > ii) min_std = ii;
656 } 656 }
657 jj <<= 1; 657 jj <<= 1;
658 } 658 }
659 if(like_std < 3) like_std = 3; 659 if (like_std < 3) like_std = 3;
660 } 660 }
661 /* Figure out what standard the device is using if it hasn't told 661 /* Figure out what standard the device is using if it hasn't told
662 * us. If we know the std, check if the device is using any of 662 * us. If we know the std, check if the device is using any of
663 * the words from the next level up. It happens. 663 * the words from the next level up. It happens.
664 */ 664 */
665 if(like_std < std) like_std = std; 665 if (like_std < std) like_std = std;
666 666
667 if (((std == 5) || (!std && (like_std < 6))) && 667 if (((std == 5) || (!std && (like_std < 6))) &&
668 ((((val[CMDS_SUPP_1] & VALID) == VALID_VAL) && 668 ((((val[CMDS_SUPP_1] & VALID) == VALID_VAL) &&
@@ -724,7 +724,7 @@ static void identify(uint16_t *id_supplied)
724 jj = val[CDR_MAJOR] >> 1; 724 jj = val[CDR_MAJOR] >> 1;
725 for (ii = 1; ii <15; ii++) 725 for (ii = 1; ii <15; ii++)
726 { 726 {
727 if(jj & 0x0001) printf("-%u ", ii); 727 if (jj & 0x0001) printf("-%u ", ii);
728 jj >>= 1; 728 jj >>= 1;
729 } 729 }
730 } 730 }
@@ -743,7 +743,7 @@ static void identify(uint16_t *id_supplied)
743 jj = val[GEN_CONFIG] >> 1; 743 jj = val[GEN_CONFIG] >> 1;
744 for (ii = 1; ii < 15; ii++) 744 for (ii = 1; ii < 15; ii++)
745 { 745 {
746 if(jj & 0x0001) printf("\t%s\n",ata1_cfg_str[ii]); 746 if (jj & 0x0001) printf("\t%s\n",ata1_cfg_str[ii]);
747 jj >>=1; 747 jj >>=1;
748 } 748 }
749 } 749 }
@@ -1018,7 +1018,7 @@ static void identify(uint16_t *id_supplied)
1018 } 1018 }
1019 } 1019 }
1020 /* Removable Media Status Notification feature set */ 1020 /* Removable Media Status Notification feature set */
1021 if((val[RM_STAT] & RM_STAT_BITS) == RM_STAT_SUP) 1021 if ((val[RM_STAT] & RM_STAT_BITS) == RM_STAT_SUP)
1022 printf("\t%s supported\n", cmd_feat_str[27]); 1022 printf("\t%s supported\n", cmd_feat_str[27]);
1023 1023
1024 1024
@@ -1196,7 +1196,7 @@ static void dump_identity(const struct hd_driveid *id)
1196 } 1196 }
1197 printf("\n"); 1197 printf("\n");
1198 1198
1199 if(!(id->field_valid&1)) 1199 if (!(id->field_valid&1))
1200 printf(" (maybe):"); 1200 printf(" (maybe):");
1201 1201
1202 printf(" CurCHS=%u/%u/%u, CurSects=%lu, LBA=%s",id->cur_cyls, id->cur_heads, 1202 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)
1589 1589
1590static void print_flag(unsigned long flag, char *s, unsigned long value) 1590static void print_flag(unsigned long flag, char *s, unsigned long value)
1591{ 1591{
1592 if(flag) 1592 if (flag)
1593 printf(" setting %s to %ld\n", s, value); 1593 printf(" setting %s to %ld\n", s, value);
1594} 1594}
1595 1595
@@ -2078,18 +2078,18 @@ static void parse_xfermode(int flag, unsigned long *get, unsigned long *set, int
2078} 2078}
2079 2079
2080/*------- getopt short options --------*/ 2080/*------- getopt short options --------*/
2081static const char hdparm_options[]= "gfu::n::p:r::m::c::k::a::B:tTh"\ 2081static const char hdparm_options[] = "gfu::n::p:r::m::c::k::a::B:tTh"
2082 USE_FEATURE_HDPARM_GET_IDENTITY("iI") 2082 USE_FEATURE_HDPARM_GET_IDENTITY("iI")
2083 USE_FEATURE_HDPARM_HDIO_GETSET_DMA("d::") 2083 USE_FEATURE_HDPARM_HDIO_GETSET_DMA("d::")
2084#ifdef HDIO_DRIVE_CMD 2084#ifdef HDIO_DRIVE_CMD
2085 "S:D:P:X:K:A:L:W:CyYzZ" 2085 "S:D:P:X:K:A:L:W:CyYzZ"
2086#endif 2086#endif
2087 USE_FEATURE_HDPARM_HDIO_UNREGISTER_HWIF("U:") 2087 USE_FEATURE_HDPARM_HDIO_UNREGISTER_HWIF("U:")
2088#ifdef HDIO_GET_QDMA 2088#ifdef HDIO_GET_QDMA
2089#ifdef HDIO_SET_QDMA 2089#ifdef HDIO_SET_QDMA
2090 "Q:" 2090 "Q:"
2091#else 2091#else
2092 "Q" 2092 "Q"
2093#endif 2093#endif
2094#endif 2094#endif
2095 USE_FEATURE_HDPARM_HDIO_DRIVE_RESET("w") 2095 USE_FEATURE_HDPARM_HDIO_DRIVE_RESET("w")
@@ -2154,8 +2154,8 @@ int hdparm_main(int argc, char **argv)
2154#if ENABLE_FEATURE_HDPARM_HDIO_SCAN_HWIF 2154#if ENABLE_FEATURE_HDPARM_HDIO_SCAN_HWIF
2155 if (c == 'R') { 2155 if (c == 'R') {
2156 parse_opts(NULL, &scan_hwif, &hwif_data, 0, INT_MAX); 2156 parse_opts(NULL, &scan_hwif, &hwif_data, 0, INT_MAX);
2157 hwif_ctrl = bb_xgetlarg((argv[optind]) ? argv[optind] : "", 10, 0, INT_MAX); 2157 hwif_ctrl = bb_xgetlarg((argv[optind]) ? argv[optind] : "", 10, 0, INT_MAX);
2158 hwif_irq = bb_xgetlarg((argv[optind+1]) ? argv[optind+1] : "", 10, 0, INT_MAX); 2158 hwif_irq = bb_xgetlarg((argv[optind+1]) ? argv[optind+1] : "", 10, 0, INT_MAX);
2159 /* Move past the 2 additional arguments */ 2159 /* Move past the 2 additional arguments */
2160 argv += 2; 2160 argv += 2;
2161 argc -= 2; 2161 argc -= 2;
@@ -2163,7 +2163,7 @@ int hdparm_main(int argc, char **argv)
2163#endif 2163#endif
2164 } 2164 }
2165 /* When no flags are given (flagcount = 0), -acdgkmnru is assumed. */ 2165 /* When no flags are given (flagcount = 0), -acdgkmnru is assumed. */
2166 if (!flagcount){ 2166 if (!flagcount) {
2167 get_mult = get_io32bit = get_unmask = get_keep = get_readonly = get_readahead = get_geom = 1; 2167 get_mult = get_io32bit = get_unmask = get_keep = get_readonly = get_readahead = get_geom = 1;
2168 USE_FEATURE_HDPARM_HDIO_GETSET_DMA(get_dma = 1); 2168 USE_FEATURE_HDPARM_HDIO_GETSET_DMA(get_dma = 1);
2169 } 2169 }
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) {
1102 1102
1103 int keypress; 1103 int keypress;
1104 1104
1105 flags = bb_getopt_ulflags(argc, argv, "EMmN~"); 1105 flags = getopt32(argc, argv, "EMmN~");
1106 1106
1107 argc -= optind; 1107 argc -= optind;
1108 argv += optind; 1108 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)
76 int linenum = 0; 76 int linenum = 0;
77 int ret = EXIT_SUCCESS; 77 int ret = EXIT_SUCCESS;
78 78
79 bb_getopt_ulflags(argc, argv, "d:", &line); 79 getopt32(argc, argv, "d:", &line);
80 if (line) 80 if (line)
81 table = xfopen(line, "r"); 81 table = xfopen(line, "r");
82 82
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 @@
13 13
14int mountpoint_main(int argc, char **argv) 14int mountpoint_main(int argc, char **argv)
15{ 15{
16 int opt = bb_getopt_ulflags(argc, argv, "qdx"); 16 int opt = getopt32(argc, argv, "qdx");
17#define OPT_q (1) 17#define OPT_q (1)
18#define OPT_d (2) 18#define OPT_d (2)
19#define OPT_x (4) 19#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 @@
21int strings_main(int argc, char **argv) 21int strings_main(int argc, char **argv)
22{ 22{
23 int n, c, i = 0, status = EXIT_SUCCESS; 23 int n, c, i = 0, status = EXIT_SUCCESS;
24 unsigned long opt; 24 unsigned opt;
25 unsigned long count; 25 unsigned long count;
26 FILE *file = stdin; 26 FILE *file = stdin;
27 char *string; 27 char *string;
28 const char *fmt = "%s: "; 28 const char *fmt = "%s: ";
29 char *n_arg = "4"; 29 char *n_arg = "4";
30 30
31 opt = bb_getopt_ulflags(argc, argv, "afon:", &n_arg); 31 opt = getopt32(argc, argv, "afon:", &n_arg);
32 /* -a is our default behaviour */ 32 /* -a is our default behaviour */
33 33
34 argc -= optind; 34 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)
25 25
26int watchdog_main(int argc, char **argv) 26int watchdog_main(int argc, char **argv)
27{ 27{
28 unsigned long opts; 28 unsigned opts;
29 unsigned long timer_duration = 30; /* Userspace timer duration, in seconds */ 29 unsigned long timer_duration = 30; /* Userspace timer duration, in seconds */
30 char *t_arg; 30 char *t_arg;
31 31
32 opts = bb_getopt_ulflags(argc, argv, "Ft:", &t_arg); 32 opts = getopt32(argc, argv, "Ft:", &t_arg);
33 33
34 if (opts & OPT_TIMER) 34 if (opts & OPT_TIMER)
35 timer_duration = bb_xgetlarg(t_arg, 10, 0, INT_MAX); 35 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)
3983 struct utsname myuname; 3983 struct utsname myuname;
3984 3984
3985 /* Parse any options */ 3985 /* Parse any options */
3986 option_mask = bb_getopt_ulflags(argc, argv, OPTION_STR, &opt_o); 3986 option_mask = getopt32(argc, argv, OPTION_STR, &opt_o);
3987 if (option_mask & OPT_o) { // -o /* name the output module */ 3987 if (option_mask & OPT_o) { // -o /* name the output module */
3988 free(m_name); 3988 free(m_name);
3989 m_name = xstrdup(opt_o); 3989 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)
902 int rc = EXIT_SUCCESS; 902 int rc = EXIT_SUCCESS;
903 char *unused; 903 char *unused;
904 904
905 bb_opt_complementally = "?V-:q-v:v-q"; 905 opt_complementary = "?V-:q-v:v-q";
906 main_opts = bb_getopt_ulflags(argc, argv, "acdklnqrst:vVC:", 906 main_opts = getopt32(argc, argv, "acdklnqrst:vVC:",
907 &unused, &unused); 907 &unused, &unused);
908 if((main_opts & (DUMP_CONF_EXIT | LIST_ALL))) 908 if((main_opts & (DUMP_CONF_EXIT | LIST_ALL)))
909 return EXIT_SUCCESS; 909 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)
44 unsigned int flags = O_NONBLOCK|O_EXCL; 44 unsigned int flags = O_NONBLOCK|O_EXCL;
45 45
46 /* Parse command line. */ 46 /* Parse command line. */
47 n = bb_getopt_ulflags(argc, argv, "wfa"); 47 n = getopt32(argc, argv, "wfa");
48 if((n & 1)) // --wait 48 if((n & 1)) // --wait
49 flags &= ~O_NONBLOCK; 49 flags &= ~O_NONBLOCK;
50 if((n & 2)) // --force 50 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)
265 xsetuid(getuid()); 265 xsetuid(getuid());
266 266
267 { 267 {
268 unsigned long opt; 268 unsigned opt;
269 char *_count, *_timeout; 269 char *_count, *_timeout;
270 270
271 /* Dad also sets quit_on_reply. 271 /* Dad also sets quit_on_reply.
272 * Advert also sets unsolicited. 272 * Advert also sets unsolicited.
273 */ 273 */
274 bb_opt_complementally = "Df:AU"; 274 opt_complementary = "Df:AU";
275 opt = bb_getopt_ulflags(argc, argv, "DUAqfbc:w:i:s:", 275 opt = getopt32(argc, argv, "DUAqfbc:w:i:s:",
276 &_count, &_timeout, &device, &source); 276 &_count, &_timeout, &device, &source);
277 cfg |= opt & 0x3f; /* set respective flags */ 277 cfg |= opt & 0x3f; /* set respective flags */
278 if (opt & 0x40) /* -c: count */ 278 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)
372 char *sttl=NULL, *sport=NULL; 372 char *sttl=NULL, *sport=NULL;
373 373
374 if(argc > 1) 374 if(argc > 1)
375 flags = bb_getopt_ulflags(argc, argv, "i:c:t:p:dv", &listen_interface, &fileconf, &sttl, &sport); 375 flags = getopt32(argc, argv, "i:c:t:p:dv", &listen_interface, &fileconf, &sttl, &sport);
376 if(sttl) 376 if(sttl)
377 if(!(ttl = atol(sttl))) 377 if(!(ttl = atol(sttl)))
378 bb_show_usage(); 378 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[])
120 struct whereto_t whereto; /* who to wake up */ 120 struct whereto_t whereto; /* who to wake up */
121 121
122 /* handle misc user options */ 122 /* handle misc user options */
123 flags = bb_getopt_ulflags(argc, argv, "bi:p:", &ifname, &pass); 123 flags = getopt32(argc, argv, "bi:p:", &ifname, &pass);
124 if (optind == argc) 124 if (optind == argc)
125 bb_show_usage(); 125 bb_show_usage();
126 if (pass) 126 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)
228 FD_SET(0, &G.readfds); 228 FD_SET(0, &G.readfds);
229 229
230 /* handle -b <ip> parameter */ 230 /* handle -b <ip> parameter */
231 bb_getopt_ulflags(argc, argv, "b:", &bind_ip_address); 231 getopt32(argc, argv, "b:", &bind_ip_address);
232 /* handle optional REPLY STRING */ 232 /* handle optional REPLY STRING */
233 if (optind < argc) 233 if (optind < argc)
234 G.identuser = argv[optind]; 234 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[] = {
275int ftpgetput_main(int argc, char **argv) 275int ftpgetput_main(int argc, char **argv)
276{ 276{
277 /* content-length of the file */ 277 /* content-length of the file */
278 unsigned long opt; 278 unsigned opt;
279 char *port = "ftp"; 279 char *port = "ftp";
280 280
281 /* socket to ftp server */ 281 /* socket to ftp server */
@@ -305,9 +305,9 @@ int ftpgetput_main(int argc, char **argv)
305 * Decipher the command line 305 * Decipher the command line
306 */ 306 */
307 if (ENABLE_FEATURE_FTPGETPUT_LONG_OPTIONS) 307 if (ENABLE_FEATURE_FTPGETPUT_LONG_OPTIONS)
308 bb_applet_long_options = ftpgetput_long_options; 308 applet_long_options = ftpgetput_long_options;
309 309
310 opt = bb_getopt_ulflags(argc, argv, "cvu:p:P:", &server->user, &server->password, &port); 310 opt = getopt32(argc, argv, "cvu:p:P:", &server->user, &server->password, &port);
311 311
312 /* Process the non-option command line arguments */ 312 /* Process the non-option command line arguments */
313 if (argc - optind != 3) { 313 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)
55 }; 55 };
56 56
57 char buf[256]; 57 char buf[256];
58 unsigned long opt; 58 unsigned opt;
59 char *hostname_str = NULL; 59 char *hostname_str = NULL;
60 60
61 if (argc < 1) 61 if (argc < 1)
62 bb_show_usage(); 62 bb_show_usage();
63 63
64 opt = bb_getopt_ulflags(argc, argv, "dfisF:", &hostname_str); 64 opt = getopt32(argc, argv, "dfisF:", &hostname_str);
65 65
66 /* Output in desired format */ 66 /* Output in desired format */
67 if (opt & OPT_dfis) { 67 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:"
1909 1909
1910int httpd_main(int argc, char *argv[]) 1910int httpd_main(int argc, char *argv[])
1911{ 1911{
1912 unsigned long opt; 1912 unsigned opt;
1913 const char *home_httpd = home; 1913 const char *home_httpd = home;
1914 char *url_for_decode; 1914 char *url_for_decode;
1915 USE_FEATURE_HTTPD_ENCODE_URL_STR(const char *url_for_encode;) 1915 USE_FEATURE_HTTPD_ENCODE_URL_STR(const char *url_for_encode;)
@@ -1932,7 +1932,7 @@ int httpd_main(int argc, char *argv[])
1932 1932
1933 config->ContentLength = -1; 1933 config->ContentLength = -1;
1934 1934
1935 opt = bb_getopt_ulflags(argc, argv, httpd_opts, 1935 opt = getopt32(argc, argv, httpd_opts,
1936 &(config->configFile), &url_for_decode, &home_httpd 1936 &(config->configFile), &url_for_decode, &home_httpd
1937 USE_FEATURE_HTTPD_ENCODE_URL_STR(, &url_for_encode) 1937 USE_FEATURE_HTTPD_ENCODE_URL_STR(, &url_for_encode)
1938 USE_FEATURE_HTTPD_BASIC_AUTH(, &(config->realm)) 1938 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)
1088 cmds = iface_down; 1088 cmds = iface_down;
1089 } 1089 }
1090 1090
1091 option_mask = bb_getopt_ulflags(argc, argv, OPTION_STR, &interfaces); 1091 option_mask = getopt32(argc, argv, OPTION_STR, &interfaces);
1092 if (argc - optind > 0) { 1092 if (argc - optind > 0) {
1093 if (DO_ALL) bb_show_usage(); 1093 if (DO_ALL) bb_show_usage();
1094 } else 1094 } 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[])
1253 1253
1254 openlog(bb_applet_name, LOG_PID | LOG_NOWAIT, LOG_DAEMON); 1254 openlog(bb_applet_name, LOG_PID | LOG_NOWAIT, LOG_DAEMON);
1255 1255
1256 opt = bb_getopt_ulflags(argc, argv, "R:f", &stoomany); 1256 opt = getopt32(argc, argv, "R:f", &stoomany);
1257 if(opt & 1) { 1257 if(opt & 1) {
1258 char *e; 1258 char *e;
1259 1259
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)
90 char *ipstr; 90 char *ipstr;
91 91
92 if (ENABLE_FEATURE_IPCALC_LONG_OPTIONS) 92 if (ENABLE_FEATURE_IPCALC_LONG_OPTIONS)
93 bb_applet_long_options = long_options; 93 applet_long_options = long_options;
94 94
95 mode = bb_getopt_ulflags(argc, argv, "mbn" USE_FEATURE_IPCALC_FANCY("phs")); 95 mode = getopt32(argc, argv, "mbn" USE_FEATURE_IPCALC_FANCY("phs"));
96 96
97 argc -= optind; 97 argc -= optind;
98 argv += optind; 98 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)
65 int if_index = 1; 65 int if_index = 1;
66 mactable_t *ch; 66 mactable_t *ch;
67 67
68 if (1 & bb_getopt_ulflags(argc, argv, "sc:", &fname)) { 68 if (1 & getopt32(argc, argv, "sc:", &fname)) {
69 openlog(bb_applet_name, 0, LOG_LOCAL0); 69 openlog(bb_applet_name, 0, LOG_LOCAL0);
70 logmode = LOGMODE_SYSLOG; 70 logmode = LOGMODE_SYSLOG;
71 } 71 }
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);
21#define NETSTAT_CONNECTED 0x01 21#define NETSTAT_CONNECTED 0x01
22#define NETSTAT_LISTENING 0x02 22#define NETSTAT_LISTENING 0x02
23#define NETSTAT_NUMERIC 0x04 23#define NETSTAT_NUMERIC 0x04
24/* Must match getopt_ulflags option string */ 24/* Must match getopt32 option string */
25#define NETSTAT_TCP 0x10 25#define NETSTAT_TCP 0x10
26#define NETSTAT_UDP 0x20 26#define NETSTAT_UDP 0x20
27#define NETSTAT_RAW 0x40 27#define NETSTAT_RAW 0x40
@@ -526,7 +526,7 @@ int netstat_main(int argc, char **argv)
526 OPT_extended = 0x4, 526 OPT_extended = 0x4,
527 OPT_showroute = 0x100, 527 OPT_showroute = 0x100,
528 }; 528 };
529 unsigned long opt; 529 unsigned opt;
530#ifdef CONFIG_FEATURE_IPV6 530#ifdef CONFIG_FEATURE_IPV6
531 int inet = 1; 531 int inet = 1;
532 int inet6 = 1; 532 int inet6 = 1;
@@ -536,7 +536,7 @@ int netstat_main(int argc, char **argv)
536#endif 536#endif
537 537
538 /* Option string must match NETSTAT_xxx constants */ 538 /* Option string must match NETSTAT_xxx constants */
539 opt = bb_getopt_ulflags(argc, argv, "laentuwxr"); 539 opt = getopt32(argc, argv, "laentuwxr");
540 if (opt & 0x1) { // -l 540 if (opt & 0x1) { // -l
541 flags &= ~NETSTAT_CONNECTED; 541 flags &= ~NETSTAT_CONNECTED;
542 flags |= NETSTAT_LISTENING; 542 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 */
647 647
648int route_main(int argc, char **argv) 648int route_main(int argc, char **argv)
649{ 649{
650 unsigned long opt; 650 unsigned opt;
651 int what; 651 int what;
652 char *family; 652 char *family;
653 653
@@ -662,7 +662,7 @@ int route_main(int argc, char **argv)
662 } 662 }
663 } 663 }
664 664
665 opt = bb_getopt_ulflags(argc, argv, "A:ne", &family); 665 opt = getopt32(argc, argv, "A:ne", &family);
666 666
667 if ((opt & ROUTE_OPT_A) && strcmp(family, "inet")) { 667 if ((opt & ROUTE_OPT_A) && strcmp(family, "inet")) {
668#ifdef CONFIG_FEATURE_IPV6 668#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)
623 bb_show_usage(); 623 bb_show_usage();
624 624
625#ifdef CONFIG_FEATURE_TELNET_AUTOLOGIN 625#ifdef CONFIG_FEATURE_TELNET_AUTOLOGIN
626 if (1 & bb_getopt_ulflags(argc, argv, "al:", &autologin)) 626 if (1 & getopt32(argc, argv, "al:", &autologin))
627 autologin = getenv("USER"); 627 autologin = getenv("USER");
628 628
629 if (optind < argc) { 629 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)
362int 362int
363telnetd_main(int argc, char **argv) 363telnetd_main(int argc, char **argv)
364{ 364{
365 unsigned long opt; 365 unsigned opt;
366 fd_set rdfdset, wrfdset; 366 fd_set rdfdset, wrfdset;
367 int selret; 367 int selret;
368#ifndef CONFIG_FEATURE_TELNETD_INETD 368#ifndef CONFIG_FEATURE_TELNETD_INETD
@@ -387,7 +387,7 @@ telnetd_main(int argc, char **argv)
387 openlog(bb_applet_name, 0, LOG_USER); 387 openlog(bb_applet_name, 0, LOG_USER);
388 logmode = LOGMODE_SYSLOG; 388 logmode = LOGMODE_SYSLOG;
389 389
390 opt = bb_getopt_ulflags(argc, argv, "f:l:" USE_FEATURE_TELNETD_INETD("p:b:"), 390 opt = getopt32(argc, argv, "f:l:" USE_FEATURE_TELNETD_INETD("p:b:"),
391 &issuefile, &loginpath 391 &issuefile, &loginpath
392 SKIP_FEATURE_TELNETD_INETD(, &opt_portnbr, &opt_bindaddr)); 392 SKIP_FEATURE_TELNETD_INETD(, &opt_portnbr, &opt_bindaddr));
393 //if (opt & 1) // -f 393 //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)
497#endif 497#endif
498 498
499#if defined(CONFIG_FEATURE_TFTP_GET) && defined(CONFIG_FEATURE_TFTP_PUT) 499#if defined(CONFIG_FEATURE_TFTP_GET) && defined(CONFIG_FEATURE_TFTP_PUT)
500 bb_opt_complementally = GET_COMPL PUT_COMPL ":?g--p:p--g"; 500 opt_complementary = GET_COMPL PUT_COMPL ":?g--p:p--g";
501#elif defined(CONFIG_FEATURE_TFTP_GET) || defined(CONFIG_FEATURE_TFTP_PUT) 501#elif defined(CONFIG_FEATURE_TFTP_GET) || defined(CONFIG_FEATURE_TFTP_PUT)
502 bb_opt_complementally = GET_COMPL PUT_COMPL; 502 opt_complementary = GET_COMPL PUT_COMPL;
503#endif 503#endif
504 504
505 505
506 cmd = bb_getopt_ulflags(argc, argv, GET PUT "l:r:" BS, 506 cmd = getopt32(argc, argv, GET PUT "l:r:" BS,
507 &localfile, &remotefile BS_ARG); 507 &localfile, &remotefile BS_ARG);
508 508
509 cmd &= (tftp_cmd_get | tftp_cmd_put); 509 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[])
949 949
950 opterr = 0; 950 opterr = 0;
951#ifdef CONFIG_FEATURE_TRACEROUTE_SOURCE_ROUTE 951#ifdef CONFIG_FEATURE_TRACEROUTE_SOURCE_ROUTE
952 bb_opt_complementally = "x-x:g::"; 952 opt_complementary = "x-x:g::";
953#else 953#else
954 bb_opt_complementally = "x-x"; 954 opt_complementary = "x-x";
955#endif 955#endif
956 956
957 op = bb_getopt_ulflags(argc, argv, "FIlnrdvxt:i:m:p:q:s:w:z:f:" 957 op = getopt32(argc, argv, "FIlnrdvxt:i:m:p:q:s:w:z:f:"
958#define USAGE_OP_DONT_FRAGMNT (1<<0) /* F */ 958#define USAGE_OP_DONT_FRAGMNT (1<<0) /* F */
959#define USAGE_OP_USE_ICMP (1<<1) /* I */ 959#define USAGE_OP_USE_ICMP (1<<1) /* I */
960#define USAGE_OP_TTL_FLAG (1<<2) /* l */ 960#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[] = {
124int wget_main(int argc, char **argv) 124int wget_main(int argc, char **argv)
125{ 125{
126 int n, try=5, status; 126 int n, try=5, status;
127 unsigned long opt; 127 unsigned opt;
128 int port; 128 int port;
129 char *proxy = 0; 129 char *proxy = 0;
130 char *dir_prefix=NULL; 130 char *dir_prefix=NULL;
@@ -148,11 +148,11 @@ int wget_main(int argc, char **argv)
148 /* 148 /*
149 * Crack command line. 149 * Crack command line.
150 */ 150 */
151 bb_opt_complementally = "-1:\203::"; 151 opt_complementary = "-1:\203::";
152#if ENABLE_FEATURE_WGET_LONG_OPTIONS 152#if ENABLE_FEATURE_WGET_LONG_OPTIONS
153 bb_applet_long_options = wget_long_options; 153 applet_long_options = wget_long_options;
154#endif 154#endif
155 opt = bb_getopt_ulflags(argc, argv, "cq\213O:\203:P:Y:U:", 155 opt = getopt32(argc, argv, "cq\213O:\203:P:Y:U:",
156 &fname_out, &headers_llist, 156 &fname_out, &headers_llist,
157 &dir_prefix, &proxy_flag, &user_agent); 157 &dir_prefix, &proxy_flag, &user_agent);
158 if (strcmp(proxy_flag, "off") == 0) { 158 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 {
75#define VDBG(fmt,args...) \ 75#define VDBG(fmt,args...) \
76 do { } while (0) 76 do { } while (0)
77 77
78static unsigned long opts; 78static unsigned opts;
79#define FOREGROUND (opts & 1) 79#define FOREGROUND (opts & 1)
80#define QUIT (opts & 2) 80#define QUIT (opts & 2)
81 81
@@ -217,8 +217,8 @@ int zcip_main(int argc, char *argv[])
217 217
218 // parse commandline: prog [options] ifname script 218 // parse commandline: prog [options] ifname script
219 char *r_opt; 219 char *r_opt;
220 bb_opt_complementally = "vv:vf"; // -v accumulates and implies -f 220 opt_complementary = "vv:vf"; // -v accumulates and implies -f
221 opts = bb_getopt_ulflags(argc, argv, "fqr:v", &r_opt, &verbose); 221 opts = getopt32(argc, argv, "fqr:v", &r_opt, &verbose);
222 if (!FOREGROUND) { 222 if (!FOREGROUND) {
223 /* Do it early, before all bb_xx_msg calls */ 223 /* Do it early, before all bb_xx_msg calls */
224 logmode = LOGMODE_SYSLOG; 224 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)
39 unsigned long int opt; 39 unsigned long int opt;
40#if ENABLE_FEATURE_PIDOF_OMIT 40#if ENABLE_FEATURE_PIDOF_OMIT
41 llist_t *omits = NULL; /* list of pids to omit */ 41 llist_t *omits = NULL; /* list of pids to omit */
42 bb_opt_complementally = _OMIT_COMPL("o::"); 42 opt_complementary = _OMIT_COMPL("o::");
43#endif 43#endif
44 44
45 /* do unconditional option parsing */ 45 /* do unconditional option parsing */
46 opt = bb_getopt_ulflags(argc, argv, 46 opt = getopt32(argc, argv,
47 _SINGLE_COMPL("s") _OMIT_COMPL("o:") 47 _SINGLE_COMPL("s") _OMIT_COMPL("o:")
48 _OMIT(&omits)); 48 _OMIT(&omits));
49 49
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)
23 int terminal_width; 23 int terminal_width;
24 int w_count = 0; 24 int w_count = 0;
25 25
26 bb_opt_complementally = "-:ww"; 26 opt_complementary = "-:ww";
27#else 27#else
28# define terminal_width 79 28# define terminal_width 79
29#endif 29#endif
@@ -31,11 +31,11 @@ int ps_main(int argc, char **argv)
31#if ENABLE_FEATURE_PS_WIDE || ENABLE_SELINUX 31#if ENABLE_FEATURE_PS_WIDE || ENABLE_SELINUX
32 /* handle arguments */ 32 /* handle arguments */
33#if ENABLE_FEATURE_PS_WIDE && ENABLE_SELINUX 33#if ENABLE_FEATURE_PS_WIDE && ENABLE_SELINUX
34 i = bb_getopt_ulflags(argc, argv, "wc", &w_count); 34 i = getopt32(argc, argv, "wc", &w_count);
35#elif ENABLE_FEATURE_PS_WIDE && !ENABLE_SELINUX 35#elif ENABLE_FEATURE_PS_WIDE && !ENABLE_SELINUX
36 bb_getopt_ulflags(argc, argv, "w", &w_count); 36 getopt32(argc, argv, "w", &w_count);
37#else /* !ENABLE_FEATURE_PS_WIDE && ENABLE_SELINUX */ 37#else /* !ENABLE_FEATURE_PS_WIDE && ENABLE_SELINUX */
38 i = bb_getopt_ulflags(argc, argv, "c"); 38 i = getopt32(argc, argv, "c");
39#endif 39#endif
40#if ENABLE_FEATURE_PS_WIDE 40#if ENABLE_FEATURE_PS_WIDE
41 /* if w is given once, GNU ps sets the width to 132, 41 /* 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)
397 397
398 /* do normal option parsing */ 398 /* do normal option parsing */
399 interval = 5; 399 interval = 5;
400 bb_opt_complementally = "-"; 400 opt_complementary = "-";
401 option_mask = bb_getopt_ulflags(argc, argv, "d:n:b", 401 option_mask = getopt32(argc, argv, "d:n:b",
402 &sinterval, &siterations); 402 &sinterval, &siterations);
403 if (option_mask & 0x1) interval = atoi(sinterval); // -d 403 if (option_mask & 0x1) interval = atoi(sinterval); // -d
404 if (option_mask & 0x2) iterations = atoi(siterations); // -n 404 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)
238 238
239 { 239 {
240 char *m,*d,*o,*p,*f,*c,*r,*t,*n; 240 char *m,*d,*o,*p,*f,*c,*r,*t,*n;
241 option_mask = bb_getopt_ulflags(argc, argv, "u:U:e:m:d:o:p:f:c:r:t:/:n:vP012", 241 option_mask = getopt32(argc, argv, "u:U:e:m:d:o:p:f:c:r:t:/:n:vP012",
242 &set_user,&env_user,&env_dir, 242 &set_user,&env_user,&env_dir,
243 &m,&d,&o,&p,&f,&c,&r,&t,&root,&n); 243 &m,&d,&o,&p,&f,&c,&r,&t,&root,&n);
244 // if (option_mask & 0x1) // -u 244 // if (option_mask & 0x1) // -u
@@ -324,7 +324,7 @@ static void envdir(int argc, char **argv)
324static void softlimit(int argc, char **argv) 324static void softlimit(int argc, char **argv)
325{ 325{
326 char *a,*c,*d,*f,*l,*m,*o,*p,*r,*s,*t; 326 char *a,*c,*d,*f,*l,*m,*o,*p,*r,*s,*t;
327 option_mask = bb_getopt_ulflags(argc, argv, "a:c:d:f:l:m:o:p:r:s:t:", 327 option_mask = getopt32(argc, argv, "a:c:d:f:l:m:o:p:r:s:t:",
328 &a,&c,&d,&f,&l,&m,&o,&p,&r,&s,&t); 328 &a,&c,&d,&f,&l,&m,&o,&p,&r,&s,&t);
329 if (option_mask & 0x001) limita = bb_xgetularg10(a); // -a 329 if (option_mask & 0x001) limita = bb_xgetularg10(a); // -a
330 if (option_mask & 0x002) limitc = bb_xgetularg10(c); // -c 330 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[])
203 char *command=NULL; 203 char *command=NULL;
204 FILE *f; 204 FILE *f;
205 205
206 bb_getopt_ulflags(argc, argv, "c:", &command); 206 getopt32(argc, argv, "c:", &command);
207 207
208 f = argv[optind] ? xfopen(argv[optind],"r") : NULL; 208 f = argv[optind] ? xfopen(argv[optind],"r") : NULL;
209 if (command) handle(command); 209 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)
1503 1503
1504int lash_main(int argc_l, char **argv_l) 1504int lash_main(int argc_l, char **argv_l)
1505{ 1505{
1506 unsigned long opt; 1506 unsigned opt;
1507 FILE *input = stdin; 1507 FILE *input = stdin;
1508 argc = argc_l; 1508 argc = argc_l;
1509 argv = argv_l; 1509 argv = argv_l;
@@ -1527,7 +1527,7 @@ int lash_main(int argc_l, char **argv_l)
1527 } 1527 }
1528 } 1528 }
1529 1529
1530 opt = bb_getopt_ulflags(argc_l, argv_l, "+ic:", &local_pending_command); 1530 opt = getopt32(argc_l, argv_l, "+ic:", &local_pending_command);
1531#define LASH_OPT_i (1<<0) 1531#define LASH_OPT_i (1<<0)
1532#define LASH_OPT_c (1<<2) 1532#define LASH_OPT_c (1<<2)
1533 if (opt & LASH_OPT_c) { 1533 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)
45 45
46 46
47 { 47 {
48 unsigned long opt; 48 unsigned opt;
49 49
50 /* do normal option parsing */ 50 /* do normal option parsing */
51 opt = bb_getopt_ulflags(argc, argv, "c:n", &start); 51 opt = getopt32(argc, argv, "c:n", &start);
52 52
53 if (opt & OPT_LEVEL) { 53 if (opt & OPT_LEVEL) {
54 /* Valid levels are between 1 and 8 */ 54 /* 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)
89 89
90int logger_main(int argc, char **argv) 90int logger_main(int argc, char **argv)
91{ 91{
92 unsigned long opt; 92 unsigned opt;
93 char *opt_p, *opt_t; 93 char *opt_p, *opt_t;
94 int pri = LOG_USER | LOG_NOTICE; 94 int pri = LOG_USER | LOG_NOTICE;
95 int option = 0; 95 int option = 0;
@@ -100,7 +100,7 @@ int logger_main(int argc, char **argv)
100 bb_getpwuid(name, geteuid(), sizeof(name)); 100 bb_getpwuid(name, geteuid(), sizeof(name));
101 101
102 /* Parse any options */ 102 /* Parse any options */
103 opt = bb_getopt_ulflags(argc, argv, "p:st:", &opt_p, &opt_t); 103 opt = getopt32(argc, argv, "p:st:", &opt_p, &opt_t);
104 if (opt & 0x1) pri = pencode(opt_p); // -p 104 if (opt & 0x1) pri = pencode(opt_p); // -p
105 if (opt & 0x2) option |= LOG_PERROR; // -s 105 if (opt & 0x2) option |= LOG_PERROR; // -s
106 if (opt & 0x4) safe_strncpy(name, opt_t, sizeof(name)); // -t 106 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)
575 char *p; 575 char *p;
576 576
577 /* do normal option parsing */ 577 /* do normal option parsing */
578 option_mask = bb_getopt_ulflags(argc, argv, OPTION_STR, OPTION_PARAM); 578 option_mask = getopt32(argc, argv, OPTION_STR, OPTION_PARAM);
579 if (option_mask & OPT_mark) MarkInterval = atoi(opt_m) * 60; // -m 579 if (option_mask & OPT_mark) MarkInterval = atoi(opt_m) * 60; // -m
580 //if (option_mask & OPT_nofork) // -n 580 //if (option_mask & OPT_nofork) // -n
581 //if (option_mask & OPT_outfile) // -O 581 //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 @@
16int dmesg_main(int argc, char *argv[]) 16int dmesg_main(int argc, char *argv[])
17{ 17{
18 char *size, *level; 18 char *size, *level;
19 int flags = bb_getopt_ulflags(argc, argv, "cs:n:", &size, &level); 19 int flags = getopt32(argc, argv, "cs:n:", &size, &level);
20 20
21 if (flags & 4) { 21 if (flags & 4) {
22 if (klogctl(8, NULL, bb_xgetlarg(level, 10, 0, 10))) 22 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)
63 if (argc < 2) { 63 if (argc < 2) {
64 bb_show_usage(); 64 bb_show_usage();
65 } 65 }
66 verify = !bb_getopt_ulflags(argc, argv, "n"); 66 verify = !getopt32(argc, argv, "n");
67 argv += optind; 67 argv += optind;
68 68
69 xstat(*argv, &st); 69 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 };
184#define init_longopt() add_longopt(NULL,0) 184#define init_longopt() add_longopt(NULL,0)
185 185
186/* Register a long option. The contents of name is copied. */ 186/* Register a long option. The contents of name is copied. */
187void add_longopt(const char *name,int has_arg) 187void add_longopt(const char *name, int has_arg)
188{ 188{
189 if (!name) { /* init */ 189 if (!name) { /* init */
190 free(long_options); 190 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)
182 182
183int hwclock_main ( int argc, char **argv ) 183int hwclock_main ( int argc, char **argv )
184{ 184{
185 unsigned long opt; 185 unsigned opt;
186 int utc; 186 int utc;
187 187
188#if ENABLE_FEATURE_HWCLOCK_LONG_OPTIONS 188#if ENABLE_FEATURE_HWCLOCK_LONG_OPTIONS
@@ -194,11 +194,11 @@ static const struct option hwclock_long_options[] = {
194 { "systohc", 0, 0, 'w' }, 194 { "systohc", 0, 0, 'w' },
195 { 0, 0, 0, 0 } 195 { 0, 0, 0, 0 }
196 }; 196 };
197 bb_applet_long_options = hwclock_long_options; 197 applet_long_options = hwclock_long_options;
198#endif 198#endif
199 199
200 bb_opt_complementally = "?:r--ws:w--rs:s--wr:l--u:u--l"; 200 opt_complementary = "?:r--ws:w--rs:s--wr:l--u:u--l";
201 opt = bb_getopt_ulflags(argc, argv, "lursw"); 201 opt = getopt32(argc, argv, "lursw");
202 202
203 /* If -u or -l wasn't given check if we are using utc */ 203 /* If -u or -l wasn't given check if we are using utc */
204 if (opt & (HWCLOCK_OPT_UTC | HWCLOCK_OPT_LOCALTIME)) 204 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)
572{ 572{
573 int id = 0; 573 int id = 0;
574 unsigned flags = 0; 574 unsigned flags = 0;
575 unsigned long opt; 575 unsigned opt;
576 char *opt_i; 576 char *opt_i;
577#define flag_print (1<<0) 577#define flag_print (1<<0)
578#define flag_msg (1<<1) 578#define flag_msg (1<<1)
579#define flag_sem (1<<2) 579#define flag_sem (1<<2)
580#define flag_shm (1<<3) 580#define flag_shm (1<<3)
581 581
582 opt = bb_getopt_ulflags(argc, argv, "i:aqsmtcplu", &opt_i); 582 opt = getopt32(argc, argv, "i:aqsmtcplu", &opt_i);
583 if (opt & 0x1) { // -i 583 if (opt & 0x1) { // -i
584 id = atoi(opt_i); 584 id = atoi(opt_i);
585 flags |= flag_print; 585 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 @@
14 14
15int losetup_main(int argc, char **argv) 15int losetup_main(int argc, char **argv)
16{ 16{
17 unsigned long opt; 17 unsigned opt;
18 char *opt_o; 18 char *opt_o;
19 int offset = 0; 19 int offset = 0;
20 20
21 opt = bb_getopt_ulflags(argc, argv, "do:", &opt_o); 21 opt = getopt32(argc, argv, "do:", &opt_o);
22 argc -= optind; 22 argc -= optind;
23 argv += optind; 23 argv += optind;
24 24
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)
1428 const char *fstabname; 1428 const char *fstabname;
1429 FILE *fstab; 1429 FILE *fstab;
1430 int i, j, rc = 0; 1430 int i, j, rc = 0;
1431 unsigned long opt; 1431 unsigned opt;
1432 struct mntent mtpair[2], *mtcur = mtpair; 1432 struct mntent mtpair[2], *mtcur = mtpair;
1433 1433
1434 /* parse long options, like --bind and --move. Note that -o option 1434 /* parse long options, like --bind and --move. Note that -o option
@@ -1444,7 +1444,7 @@ int mount_main(int argc, char **argv)
1444 1444
1445 // Parse remaining options 1445 // Parse remaining options
1446 1446
1447 opt = bb_getopt_ulflags(argc, argv, "o:t:rwanfvs", &opt_o, &fstype); 1447 opt = getopt32(argc, argv, "o:t:rwanfvs", &opt_o, &fstype);
1448 if (opt & 0x1) append_mount_options(&cmdopts, opt_o); // -o 1448 if (opt & 0x1) append_mount_options(&cmdopts, opt_o); // -o
1449 //if (opt & 0x2) // -t 1449 //if (opt & 0x2) // -t
1450 if (opt & 0x4) append_mount_options(&cmdopts, "ro"); // -r 1450 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)
63 time_t remote_time; 63 time_t remote_time;
64 unsigned long flags; 64 unsigned long flags;
65 65
66 bb_opt_complementally = "-1"; 66 opt_complementary = "-1";
67 flags = bb_getopt_ulflags(argc, argv, "sp"); 67 flags = getopt32(argc, argv, "sp");
68 68
69 remote_time = askremotedate(argv[optind]); 69 remote_time = askremotedate(argv[optind]);
70 70
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)
64 proFile = defaultpro; 64 proFile = defaultpro;
65 mapFile = defaultmap; 65 mapFile = defaultmap;
66 66
67 bb_opt_complementally = "nn:aa:bb:ss:ii:rr:vv"; 67 opt_complementary = "nn:aa:bb:ss:ii:rr:vv";
68 bb_getopt_ulflags(argc, argv, "M:m:p:nabsirv", 68 getopt32(argc, argv, "M:m:p:nabsirv",
69 &mult, &mapFile, &proFile, 69 &mult, &mapFile, &proFile,
70 &optNative, &optAll, &optBins, &optSub, 70 &optNative, &optAll, &optBins, &optSub,
71 &optInfo, &optReset, &optVerbose); 71 &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)
66 if (argc == 1) 66 if (argc == 1)
67 bb_show_usage(); 67 bb_show_usage();
68 68
69 ret = bb_getopt_ulflags(argc, argv, "a"); 69 ret = getopt32(argc, argv, "a");
70 if (ret & DO_ALL) 70 if (ret & DO_ALL)
71 return do_em_all(); 71 return do_em_all();
72 72
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[])
71 71
72 // Parse args (-c console) 72 // Parse args (-c console)
73 73
74 bb_opt_complementally="-2"; 74 opt_complementary="-2";
75 bb_getopt_ulflags(argc,argv,"c:",&console); 75 getopt32(argc,argv,"c:",&console);
76 76
77 // Change to new root directory and verify it's a different fs. 77 // Change to new root directory and verify it's a different fs.
78 78
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)
27 struct mntent me; 27 struct mntent me;
28 FILE *fp; 28 FILE *fp;
29 int status = EXIT_SUCCESS; 29 int status = EXIT_SUCCESS;
30 unsigned long opt; 30 unsigned opt;
31 struct mtab_list { 31 struct mtab_list {
32 char *dir; 32 char *dir;
33 char *device; 33 char *device;
@@ -36,7 +36,7 @@ int umount_main(int argc, char **argv)
36 36
37 /* Parse any options */ 37 /* Parse any options */
38 38
39 opt = bb_getopt_ulflags(argc, argv, OPTION_STRING); 39 opt = getopt32(argc, argv, OPTION_STRING);
40 40
41 argc -= optind; 41 argc -= optind;
42 argv += optind; 42 argv += optind;