File: includes.h

package info (click to toggle)
procmail 3.22-24
  • links: PTS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 2,104 kB
  • sloc: ansic: 9,885; sh: 1,957; makefile: 132
file content (569 lines) | stat: -rw-r--r-- 12,659 bytes parent folder | download | duplicates (10)
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
/*$Id: includes.h,v 1.77 2001/08/25 04:38:37 guenther Exp $*/

#include "../autoconf.h"
#ifdef NO_const
#ifdef const
#undef const
#endif
#define const
#endif
#include "../config.h"
	/* not all the "library identifiers" specified here need to be
	   available for all programs in this package; some have substitutes
	   as well (see autoconf); this is just an informal list */

#ifndef _HPUX_SOURCE
#define _HPUX_SOURCE	      /* sad, but needed on HP-UX when compiling -Aa */
#endif
#ifndef NO_FIX_MALLOC
#define NO_FIX_MALLOC		   /* we don't need a `fixed' malloc(0) call */
#endif				/* saves a few bytes in some implementations */

#include <sys/types.h>		/* pid_t mode_t uid_t gid_t off_t */
#ifndef LIMITS_H_MISSING
#include <limits.h>		/* absolutely nothing, just for fun */
#undef LIMITS_H_MISSING
#endif
#ifndef UNISTD_H_MISSING
#include <unistd.h>		/* open() read() write() close() dup() pipe()
				/* fork() getuid() geteuid() getgid() getegid()
				   getpid() execv() execvp() sleep() setuid()
				   setgid() setruid() setrgid() setegid()
				   chown() nice() ftruncate() truncate() */
#undef EX_OK
#else
#undef UNISTD_H_MISSING
#endif
#include <stdio.h>		/* setbuf() fclose() stdin stdout stderr
				/* fopen() fread() fwrite() fgetc() getc()
				   getchar() fdopen() putc() fputs() printf()
				   sprintf() fprintf() sscanf() FILE EOF
				   fileno() */
#ifndef STDDEF_H_MISSING
#include <stddef.h>		/* ptrdiff_t size_t */
#else
#undef STDDEF_H_MISSING
#endif
#ifndef STDLIB_H_MISSING
#include <stdlib.h>		/* getenv() malloc() realloc() free()
				/* strtol() strtod() exit() EXIT_SUCCESS */
#endif
#include <time.h>		/* time() ctime() time_t */
#include <fcntl.h>		/* fcntl() struct flock O_RDONLY O_WRONLY
				/* O_APPEND O_CREAT O_EXCL */
#include <grp.h>		/* getgrgid() struct group */
#include <pwd.h>		/* getpwuid() getpwnam() struct passwd */
#ifndef DIRENT_H_MISSING
#include <dirent.h>		/* opendir() readdir() closedir() DIR
				/* struct dirent */
#endif
#ifndef SYS_WAIT_H_MISSING
#include <sys/wait.h>		/* wait() waitpid() WIFEXITED() WIFSTOPPED()
				/* WEXITSTATUS() WTERMSIG() WNOHANG */
#else
#undef SYS_WAIT_H_MISSING
#endif
#ifndef SYS_UTSNAME_H_MISSING
#include <sys/utsname.h>	/* uname() utsname */
#endif
#include <sys/stat.h>		/* stat() S_ISDIR() S_ISREG() struct stat
				/* chmod() mkdir() */
#include <signal.h>		/* signal() kill() alarm() SIG_IGN SIGHUP
				/* SIGINT SIGQUIT SIGALRM SIGTERM */
#ifndef STRING_H_MISSING
#include <string.h>		/* strcpy() strcat() strlen()
				/* strspn() strcspn() strchr() strcmp()
				   strncmp() strpbrk() strstr() memmove()
				   strncasecmp() memset() */
#endif
#ifndef MATH_H_MISSING
#include <math.h>		/* pow() */
#endif
#ifndef SYSLOG_H_MISSING
#include <syslog.h>		/* openlog() syslog() closelog() LOG_EMERG
				/* LOG_ALERT LOG_CRIT LOG_ERR LOG_NOTICE
				   LOG_PID LOG_MAIL */
#endif
#include <errno.h>		/* EINTR EEXIST ENFILE EACCES EAGAIN EXDEV */
				/* EDQUOT ENOSPC strerror() */
#ifndef SYSEXITS_H_MISSING
#include <sysexits.h>		/* EX_USAGE EX_DATAERR EX_NOINPUT EX_NOUSER
				   EX_UNAVAILABLE EX_OSERR EX_OSFILE
				   EX_CANTCREAT EX_IOERR EX_TEMPFAIL
				   EX_NOPERM EX__BASE */
