diff options
author | Rob Landley <rob@landley.net> | 2006-08-03 15:41:12 +0000 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2006-08-03 15:41:12 +0000 |
commit | d921b2ecc0d294ad4bf8c7458fc52a60c28727d2 (patch) | |
tree | e4a2769349867c441cf2983d83097bb66701a733 /networking/ifupdown.c | |
parent | 6dce0b6fa79f2d4bb7e9d90e1fbc0f6beb25f855 (diff) | |
download | busybox-w32-d921b2ecc0d294ad4bf8c7458fc52a60c28727d2.tar.gz busybox-w32-d921b2ecc0d294ad4bf8c7458fc52a60c28727d2.tar.bz2 busybox-w32-d921b2ecc0d294ad4bf8c7458fc52a60c28727d2.zip |
Remove bb_ prefixes from xfuncs.c (and a few other places), consolidate
things like xasprintf() into xfuncs.c, remove xprint_file_by_name() (it only
had one user), clean up lots of #includes... General cleanup pass. What I've
been doing for the last couple days.
And it conflicts! I've removed httpd.c from this checkin due to somebody else
touching that file. It builds for me. I have to catch a bus. (Now you know
why I'm looking forward to Mercurial.)
Diffstat (limited to 'networking/ifupdown.c')
-rw-r--r-- | networking/ifupdown.c | 48 |
1 files changed, 18 insertions, 30 deletions
diff --git a/networking/ifupdown.c b/networking/ifupdown.c index 8ee488364..6429c07e5 100644 --- a/networking/ifupdown.c +++ b/networking/ifupdown.c | |||
@@ -17,22 +17,10 @@ | |||
17 | 17 | ||
18 | /* TODO: standardise execute() return codes to return 0 for success and 1 for failure */ | 18 | /* TODO: standardise execute() return codes to return 0 for success and 1 for failure */ |
19 | 19 | ||
20 | #include <sys/stat.h> | 20 | #include "busybox.h" |
21 | #include <sys/utsname.h> | 21 | #include <sys/utsname.h> |
22 | #include <sys/wait.h> | ||
23 | |||
24 | #include <ctype.h> | ||
25 | #include <errno.h> | ||
26 | #include <fcntl.h> | ||
27 | #include <fnmatch.h> | 22 | #include <fnmatch.h> |
28 | #include <getopt.h> | 23 | #include <getopt.h> |
29 | #include <stdarg.h> | ||
30 | #include <stdio.h> | ||
31 | #include <stdlib.h> | ||
32 | #include <string.h> | ||
33 | #include <unistd.h> | ||
34 | |||
35 | #include "busybox.h" | ||
36 | 24 | ||
37 | #define MAX_OPT_DEPTH 10 | 25 | #define MAX_OPT_DEPTH 10 |
38 | #define EUNBALBRACK 10001 | 26 | #define EUNBALBRACK 10001 |
@@ -628,7 +616,7 @@ static struct interfaces_file_t *read_interfaces(const char *filename) | |||
628 | 616 | ||
629 | defn = xzalloc(sizeof(struct interfaces_file_t)); | 617 | defn = xzalloc(sizeof(struct interfaces_file_t)); |
630 | 618 | ||
631 | f = bb_xfopen(filename, "r"); | 619 | f = xfopen(filename, "r"); |
632 | 620 | ||
633 | while ((buf = bb_get_chomped_line_from_file(f)) != NULL) { | 621 | while ((buf = bb_get_chomped_line_from_file(f)) != NULL) { |
634 | char *buf_ptr = buf; | 622 | char *buf_ptr = buf; |
@@ -649,7 +637,7 @@ static struct interfaces_file_t *read_interfaces(const char *filename) | |||
649 | currmap->match = xrealloc(currmap->match, sizeof(currmap->match) * currmap->max_matches); | 637 | currmap->match = xrealloc(currmap->match, sizeof(currmap->match) * currmap->max_matches); |
650 | } | 638 | } |
651 | 639 | ||
652 | currmap->match[currmap->n_matches++] = bb_xstrdup(firstword); | 640 | currmap->match[currmap->n_matches++] = xstrdup(firstword); |
653 | } | 641 | } |
654 | currmap->max_mappings = 0; | 642 | currmap->max_mappings = 0; |
655 | currmap->n_mappings = 0; | 643 | currmap->n_mappings = 0; |
@@ -701,7 +689,7 @@ static struct interfaces_file_t *read_interfaces(const char *filename) | |||
701 | return NULL; | 689 | return NULL; |
702 | } | 690 | } |
703 | 691 | ||
704 | currif->iface = bb_xstrdup(iface_name); | 692 | currif->iface = xstrdup(iface_name); |
705 | 693 | ||
706 | currif->address_family = get_address_family(addr_fams, address_family_name); | 694 | currif->address_family = get_address_family(addr_fams, address_family_name); |
707 | if (!currif->address_family) { | 695 | if (!currif->address_family) { |
@@ -741,7 +729,7 @@ static struct interfaces_file_t *read_interfaces(const char *filename) | |||
741 | } | 729 | } |
742 | 730 | ||
743 | /* Add the interface to the list */ | 731 | /* Add the interface to the list */ |
744 | llist_add_to_end(&(defn->autointerfaces), bb_xstrdup(firstword)); | 732 | llist_add_to_end(&(defn->autointerfaces), xstrdup(firstword)); |
745 | debug_noise("\nauto %s\n", firstword); | 733 | debug_noise("\nauto %s\n", firstword); |
746 | } | 734 | } |
747 | currently_processing = NONE; | 735 | currently_processing = NONE; |
@@ -775,8 +763,8 @@ static struct interfaces_file_t *read_interfaces(const char *filename) | |||
775 | opt = xrealloc(currif->option, sizeof(*opt) * currif->max_options); | 763 | opt = xrealloc(currif->option, sizeof(*opt) * currif->max_options); |
776 | currif->option = opt; | 764 | currif->option = opt; |
777 | } | 765 | } |
778 | currif->option[currif->n_options].name = bb_xstrdup(firstword); | 766 | currif->option[currif->n_options].name = xstrdup(firstword); |
779 | currif->option[currif->n_options].value = bb_xstrdup(buf_ptr); | 767 | currif->option[currif->n_options].value = xstrdup(buf_ptr); |
780 | if (!currif->option[currif->n_options].name) { | 768 | if (!currif->option[currif->n_options].name) { |
781 | perror(filename); | 769 | perror(filename); |
782 | return NULL; | 770 | return NULL; |
@@ -796,14 +784,14 @@ static struct interfaces_file_t *read_interfaces(const char *filename) | |||
796 | bb_error_msg("duplicate script in mapping \"%s\"", buf); | 784 | bb_error_msg("duplicate script in mapping \"%s\"", buf); |
797 | return NULL; | 785 | return NULL; |
798 | } else { | 786 | } else { |
799 | currmap->script = bb_xstrdup(next_word(&buf_ptr)); | 787 | currmap->script = xstrdup(next_word(&buf_ptr)); |
800 | } | 788 | } |
801 | } else if (strcmp(firstword, "map") == 0) { | 789 | } else if (strcmp(firstword, "map") == 0) { |
802 | if (currmap->max_mappings == currmap->n_mappings) { | 790 | if (currmap->max_mappings == currmap->n_mappings) { |
803 | currmap->max_mappings = currmap->max_mappings * 2 + 1; | 791 | currmap->max_mappings = currmap->max_mappings * 2 + 1; |
804 | currmap->mapping = xrealloc(currmap->mapping, sizeof(char *) * currmap->max_mappings); | 792 | currmap->mapping = xrealloc(currmap->mapping, sizeof(char *) * currmap->max_mappings); |
805 | } | 793 | } |
806 | currmap->mapping[currmap->n_mappings] = bb_xstrdup(next_word(&buf_ptr)); | 794 | currmap->mapping[currmap->n_mappings] = xstrdup(next_word(&buf_ptr)); |
807 | currmap->n_mappings++; | 795 | currmap->n_mappings++; |
808 | } else { | 796 | } else { |
809 | bb_error_msg("misplaced option \"%s\"", buf); | 797 | bb_error_msg("misplaced option \"%s\"", buf); |
@@ -833,7 +821,7 @@ static char *setlocalenv(char *format, const char *name, const char *value) | |||
833 | char *here; | 821 | char *here; |
834 | char *there; | 822 | char *there; |
835 | 823 | ||
836 | result = bb_xasprintf(format, name, value); | 824 | result = xasprintf(format, name, value); |
837 | 825 | ||
838 | for (here = there = result; *there != '=' && *there; there++) { | 826 | for (here = there = result; *there != '=' && *there; there++) { |
839 | if (*there == '-') | 827 | if (*there == '-') |
@@ -922,7 +910,7 @@ static int execute_all(struct interface_defn_t *ifd, const char *opt) | |||
922 | } | 910 | } |
923 | } | 911 | } |
924 | 912 | ||
925 | buf = bb_xasprintf("run-parts /etc/network/if-%s.d", opt); | 913 | buf = xasprintf("run-parts /etc/network/if-%s.d", opt); |
926 | if (doit(buf) != 1) { | 914 | if (doit(buf) != 1) { |
927 | return 0; | 915 | return 0; |
928 | } | 916 | } |
@@ -1013,7 +1001,7 @@ static char *run_mapping(char *physical, struct mapping_defn_t * map) | |||
1013 | int i, status; | 1001 | int i, status; |
1014 | pid_t pid; | 1002 | pid_t pid; |
1015 | 1003 | ||
1016 | char *logical = bb_xstrdup(physical); | 1004 | char *logical = xstrdup(physical); |
1017 | 1005 | ||
1018 | /* Run the mapping script. */ | 1006 | /* Run the mapping script. */ |
1019 | pid = popen2(&in, &out, map->script, physical, NULL); | 1007 | pid = popen2(&in, &out, map->script, physical, NULL); |
@@ -1158,7 +1146,7 @@ int ifupdown_main(int argc, char **argv) | |||
1158 | /* iface_down */ | 1146 | /* iface_down */ |
1159 | const llist_t *list = state_list; | 1147 | const llist_t *list = state_list; |
1160 | while (list) { | 1148 | while (list) { |
1161 | llist_add_to_end(&target_list, bb_xstrdup(list->data)); | 1149 | llist_add_to_end(&target_list, xstrdup(list->data)); |
1162 | list = list->link; | 1150 | list = list->link; |
1163 | } | 1151 | } |
1164 | target_list = defn->autointerfaces; | 1152 | target_list = defn->autointerfaces; |
@@ -1178,15 +1166,15 @@ int ifupdown_main(int argc, char **argv) | |||
1178 | int okay = 0; | 1166 | int okay = 0; |
1179 | int cmds_ret; | 1167 | int cmds_ret; |
1180 | 1168 | ||
1181 | iface = bb_xstrdup(target_list->data); | 1169 | iface = xstrdup(target_list->data); |
1182 | target_list = target_list->link; | 1170 | target_list = target_list->link; |
1183 | 1171 | ||
1184 | pch = strchr(iface, '='); | 1172 | pch = strchr(iface, '='); |
1185 | if (pch) { | 1173 | if (pch) { |
1186 | *pch = '\0'; | 1174 | *pch = '\0'; |
1187 | liface = bb_xstrdup(pch + 1); | 1175 | liface = xstrdup(pch + 1); |
1188 | } else { | 1176 | } else { |
1189 | liface = bb_xstrdup(iface); | 1177 | liface = xstrdup(iface); |
1190 | } | 1178 | } |
1191 | 1179 | ||
1192 | if (!force) { | 1180 | if (!force) { |
@@ -1263,7 +1251,7 @@ int ifupdown_main(int argc, char **argv) | |||
1263 | llist_t *iface_state = find_iface_state(state_list, iface); | 1251 | llist_t *iface_state = find_iface_state(state_list, iface); |
1264 | 1252 | ||
1265 | if (cmds == iface_up) { | 1253 | if (cmds == iface_up) { |
1266 | char *newiface = bb_xasprintf("%s=%s", iface, liface); | 1254 | char *newiface = xasprintf("%s=%s", iface, liface); |
1267 | if (iface_state == NULL) { | 1255 | if (iface_state == NULL) { |
1268 | llist_add_to_end(&state_list, newiface); | 1256 | llist_add_to_end(&state_list, newiface); |
1269 | } else { | 1257 | } else { |
@@ -1281,7 +1269,7 @@ int ifupdown_main(int argc, char **argv) | |||
1281 | if (!no_act) { | 1269 | if (!no_act) { |
1282 | FILE *state_fp = NULL; | 1270 | FILE *state_fp = NULL; |
1283 | 1271 | ||
1284 | state_fp = bb_xfopen(statefile, "w"); | 1272 | state_fp = xfopen(statefile, "w"); |
1285 | while (state_list) { | 1273 | while (state_list) { |
1286 | if (state_list->data) { | 1274 | if (state_list->data) { |
1287 | fputs(state_list->data, state_fp); | 1275 | fputs(state_list->data, state_fp); |