root/src/include/ftdm_declare.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


   1 /*
   2  * Copyright (c) 2010, Sangoma Technologies
   3  * Moises Silva <moy@sangoma.com>
   4  * All rights reserved.
   5  * 
   6  * Redistribution and use in source and binary forms, with or without
   7  * modification, are permitted provided that the following conditions
   8  * are met:
   9  * 
  10  * * Redistributions of source code must retain the above copyright
  11  * notice, this list of conditions and the following disclaimer.
  12  * 
  13  * * Redistributions in binary form must reproduce the above copyright
  14  * notice, this list of conditions and the following disclaimer in the
  15  * documentation and/or other materials provided with the distribution.
  16  * 
  17  * * Neither the name of the original author; nor the names of any contributors
  18  * may be used to endorse or promote products derived from this software
  19  * without specific prior written permission.
  20  * 
  21  * 
  22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  23  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  24  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  25  * A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER
  26  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  27  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  28  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  29  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  30  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  31  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  32  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  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)                  /* VC8+ */
  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 /* disable warning for zero length array in a struct */
 117 /* this will cause errors on c99 and ansi compliant compilers and will need to be fixed in the wanpipe header files */
 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  * \brief FreeTDM channel.
 169  *        This is the basic data structure used to place calls and I/O operations
 170  */
 171 typedef struct ftdm_channel ftdm_channel_t;
 172 
 173 /*! 
 174  * \brief FreeTDM span.
 175  *        Channel and signaling configuration container.
 176  *        This is a logical span structure, a span may ( or may note ) contain channels
 177  *        of other physical spans, depending on configuration (freetdm.conf) or if you
 178  *        are not using configuration depends on how you call ftdm_span_add_channel
 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 } /* extern C */
 194 #endif
 195 
 196 #endif
 197 
 198 /* For Emacs:
 199  * Local Variables:
 200  * mode:c
 201  * indent-tabs-mode:t
 202  * tab-width:4
 203  * c-basic-offset:4
 204  * End:
 205  * For VIM:
 206  * vim:set softtabstop=4 shiftwidth=4 tabstop=4:
 207  */

/* [<][>][^][v][top][bottom][index][help] */