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 License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 *
19 * Authors:
20 * Florian Forster <octo at verplant.org>
21 */
23 #ifndef UTILS_LLIST_H
24 #define UTILS_LLIST_H 1
26 /*
27 * Data types
28 */
29 struct llentry_s
30 {
31 char *key;
32 void *value;
33 struct llentry_s *next;
34 };
35 typedef struct llentry_s llentry_t;
37 struct llist_s;
38 typedef struct llist_s llist_t;
40 /*
41 * Functions
42 */
43 llist_t *llist_create (void);
44 void llist_destroy (llist_t *l);
46 llentry_t *llentry_create (char *key, void *value);
47 void llentry_destroy (llentry_t *e);
49 void llist_append (llist_t *l, llentry_t *e);
50 void llist_prepend (llist_t *l, llentry_t *e);
51 void llist_remove (llist_t *l, llentry_t *e);
53 int llist_size (llist_t *l);
55 llentry_t *llist_search (llist_t *l, const char *key);
56 llentry_t *llist_search_custom (llist_t *l,
57 int (*compare) (llentry_t *, void *), void *user_data);
59 llentry_t *llist_head (llist_t *l);
60 llentry_t *llist_tail (llist_t *l);
62 #endif /* UTILS_LLIST_H */