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:
Denis Vlasenko
2006-10-03 21:00:06 +00:00
parent 40920825d5
commit 67b23e6043
120 changed files with 322 additions and 327 deletions

View File

@@ -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 */

View File

@@ -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();

View File

@@ -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)

View File

@@ -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];

View File

@@ -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) {

View File

@@ -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) {

View File

@@ -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))

View File

@@ -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

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;
}

View File

@@ -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;

View File

@@ -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

View File

@@ -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) {

View File

@@ -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

View File

@@ -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);

View File

@@ -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 */

View File

@@ -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) {

View File

@@ -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;