2
* Copyright (C) 2000-2006 SWsoft. All rights reserved.
2
* Copyright (C) 2000-2007 SWsoft. All rights reserved.
4
4
* This program is free software; you can redistribute it and/or modify
5
5
* it under the terms of the GNU General Public License as published by
25
struct list_elem *prev, *next;
28
typedef struct list_elem {
29
struct list_elem *prev, *next;
24
struct list_head *prev, *next;
26
typedef struct list_head list_head_t;
27
typedef struct list_head list_elem_t;
32
29
struct str_struct {
51
48
static inline void list_add(list_elem_t *new, list_head_t *list)
53
50
new->next = list->next;
54
new->prev = (list_elem_t *)list;
55
52
list->next->prev = new;
59
56
static inline void list_add_tail(list_elem_t *new, list_head_t *list)
61
new->next = (list_elem_t *)list;
62
59
new->prev = list->prev;
63
60
list->prev->next = new;
112
109
#define list_for_each(entry, head, field) \
113
110
for (entry = list_entry((head)->next, typeof(*entry), field);\
114
&entry->field != (list_elem_t*)(head); \
111
&entry->field != (head); \
115
112
entry = list_entry(entry->field.next, typeof(*entry), field))
117
114
#define list_for_each_prev(entry, head, field) \
118
115
for (entry = list_entry((head)->prev, typeof(*entry), field);\
119
&entry->field != (list_elem_t*)(head); \
116
&entry->field != (head); \
120
117
entry = list_entry(entry->field.prev, typeof(*entry), field))
122
119
#define list_for_each_safe(entry, tmp, head, field) \
123
120
for (entry = list_entry((head)->next, typeof(*entry), field),\
124
121
tmp = list_entry(entry->field.next, typeof(*entry), field); \
125
&entry->field != (list_elem_t*)(head); \
122
&entry->field != (head); \
127
tmp = list_entry(tmp->field.next, typeof(*tmp), field))
124
tmp = list_entry(tmp->field.next, typeof(*tmp), field))
130
127
char *list2str_c(char *name, char c, list_head_t *head);
137
134
int copy_str_param(list_head_t *dst, list_head_t *src);
138
135
char *find_str(list_head_t *head, const char *val);
139
136
int merge_str_list(int delall, list_head_t *old, list_head_t *add,
140
list_head_t *del, list_head_t *merged);
137
list_head_t *del, list_head_t *merged);
141
138
int list_size(list_head_t *head);
142
139
#endif /* _LIST_H_ */