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 EX_DECLARE_DATA __declspec(dllexport)
74 #else
75 #if (defined(__GNUC__) || defined(__SUNPRO_CC) || defined (__SUNPRO_C)) && defined(HAVE_VISIBILITY)
76 #define FT_DECLARE(type) __attribute__((visibility("default"))) type
77 #define FT_DECLARE_NONSTD(type) __attribute__((visibility("default"))) type
78 #define FT_DECLARE_DATA __attribute__((visibility("default")))
79 #else
80 #define FT_DECLARE(type) type
81 #define FT_DECLARE_NONSTD(type) type
82 #define FT_DECLARE_DATA
83 #endif
84 #define EX_DECLARE_DATA
85 #endif
86
87 #ifdef _MSC_VER
88 #ifndef __inline__
89 #define __inline__ __inline
90 #endif
91 #if (_MSC_VER >= 1400)
92 #ifndef _CRT_SECURE_NO_DEPRECATE
93 #define _CRT_SECURE_NO_DEPRECATE
94 #endif
95 #ifndef _CRT_NONSTDC_NO_DEPRECATE
96 #define _CRT_NONSTDC_NO_DEPRECATE
97 #endif
98 #endif
99 #ifndef strcasecmp
100 #define strcasecmp(s1, s2) _stricmp(s1, s2)
101 #endif
102 #ifndef strncasecmp
103 #define strncasecmp(s1, s2, n) _strnicmp(s1, s2, n)
104 #endif
105 #ifndef snprintf
106 #define snprintf _snprintf
107 #endif
108 #ifndef S_IRUSR
109 #define S_IRUSR _S_IREAD
110 #endif
111 #ifndef S_IWUSR
112 #define S_IWUSR _S_IWRITE
113 #endif
114 #undef HAVE_STRINGS_H
115 #undef HAVE_SYS_SOCKET_H
116
117
118 #pragma warning(disable:4706)
119 #pragma comment(lib, "Winmm")
120 #endif
121
122 #define FTDM_STR2ENUM_P(_FUNC1, _FUNC2, _TYPE) FT_DECLARE(_TYPE) _FUNC1 (const char *name); FT_DECLARE(const char *) _FUNC2 (_TYPE type);
123 #define FTDM_STR2ENUM(_FUNC1, _FUNC2, _TYPE, _STRINGS, _MAX) \
124 FT_DECLARE(_TYPE) _FUNC1 (const char *name) \
125 { \
126 int i; \
127 _TYPE t = _MAX ; \
128 \
129 for (i = 0; i < _MAX ; i++) { \
130 if (!strcasecmp(name, _STRINGS[i])) { \
131 t = (_TYPE) i; \
132 break; \
133 } \
134 } \
135 \
136 return t; \
137 } \
138 FT_DECLARE(const char *) _FUNC2 (_TYPE type) \
139 { \
140 if (type > _MAX) { \
141 type = _MAX; \
142 } \
143 return _STRINGS[(int)type]; \
144 } \
145
146 #ifdef __WINDOWS__
147 #include <stdio.h>
148 #include <windows.h>
149 #define FTDM_INVALID_SOCKET INVALID_HANDLE_VALUE
150 typedef HANDLE ftdm_socket_t;
151 typedef unsigned __int64 uint64_t;
152 typedef unsigned __int32 uint32_t;
153 typedef unsigned __int16 uint16_t;
154 typedef unsigned __int8 uint8_t;
155 typedef __int64 int64_t;
156 typedef __int32 int32_t;
157 typedef __int16 int16_t;
158 typedef __int8 int8_t;
159 #else
160 #define FTDM_INVALID_SOCKET -1
161 typedef int ftdm_socket_t;
162 #include <stdio.h>
163 #include <stdint.h>
164 #include <stdarg.h>
165 #endif
166
167
168
169
170
171 typedef struct ftdm_channel ftdm_channel_t;
172
173
174
175
176
177
178
179
180 typedef struct ftdm_span ftdm_span_t;
181
182 typedef struct ftdm_event ftdm_event_t;
183 typedef struct ftdm_conf_node ftdm_conf_node_t;
184 typedef struct ftdm_group ftdm_group_t;
185 typedef size_t ftdm_size_t;
186 typedef struct ftdm_sigmsg ftdm_sigmsg_t;
187 typedef struct ftdm_io_interface ftdm_io_interface_t;
188 typedef struct ftdm_stream_handle ftdm_stream_handle_t;
189 typedef struct ftdm_queue ftdm_queue_t;
190 typedef struct ftdm_memory_handler ftdm_memory_handler_t;
191
192 #ifdef __cplusplus
193 }
194 #endif
195
196 #endif
197
198
199
200
201
202
203
204
205
206
207