aboutsummaryrefslogtreecommitdiff
path: root/networking/ipcalc.c
diff options
context:
space:
mode:
Diffstat (limited to 'networking/ipcalc.c')
-rw-r--r--networking/ipcalc.c43
1 files changed, 18 insertions, 25 deletions
diff --git a/networking/ipcalc.c b/networking/ipcalc.c
index 9888a6ff2..cdae8eea8 100644
--- a/networking/ipcalc.c
+++ b/networking/ipcalc.c
@@ -31,7 +31,7 @@
31//config: Adds the options hostname, prefix and silent to the output of 31//config: Adds the options hostname, prefix and silent to the output of
32//config: "ipcalc". 32//config: "ipcalc".
33 33
34//applet:IF_IPCALC(APPLET(ipcalc, BB_DIR_BIN, BB_SUID_DROP)) 34//applet:IF_IPCALC(APPLET_NOEXEC(ipcalc, ipcalc, BB_DIR_BIN, BB_SUID_DROP, ipcalc))
35 35
36//kbuild:lib-$(CONFIG_IPCALC) += ipcalc.o 36//kbuild:lib-$(CONFIG_IPCALC) += ipcalc.o
37 37
@@ -39,26 +39,14 @@
39//usage: "[OPTIONS] ADDRESS" 39//usage: "[OPTIONS] ADDRESS"
40//usage: IF_FEATURE_IPCALC_FANCY("[/PREFIX]") " [NETMASK]" 40//usage: IF_FEATURE_IPCALC_FANCY("[/PREFIX]") " [NETMASK]"
41//usage:#define ipcalc_full_usage "\n\n" 41//usage:#define ipcalc_full_usage "\n\n"
42//usage: "Calculate IP network settings from a IP address\n" 42//usage: "Calculate and display network settings from IP address\n"
43//usage: IF_FEATURE_IPCALC_LONG_OPTIONS( 43//usage: "\n -b Broadcast address"
44//usage: "\n -b,--broadcast Display calculated broadcast address" 44//usage: "\n -n Network address"
45//usage: "\n -n,--network Display calculated network address" 45//usage: "\n -m Default netmask for IP"
46//usage: "\n -m,--netmask Display default netmask for IP"
47//usage: IF_FEATURE_IPCALC_FANCY( 46//usage: IF_FEATURE_IPCALC_FANCY(
48//usage: "\n -p,--prefix Display the prefix for IP/NETMASK" 47//usage: "\n -p Prefix for IP/NETMASK"
49//usage: "\n -h,--hostname Display first resolved host name" 48//usage: "\n -h Resolved host name"
50//usage: "\n -s,--silent Don't ever display error messages" 49//usage: "\n -s No error messages"
51//usage: )
52//usage: )
53//usage: IF_NOT_FEATURE_IPCALC_LONG_OPTIONS(
54//usage: "\n -b Display calculated broadcast address"
55//usage: "\n -n Display calculated network address"
56//usage: "\n -m Display default netmask for IP"
57//usage: IF_FEATURE_IPCALC_FANCY(
58//usage: "\n -p Display the prefix for IP/NETMASK"
59//usage: "\n -h Display first resolved host name"
60//usage: "\n -s Don't ever display error messages"
61//usage: )
62//usage: ) 50//usage: )
63 51
64#include "libbb.h" 52#include "libbb.h"
@@ -120,6 +108,11 @@ int get_prefix(unsigned long netmask);
120 "silent\0" No_argument "s" // don’t ever display error messages 108 "silent\0" No_argument "s" // don’t ever display error messages
121# endif 109# endif
122 ; 110 ;
111# define GETOPT32 getopt32long
112# define LONGOPTS ,ipcalc_longopts
113#else
114# define GETOPT32 getopt32
115# define LONGOPTS
123#endif 116#endif
124 117
125int ipcalc_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 118int ipcalc_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
@@ -137,11 +130,11 @@ int ipcalc_main(int argc UNUSED_PARAM, char **argv)
137#define ipaddr (s_ipaddr.s_addr) 130#define ipaddr (s_ipaddr.s_addr)
138 char *ipstr; 131 char *ipstr;
139 132
140#if ENABLE_FEATURE_IPCALC_LONG_OPTIONS 133 opt = GETOPT32(argv, "^"
141 applet_long_options = ipcalc_longopts; 134 "mbn" IF_FEATURE_IPCALC_FANCY("phs")
142#endif 135 "\0" "-1:?2"/*min 1, max 2 args*/
143 opt_complementary = "-1:?2"; /* minimum 1 arg, maximum 2 args */ 136 LONGOPTS
144 opt = getopt32(argv, "mbn" IF_FEATURE_IPCALC_FANCY("phs")); 137 );
145 argv += optind; 138 argv += optind;
146 if (opt & SILENT) 139 if (opt & SILENT)
147 logmode = LOGMODE_NONE; /* suppress error_msg() output */ 140 logmode = LOGMODE_NONE; /* suppress error_msg() output */