sipxportlib  Version 3.3
OsDefs.h
Go to the documentation of this file.
1 /*
2 //
3 //
4 // Copyright (C) 2005-2017 SIPez LLC.
5 //
6 // Copyright (C) 2004-2009 SIPfoundry Inc.
7 // Licensed by SIPfoundry under the LGPL license.
8 //
9 // Copyright (C) 2004-2006 Pingtel Corp. All rights reserved.
10 // Licensed to SIPfoundry under a Contributor Agreement.
11 //
12 // $$
14 */
15 
16 /* NOTE THIS FILE MUST BE INCLUDABLE IN C CODE as well as C++ */
17 /* USE C Style comments */
18 
19 #ifndef _OsDefs_h_
20 #define _OsDefs_h_
21 
22 /* SYSTEM INCLUDES */
23 /* APPLICATION INCLUDES */
24 #include <os/OsIntTypes.h>
25 
26 #ifdef _VXWORKS
27 # include "os/Vxw/OsVxwDefs.h"
28 #endif /* _VXWORKS */
29 #ifdef __pingtel_on_posix__
30 # include "os/linux/OsLinuxDefs.h"
31 #endif /* __pingtel_on_posix__ */
32 
33 /* MACROS */
34 #if defined(_VXWORKS)
35  /* wdn - OK == 0 defined in vxWorks.h but has issues ??? */
36 # define IS_INET_RETURN_OK( x ) (x == 0)
37 #else
38 # define IS_INET_RETURN_OK( x ) (x > 0)
39 #endif
40 
41 /*
42 * S_IREAD and S_IWRITE are not always defined, e.g. they're not
43 * defined in bionic (Android's libc).
44 */
45 #ifdef DEFINE_S_IREAD_IWRITE
46 # define S_IREAD (S_IRUSR | S_IRGRP | S_IROTH)
47 # define S_IWRITE (S_IWUSR)
48 #endif
49 
50 // O_BINARY is needed for WIN32, but is not defined under VxWorks and Linux
51 #ifdef __pingtel_on_posix__
52 # define O_BINARY 0
53 #endif
54 
55 /*
56 * If we're compiling for windows using a visual studio prior to VS2008
57 * http:*www.casabasecurity.com/content/visual-studio-2008-crt-bug
58 * Basically, prior versions of Visual Studio did not define snprintf
59 * or vsnprintf, because they were not ANSI compliant.
60 * Even now, with VS2008, they aren't compliant, however visual studio
61 * has gone about and defined vsnprintf.
62 * http:*connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=101293
63 */
64 #if defined(WIN32) && defined(_MSC_VER)
65 
66 #if (_MSC_VER < 1900)
67 # define snprintf _snprintf
68 #endif
69 
70 #if (_MSC_VER < 1500)
71 # define vsnprintf _vsnprintf
72 #endif
73 
74 #define popen _popen
75 #define pclose _pclose
76 /*
77 * WIN32 doesn't have wait(), so the return value for children
78 * is simply the return value specified by the child, without
79 * any additional information on whether the child terminated
80 * on its own or via a signal. These macros are also used
81 * to interpret the return value of system().
82 */
83 #define WEXITSTATUS(w) (w)
84 #define WIFEXITED(w) (true)
85 #define WIFSIGNALED(w) (false)
86 #define WTERMSIG(w) (0)
87 #endif
88 
89 #if defined(va_copy)
90 #elif defined(__va_copy)
91 # define va_copy(dst, src) __va_copy((dst), (src))
92 #else
93 //# define va_copy(dst, src) (memcpy(&(dst), &(src), sizeof (va_list)))
94 # define va_copy(dst, src) ((dst) = (src))
95 #endif
96 
97 
98 
99 /*
100  * Handle the case-insensitive string comparison functions, by making
101  * the Posix names strcasecmp and strncasecmp available on all platforms.
102  * (On newer Windows environments, str(n)casecmp are built-in, along
103  * with the older str(n)icmp, but on older ones, they are not.)
104  */
105 #ifdef WIN32
106  /* if wince, or win and >= msvc8(vs2005) */
107 # if defined(WINCE) || (defined(_MSC_VER) && (_MSC_VER >= 1400))
108 # ifndef strcasecmp
109 # define strcasecmp _stricmp
110 # endif
111 # ifndef strncasecmp
112 # define strncasecmp _strnicmp
113 # endif
114 # else
115 # ifndef strcasecmp
116 # define strcasecmp stricmp
117 # endif
118 # ifndef strncasecmp
119 # define strncasecmp strnicmp
120 # endif
121 # endif
122 #endif
123 
124 
125 /* Define min and max if they're not already defined. */
126 #ifndef sipx_max
127 # define sipx_max(x,y) (((x)>(y))?(x):(y))
128 #endif
129 
130 #ifndef sipx_min
131 # define sipx_min(x,y) (((x)<(y))?(x):(y))
132 #endif
133 
134 #ifdef __cplusplus
135  extern "C" {
136 #endif
137 
138 #if defined (_VXWORKS) /* Only needed for VxWorks --GAT */
139  int strcasecmp(const char *, const char *);
140  char * strdup (const char *);
141 
142  /* These function names are for code compatibility with Windows. --GAT */
143 # ifndef strcmpi
144 # define strcmpi strcasecmp
145 # endif
146 # ifndef stricmp
147 # define stricmp strcasecmp
148 # endif
149 # ifndef _stricmp
150 # define _stricmp strcasecmp
151 # endif
152 #endif /* _VXWORKS */
153 
154 extern unsigned int pspGetLocalMemLocalAddr(void);
155 extern unsigned int pspGetLocalMemSize(void);
156 
157 #define SysLowerMemoryLimit (pspGetLocalMemLocalAddr())
158 #define SysUpperMemoryLimit (pspGetLocalMemLocalAddr() + pspGetLocalMemSize() - 4)
159 
160 
161 extern int hSipLogId;
162 void enableConsoleOutput(int bEnable) ;
163 void osPrintf(const char* format , ...)
164 #ifdef __GNUC__
165  /* with the -Wformat switch, this enables format string checking */
166  __attribute__ ((format (printf, 1, 2)))
167 #endif
168 ;
169 
170 /* A special value for "port number" which means that no port is specified. */
171 #define PORT_NONE (-1)
172 
173 /*
174  * A special value for "port number" which means that some default
175  * port number should be used. The default may be defined by the
176  * situation, or the OS may choose a port number.
177  * For use when PORT_NONE is used to mean "open no port", and in
178  * socket-opening calls.
179  */
180 #define PORT_DEFAULT (-2)
181 
182 /*
183  * Macro to test a port number for validity as a real port (and not
184  * PORT_NONE or PORT_DEFAULT). Note that 0 is a valid port number for
185  * the protocol, but the Berkeley sockets interface makes it
186  * impossible to specify it. In addition, RTP treats port 0 as a
187  * special value. Thus we forbid port 0.
188  */
189 #define portIsValid(p) ((p) >= 1 && (p) <= 65535)
190 
191 #ifdef __cplusplus
192  }
193 #endif
194 
195 
196 /* Silence unused vailable warnings
197  * May be present for the purpose of debugging */
198 #define SIPX_UNUSED(VAR) if(0){(void) VAR;}
199 
200 
201 #include "stdlib.h"
202 #include "string.h"
203 #include "stdio.h"
204 #include "time.h"
205 
206 #if defined(__sun) && defined(__SVR4)
207 # include <strings.h>
208 # include <sys/sockio.h>
209 # include <netdb.h>
210 # ifdef __cplusplus
211  extern "C"
212 # endif
213  extern int getdomainname(char *, int);
214 #endif
215 
216 #endif /* _OsDefs_h_ */
void enableConsoleOutput(int bEnable)
Definition: osPrintf.cpp:57
unsigned int pspGetLocalMemSize(void)
Include this file if you want use C99 integer types with specified width and corresponding set of mac...
void osPrintf(const char *format,...)
Definition: osPrintf.cpp:62
#define strdup(x)
Definition: WinCEFixups.h:75
int hSipLogId
#define strcasecmp
Definition: WinCEFixups.h:54
unsigned int pspGetLocalMemLocalAddr(void)