and added files
[bcm963xx.git] / userapps / opensource / libosip2 / include / osip2 / internal.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 #include <osipparser2/osip_port.h>
22
23 #ifndef _INTERNAL_H_
24 #define _INTERNAL_H_
25
26 /**
27  * Structure for payload management. Each payload element
28  * represents one codec of a media line.
29  * @defvar __payload_t
30  */
31 typedef struct __payload __payload_t;
32
33 struct __payload
34 {
35   char *payload;
36   /*  char *port; this must be assigned by the application dynamicly */
37   char *number_of_port;
38   char *proto;
39   char *c_nettype;
40   char *c_addrtype;
41   char *c_addr;
42   char *c_addr_multicast_ttl;
43   char *c_addr_multicast_int;
44   /* rtpmap (rcvonly and other attributes are added dynamicly) */
45   char *a_rtpmap;
46 };
47
48
49 /**
50  * Allocate a payload element.
51  * @param payload The payload.
52  */
53 int __payload_init (__payload_t ** payload);
54 /**
55  * Free a payload element.
56  * @param payload The payload.
57  */
58 void __payload_free (__payload_t * payload);
59
60
61 #ifdef OSIP_MT
62
63 /* Thread abstraction layer definition */
64
65 #ifdef __VXWORKS_OS__
66 #include <taskLib.h>
67 #endif
68
69 #if defined(WIN32) || defined(_WIN32_WCE)
70
71 #include <windows.h>
72 #endif
73
74 #if !defined(WIN32) && !defined(_WIN32_WCE) && defined(__PSOS__)
75 #include <psos.h>
76 #endif
77
78 /* HAVE_PTHREAD_H is not used any more! I keep it for a while... */
79 #if defined(HAVE_PTHREAD) || defined(HAVE_PTHREAD_H) || defined(HAVE_PTH_PTHREAD_H)
80 #include <pthread.h>
81 typedef pthread_mutex_t osip_mutex_t;
82 #endif
83
84 #ifdef __VXWORKS_OS__
85 typedef
86 {
87   int id;
88 }
89 osip_thread_t;
90 #endif
91
92 #if defined(WIN32) || defined(_WIN32_WCE)
93 typedef struct
94 {
95   HANDLE h;
96   unsigned id;
97 }
98 osip_thread_t;
99
100 #elif defined(__PSOS__)
101 typedef struct
102 {
103   unsigned long tid;
104 }
105 osip_thread_t;
106 #endif
107
108 #if !defined(WIN32) && !defined(_WIN32_WCE) && !defined(__VXWORKS_OS__) && !defined(__POS__)
109 #if defined(HAVE_PTHREAD) || defined(HAVE_PTHREAD_H) || defined(HAVE_PTH_PTHREAD_H)
110 typedef pthread_t osip_thread_t;
111 #else
112 #error no thread implementation found!
113 #endif
114 #endif
115
116
117 /* Semaphore and Mutex abstraction layer definition */
118
119 #if defined(WIN32) || defined(_WIN32_WCE)
120 #include <windows.h>
121 typedef struct
122 {
123   HANDLE h;
124 }
125 osip_mutex_t;
126 typedef struct
127 {
128   HANDLE h;
129 }
130 osip_sem_t;
131 #endif
132
133 #if (!(defined(WIN32) || defined (_WIN32_WCE)) && defined(__PSOS__))
134 #include <Types.h>
135 #include <os.h>
136 typedef struct
137 {
138   UInt32 id;
139 }
140 osip_mutex_t;
141 typedef struct
142 {
143   UInt32 id;
144 }
145 osip_sem_t;
146 #endif
147
148 #ifdef __VXWORKS_OS__
149 #include <semaphore.h>
150 #include <semLib.h>
151 typedef struct semaphore osip_mutex_t;
152 typedef sem_t osip_sem_t;
153 #endif
154
155 #ifdef __sun__
156 #include <semaphore.h>
157 #undef getdate
158 #include <synch.h>
159 #endif
160
161
162 #if defined(HAVE_SEMAPHORE_H) && !defined(__APPLE_CC__)
163 #include <semaphore.h>
164 #ifdef __sun__
165 #undef getdate
166 #include <synch.h>
167 #endif
168 /**
169  * Structure for referencing a semaphore element.
170  * @defvar osip_sem_t
171  */
172 typedef sem_t osip_sem_t;
173
174 #elif defined(HAVE_SYS_SEM_H)
175 #include <sys/types.h>
176 #include <sys/ipc.h>
177 #include <sys/sem.h>
178 typedef struct
179 {
180   int semid;
181 }
182 osip_sem_t;
183 #endif
184
185 #if (!defined(HAVE_SEMAPHORE_H) && !defined(HAVE_SYS_SEM_H) && !defined(WIN32) && !defined(_WIN32_WCE) && !defined(__PSOS__) && !defined(__VXWORKS_OS__))
186 #error No semaphore implementation found
187 #endif
188
189 #if defined(__PSOS__) || defined(__VXWORKS_OS__)
190
191 /* TODO */
192
193 #else
194
195 /**
196  * Structure for referencing a condition variable element.
197  * @defvar struct osip_cond
198  */
199 #if defined(HAVE_PTHREAD) || defined(HAVE_PTH_PTHREAD_H)
200 typedef struct osip_cond
201 {
202   pthread_cond_t cv;
203 } osip_cond_t;
204
205 #endif
206
207 #ifdef WIN32
208 typedef struct osip_cond
209 {
210   struct osip_mutex *mut;
211   struct osip_sem *sem;
212 } osip_cond_t;
213 #endif
214
215 #endif
216
217 #endif
218
219 #endif