and added files
[bcm963xx.git] / userapps / opensource / libosip2 / include / osip2 / osip_fifo.h
1 /*
2   The oSIP library implements the Session Initiation Protocol (SIP -rfc2543-)
3   Copyright (C) 2001  Aymeric MOIZARD jack@atosc.org
4   
5   This library is free software; you can redistribute it and/or
6   modify it under the terms of the GNU Lesser General Public
7   License as published by the Free Software Foundation; either
8   version 2.1 of the License, or (at your option) any later version.
9   
10   This library is distributed in the hope that it will be useful,
11   but WITHOUT ANY WARRANTY; without even the implied warranty of
12   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13   Lesser General Public License for more details.
14   
15   You should have received a copy of the GNU Lesser General Public
16   License along with this library; if not, write to the Free Software
17   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18 */
19
20 #ifndef _FIFO_H_
21 #define _FIFO_H_
22
23 #ifdef OSIP_MT
24 #include <osip2/osip_mt.h>
25 #endif
26 #include <osipparser2/osip_list.h>
27
28 /**
29  * @file osip_fifo.h
30  * @brief oSIP fifo Routines
31  *
32  * This is a very simple implementation of a fifo.
33  * <BR>There is not much to say about it...
34  */
35
36 /**
37  * @defgroup oSIP_FIFO oSIP fifo Handling
38  * @ingroup oSIP
39  * @{
40  */
41
42 #ifdef __cplusplus
43 extern "C"
44 {
45 #endif
46
47
48 #ifndef DOXYGEN
49
50 #define MAX_LEN 1000
51   typedef enum
52   { ok, plein, vide }
53   osip_fifo_etat;
54
55 #endif
56
57 /**
58  * Structure for referencing a fifo.
59  * @defvar osip_fifo_t
60  */
61   typedef struct osip_fifo osip_fifo_t;
62
63   struct osip_fifo
64   {
65 #ifdef OSIP_MT
66     struct osip_mutex *qislocked;
67     struct osip_sem *qisempty;
68 #endif
69     osip_list_t *queue;
70     int nb_elt;
71     osip_fifo_etat etat;
72   };
73
74 /**
75  * Initialise a osip_fifo_t element.
76  * NOTE: this element MUST be previously allocated.
77  * @param ff The element to initialise.
78  */
79   void osip_fifo_init (osip_fifo_t * ff);
80 /**
81  * Free a fifo element.
82  * @param ff The element to work on.
83  */
84   void osip_fifo_free (osip_fifo_t * ff);
85 /**
86  * Insert an element in a fifo (at the beginning).
87  * @param ff The element to work on.
88  * @param element The pointer on the element to insert.
89  */
90   int osip_fifo_insert (osip_fifo_t * ff, void *element);
91 /**
92  * Add an element in a fifo.
93  * @param ff The element to work on.
94  * @param element The pointer on the element to add.
95  */
96   int osip_fifo_add (osip_fifo_t * ff, void *element);
97 /**
98  * Get the number of element in a fifo.
99  * @param ff The element to work on.
100  */
101   int osip_fifo_size (osip_fifo_t * ff);
102 #ifdef OSIP_MT
103 /**
104  * Get an element from a fifo or block until one is added.
105  * @param ff The element to work on.
106  */
107   void *osip_fifo_get (osip_fifo_t * ff);
108 #endif
109 /**
110  * Try to get an element from a fifo, but do not block if there is no element.
111  * @param ff The element to work on.
112  */
113   void *osip_fifo_tryget (osip_fifo_t * ff);
114
115
116 /** @} */
117
118
119 #ifdef __cplusplus
120 }
121 #endif
122
123
124 #endif