xatonum.h: add comment
[oweals/busybox.git] / networking / hostname.c
index 45aaaa465a7deab6040523ba8ddd0912735b0011..2c224bef905fc5afc6c1b4ddb3a0e4a88f24d6c2 100644 (file)
@@ -12,7 +12,7 @@
  * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
  */
 
-#include "busybox.h"
+#include "libbb.h"
 
 static void do_sethostname(char *s, int isfile)
 {
@@ -29,18 +29,20 @@ static void do_sethostname(char *s, int isfile)
                }
        } else {
                f = xfopen(s, "r");
-               while (fgets(bb_common_bufsiz1, sizeof(bb_common_bufsiz1), f) != NULL) {
-                       if (bb_common_bufsiz1[0] == '#') {
+#define strbuf bb_common_bufsiz1
+               while (fgets(strbuf, sizeof(strbuf), f) != NULL) {
+                       if (strbuf[0] == '#') {
                                continue;
                        }
-                       chomp(bb_common_bufsiz1);
-                       do_sethostname(bb_common_bufsiz1, 0);
+                       chomp(strbuf);
+                       do_sethostname(strbuf, 0);
                }
                if (ENABLE_FEATURE_CLEAN_UP)
                        fclose(f);
        }
 }
 
+int hostname_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
 int hostname_main(int argc, char **argv)
 {
        enum {
@@ -58,7 +60,7 @@ int hostname_main(int argc, char **argv)
        if (argc < 1)
                bb_show_usage();
 
-       getopt32(argc, argv, "dfisF:", &hostname_str);
+       getopt32(argv, "dfisF:", &hostname_str);
 
        /* Output in desired format */
        if (option_mask32 & OPT_dfis) {
@@ -81,7 +83,7 @@ int hostname_main(int argc, char **argv)
                        while (hp->h_addr_list[0]) {
                                printf("%s ", inet_ntoa(*(struct in_addr *) (*hp->h_addr_list++)));
                        }
-                       puts("");
+                       bb_putchar('\n');
                }
        }
        /* Set the hostname */