2013-01-08 15:13:43 +00:00
|
|
|
#ifndef __STRINGLIST_H
|
|
|
|
#define __STRINGLIST_H
|
2008-03-11 20:38:22 +00:00
|
|
|
|
2009-11-02 13:31:18 +00:00
|
|
|
#include <linux/list.h>
|
2008-03-11 20:38:22 +00:00
|
|
|
|
|
|
|
struct string_list {
|
|
|
|
struct list_head list;
|
2012-04-19 02:34:11 +00:00
|
|
|
char *str;
|
2008-03-11 20:38:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
int string_list_add(struct string_list *sl, char *str);
|
2012-04-19 02:36:28 +00:00
|
|
|
int string_list_add_asprintf(struct string_list *sl, const char *fmt, ...);
|
2011-12-21 08:07:55 +00:00
|
|
|
int string_list_add_sorted(struct string_list *sl, char *str);
|
|
|
|
int string_list_contains(struct string_list *sl, char *str);
|
2008-03-11 20:38:22 +00:00
|
|
|
void string_list_print_by_column(struct string_list *sl);
|
|
|
|
|
|
|
|
static inline void string_list_init(struct string_list *sl)
|
|
|
|
{
|
|
|
|
INIT_LIST_HEAD(&sl->list);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void string_list_free(struct string_list *sl)
|
|
|
|
{
|
|
|
|
struct string_list *entry, *safe;
|
|
|
|
|
2012-04-19 02:34:11 +00:00
|
|
|
list_for_each_entry_safe(entry, safe, &sl->list, list) {
|
|
|
|
free(entry->str);
|
2008-03-11 20:38:22 +00:00
|
|
|
free(entry);
|
2012-04-19 02:34:11 +00:00
|
|
|
}
|
2008-03-11 20:38:22 +00:00
|
|
|
}
|
|
|
|
|
2014-06-24 10:07:00 +00:00
|
|
|
#define string_list_for_each_entry(entry, sl) \
|
|
|
|
list_for_each_entry(entry, &(sl)->list, list)
|
|
|
|
|
2013-01-08 15:13:43 +00:00
|
|
|
#endif /* __STRINGLIST_H */
|