new upstream release (3.3.0); modify package compatibility for Stretch
[ossec-hids.git] / src / headers / store_op.h
1 /* Copyright (C) 2009 Trend Micro Inc.
2  * All right reserved.
3  *
4  * This program is a free software; you can redistribute it
5  * and/or modify it under the terms of the GNU General Public
6  * License (version 2) as published by the FSF - Free Software
7  * Foundation
8  */
9
10 /* Common list API */
11
12 #ifndef _OS_STORE
13 #define _OS_STORE
14
15 /* Store node */
16 typedef struct _OSStoreNode {
17     struct _OSStoreNode *next;
18     struct _OSStoreNode *prev;
19     void *data;
20     char *key;
21     size_t key_size;
22 } OSStoreNode;
23
24 /* Store list */
25 typedef struct _OSStore {
26     OSStoreNode *first_node;
27     OSStoreNode *last_node;
28     OSStoreNode *cur_node;
29
30     int currently_size;
31     int max_size;
32
33     void (*free_data_function)(void *data);
34 } OSStore;
35
36 OSStore *OSStore_Create(void);
37 OSStore *OSStore_Free(OSStore *list) __attribute__((nonnull));
38
39 int OSStore_Put(OSStore *list, const char *key, void *data) __attribute__((nonnull(1, 2)));
40 int OSStore_Check(OSStore *list, const char *key) __attribute__((nonnull));
41 int OSStore_NCheck(OSStore *list, const char *key) __attribute__((nonnull));
42 int OSStore_NCaseCheck(OSStore *list, const char *key) __attribute__((nonnull));
43 int OSStore_GetPosition(OSStore *list, const char *key) __attribute__((nonnull));
44 void *OSStore_Get(OSStore *list, const char *key) __attribute__((nonnull));
45 OSStoreNode *OSStore_GetFirstNode(OSStore *list) __attribute__((nonnull));
46 int OSStore_Sort(OSStore *list, void *(sort_data_function)(void *d1, void *d2)) __attribute__((nonnull));
47
48 int OSStore_SetMaxSize(OSStore *list, int max_size);
49 int OSStore_SetFreeDataPointer(OSStore *list, void (free_data_function)(void *));
50
51 #endif
52