#endif

#ifdef STDLIB_H_MISSING
#undef STDLIB_H_MISSING
void*malloc(),*realloc();
const char*getenv();
#endif
#ifdef DIRENT_H_MISSING
#undef DIRENT_H_MISSING
#ifndef NDIR_H_MISSING
#include <ndir.h>
#define dirent	direct
#else
#undef NDIR_H_MISSING
#ifndef SYS_NDIR_H_MISSING
#include <sys/ndir.h>
#define dirent	direct
#else
#undef SYS_NDIR_H_MISSING
#ifndef SYS_DIR_H_MISSING
#include <sys/dir.h>
#define dirent	direct
#else			  /* due to brain-damaged NeXT sys/dirent.h contents */
#undef SYS_DIR_H_MISSING
#ifndef SYS_DIRENT_H_MISSING	     /* sys/dirent.h must be moved down here */
#include <sys/dirent.h>
#else
/*#undef SYS_DIRENT_H_MISSING			       /* needed by autoconf */
/* I give up, I can only hope that your system defines DIR and struct dirent */
#endif
#endif
#endif
#endif
#endif /* DIRENT_H_MISSING */
#ifdef STRING_H_MISSING
#undef STRING_H_MISSING
#include <strings.h>
#ifndef strchr
char*strchr();
#endif
char*strpbrk();
#endif
#ifdef SYS_UTSNAME_H_MISSING
#undef SYS_UTSNAME_H_MISSING
#define NOuname
#endif
#ifdef MATH_H_MISSING
#undef MATH_H_MISSING
double pow();
#endif
#ifdef SYSEXITS_H_MISSING
#undef SYSEXITS_H_MISSING
		/* Standard exitcodes, original list maintained
		   by Eric Allman (eric@Sendmail.COM) */
#define EX__BASE	64
#define EX_USAGE	64
#define EX_DATAERR	65
#define EX_NOINPUT	66
#define EX_NOUSER	67
#define EX_UNAVAILABLE	69
#define EX_OSERR	71
#define EX_OSFILE	72
#define EX_CANTCREAT	73
#define EX_IOERR	74
#define EX_TEMPFAIL	75
#define EX_NOPERM	77
#endif

#ifndef EXIT_SUCCESS
#define EXIT_SUCCESS	0
#endif

#ifdef NO_exit
#define _exit(sig)	exit(sig)
#endif

#if O_SYNC
#else
#undef O_SYNC
#define O_SYNC		0
#endif
#ifndef O_RDONLY
#define O_RDONLY	0
#define O_WRONLY	1
#endif
#ifndef SEEK_SET
#define SEEK_SET	0
#define SEEK_CUR	1
#define SEEK_END	2
#endif
#ifndef tell
#define tell(fd)	lseek(fd,(off_t)0,SEEK_CUR)
#endif

#ifndef EWOULDBLOCK
#define EWOULDBLOCK	EAGAIN
#endif
#ifndef EAGAIN
#define EAGAIN		EINTR
#endif

#ifndef EOF
#define EOF	(-1)
#endif

#ifndef S_ISDIR
#define S_ISDIR(mode)	(((mode)&S_IFMT)==S_IFDIR)
#ifndef S_IFDIR
#define S_IFDIR 0040000
#endif
#endif

#ifndef S_ISREG
#define S_ISREG(mode)	(((mode)&S_IFMT)==S_IFREG)
#ifndef S_IFREG
#define S_IFREG 0100000
#endif
#endif

#ifndef S_ISLNK
#ifndef S_IFLNK
#define lstat(path,stbuf)	stat(path,stbuf)
#define S_ISLNK(mode)	0
#else
#define S_ISLNK(mode)	(((mode)&S_IFMT)==S_IFLNK)
#endif
#endif

#ifndef S_IFMT
#define S_IFMT	0170000
#endif

#ifndef S_IRWXU
#define S_IRWXU 00700
#define S_IRWXG 00070
#define S_IRWXO 00007
#endif
#ifndef S_IWUSR
#ifdef S_IREAD
#define S_IRUSR	 S_IREAD
#define S_IWUSR	 S_IWRITE
#define S_IXUSR	 S_IEXEC
#else
#define S_IRUSR	 0400
#define S_IWUSR	 0200
#define S_IXUSR	 0100
#endif /* S_IREAD */
#define S_IRGRP	 0040
#define S_IWGRP	 0020
#define S_IXGRP	 0010
#define S_IROTH	 0004
#define S_IWOTH	 0002
#define S_IXOTH	 0001
#endif /* S_IWUSR */
#ifndef S_ISGID
#define S_ISUID 04000
#define S_ISGID 02000
#endif
#ifndef S_ISVTX
#define S_ISVTX 01000
#endif

