libosip 3.6.0

osip_fifo.h

Go to the documentation of this file.
00001 /*
00002   The oSIP library implements the Session Initiation Protocol (SIP -rfc3261-)
00003   Copyright (C) 2001,2002,2003,2004,2005,2006,2007 Aymeric MOIZARD jack@atosc.org
00004   
00005   This library is free software; you can redistribute it and/or
00006   modify it under the terms of the GNU Lesser General Public
00007   License as published by the Free Software Foundation; either
00008   version 2.1 of the License, or (at your option) any later version.
00009   
00010   This library is distributed in the hope that it will be useful,
00011   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013   Lesser General Public License for more details.
00014   
00015   You should have received a copy of the GNU Lesser General Public
00016   License along with this library; if not, write to the Free Software
00017   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 */
00019 
00020 #ifndef _FIFO_H_
00021 #define _FIFO_H_
00022 
00023 #ifdef OSIP_MT
00024 #include <osip2/osip_mt.h>
00025 #endif
00026 #include <osipparser2/osip_list.h>
00027 
00042 #ifdef __cplusplus
00043 extern "C" {
00044 #endif
00045 
00046 
00047 #ifndef DOXYGEN
00048 
00049 #define MAX_LEN 1000
00050         typedef enum { osip_ok, osip_full, osip_empty } osip_fifo_state;
00051 
00052 #endif
00053 
00058         typedef struct osip_fifo osip_fifo_t;
00059 
00064         struct osip_fifo {
00065 #ifdef OSIP_MT
00066                 struct osip_mutex *qislocked;
00068                 struct osip_sem *qisempty; 
00069 #endif
00070                 osip_list_t queue;                 
00071                 int nb_elt;                                
00072                 osip_fifo_state state;           
00073         };
00074 
00084         void osip_fifo_init(osip_fifo_t * ff);
00089         void osip_fifo_free(osip_fifo_t * ff);
00095         int osip_fifo_insert(osip_fifo_t * ff, void *element);
00101         int osip_fifo_add(osip_fifo_t * ff, void *element);
00106         int osip_fifo_size(osip_fifo_t * ff);
00107 #ifdef OSIP_MT
00108 
00112         void *osip_fifo_get(osip_fifo_t * ff);
00113 #endif
00114 
00118         void *osip_fifo_tryget(osip_fifo_t * ff);
00119 
00120 
00124 #ifdef __cplusplus
00125 }
00126 #endif
00127 #endif