new upstream release (3.3.0); modify package compatibility for Stretch
[ossec-hids.git] / src / headers / list_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_LIST
13 #define _OS_LIST
14
15 typedef struct _OSListNode {
16     struct _OSListNode *next;
17     struct _OSListNode *prev;
18     void *data;
19 } OSListNode;
20
21 typedef struct _OSList {
22     OSListNode *first_node;
23     OSListNode *last_node;
24     OSListNode *cur_node;
25
26     int currently_size;
27     int max_size;
28
29     void (*free_data_function)(void *data);
30 } OSList;
31
32 OSList *OSList_Create(void);
33
34 int OSList_SetMaxSize(OSList *list, int max_size);
35 int OSList_SetFreeDataPointer(OSList *list, void (free_data_function)(void *));
36
37 OSListNode *OSList_GetFirstNode(OSList *) __attribute__((nonnull));
38 OSListNode *OSList_GetLastNode(OSList *) __attribute__((nonnull));
39 OSListNode *OSList_GetPrevNode(OSList *) __attribute__((nonnull));
40 OSListNode *OSList_GetNextNode(OSList *) __attribute__((nonnull));
41 OSListNode *OSList_GetCurrentlyNode(OSList *list) __attribute__((nonnull));
42
43 void OSList_DeleteCurrentlyNode(OSList *list) __attribute__((nonnull));
44 void OSList_DeleteThisNode(OSList *list, OSListNode *thisnode) __attribute__((nonnull(1)));
45 void OSList_DeleteOldestNode(OSList *list) __attribute__((nonnull));
46
47 int OSList_AddData(OSList *list, void *data) __attribute__((nonnull(1)));
48
49 #endif
50