Revert "Revert "and added files""
[bcm963xx.git] / userapps / opensource / libosip2 / include / osipparser2 / osip_list.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
21 #ifndef _LIST_H_
22 #define _LIST_H_
23
24 #ifdef ENABLE_MPATROL
25 #include <mpatrol.h>
26 #endif
27
28 /**
29  * @file osip_list.h
30  * @brief oSIP list Routines
31  *
32  * This is a very simple implementation of a linked list.
33  * <BR>There is not much to say about it... Except that it
34  * could be a lot improved. Sadly, it would be difficult
35  * to improve it without breaking the compatibility with
36  * older version!
37  */
38
39 /**
40  * @defgroup oSIP_LIST oSIP list Handling
41  * @ingroup oSIP
42  * @{
43  */
44
45 #ifdef __cplusplus
46 extern "C"
47 {
48 #endif
49
50 #ifndef DOXYGEN
51 /**
52  * Structure for referencing a node in a osip_list_t element.
53  * @defvar __node_t
54  */
55   typedef struct __node __node_t;
56
57   struct __node
58   {
59     void *next;                 /* next __node_t */
60     void *element;
61   };
62 #endif
63
64 /**
65  * Structure for referencing a list of elements.
66  * @defvar osip_list_t
67  */
68   typedef struct osip_list osip_list_t;
69
70   struct osip_list
71   {
72
73     int nb_elt;
74     __node_t *node;
75
76   };
77
78 /**
79  * Initialise a osip_list_t element.
80  * NOTE: this element MUST be previously allocated.
81  * @param li The element to initialise.
82  */
83   int osip_list_init (osip_list_t * li);
84 /**
85  * Free a list of element.
86  * Each element will be free with the method given as the second parameter.
87  * @param li The element to work on.
88  * @param free_func The method that is able to release one element of the list.
89  */
90   void osip_list_special_free (osip_list_t * li, void *(*free_func) (void *));
91 /**
92  * Free a list of element where elements are pointer to 'char'.
93  * @param li The element to work on.
94  */
95   void osip_list_ofchar_free (osip_list_t * li);
96 /**
97  * Get the size of a list of element.
98  * @param li The element to work on.
99  */
100   int osip_list_size (const osip_list_t * li);
101 /**
102  * Check if the end of list is detected .
103  * @param li The element to work on.
104  * @param pos The index of the possible element.
105  */
106   int osip_list_eol (const osip_list_t * li, int pos);
107 /**
108  * Add an element in a list.
109  * @param li The element to work on.
110  * @param element The pointer on the element to add.
111  * @param pos the index of the element to add. (or -1 to append the element at the end)
112  */
113   int osip_list_add (osip_list_t * li, void *element, int pos);
114 /**
115  * Get an element from a list.
116  * @param li The element to work on.
117  * @param pos the index of the element to get.
118  */
119   void *osip_list_get (const osip_list_t * li, int pos);
120 /**
121  * Remove an element from a list.
122  * @param li The element to work on.
123  * @param pos the index of the element to remove.
124  */
125   int osip_list_remove (osip_list_t * li, int pos);
126
127
128 #ifdef __cplusplus
129 }
130 #endif
131
132
133 /** @} */
134
135 #endif