diff options
author | Glenn L McGrath <bug1@ihug.co.nz> | 2002-11-28 10:20:45 +0000 |
---|---|---|
committer | Glenn L McGrath <bug1@ihug.co.nz> | 2002-11-28 10:20:45 +0000 |
commit | 642f28903ac3986d2af6002c78f48c0256801965 (patch) | |
tree | 866d40a283b0bbe99ecab41f172cc4f4d8c30031 | |
parent | 30db423e11da340eadb4a55baa2037fc3b8c34e6 (diff) | |
download | busybox-w32-642f28903ac3986d2af6002c78f48c0256801965.tar.gz busybox-w32-642f28903ac3986d2af6002c78f48c0256801965.tar.bz2 busybox-w32-642f28903ac3986d2af6002c78f48c0256801965.zip |
Use error_msg instead of fprintf(stderr, other minor cleanups
-rw-r--r-- | libbb/interface.c | 46 |
1 files changed, 19 insertions, 27 deletions
diff --git a/libbb/interface.c b/libbb/interface.c index 2f4319265..ff7970321 100644 --- a/libbb/interface.c +++ b/libbb/interface.c | |||
@@ -15,7 +15,7 @@ | |||
15 | * that either displays or sets the characteristics of | 15 | * that either displays or sets the characteristics of |
16 | * one or more of the system's networking interfaces. | 16 | * one or more of the system's networking interfaces. |
17 | * | 17 | * |
18 | * Version: $Id: interface.c,v 1.11 2002/11/26 09:02:04 bug1 Exp $ | 18 | * Version: $Id: interface.c,v 1.12 2002/11/28 10:20:45 bug1 Exp $ |
19 | * | 19 | * |
20 | * Author: Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org> | 20 | * Author: Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org> |
21 | * and others. Copyright 1993 MicroWalt Corporation | 21 | * and others. Copyright 1993 MicroWalt Corporation |
@@ -619,7 +619,7 @@ static int aftrans_opt(const char *arg) | |||
619 | if (strcmp(tmp1, paft->alias)) | 619 | if (strcmp(tmp1, paft->alias)) |
620 | continue; | 620 | continue; |
621 | if (strlen(paft->name) + strlen(afname) + 1 >= sizeof(afname)) { | 621 | if (strlen(paft->name) + strlen(afname) + 1 >= sizeof(afname)) { |
622 | fprintf(stderr, _("Too much address family arguments.\n")); | 622 | error_msg(_("Too many address family arguments.")); |
623 | return (0); | 623 | return (0); |
624 | } | 624 | } |
625 | if (paft->flag) | 625 | if (paft->flag) |
@@ -630,7 +630,7 @@ static int aftrans_opt(const char *arg) | |||
630 | break; | 630 | break; |
631 | } | 631 | } |
632 | if (!paft->alias) { | 632 | if (!paft->alias) { |
633 | fprintf(stderr, _("Unknown address family `%s'.\n"), tmp1); | 633 | error_msg(_("Unknown address family `%s'."), tmp1); |
634 | return (1); | 634 | return (1); |
635 | } | 635 | } |
636 | tmp1 = tmp2; | 636 | tmp1 = tmp2; |
@@ -693,8 +693,7 @@ static struct aftype *get_aftype(const char *name) | |||
693 | afp++; | 693 | afp++; |
694 | } | 694 | } |
695 | if (strchr(name, ',')) | 695 | if (strchr(name, ',')) |
696 | fprintf(stderr, | 696 | error_msg(_("Please don't supply more than one address family.")); |
697 | _("Please don't supply more than one address family.\n")); | ||
698 | return (NULL); | 697 | return (NULL); |
699 | } | 698 | } |
700 | #endif /* KEEP_UNUSED */ | 699 | #endif /* KEEP_UNUSED */ |
@@ -888,8 +887,9 @@ static int sockets_open(int family) | |||
888 | if (af->fd >= 0) | 887 | if (af->fd >= 0) |
889 | sfd = af->fd; | 888 | sfd = af->fd; |
890 | } | 889 | } |
891 | if (sfd < 0) | 890 | if (sfd < 0) { |
892 | fprintf(stderr, _("No usable address families found.\n")); | 891 | error_msg(_("No usable address families found.")); |
892 | } | ||
893 | return sfd; | 893 | return sfd; |
894 | } | 894 | } |
895 | 895 | ||
@@ -960,8 +960,7 @@ static int if_readconf(void) | |||
960 | (as of 2.1.128) */ | 960 | (as of 2.1.128) */ |
961 | skfd2 = get_socket_for_af(AF_INET); | 961 | skfd2 = get_socket_for_af(AF_INET); |
962 | if (skfd2 < 0) { | 962 | if (skfd2 < 0) { |
963 | fprintf(stderr, _("warning: no inet socket available: %s\n"), | 963 | perror_msg(("warning: no inet socket available: %s\n")); |
964 | strerror(errno)); | ||
965 | /* Try to soldier on with whatever socket we can get hold of. */ | 964 | /* Try to soldier on with whatever socket we can get hold of. */ |
966 | skfd2 = sockets_open(0); | 965 | skfd2 = sockets_open(0); |
967 | if (skfd2 < 0) | 966 | if (skfd2 < 0) |
@@ -1107,8 +1106,7 @@ static int if_readlist_proc(char *target) | |||
1107 | 1106 | ||
1108 | fh = fopen(_PATH_PROCNET_DEV, "r"); | 1107 | fh = fopen(_PATH_PROCNET_DEV, "r"); |
1109 | if (!fh) { | 1108 | if (!fh) { |
1110 | fprintf(stderr, _("Warning: cannot open %s (%s). Limited output.\n"), | 1109 | perror_msg(_("Warning: cannot open %s (%s). Limited output.\n"), _PATH_PROCNET_DEV); |
1111 | _PATH_PROCNET_DEV, strerror(errno)); | ||
1112 | return if_readconf(); | 1110 | return if_readconf(); |
1113 | } | 1111 | } |
1114 | fgets(buf, sizeof buf, fh); /* eat line */ | 1112 | fgets(buf, sizeof buf, fh); /* eat line */ |
@@ -1368,7 +1366,7 @@ static int do_if_fetch(struct interface *ife) | |||
1368 | } else { | 1366 | } else { |
1369 | errmsg = strerror(errno); | 1367 | errmsg = strerror(errno); |
1370 | } | 1368 | } |
1371 | fprintf(stderr, _("%s: error fetching interface information: %s\n"), | 1369 | error_msg(_("%s: error fetching interface information: %s\n"), |
1372 | ife->name, errmsg); | 1370 | ife->name, errmsg); |
1373 | return -1; | 1371 | return -1; |
1374 | } | 1372 | } |
@@ -1438,8 +1436,7 @@ static int in_ether(char *bufp, struct sockaddr *sap) | |||
1438 | val = c - 'A' + 10; | 1436 | val = c - 'A' + 10; |
1439 | else { | 1437 | else { |
1440 | #ifdef DEBUG | 1438 | #ifdef DEBUG |
1441 | fprintf(stderr, _("in_ether(%s): invalid ether address!\n"), | 1439 | error_msg(_("in_ether(%s): invalid ether address!\n"), orig); |
1442 | orig); | ||
1443 | #endif | 1440 | #endif |
1444 | errno = EINVAL; | 1441 | errno = EINVAL; |
1445 | return (-1); | 1442 | return (-1); |
@@ -1456,8 +1453,7 @@ static int in_ether(char *bufp, struct sockaddr *sap) | |||
1456 | val >>= 4; | 1453 | val >>= 4; |
1457 | else { | 1454 | else { |
1458 | #ifdef DEBUG | 1455 | #ifdef DEBUG |
1459 | fprintf(stderr, _("in_ether(%s): invalid ether address!\n"), | 1456 | error_msg(_("in_ether(%s): invalid ether address!"), orig); |
1460 | orig); | ||
1461 | #endif | 1457 | #endif |
1462 | errno = EINVAL; | 1458 | errno = EINVAL; |
1463 | return (-1); | 1459 | return (-1); |
@@ -1469,27 +1465,23 @@ static int in_ether(char *bufp, struct sockaddr *sap) | |||
1469 | 1465 | ||
1470 | /* We might get a semicolon here - not required. */ | 1466 | /* We might get a semicolon here - not required. */ |
1471 | if (*bufp == ':') { | 1467 | if (*bufp == ':') { |
1472 | if (i == ETH_ALEN) { | ||
1473 | #ifdef DEBUG | 1468 | #ifdef DEBUG |
1474 | fprintf(stderr, _("in_ether(%s): trailing : ignored!\n"), | 1469 | if (i == ETH_ALEN) { |
1475 | orig) | 1470 | error_msg(_("in_ether(%s): trailing : ignored!"), orig); |
1476 | #endif | ||
1477 | ; /* nothing */ | ||
1478 | } | 1471 | } |
1472 | #endif | ||
1479 | bufp++; | 1473 | bufp++; |
1480 | } | 1474 | } |
1481 | } | 1475 | } |
1482 | 1476 | ||
1477 | #ifdef DEBUG | ||
1483 | /* That's it. Any trailing junk? */ | 1478 | /* That's it. Any trailing junk? */ |
1484 | if ((i == ETH_ALEN) && (*bufp != '\0')) { | 1479 | if ((i == ETH_ALEN) && (*bufp != '\0')) { |
1485 | #ifdef DEBUG | 1480 | error_msg(_("in_ether(%s): trailing junk!"), orig); |
1486 | fprintf(stderr, _("in_ether(%s): trailing junk!\n"), orig); | ||
1487 | errno = EINVAL; | 1481 | errno = EINVAL; |
1488 | return (-1); | 1482 | return (-1); |
1489 | #endif | ||
1490 | } | 1483 | } |
1491 | #ifdef DEBUG | 1484 | error_msg("in_ether(%s): %s", orig, pr_ether(sap->sa_data)); |
1492 | fprintf(stderr, "in_ether(%s): %s\n", orig, pr_ether(sap->sa_data)); | ||
1493 | #endif | 1485 | #endif |
1494 | 1486 | ||
1495 | return (0); | 1487 | return (0); |
@@ -1514,7 +1506,7 @@ static struct hwtype ether_hwtype = { | |||
1514 | /* Start the PPP encapsulation on the file descriptor. */ | 1506 | /* Start the PPP encapsulation on the file descriptor. */ |
1515 | static int do_ppp(int fd) | 1507 | static int do_ppp(int fd) |
1516 | { | 1508 | { |
1517 | fprintf(stderr, _("You cannot start PPP with this program.\n")); | 1509 | error_msg(_("You cannot start PPP with this program.")); |
1518 | return -1; | 1510 | return -1; |
1519 | } | 1511 | } |
1520 | #endif /* KEEP_UNUSED */ | 1512 | #endif /* KEEP_UNUSED */ |