ze-filter  (ze-filter-0.8.0-develop-180218)
ze-sys.h
Go to the documentation of this file.
1 /*
2  *
3  * ze-filter - Mail Server Filter for sendmail
4  *
5  * Copyright (c) 2001-2018 - Jose-Marcio Martins da Cruz
6  *
7  * Auteur : Jose Marcio Martins da Cruz
8  * jose.marcio.mc@gmail.org
9  *
10  * Historique :
11  * Creation : janvier 2002
12  *
13  * This program is free software, but with restricted license :
14  *
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19  *
20  * More details about ze-filter license can be found at ze-filter
21  * web site : http://foss.jose-marcio.org
22  */
23 
24 #ifndef __ZE_SYS_H
25 
26 
27 #ifdef HAVE_CONFIG_H
28 #include <config.h>
29 #endif /* HAVE_CONFIG_H */
30 
31 #if 0
32 #ifndef _REENTRANT
33 #define _REENTRANT
34 #endif /* _REENTRANT */
35 #endif
36 
37 #define OS_OTHER
38 
39 /*
40 ** S U N S O L A R I S
41 **
42 */
43 #if defined(OS_SOLARIS)
44 
45 #undef OS_OTHER
46 
47 #if 0
48 #ifndef _POSIX_SOURCE
49 # define _POSIX_SOURCE
50 #endif /* _POSIX_SOURCE */
51 
52 #ifndef _POSIX_C_SOURCE
53 # define _POSIX_C_SOURCE 199506L
54 #endif /* _POSIX_C_SOURCE */
55 
56 #ifndef _POSIX_PTHREAD_SEMANTICS
57 # define _POSIX_PTHREAD_SEMANTICS
58 #endif /* _POSIX_PTHREAD_SEMANTICS */
59 
60 #define __EXTENSIONS__
61 #endif
62 
63 #endif /* OS_SOLARIS */
64 
65 /*
66 ** L I N U X
67 **
68 */
69 #if defined(OS_LINUX)
70 
71 #undef OS_OTHER
72 
73 /* may delete all this - deprecated */
74 #if 0
75 
76 #define _POSIX_SOURCE
77 #define _POSIX_C_SOURCE 199506L
78 #define __USE_UNIX98
79 #if HAVE_PTHREAD_H
80 #define _POSIX_PTHREAD_SEMANTICS
81 #endif /* HAVE_PTHREAD_H */
82 #define _BSD_SOURCE
83 #define _XOPEN_SOURCE 600
84 #define _XOPEN_SOURCE_EXTENDED 1
85 #ifndef __STDC__
86 #define __STDC__
87 #endif /* __STDC__ */
88 #define __EXTENSIONS__
89 
90 #endif /* 0 */
91 
92 #endif
93 
94 /*
95 ** F R E E B S D
96 **
97 */
98 #if defined(OS_FREEBSD)
99 
100 #undef OS_OTHER
101 
102 #if 0
103 #ifndef __STDC__
104 #define __STDC__
105 #endif /* __STDC__ */
106 #define __BSD_VISIBLE 1
107 #endif
108 
109 #endif /* OS_FREEBSD */
110 
111 /*
112 ** T R U 6 4
113 **
114 */
115 #if defined(OS_TRU64)
116 
117 #undef OS_OTHER
118 
119 #define _XOPEN_SOURCE 600
120 #define _XOPEN_SOURCE_EXTENDED 1
121 
122 #ifndef _POSIX_SOURCE
123 # define _POSIX_SOURCE
124 #endif /* _POSIX_SOURCE */
125 
126 #ifndef _POSIX_C_SOURCE
127 # define _POSIX_C_SOURCE 199506L
128 #endif /* _POSIX_C_SOURCE */
129 
130 #ifndef _POSIX_PTHREAD_SEMANTICS
131 # define _POSIX_PTHREAD_SEMANTICS
132 #endif /* _POSIX_PTHREAD_SEMANTICS */
133 
134 #ifndef _POSIX_SHARED_MEMORY_OBJECTS
135 # define _POSIX_SHARED_MEMORY_OBJECTS
136 #endif /* _POSIX_SHARED_MEMORY_OBJECTS */
137 
138 #if 0
139 #ifndef __STDC__
140 #define __STDC__
141 #endif /* __STDC__ */
142 #endif
143 
144 #if 0
145 #define _BSD_SOURCE
146 #endif
147 
148 #undef HAVE_GETIPNODEBYADDR
149 #undef HAVE_GETIPNODEBYNAME
150 
151 #endif /* OS_TRU64 */
152 
153 /*
154 ** H P - U X
155 **
156 */
157 #if defined(OS_HPUX)
158 
159 #undef OS_OTHER
160 
161 #if 0
162 #ifndef __STDC__
163 #define __STDC__
164 #endif /* __STDC__ */
165 #define __BSD_VISIBLE 1
166 #endif
167 
168 #endif /* OS_HPUX */
169 
170 /*
171 ** N E T B S D
172 **
173 */
174 #if defined(OS_NETBSD)
175 
176 #undef OS_OTHER
177 
178 #ifndef _POSIX_SOURCE
179 # define _POSIX_SOURCE
180 #endif /* _POSIX_SOURCE */
181 
182 #ifndef _POSIX_C_SOURCE
183 # define _POSIX_C_SOURCE 199506L
184 #endif /* _POSIX_C_SOURCE */
185 
186 #ifndef _POSIX_PTHREAD_SEMANTICS
187 # define _POSIX_PTHREAD_SEMANTICS
188 #endif /* _POSIX_PTHREAD_SEMANTICS */
189 
190 #ifndef _POSIX_SHARED_MEMORY_OBJECTS
191 # define _POSIX_SHARED_MEMORY_OBJECTS
192 #endif /* _POSIX_SHARED_MEMORY_OBJECTS */
193 
194 #endif /* OS_NETBSD */
195 
196 /*
197 **
198 **
199 */
200 #include <stdio.h>
201 #include <stdlib.h>
202 
203 #ifdef HAVE_STDDEF_H
204 #include <stddef.h>
205 #endif /* HAVE_STDDEF_H */
206 
207 #ifdef HAVE_UNISTD_H
208 #include <unistd.h>
209 #endif /* HAVE_UNISTD_H */
210 
211 #if STDC_HEADERS
212 # include <string.h>
213 #else
214 # if HAVE_STRING_H
215 # include <string.h>
216 # endif /* HAVE_STRING_H */
217 # ifndef HAVE_STRCHR
218 # define strchr index
219 # define strrchr rindex
220 # endif /* STDC_STRCHR */
221 char *strchr(), *strrchr();
222 
223 # ifndef HAVE_MEMCPY
224 # define memcpy(d, s, n) bcopy ((s), (d), (n))
225 # define memmove(d, s, n) bcopy ((s), (d), (n))
226 # endif /* HAVE_MEMCPY */
227 #endif /* STDC_HEADERS */
228 
229 #if HAVE_STRINGS_H
230 #include <strings.h>
231 #endif /* HAVE_STRINGS_H */
232 
233 #if HAVE_STRING_H
234 #include <string.h>
235 #endif /* HAVE_STRING_H */
236 
237 #if HAVE_SYSEXITS_H
238 #include <sysexits.h>
239 #endif /* hVE_SYSEXITS_H */
240 
241 #ifdef HAVE_SYS_TYPES_H
242 #include <sys/types.h>
243 #endif /* HAVE_SYS_TYPES_H */
244 
245 #if HAVE_LIMITS_H
246 #include <limits.h>
247 #else
248 #if HAVE_VALUES_H
249 #include <values.h>
250 #else
251 Error - dont have limits.h nor values.h
252 #endif /* HAVE_VALUES_H */
253 #endif /* HAVE_LIMITS_H */
254 
255 
256 /* ---------- */
257 
258 
259 #ifndef __bool_true_false_are_defined
260 # if !defined (HAVE_BOOL)
261 typedef int bool;
262 # endif /* HAVE_BOOL */
263 # define __bool_true_false_are_defined 1
264 #endif /* __bool_true_false_are_defined */
265 
266 #ifndef true
267 # define true 1
268 # define false 0
269 #endif
270 
271 
272 #if HAVE_STDARG_H
273 #include <stdarg.h>
274 #endif /* HAVE_STDARG_H */
275 
276 #if HAVE_MATH_H
277 #include <math.h>
278 #endif /* HAVE_MATH_H */
279 
280 #include <errno.h>
281 
282 #if TIME_WITH_SYS_TIME
283 # include <time.h>
284 # include <sys/time.h>
285 #else
286 # if HAVE_SYS_TIME_H
287 # include <sys/time.h>
288 # else
289 # include <time.h>
290 # endif /* HAVE_SYS_TIME_H */
291 #endif /* TIME_WITH_SYS_TIME */
292 
293 #if HAVE_SYS_RESOURCE_H
294 #include <sys/resource.h>
295 #endif /* HAVE_SYS_RESOURCE_H */
296 
297 #if HAVE_SIGNAL_H
298 #include <signal.h>
299 #endif /* HAVE_SIGNAL_H */
300 
301 #if HAVE_SYS_WAIT_H
302 # include <sys/wait.h>
303 #endif /* HAVE_SYS_WAIT_H */
304 #ifndef WEXITSTATUS
305 # define WEXITSTATUS(stat_val) ((unsigned int)(stat_val) >> 8)
306 #endif
307 #ifndef WIFEXITED
308 # define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
309 #endif
310 
311 #if HAVE_FCNTL_H
312 #include <fcntl.h>
313 #endif /* HAVE_FCNTL_H */
314 
315 #if HAVE_SYS_STAT_H
316 #include <sys/stat.h>
317 #endif /* HAVE_SYS_STAT_H */
318 
319 #if HAVE_DIRENT_H
320 #include <dirent.h>
321 #endif /* HAVE_DIRENT_H */
322 
323 #if USE_PCRE
324 # if !defined(HAVE_PCRE_H) || !defined(HAVE_LIBPCRE)
325 # undef USE_PCRE
326 # endif /* !defined(HAVE_PCRE_H) || !defined(HAVE_LIBPCRE) */
327 #endif /* USE_PCRE */
328 
329 #if USE_PCRE
330 # if HAVE_PCRE_H && HAVE_LIBPCRE
331 # include <pcre.h>
332 # else /* HAVE_PCRE_H && HAVE_LIBPCREX */
333 # ERROR : PCRE
334 # endif /* HAVE_PCRE_H && HAVE_LIBPCREX */
335 #endif /* USE_PCRE */
336 
337 #if HAVE_REGEX_H
338 #include <regex.h>
339 #endif /* HAVE_REGEX_H */
340 
341 #if HAVE_CTYPE_H
342 #include <ctype.h>
343 #endif /* HAVE_CTYPE_H */
344 
345 #if HAVE_SYS_SOCKET_H
346 #include <sys/socket.h>
347 #endif /* HAVE_SYS_SOCKET_H */
348 
349 #if HAVE_SYS_UN_H
350 #include <sys/un.h>
351 #endif /* HAVE_SYS_UN_H */
352 
353 #if HAVE_POLL_H
354 #include <poll.h>
355 #endif /* HAVE_POLL_H */
356 
357 #if HAVE_SYS_POLL_H
358 #include <sys/poll.h>
359 #endif /* HAVE_SYS_POLL_H */
360 
361 #if HAVE_SYS_SELECT_H
362 #include <sys/select.h>
363 #endif /* HAVE_SYS_SELECT_H */
364 
365 #if HAVE_NETINET_IN_H
366 #include <netinet/in.h>
367 #endif /* HAVE_NETINET_IN_H */
368 
369 #if HAVE_ARPA_INET_H
370 #include <arpa/inet.h>
371 #endif /* HAVE_ARPA_INET_H */
372 
373 #if HAVE_ARPA_NAMESER_H
374 #include <arpa/nameser.h>
375 #endif /* HAVE_ARPA_NAMESER_H */
376 
377 #if HAVE_NETDB_H
378 #include <netdb.h>
379 #endif /* HAVE_NETDB_H */
380 
381 #if HAVE_RESOLV_H
382 #include <resolv.h>
383 #endif /* HAVE_RESOLV_H */
384 
385 #if HAVE_SYSLOG_H
386 #include <syslog.h>
387 #endif /* HAVE_SYSLOG_H */
388 
389 #if HAVE_THREAD_H
390 #include <thread.h>
391 #endif /* HAVE_THREAD_H */
392 
393 #if HAVE_PTHREAD_H
394 #include <pthread.h>
395 #else
396 #if HAVE_SYS_PTHREAD_H
397 #include <sys/pthread.h>
398 #endif /* HAVE_SYS_PTHREAD_H */
399 #endif /* HAVE_PTHREAD_H */
400 
401 #if HAVE_DLFCN_H
402 #include <dlfcn.h>
403 #endif /* HAVE_DLFCN_H */
404 
405 #if HAVE_PWD_H
406 #include <pwd.h>
407 #endif /* HAVE_PWD_H */
408 
409 #if HAVE_GRP_H
410 #include <grp.h>
411 #endif /* HAVE_GRP_H */
412 
413 #ifdef HAVE_KSTAT_H
414 #include <kstat.h>
415 #endif /* HAVE_KSTAT_H */
416 
417 #ifdef HAVE_KVM_H
418 #include <kvm.h>
419 #endif /* HAVE_KVM_H */
420 
421 #ifdef HAVE_SYS_DKSTAT_H
422 #include <sys/dkstat.h>
423 #endif /* HAVE_SYS_DKSTAT_H */
424 
425 #ifdef HAVE_SYS_LOADAVG_H
426 #include <sys/loadavg.h>
427 #endif /* HAVE_SYS_LOADAVG_H */
428 
429 #ifdef HAVE_SYS_SYSTEMINFO_H
430 #include <sys/systeminfo.h>
431 #endif /* HAVE_SYS_SYSTEMINFO_H */
432 
433 #ifdef HAVE_SYS_SYSINFO_H
434 #include <sys/sysinfo.h>
435 #endif /* HAVE_SYS_SYSINFO_H */
436 
437 #ifdef HAVE_SYS_UTSNAME_H
438 #include <sys/utsname.h>
439 #endif /* HAVE_SYS_UTSNAME_H */
440 
441 #ifdef HAVE_SYS_MMAN_H
442 #include <sys/mman.h>
443 #endif /* HAVE_SYS_MMAN_H */
444 
445 #ifdef HAVE_ASSERT_H
446 # include <assert.h>
447 #endif /* HAVE_ASSERT_H */
448 
449 #ifdef HAVE_LIBGEN_H
450 # include <libgen.h>
451 #endif /* HAVE_LIBGEN_H */
452 
453 #ifndef isblank
454 # define isblank(c) ((c) == ' ' || (c) == '\t')
455 #endif
456 
457 #if USE_BerkeleyDB
458 #if HAVE_DB_H
459 #include <db.h>
460 #endif /* HAVE_DB_H */
461 #endif /* USE_BerkeleyDB */
462 
463 #if defined(HAVE_DECL___FUNC__) && (HAVE_DECL___FUNC__ == 1)
464 # define ZE_FUNCTION __func__
465 # define ZE_PRETTY_FUNCTION __func__
466 #else
467 # if defined(HAVE_DECL___FUNCTION__) && (HAVE_DECL___FUNCTION__ == 1)
468 # define ZE_FUNCTION __FUNCTION__
469 # define ZE_PRETTY_FUNCTION __PRETTY_FUNCTION__
470 # else
471 # define ZE_FUNCTION __FILE__
472 # define ZE_PRETTY_FUNCTION __FILE__
473 # endif
474 #endif
475 
476 #if !defined(HAVE_UCHAR)
477 typedef unsigned char uchar;
478 #endif /* HAVE_UCHAR */
479 
480 #if !defined(HAVE_INT16_T)
481 typedef short int16_t;
482 #endif /* HAVE_INT16_T */
483 
484 #if !defined(HAVE_UINT16_T)
485 typedef unsigned short uint16_t;
486 #endif
487 
488 #if !HAVE_INT32_T
489 typedef long uint32_t;
490 #endif
491 
492 #if !HAVE_UINT32_T
493 typedef unsigned long uint32_t;
494 #endif
495 
496 #if !defined(HAVE_INT64_T)
497 # if HAVE_LONG_LONG
498 # if SIZEOF_LONG_LONG == 8
499 typedef long long int64_t;
500 # define HAVE_INT64_T 1
501 # endif /* SIZEOF_LONG_LONG */
502 # endif /* HAVE_LONG_LONG */
503 #endif /* HAVE_INT64_T */
504 
505 #if !defined(HAVE_UINT64_T)
506 # if HAVE_UNSIGNED_LONG_LONG
507 # if SIZEOF_UNSIGNED_LONG_LONG == 8
508 typedef unsigned long long uint64_t;
509 # define HAVE_UINT64_T 1
510 # endif /* SIZEOF_UNSIGNED_LONG_LONG */
511 # endif /* HAVE_UNSIGNED_LONG_LONG */
512 #endif /* HAVE_UINT64_T */
513 
514 #if !defined(HAVE_OFF_T)
515 typedef unsigned long off_t;
516 #endif
517 
518 #if !defined(HAVE_MODE_T)
519 typedef unsigned int mode_t;
520 #endif
521 
522 #if !defined(HAVE_SSIZE_T)
523 typedef long ssize_t;
524 #endif
525 
526 #if !defined(HAVE_SOCKET_T)
527 typedef int socket_t;
528 #endif
529 
530 #ifndef HAVE_SOCKLEN_T
531 #if HAVE_SIZE_T
532 typedef size_t socklen_t;
533 #else
534 typedef int socklen_t;
535 #endif
536 #endif
537 
538 
539 /* #undef HAVE_IN_ADDR_T */
540 #if !defined(HAVE_IN_ADDR_T)
542 #endif
543 
544 typedef union
545 {
546  struct sockaddr sa;
547 #if HAVE_STRUCT_SOCKADDR_IN
548  struct sockaddr_in sin;
549 #endif /* HAVE_STRUCT_SOCKADDR_IN */
550 #if ENABLE_IPV6
551 # if HAVE_STRUCT_SOCKADDR_IN6
552  struct sockaddr_in6 sin6;
553 # endif /* HAVE_STRUCT_SOCKADDR_IN6 */
554 #endif /* ENABLE_IPV6 */
555 #if HAVE_STRUCT_SOCKADDR_UN && 0
556  struct sockaddr_un sun;
557 #endif /* HAVE_STRUCT_SOCKADDR_UN */
558 } JSOCKADDR_T;
559 
560 #if !HAVE_FLOCK_T && HAVE_STRUCT_FLOCK
561 typedef struct flock flock_t;
562 #endif
563 
564 
565 #if !HAVE_DECL_STRLCPY
566 size_t strlcpy(char *, const char *, size_t);
567 #endif
568 
569 #if !HAVE_DECL_STRLCAT
570 size_t strlcat(char *, const char *, size_t);
571 #endif
572 
573 #if HAVE_FCHMOD && (HAVE_DECL_FCHMOD == 0)
574 int fchmod(int, mode_t);
575 #endif
576 
577 #if HAVE_PREAD && (HAVE_DECL_PREAD == 0)
578 ssize_t pread(int, void *, size_t, off_t);
579 #endif
580 
581 #if HAVE_PWRITE && (HAVE_DECL_PWRITE == 0)
582 ssize_t pwrite(int, const void *, size_t, off_t);
583 #endif
584 
585 #ifndef _POSIX2_LINE_MAX
586 #define _POSIX2_LINE_MAX 2048
587 #endif /* _POSIX2_LINE_MAX **/
588 
589 
590 #if HAVE_MI_STOP
591 int mi_stop (void);
592 #endif /* HAVE_MI_STOP */
593 
594 #ifdef _POSIX_PTHREAD_SEMANTICS
595 # define CTIME_R(t,s) ctime_r(t,s)
596 #else
597 # define CTIME_R(t,s) ctime_r(t,s,sizeof(s))
598 #endif
599 
600 #if !HAVE_STRTOULL
601 # if HAVE_STRTOLL
602 # define strtoull strtoll
603 # else
604 # define strtoull strtoul
605 # endif /* HAVE_STRTOLL */
606 #endif /* HAVE_STRTOULL */
607 
608 
609 #define __ZE_SYS_H
610 
611 #endif
int socklen_t
Definition: ze-sys.h:534
short int16_t
Definition: ze-sys.h:481
#define strrchr
Definition: ze-sys.h:219
size_t strlcat(char *, const char *, size_t)
int socket_t
Definition: ze-sys.h:527
#define strchr
Definition: ze-sys.h:218
Error dont have limits h nor values h typedef int bool
Definition: ze-sys.h:261
unsigned short uint16_t
Definition: ze-sys.h:485
unsigned char uchar
Definition: ze-sys.h:477
unsigned long off_t
Definition: ze-sys.h:515
size_t strlcpy(char *, const char *, size_t)
long ssize_t
Definition: ze-sys.h:523
unsigned int mode_t
Definition: ze-sys.h:519
long uint32_t
Definition: ze-sys.h:489
uint32_t in_addr_t
Definition: ze-sys.h:541