aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2009-04-13 20:52:00 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2009-04-13 20:52:00 +0000
commit0b791d9a976e46b2705ae73046706ab9ac3768be (patch)
treec97a6ccdf5b8eb54ecac8991024fa8c80d01ff6e
parent4144504912954b0d31c5bbe5f13df5a4ec4f122a (diff)
downloadbusybox-w32-0b791d9a976e46b2705ae73046706ab9ac3768be.tar.gz
busybox-w32-0b791d9a976e46b2705ae73046706ab9ac3768be.tar.bz2
busybox-w32-0b791d9a976e46b2705ae73046706ab9ac3768be.zip
move llist_find_str from modutils to libbb
-rw-r--r--include/libbb.h1
-rw-r--r--libbb/llist.c10
-rw-r--r--modutils/modutils.c13
-rw-r--r--modutils/modutils.h1
-rw-r--r--networking/ifupdown.c16
-rw-r--r--procps/pidof.c10
6 files changed, 17 insertions, 34 deletions
diff --git a/include/libbb.h b/include/libbb.h
index babf9c9f7..0b94f70fd 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -859,6 +859,7 @@ void *llist_pop(llist_t **elm) FAST_FUNC;
859void llist_unlink(llist_t **head, llist_t *elm) FAST_FUNC; 859void llist_unlink(llist_t **head, llist_t *elm) FAST_FUNC;
860void llist_free(llist_t *elm, void (*freeit)(void *data)) FAST_FUNC; 860void llist_free(llist_t *elm, void (*freeit)(void *data)) FAST_FUNC;
861llist_t *llist_rev(llist_t *list) FAST_FUNC; 861llist_t *llist_rev(llist_t *list) FAST_FUNC;
862llist_t *llist_find_str(llist_t *first, const char *str) FAST_FUNC;
862/* BTW, surprisingly, changing API to 863/* BTW, surprisingly, changing API to
863 * llist_t *llist_add_to(llist_t *old_head, void *data) 864 * llist_t *llist_add_to(llist_t *old_head, void *data)
864 * etc does not result in smaller code... */ 865 * etc does not result in smaller code... */
diff --git a/libbb/llist.c b/libbb/llist.c
index 5ba7f6047..51b1ce6c9 100644
--- a/libbb/llist.c
+++ b/libbb/llist.c
@@ -86,3 +86,13 @@ llist_t* FAST_FUNC llist_rev(llist_t *list)
86 } 86 }
87 return rev; 87 return rev;
88} 88}
89
90llist_t* FAST_FUNC llist_find_str(llist_t *list, const char *str)
91{
92 while (list) {
93 if (strcmp(list->data, str) == 0)
94 break;
95 list = list->link;
96 }
97 return list;
98}
diff --git a/modutils/modutils.c b/modutils/modutils.c
index 44dae7bc5..0f6cb0f2d 100644
--- a/modutils/modutils.c
+++ b/modutils/modutils.c
@@ -16,19 +16,6 @@ extern int delete_module(const char *module, unsigned int flags);
16# define delete_module(mod, flags) syscall(__NR_delete_module, mod, flags) 16# define delete_module(mod, flags) syscall(__NR_delete_module, mod, flags)
17#endif 17#endif
18 18
19/*
20 a libbb candidate from ice age!
21*/
22llist_t FAST_FUNC *llist_find(llist_t *first, const char *str)
23{
24 while (first != NULL) {
25 if (strcmp(first->data, str) == 0)
26 return first;
27 first = first->link;
28 }
29 return NULL;
30}
31
32void FAST_FUNC replace(char *s, char what, char with) 19void FAST_FUNC replace(char *s, char what, char with)
33{ 20{
34 while (*s) { 21 while (*s) {
diff --git a/modutils/modutils.h b/modutils/modutils.h
index 086bb3977..5104f1b6e 100644
--- a/modutils/modutils.h
+++ b/modutils/modutils.h
@@ -18,7 +18,6 @@ PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN
18#define MODULE_NAME_LEN 256 18#define MODULE_NAME_LEN 256
19 19
20const char *moderror(int err) FAST_FUNC; 20const char *moderror(int err) FAST_FUNC;
21llist_t *llist_find(llist_t *first, const char *str) FAST_FUNC;
22void replace(char *s, char what, char with) FAST_FUNC; 21void replace(char *s, char what, char with) FAST_FUNC;
23char *replace_underscores(char *s) FAST_FUNC; 22char *replace_underscores(char *s) FAST_FUNC;
24int string_to_llist(char *string, llist_t **llist, const char *delim) FAST_FUNC; 23int string_to_llist(char *string, llist_t **llist, const char *delim) FAST_FUNC;
diff --git a/networking/ifupdown.c b/networking/ifupdown.c
index c9371cce8..dc7ed490b 100644
--- a/networking/ifupdown.c
+++ b/networking/ifupdown.c
@@ -692,20 +692,6 @@ static const struct method_t *get_method(const struct address_family_t *af, char
692 return NULL; 692 return NULL;
693} 693}
694 694
695static const llist_t *find_list_string(const llist_t *list, const char *string)
696{
697 if (string == NULL)
698 return NULL;
699
700 while (list) {
701 if (strcmp(list->data, string) == 0) {
702 return list;
703 }
704 list = list->link;
705 }
706 return NULL;
707}
708
709static struct interfaces_file_t *read_interfaces(const char *filename) 695static struct interfaces_file_t *read_interfaces(const char *filename)
710{ 696{
711 /* Let's try to be compatible. 697 /* Let's try to be compatible.
@@ -836,7 +822,7 @@ static struct interfaces_file_t *read_interfaces(const char *filename)
836 while ((first_word = next_word(&rest_of_line)) != NULL) { 822 while ((first_word = next_word(&rest_of_line)) != NULL) {
837 823
838 /* Check the interface isnt already listed */ 824 /* Check the interface isnt already listed */
839 if (find_list_string(defn->autointerfaces, first_word)) { 825 if (llist_find_str(defn->autointerfaces, first_word)) {
840 bb_perror_msg_and_die("interface declared auto twice \"%s\"", buf); 826 bb_perror_msg_and_die("interface declared auto twice \"%s\"", buf);
841 } 827 }
842 828
diff --git a/procps/pidof.c b/procps/pidof.c
index 780504433..194239961 100644
--- a/procps/pidof.c
+++ b/procps/pidof.c
@@ -35,12 +35,12 @@ int pidof_main(int argc UNUSED_PARAM, char **argv)
35 /* fill omit list. */ 35 /* fill omit list. */
36 { 36 {
37 llist_t *omits_p = omits; 37 llist_t *omits_p = omits;
38 while (omits_p) { 38 while (1) {
39 omits_p = llist_find_str(omits_p, "%PPID");
40 if (!omits_p)
41 break;
39 /* are we asked to exclude the parent's process ID? */ 42 /* are we asked to exclude the parent's process ID? */
40 if (strcmp(omits_p->data, "%PPID") == 0) { 43 omits_p->data = utoa((unsigned)getppid());
41 omits_p->data = utoa((unsigned)getppid());
42 }
43 omits_p = omits_p->link;
44 } 44 }
45 } 45 }
46#endif 46#endif