* Copyright (C) 1996-2000 Michael R. Elkins <me@mutt.org>
*/
-#ifndef _MUTT_LIST_H
-#define _MUTT_LIST_H
+#ifndef MUTT_LIB_LIB_LIST_H
+#define MUTT_LIB_LIB_LIST_H
+
+#include "str.h"
typedef struct list_t {
char *data;
return mutt_add_list_n(head, data, len ? len + 1 : 0);
}
-#endif /* !_MUTT_LIST_H */
+#define DO_SLIST(type, prefix) \
+ static inline type *prefix##_list_pop(type **list) { \
+ if (*list) { \
+ type *res = *list; \
+ *list = res->next; \
+ res->next = NULL; \
+ return res; \
+ } \
+ return NULL; \
+ } \
+ static inline void prefix##_list_push(type **list, type *item) { \
+ item->next = *list; \
+ *list = item; \
+ } \
+ \
+ static inline type **prefix##_list_last(type **list) { \
+ while (*list) { \
+ list = &(*list)->next; \
+ } \
+ return list; \
+ } \
+ \
+ static inline type **prefix##_list_append(type **list, type *item) { \
+ list = prefix##_list_last(list); \
+ *list = item; \
+ return list; \
+ } \
+ \
+ static inline type **prefix##_list_init(type **list) { \
+ *list = NULL; \
+ return list; \
+ } \
+ static inline void prefix##_list_wipe(type **list, int del) { \
+ if (del) { \
+ while (*list) { \
+ type *item = prefix##_list_pop(list); \
+ prefix##_delete(&item); \
+ } \
+ } else { \
+ *list = NULL; \
+ } \
+ } \
+
+
+
+
+
+#endif /* MUTT_LIB_LIB_LIST_H */