2 * FCRON - periodic command scheduler
4 * Copyright 2000-2014 Thibault Godouet <fcron@free.fr>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 * The GNU General Public License can also be found in the file
21 * `LICENSE' that comes with the fcron source distribution.
26 * 'First in first out' list of generic items
29 #ifndef __FIFO_LIST_H__
30 #define __FIFO_LIST_H__
34 #include <sys/types.h>
37 typedef void fifo_list_entry_t;
39 typedef struct fifo_list_t {
41 int max_entries; /* max allowed element number (0: no limit) */
42 int num_entries; /* READ ONLY: num of entries in the list now */
43 /* PRIVATE: DO NOT ACCESS DIRECTLY */
44 int array_size; /* size of the array (in number of entries) */
45 size_t entry_size; /* number of element currently in the array */
46 int grow_size; /* grow array by grow_size entries at a time */
47 u_list_entry_t *first_entry; /* Current entry in iteration */
48 u_list_entry_t *cur_entry; /* Current entry in iteration
49 * (null if not in iteration, i.e. X_first() has
50 * not been called or we reached the list end */
51 u_list_entry_t *entries_array; /* pointer to the actual array */
54 /* functions prototypes */
55 extern fifo_list_t *fifo_list_init(size_t entry_size, int init_size,
57 extern fifo_list_entry_t *fifo_list_add(fifo_list_t * list,
58 fifo_list_entry_t * entry);
59 extern fifo_list_entry_t *fifo_list_first(fifo_list_t * list);
60 extern fifo_list_entry_t *fifo_list_next(fifo_list_t * list);
61 extern void fifo_list_end_iteration(fifo_list_t * list);
62 extern void fifo_list_remove_first(fifo_list_t * list);
63 extern fifo_list_t *fifo_list_destroy(fifo_list_t * list);
65 #endif /* __FIFO_LIST_H__ */