From: Denis Vlasenko Date: Fri, 22 Sep 2006 08:50:29 +0000 (-0000) Subject: telnetd: getopt_ulflags'isation X-Git-Tag: 1_4_0~633 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=0e87d347e8298c76d689eae1aabcee5aba313072;p=oweals%2Fbusybox.git telnetd: getopt_ulflags'isation --- diff --git a/networking/telnetd.c b/networking/telnetd.c index 890e58466..9fa8faf66 100644 --- a/networking/telnetd.c +++ b/networking/telnetd.c @@ -362,23 +362,16 @@ free_session(struct tsession *ts) int telnetd_main(int argc, char **argv) { -#ifndef CONFIG_FEATURE_TELNETD_INETD - sockaddr_type sa; - int master_fd; -#endif /* CONFIG_FEATURE_TELNETD_INETD */ + unsigned long opt; fd_set rdfdset, wrfdset; int selret; #ifndef CONFIG_FEATURE_TELNETD_INETD + sockaddr_type sa; + int master_fd; int on = 1; int portnbr = 23; struct in_addr bind_addr = { .s_addr = 0x0 }; -#endif /* CONFIG_FEATURE_TELNETD_INETD */ - int c; - static const char options[] = -#ifdef CONFIG_FEATURE_TELNETD_INETD - "f:l:"; -#else /* CONFIG_EATURE_TELNETD_INETD */ - "f:l:p:b:"; + char *opt_portnbr, *opt_bindaddr; #endif /* CONFIG_FEATURE_TELNETD_INETD */ int maxlen, w, r; @@ -394,29 +387,16 @@ telnetd_main(int argc, char **argv) openlog(bb_applet_name, 0, LOG_USER); logmode = LOGMODE_SYSLOG; - for (;;) { - c = getopt( argc, argv, options); - if (c == EOF) break; - switch (c) { - case 'f': - issuefile = optarg; - break; - case 'l': - loginpath = optarg; - break; + opt = bb_getopt_ulflags(argc, argv, "f:l:" USE_FEATURE_TELNETD_INETD("p:b:"), + &issuefile, &loginpath + SKIP_FEATURE_TELNETD_INETD(, &opt_portnbr, &opt_bindaddr)); + //if (opt & 1) // -f + //if (opt & 2) // -l #ifndef CONFIG_FEATURE_TELNETD_INETD - case 'p': - portnbr = atoi(optarg); - break; - case 'b': - if (inet_aton(optarg, &bind_addr) == 0) - bb_show_usage(); - break; + if (opt & 4) portnbr = atoi(opt_portnbr); // -p + if (opt & 8) // -b + if (inet_aton(opt_bindaddr, &bind_addr) == 0) bb_show_usage(); #endif /* CONFIG_FEATURE_TELNETD_INETD */ - default: - bb_show_usage(); - } - } if (access(loginpath, X_OK) < 0) { bb_error_msg_and_die("'%s' unavailable", loginpath);