* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
-#include <getopt.h>
#include <sys/socket.h>
#include <arpa/inet.h>
;
#endif
-int ipcalc_main(int argc, char **argv);
+int ipcalc_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int ipcalc_main(int argc, char **argv)
{
unsigned opt;
#if ENABLE_FEATURE_IPCALC_LONG_OPTIONS
applet_long_options = ipcalc_longopts;
#endif
- opt = getopt32(argc, argv, "mbn" USE_FEATURE_IPCALC_FANCY("phs"));
+ opt = getopt32(argv, "mbn" IF_FEATURE_IPCALC_FANCY("phs"));
argc -= optind;
argv += optind;
if (opt & (BROADCAST | NETWORK | NETPREFIX)) {
if (opt & HOSTNAME) {
struct hostent *hostinfo;
- int x;
hostinfo = gethostbyaddr((char *) &ipaddr, sizeof(ipaddr), AF_INET);
if (!hostinfo) {
- bb_herror_msg_and_die("cannot find hostname for %s", argv[0]);
- }
- for (x = 0; hostinfo->h_name[x]; x++) {
- hostinfo->h_name[x] = tolower(hostinfo->h_name[x]);
+ bb_herror_msg_and_die("can't find hostname for %s", argv[0]);
}
+ str_tolower(hostinfo->h_name);
printf("HOSTNAME=%s\n", hostinfo->h_name);
}