X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=libeap%2Fsrc%2Futils%2Flist.h;fp=libeap%2Fsrc%2Futils%2Flist.h;h=ee2f4856950f1e9025d93595d1893e539dc667a3;hb=4f319dde67a76fe0aaf33f6d2788968012584ada;hp=ed7c0227264f879123a2e6ee1a2efacc6dfc65d3;hpb=ed09b5e64dd485851310307979d5eed14678087b;p=mech_eap.git diff --git a/libeap/src/utils/list.h b/libeap/src/utils/list.h index ed7c022..ee2f485 100644 --- a/libeap/src/utils/list.h +++ b/libeap/src/utils/list.h @@ -2,14 +2,8 @@ * Doubly-linked list * Copyright (c) 2009, Jouni Malinen * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * Alternatively, this software may be distributed under the terms of BSD - * license. - * - * See README and COPYING for more details. + * This software may be distributed under the terms of the BSD license. + * See README for more details. */ #ifndef LIST_H @@ -23,6 +17,8 @@ struct dl_list { struct dl_list *prev; }; +#define DL_LIST_HEAD_INIT(l) { &(l), &(l) } + static inline void dl_list_init(struct dl_list *list) { list->next = list; @@ -75,6 +71,10 @@ static inline unsigned int dl_list_len(struct dl_list *list) (dl_list_empty((list)) ? NULL : \ dl_list_entry((list)->next, type, member)) +#define dl_list_last(list, type, member) \ + (dl_list_empty((list)) ? NULL : \ + dl_list_entry((list)->prev, type, member)) + #define dl_list_for_each(item, list, type, member) \ for (item = dl_list_entry((list)->next, type, member); \ &item->member != (list); \ @@ -86,4 +86,12 @@ static inline unsigned int dl_list_len(struct dl_list *list) &item->member != (list); \ item = n, n = dl_list_entry(n->member.next, type, member)) +#define dl_list_for_each_reverse(item, list, type, member) \ + for (item = dl_list_entry((list)->prev, type, member); \ + &item->member != (list); \ + item = dl_list_entry(item->member.prev, type, member)) + +#define DEFINE_DL_LIST(name) \ + struct dl_list name = { &(name), &(name) } + #endif /* LIST_H */