Debian Codegraph @

madrisan-nagios-plugins-linux/nagios-plugins-linux/include/collection.h

raw symbols SCIP
1 // SPDX-License-Identifier: GPL-3.0-or-later
2 /* collection.h -- dictionary for counting hashable objects (strings)
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
16
17 #ifndef _COLLECTION_H_
18 #define _COLLECTION_H_
19
20 #ifdef __cplusplus
21 extern "C"
22 {
23 #endif
24
25 typedef struct hashable
26 { /* table entry: */
27 struct hashable *next; /* next element in case of a collision */
28 char *key;
29 unsigned long count;
30 } hashable_t;
31
32 typedef struct hashtable
33 {
34 unsigned int capacity; /* hashtable capacity */
35 unsigned int elements; /* number of elements stored */
36 unsigned int uniq; /* number of unique keys */
37 hashable_t **table;
38 char **keys; /* array containing the ptrs to the keys */
39 } hashtable_t;
40
41 hashtable_t *counter_create (void);
42 void counter_free (hashtable_t * hashtable);
43
44 hashable_t *counter_lookup (const hashtable_t * hashtable, const char *key);
45 hashable_t *counter_put (hashtable_t * hashtable, const char *key,
46 unsigned long increment);
47 unsigned int counter_get_elements (const hashtable_t * hashtable);
48 unsigned int counter_get_unique_elements (const hashtable_t * hashtable);
49 char **counter_keys (hashtable_t * hashtable);
50
51 #ifdef __cplusplus
52 }
53 #endif
54
55 #endif /* _COLLECTION_H_ */