source: branches/samhain-2_2-branch/include/sh_fifo.h@ 434

Last change on this file since 434 was 1, checked in by katerina, 19 years ago

Initial import

File size: 1.4 KB
Line 
1
2#ifndef SH_FIFO_H
3#define SH_FIFO_H
4
5/*****************************************************
6 *
7 * the maximum number of entries the fifo will hold
8 * - additional entries are simply not accepted -
9 *
10 *****************************************************/
11
12#define SH_FIFO_MAX 128
13
14/*****************************************************
15 *
16 * the type definitions for the fifo
17 *
18 *****************************************************/
19
20struct dlist {
21 struct dlist * next;
22 char * data;
23 struct dlist * prev;
24};
25
26typedef struct fifo_str {
27 struct dlist * head_ptr;
28 struct dlist * tail_ptr;
29 int fifo_cts;
30} SH_FIFO;
31
32/*****************************************************
33 *
34 * fifo functions
35 *
36 *****************************************************/
37
38/* Initialize the list.
39 *
40 */
41#define fifo_init(fifo_p) { fifo_p->fifo_cts = 0; fifo_p->head_ptr = NULL; \
42 fifo_p->tail_ptr = NULL; }
43
44
45/* Push an item on the head of the list.
46 *
47 * Returns: -1 if the list is full, 0 on success
48 */
49int push_list (SH_FIFO * fifo, char * indat);
50
51/* Push an item on the tail of the list.
52 *
53 * Returns: -1 if the list is full, 0 on success
54 */
55int push_tail_list (SH_FIFO * fifo, char * indat);
56
57/* pop an item from the tail of the list
58 *
59 * Returns: NULL if the list is empty,
60 * freshly allocated memory on success (should be free'd by caller)
61 */
62char * pop_list (SH_FIFO * fifo);
63
64#endif
Note: See TracBrowser for help on using the repository browser.