19d8d947bd66b94acead4079856a558107186f13
[collectd.git] / src / utils_llist.h
1 /**
2  * collectd - src/utils_llist.h
3  * Copyright (C) 2006 Florian Forster <octo at verplant.org>
4  *
5  * This program is free software; you can redistribute it and/
6  * or modify it under the terms of the GNU General Public Li-
7  * cence as published by the Free Software Foundation; only
8  * version 2 of the Licence is applicable.
9  *
10  * This program is distributed in the hope that it will be use-
11  * ful, but WITHOUT ANY WARRANTY; without even the implied war-
12  * ranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13  * See the GNU General Public Licence for more details.
14  *
15  * You should have received a copy of the GNU General Public
16  * Licence along with this program; if not, write to the Free
17  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
18  * USA.
19  *
20  * Authors:
21  *   Florian Forster <octo at verplant.org>
22  */
23
24 #ifndef UTILS_LLIST_H
25 #define UTILS_LLIST_H 1
26
27 /*
28  * Data types
29  */
30 struct llentry_s
31 {
32         char *key;
33         void *value;
34         struct llentry_s *next;
35 };
36 typedef struct llentry_s llentry_t;
37
38 struct llist_s;
39 typedef struct llist_s llist_t;
40
41 /*
42  * Functions
43  */
44 llist_t *llist_create (void);
45 void llist_destroy (llist_t *l);
46
47 llentry_t *llentry_create (char *key, void *value);
48 void llentry_destroy (llentry_t *e);
49
50 void llist_append (llist_t *l, llentry_t *e);
51 void llist_prepend (llist_t *l, llentry_t *e);
52 void llist_remove (llist_t *l, llentry_t *e);
53
54 int llist_size (llist_t *l);
55
56 llentry_t *llist_search (llist_t *l, const char *key);
57 llentry_t *llist_search_custom (llist_t *l,
58                 int (*compare) (llentry_t *, void *), void *user_data);
59
60 llentry_t *llist_head (llist_t *l);
61 llentry_t *llist_tail (llist_t *l);
62
63 #endif /* UTILS_LLIST_H */