00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
#ifndef __LIST_H
00018
#define __LIST_H
00019
00020
00021
00030
00031
00032
#define list_next(n) ((n) ? (n)->next : NULL)
00033
#define list_prev(n) ((n) ? (n)->prev : NULL)
00034
00035
00036
00044 typedef int (*
CompareFunc) (
void *a,
void *b);
00045
00049 typedef struct listlink
00050 {
00051 void *
data;
00053 struct listlink *
prev;
00054 struct listlink *
next;
00055 }
List;
00056
00057
00058
00059 EXTERN_C_BEGIN
00060
00061
00062
00069 typedef int (*ListForeachFunc) (
void *data,
void *udata);
00070
#define LIST_FOREACH(func) ((ListForeachFunc)func)
00071
00072
00073
00077 LIBGIFT_EXPORT
00078
List *list_append (
List *head,
void *udata);
00079
00080
#if 0
00081
00086 LIBGIFT_EXPORT
00087
List *list_append_link (
List *head,
List *link);
00088
#endif
00089
00093 LIBGIFT_EXPORT
00094
List *list_prepend (
List *head,
void *udata);
00095
00096
#if 0
00097
00100 LIBGIFT_EXPORT
00101
List *list_prepend_link (
List *head,
List *link);
00102
#endif
00103
00104
00105
00110 LIBGIFT_EXPORT
00111
List *list_insert (
List *head,
int nth,
void *udata);
00112
00117 LIBGIFT_EXPORT
00118
List *list_insert_sorted (
List *head, CompareFunc func,
void *udata);
00119
00120
00121
00126 LIBGIFT_EXPORT
00127
List *list_remove (
List *head,
void *udata);
00128
00133 LIBGIFT_EXPORT
00134
List *list_remove_link (
List *head,
List *link);
00135
00136
#if 0
00137
00141 LIBGIFT_EXPORT
00142
List *list_unlink_link (
List *head,
List *link);
00143
#endif
00144
00145
00146
00153 LIBGIFT_EXPORT
00154
List *list_free (
List *head);
00155
00156
00157
00162 LIBGIFT_EXPORT
00163
List *list_find (
List *head,
void *udata);
00164
00170 LIBGIFT_EXPORT
00171
List *list_find_custom (
List *head,
void *udata, CompareFunc func);
00172
00173
00174
00179 LIBGIFT_EXPORT
00180
void list_foreach (
List *head, ListForeachFunc func,
void *udata);
00181
00188 LIBGIFT_EXPORT
00189
List *list_foreach_remove (
List *head, ListForeachFunc func,
void *udata);
00190
00191
00192
00196 LIBGIFT_EXPORT
00197
List *list_nth (
List *head,
int nth);
00198
00203 LIBGIFT_EXPORT
00204
void *list_nth_data (
List *head,
int nth);
00205
00210 LIBGIFT_EXPORT
00211
List *list_last (
List *head);
00212
00213
00214
00218 LIBGIFT_EXPORT
00219
int list_length (
List *head);
00220
00226 LIBGIFT_EXPORT
00227
List *list_sort (
List *head, CompareFunc func);
00228
00233 LIBGIFT_EXPORT
00234
List *list_copy (
List *head);
00235
00236
00237
00238 EXTERN_C_END
00239
00240
00241
00242
#endif