Updates from the list to 1.7.2 Release Notes
[git/wpalmer.git] / string-list.h
blob680d600d16c095eb167be2eca8c1a7cb94f962af
1 #ifndef STRING_LIST_H
2 #define STRING_LIST_H
4 struct string_list_item {
5 char *string;
6 void *util;
7 };
8 struct string_list
10 struct string_list_item *items;
11 unsigned int nr, alloc;
12 unsigned int strdup_strings:1;
15 void print_string_list(const struct string_list *p, const char *text);
16 void string_list_clear(struct string_list *list, int free_util);
18 /* Use this function to call a custom clear function on each util pointer */
19 /* The string associated with the util pointer is passed as the second argument */
20 typedef void (*string_list_clear_func_t)(void *p, const char *str);
21 void string_list_clear_func(struct string_list *list, string_list_clear_func_t clearfunc);
23 /* Use this function to iterate over each item */
24 typedef int (*string_list_each_func_t)(struct string_list_item *, void *);
25 int for_each_string_list(struct string_list *list,
26 string_list_each_func_t, void *cb_data);
28 /* Use these functions only on sorted lists: */
29 int string_list_has_string(const struct string_list *list, const char *string);
30 int string_list_find_insert_index(const struct string_list *list, const char *string,
31 int negative_existing_index);
32 struct string_list_item *string_list_insert(struct string_list *list, const char *string);
33 struct string_list_item *string_list_insert_at_index(struct string_list *list,
34 int insert_at, const char *string);
35 struct string_list_item *string_list_lookup(struct string_list *list, const char *string);
37 /* Use these functions only on unsorted lists: */
38 struct string_list_item *string_list_append(struct string_list *list, const char *string);
39 void sort_string_list(struct string_list *list);
40 int unsorted_string_list_has_string(struct string_list *list, const char *string);
41 struct string_list_item *unsorted_string_list_lookup(struct string_list *list,
42 const char *string);
43 #endif /* STRING_LIST_H */