manager can query and list IKE_SA status (no layout yet)
[strongswan.git] / src / manager / lib / dict.h
1 /**
2 * @file dict.h
3 *
4 * @brief Interface of dict_t.
5 *
6 */
7
8 /*
9 * Copyright (C) 2007 Martin Willi
10 * Hochschule fuer Technik Rapperswil
11 *
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 * for more details.
21 */
22
23 #ifndef DICT_H_
24 #define DICT_H_
25
26 #include <library.h>
27
28 typedef struct dict_t dict_t;
29
30 /**
31 * @brief Dictionary type, key value stuff.
32 */
33 struct dict_t {
34
35 /**
36 * @brief Set a value in the dict.
37 *
38 * @param key key to set
39 * @param value value, NULL to unset key
40 * @return
41 */
42 void (*set)(dict_t *this, void *key, void *value);
43
44 /**
45 * @brief Get a value form the dict.
46 *
47 * @param key key to get value of
48 * @return assigned value, NULL if not found
49 */
50 void* (*get)(dict_t *this, void *key);
51
52 /**
53 * @brief Destroy a dict instance.
54 */
55 void (*destroy)(dict_t *this);
56 };
57
58 /**
59 * @brief Key comparator function for strings
60 */
61 bool dict_streq(void *a, void *b);
62
63 /**
64 * @brief Create a dict instance.
65 *
66 * @param free_key TRUE to free() keys on destruction
67 * @param
68 */
69 dict_t *dict_create(bool(*key_comparator)(void*,void*),
70 void(*key_destructor)(void*),
71 void(*value_destructor)(void*));
72
73 #endif /* DICT_H_ */