httpd: sendfile support
[oweals/busybox.git] / networking / nameif.c
index 146eccea9ebaea0800f95c4cdf33b0b639950ed5..fd081fd63c1fe83b7121a0276f7439bd7fc0113a 100644 (file)
@@ -9,7 +9,7 @@
  * Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
  */
 
-#include "busybox.h"
+#include "libbb.h"
 #include <syslog.h>
 #include <net/if.h>
 #include <netinet/ether.h>
@@ -55,6 +55,7 @@ static struct ether_addr *cc_macaddr(const char *str_macaddr)
        return mac;
 }
 
+int nameif_main(int argc, char **argv);
 int nameif_main(int argc, char **argv)
 {
        mactable_t *clist = NULL;
@@ -66,7 +67,7 @@ int nameif_main(int argc, char **argv)
        mactable_t *ch;
 
        if (1 & getopt32(argc, argv, "sc:", &fname)) {
-               openlog(bb_applet_name, 0, LOG_LOCAL0);
+               openlog(applet_name, 0, LOG_LOCAL0);
                logmode = LOGMODE_SYSLOG;
        }
 
@@ -78,7 +79,7 @@ int nameif_main(int argc, char **argv)
 
                while (*a) {
                        if (strlen(*a) > IF_NAMESIZE)
-                               bb_error_msg_and_die("interface name `%s' "
+                               bb_error_msg_and_die("interface name '%s' "
                                            "too long", *a);
                        ch = xzalloc(sizeof(mactable_t));
                        ch->ifname = xstrdup(*a++);
@@ -91,7 +92,7 @@ int nameif_main(int argc, char **argv)
        } else {
                ifh = xfopen(fname, "r");
 
-               while ((line = bb_get_line_from_file(ifh)) != NULL) {
+               while ((line = xmalloc_fgets(ifh)) != NULL) {
                        char *line_ptr;
                        size_t name_length;
 
@@ -104,7 +105,7 @@ int nameif_main(int argc, char **argv)
                        ch = xzalloc(sizeof(mactable_t));
                        ch->ifname = xstrndup(line_ptr, name_length);
                        if (name_length > IF_NAMESIZE)
-                               bb_error_msg_and_die("interface name `%s' "
+                               bb_error_msg_and_die("interface name '%s' "
                                                "too long", ch->ifname);
                        line_ptr += name_length;
                        line_ptr += strspn(line_ptr, " \t");
@@ -147,9 +148,9 @@ int nameif_main(int argc, char **argv)
                        continue;
 
                strcpy(ifr.ifr_newname, ch->ifname);
-               if (ioctl(ctl_sk, SIOCSIFNAME, &ifr) < 0)
-                       bb_perror_msg_and_die("cannot change ifname %s to %s",
-                                  ifr.ifr_name, ch->ifname);
+               ioctl_or_perror_and_die(ctl_sk, SIOCSIFNAME, &ifr,
+                                       "cannot change ifname %s to %s",
+                                       ifr.ifr_name, ch->ifname);
 
                /* Remove list entry of renamed interface */
                if (ch->prev != NULL) {