#ifdef WMACROS_NON_POSIX
#undef WMACROS_NON_POSIX
#ifdef WIFEXITED
#undef WIFEXITED
#endif
#ifdef WIFSTOPPED
#undef WIFSTOPPED
#endif
#ifdef WEXITSTATUS
#undef WEXITSTATUS
#endif
#ifdef WTERMSIG
#undef WTERMSIG
#endif
#endif /* WMACROS_NON_POSIX */

#ifndef WIFEXITED
#define WIFEXITED(waitval)	(!((waitval)&255))
#endif
#ifndef WIFSTOPPED
#define WIFSTOPPED(waitval)	(((waitval)&255)==127)
#endif
#ifndef WEXITSTATUS
#define WEXITSTATUS(waitval)	((waitval)>>8&255)
#endif
#ifndef WTERMSIG
#define WTERMSIG(waitval)	((waitval)&255)
#endif

extern /*const*/char**environ;
extern int errno;

#ifndef STDIN_FILENO
#define STDIN	0
#define STDOUT	1
#define STDERR	2
#else
#define STDIN	STDIN_FILENO
#define STDOUT	STDOUT_FILENO
#define STDERR	STDERR_FILENO
#endif

#ifdef NO_fcntl_LOCK
#ifndef NOfcntl_lock
#define NOfcntl_lock
#endif
#endif
#ifdef NO_lockf_LOCK
#ifdef USElockf
#undef USElockf
#endif
#endif
#ifdef NO_flock_LOCK
#ifdef USEflock
#undef USEflock
#endif
#endif

#ifdef SYSLOG_H_MISSING
#undef SYSLOG_H_MISSING
#define Openlog(ident,logopt,facility)	0
#define syslog				(void)
#define closelog()
#define LOG_EMERG			0
#define LOG_CRIT			0
#define LOG_ALERT			0
#define LOG_ERR				0
#define LOG_NOTICE			0
#else
#ifdef LOG_MAIL
#define Openlog(ident,logopt,facility)	openlog(ident,logopt,facility)
#else
#define Openlog(ident,logopt,facility)	openlog(ident,logopt)
#endif
#endif

#ifndef NOuname
#ifndef P		  /* SINIX V5.23 has the wrong prototype for uname() */
extern int uname();					 /* so we fix it :-) */
#define Uname(name)		((int(*)(struct utsname*))uname)(name)
#else
#define Uname(name)		uname(name)		    /* no fix needed */
#endif /* P */
#endif /* NOuname */
				 /* NEWS OS 5.X has the wrong prototype here */
#define Fdopen(fd,type)		((FILE*)fdopen(fd,type))

#ifdef u
#undef u				       /* and the winner is: AIX 3.2 */
#endif

#ifndef strchr		   /* for very old K&R compatible include files with */
#ifdef P						/* new K&R libraries */
#ifdef void
#ifdef NO_const
extern char*strchr();
extern char*strpbrk();
extern char*strstr();
extern void*memmove();
#endif
#endif
#endif
#endif

#define Const			/*const*/     /* Convex cc doesn't grok this */

#ifndef P				      /* no prototypes without const */
#ifdef NO_const
#define P(args) ()
#endif
#endif

#ifdef NOrename
#undef NOrename
#define rename(old,new) (-(link(old,new)||unlink(old)))
#endif

#ifndef NOsetregid
#ifdef NOsetrgid
#define setrgid(gid)	setregid(gid,-1)
#define setruid(uid)	setreuid(uid,-1)
#endif
#ifdef NOsetegid
#define setegid(gid)	setregid(-1,gid)
#endif
#else
#ifndef NOsetresgid
#ifdef NOsetrgid
#define setrgid(gid)	setresgid(gid,-1,-1)
#define setruid(uid)	setresuid(uid,-1,-1)
#endif
#ifdef NOsetegid
#define setegid(gid)	setresgid(-1,gid,-1)
#endif
#else
#ifdef NOsetrgid
#define setrgid(gid)	(-1)
#define setruid(uid)	(-1)
#endif
#ifdef NOsetegid
#define setegid(gid)	setgid(gid)
#endif
#endif
#endif

#ifdef NOsetrgid
#undef NOsetrgid
#endif
#ifdef NOsetegid
#undef NOsetegid
#endif
#ifdef NOsetregid
#undef NOsetregid
#endif
#ifdef NOsetresgid
#undef NOsetresgid
#endif

