move llist_find_str from modutils to libbb
This commit is contained in:
parent
4144504912
commit
0b791d9a97
@ -859,6 +859,7 @@ void *llist_pop(llist_t **elm) FAST_FUNC;
|
|||||||
void llist_unlink(llist_t **head, llist_t *elm) FAST_FUNC;
|
void llist_unlink(llist_t **head, llist_t *elm) FAST_FUNC;
|
||||||
void llist_free(llist_t *elm, void (*freeit)(void *data)) FAST_FUNC;
|
void llist_free(llist_t *elm, void (*freeit)(void *data)) FAST_FUNC;
|
||||||
llist_t *llist_rev(llist_t *list) FAST_FUNC;
|
llist_t *llist_rev(llist_t *list) FAST_FUNC;
|
||||||
|
llist_t *llist_find_str(llist_t *first, const char *str) FAST_FUNC;
|
||||||
/* BTW, surprisingly, changing API to
|
/* BTW, surprisingly, changing API to
|
||||||
* llist_t *llist_add_to(llist_t *old_head, void *data)
|
* llist_t *llist_add_to(llist_t *old_head, void *data)
|
||||||
* etc does not result in smaller code... */
|
* etc does not result in smaller code... */
|
||||||
|
@ -86,3 +86,13 @@ llist_t* FAST_FUNC llist_rev(llist_t *list)
|
|||||||
}
|
}
|
||||||
return rev;
|
return rev;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
llist_t* FAST_FUNC llist_find_str(llist_t *list, const char *str)
|
||||||
|
{
|
||||||
|
while (list) {
|
||||||
|
if (strcmp(list->data, str) == 0)
|
||||||
|
break;
|
||||||
|
list = list->link;
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
@ -16,19 +16,6 @@ extern int delete_module(const char *module, unsigned int flags);
|
|||||||
# define delete_module(mod, flags) syscall(__NR_delete_module, mod, flags)
|
# define delete_module(mod, flags) syscall(__NR_delete_module, mod, flags)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
|
||||||
a libbb candidate from ice age!
|
|
||||||
*/
|
|
||||||
llist_t FAST_FUNC *llist_find(llist_t *first, const char *str)
|
|
||||||
{
|
|
||||||
while (first != NULL) {
|
|
||||||
if (strcmp(first->data, str) == 0)
|
|
||||||
return first;
|
|
||||||
first = first->link;
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void FAST_FUNC replace(char *s, char what, char with)
|
void FAST_FUNC replace(char *s, char what, char with)
|
||||||
{
|
{
|
||||||
while (*s) {
|
while (*s) {
|
||||||
|
@ -18,7 +18,6 @@ PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN
|
|||||||
#define MODULE_NAME_LEN 256
|
#define MODULE_NAME_LEN 256
|
||||||
|
|
||||||
const char *moderror(int err) FAST_FUNC;
|
const char *moderror(int err) FAST_FUNC;
|
||||||
llist_t *llist_find(llist_t *first, const char *str) FAST_FUNC;
|
|
||||||
void replace(char *s, char what, char with) FAST_FUNC;
|
void replace(char *s, char what, char with) FAST_FUNC;
|
||||||
char *replace_underscores(char *s) FAST_FUNC;
|
char *replace_underscores(char *s) FAST_FUNC;
|
||||||
int string_to_llist(char *string, llist_t **llist, const char *delim) FAST_FUNC;
|
int string_to_llist(char *string, llist_t **llist, const char *delim) FAST_FUNC;
|
||||||
|
@ -692,20 +692,6 @@ static const struct method_t *get_method(const struct address_family_t *af, char
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const llist_t *find_list_string(const llist_t *list, const char *string)
|
|
||||||
{
|
|
||||||
if (string == NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
while (list) {
|
|
||||||
if (strcmp(list->data, string) == 0) {
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
list = list->link;
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct interfaces_file_t *read_interfaces(const char *filename)
|
static struct interfaces_file_t *read_interfaces(const char *filename)
|
||||||
{
|
{
|
||||||
/* Let's try to be compatible.
|
/* Let's try to be compatible.
|
||||||
@ -836,7 +822,7 @@ static struct interfaces_file_t *read_interfaces(const char *filename)
|
|||||||
while ((first_word = next_word(&rest_of_line)) != NULL) {
|
while ((first_word = next_word(&rest_of_line)) != NULL) {
|
||||||
|
|
||||||
/* Check the interface isnt already listed */
|
/* Check the interface isnt already listed */
|
||||||
if (find_list_string(defn->autointerfaces, first_word)) {
|
if (llist_find_str(defn->autointerfaces, first_word)) {
|
||||||
bb_perror_msg_and_die("interface declared auto twice \"%s\"", buf);
|
bb_perror_msg_and_die("interface declared auto twice \"%s\"", buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,12 +35,12 @@ int pidof_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
/* fill omit list. */
|
/* fill omit list. */
|
||||||
{
|
{
|
||||||
llist_t *omits_p = omits;
|
llist_t *omits_p = omits;
|
||||||
while (omits_p) {
|
while (1) {
|
||||||
|
omits_p = llist_find_str(omits_p, "%PPID");
|
||||||
|
if (!omits_p)
|
||||||
|
break;
|
||||||
/* are we asked to exclude the parent's process ID? */
|
/* are we asked to exclude the parent's process ID? */
|
||||||
if (strcmp(omits_p->data, "%PPID") == 0) {
|
omits_p->data = utoa((unsigned)getppid());
|
||||||
omits_p->data = utoa((unsigned)getppid());
|
|
||||||
}
|
|
||||||
omits_p = omits_p->link;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user