1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35 #ifndef __FTDM_DECLARE_H__
36 #define __FTDM_DECLARE_H__
37
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41
42 #if !defined(_XOPEN_SOURCE) && !defined(__FreeBSD__)
43 #define _XOPEN_SOURCE 600
44 #endif
45
46 #ifndef HAVE_STRINGS_H
47 #define HAVE_STRINGS_H 1
48 #endif
49 #ifndef HAVE_SYS_SOCKET_H
50 #define HAVE_SYS_SOCKET_H 1
51 #endif
52
53 #ifndef __WINDOWS__
54 #if defined(WIN32) || defined(WIN64) || defined(_MSC_VER) || defined(_WIN32) || defined(_WIN64)
55 #define __WINDOWS__
56 #endif
57 #endif
58
59 #ifdef _MSC_VER
60 #if defined(FT_DECLARE_STATIC)
61 #define FT_DECLARE(type) type __stdcall
62 #define FT_DECLARE_NONSTD(type) type __cdecl
63 #define FT_DECLARE_DATA
64 #elif defined(FREETDM_EXPORTS)
65 #define FT_DECLARE(type) __declspec(dllexport) type __stdcall
66 #define FT_DECLARE_NONSTD(type) __declspec(dllexport) type __cdecl
67 #define FT_DECLARE_DATA __declspec(dllexport)
68 #else
69 #define FT_DECLARE(type) __declspec(dllimport) type __stdcall
70 #define FT_DECLARE_NONSTD(type) __declspec(dllimport) type __cdecl
71 #define FT_DECLARE_DATA __declspec(dllimport)
72 #endif
73 #define FT_DECLARE_INLINE(type) extern __inline__ type
74 #define EX_DECLARE_DATA __declspec(dllexport)
75 #else
76 #if (defined(__GNUC__) || defined(__SUNPRO_CC) || defined (__SUNPRO_C)) && defined(HAVE_VISIBILITY)
77 #define FT_DECLARE(type) __attribute__((visibility("default"))) type
78 #define FT_DECLARE_NONSTD(type) __attribute__((visibility("default"))) type
79 #define FT_DECLARE_DATA __attribute__((visibility("default")))
80 #else
81 #define FT_DECLARE(type) type
82 #define FT_DECLARE_NONSTD(type) type
83 #define FT_DECLARE_DATA
84 #endif
85 #define FT_DECLARE_INLINE(type) __inline__ type
86 #define EX_DECLARE_DATA
87 #endif
88
89 #ifdef _MSC_VER
90 #ifndef __inline__
91 #define __inline__ __inline
92 #endif
93 #if (_MSC_VER >= 1400)
94 #ifndef _CRT_SECURE_NO_DEPRECATE
95 #define _CRT_SECURE_NO_DEPRECATE
96 #endif
97 #ifndef _CRT_NONSTDC_NO_DEPRECATE
98 #define _CRT_NONSTDC_NO_DEPRECATE
99 #endif
100 #endif
101 #ifndef strcasecmp
102 #define strcasecmp(s1, s2) _stricmp(s1, s2)
103 #endif
104 #ifndef strncasecmp
105 #define strncasecmp(s1, s2, n) _strnicmp(s1, s2, n)
106 #endif
107 #ifndef snprintf
108 #define snprintf _snprintf
109 #endif
110 #ifndef S_IRUSR
111 #define S_IRUSR _S_IREAD
112 #endif
113 #ifndef S_IWUSR
114 #define S_IWUSR _S_IWRITE
115 #endif
116 #undef HAVE_STRINGS_H
117 #undef HAVE_SYS_SOCKET_H
118
119
120 #pragma warning(disable:4706)
121 #pragma comment(lib, "Winmm")
122 #endif
123
124 #define FTDM_STR2ENUM_P(_FUNC1, _FUNC2, _TYPE) FT_DECLARE(_TYPE) _FUNC1 (const char *name); FT_DECLARE(const char *) _FUNC2 (_TYPE type);
125 #define FTDM_STR2ENUM(_FUNC1, _FUNC2, _TYPE, _STRINGS, _MAX) \
126 FT_DECLARE(_TYPE) _FUNC1 (const char *name) \
127 { \
128 int i; \
129 _TYPE t = _MAX ; \
130 \
131 for (i = 0; i < _MAX ; i++) { \
132 if (!strcasecmp(name, _STRINGS[i])) { \
133 t = (_TYPE) i; \
134 break; \
135 } \
136 } \
137 \
138 return t; \
139 } \
140 FT_DECLARE(const char *) _FUNC2 (_TYPE type) \
141 { \
142 if (type > _MAX) { \
143 type = _MAX; \
144 } \
145 return _STRINGS[(int)type]; \
146 } \
147
148 #ifdef __WINDOWS__
149 #include <stdio.h>
150 #include <windows.h>
151 #define FTDM_INVALID_SOCKET INVALID_HANDLE_VALUE
152 typedef HANDLE ftdm_socket_t;
153 typedef unsigned __int64 uint64_t;
154 typedef unsigned __int32 uint32_t;
155 typedef unsigned __int16 uint16_t;
156 typedef unsigned __int8 uint8_t;
157 typedef __int64 int64_t;
158 typedef __int32 int32_t;
159 typedef __int16 int16_t;
160 typedef __int8 int8_t;
161 #define FTDM_O_BINARY O_BINARY
162 #define FTDM_SIZE_FMT "Id"
163 #if defined(_MSC_VER) || defined(_MSC_EXTENSIONS)
164 #define DELTA_EPOCH_IN_MICROSECS 11644473600000000Ui64
165 #else
166 #define DELTA_EPOCH_IN_MICROSECS 11644473600000000ULL
167 #endif
168 #else
169 #define FTDM_O_BINARY 0
170 #define FTDM_SIZE_FMT "zd"
171 #define FTDM_INVALID_SOCKET -1
172 typedef int ftdm_socket_t;
173 #include <stdio.h>
174 #include <stdint.h>
175 #include <stdarg.h>
176 #endif
177
178
179 typedef enum {
180 FTDM_SUCCESS,
181 FTDM_FAIL,
182 FTDM_MEMERR,
183 FTDM_TIMEOUT,
184 FTDM_NOTIMPL,
185 FTDM_BREAK,
186
187
188
189 FTDM_ENOMEM = FTDM_MEMERR,
190 FTDM_ETIMEDOUT = FTDM_TIMEOUT,
191 FTDM_ENOSYS = FTDM_NOTIMPL,
192
193 FTDM_EINVAL,
194 FTDM_ECANCELED,
195 FTDM_EBUSY,
196 } ftdm_status_t;
197
198
199 typedef enum {
200 FTDM_FALSE,
201 FTDM_TRUE
202 } ftdm_bool_t;
203
204
205
206
207
208 typedef struct ftdm_channel ftdm_channel_t;
209
210
211
212
213
214
215
216
217 typedef struct ftdm_span ftdm_span_t;
218
219 typedef struct ftdm_event ftdm_event_t;
220 typedef struct ftdm_conf_node ftdm_conf_node_t;
221 typedef struct ftdm_group ftdm_group_t;
222 typedef size_t ftdm_size_t;
223 typedef struct ftdm_sigmsg ftdm_sigmsg_t;
224 typedef struct ftdm_io_interface ftdm_io_interface_t;
225 typedef struct ftdm_stream_handle ftdm_stream_handle_t;
226 typedef struct ftdm_queue ftdm_queue_t;
227 typedef struct ftdm_memory_handler ftdm_memory_handler_t;
228
229 #ifdef __cplusplus
230 }
231 #endif
232
233 #endif
234
235
236
237
238
239
240
241
242
243
244