#ifdef setrgid_BRAIN_DAMAGE
#undef setrgid_BRAIN_DAMAGE
#ifdef setrgid
#undef setrgid
#endif
#ifdef setruid
#undef setruid
#endif
#define setrgid(gid)	(-1)		   /* and you think POSIX is broken? */
#define setruid(uid)	(-1)			   /* BSD 4.4 just topped it */
#endif

#ifdef setrgid_RUNTIME_CHECK
#undef setrgid_RUNTIME_CHECK
#define setRgid(gid)	(setrgid(gid)||getgid()!=(gid))
#define setRuid(uid)	(setruid(uid)||getuid()!=(uid))
#else
#define setRgid(gid)	setrgid(gid)
#define setRuid(uid)	setruid(uid)
#endif

#ifdef NOinitgroups
/*#undef NOinitgroups				 need this macro in autoconf */
#define initgroups(n,g)
#endif

#ifdef INEFFICIENTrealloc
#undef INEFFICIENTrealloc
#define EXPBLKSIZ	4		    /* 4+3+2+1 = 10 bits total shift */
#else
#define EXPBLKSIZ	0
#endif

#ifdef NOpow
#define tpow(x,y)	(x)
#else
#define tpow(x,y)	pow(x,y)
#endif

#ifdef NOmkdir
#undef NOmkdir
#define mkdir(dir,mode) (-1)
#endif

#ifdef NOftruncate
#undef NOftruncate
#define ftruncate(fildes,length)	(-1)
#define truncate(file,length)		(-1)
#endif

#ifdef NOfsync
#define fsync(fd)	0
#endif

#ifdef NOfstat
#define fstat(fd,st)	(-1)
#endif

#ifdef NOwaitpid
#undef NOwaitpid
#define waitpid(pid,stat_loc,options)	0
#else
#ifndef WNOHANG
#ifdef waitpid
#undef waitpid
#endif
#define waitpid(pid,stat_loc,options)	0
#endif
#endif

#ifdef NOmemmove
#define memmove(to,from,count) smemmove(to,from,count)
#endif

#ifdef NOstrpbrk
#define strpbrk(s,d) sstrpbrk(s,d)
#endif

#ifdef SLOWstrstr
#ifdef strstr
#undef strstr
#endif
#define strstr(haystack,needle) sstrstr(haystack,needle)
#endif

#ifdef NOmemset
#ifdef NObzero
#define NEEDbbzero
#else
#define bbzero(s,l) bzero(s,l)
#endif
#else
#define bbzero(s,l) memset(s,'\0',l)
#endif

#ifdef NOstrlcat
#define strlcat(d,s,z) sstrlcat(d,s,z)
#define strlcpy(d,s,z) sstrlcpy(d,s,z)
#endif

#ifdef NOstrerror
#define strerror(e) sstrerror(e)
#endif

#ifdef NOstrtol
#define strtol(s,p,b) sstrtol(s,p,b)
#endif

#ifndef P
#define P(args)		args
#endif

/*
 * Until function definitions are ANSI, any function whose argument list
 * includes a size_t, uid_t, gid_t, mode_t, pid_t, or time_t type variable
 * should be declared with Q() instead of P().	This is done to prevent
 * problems caused by one of those types being shorter than int and thereby
 * being passed differently under ANSI rules.
 */
#define Q(args)		()

#ifdef oBRAIN_DAMAGE
#undef oBRAIN_DAMAGE
#undef offsetof
#endif
#ifndef offsetof
#define offsetof(s,m) ((char*)&(((s*)sizeof(s))->m)-(char*)sizeof(s))
#endif

#define SETerrno(v)	(errno=(v))	       /* multi-threading errno hook */

#define PROGID		/*const*/char progid[]="Stephen R. van den Berg"
#define maxindex(x)	(sizeof(x)/sizeof((x)[0])-1)
#define STRLEN(x)	(sizeof(x)-1)
#define ioffsetof(s,m)	((int)offsetof(s,m))
#define numeric(x)	(alphanum((unsigned char)(x))>1)
#define sizeNUM(v)	(8*sizeof(v)*4/10+1+1)
#define charNUM(num,v)	char num[sizeNUM(v)]

#define mx(a,b)		((a)>(b)?(a):(b))

typedef unsigned char uschar;	     /* sometimes uchar is already typedef'd */
#ifdef uchar
#undef uchar
#endif
#define uchar uschar

#if ! (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 5))
#define __attribute__(foo)
#endif

#if defined(__OpenBSD__) && defined(DEBUGGING)
#define setuid(x) 0			 /* Under OpenBSD, you can't trace a */
#define setgid(x) 0		      /* program after it calls any of these */
#define setegid(x) 0
#endif