mirror of
https://github.com/sheumann/hush.git
synced 2024-12-21 08:29:45 +00:00
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.
This commit is contained in:
parent
40920825d5
commit
67b23e6043
@ -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;
|
||||
|
@ -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];
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -688,7 +688,7 @@ int tar_main(int argc, char **argv)
|
||||
archive_handle_t *tar_handle;
|
||||
char *base_dir = NULL;
|
||||
const char *tar_filename = "-";
|
||||
unsigned long opt;
|
||||
unsigned opt;
|
||||
llist_t *excludes = NULL;
|
||||
|
||||
/* Initialise default values */
|
||||
@ -696,12 +696,12 @@ int tar_main(int argc, char **argv)
|
||||
tar_handle->flags = ARCHIVE_CREATE_LEADING_DIRS | ARCHIVE_PRESERVE_DATE | ARCHIVE_EXTRACT_UNCONDITIONAL;
|
||||
|
||||
/* Prepend '-' to the first argument if required */
|
||||
bb_opt_complementally = ENABLE_FEATURE_TAR_CREATE ?
|
||||
opt_complementary = ENABLE_FEATURE_TAR_CREATE ?
|
||||
"--:X::T::\n::c:t:x:?:c--tx:t--cx:x--ct" :
|
||||
"--:X::T::\n::t:x:?:t--x:x--t";
|
||||
if (ENABLE_FEATURE_TAR_LONG_OPTIONS)
|
||||
bb_applet_long_options = tar_long_options;
|
||||
opt = bb_getopt_ulflags(argc, argv, tar_options,
|
||||
applet_long_options = tar_long_options;
|
||||
opt = getopt32(argc, argv, tar_options,
|
||||
&base_dir, /* Change to dir <optarg> */
|
||||
&tar_filename /* archive filename */
|
||||
#ifdef CONFIG_FEATURE_TAR_FROM
|
||||
|
@ -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++];
|
||||
|
@ -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];
|
||||
|
@ -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();
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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)
|
||||
|
@ -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();
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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))
|
||||
|
@ -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();
|
||||
|
@ -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);
|
||||
|
@ -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");
|
||||
|
@ -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));
|
||||
|
@ -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",
|
||||
|
@ -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) {
|
||||
|
@ -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. */
|
||||
|
@ -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 */
|
||||
|
@ -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]) {
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
|
@ -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
|
||||
|
@ -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)) {
|
||||
|
@ -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)) {
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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)
|
||||
);
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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... */
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
@ -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:"
|
||||
|
@ -567,7 +567,7 @@ for failure and abort the program with an error message so the caller doesn't
|
||||
have to test the return value (xmalloc(), xstrdup(), etc), wrapped versions
|
||||
of open(), close(), read(), and write() that test for their own failures
|
||||
and/or retry automatically, linked list management functions (llist.c),
|
||||
command line argument parsing (getopt_ulflags.c), and a whole lot more.</p>
|
||||
command line argument parsing (getopt32.c), and a whole lot more.</p>
|
||||
|
||||
<hr />
|
||||
<p>
|
||||
|
@ -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(".");
|
||||
|
@ -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
|
||||
|
@ -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) {
|
||||
|
@ -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] */
|
||||
|
@ -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 */
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* universal getopt_ulflags implementation for busybox
|
||||
* universal getopt32 implementation for busybox
|
||||
*
|
||||
* Copyright (C) 2003-2005 Vladimir Oleynik <dzo@simtreas.ru>
|
||||
*
|
||||
@ -12,13 +12,13 @@
|
||||
|
||||
/* Documentation
|
||||
|
||||
unsigned long
|
||||
bb_getopt_ulflags(int argc, char **argv, const char *applet_opts, ...)
|
||||
uint32_t
|
||||
getopt32(int argc, char **argv, const char *applet_opts, ...)
|
||||
|
||||
The command line options must be declared in const char
|
||||
*applet_opts as a string of chars, for example:
|
||||
|
||||
flags = bb_getopt_ulflags(argc, argv, "rnug");
|
||||
flags = getopt32(argc, argv, "rnug");
|
||||
|
||||
If one of the given options is found, a flag value is added to
|
||||
the return value (an unsigned long).
|
||||
@ -26,7 +26,7 @@ bb_getopt_ulflags(int argc, char **argv, const char *applet_opts, ...)
|
||||
The flag value is determined by the position of the char in
|
||||
applet_opts string. For example, in the above case:
|
||||
|
||||
flags = bb_getopt_ulflags(argc, argv, "rnug");
|
||||
flags = getopt32(argc, argv, "rnug");
|
||||
|
||||
"r" will add 1 (bit 0)
|
||||
"n" will add 2 (bit 1)
|
||||
@ -52,13 +52,13 @@ bb_getopt_ulflags(int argc, char **argv, const char *applet_opts, ...)
|
||||
char *pointer_to_arg_for_c;
|
||||
char *pointer_to_arg_for_d;
|
||||
|
||||
flags = bb_getopt_ulflags(argc, argv, "a:b:c:d:",
|
||||
flags = getopt32(argc, argv, "a:b:c:d:",
|
||||
&pointer_to_arg_for_a, &pointer_to_arg_for_b,
|
||||
&pointer_to_arg_for_c, &pointer_to_arg_for_d);
|
||||
|
||||
The type of the pointer (char* or llist_t*) may be controlled
|
||||
by the "::" special separator that is set in the external string
|
||||
bb_opt_complementally (see below for more info).
|
||||
opt_complementary (see below for more info).
|
||||
|
||||
"::" If option can have an *optional* argument, then add a "::"
|
||||
after its char in applet_opts and provide a pointer to store
|
||||
@ -72,7 +72,7 @@ bb_getopt_ulflags(int argc, char **argv, const char *applet_opts, ...)
|
||||
env -i ls -d /
|
||||
Here we want env to process just the '-i', not the '-d'.
|
||||
|
||||
const struct option *bb_applet_long_options
|
||||
const struct option *applet_long_options
|
||||
|
||||
This struct allows you to define long options. The syntax for
|
||||
declaring the array is just like that of getopt's longopts.
|
||||
@ -83,23 +83,20 @@ const struct option *bb_applet_long_options
|
||||
{ "verbose", 0, 0, 'v' },
|
||||
{ 0, 0, 0, 0 }
|
||||
};
|
||||
bb_applet_long_options = applet_long_options;
|
||||
applet_long_options = applet_long_options;
|
||||
|
||||
The last member of struct option (val) typically is set to
|
||||
matching short option from applet_opts. If there is no matching
|
||||
char in applet_opts, then:
|
||||
- return bit have next position after short options
|
||||
- if has_arg is not "no_argument", use ptr for arg also
|
||||
- bb_opt_complementally affects it too
|
||||
- opt_complementary affects it too
|
||||
|
||||
Note: a good applet will make long options configurable via the
|
||||
config process and not a required feature. The current standard
|
||||
is to name the config option CONFIG_FEATURE_<applet>_LONG_OPTIONS.
|
||||
|
||||
const char *bb_opt_complementally
|
||||
|
||||
this should be bb_opt_complementary, but we'll just keep it as
|
||||
bb_opt_complementally due to the Russian origins
|
||||
const char *opt_complementary
|
||||
|
||||
":" The colon (":") is used to separate groups of two or more chars
|
||||
and/or groups of chars and special characters (stating some
|
||||
@ -110,11 +107,11 @@ const char *bb_opt_complementally
|
||||
Their flags will be turned on if the main option is found even
|
||||
if they are not specifed on the command line. For example:
|
||||
|
||||
bb_opt_complementally = "abc";
|
||||
flags = bb_getopt_ulflags(argc, argv, "abcd")
|
||||
opt_complementary = "abc";
|
||||
flags = getopt32(argc, argv, "abcd")
|
||||
|
||||
If getopt() finds "-a" on the command line, then
|
||||
bb_getopt_ulflags's return value will be as if "-a -b -c" were
|
||||
getopt32's return value will be as if "-a -b -c" were
|
||||
found.
|
||||
|
||||
"ww" Adjacent double options have a counter associated which indicates
|
||||
@ -124,15 +121,15 @@ const char *bb_opt_complementally
|
||||
if w is given more than once, it is "unlimited"
|
||||
|
||||
int w_counter = 0;
|
||||
bb_opt_complementally = "ww";
|
||||
bb_getopt_ulflags(argc, argv, "w", &w_counter);
|
||||
opt_complementary = "ww";
|
||||
getopt32(argc, argv, "w", &w_counter);
|
||||
if (w_counter)
|
||||
width = (w_counter == 1) ? 132 : INT_MAX;
|
||||
else
|
||||
get_terminal_width(...&width...);
|
||||
|
||||
w_counter is a pointer to an integer. It has to be passed to
|
||||
bb_getopt_ulflags() after all other option argument sinks.
|
||||
getopt32() after all other option argument sinks.
|
||||
|
||||
For example: accept multiple -v to indicate the level of verbosity
|
||||
and for each -b optarg, add optarg to my_b. Finally, if b is given,
|
||||
@ -140,8 +137,8 @@ const char *bb_opt_complementally
|
||||
|
||||
llist_t *my_b = NULL;
|
||||
int verbose_level = 0;
|
||||
bb_opt_complementally = "vv:b::b-c:c-b";
|
||||
f = bb_getopt_ulflags(argc, argv, "vb:c", &my_b, &verbose_level);
|
||||
opt_complementary = "vv:b::b-c:c-b";
|
||||
f = getopt32(argc, argv, "vb:c", &my_b, &verbose_level);
|
||||
if (f & 2) // -c after -b unsets -b flag
|
||||
while (my_b) { dosomething_with(my_b->data); my_b = my_b->link; }
|
||||
if (my_b) // but llist is stored if -b is specified
|
||||
@ -157,37 +154,37 @@ Special characters:
|
||||
|
||||
For example:
|
||||
The du applet has the options "-s" and "-d depth". If
|
||||
bb_getopt_ulflags finds -s, then -d is unset or if it finds -d
|
||||
getopt32 finds -s, then -d is unset or if it finds -d
|
||||
then -s is unset. (Note: busybox implements the GNU
|
||||
"--max-depth" option as "-d".) To obtain this behavior, you
|
||||
set bb_opt_complementally = "s-d:d-s". Only one flag value is
|
||||
added to bb_getopt_ulflags's return value depending on the
|
||||
set opt_complementary = "s-d:d-s". Only one flag value is
|
||||
added to getopt32's return value depending on the
|
||||
position of the options on the command line. If one of the
|
||||
two options requires an argument pointer (":" in applet_opts
|
||||
as in "d:") optarg is set accordingly.
|
||||
|
||||
char *smax_print_depth;
|
||||
|
||||
bb_opt_complementally = "s-d:d-s:x-x";
|
||||
opt = bb_getopt_ulflags(argc, argv, "sd:x", &smax_print_depth);
|
||||
opt_complementary = "s-d:d-s:x-x";
|
||||
opt = getopt32(argc, argv, "sd:x", &smax_print_depth);
|
||||
|
||||
if (opt & 2)
|
||||
max_print_depth = atoi(smax_print_depth);
|
||||
if (opt & 4)
|
||||
printf("Detected odd -x usage\n");
|
||||
|
||||
"-" A dash as the first char in a bb_opt_complementally group forces
|
||||
"-" A dash as the first char in a opt_complementary group forces
|
||||
all arguments to be treated as options, even if they have
|
||||
no leading dashes. Next char in this case can't be a digit (0-9),
|
||||
use ':' or end of line. For example:
|
||||
|
||||
bb_opt_complementally = "-:w-x:x-w";
|
||||
bb_getopt_ulflags(argc, argv, "wx");
|
||||
opt_complementary = "-:w-x:x-w";
|
||||
getopt32(argc, argv, "wx");
|
||||
|
||||
Allows any arguments to be given without a dash (./program w x)
|
||||
as well as with a dash (./program -x).
|
||||
|
||||
"-N" A dash as the first char in a bb_opt_complementally group followed
|
||||
"-N" A dash as the first char in a opt_complementary group followed
|
||||
by a single digit (0-9) means that at least N non-option
|
||||
arguments must be present on the command line
|
||||
|
||||
@ -205,8 +202,8 @@ Special characters:
|
||||
The cut applet must have only one type of list specified, so
|
||||
-b, -c and -f are mutally exclusive and should raise an error
|
||||
if specified together. In this case you must set
|
||||
bb_opt_complementally = "b--cf:c--bf:f--bc". If two of the
|
||||
mutually exclusive options are found, bb_getopt_ulflags's
|
||||
opt_complementary = "b--cf:c--bf:f--bc". If two of the
|
||||
mutually exclusive options are found, getopt32's
|
||||
return value will have the error flag set (BB_GETOPT_ERROR) so
|
||||
that we can check for it:
|
||||
|
||||
@ -216,35 +213,35 @@ Special characters:
|
||||
"x--x" Variation of the above, it means that -x option should occur
|
||||
at most once.
|
||||
|
||||
"?" A "?" as the first char in a bb_opt_complementally group means:
|
||||
"?" A "?" as the first char in a opt_complementary group means:
|
||||
if BB_GETOPT_ERROR is detected, don't return, call bb_show_usage
|
||||
and exit instead. Next char after '?' can't be a digit.
|
||||
|
||||
"?N" A "?" as the first char in a bb_opt_complementally group followed
|
||||
"?N" A "?" as the first char in a opt_complementary group followed
|
||||
by a single digit (0-9) means that at most N arguments must be present
|
||||
on the command line.
|
||||
|
||||
"::" A double colon after a char in bb_opt_complementally means that the
|
||||
"::" A double colon after a char in opt_complementary means that the
|
||||
option can occur multiple times. Each occurrence will be saved as
|
||||
a llist_t element instead of char*.
|
||||
|
||||
For example:
|
||||
The grep applet can have one or more "-e pattern" arguments.
|
||||
In this case you should use bb_getopt_ulflags() as follows:
|
||||
In this case you should use getopt32() as follows:
|
||||
|
||||
llist_t *patterns = NULL;
|
||||
|
||||
(this pointer must be initializated to NULL if the list is empty
|
||||
as required by *llist_add_to(llist_t *old_head, char *new_item).)
|
||||
|
||||
bb_opt_complementally = "e::";
|
||||
opt_complementary = "e::";
|
||||
|
||||
bb_getopt_ulflags(argc, argv, "e:", &patterns);
|
||||
getopt32(argc, argv, "e:", &patterns);
|
||||
$ grep -e user -e root /etc/passwd
|
||||
root:x:0:0:root:/root:/bin/bash
|
||||
user:x:500:500::/home/user:/bin/bash
|
||||
|
||||
"--" A double dash at the beginning of bb_opt_complementally means the
|
||||
"--" A double dash at the beginning of opt_complementary means the
|
||||
argv[1] string should always be treated as options, even if it isn't
|
||||
prefixed with a "-". This is useful for special syntax in applets
|
||||
such as "ar" and "tar":
|
||||
@ -257,20 +254,20 @@ Special characters:
|
||||
For example from "id" applet:
|
||||
|
||||
// Don't allow -n -r -rn -ug -rug -nug -rnug
|
||||
bb_opt_complementally = "r?ug:n?ug:?u--g:g--u";
|
||||
flags = bb_getopt_ulflags(argc, argv, "rnug");
|
||||
opt_complementary = "r?ug:n?ug:?u--g:g--u";
|
||||
flags = getopt32(argc, argv, "rnug");
|
||||
|
||||
This example allowed only:
|
||||
$ id; id -u; id -g; id -ru; id -nu; id -rg; id -ng; id -rnu; id -rng
|
||||
|
||||
"X" A bb_opt_complementally group with just a single letter means
|
||||
"X" A opt_complementary group with just a single letter means
|
||||
that this option is required. If more than one such group exists,
|
||||
at least one option is required to occur (not all of them).
|
||||
For example from "start-stop-daemon" applet:
|
||||
|
||||
// Don't allow -KS -SK, but -S or -K is required
|
||||
bb_opt_complementally = "K:S:?K--S:S--K";
|
||||
flags = bb_getopt_ulflags(argc, argv, "KS...);
|
||||
opt_complementary = "K:S:?K--S:S--K";
|
||||
flags = getopt32(argc, argv, "KS...);
|
||||
|
||||
|
||||
Don't forget to use ':'. For example, "?322-22-23X-x-a"
|
||||
@ -280,45 +277,45 @@ Special characters:
|
||||
a '-2' and after it a '-x' then error out.
|
||||
*/
|
||||
|
||||
/* this should be bb_opt_complementary, but we'll just keep it as
|
||||
bb_opt_complementally due to the Russian origins */
|
||||
const char *bb_opt_complementally;
|
||||
/* Code here assumes that 'unsigned' is at least 32 bits wide */
|
||||
|
||||
const char *opt_complementary;
|
||||
|
||||
typedef struct {
|
||||
int opt;
|
||||
int list_flg;
|
||||
unsigned long switch_on;
|
||||
unsigned long switch_off;
|
||||
unsigned long incongruously;
|
||||
unsigned long requires;
|
||||
unsigned switch_on;
|
||||
unsigned switch_off;
|
||||
unsigned incongruously;
|
||||
unsigned requires;
|
||||
void **optarg; /* char **optarg or llist_t **optarg */
|
||||
int *counter;
|
||||
} t_complementally;
|
||||
} t_complementary;
|
||||
|
||||
/* You can set bb_applet_long_options for parse called long options */
|
||||
/* You can set applet_long_options for parse called long options */
|
||||
#if ENABLE_GETOPT_LONG
|
||||
static const struct option bb_default_long_options[] = {
|
||||
/* { "help", 0, NULL, '?' }, */
|
||||
{ 0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
const struct option *bb_applet_long_options = bb_default_long_options;
|
||||
const struct option *applet_long_options = bb_default_long_options;
|
||||
#endif
|
||||
|
||||
unsigned long
|
||||
bb_getopt_ulflags(int argc, char **argv, const char *applet_opts, ...)
|
||||
uint32_t
|
||||
getopt32(int argc, char **argv, const char *applet_opts, ...)
|
||||
{
|
||||
unsigned long flags = 0;
|
||||
unsigned long requires = 0;
|
||||
t_complementally complementally[sizeof(flags) * 8 + 1];
|
||||
unsigned flags = 0;
|
||||
unsigned requires = 0;
|
||||
t_complementary complementary[sizeof(flags) * 8 + 1];
|
||||
int c;
|
||||
const unsigned char *s;
|
||||
t_complementally *on_off;
|
||||
t_complementary *on_off;
|
||||
va_list p;
|
||||
#if ENABLE_GETOPT_LONG
|
||||
const struct option *l_o;
|
||||
#endif
|
||||
unsigned long trigger;
|
||||
unsigned trigger;
|
||||
char **pargv = NULL;
|
||||
int min_arg = 0;
|
||||
int max_arg = -1;
|
||||
@ -332,8 +329,8 @@ bb_getopt_ulflags(int argc, char **argv, const char *applet_opts, ...)
|
||||
va_start(p, applet_opts);
|
||||
|
||||
c = 0;
|
||||
on_off = complementally;
|
||||
memset(on_off, 0, sizeof(complementally));
|
||||
on_off = complementary;
|
||||
memset(on_off, 0, sizeof(complementary));
|
||||
|
||||
/* skip GNU extension */
|
||||
s = (const unsigned char *)applet_opts;
|
||||
@ -355,10 +352,10 @@ bb_getopt_ulflags(int argc, char **argv, const char *applet_opts, ...)
|
||||
}
|
||||
|
||||
#if ENABLE_GETOPT_LONG
|
||||
for (l_o = bb_applet_long_options; l_o->name; l_o++) {
|
||||
for (l_o = applet_long_options; l_o->name; l_o++) {
|
||||
if (l_o->flag)
|
||||
continue;
|
||||
for (on_off = complementally; on_off->opt != 0; on_off++)
|
||||
for (on_off = complementary; on_off->opt != 0; on_off++)
|
||||
if (on_off->opt == l_o->val)
|
||||
break;
|
||||
if (on_off->opt == 0) {
|
||||
@ -372,9 +369,9 @@ bb_getopt_ulflags(int argc, char **argv, const char *applet_opts, ...)
|
||||
}
|
||||
}
|
||||
#endif /* ENABLE_GETOPT_LONG */
|
||||
for (s = (const unsigned char *)bb_opt_complementally; s && *s; s++) {
|
||||
t_complementally *pair;
|
||||
unsigned long *pair_switch;
|
||||
for (s = (const unsigned char *)opt_complementary; s && *s; s++) {
|
||||
t_complementary *pair;
|
||||
unsigned *pair_switch;
|
||||
|
||||
if (*s == ':')
|
||||
continue;
|
||||
@ -401,7 +398,7 @@ bb_getopt_ulflags(int argc, char **argv, const char *applet_opts, ...)
|
||||
}
|
||||
continue;
|
||||
}
|
||||
for (on_off = complementally; on_off->opt; on_off++)
|
||||
for (on_off = complementary; on_off->opt; on_off++)
|
||||
if (on_off->opt == *s)
|
||||
break;
|
||||
if (c == ':' && s[2] == ':') {
|
||||
@ -433,7 +430,7 @@ bb_getopt_ulflags(int argc, char **argv, const char *applet_opts, ...)
|
||||
else
|
||||
pair_switch = &(pair->switch_off);
|
||||
} else {
|
||||
for (on_off = complementally; on_off->opt; on_off++)
|
||||
for (on_off = complementary; on_off->opt; on_off++)
|
||||
if (on_off->opt == *s) {
|
||||
*pair_switch |= on_off->switch_on;
|
||||
break;
|
||||
@ -455,12 +452,12 @@ bb_getopt_ulflags(int argc, char **argv, const char *applet_opts, ...)
|
||||
#endif
|
||||
#if ENABLE_GETOPT_LONG
|
||||
while ((c = getopt_long(argc, argv, applet_opts,
|
||||
bb_applet_long_options, NULL)) >= 0) {
|
||||
applet_long_options, NULL)) >= 0) {
|
||||
#else
|
||||
while ((c = getopt(argc, argv, applet_opts)) >= 0) {
|
||||
#endif /* ENABLE_GETOPT_LONG */
|
||||
loop_arg_is_opt:
|
||||
for (on_off = complementally; on_off->opt != c; on_off++) {
|
||||
for (on_off = complementary; on_off->opt != c; on_off++) {
|
||||
/* c==0 if long opt have non NULL flag */
|
||||
if (on_off->opt == 0 && c != 0)
|
||||
bb_show_usage();
|
||||
@ -505,7 +502,7 @@ loop_arg_is_opt:
|
||||
free(argv[1]);
|
||||
#endif
|
||||
/* check depending requires for given options */
|
||||
for (on_off = complementally; on_off->opt; on_off++) {
|
||||
for (on_off = complementary; on_off->opt; on_off++) {
|
||||
if (on_off->requires && (flags & on_off->switch_on) &&
|
||||
(flags & on_off->requires) == 0)
|
||||
bb_show_usage();
|
@ -90,9 +90,9 @@ int addgroup_main(int argc, char **argv)
|
||||
gid_t gid = 0;
|
||||
|
||||
/* check for min, max and missing args and exit on error */
|
||||
bb_opt_complementally = "-1:?2:?";
|
||||
opt_complementary = "-1:?2:?";
|
||||
|
||||
if (bb_getopt_ulflags(argc, argv, "g:", &group)) {
|
||||
if (getopt32(argc, argv, "g:", &group)) {
|
||||
gid = bb_xgetlarg(group, 10, 0, LONG_MAX);
|
||||
}
|
||||
/* move past the commandline options */
|
||||
|
@ -169,8 +169,8 @@ int adduser_main(int argc, char **argv)
|
||||
pw.pw_dir = NULL;
|
||||
|
||||
/* check for min, max and missing args and exit on error */
|
||||
bb_opt_complementally = "-1:?1:?";
|
||||
flags = bb_getopt_ulflags(argc, argv, "h:g:s:G:DSH", &pw.pw_dir, &pw.pw_gecos, &pw.pw_shell, &usegroup);
|
||||
opt_complementary = "-1:?1:?";
|
||||
flags = getopt32(argc, argv, "h:g:s:G:DSH", &pw.pw_dir, &pw.pw_gecos, &pw.pw_shell, &usegroup);
|
||||
|
||||
/* got root? */
|
||||
if(geteuid()) {
|
||||
|
@ -258,7 +258,7 @@ static void parse_args(int argc, char **argv, struct options *op)
|
||||
{
|
||||
char *ts;
|
||||
|
||||
op->flags = bb_getopt_ulflags(argc, argv, opt_string,
|
||||
op->flags = getopt32(argc, argv, opt_string,
|
||||
&(op->initstring), &fakehost, &(op->issue),
|
||||
&(op->login), &ts);
|
||||
if(op->flags & F_INITSTRING) {
|
||||
|
@ -222,7 +222,7 @@ int login_main(int argc, char **argv)
|
||||
char username[USERNAME_SIZE];
|
||||
const char *tmp;
|
||||
int amroot;
|
||||
unsigned long opt;
|
||||
unsigned opt;
|
||||
int count = 0;
|
||||
struct passwd *pw;
|
||||
char *opt_host = NULL;
|
||||
@ -234,7 +234,7 @@ int login_main(int argc, char **argv)
|
||||
signal(SIGALRM, alarm_handler);
|
||||
alarm(TIMEOUT);
|
||||
|
||||
opt = bb_getopt_ulflags(argc, argv, "f:h:p", &opt_user, &opt_host);
|
||||
opt = getopt32(argc, argv, "f:h:p", &opt_user, &opt_host);
|
||||
if (opt & LOGIN_OPT_f) {
|
||||
if (!amroot)
|
||||
bb_error_msg_and_die("-f is for root only");
|
||||
|
@ -134,7 +134,7 @@ int passwd_main(int argc, char **argv)
|
||||
OPT_delete = 0x8, /* -d - delete password */
|
||||
OPT_lud = 0xe,
|
||||
};
|
||||
unsigned long opt;
|
||||
unsigned opt;
|
||||
char *opt_a;
|
||||
int amroot;
|
||||
char *cp;
|
||||
@ -146,7 +146,7 @@ int passwd_main(int argc, char **argv)
|
||||
|
||||
amroot = (getuid() == 0);
|
||||
openlog("passwd", LOG_PID | LOG_CONS | LOG_NOWAIT, LOG_AUTH);
|
||||
opt = bb_getopt_ulflags(argc, argv, "a:lud", &opt_a);
|
||||
opt = getopt32(argc, argv, "a:lud", &opt_a);
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
if (opt & OPT_algo) algo = get_algo(opt_a); // -a
|
||||
|
@ -20,7 +20,7 @@ int su_main(int argc, char **argv)
|
||||
const char *tty;
|
||||
char *old_user;
|
||||
|
||||
flags = bb_getopt_ulflags(argc, argv, "mplc:s:", &opt_command, &opt_shell);
|
||||
flags = getopt32(argc, argv, "mplc:s:", &opt_command, &opt_shell);
|
||||
#define SU_OPT_mp (3)
|
||||
#define SU_OPT_l (4)
|
||||
|
||||
|
@ -46,7 +46,7 @@ int sulogin_main(int argc, char **argv)
|
||||
logmode = LOGMODE_BOTH;
|
||||
openlog(bb_applet_name, 0, LOG_AUTH);
|
||||
|
||||
if (bb_getopt_ulflags (argc, argv, "t:", &timeout_arg)) {
|
||||
if (getopt32 (argc, argv, "t:", &timeout_arg)) {
|
||||
if (safe_strtoi(timeout_arg, &timeout)) {
|
||||
timeout = 0;
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ int vlock_main(int argc, char **argv)
|
||||
bb_show_usage();
|
||||
}
|
||||
|
||||
o_lock_all = bb_getopt_ulflags (argc, argv, "a");
|
||||
o_lock_all = getopt32 (argc, argv, "a");
|
||||
|
||||
if((pw = getpwuid(getuid())) == NULL) {
|
||||
bb_error_msg_and_die("Unknown uid %d", getuid());
|
||||
|
@ -47,14 +47,14 @@ int adjtimex_main(int argc, char **argv)
|
||||
enum {
|
||||
OPT_quiet = 0x1
|
||||
};
|
||||
unsigned long opt;
|
||||
unsigned opt;
|
||||
char *opt_o, *opt_f, *opt_p, *opt_t;
|
||||
struct timex txc;
|
||||
int i, ret, sep;
|
||||
const char *descript;
|
||||
txc.modes=0;
|
||||
|
||||
opt = bb_getopt_ulflags(argc, argv, "qo:f:p:t:",
|
||||
opt = getopt32(argc, argv, "qo:f:p:t:",
|
||||
&opt_o, &opt_f, &opt_p, &opt_t);
|
||||
//if (opt & 0x1) // -q
|
||||
if (opt & 0x2) { // -o
|
||||
|
@ -133,19 +133,19 @@ static void crondlog(const char *ctl, ...)
|
||||
|
||||
int crond_main(int ac, char **av)
|
||||
{
|
||||
unsigned long opt;
|
||||
unsigned opt;
|
||||
char *lopt, *Lopt, *copt;
|
||||
|
||||
#if ENABLE_DEBUG_CROND_OPTION
|
||||
char *dopt;
|
||||
|
||||
bb_opt_complementally = "f-b:b-f:S-L:L-S:d-l";
|
||||
opt_complementary = "f-b:b-f:S-L:L-S:d-l";
|
||||
#else
|
||||
bb_opt_complementally = "f-b:b-f:S-L:L-S";
|
||||
opt_complementary = "f-b:b-f:S-L:L-S";
|
||||
#endif
|
||||
|
||||
opterr = 0; /* disable getopt 'errors' message. */
|
||||
opt = bb_getopt_ulflags(ac, av, "l:L:fbSc:"
|
||||
opt = getopt32(ac, av, "l:L:fbSc:"
|
||||
#if ENABLE_DEBUG_CROND_OPTION
|
||||
"d:"
|
||||
#endif
|
||||
|
@ -31,8 +31,8 @@ int eject_main(int argc, char **argv)
|
||||
struct mntent *m;
|
||||
int dev;
|
||||
|
||||
/*bb_opt_complementally = "t--T:T--t";*/
|
||||
flags = bb_getopt_ulflags(argc, argv, "tT");
|
||||
/*opt_complementary = "t--T:T--t";*/
|
||||
flags = getopt32(argc, argv, "tT");
|
||||
device = argv[optind] ? : DEFAULT_CDROM;
|
||||
|
||||
m = find_mount_point(device, bb_path_mtab_file);
|
||||
|
@ -575,18 +575,18 @@ static void identify(uint16_t *id_supplied)
|
||||
|
||||
/* check if we recognise the device type */
|
||||
printf("\n");
|
||||
if(!(val[GEN_CONFIG] & NOT_ATA))
|
||||
if (!(val[GEN_CONFIG] & NOT_ATA))
|
||||
{
|
||||
dev = ATA_DEV;
|
||||
printf("ATA device, with ");
|
||||
}
|
||||
else if(val[GEN_CONFIG]==CFA_SUPPORT_VAL)
|
||||
else if (val[GEN_CONFIG]==CFA_SUPPORT_VAL)
|
||||
{
|
||||
dev = ATA_DEV;
|
||||
like_std = 4;
|
||||
printf("CompactFlash ATA device, with ");
|
||||
}
|
||||
else if(!(val[GEN_CONFIG] & NOT_ATAPI))
|
||||
else if (!(val[GEN_CONFIG] & NOT_ATAPI))
|
||||
{
|
||||
dev = ATAPI_DEV;
|
||||
eqpt = (val[GEN_CONFIG] & EQPT_TYPE) >> SHIFT_EQPT;
|
||||
@ -609,9 +609,9 @@ static void identify(uint16_t *id_supplied)
|
||||
(val[CONFIG]==PWRD_NID_VAL) || (val[CONFIG]==PWRD_ID_VAL) )
|
||||
{
|
||||
like_std = 5;
|
||||
if((val[CONFIG]==STBY_NID_VAL) || (val[CONFIG]==STBY_ID_VAL))
|
||||
if ((val[CONFIG]==STBY_NID_VAL) || (val[CONFIG]==STBY_ID_VAL))
|
||||
printf("powers-up in standby; SET FEATURES subcmd spins-up.\n");
|
||||
if(((val[CONFIG]==STBY_NID_VAL) || (val[CONFIG]==PWRD_NID_VAL)) && (val[GEN_CONFIG] & INCOMPLETE))
|
||||
if (((val[CONFIG]==STBY_NID_VAL) || (val[CONFIG]==PWRD_NID_VAL)) && (val[GEN_CONFIG] & INCOMPLETE))
|
||||
printf("\n\tWARNING: ID response incomplete.\n\tFollowing data may be incorrect.\n\n");
|
||||
}
|
||||
|
||||
@ -629,9 +629,9 @@ static void identify(uint16_t *id_supplied)
|
||||
{
|
||||
if (val[MINOR] && (val[MINOR] <= MINOR_MAX))
|
||||
{
|
||||
if(like_std < 3) like_std = 3;
|
||||
if (like_std < 3) like_std = 3;
|
||||
std = actual_ver[val[MINOR]];
|
||||
if(std) printf("\n\tUsed: %s ",minor_str[val[MINOR]]);
|
||||
if (std) printf("\n\tUsed: %s ",minor_str[val[MINOR]]);
|
||||
|
||||
}
|
||||
/* looks like when they up-issue the std, they obsolete one;
|
||||
@ -652,17 +652,17 @@ static void identify(uint16_t *id_supplied)
|
||||
like_std = ii;
|
||||
kk = like_std >4 ? like_std-4: 0;
|
||||
}
|
||||
if(min_std > ii) min_std = ii;
|
||||
if (min_std > ii) min_std = ii;
|
||||
}
|
||||
jj <<= 1;
|
||||
}
|
||||
if(like_std < 3) like_std = 3;
|
||||
if (like_std < 3) like_std = 3;
|
||||
}
|
||||
/* Figure out what standard the device is using if it hasn't told
|
||||
* us. If we know the std, check if the device is using any of
|
||||
* the words from the next level up. It happens.
|
||||
*/
|
||||
if(like_std < std) like_std = std;
|
||||
if (like_std < std) like_std = std;
|
||||
|
||||
if (((std == 5) || (!std && (like_std < 6))) &&
|
||||
((((val[CMDS_SUPP_1] & VALID) == VALID_VAL) &&
|
||||
@ -724,7 +724,7 @@ static void identify(uint16_t *id_supplied)
|
||||
jj = val[CDR_MAJOR] >> 1;
|
||||
for (ii = 1; ii <15; ii++)
|
||||
{
|
||||
if(jj & 0x0001) printf("-%u ", ii);
|
||||
if (jj & 0x0001) printf("-%u ", ii);
|
||||
jj >>= 1;
|
||||
}
|
||||
}
|
||||
@ -743,7 +743,7 @@ static void identify(uint16_t *id_supplied)
|
||||
jj = val[GEN_CONFIG] >> 1;
|
||||
for (ii = 1; ii < 15; ii++)
|
||||
{
|
||||
if(jj & 0x0001) printf("\t%s\n",ata1_cfg_str[ii]);
|
||||
if (jj & 0x0001) printf("\t%s\n",ata1_cfg_str[ii]);
|
||||
jj >>=1;
|
||||
}
|
||||
}
|
||||
@ -1018,7 +1018,7 @@ static void identify(uint16_t *id_supplied)
|
||||
}
|
||||
}
|
||||
/* Removable Media Status Notification feature set */
|
||||
if((val[RM_STAT] & RM_STAT_BITS) == RM_STAT_SUP)
|
||||
if ((val[RM_STAT] & RM_STAT_BITS) == RM_STAT_SUP)
|
||||
printf("\t%s supported\n", cmd_feat_str[27]);
|
||||
|
||||
|
||||
@ -1196,7 +1196,7 @@ static void dump_identity(const struct hd_driveid *id)
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
if(!(id->field_valid&1))
|
||||
if (!(id->field_valid&1))
|
||||
printf(" (maybe):");
|
||||
|
||||
printf(" CurCHS=%u/%u/%u, CurSects=%lu, LBA=%s",id->cur_cyls, id->cur_heads,
|
||||
@ -1589,7 +1589,7 @@ static void interpret_xfermode(unsigned int xfermode)
|
||||
|
||||
static void print_flag(unsigned long flag, char *s, unsigned long value)
|
||||
{
|
||||
if(flag)
|
||||
if (flag)
|
||||
printf(" setting %s to %ld\n", s, value);
|
||||
}
|
||||
|
||||
@ -2078,18 +2078,18 @@ static void parse_xfermode(int flag, unsigned long *get, unsigned long *set, int
|
||||
}
|
||||
|
||||
/*------- getopt short options --------*/
|
||||
static const char hdparm_options[]= "gfu::n::p:r::m::c::k::a::B:tTh"\
|
||||
static const char hdparm_options[] = "gfu::n::p:r::m::c::k::a::B:tTh"
|
||||
USE_FEATURE_HDPARM_GET_IDENTITY("iI")
|
||||
USE_FEATURE_HDPARM_HDIO_GETSET_DMA("d::")
|
||||
#ifdef HDIO_DRIVE_CMD
|
||||
"S:D:P:X:K:A:L:W:CyYzZ"
|
||||
"S:D:P:X:K:A:L:W:CyYzZ"
|
||||
#endif
|
||||
USE_FEATURE_HDPARM_HDIO_UNREGISTER_HWIF("U:")
|
||||
#ifdef HDIO_GET_QDMA
|
||||
#ifdef HDIO_SET_QDMA
|
||||
"Q:"
|
||||
"Q:"
|
||||
#else
|
||||
"Q"
|
||||
"Q"
|
||||
#endif
|
||||
#endif
|
||||
USE_FEATURE_HDPARM_HDIO_DRIVE_RESET("w")
|
||||
@ -2154,8 +2154,8 @@ int hdparm_main(int argc, char **argv)
|
||||
#if ENABLE_FEATURE_HDPARM_HDIO_SCAN_HWIF
|
||||
if (c == 'R') {
|
||||
parse_opts(NULL, &scan_hwif, &hwif_data, 0, INT_MAX);
|
||||
hwif_ctrl = bb_xgetlarg((argv[optind]) ? argv[optind] : "", 10, 0, INT_MAX);
|
||||
hwif_irq = bb_xgetlarg((argv[optind+1]) ? argv[optind+1] : "", 10, 0, INT_MAX);
|
||||
hwif_ctrl = bb_xgetlarg((argv[optind]) ? argv[optind] : "", 10, 0, INT_MAX);
|
||||
hwif_irq = bb_xgetlarg((argv[optind+1]) ? argv[optind+1] : "", 10, 0, INT_MAX);
|
||||
/* Move past the 2 additional arguments */
|
||||
argv += 2;
|
||||
argc -= 2;
|
||||
@ -2163,7 +2163,7 @@ int hdparm_main(int argc, char **argv)
|
||||
#endif
|
||||
}
|
||||
/* When no flags are given (flagcount = 0), -acdgkmnru is assumed. */
|
||||
if (!flagcount){
|
||||
if (!flagcount) {
|
||||
get_mult = get_io32bit = get_unmask = get_keep = get_readonly = get_readahead = get_geom = 1;
|
||||
USE_FEATURE_HDPARM_HDIO_GETSET_DMA(get_dma = 1);
|
||||
}
|
||||
|
@ -1102,7 +1102,7 @@ int less_main(int argc, char **argv) {
|
||||
|
||||
int keypress;
|
||||
|
||||
flags = bb_getopt_ulflags(argc, argv, "EMmN~");
|
||||
flags = getopt32(argc, argv, "EMmN~");
|
||||
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
|
@ -76,7 +76,7 @@ int makedevs_main(int argc, char **argv)
|
||||
int linenum = 0;
|
||||
int ret = EXIT_SUCCESS;
|
||||
|
||||
bb_getopt_ulflags(argc, argv, "d:", &line);
|
||||
getopt32(argc, argv, "d:", &line);
|
||||
if (line)
|
||||
table = xfopen(line, "r");
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
int mountpoint_main(int argc, char **argv)
|
||||
{
|
||||
int opt = bb_getopt_ulflags(argc, argv, "qdx");
|
||||
int opt = getopt32(argc, argv, "qdx");
|
||||
#define OPT_q (1)
|
||||
#define OPT_d (2)
|
||||
#define OPT_x (4)
|
||||
|
@ -21,14 +21,14 @@
|
||||
int strings_main(int argc, char **argv)
|
||||
{
|
||||
int n, c, i = 0, status = EXIT_SUCCESS;
|
||||
unsigned long opt;
|
||||
unsigned opt;
|
||||
unsigned long count;
|
||||
FILE *file = stdin;
|
||||
char *string;
|
||||
const char *fmt = "%s: ";
|
||||
char *n_arg = "4";
|
||||
|
||||
opt = bb_getopt_ulflags(argc, argv, "afon:", &n_arg);
|
||||
opt = getopt32(argc, argv, "afon:", &n_arg);
|
||||
/* -a is our default behaviour */
|
||||
|
||||
argc -= optind;
|
||||
|
@ -25,11 +25,11 @@ static void watchdog_shutdown(int ATTRIBUTE_UNUSED unused)
|
||||
|
||||
int watchdog_main(int argc, char **argv)
|
||||
{
|
||||
unsigned long opts;
|
||||
unsigned opts;
|
||||
unsigned long timer_duration = 30; /* Userspace timer duration, in seconds */
|
||||
char *t_arg;
|
||||
|
||||
opts = bb_getopt_ulflags(argc, argv, "Ft:", &t_arg);
|
||||
opts = getopt32(argc, argv, "Ft:", &t_arg);
|
||||
|
||||
if (opts & OPT_TIMER)
|
||||
timer_duration = bb_xgetlarg(t_arg, 10, 0, INT_MAX);
|
||||
|
@ -3983,7 +3983,7 @@ int insmod_main( int argc, char **argv)
|
||||
struct utsname myuname;
|
||||
|
||||
/* Parse any options */
|
||||
option_mask = bb_getopt_ulflags(argc, argv, OPTION_STR, &opt_o);
|
||||
option_mask = getopt32(argc, argv, OPTION_STR, &opt_o);
|
||||
if (option_mask & OPT_o) { // -o /* name the output module */
|
||||
free(m_name);
|
||||
m_name = xstrdup(opt_o);
|
||||
|
@ -902,8 +902,8 @@ int modprobe_main(int argc, char** argv)
|
||||
int rc = EXIT_SUCCESS;
|
||||
char *unused;
|
||||
|
||||
bb_opt_complementally = "?V-:q-v:v-q";
|
||||
main_opts = bb_getopt_ulflags(argc, argv, "acdklnqrst:vVC:",
|
||||
opt_complementary = "?V-:q-v:v-q";
|
||||
main_opts = getopt32(argc, argv, "acdklnqrst:vVC:",
|
||||
&unused, &unused);
|
||||
if((main_opts & (DUMP_CONF_EXIT | LIST_ALL)))
|
||||
return EXIT_SUCCESS;
|
||||
|
@ -44,7 +44,7 @@ int rmmod_main(int argc, char **argv)
|
||||
unsigned int flags = O_NONBLOCK|O_EXCL;
|
||||
|
||||
/* Parse command line. */
|
||||
n = bb_getopt_ulflags(argc, argv, "wfa");
|
||||
n = getopt32(argc, argv, "wfa");
|
||||
if((n & 1)) // --wait
|
||||
flags &= ~O_NONBLOCK;
|
||||
if((n & 2)) // --force
|
||||
|
@ -265,14 +265,14 @@ int arping_main(int argc, char **argv)
|
||||
xsetuid(getuid());
|
||||
|
||||
{
|
||||
unsigned long opt;
|
||||
unsigned opt;
|
||||
char *_count, *_timeout;
|
||||
|
||||
/* Dad also sets quit_on_reply.
|
||||
* Advert also sets unsolicited.
|
||||
*/
|
||||
bb_opt_complementally = "Df:AU";
|
||||
opt = bb_getopt_ulflags(argc, argv, "DUAqfbc:w:i:s:",
|
||||
opt_complementary = "Df:AU";
|
||||
opt = getopt32(argc, argv, "DUAqfbc:w:i:s:",
|
||||
&_count, &_timeout, &device, &source);
|
||||
cfg |= opt & 0x3f; /* set respective flags */
|
||||
if (opt & 0x40) /* -c: count */
|
||||
|
@ -372,7 +372,7 @@ int dnsd_main(int argc, char **argv)
|
||||
char *sttl=NULL, *sport=NULL;
|
||||
|
||||
if(argc > 1)
|
||||
flags = bb_getopt_ulflags(argc, argv, "i:c:t:p:dv", &listen_interface, &fileconf, &sttl, &sport);
|
||||
flags = getopt32(argc, argv, "i:c:t:p:dv", &listen_interface, &fileconf, &sttl, &sport);
|
||||
if(sttl)
|
||||
if(!(ttl = atol(sttl)))
|
||||
bb_show_usage();
|
||||
|
@ -120,7 +120,7 @@ int ether_wake_main(int argc, char *argv[])
|
||||
struct whereto_t whereto; /* who to wake up */
|
||||
|
||||
/* handle misc user options */
|
||||
flags = bb_getopt_ulflags(argc, argv, "bi:p:", &ifname, &pass);
|
||||
flags = getopt32(argc, argv, "bi:p:", &ifname, &pass);
|
||||
if (optind == argc)
|
||||
bb_show_usage();
|
||||
if (pass)
|
||||
|
@ -228,7 +228,7 @@ int fakeidentd_main(int argc, char **argv)
|
||||
FD_SET(0, &G.readfds);
|
||||
|
||||
/* handle -b <ip> parameter */
|
||||
bb_getopt_ulflags(argc, argv, "b:", &bind_ip_address);
|
||||
getopt32(argc, argv, "b:", &bind_ip_address);
|
||||
/* handle optional REPLY STRING */
|
||||
if (optind < argc)
|
||||
G.identuser = argv[optind];
|
||||
|
@ -275,7 +275,7 @@ static const struct option ftpgetput_long_options[] = {
|
||||
int ftpgetput_main(int argc, char **argv)
|
||||
{
|
||||
/* content-length of the file */
|
||||
unsigned long opt;
|
||||
unsigned opt;
|
||||
char *port = "ftp";
|
||||
|
||||
/* socket to ftp server */
|
||||
@ -305,9 +305,9 @@ int ftpgetput_main(int argc, char **argv)
|
||||
* Decipher the command line
|
||||
*/
|
||||
if (ENABLE_FEATURE_FTPGETPUT_LONG_OPTIONS)
|
||||
bb_applet_long_options = ftpgetput_long_options;
|
||||
applet_long_options = ftpgetput_long_options;
|
||||
|
||||
opt = bb_getopt_ulflags(argc, argv, "cvu:p:P:", &server->user, &server->password, &port);
|
||||
opt = getopt32(argc, argv, "cvu:p:P:", &server->user, &server->password, &port);
|
||||
|
||||
/* Process the non-option command line arguments */
|
||||
if (argc - optind != 3) {
|
||||
|
@ -55,13 +55,13 @@ int hostname_main(int argc, char **argv)
|
||||
};
|
||||
|
||||
char buf[256];
|
||||
unsigned long opt;
|
||||
unsigned opt;
|
||||
char *hostname_str = NULL;
|
||||
|
||||
if (argc < 1)
|
||||
bb_show_usage();
|
||||
|
||||
opt = bb_getopt_ulflags(argc, argv, "dfisF:", &hostname_str);
|
||||
opt = getopt32(argc, argv, "dfisF:", &hostname_str);
|
||||
|
||||
/* Output in desired format */
|
||||
if (opt & OPT_dfis) {
|
||||
|
@ -1909,7 +1909,7 @@ static const char httpd_opts[] = "c:d:h:"
|
||||
|
||||
int httpd_main(int argc, char *argv[])
|
||||
{
|
||||
unsigned long opt;
|
||||
unsigned opt;
|
||||
const char *home_httpd = home;
|
||||
char *url_for_decode;
|
||||
USE_FEATURE_HTTPD_ENCODE_URL_STR(const char *url_for_encode;)
|
||||
@ -1932,7 +1932,7 @@ int httpd_main(int argc, char *argv[])
|
||||
|
||||
config->ContentLength = -1;
|
||||
|
||||
opt = bb_getopt_ulflags(argc, argv, httpd_opts,
|
||||
opt = getopt32(argc, argv, httpd_opts,
|
||||
&(config->configFile), &url_for_decode, &home_httpd
|
||||
USE_FEATURE_HTTPD_ENCODE_URL_STR(, &url_for_encode)
|
||||
USE_FEATURE_HTTPD_BASIC_AUTH(, &(config->realm))
|
||||
|
@ -1088,7 +1088,7 @@ int ifupdown_main(int argc, char **argv)
|
||||
cmds = iface_down;
|
||||
}
|
||||
|
||||
option_mask = bb_getopt_ulflags(argc, argv, OPTION_STR, &interfaces);
|
||||
option_mask = getopt32(argc, argv, OPTION_STR, &interfaces);
|
||||
if (argc - optind > 0) {
|
||||
if (DO_ALL) bb_show_usage();
|
||||
} else
|
||||
|
@ -1253,7 +1253,7 @@ inetd_main(int argc, char *argv[])
|
||||
|
||||
openlog(bb_applet_name, LOG_PID | LOG_NOWAIT, LOG_DAEMON);
|
||||
|
||||
opt = bb_getopt_ulflags(argc, argv, "R:f", &stoomany);
|
||||
opt = getopt32(argc, argv, "R:f", &stoomany);
|
||||
if(opt & 1) {
|
||||
char *e;
|
||||
|
||||
|
@ -90,9 +90,9 @@ int ipcalc_main(int argc, char **argv)
|
||||
char *ipstr;
|
||||
|
||||
if (ENABLE_FEATURE_IPCALC_LONG_OPTIONS)
|
||||
bb_applet_long_options = long_options;
|
||||
applet_long_options = long_options;
|
||||
|
||||
mode = bb_getopt_ulflags(argc, argv, "mbn" USE_FEATURE_IPCALC_FANCY("phs"));
|
||||
mode = getopt32(argc, argv, "mbn" USE_FEATURE_IPCALC_FANCY("phs"));
|
||||
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
|
@ -65,7 +65,7 @@ int nameif_main(int argc, char **argv)
|
||||
int if_index = 1;
|
||||
mactable_t *ch;
|
||||
|
||||
if (1 & bb_getopt_ulflags(argc, argv, "sc:", &fname)) {
|
||||
if (1 & getopt32(argc, argv, "sc:", &fname)) {
|
||||
openlog(bb_applet_name, 0, LOG_LOCAL0);
|
||||
logmode = LOGMODE_SYSLOG;
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ extern void displayroutes(int noresolve, int netstatfmt);
|
||||
#define NETSTAT_CONNECTED 0x01
|
||||
#define NETSTAT_LISTENING 0x02
|
||||
#define NETSTAT_NUMERIC 0x04
|
||||
/* Must match getopt_ulflags option string */
|
||||
/* Must match getopt32 option string */
|
||||
#define NETSTAT_TCP 0x10
|
||||
#define NETSTAT_UDP 0x20
|
||||
#define NETSTAT_RAW 0x40
|
||||
@ -526,7 +526,7 @@ int netstat_main(int argc, char **argv)
|
||||
OPT_extended = 0x4,
|
||||
OPT_showroute = 0x100,
|
||||
};
|
||||
unsigned long opt;
|
||||
unsigned opt;
|
||||
#ifdef CONFIG_FEATURE_IPV6
|
||||
int inet = 1;
|
||||
int inet6 = 1;
|
||||
@ -536,7 +536,7 @@ int netstat_main(int argc, char **argv)
|
||||
#endif
|
||||
|
||||
/* Option string must match NETSTAT_xxx constants */
|
||||
opt = bb_getopt_ulflags(argc, argv, "laentuwxr");
|
||||
opt = getopt32(argc, argv, "laentuwxr");
|
||||
if (opt & 0x1) { // -l
|
||||
flags &= ~NETSTAT_CONNECTED;
|
||||
flags |= NETSTAT_LISTENING;
|
||||
|
@ -647,7 +647,7 @@ static const char tbl_verb[] = /* 2nd byte matches RTACTION_* code */
|
||||
|
||||
int route_main(int argc, char **argv)
|
||||
{
|
||||
unsigned long opt;
|
||||
unsigned opt;
|
||||
int what;
|
||||
char *family;
|
||||
|
||||
@ -662,7 +662,7 @@ int route_main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
opt = bb_getopt_ulflags(argc, argv, "A:ne", &family);
|
||||
opt = getopt32(argc, argv, "A:ne", &family);
|
||||
|
||||
if ((opt & ROUTE_OPT_A) && strcmp(family, "inet")) {
|
||||
#ifdef CONFIG_FEATURE_IPV6
|
||||
|
@ -623,7 +623,7 @@ int telnet_main(int argc, char** argv)
|
||||
bb_show_usage();
|
||||
|
||||
#ifdef CONFIG_FEATURE_TELNET_AUTOLOGIN
|
||||
if (1 & bb_getopt_ulflags(argc, argv, "al:", &autologin))
|
||||
if (1 & getopt32(argc, argv, "al:", &autologin))
|
||||
autologin = getenv("USER");
|
||||
|
||||
if (optind < argc) {
|
||||
|
@ -362,7 +362,7 @@ free_session(struct tsession *ts)
|
||||
int
|
||||
telnetd_main(int argc, char **argv)
|
||||
{
|
||||
unsigned long opt;
|
||||
unsigned opt;
|
||||
fd_set rdfdset, wrfdset;
|
||||
int selret;
|
||||
#ifndef CONFIG_FEATURE_TELNETD_INETD
|
||||
@ -387,7 +387,7 @@ telnetd_main(int argc, char **argv)
|
||||
openlog(bb_applet_name, 0, LOG_USER);
|
||||
logmode = LOGMODE_SYSLOG;
|
||||
|
||||
opt = bb_getopt_ulflags(argc, argv, "f:l:" USE_FEATURE_TELNETD_INETD("p:b:"),
|
||||
opt = getopt32(argc, argv, "f:l:" USE_FEATURE_TELNETD_INETD("p:b:"),
|
||||
&issuefile, &loginpath
|
||||
SKIP_FEATURE_TELNETD_INETD(, &opt_portnbr, &opt_bindaddr));
|
||||
//if (opt & 1) // -f
|
||||
|
@ -497,13 +497,13 @@ int tftp_main(int argc, char **argv)
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_FEATURE_TFTP_GET) && defined(CONFIG_FEATURE_TFTP_PUT)
|
||||
bb_opt_complementally = GET_COMPL PUT_COMPL ":?g--p:p--g";
|
||||
opt_complementary = GET_COMPL PUT_COMPL ":?g--p:p--g";
|
||||
#elif defined(CONFIG_FEATURE_TFTP_GET) || defined(CONFIG_FEATURE_TFTP_PUT)
|
||||
bb_opt_complementally = GET_COMPL PUT_COMPL;
|
||||
opt_complementary = GET_COMPL PUT_COMPL;
|
||||
#endif
|
||||
|
||||
|
||||
cmd = bb_getopt_ulflags(argc, argv, GET PUT "l:r:" BS,
|
||||
cmd = getopt32(argc, argv, GET PUT "l:r:" BS,
|
||||
&localfile, &remotefile BS_ARG);
|
||||
|
||||
cmd &= (tftp_cmd_get | tftp_cmd_put);
|
||||
|
@ -949,12 +949,12 @@ traceroute_main(int argc, char *argv[])
|
||||
|
||||
opterr = 0;
|
||||
#ifdef CONFIG_FEATURE_TRACEROUTE_SOURCE_ROUTE
|
||||
bb_opt_complementally = "x-x:g::";
|
||||
opt_complementary = "x-x:g::";
|
||||
#else
|
||||
bb_opt_complementally = "x-x";
|
||||
opt_complementary = "x-x";
|
||||
#endif
|
||||
|
||||
op = bb_getopt_ulflags(argc, argv, "FIlnrdvxt:i:m:p:q:s:w:z:f:"
|
||||
op = getopt32(argc, argv, "FIlnrdvxt:i:m:p:q:s:w:z:f:"
|
||||
#define USAGE_OP_DONT_FRAGMNT (1<<0) /* F */
|
||||
#define USAGE_OP_USE_ICMP (1<<1) /* I */
|
||||
#define USAGE_OP_TTL_FLAG (1<<2) /* l */
|
||||
|
@ -124,7 +124,7 @@ static const struct option wget_long_options[] = {
|
||||
int wget_main(int argc, char **argv)
|
||||
{
|
||||
int n, try=5, status;
|
||||
unsigned long opt;
|
||||
unsigned opt;
|
||||
int port;
|
||||
char *proxy = 0;
|
||||
char *dir_prefix=NULL;
|
||||
@ -148,11 +148,11 @@ int wget_main(int argc, char **argv)
|
||||
/*
|
||||
* Crack command line.
|
||||
*/
|
||||
bb_opt_complementally = "-1:\203::";
|
||||
opt_complementary = "-1:\203::";
|
||||
#if ENABLE_FEATURE_WGET_LONG_OPTIONS
|
||||
bb_applet_long_options = wget_long_options;
|
||||
applet_long_options = wget_long_options;
|
||||
#endif
|
||||
opt = bb_getopt_ulflags(argc, argv, "cq\213O:\203:P:Y:U:",
|
||||
opt = getopt32(argc, argv, "cq\213O:\203:P:Y:U:",
|
||||
&fname_out, &headers_llist,
|
||||
&dir_prefix, &proxy_flag, &user_agent);
|
||||
if (strcmp(proxy_flag, "off") == 0) {
|
||||
|
@ -75,7 +75,7 @@ enum {
|
||||
#define VDBG(fmt,args...) \
|
||||
do { } while (0)
|
||||
|
||||
static unsigned long opts;
|
||||
static unsigned opts;
|
||||
#define FOREGROUND (opts & 1)
|
||||
#define QUIT (opts & 2)
|
||||
|
||||
@ -217,8 +217,8 @@ int zcip_main(int argc, char *argv[])
|
||||
|
||||
// parse commandline: prog [options] ifname script
|
||||
char *r_opt;
|
||||
bb_opt_complementally = "vv:vf"; // -v accumulates and implies -f
|
||||
opts = bb_getopt_ulflags(argc, argv, "fqr:v", &r_opt, &verbose);
|
||||
opt_complementary = "vv:vf"; // -v accumulates and implies -f
|
||||
opts = getopt32(argc, argv, "fqr:v", &r_opt, &verbose);
|
||||
if (!FOREGROUND) {
|
||||
/* Do it early, before all bb_xx_msg calls */
|
||||
logmode = LOGMODE_SYSLOG;
|
||||
|
@ -39,11 +39,11 @@ int pidof_main(int argc, char **argv)
|
||||
unsigned long int opt;
|
||||
#if ENABLE_FEATURE_PIDOF_OMIT
|
||||
llist_t *omits = NULL; /* list of pids to omit */
|
||||
bb_opt_complementally = _OMIT_COMPL("o::");
|
||||
opt_complementary = _OMIT_COMPL("o::");
|
||||
#endif
|
||||
|
||||
/* do unconditional option parsing */
|
||||
opt = bb_getopt_ulflags(argc, argv,
|
||||
opt = getopt32(argc, argv,
|
||||
_SINGLE_COMPL("s") _OMIT_COMPL("o:")
|
||||
_OMIT(&omits));
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user