From 67b23e6043d8e2b30b0bf3bc105b8583c2a26db5 Mon Sep 17 00:00:00 2001
From: Denis Vlasenko
Date: Tue, 3 Oct 2006 21:00:06 +0000
Subject: [PATCH] getopt_ulflags -> getopt32. It is impossible to formulate
sane ABI based on size of ulong because it can be 32-bit or 64-bit. Basically
it means that you cannot portably use more that 32 option chars in one call
anyway... Make it explicit.
---
archival/ar.c | 6 +-
archival/bunzip2.c | 4 +-
archival/cpio.c | 4 +-
archival/dpkg_deb.c | 6 +-
archival/gunzip.c | 4 +-
archival/gzip.c | 6 +-
archival/tar.c | 8 +-
archival/uncompress.c | 2 +-
archival/unlzma.c | 4 +-
console-tools/setconsole.c | 4 +-
coreutils/cal.c | 2 +-
coreutils/cat.c | 2 +-
coreutils/catv.c | 2 +-
coreutils/chgrp.c | 2 +-
coreutils/chown.c | 2 +-
coreutils/cmp.c | 2 +-
coreutils/comm.c | 2 +-
coreutils/cp.c | 2 +-
coreutils/cut.c | 10 +-
coreutils/date.c | 6 +-
coreutils/df.c | 8 +-
coreutils/diff.c | 4 +-
coreutils/dos2unix.c | 4 +-
coreutils/du.c | 10 +-
coreutils/env.c | 8 +-
coreutils/fold.c | 2 +-
coreutils/head.c | 2 +-
coreutils/id.c | 4 +-
coreutils/install.c | 6 +-
coreutils/libcoreutils/getopt_mk_fifo_nod.c | 2 +-
coreutils/ln.c | 2 +-
coreutils/ls.c | 8 +-
coreutils/md5_sha1_sum.c | 2 +-
coreutils/mkdir.c | 6 +-
coreutils/mv.c | 6 +-
coreutils/rm.c | 6 +-
coreutils/rmdir.c | 2 +-
coreutils/stat.c | 2 +-
coreutils/sum.c | 2 +-
coreutils/tee.c | 2 +-
coreutils/touch.c | 2 +-
coreutils/tty.c | 2 +-
coreutils/uname.c | 2 +-
coreutils/uudecode.c | 2 +-
coreutils/uuencode.c | 2 +-
coreutils/wc.c | 2 +-
debianutils/mktemp.c | 2 +-
debianutils/readlink.c | 4 +-
debianutils/start_stop_daemon.c | 8 +-
docs/busybox.net/FAQ.html | 2 +-
e2fsprogs/lsattr.c | 2 +-
editors/awk.c | 4 +-
editors/patch.c | 2 +-
editors/sed.c | 10 +-
findutils/grep.c | 10 +-
findutils/xargs.c | 4 +-
include/libbb.h | 8 +-
init/halt.c | 2 +-
libbb/Makefile.in | 2 +-
libbb/{getopt_ulflags.c => getopt32.c} | 145 ++++++++++----------
loginutils/addgroup.c | 4 +-
loginutils/adduser.c | 4 +-
loginutils/getty.c | 2 +-
loginutils/login.c | 4 +-
loginutils/passwd.c | 4 +-
loginutils/su.c | 2 +-
loginutils/sulogin.c | 2 +-
loginutils/vlock.c | 2 +-
miscutils/adjtimex.c | 4 +-
miscutils/crond.c | 8 +-
miscutils/eject.c | 4 +-
miscutils/hdparm.c | 44 +++---
miscutils/less.c | 2 +-
miscutils/makedevs.c | 2 +-
miscutils/mountpoint.c | 2 +-
miscutils/strings.c | 4 +-
miscutils/watchdog.c | 4 +-
modutils/insmod.c | 2 +-
modutils/modprobe.c | 4 +-
modutils/rmmod.c | 2 +-
networking/arping.c | 6 +-
networking/dnsd.c | 2 +-
networking/ether-wake.c | 2 +-
networking/fakeidentd.c | 2 +-
networking/ftpgetput.c | 6 +-
networking/hostname.c | 4 +-
networking/httpd.c | 4 +-
networking/ifupdown.c | 2 +-
networking/inetd.c | 2 +-
networking/ipcalc.c | 4 +-
networking/nameif.c | 2 +-
networking/netstat.c | 6 +-
networking/route.c | 4 +-
networking/telnet.c | 2 +-
networking/telnetd.c | 4 +-
networking/tftp.c | 6 +-
networking/traceroute.c | 6 +-
networking/wget.c | 8 +-
networking/zcip.c | 6 +-
procps/pidof.c | 4 +-
procps/ps.c | 8 +-
procps/top.c | 4 +-
runit/chpst.c | 4 +-
shell/bbsh.c | 2 +-
shell/lash.c | 4 +-
sysklogd/klogd.c | 4 +-
sysklogd/logger.c | 4 +-
sysklogd/syslogd.c | 2 +-
util-linux/dmesg.c | 2 +-
util-linux/fdformat.c | 2 +-
util-linux/getopt.c | 2 +-
util-linux/hwclock.c | 8 +-
util-linux/ipcs.c | 4 +-
util-linux/losetup.c | 4 +-
util-linux/mount.c | 4 +-
util-linux/rdate.c | 4 +-
util-linux/readprofile.c | 4 +-
util-linux/swaponoff.c | 2 +-
util-linux/switch_root.c | 4 +-
util-linux/umount.c | 4 +-
120 files changed, 322 insertions(+), 327 deletions(-)
rename libbb/{getopt_ulflags.c => getopt32.c} (77%)
diff --git a/archival/ar.c b/archival/ar.c
index e10bf7c47..06a879b93 100644
--- a/archival/ar.c
+++ b/archival/ar.c
@@ -41,7 +41,7 @@ static void header_verbose_list_ar(const file_header_t *file_header)
int ar_main(int argc, char **argv)
{
archive_handle_t *archive_handle;
- unsigned long opt;
+ unsigned opt;
static const char msg_unsupported_err[] =
"Archive %s not supported. Install binutils 'ar'.";
char magic[8];
@@ -49,8 +49,8 @@ int ar_main(int argc, char **argv)
archive_handle = init_handle();
/* Prepend '-' to the first argument if required */
- bb_opt_complementally = "--:p:t:x:-1:?:p--tx:t--px:x--pt";
- opt = bb_getopt_ulflags(argc, argv, "ptxovcr");
+ opt_complementary = "--:p:t:x:-1:?:p--tx:t--px:x--pt";
+ opt = getopt32(argc, argv, "ptxovcr");
if (opt & AR_CTX_PRINT) {
archive_handle->action_data = data_extract_to_stdout;
diff --git a/archival/bunzip2.c b/archival/bunzip2.c
index 9d62366c3..faf997bbe 100644
--- a/archival/bunzip2.c
+++ b/archival/bunzip2.c
@@ -16,10 +16,10 @@ int bunzip2_main(int argc, char **argv)
{
USE_DESKTOP(long long) int status;
char *filename;
- unsigned long opt;
+ unsigned opt;
int src_fd, dst_fd;
- opt = bb_getopt_ulflags(argc, argv, "cf");
+ opt = getopt32(argc, argv, "cf");
/* Set input filename and number */
filename = argv[optind];
diff --git a/archival/cpio.c b/archival/cpio.c
index 48b688e79..d0d3288ff 100644
--- a/archival/cpio.c
+++ b/archival/cpio.c
@@ -30,7 +30,7 @@ int cpio_main(int argc, char **argv)
{
archive_handle_t *archive_handle;
char *cpio_filename = NULL;
- unsigned long opt;
+ unsigned opt;
/* Initialise */
archive_handle = init_handle();
@@ -38,7 +38,7 @@ int cpio_main(int argc, char **argv)
archive_handle->seek = seek_by_char;
archive_handle->flags = ARCHIVE_EXTRACT_NEWER | ARCHIVE_PRESERVE_DATE;
- opt = bb_getopt_ulflags(argc, argv, "ituvF:dm", &cpio_filename);
+ opt = getopt32(argc, argv, "ituvF:dm", &cpio_filename);
/* One of either extract or test options must be given */
if ((opt & (CPIO_OPT_TEST | CPIO_OPT_EXTRACT)) == 0) {
diff --git a/archival/dpkg_deb.c b/archival/dpkg_deb.c
index ce65e219a..80a5f3250 100644
--- a/archival/dpkg_deb.c
+++ b/archival/dpkg_deb.c
@@ -18,7 +18,7 @@ int dpkg_deb_main(int argc, char **argv)
archive_handle_t *ar_archive;
archive_handle_t *tar_archive;
llist_t *control_tar_llist = NULL;
- unsigned long opt;
+ unsigned opt;
char *extract_dir = NULL;
short argcount = 1;
@@ -40,8 +40,8 @@ int dpkg_deb_main(int argc, char **argv)
llist_add_to(&control_tar_llist, "control.tar.bz2");
#endif
- bb_opt_complementally = "?c--efXx:e--cfXx:f--ceXx:X--cefx:x--cefX";
- opt = bb_getopt_ulflags(argc, argv, "cefXx");
+ opt_complementary = "?c--efXx:e--cfXx:f--ceXx:X--cefx:x--cefX";
+ opt = getopt32(argc, argv, "cefXx");
if (opt & DPKG_DEB_OPT_CONTENTS) {
tar_archive->action_header = header_verbose_list;
diff --git a/archival/gunzip.c b/archival/gunzip.c
index 1b4968628..1cde08b4d 100644
--- a/archival/gunzip.c
+++ b/archival/gunzip.c
@@ -40,9 +40,9 @@ int gunzip_main(int argc, char **argv)
{
USE_DESKTOP(long long) int status;
int exitcode = 0;
- unsigned long opt;
+ unsigned opt;
- opt = bb_getopt_ulflags(argc, argv, "cftdv");
+ opt = getopt32(argc, argv, "cftdv");
/* if called as zcat */
if (strcmp(bb_applet_name, "zcat") == 0) {
opt |= GUNZIP_OPT_STDOUT;
diff --git a/archival/gzip.c b/archival/gzip.c
index 2fc9f7698..ef3724c34 100644
--- a/archival/gzip.c
+++ b/archival/gzip.c
@@ -1134,14 +1134,14 @@ int gzip_main(int argc, char **argv)
OPT_force = 0x2,
};
- unsigned long opt;
+ unsigned opt;
int result;
int inFileNum;
int outFileNum;
struct stat statBuf;
char *delFileName;
- opt = bb_getopt_ulflags(argc, argv, "cf123456789qv" USE_GUNZIP("d"));
+ opt = getopt32(argc, argv, "cf123456789qv" USE_GUNZIP("d"));
//if (opt & 0x1) // -c
//if (opt & 0x2) // -f
/* Ignore 1-9 (compression level) options */
@@ -1157,7 +1157,7 @@ int gzip_main(int argc, char **argv)
//if (opt & 0x800) // -q
//if (opt & 0x1000) // -v
if (ENABLE_GUNZIP && (opt & 0x2000)) { // -d
- /* FIXME: bb_getopt_ulflags should not depend on optind */
+ /* FIXME: getopt32 should not depend on optind */
optind = 1;
return gunzip_main(argc, argv);
}
diff --git a/archival/tar.c b/archival/tar.c
index bfee638b4..3775598cc 100644
--- a/archival/tar.c
+++ b/archival/tar.c
@@ -688,7 +688,7 @@ int tar_main(int argc, char **argv)
archive_handle_t *tar_handle;
char *base_dir = NULL;
const char *tar_filename = "-";
- unsigned long opt;
+ unsigned opt;
llist_t *excludes = NULL;
/* Initialise default values */
@@ -696,12 +696,12 @@ int tar_main(int argc, char **argv)
tar_handle->flags = ARCHIVE_CREATE_LEADING_DIRS | ARCHIVE_PRESERVE_DATE | ARCHIVE_EXTRACT_UNCONDITIONAL;
/* Prepend '-' to the first argument if required */
- bb_opt_complementally = ENABLE_FEATURE_TAR_CREATE ?
+ opt_complementary = ENABLE_FEATURE_TAR_CREATE ?
"--:X::T::\n::c:t:x:?:c--tx:t--cx:x--ct" :
"--:X::T::\n::t:x:?:t--x:x--t";
if (ENABLE_FEATURE_TAR_LONG_OPTIONS)
- bb_applet_long_options = tar_long_options;
- opt = bb_getopt_ulflags(argc, argv, tar_options,
+ applet_long_options = tar_long_options;
+ opt = getopt32(argc, argv, tar_options,
&base_dir, /* Change to dir */
&tar_filename /* archive filename */
#ifdef CONFIG_FEATURE_TAR_FROM
diff --git a/archival/uncompress.c b/archival/uncompress.c
index 91568e45f..d1b0d2cb3 100644
--- a/archival/uncompress.c
+++ b/archival/uncompress.c
@@ -16,7 +16,7 @@ int uncompress_main(int argc, char **argv)
int status = EXIT_SUCCESS;
unsigned long flags;
- flags = bb_getopt_ulflags(argc, argv, "cf");
+ flags = getopt32(argc, argv, "cf");
while (optind < argc) {
char *compressed_file = argv[optind++];
diff --git a/archival/unlzma.c b/archival/unlzma.c
index b87a3fe79..20891e316 100644
--- a/archival/unlzma.c
+++ b/archival/unlzma.c
@@ -19,10 +19,10 @@ int unlzma_main(int argc, char **argv)
{
USE_DESKTOP(long long) int status;
char *filename;
- unsigned long opt;
+ unsigned opt;
int src_fd, dst_fd;
- opt = bb_getopt_ulflags(argc, argv, "c");
+ opt = getopt32(argc, argv, "c");
/* Set input filename and number */
filename = argv[optind];
diff --git a/console-tools/setconsole.c b/console-tools/setconsole.c
index 71fe928da..ef81f298b 100644
--- a/console-tools/setconsole.c
+++ b/console-tools/setconsole.c
@@ -24,9 +24,9 @@ int setconsole_main(int argc, char **argv)
const char *device = CURRENT_TTY;
#if ENABLE_FEATURE_SETCONSOLE_LONG_OPTIONS
- bb_applet_long_options = setconsole_long_options;
+ applet_long_options = setconsole_long_options;
#endif
- flags = bb_getopt_ulflags(argc, argv, "r");
+ flags = getopt32(argc, argv, "r");
if (argc - optind > 1)
bb_show_usage();
diff --git a/coreutils/cal.c b/coreutils/cal.c
index 8996aa8c7..ef914128c 100644
--- a/coreutils/cal.c
+++ b/coreutils/cal.c
@@ -91,7 +91,7 @@ int cal_main(int argc, char **argv)
setlocale(LC_TIME, "");
#endif
- flags = bb_getopt_ulflags(argc, argv, "jy");
+ flags = getopt32(argc, argv, "jy");
julian = flags & 1;
diff --git a/coreutils/cat.c b/coreutils/cat.c
index 37237ec1d..f3baf0a2d 100644
--- a/coreutils/cat.c
+++ b/coreutils/cat.c
@@ -18,7 +18,7 @@ int cat_main(int argc, char **argv)
FILE *f;
int retval = EXIT_SUCCESS;
- bb_getopt_ulflags(argc, argv, "u");
+ getopt32(argc, argv, "u");
argv += optind;
if (!*argv) {
diff --git a/coreutils/catv.c b/coreutils/catv.c
index f8229c20e..55656b4b2 100644
--- a/coreutils/catv.c
+++ b/coreutils/catv.c
@@ -17,7 +17,7 @@ int catv_main(int argc, char **argv)
int retval = EXIT_SUCCESS, fd;
unsigned long flags;
- flags = bb_getopt_ulflags(argc, argv, "etv");
+ flags = getopt32(argc, argv, "etv");
#define CATV_OPT_e (1<<0)
#define CATV_OPT_t (1<<1)
#define CATV_OPT_v (1<<2)
diff --git a/coreutils/chgrp.c b/coreutils/chgrp.c
index 5064f2d6e..e62bd16f0 100644
--- a/coreutils/chgrp.c
+++ b/coreutils/chgrp.c
@@ -31,7 +31,7 @@ int chgrp_main(int argc, char **argv)
int recursiveFlag;
int retval = EXIT_SUCCESS;
- recursiveFlag = bb_getopt_ulflags(argc, argv, "R");
+ recursiveFlag = getopt32(argc, argv, "R");
if (argc - optind < 2) {
bb_show_usage();
diff --git a/coreutils/chown.c b/coreutils/chown.c
index bb379ac20..b73f66a89 100644
--- a/coreutils/chown.c
+++ b/coreutils/chown.c
@@ -43,7 +43,7 @@ int chown_main(int argc, char **argv)
int retval = EXIT_SUCCESS;
char *groupName;
- flags = bb_getopt_ulflags(argc, argv, "Rh");
+ flags = getopt32(argc, argv, "Rh");
if (flags & FLAG_h) chown_func = lchown;
diff --git a/coreutils/cmp.c b/coreutils/cmp.c
index d0d976997..07858c64e 100644
--- a/coreutils/cmp.c
+++ b/coreutils/cmp.c
@@ -54,7 +54,7 @@ int cmp_main(int argc, char **argv)
xfunc_error_retval = 2; /* 1 is returned if files are different. */
- opt = bb_getopt_ulflags(argc, argv, opt_chars);
+ opt = getopt32(argc, argv, opt_chars);
if (((opt & (CMP_OPT_s|CMP_OPT_l)) == (CMP_OPT_s|CMP_OPT_l))
|| (((unsigned int)(--argc - optind)) > 1))
diff --git a/coreutils/comm.c b/coreutils/comm.c
index 7524a7b25..91f017753 100644
--- a/coreutils/comm.c
+++ b/coreutils/comm.c
@@ -112,7 +112,7 @@ int comm_main(int argc, char **argv)
{
unsigned long flags;
- flags = bb_getopt_ulflags(argc, argv, "123");
+ flags = getopt32(argc, argv, "123");
if (optind + 2 != argc)
bb_show_usage();
diff --git a/coreutils/cp.c b/coreutils/cp.c
index 85086aab5..fabfe58e0 100644
--- a/coreutils/cp.c
+++ b/coreutils/cp.c
@@ -39,7 +39,7 @@ int cp_main(int argc, char **argv)
int flags;
int status = 0;
- flags = bb_getopt_ulflags(argc, argv, "pdRfiarPHL");
+ flags = getopt32(argc, argv, "pdRfiarPHL");
if (flags & 32) {
flags |= (FILEUTILS_PRESERVE_STATUS | FILEUTILS_RECUR | FILEUTILS_DEREFERENCE);
diff --git a/coreutils/cut.c b/coreutils/cut.c
index d88a891b0..30dbc02db 100644
--- a/coreutils/cut.c
+++ b/coreutils/cut.c
@@ -12,14 +12,13 @@
#include "busybox.h"
/* option vars */
-static const char *const optstring = "b:c:f:d:sn";
-
+static const char optstring[] = "b:c:f:d:sn";
#define CUT_OPT_BYTE_FLGS (1<<0)
#define CUT_OPT_CHAR_FLGS (1<<1)
#define CUT_OPT_FIELDS_FLGS (1<<2)
#define CUT_OPT_DELIM_FLGS (1<<3)
#define CUT_OPT_SUPPRESS_FLGS (1<<4)
-static unsigned long opt;
+static unsigned opt;
static char delim = '\t'; /* delimiter, default is tab */
@@ -179,9 +178,8 @@ int cut_main(int argc, char **argv)
{
char *sopt, *ltok;
- bb_opt_complementally = "b--bcf:c--bcf:f--bcf";
- opt =
- bb_getopt_ulflags(argc, argv, optstring, &sopt, &sopt, &sopt, <ok);
+ opt_complementary = "b--bcf:c--bcf:f--bcf";
+ opt = getopt32(argc, argv, optstring, &sopt, &sopt, &sopt, <ok);
if (!(opt & (CUT_OPT_BYTE_FLGS | CUT_OPT_CHAR_FLGS | CUT_OPT_FIELDS_FLGS)))
bb_error_msg_and_die
("expected a list of bytes, characters, or fields");
diff --git a/coreutils/date.c b/coreutils/date.c
index 2a82e0413..74e99665d 100644
--- a/coreutils/date.c
+++ b/coreutils/date.c
@@ -42,7 +42,7 @@ int date_main(int argc, char **argv)
{
time_t tm;
struct tm tm_time;
- unsigned long opt;
+ unsigned opt;
int ifmt = -1;
char *date_str = NULL;
char *date_fmt = NULL;
@@ -50,9 +50,9 @@ int date_main(int argc, char **argv)
char *isofmt_arg;
char *hintfmt_arg;
- bb_opt_complementally = "?:d--s:s--d"
+ opt_complementary = "?:d--s:s--d"
USE_FEATURE_DATE_ISOFMT(":R--I:I--R");
- opt = bb_getopt_ulflags(argc, argv, "Rs:ud:r:"
+ opt = getopt32(argc, argv, "Rs:ud:r:"
USE_FEATURE_DATE_ISOFMT("I::D:"),
&date_str, &date_str, &filename
USE_FEATURE_DATE_ISOFMT(, &isofmt_arg, &hintfmt_arg));
diff --git a/coreutils/df.c b/coreutils/df.c
index 17ce634a7..94ead32eb 100644
--- a/coreutils/df.c
+++ b/coreutils/df.c
@@ -41,7 +41,7 @@ int df_main(int argc, char **argv)
unsigned long df_disp_hr = KILOBYTE;
#endif
int status = EXIT_SUCCESS;
- unsigned long opt;
+ unsigned opt;
FILE *mount_table;
struct mntent *mount_entry;
struct statfs s;
@@ -49,8 +49,8 @@ int df_main(int argc, char **argv)
const char *disp_units_hdr = hdr_1k;
#ifdef CONFIG_FEATURE_HUMAN_READABLE
- bb_opt_complementally = "h-km:k-hm:m-hk";
- opt = bb_getopt_ulflags(argc, argv, "hmk");
+ opt_complementary = "h-km:k-hm:m-hk";
+ opt = getopt32(argc, argv, "hmk");
if(opt & 1) {
df_disp_hr = 0;
disp_units_hdr = " Size";
@@ -60,7 +60,7 @@ int df_main(int argc, char **argv)
disp_units_hdr = "1M-blocks";
}
#else
- opt = bb_getopt_ulflags(argc, argv, "k");
+ opt = getopt32(argc, argv, "k");
#endif
bb_printf("Filesystem%11s%-15sUsed Available Use%% Mounted on\n",
diff --git a/coreutils/diff.c b/coreutils/diff.c
index 3c409b2cf..2edcd96ca 100644
--- a/coreutils/diff.c
+++ b/coreutils/diff.c
@@ -1164,9 +1164,9 @@ int diff_main(int argc, char **argv)
char *U_opt;
llist_t *L_arg = NULL;
- bb_opt_complementally = "L::";
+ opt_complementary = "L::";
cmd_flags =
- bb_getopt_ulflags(argc, argv, "abdiL:NqrsS:tTU:wu", &L_arg, &start,
+ getopt32(argc, argv, "abdiL:NqrsS:tTU:wu", &L_arg, &start,
&U_opt);
if (cmd_flags & FLAG_L) {
diff --git a/coreutils/dos2unix.c b/coreutils/dos2unix.c
index 19f1a3257..a8038a6dd 100644
--- a/coreutils/dos2unix.c
+++ b/coreutils/dos2unix.c
@@ -93,11 +93,11 @@ int dos2unix_main(int argc, char *argv[])
ConvType = CT_UNIX2DOS; /*1 */
}
/* -u and -d are mutally exclusive */
- bb_opt_complementally = "?:u--d:d--u";
+ opt_complementary = "?:u--d:d--u";
/* process parameters */
/* -u convert to unix */
/* -d convert to dos */
- o = bb_getopt_ulflags(argc, argv, "du");
+ o = getopt32(argc, argv, "du");
/* Do the conversion requested by an argument else do the default
* conversion depending on our name. */
diff --git a/coreutils/du.c b/coreutils/du.c
index 3cc935553..1452e5883 100644
--- a/coreutils/du.c
+++ b/coreutils/du.c
@@ -153,7 +153,7 @@ int du_main(int argc, char **argv)
int slink_depth_save;
int print_final_total;
char *smax_print_depth;
- unsigned long opt;
+ unsigned opt;
#ifdef CONFIG_FEATURE_DU_DEFUALT_BLOCKSIZE_1K
if (getenv("POSIXLY_CORRECT")) { /* TODO - a new libbb function? */
@@ -172,8 +172,8 @@ int du_main(int argc, char **argv)
* ignore -a. This is consistent with -s being equivalent to -d 0.
*/
#ifdef CONFIG_FEATURE_HUMAN_READABLE
- bb_opt_complementally = "h-km:k-hm:m-hk:H-L:L-H:s-d:d-s";
- opt = bb_getopt_ulflags(argc, argv, "aHkLsx" "d:" "lc" "hm", &smax_print_depth);
+ opt_complementary = "h-km:k-hm:m-hk:H-L:L-H:s-d:d-s";
+ opt = getopt32(argc, argv, "aHkLsx" "d:" "lc" "hm", &smax_print_depth);
if((opt & (1 << 9))) {
/* -h opt */
disp_hr = 0;
@@ -187,8 +187,8 @@ int du_main(int argc, char **argv)
disp_hr = KILOBYTE;
}
#else
- bb_opt_complementally = "H-L:L-H:s-d:d-s";
- opt = bb_getopt_ulflags(argc, argv, "aHkLsx" "d:" "lc", &smax_print_depth);
+ opt_complementary = "H-L:L-H:s-d:d-s";
+ opt = getopt32(argc, argv, "aHkLsx" "d:" "lc", &smax_print_depth);
#if !defined CONFIG_FEATURE_DU_DEFAULT_BLOCKSIZE_1K
if((opt & (1 << 2))) {
/* -k opt */
diff --git a/coreutils/env.c b/coreutils/env.c
index 2af15a37e..d03318fea 100644
--- a/coreutils/env.c
+++ b/coreutils/env.c
@@ -46,16 +46,16 @@ int env_main(int argc, char** argv)
static char *cleanenv[1] = { NULL };
char **ep;
- unsigned long opt;
+ unsigned opt;
llist_t *unset_env = NULL;
extern char **environ;
- bb_opt_complementally = "u::";
+ opt_complementary = "u::";
#if ENABLE_FEATURE_ENV_LONG_OPTIONS
- bb_applet_long_options = env_long_options;
+ applet_long_options = env_long_options;
#endif
- opt = bb_getopt_ulflags(argc, argv, "+iu:", &unset_env);
+ opt = getopt32(argc, argv, "+iu:", &unset_env);
argv += optind;
if (*argv && (argv[0][0] == '-') && !argv[0][1]) {
diff --git a/coreutils/fold.c b/coreutils/fold.c
index aff7bb1d9..3b5be64fe 100644
--- a/coreutils/fold.c
+++ b/coreutils/fold.c
@@ -60,7 +60,7 @@ int fold_main(int argc, char **argv)
}
}
- flags = bb_getopt_ulflags(argc, argv, "bsw:", &w_opt);
+ flags = getopt32(argc, argv, "bsw:", &w_opt);
if (flags & FLAG_WIDTH)
width = bb_xgetlarg(w_opt, 10, 1, 10000);
diff --git a/coreutils/head.c b/coreutils/head.c
index 50694bfef..7d5f219d2 100644
--- a/coreutils/head.c
+++ b/coreutils/head.c
@@ -60,7 +60,7 @@ int head_main(int argc, char **argv)
}
#endif
- /* No size benefit in converting this to bb_getopt_ulflags */
+ /* No size benefit in converting this to getopt32 */
while ((opt = getopt(argc, argv, head_opts)) > 0) {
switch (opt) {
#if ENABLE_FEATURE_FANCY_HEAD
diff --git a/coreutils/id.c b/coreutils/id.c
index 1bedff37a..dd825ab3c 100644
--- a/coreutils/id.c
+++ b/coreutils/id.c
@@ -50,8 +50,8 @@ int id_main(int argc, char **argv)
/* Don't allow -n -r -nr -ug -rug -nug -rnug */
/* Don't allow more than one username */
- bb_opt_complementally = "?1:?:u--g:g--u:r?ug:n?ug";
- flags = bb_getopt_ulflags(argc, argv, "rnug");
+ opt_complementary = "?1:?:u--g:g--u:r?ug:n?ug";
+ flags = getopt32(argc, argv, "rnug");
/* This values could be overwritten later */
uid = geteuid();
diff --git a/coreutils/install.c b/coreutils/install.c
index d3d6a58a1..2178d435d 100644
--- a/coreutils/install.c
+++ b/coreutils/install.c
@@ -45,11 +45,11 @@ int install_main(int argc, char **argv)
int ret = EXIT_SUCCESS, flags, i, isdir;
#if ENABLE_FEATURE_INSTALL_LONG_OPTIONS
- bb_applet_long_options = install_long_options;
+ applet_long_options = install_long_options;
#endif
- bb_opt_complementally = "?:s--d:d--s";
+ opt_complementary = "?:s--d:d--s";
/* -c exists for backwards compatibility, its needed */
- flags = bb_getopt_ulflags(argc, argv, "cdpsg:m:o:", &gid_str, &mode_str, &uid_str); /* 'a' must be 2nd */
+ flags = getopt32(argc, argv, "cdpsg:m:o:", &gid_str, &mode_str, &uid_str); /* 'a' must be 2nd */
/* preserve access and modification time, this is GNU behaviour, BSD only preserves modification time */
if (flags & INSTALL_OPT_PRESERVE_TIME) {
diff --git a/coreutils/libcoreutils/getopt_mk_fifo_nod.c b/coreutils/libcoreutils/getopt_mk_fifo_nod.c
index d1f5b1e89..3a3d34118 100644
--- a/coreutils/libcoreutils/getopt_mk_fifo_nod.c
+++ b/coreutils/libcoreutils/getopt_mk_fifo_nod.c
@@ -31,7 +31,7 @@ mode_t getopt_mk_fifo_nod(int argc, char **argv)
mode_t mode = 0666;
char *smode = NULL;
- bb_getopt_ulflags(argc, argv, "m:", &smode);
+ getopt32(argc, argv, "m:", &smode);
if(smode) {
if (bb_parse_mode(smode, &mode))
umask(0);
diff --git a/coreutils/ln.c b/coreutils/ln.c
index df183581e..cd6e470be 100644
--- a/coreutils/ln.c
+++ b/coreutils/ln.c
@@ -30,7 +30,7 @@ int ln_main(int argc, char **argv)
struct stat statbuf;
int (*link_func)(const char *, const char *);
- flag = bb_getopt_ulflags(argc, argv, "sfnbS:", &suffix);
+ flag = getopt32(argc, argv, "sfnbS:", &suffix);
if (argc == optind) {
bb_show_usage();
diff --git a/coreutils/ls.c b/coreutils/ls.c
index 0099f18fe..8ba4ab758 100644
--- a/coreutils/ls.c
+++ b/coreutils/ls.c
@@ -877,7 +877,7 @@ int ls_main(int argc, char **argv)
struct dnode **dnp;
struct dnode *dn;
struct dnode *cur;
- long opt;
+ unsigned opt;
int nfiles = 0;
int dnfiles;
int dndirs;
@@ -904,12 +904,12 @@ int ls_main(int argc, char **argv)
#endif
#ifdef CONFIG_FEATURE_LS_COLOR
- bb_applet_long_options = ls_color_opt;
+ applet_long_options = ls_color_opt;
#endif
/* process options */
#ifdef CONFIG_FEATURE_AUTOWIDTH
- opt = bb_getopt_ulflags(argc, argv, ls_options, &tabstops_str, &terminal_width_str
+ opt = getopt32(argc, argv, ls_options, &tabstops_str, &terminal_width_str
#ifdef CONFIG_FEATURE_LS_COLOR
, &color_opt
#endif
@@ -921,7 +921,7 @@ int ls_main(int argc, char **argv)
terminal_width = atoi(terminal_width_str);
}
#else
- opt = bb_getopt_ulflags(argc, argv, ls_options
+ opt = getopt32(argc, argv, ls_options
#ifdef CONFIG_FEATURE_LS_COLOR
, &color_opt
#endif
diff --git a/coreutils/md5_sha1_sum.c b/coreutils/md5_sha1_sum.c
index c10fac5d0..a99e45864 100644
--- a/coreutils/md5_sha1_sum.c
+++ b/coreutils/md5_sha1_sum.c
@@ -91,7 +91,7 @@ int md5_sha1_sum_main(int argc, char **argv)
: HASH_SHA1;
if (ENABLE_FEATURE_MD5_SHA1_SUM_CHECK)
- flags = bb_getopt_ulflags(argc, argv, "scw");
+ flags = getopt32(argc, argv, "scw");
else optind = 1;
if (ENABLE_FEATURE_MD5_SHA1_SUM_CHECK && !(flags & FLAG_CHECK)) {
diff --git a/coreutils/mkdir.c b/coreutils/mkdir.c
index c09c72f7d..3fe55c395 100644
--- a/coreutils/mkdir.c
+++ b/coreutils/mkdir.c
@@ -34,13 +34,13 @@ int mkdir_main (int argc, char **argv)
mode_t mode = (mode_t)(-1);
int status = EXIT_SUCCESS;
int flags = 0;
- unsigned long opt;
+ unsigned opt;
char *smode;
#if ENABLE_FEATURE_MKDIR_LONG_OPTIONS
- bb_applet_long_options = mkdir_long_options;
+ applet_long_options = mkdir_long_options;
#endif
- opt = bb_getopt_ulflags(argc, argv, "m:p", &smode);
+ opt = getopt32(argc, argv, "m:p", &smode);
if(opt & 1) {
mode = 0777;
if (!bb_parse_mode (smode, &mode)) {
diff --git a/coreutils/mv.c b/coreutils/mv.c
index 274aecb45..770b42417 100644
--- a/coreutils/mv.c
+++ b/coreutils/mv.c
@@ -45,10 +45,10 @@ int mv_main(int argc, char **argv)
int status = 0;
#if ENABLE_FEATURE_MV_LONG_OPTIONS
- bb_applet_long_options = mv_long_options;
+ applet_long_options = mv_long_options;
#endif
- bb_opt_complementally = "f-i:i-f";
- flags = bb_getopt_ulflags(argc, argv, "fi");
+ opt_complementary = "f-i:i-f";
+ flags = getopt32(argc, argv, "fi");
if (optind + 2 > argc) {
bb_show_usage();
}
diff --git a/coreutils/rm.c b/coreutils/rm.c
index c787ae342..490694a6e 100644
--- a/coreutils/rm.c
+++ b/coreutils/rm.c
@@ -22,10 +22,10 @@ int rm_main(int argc, char **argv)
{
int status = 0;
int flags = 0;
- unsigned long opt;
+ unsigned opt;
- bb_opt_complementally = "f-i:i-f";
- opt = bb_getopt_ulflags(argc, argv, "fiRr");
+ opt_complementary = "f-i:i-f";
+ opt = getopt32(argc, argv, "fiRr");
if(opt & 1)
flags |= FILEUTILS_FORCE;
if(opt & 2)
diff --git a/coreutils/rmdir.c b/coreutils/rmdir.c
index e1ed34c6e..05ea0e9ff 100644
--- a/coreutils/rmdir.c
+++ b/coreutils/rmdir.c
@@ -22,7 +22,7 @@ int rmdir_main(int argc, char **argv)
int do_dot;
char *path;
- flags = bb_getopt_ulflags(argc, argv, "p");
+ flags = getopt32(argc, argv, "p");
argv += optind;
diff --git a/coreutils/stat.c b/coreutils/stat.c
index 8e0121849..b9fd42f4a 100644
--- a/coreutils/stat.c
+++ b/coreutils/stat.c
@@ -516,7 +516,7 @@ int stat_main(int argc, char **argv)
int ok = 1;
int (*statfunc)(char const *, char const *) = do_stat;
- flags = bb_getopt_ulflags(argc, argv, "ftL"
+ flags = getopt32(argc, argv, "ftL"
USE_FEATURE_STAT_FORMAT("c:", &format)
);
diff --git a/coreutils/sum.c b/coreutils/sum.c
index 99d477fc3..61ca582a1 100644
--- a/coreutils/sum.c
+++ b/coreutils/sum.c
@@ -136,7 +136,7 @@ int sum_main(int argc, char **argv)
int (*sum_func)(const char *, int) = bsd_sum_file;
/* give the bsd func priority over sysv func */
- flags = bb_getopt_ulflags(argc, argv, "sr");
+ flags = getopt32(argc, argv, "sr");
if (flags & 1)
sum_func = sysv_sum_file;
if (flags & 2)
diff --git a/coreutils/tee.c b/coreutils/tee.c
index 1f59f0361..a194153e0 100644
--- a/coreutils/tee.c
+++ b/coreutils/tee.c
@@ -28,7 +28,7 @@ int tee_main(int argc, char **argv)
int c;
#endif
- flags = bb_getopt_ulflags(argc, argv, "ia"); /* 'a' must be 2nd */
+ flags = getopt32(argc, argv, "ia"); /* 'a' must be 2nd */
mode += (flags & 2); /* Since 'a' is the 2nd option... */
diff --git a/coreutils/touch.c b/coreutils/touch.c
index 76c05d8c8..e1af7d0dc 100644
--- a/coreutils/touch.c
+++ b/coreutils/touch.c
@@ -32,7 +32,7 @@ int touch_main(int argc, char **argv)
int flags;
int status = EXIT_SUCCESS;
- flags = bb_getopt_ulflags(argc, argv, "c");
+ flags = getopt32(argc, argv, "c");
argv += optind;
diff --git a/coreutils/tty.c b/coreutils/tty.c
index eb8c3dd0f..579e6f73c 100644
--- a/coreutils/tty.c
+++ b/coreutils/tty.c
@@ -23,7 +23,7 @@ int tty_main(int argc, char **argv)
xfunc_error_retval = 2; /* SUSv3 requires > 1 for error. */
- silent = bb_getopt_ulflags(argc, argv, "s");
+ silent = getopt32(argc, argv, "s");
/* gnu tty outputs a warning that it is ignoring all args. */
bb_warn_ignoring_args(argc - optind);
diff --git a/coreutils/uname.c b/coreutils/uname.c
index da12c3aee..575fb525c 100644
--- a/coreutils/uname.c
+++ b/coreutils/uname.c
@@ -63,7 +63,7 @@ int uname_main(int argc, char **argv)
const unsigned short int *delta;
char toprint;
- toprint = bb_getopt_ulflags(argc, argv, options);
+ toprint = getopt32(argc, argv, options);
if (argc != optind) {
bb_show_usage();
diff --git a/coreutils/uudecode.c b/coreutils/uudecode.c
index 21ebce3ac..921d29af0 100644
--- a/coreutils/uudecode.c
+++ b/coreutils/uudecode.c
@@ -129,7 +129,7 @@ int uudecode_main(int argc, char **argv)
char *outname = NULL;
char *line;
- bb_getopt_ulflags(argc, argv, "o:", &outname);
+ getopt32(argc, argv, "o:", &outname);
if (optind == argc) {
src_stream = stdin;
diff --git a/coreutils/uuencode.c b/coreutils/uuencode.c
index 1a8882fc7..58538365e 100644
--- a/coreutils/uuencode.c
+++ b/coreutils/uuencode.c
@@ -27,7 +27,7 @@ int uuencode_main(int argc, char **argv)
RESERVE_CONFIG_BUFFER(dst_buf, DST_BUF_SIZE + 1);
tbl = bb_uuenc_tbl_std;
- if (bb_getopt_ulflags(argc, argv, "m") & 1) {
+ if (getopt32(argc, argv, "m") & 1) {
tbl = bb_uuenc_tbl_base64;
}
diff --git a/coreutils/wc.c b/coreutils/wc.c
index 6ddac4dec..359d9fd6d 100644
--- a/coreutils/wc.c
+++ b/coreutils/wc.c
@@ -87,7 +87,7 @@ int wc_main(int argc, char **argv)
char in_word;
unsigned print_type;
- print_type = bb_getopt_ulflags(argc, argv, "lwcL");
+ print_type = getopt32(argc, argv, "lwcL");
if (print_type == 0) {
print_type = (1 << WC_LINES) | (1 << WC_WORDS) | (1 << WC_CHARS);
diff --git a/debianutils/mktemp.c b/debianutils/mktemp.c
index 495a2ea3a..546e030b0 100644
--- a/debianutils/mktemp.c
+++ b/debianutils/mktemp.c
@@ -18,7 +18,7 @@
int mktemp_main(int argc, char **argv)
{
- unsigned long flags = bb_getopt_ulflags(argc, argv, "dq");
+ unsigned long flags = getopt32(argc, argv, "dq");
if (optind + 1 != argc)
bb_show_usage();
diff --git a/debianutils/readlink.c b/debianutils/readlink.c
index bfe0db6c3..0d5ad94f4 100644
--- a/debianutils/readlink.c
+++ b/debianutils/readlink.c
@@ -18,8 +18,8 @@
int readlink_main(int argc, char **argv)
{
char *buf;
- unsigned long opt = ENABLE_FEATURE_READLINK_FOLLOW ?
- bb_getopt_ulflags(argc, argv, "f") : 0;
+ unsigned opt = ENABLE_FEATURE_READLINK_FOLLOW ?
+ getopt32(argc, argv, "f") : 0;
if (argc != (ENABLE_FEATURE_READLINK_FOLLOW ? optind + 1 : 2))
bb_show_usage();
diff --git a/debianutils/start_stop_daemon.c b/debianutils/start_stop_daemon.c
index dcff1dd86..57f42d8ef 100644
--- a/debianutils/start_stop_daemon.c
+++ b/debianutils/start_stop_daemon.c
@@ -227,7 +227,7 @@ static const struct option ssd_long_options[] = {
int start_stop_daemon_main(int argc, char **argv)
{
- unsigned long opt;
+ unsigned opt;
char *signame = NULL;
char *startas = NULL;
#if ENABLE_FEATURE_START_STOP_DAEMON_FANCY
@@ -235,12 +235,12 @@ int start_stop_daemon_main(int argc, char **argv)
// int retries = -1;
#endif
#if ENABLE_FEATURE_START_STOP_DAEMON_LONG_OPTIONS
- bb_applet_long_options = ssd_long_options;
+ applet_long_options = ssd_long_options;
#endif
/* Check required one context option was given */
- bb_opt_complementally = "K:S:?:K--S:S--K:m?p:K?xpun:S?xa";
- opt = bb_getopt_ulflags(argc, argv, "KSbqm"
+ opt_complementary = "K:S:?:K--S:S--K:m?p:K?xpun:S?xa";
+ opt = getopt32(argc, argv, "KSbqm"
// USE_FEATURE_START_STOP_DAEMON_FANCY("ovR:")
USE_FEATURE_START_STOP_DAEMON_FANCY("ov")
"a:n:s:u:c:x:p:"
diff --git a/docs/busybox.net/FAQ.html b/docs/busybox.net/FAQ.html
index fee207486..af20366b6 100644
--- a/docs/busybox.net/FAQ.html
+++ b/docs/busybox.net/FAQ.html
@@ -567,7 +567,7 @@ for failure and abort the program with an error message so the caller doesn't
have to test the return value (xmalloc(), xstrdup(), etc), wrapped versions
of open(), close(), read(), and write() that test for their own failures
and/or retry automatically, linked list management functions (llist.c),
-command line argument parsing (getopt_ulflags.c), and a whole lot more.
+command line argument parsing (getopt32.c), and a whole lot more.
diff --git a/e2fsprogs/lsattr.c b/e2fsprogs/lsattr.c
index 5c20d25f3..e76f8d9d7 100644
--- a/e2fsprogs/lsattr.c
+++ b/e2fsprogs/lsattr.c
@@ -124,7 +124,7 @@ int lsattr_main(int argc, char **argv)
{
int i;
- flags = bb_getopt_ulflags(argc, argv, "Radlv");
+ flags = getopt32(argc, argv, "Radlv");
if (optind > argc - 1)
lsattr_args(".");
diff --git a/editors/awk.c b/editors/awk.c
index b46f25c0a..c1b56d9e5 100644
--- a/editors/awk.c
+++ b/editors/awk.c
@@ -2634,7 +2634,7 @@ static rstream *next_input_file(void)
int awk_main(int argc, char **argv)
{
- unsigned long opt;
+ unsigned opt;
char *opt_F, *opt_v, *opt_W;
char *s, *s1;
int i, j, c, flen;
@@ -2691,7 +2691,7 @@ keep_going:
free(s);
}
- opt = bb_getopt_ulflags(argc, argv, "F:v:f:W:", &opt_F, &opt_v, &programname, &opt_W);
+ opt = getopt32(argc, argv, "F:v:f:W:", &opt_F, &opt_v, &programname, &opt_W);
if (opt & 0x1) setvar_s(V[FS], opt_F); // -F
if (opt & 0x2) if (!is_assignment(opt_v)) bb_show_usage(); // -v
if (opt & 0x4) { // -f
diff --git a/editors/patch.c b/editors/patch.c
index a710d8224..c18659eda 100644
--- a/editors/patch.c
+++ b/editors/patch.c
@@ -85,7 +85,7 @@ int patch_main(int argc, char **argv)
{
char *p, *i;
- ret = bb_getopt_ulflags(argc, argv, "p:i:", &p, &i);
+ ret = getopt32(argc, argv, "p:i:", &p, &i);
if (ret & 1)
patch_level = bb_xgetlarg(p, 10, -1, USHRT_MAX);
if (ret & 2) {
diff --git a/editors/sed.c b/editors/sed.c
index 201665209..7dba8b456 100644
--- a/editors/sed.c
+++ b/editors/sed.c
@@ -1109,7 +1109,7 @@ static void add_files_link(llist_t *opt_f)
int sed_main(int argc, char **argv)
{
- unsigned long opt;
+ unsigned opt;
llist_t *opt_e, *opt_f;
int status = EXIT_SUCCESS;
@@ -1126,8 +1126,8 @@ int sed_main(int argc, char **argv)
/* do normal option parsing */
opt_e = opt_f = NULL;
- bb_opt_complementally = "e::f::"; /* can occur multiple times */
- opt = bb_getopt_ulflags(argc, argv, "irne:f:", &opt_e, &opt_f);
+ opt_complementary = "e::f::"; /* can occur multiple times */
+ opt = getopt32(argc, argv, "irne:f:", &opt_e, &opt_f);
if (opt & 0x1) { // -i
bbg.in_place++;
atexit(cleanup_outname);
@@ -1135,11 +1135,11 @@ int sed_main(int argc, char **argv)
if (opt & 0x2) bbg.regex_type|=REG_EXTENDED; // -r
if (opt & 0x4) bbg.be_quiet++; // -n
if (opt & 0x8) { // -e
- /* getopt_ulflags reverses order of arguments, handle it */
+ /* getopt32 reverses order of arguments, handle it */
add_cmds_link(opt_e);
}
if (opt & 0x10) { // -f
- /* getopt_ulflags reverses order of arguments, handle it */
+ /* getopt32 reverses order of arguments, handle it */
add_files_link(opt_f);
}
/* if we didn't get a pattern from -e or -f, use argv[optind] */
diff --git a/findutils/grep.c b/findutils/grep.c
index 5659a7d2b..35e6aff2d 100644
--- a/findutils/grep.c
+++ b/findutils/grep.c
@@ -24,7 +24,7 @@
/* options */
-static unsigned long opt;
+static unsigned opt;
#define GREP_OPTS "lnqvscFiHhe:f:Lo"
#define GREP_OPT_l (1<<0)
#define PRINT_FILES_WITH_MATCHES (opt & GREP_OPT_l)
@@ -302,8 +302,8 @@ int grep_main(int argc, char **argv)
char *slines_before;
char *Copt;
- bb_opt_complementally = "H-h:e::f::C-AB";
- opt = bb_getopt_ulflags(argc, argv,
+ opt_complementary = "H-h:e::f::C-AB";
+ opt = getopt32(argc, argv,
GREP_OPTS GREP_OPT_CONTEXT OPT_EGREP,
&pattern_head, &fopt,
&slines_after, &slines_before, &Copt);
@@ -336,8 +336,8 @@ int grep_main(int argc, char **argv)
before_buf = (char **)xzalloc(lines_before * sizeof(char *));
#else
/* with auto sanity checks */
- bb_opt_complementally = "H-h:e::f::c-n:q-n:l-n";
- opt = bb_getopt_ulflags(argc, argv, GREP_OPTS OPT_EGREP,
+ opt_complementary = "H-h:e::f::c-n:q-n:l-n";
+ opt = getopt32(argc, argv, GREP_OPTS OPT_EGREP,
&pattern_head, &fopt);
#endif
invert_search = (opt & GREP_OPT_v) != 0; /* 0 | 1 */
diff --git a/findutils/xargs.c b/findutils/xargs.c
index b6a154f15..278382373 100644
--- a/findutils/xargs.c
+++ b/findutils/xargs.c
@@ -399,7 +399,7 @@ int xargs_main(int argc, char **argv)
size_t n_chars = 0;
long orig_arg_max;
const char *eof_str = "_";
- unsigned long opt;
+ unsigned opt;
size_t n_max_chars;
#if ENABLE_FEATURE_XARGS_SUPPORT_ZERO_TERM
xlist_t* (*read_args)(xlist_t*, const char*, size_t, char*) = process_stdin;
@@ -407,7 +407,7 @@ int xargs_main(int argc, char **argv)
#define read_args process_stdin
#endif
- opt = bb_getopt_ulflags(argc, argv, OPTION_STR, &max_args, &max_chars, &eof_str);
+ opt = getopt32(argc, argv, OPTION_STR, &max_args, &max_chars, &eof_str);
if (opt & OPT_ZEROTERM)
USE_FEATURE_XARGS_SUPPORT_ZERO_TERM(read_args = process0_stdin);
diff --git a/include/libbb.h b/include/libbb.h
index c0de92190..4e96ea415 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -207,9 +207,9 @@ extern void xsetuid(uid_t uid);
extern off_t fdlength(int fd);
#define BB_GETOPT_ERROR 0x80000000UL
-extern const char *bb_opt_complementally;
-extern const struct option *bb_applet_long_options;
-extern unsigned long bb_getopt_ulflags(int argc, char **argv, const char *applet_opts, ...);
+extern const char *opt_complementary;
+extern const struct option *applet_long_options;
+extern uint32_t getopt32(int argc, char **argv, const char *applet_opts, ...);
extern int bb_vfprintf(FILE * __restrict stream, const char * __restrict format,
va_list arg) __attribute__ ((format (printf, 2, 0)));
@@ -232,7 +232,7 @@ extern char *skip_whitespace(const char *);
#ifndef BUILD_INDIVIDUAL
extern struct BB_applet *find_applet_by_name(const char *name);
-void run_applet_by_name(const char *name, int argc, char **argv);
+extern void run_applet_by_name(const char *name, int argc, char **argv);
#endif
/* dmalloc will redefine these to it's own implementation. It is safe
diff --git a/init/halt.c b/init/halt.c
index 7bd27896c..d796a4aea 100644
--- a/init/halt.c
+++ b/init/halt.c
@@ -34,7 +34,7 @@ RB_AUTOBOOT
for(which=0;delay[which]!=*bb_applet_name;which++);
/* Parse and handle arguments */
- flags = bb_getopt_ulflags(argc, argv, "d:nf", &delay);
+ flags = getopt32(argc, argv, "d:nf", &delay);
if (flags&1) sleep(atoi(delay));
if (!(flags&2)) sync();
diff --git a/libbb/Makefile.in b/libbb/Makefile.in
index f731e6e03..ef5c6b97a 100644
--- a/libbb/Makefile.in
+++ b/libbb/Makefile.in
@@ -30,7 +30,7 @@ LIBBB-y:= \
vherror_msg.c vperror_msg.c wfopen.c xconnect.c xgetcwd.c \
xgethostbyname.c xgethostbyname2.c xreadlink.c xgetlarg.c \
fclose_nonstdin.c fflush_stdout_and_exit.c \
- getopt_ulflags.c default_error_retval.c wfopen_input.c speed_table.c \
+ getopt32.c default_error_retval.c wfopen_input.c speed_table.c \
perror_nomsg_and_die.c perror_nomsg.c skip_whitespace.c bb_askpass.c \
warn_ignoring_args.c concat_subpath_file.c vfork_daemon_rexec.c \
bb_do_delay.c
diff --git a/libbb/getopt_ulflags.c b/libbb/getopt32.c
similarity index 77%
rename from libbb/getopt_ulflags.c
rename to libbb/getopt32.c
index 9d27c1f11..e08496578 100644
--- a/libbb/getopt_ulflags.c
+++ b/libbb/getopt32.c
@@ -1,6 +1,6 @@
/* vi: set sw=4 ts=4: */
/*
- * universal getopt_ulflags implementation for busybox
+ * universal getopt32 implementation for busybox
*
* Copyright (C) 2003-2005 Vladimir Oleynik
*
@@ -12,13 +12,13 @@
/* Documentation
-unsigned long
-bb_getopt_ulflags(int argc, char **argv, const char *applet_opts, ...)
+uint32_t
+getopt32(int argc, char **argv, const char *applet_opts, ...)
The command line options must be declared in const char
*applet_opts as a string of chars, for example:
- flags = bb_getopt_ulflags(argc, argv, "rnug");
+ flags = getopt32(argc, argv, "rnug");
If one of the given options is found, a flag value is added to
the return value (an unsigned long).
@@ -26,7 +26,7 @@ bb_getopt_ulflags(int argc, char **argv, const char *applet_opts, ...)
The flag value is determined by the position of the char in
applet_opts string. For example, in the above case:
- flags = bb_getopt_ulflags(argc, argv, "rnug");
+ flags = getopt32(argc, argv, "rnug");
"r" will add 1 (bit 0)
"n" will add 2 (bit 1)
@@ -52,13 +52,13 @@ bb_getopt_ulflags(int argc, char **argv, const char *applet_opts, ...)
char *pointer_to_arg_for_c;
char *pointer_to_arg_for_d;
- flags = bb_getopt_ulflags(argc, argv, "a:b:c:d:",
+ flags = getopt32(argc, argv, "a:b:c:d:",
&pointer_to_arg_for_a, &pointer_to_arg_for_b,
&pointer_to_arg_for_c, &pointer_to_arg_for_d);
The type of the pointer (char* or llist_t*) may be controlled
by the "::" special separator that is set in the external string
- bb_opt_complementally (see below for more info).
+ opt_complementary (see below for more info).
"::" If option can have an *optional* argument, then add a "::"
after its char in applet_opts and provide a pointer to store
@@ -72,7 +72,7 @@ bb_getopt_ulflags(int argc, char **argv, const char *applet_opts, ...)
env -i ls -d /
Here we want env to process just the '-i', not the '-d'.
-const struct option *bb_applet_long_options
+const struct option *applet_long_options
This struct allows you to define long options. The syntax for
declaring the array is just like that of getopt's longopts.
@@ -83,23 +83,20 @@ const struct option *bb_applet_long_options
{ "verbose", 0, 0, 'v' },
{ 0, 0, 0, 0 }
};
- bb_applet_long_options = applet_long_options;
+ applet_long_options = applet_long_options;
The last member of struct option (val) typically is set to
matching short option from applet_opts. If there is no matching
char in applet_opts, then:
- return bit have next position after short options
- if has_arg is not "no_argument", use ptr for arg also
- - bb_opt_complementally affects it too
+ - opt_complementary affects it too
Note: a good applet will make long options configurable via the
config process and not a required feature. The current standard
is to name the config option CONFIG_FEATURE_