sipxtacklib  Version 3.3
sysdep.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2006-2019 SIPez LLC. All rights reserved.
3 //
4 // Copyright (C) 2006 SIPfoundry Inc.
5 // Licensed by SIPfoundry under the LGPL license.
6 //
7 // $$
9 
10 #ifndef SYSDEP_H
11 #define SYSDEP_H
12 
13 
14 #if defined(unix) || defined(__unix) || defined (__unix__)
15 /* Code for Unix. Any Unix compiler should define one of the above three
16  * symbols. */
17 
18 #if HAVE_CRYPT_H
19 #include <crypt.h>
20 #endif
21 
22 #ifndef HAVE_GETHOSTBYNAME_R
23 struct hostent *gethostbyname_r (const char *name, struct hostent
24  *result, char *buffer, int buflen,
25  int *h_errnop);
26 #endif
27 
28 #ifndef HAVE_STRTOK_R
29 char *strtok_r(char *s1, char *s2, char **lasts);
30 #endif
31 
32 #if !defined(ETIMEDOUT) && defined(ETIME)
33 #define ETIMEDOUT ETIME
34 #endif
35 
36 #if !defined(ETIME) && defined(ETIMEDOUT)
37 #define ETIME ETIMEDOUT
38 #endif
39 
40 #ifndef DIR_SEPARATOR
41 #define DIR_SEPARATOR "/"
42 #endif
43 
44 #ifndef TRUE
45 #define TRUE 1
46 #endif
47 
48 #include <limits.h>
49 #ifndef INFINITE
50 #define INFINITE ULONG_MAX
51 #endif
52 
53 #ifndef WaitForMultipleObjects
54 #define WaitForMultipleObjects(n, tid, b, f) \
55 do { \
56  int _i; \
57  for (_i = 0; _i < n; _i++) { \
58  if (tid[_i]) { \
59  pthread_join(tid[_i], NULL); \
60  } \
61  } \
62 } while (0)
63 #endif
64 
65 
66 #ifndef startupSocket
67 #define startupSocket()
68 #endif
69 
70 
71 #ifndef closesocket
72 #define closesocket close
73 #endif
74 
75 #ifndef FILE_SOCKET
76 #define FILE_SOCKET FILE
77 #endif
78 
79 #ifndef fdopen_socket
80 #define fdopen_socket(f, g) fdopen(f, g)
81 #endif
82 
83 #ifndef fclose_socket
84 #define fclose_socket(f) fclose(f)
85 #endif
86 
87 #ifndef getc_socket
88 #define getc_socket(f) getc(f)
89 #endif
90 
91 #ifndef write_socket
92 #define write_socket(r, s, l) write(r, s, l)
93 #endif
94 
95 /* end of 'if unix' */
96 
97 #elif defined(WIN32)
98 
99 #define NOLONGLONG
100 #define WNOHANG 0 /* used in waitpid */
101 
102 #include <stdio.h> /* required for compilation on win32.
103  * Probably types.h does not include WCHAR */
104 
105 #include <winsock2.h> /* For NT socket */
106 
107 #if (_MSC_VER > 1900)
108 # define _TIMESPEC_T
109 #endif
110 
111 #ifndef WINCE
112 # include <sys/timeb.h> /* For _ftime() */
113 # include <sys/stat.h> /* S_IWRITE */
114 # include <process.h> /* For _getpid() */
115 # include <io.h> /* open, write, read */
116 # include <direct.h> /* chdir() */
117 #endif
118 
119 #include <resparse/wnt/crypt.h>
120 #ifndef WINCE /* WinCE doesn't have signal.h or errno.h */
121 #include <signal.h> /* SIGINT */
122 #include <errno.h>
123 #endif
124 #include <resparse/wnt/nterrno.h> /* Additional errors not in errno.h --GAT */
125 
126 
127 #include <resparse/wnt/utilNT.h> /* For function and struct in UNIX but not in NT */
128 #include "resparse/types.h"
129 
130 #ifndef stat
131 #define stat _stat
132 #endif
133 
134 #ifndef snprintf
135 #define snprintf _snprintf
136 #endif
137 
138 #ifndef usleep
139 #define usleep(s) _sleep((s)/1000)
140 #endif
141 
142 #ifndef open
143 #define open _open
144 #endif
145 
146 #ifndef write
147 #define write _write
148 #endif
149 
150 #ifndef close
151 #define close _close
152 #endif
153 
154 #ifndef popen
155 #define popen _popen
156 #endif
157 
158 #ifndef pclose
159 #define pclose _pclose
160 #endif
161 
162 #ifndef _WIN32 // Conflicts with glib under windows
163 #ifndef pipe
164 #define pipe(p) _pipe(p, 256, O_BINARY)
165 #endif
166 #endif
167 
168 #ifndef S_IRWXU
169 #define S_IRWXU S_IWRITE
170 #endif
171 
172 #ifndef waitpid
173 #define waitpid(pid, status, act) _cwait(status, pid, act)
174 #endif
175 
176 #ifndef dup2
177 #define dup2 _dup2
178 #endif
179 
180 #ifndef getpid /* used in random32.c */
181 #define getpid _getpid
182 #endif
183 
184 #ifndef bcopy
185 #define bcopy(s, t, n) memcpy(t, s, n)
186 #endif
187 
188 struct utsname {
189  char uname[16];
190 };
191 
192 #ifndef PATH_MAX
193 #define PATH_MAX 1024 /* For NT */
194 #endif
195 
196 #ifndef DIR_SEPARATOR
197 #define DIR_SEPARATOR "\\"
198 #endif
199 
200 #ifndef VERSION
201 #define VERSION "1.0"
202 #endif
203 
204 #ifndef SIGBUS
205 #define SIGBUS SIGINT
206 #endif
207 
208 #ifndef SIGHUP
209 #define SIGHUP SIGINT
210 #endif
211 
212 #ifndef SIGPIPE
213 #define SIGPIPE SIGINT
214 #endif
215 
216 #ifndef _WIN32 /* Conflicts with glib under windows */
217 typedef long pid_t;
218 #endif
219 typedef long gid_t;
220 typedef long uid_t;
221 
222 #ifndef HAVE_BOOLEAN_T
223 #define HAVE_BOOLEAN_T
224 /* Define boolean_t if macro HAVE_BOOLEAN_T is not defined */
225 typedef enum {
226  B_FALSE = FALSE,
227  B_TRUE = TRUE
228 } boolean_t;
229 
230 #endif
231 
232 typedef unsigned long u_long;
233 typedef unsigned int u_int;
234 typedef unsigned short u_short;
235 typedef unsigned char u_char;
236 typedef int ssize_t;
237 typedef char * caddr_t; /* core address */
238 typedef long fd_mask;
239 #define NBBY 8 /* number of bits in a byte */
240 #define NFDBITS (sizeof(fd_mask) * NBBY) /* bits per mask */
241 #ifndef howmany
242 #define howmany(x, y) (((x) + ((y) - 1)) / (y))
243 #endif
244 
245 struct passwd {
246  char *pw_name;
247  char *pw_passwd;
248  uid_t pw_uid;
249  gid_t pw_gid;
250  char *pw_age;
251  char *pw_comment;
252  char *pw_gecos;
253  char *pw_dir;
254  char *pw_shell;
255 };
256 
257 #ifndef _TIMESPEC_T
258 #define _TIMESPEC_T
259 typedef struct timespec { /* definition per POSIX.4 */
260  time_t tv_sec; /* seconds */
261  long tv_nsec; /* and nanoseconds */
262 } timespec_t;
263 #endif /* _TIMESPEC_T */
264 
265 #ifndef ETIME
266 #define ETIME 1
267 #endif
268 
269 #ifndef SIGKILL
270 #define SIGKILL SIGTERM
271 #endif
272 
273 #define fork() 0
274 #define setsid() {}
275 
276 #ifndef startupSocket
277 #define startupSocket() {WSADATA wsaData; \
278  if (WSAStartup(0x0101, &wsaData)) \
279  printf("Could not open start up windows socket.\n"); }
280 #endif
281 
282 #ifndef FILE_SOCKET
283 #define FILE_SOCKET int
284 #endif
285 
286 #ifndef fdopen_socket
287 #define fdopen_socket(f, g) &f
288 #endif
289 
290 #ifndef fclose_socket
291 #define fclose_socket(f) closesocket(*f)
292 #endif
293 
294 #ifndef gethostbyname_r
295 #define gethostbyname_r(h,a,b,c,d) gethostbyname(h)
296 #endif
297 
298 extern int getc_socket(FILE_SOCKET *f);
299 extern ssize_t write_socket(int fildes, const void *buf, size_t nbyte);
300 
301 #define S_IRUSR 0400 /* User read permission */
302 #define S_IWUSR 0200 /* User write permission */
303 #define S_IXUSR 0100 /* User execute permission */
304 
305 #define S_IRGRP 0040 /* Groupread permission */
306 #define S_IWGRP 0020 /* groupwrite permission */
307 #define S_IXGRP 0010 /* groupexecute permission */
308 
309 #define S_IROTH 0004 /* otherread permission */
310 #define S_IWOTH 0002 /* otherwrite permission */
311 #define S_IXOTH 0001 /* otherexecute permission */
312 
313 
314 /* end of 'ifdef WIN32' */
315 #else
316 #error "Not Unix or WIN32 -- what system is this?"
317 #endif
318 
319 #define DO_NOTHING 2
320 #define ADD_PROXY 1
321 #define REMOVE_PROXY 0
322 
323 #endif /* end of ifdef SYSDEP_H */
int uname(struct utsname *name)
char * strtok_r(char *s1, char *s2, char **lasts)
long uid_t
Definition: utilNT.h:33
uid_t gid_t
Definition: utilNT.h:34
long pid_t
Definition: utilNT.h:31

sipXtackLib home page