1 /***************************************************************************
2  * LPRng - An Extended Print Spooler System
3  *
4  * Copyright 1988-2003, Patrick Powell, San Diego, CA
5  *     papowell@lprng.com
6  * See LICENSE for conditions of use.
7  ***************************************************************************/
8 
9 #ifndef _PLP_PORTABLE_H
10 #define _PLP_PORTABLE_H 1
11 
12 /***************************************************************************
13  * MODULE: portable.h
14  * PURPOSE:
15  * The configure program generates config.h,  which defines various
16  * macros indicating the presence or abscence of include files, etc.
17  * However, there are some systems which pass the tests,  but things
18  * do not work correctly on them.  This file will try and fix
19  * these things up for the user.
20  *
21  * NOTE:  if there were no problems, this file would be:
22  *    #include "config.h"
23  *
24  * Sigh. Patrick Powell Thu Apr  6 07:00:48 PDT 1995 <papowell@sdsu.edu>
25  *    NOTE: thanks to all the folks who worked on the PLP software,
26  *    Justin Mason <jmason@iona.ie> especially.  Some of the things
27  *    that you have to do to get portability are truely bizzare.
28  *
29  * portable.h,v 3.14 1998/03/24 02:43:22 papowell Exp
30  **************************************************************************/
31 
32 #if !defined(EXTERN)
33 #define EXTERN extern
34 #define DEFINE(X)
35 #undef DEFS
36 #endif
37 
38 #ifndef __STDC__
39 LPRng requires ANSI Standard C compiler
40 #endif
41 
42 #include <config.h>
43 
44 #ifdef HAVE_CTYPE_H
45 #include <ctype.h>
46 #endif
47 
48 /*************************************************************************
49  * ARGH: some things that "configure" can't get right.
50 *************************************************************************/
51 
52 /***************************************************************************
53  * porting note: if you port PLP and you get some errors
54  * caused by autoconf guessing the wrong set of functions/headers/structs,
55  * add or change the entry for your system in the ARGH section below.
56  * You might want to try and determine how your system is identified
57  * by the C preprocessor and use this informaton rather than trying
58  * to look for information in various f1les.
59  *    Patrick Powell and Justin Mason
60  ***************************************************************************/
61 
62 /*************************************************************************
63  * APOLLO Ports
64  *  Thu Apr  6 07:01:51 PDT 1995 Patrick Powell
65  * This appears to be historical.
66  *************************************************************************/
67 #ifdef apollo
68 # define IS_APOLLO OSVERSION
69 /* #undef __STDC__ */
70 /* # define CONFLICTING_PROTOS */
71 #endif
72 
73 /*************************************************************************
74  * ULTRIX.
75  * Patrick Powell Thu Apr  6 07:17:34 PDT 1995
76  *
77  * Take a chance on using the standard calls
78  *************************************************************************/
79 #ifdef ultrix
80 # define IS_ULTRIX OSVERSION
81 #endif
82 
83 
84 /*************************************************************************
85  * AIX.
86  *************************************************************************/
87 #ifdef _AIX32
88 # define IS_AIX32 OSVERSION
89 #endif
90 
91 /*************************************************************************
92  * Sun
93  *************************************************************************/
94 
95 #if defined(sun)
96 #endif
97 
98 /*************************************************************************
99  * SCO OpenServer 5.0.5
100  *************************************************************************/
101 #ifdef sco
102 /* SCO doesn't define the S_ISSOCK POSIX macro to use in testing the
103    stat.st_mode structure member  - it appears as though a socket has
104    st_mode = 0020000 (same as character special) */
105 #ifndef S_ISSOCK
106 #define S_IFSOCK	0020000
107 #define S_ISSOCK(m)	(((m) & S_IFMT) == S_IFSOCK)
108 #endif
109 #endif
110 
111 /*************************************************************************
112  * Cray
113  *************************************************************************/
114 
115 #if defined(cray)
116 #define HAVE_SIGLONGJMP	1
117 
118 /* configure incorrectly chooses STATVFS */
119 #if defined(USE_STATFS_TYPE)
120 #undef  USE_STATFS_TYPE
121 #endif
122 
123 #define USE_STATFS_TYPE	SRV3_STATFS
124 #endif
125 
126 
127 /*************************************************************************/
128 #if defined(NeXT)
129 # define IS_NEXT OSVERSION
130 # define __STRICT_BSD__
131 #endif
132 
133 /*************************************************************************/
134 #if defined(__sgi) && defined(_SYSTYPE_SVR4)
135 # define IS_IRIX5 OSVERSION
136 #endif
137 
138 /*************************************************************************/
139 #if defined(__sgi) && defined(_SYSTYPE_SYSV)
140 #define IS_IRIX4 OSVERSION
141 #endif
142 
143 /*************************************************************************/
144 #if defined(__linux__) || defined (__linux) || defined (LINUX)
145 # define IS_LINUX OSVERSION
146 #endif
147 
148 /*************************************************************************/
149 
150 #if defined(__convex__) /* Convex OS 11.0 - from w_stef */
151 # define IS_CONVEX OSVERSION
152 # define LPASS8 (L004000>>16)
153 #endif
154 
155 /*************************************************************************/
156 
157 #ifdef _AUX_SOURCE
158 # define IS_AUX OSVERSION
159 # define _POSIX_SOURCE
160 
161 # undef SETPROCTITLE
162 
163 #endif
164 
165 /*************************************************************************/
166 
167 #if defined(SNI) && defined(sinix)
168 # define IS_SINIX OSVERSION
169 #endif
170 
171 
172 /*************************************************************************/
173 #if defined(__svr4__) && !defined(SVR4)
174 # define SVR4 __svr4__
175 #endif
176 
177 /***************************************************************************
178  * Solaris SUNWorks CC compiler
179  *  man page indicates __SVR4 is defined, as is __unix, __sun
180  ***************************************************************************/
181 #if (defined(__SVR4) || defined(_SVR4_)) && !defined(SVR4)
182 # define SVR4 1
183 #endif
184 
185 /*************************************************************************/
186 #if defined(__bsdi__)
187 # define IS_BSDI OSVERSION
188 #endif
189 
190 /*************************************************************************/
191 
192 /*************************************************************************
193  * we also need some way of spotting IS_DATAGEN (Data Generals),
194  * and IS_SEQUENT (Sequent machines). Any suggestions?
195  * these ports probably don't work anymore...
196  *************************************************************************/
197 
198 /*************************************************************************
199  * END OF ARGH SECTION; next: overrides from the Makefile.
200  *************************************************************************/
201 /*************************
202  * STTY functions to use *
203  *************************/
204 #define SGTTYB  0
205 #define TERMIO  1
206 #define TERMIOS 2
207 
208 /*************************
209  * FSTYPE functions to use *
210  *************************/
211 
212 #define SVR3_STATFS       0
213 #define ULTRIX_STATFS     1
214 #define STATFS            2
215 #define STATVFS           3
216 
217 #if defined(MAKE_USE_STATFS)
218 # undef USE_STATFS
219 # define USE_STATFS MAKE_USE_STATFS
220 #endif
221 
222 #if defined(MAKE_USE_STTY)
223 # undef  USE_STTY
224 # define USE_STTY MAKE_USE_STTY
225 #endif
226 
227 
228 /*********************************************************************
229  * GET STANDARD INCLUDE FILES
230  * This is the one-size-fits-all include that should grab everthing.
231  * This has a horrible impact on compilation speed,  but then, do you
232  * want compilation speed or portability?
233  *
234  * Patrick Powell Thu Apr  6 07:21:10 PDT 1995
235  *********************************************************************
236  * If you do not have the following, you are doomed. Or at least
237  * going to have an uphill hard time.
238  * NOTE: string.h might also be strings.h on some very very odd systems
239  *
240  * Patrick Powell Thu Apr  6 07:21:10 PDT 1995
241  *********************************************************************/
242 
243 /*********************************************************************
244  * yuck -- this is a nightmare! half-baked-ANSI systems are poxy (jm)
245  *
246  * Note that configure checks for absolute compliance, i.e.-
247  * older versions of SUNOS, HP-UX, do not meet this.
248  *
249  * Patrick Powell Thu Apr  6 07:21:10 PDT 1995
250  *********************************************************************/
251 
252 
253 #ifdef HAVE_UNISTD_H
254 # include <unistd.h>
255 #else
256   extern int dup2 ();
257   extern int execve ();
258   extern uid_t geteuid (), getegid ();
259 #if !defined(_AIX51)
260   extern int setgid (), getgid ();
261 #endif
262 #endif
263 
264 
265 #ifdef HAVE_STDLIB_H
266 # include <stdlib.h>
267 #else
268   char *getenv( char * );
269   void abort(void);
270 #endif
271 
272 #include <sys/types.h>
273 #include <stdio.h>
274 #include <string.h>
275 #if defined(HAVE_STRINGS_H)
276 # include <strings.h>
277 #endif
278 #include <sys/param.h>
279 #include <sys/socket.h>
280 #include <netinet/in.h>
281 #include <netdb.h>
282 #include <arpa/inet.h>
283 #include <sys/un.h>
284 
285 #include <sys/stat.h>
286 #include <pwd.h>
287 #if defined(HAVE_SYS_SIGNAL_H)
288 #  include <sys/signal.h>
289 #endif
290 #include <signal.h>
291 #include <sys/wait.h>
292 #include <ctype.h>
293 
294 #include <errno.h>
295 #include <grp.h>
296 
297 #ifdef HAVE_MEMORY_H
298 #include <memory.h>
299 #endif
300 
301 #ifndef HAVE_STRCHR
302 # define strchr			index
303 # define strrchr		rindex
304 #endif
305 
306 #ifndef HAVE_SOCKLEN_T
307 typedef int socklen_t;
308 #endif
309 
310 /* case insensitive compare for OS without it */
311 #if !defined(HAVE_STRCASECMP)
312  int strcasecmp (const char *s1, const char *s2);
313 #endif
314 #if !defined(HAVE_STRNCASECMP)
315  int strncasecmp (const char *s1, const char *s2, int len );
316 #endif
317 #if !defined(HAVE_STRCASECMP_DEF)
318  int strcasecmp (const char *s1, const char *s2 );
319 #endif
320 
321 
322 /*********************************************************************
323  * directory management is nasty.  There are two standards:
324  * struct directory and struct dirent.
325  * Solution:  macros + a typedef.
326  * Patrick Powell Thu Apr  6 07:44:50 PDT 1995
327  *
328  *See GNU autoconf documentation for this little AHEM gem... and others
329  *  too obnoxious to believe
330  *********************************************************************/
331 
332 #if HAVE_DIRENT_H
333 # include <dirent.h>
334 # define NLENGTH(dirent) strlen((dirent)->d_name)
335 #else
336 # define dirent direct
337 # define NLENGTH(dirent) (dirent)->d_namlen
338 # if HAVE_SYS_NDIR_H
339 #  include <sys/ndir.h>
340 # endif
341 # if HAVE_SYS_DIR_H
342 #  include <sys/dir.h>
343 # endif
344 # if HAVE_NDIR_H
345 #  include <ndir.h>
346 # endif
347 #endif
348 
349 typedef struct dirent plp_dir_t;
350 
351 /*********************************************************************
352  * malloc strikes again. Definition is a la ANSI C.  However,
353  * You may need to edit this on historical systems.
354  * Patrick Powell Thu Apr  6 07:47:54 PDT 1995
355  *********************************************************************/
356 
357 #if !defined(HAVE_STDLIB_H)
358 # ifdef HAVE_MALLOC_H
359 #   include <malloc.h>
360 # else
361    void *malloc(size_t);
362    void free(void *);
363 # endif
364 #endif
365 
366 /*********************************************************************
367  * Note the <time.h> may already be included by some previous
368  * lines.  You may need to edit this by hand.
369  * Better solution is to put include guards in all of the include files.
370  * Patrick Powell Thu Apr  6 07:55:58 PDT 1995
371  *********************************************************************/
372 
373 #ifdef TIME_WITH_SYS_TIME
374 # include <sys/time.h>
375 # include <time.h>
376 #else
377 # ifdef HAVE_SYS_TIME_H
378 #   include <sys/time.h>
379 # else
380 #   include <time.h>
381 # endif
382 #endif
383 
384 #ifdef HAVE_SYS_FILE_H
385 # include <sys/file.h>
386 #endif
387 
388 #ifdef HAVE_SYS_RESOURCE_H
389 # include <sys/resource.h>
390 #endif
391 
392 #ifdef HAVE_SYS_FCNTL_H
393 # include <sys/fcntl.h>
394 #endif
395 #ifdef HAVE_FCNTL_H
396 #  include <fcntl.h>
397 #endif
398 
399 /*
400  * we use the FCNTL code if we have it
401  * We want you to define F_SETLK, etc.  If they are not defined,
402  *  Then you better put a system dependent configuration
403  *  in and define them.
404  */
405 #if defined(HAVE_FCNTL) && ! defined(F_SETLK)
406 /*ABORT: "defined(HAVE_FCNTL) && ! defined(F_SETLK)"*/
407 #undef HAVE_FCNTL
408 #endif
409 
410 #if defined(HAVE_LOCKF) && ! defined(F_LOCK)
411 /*ABORT: "defined(HAVE_LOCKF) && ! defined(F_LOCK)"*/
412 /* You must fix this up */
413 #undef HAVE_LOCKF
414 #endif
415 
416 #if defined(HAVE_FLOCK) && ! defined(LOCK_EX)
417 /*AB0RT: "defined(HAVE_FLOCK) && ! defined(LOCK_EX)"*/
418 /* You must fix this up */
419 #undef HAVE_FLOCK
420 #endif
421 
422 #ifdef HAVE_LIMITS_H
423 #include <limits.h>
424 #endif
425 
426 /* 4.2 BSD systems */
427 #ifndef S_IRUSR
428 # define S_IRUSR S_IREAD
429 # define S_IWUSR S_IWRITE
430 # define S_IXUSR S_IEXEC
431 # define S_IXGRP (S_IEXEC >> 3)
432 # define S_IXOTH (S_IEXEC >> 6)
433 #endif
434 
435 #ifndef S_ISLNK
436 # define S_ISLNK(mode) (((mode) & S_IFLNK) == S_IFLNK)
437 #endif
438 #ifndef S_ISREG
439 # define S_ISREG(mode) (((mode) & S_IFREG) == S_IFREG)
440 #endif
441 #ifndef S_ISDIR
442 # define S_ISDIR(mode) (((mode) & S_IFDIR) == S_IFDIR)
443 #endif
444 
445 
446 /* 4.2 BSD systems */
447 #ifndef SEEK_SET
448 # define SEEK_SET 0
449 # define SEEK_CUR 1
450 # define SEEK_END 2
451 #endif
452 
453 #ifndef HAVE_KILLPG
454 # define killpg(pg,sig)	((int) kill ((pid_t)(-(pg)), (sig)))
455 #else
456 extern int killpg(pid_t pgrp, int sig);
457 #endif
458 
459 /***********************************************************************
460  * wait() stuff: most recent systems support a compatability version
461  * of "union wait", but it's not as fully-featured as the recent stuff
462  * that uses an "int *". However, we want to keep support for the
463  * older BSD systems as much as possible, so it's still supported;
464  * however, if waitpid() exists, we're POSIX.1 compliant, and we should
465  * not use "union wait". (hack hack hack) (jm)
466  *
467  * I agree.  See the waitchild.c code for a tour through the depths of
468  * portability hell.
469  *
470  * Patrick Powell Thu Apr  6 08:03:58 PDT 1995
471  *
472  ***********************************************************************/
473 
474 #ifdef HAVE_WAITPID
475 # undef HAVE_UNION_WAIT		/* and good riddance */
476 #endif
477 
478 /***************************************************************************
479  * HAVE_UNION_WAIT will be def'd by configure if it's in <sys/wait.h>,
480  * and isn't just there for compatibility (like it is on HP/UX).
481  ***************************************************************************/
482 
483 #ifdef HAVE_UNION_WAIT
484 typedef union wait		plp_status_t;
485 /*
486  * with some BSDish systems, there are already #defines for this,
487  * so we should use them if they're there.
488  */
489 # ifndef WCOREDUMP
490 #  define WCOREDUMP(x)	((x).w_coredump)
491 # endif
492 # ifndef WEXITSTATUS
493 #  define WEXITSTATUS(x)	((x).w_retcode)
494 # endif
495 # ifndef WTERMSIG
496 #  define WTERMSIG(x)	((x).w_termsig)
497 # endif
498 # ifndef WIFSTOPPED
499 #  define WIFSTOPPED(x)	((x).w_stopval == WSTOPPED)
500 # endif
501 # ifndef WIFEXITED
502 #  define WIFEXITED(x)	((x).w_stopval == WEXITED)
503 # endif
504 
505 #else
506   typedef int			plp_status_t;
507 /* The POSIX defaults for these macros. (this is cheating!) */
508 # ifndef WTERMSIG
509 #  define WTERMSIG(x)	((x) & 0x7f)
510 # endif
511 # if defined(_AIX52)
512 #  undef  WTERMSIG
513 #  define WTERMSIG(__x)    (WIFSIGNALED(__x) ? (int)((((unsigned int)__x) >> 16) & 0xff) : -1)
514 # endif
515 # ifndef WCOREDUMP
516 #  define WCOREDUMP(x)	((x) & 0x80)
517 # endif
518 # if !defined(WEXITSTATUS)
519 #  define WEXITSTATUS(x)	(((x) >> 8) & 0xff)
520 # endif
521 # if defined(_AIX52)
522 #  undef  WEXITSTATUS
523 #  define WEXITSTATUS(__x) (WIFEXITED(__x) ? (int)((((unsigned int)__x) >> 8) & 0xff) : -1)
524 # endif
525 
526 # ifndef WIFSIGNALED
527 #  define WIFSIGNALED(x)	(WTERMSIG (x) != 0)
528 # endif
529 # ifndef WIFEXITED
530 #  define WIFEXITED(x)	(WTERMSIG (x) == 0)
531 # endif
532 #endif /* HAVE_UNION_WAIT */
533 
534 /***********************************************************************
535  * SVR4: SIGCHLD is really SIGCLD; #define it here.
536  * PLP lpd _does_ handle the compatibility semantics properly
537  * (Advanced UNIX Programming p. 281).
538  ***********************************************************************/
539 
540 #if !defined(SIGCHLD) && defined(SIGCLD)
541 # define SIGCHLD			SIGCLD
542 #endif
543 
544 
545 /***********************************************************************
546  * configure will set RETSIGTYPE to the type returned by signal()
547  ***********************************************************************/
548 
549 typedef RETSIGTYPE plp_signal_t;
550 typedef plp_signal_t (*plp_sigfunc_t)(int) ;
551 
552 #ifndef HAVE_GETDTABLESIZE
553 # ifdef NOFILE
554 #  define getdtablesize()	NOFILE
555 # else
556 #  ifdef NOFILES_MAX
557 #   define getdtablesize()	NOFILES_MAX
558 #  endif
559 # endif
560 #endif
561 
562 #ifndef HAVE_STRDUP
563 # ifdef __STDC__
564    char *strdup(const char*);
565 # else
566    char *strdup();
567 # endif
568 #endif
569 
570 #ifndef IPPORT_RESERVED
571 #define IPPORT_RESERVED 1024
572 #endif
573 
574 
575 /* varargs declarations: */
576 
577 #if defined(HAVE_STDARG_H)
578 # include <stdarg.h>
579 # define HAVE_STDARGS    /* let's hope that works everywhere (mj) */
580 # define VA_LOCAL_DECL   va_list ap;
581 # define VA_START(f)     va_start(ap, f)
582 # define VA_SHIFT(v,t)	;	/* no-op for ANSI */
583 # define VA_END          va_end(ap)
584 #else
585 # if defined(HAVE_VARARGS_H)
586 #  include <varargs.h>
587 #  undef HAVE_STDARGS
588 #  define VA_LOCAL_DECL   va_list ap;
589 #  define VA_START(f)     va_start(ap)		/* f is ignored! */
590 #  define VA_SHIFT(v,t)	v = va_arg(ap,t)
591 #  define VA_END		va_end(ap)
592 # else
593 XX ** NO VARARGS ** XX
594 # endif
595 #endif
596 
597 #if !defined(IS_ULTRIX) && defined(HAVE_SYSLOG_H)
598 # include <syslog.h>
599 #endif
600 #if defined(HAVE_SYS_SYSLOG_H)
601 # include <syslog.h>
602 #endif
603 # if !(defined(LOG_PID) && defined(LOG_NOWAIT) && defined(HAVE_OPENLOG))
604 #  undef HAVE_OPENLOG
605 # endif /* LOG_PID && LOG_NOWAIT */
606 
607 /*
608  *  Priorities (these are ordered)
609  */
610 #ifndef LOG_ERR
611 # define LOG_EMERG   0   /* system is unusable */
612 # define LOG_ALERT   1   /* action must be taken immediately */
613 # define LOG_CRIT    2   /* critical conditions */
614 # define LOG_ERR     3   /* error conditions */
615 # define LOG_WARNING 4   /* warning conditions */
616 # define LOG_NOTICE  5   /* normal but signification condition */
617 # define LOG_INFO    6   /* informational */
618 # define LOG_DEBUG   7   /* debug-level messages */
619 #endif
620 
621 #ifdef LOG_LPR
622 # define SYSLOG_FACILITY LOG_LPR
623 #else
624 # ifdef LOG_LOCAL0
625 #  define SYSLOG_FACILITY LOCAL0
626 # else
627 #  define SYSLOG_FACILITY (0) /* for Ultrix -- facilities aren't supported */
628 # endif
629 #endif
630 
631 /*************************************************************************
632  * If we have SVR4 and no setpgid() then we need getpgrp()
633  *************************************************************************/
634 #if defined(SVR4) || defined(__alpha__)
635 # undef HAVE_SETPGRP_0
636 #endif
637 
638 /*
639  * NONBLOCKING Open and IO - different flags for
640  * different systems
641  */
642 
643 #define NONBLOCK (O_NDELAY|O_NONBLOCK)
644 
645 /* we no longer set HPUX, so this cannot be done automatically,
646  * unless knowing why it was here. is O_NDELAY not defined there?
647  * something else?
648 Hif defined(HPUX) && HPUX<110
649 H  undef NONBLOCK
650 H  define NONBLOCK (O_NONBLOCK)
651 Hendif
652 */
653 
654 /*********************************************************************
655  * AIX systems need this
656  *********************************************************************/
657 
658 #if defined(HAVE_SYS_SELECT_H)
659 # include <sys/select.h>
660 #endif
661 
662 /**********************************************************************
663  *  Signal blocking
664  **********************************************************************/
665 #ifdef HAVE_SIGPROCMASK
666 /* a signal set */
667 #define plp_block_mask sigset_t
668 #else
669 /* an integer */
670 #define plp_block_mask int
671 #endif
672 
673 /**********************************************************************
674  *  Select() problems
675  **********************************************************************/
676 #ifdef HAVE_SELECT_H
677 #include <select.h>
678 #endif
679 
680 /**********************************************************************
681  * IPV6 and newer versions
682  **********************************************************************/
683 #if !defined(HAVE_INET_PTON)
684 int inet_pton( int family, const char *strptr, void *addr );
685 #endif
686 #if !defined(HAVE_INET_NTOP)
687 const char *inet_ntop( int family, const void *addr, char *strptr, size_t len );
688 #endif
689 
690 
691 /*****************************************************
692  * Internationalisation of messages, using GNU gettext
693  *****************************************************/
694 
695 #if HAVE_LOCALE_H
696 # include <locale.h>
697 #else
698 # define setlocale(category, locale)
699 #endif
700 
701 #if ENABLE_NLS
702 # include <libintl.h>
703 # define _(Text) gettext(Text)
704 # ifdef gettext_noop
705 #  define N_(Text) gettext_noop(Text)
706 # else
707 #  define N_(Text) Text
708 # endif
709 #else
710 # define _(Text) Text
711 # define N_(Text) Text
712 # define ngettext(Singular, Plural, n) ((n==1)?(Singular):(Plural))
713 # define textdomain(Domain)
714 # define bindtextdomain(Package, Directory)
715 #endif
716 
717 
718 /**********************************************************************
719  *  Cygwin Definitions
720  **********************************************************************/
721 #ifdef __CYGWIN__
722 #define ROOTUID 18
723 #else
724 #define ROOTUID 0
725 #endif
726 
727 #ifndef HAVE_FLOCK_DEF
728 extern int flock( int fd, int operation );
729 #endif
730 
731 #if !defined(HAVE_SYSLOG_DEF)
732 extern void syslog(int, const char *, ...);
733 #endif
734 #if !defined(HAVE_OPENLOG_DEF)
735 extern int openlog( const char *ident, int logopt, int facility );
736 #endif
737 
738 #ifdef IS_AIX32
739 extern int seteuid(uid_t);
740 extern int setruid(uid_t);
741 #if !defined(_AIX51) && !defined(_AIX52)
742 extern int setenv(char *, char *, int);
743 #endif
744 #endif
745 
746 
747 /* IPV6 structures define */
748 
749 #if defined(AF_INET6)
750 # if defined(IN_ADDR6)
751 #  define in6_addr in_addr6
752 # endif
753 #endif
754 
755 #if defined(HAVE_ARPA_NAMESER_H)
756 # include <arpa/nameser.h>
757 #endif
758 #if defined(HAVE_RESOLV_H)
759 # include <resolv.h>
760 #endif
761 
762 #ifdef HAVE_INNETGR
763 #if !defined(HAVE_INNETGR_DEF)
764 extern int innetgr(const char *netgroup,
765     const char *machine, const char *user, const char *domain);
766 #endif
767 #endif
768 
769 
770 #define Cast_int_to_voidstar(v) ((void *)(long)(v))
771 #define Cast_ptr_to_int(v) ((int)(long)(v))
772 #define Cast_ptr_to_long(v) ((long)(v))
773 
774 # define FPRINTF safefprintf
775 # define STDOUT 1
776 # define STDERR 2
777 
778 #ifdef __GNUC__
779 # define PRINTFATTR(fmtofs,dotsofs) __attribute__ ((format (printf, fmtofs, dotsofs)))
780 # define NORETURN __attribute__ ((noreturn))
781 # define UNUSED __attribute__ ((unused))
782 #else
783 # define PRINTFATTR(fmtofs,dotsofs)
784 # define NORETURN
785 # define UNUSED
786 #endif
787 
788 #endif
789