home *** CD-ROM | disk | FTP | other *** search
- /*
- * common.h
- *
- * Copyright (c) 1992 Sun Microsystems, Inc.
- * Copyright (c) 1993 Zik Saleeba <zik@zikzak.apana.org.au>
- *
- * This header shared between the daemon and the client and
- * contains the portability code.
- * This implementation may be freely copied, modified, and
- * redistributed, provided that this comment is retained.
- */
-
- /* $Id: common.h,v 1.1 1997/10/26 07:31:23 lukeh Exp $ */
-
- #define MESSAGE_SEP "\n---< MESSAGE FOLLOWS >---\n"
- #define MSG_SEP (MESSAGE_SEP+1)
-
-
- /*
- * Portability considerations
- */
-
- #ifdef AIX
- #define USE_STRFTIME
- #define USE_SYSV_UTMP
- #define SIGHANDLER_TYPE int
- #define BSD_SIGHANDLERS
- #define NO_GETDTABLESIZE
- #define NEW_HEADERS
- #define NO_UNION_WAIT
- #define USE_LOCKF
- #endif
-
- #ifdef BSD
- #define USE_STRFTIME
- #define SIGHANDLER_TYPE int
- #define BSD_SIGHANDLERS
- #endif
-
- #ifdef BSD44
- #define USE_STRFTIME
- #define NEW_STRFTIME
- #define SIGHANDLER_TYPE void
- #define NEW_HEADERS
- #define NO_UNION_WAIT
- #define USE_SETSID
- #endif
-
- #ifdef IRIX
- #define USE_SETSID
- #define USE_SYSV_UTMP
- #define USE_STRFTIME
- #define NEW_STRFTIME
- #define IGNORE_CHILDREN
- #define SIGHANDLER_TYPE void
- #define GETHOSTNAME_NO_FQDN
- #define USE_LOCKF
- #define USE_MEMORY_H
- #define USE_MALLOC_H
- #define NEW_HEADERS
- #endif
-
- #ifdef LINUX
- #define USE_SETSID
- #define USE_STRFTIME
- #define NEW_STRFTIME
- #define USE_SYSV_UTMP
- #define IGNORE_CHILDREN
- #define SIGHANDLER_TYPE void
- #define USE_LOCKF
- #define USE_MEMORY_H
- #define USE_MALLOC_H
- #define NEW_HEADERS
- #endif
-
- #ifdef OLDBSD
- #define SIGHANDLER_TYPE int
- #define BSD_SIGHANDLERS
- #define NO_S_IWGRP
- #define NO_POSIX_STRFUNCS
- #define NO_POSIX_MEMFUNCS
- #endif
-
- #ifdef SUNOS3
- #define BSD_SIGHANDLERS
- #define SIGHANDLER_TYPE int
- #define NO_LIMITS_H
- #define NO_S_IWGRP
- #define USE_MALLOC_H
- #define NO_BROADCAST
- #define FD_SET(n,p) ((p)->fds_bits[(n)/32] |= (1<<((n)%32)))
- #define FD_CLR(n,p) ((p)->fds_bits[(n)/32] &= (1<<((n)%32)))
- #define FD_ISSET(n,p) ((p)->fds_bits[(n)/32] & (1<<((n)%32)))
- #define FD_ZERO(p) bzero(p,sizeof(p))
- #define NO_POSIX_STRFUNCS
- #endif
-
- #ifdef SUNOS4
- #define BSD_SIGHANDLERS
- #define SIGHANDLER_TYPE int
- #define NO_LIMITS_H
- #define USE_MALLOC_H
- #define NO_STRCASECMP
- #define NO_POSIX_STRFUNCS
- #endif
-
- #ifdef SVR4
- #define USE_SETSID
- #define USE_SYSV_UTMP
- #define USE_UTMPX
- #define USE_STRFTIME
- #define NEW_STRFTIME
- #define IGNORE_CHILDREN
- #define SIGHANDLER_TYPE void
- #define NO_GETDTABLESIZE
- #define GETHOSTNAME_NO_FQDN
- #define USE_LOCKF
- #define USE_SYSTEMINFO
- #define USE_SOCKIO_H
- #define NO_SYS_FILE_H
- #define USE_MEMORY_H
- #define USE_MALLOC_H
- #define NEW_HEADERS
- #define NO_STRCASECMP
- #endif
-
- #ifdef ULTRIX
- #define USE_STRFTIME
- #define SIGHANDLER_TYPE int
- #define BSD_SIGHANDLERS
- #define USE_MEMORY_H
- #define USE_MALLOC_H
- #endif
-
- #ifndef SIGHANDLER_TYPE
- error You MUST choose a system type before you compile
- #endif
-
-
- /*
- * Include files
- */
-
- #include <sys/types.h>
- #include <sys/time.h>
- #include <sys/stat.h>
- #include <sys/socket.h>
- #include <netinet/in.h>
- #include <net/if.h>
- #include <arpa/inet.h>
- #include <netdb.h>
- #include <stdio.h>
- #include <fcntl.h>
- #include <string.h>
- #include <signal.h>
- #include <ctype.h>
- #include <unistd.h>
- #include <pwd.h>
- #include <sys/param.h>
- #include <errno.h>
-
- #ifdef NEW_HEADERS
- #include <stdlib.h>
- #endif
-
- #ifdef USE_UTMPX
- #include <utmpx.h>
- #else
- #include <utmp.h>
- #endif
-
- #ifdef USE_SOCKIO_H
- #include <sys/sockio.h>
- #else
- #include <sys/ioctl.h>
- #endif
-
- #ifndef NO_SYS_FILE_H
- #include <sys/file.h>
- #endif
-
- #ifdef USE_SYSTEMINFO
- #include <sys/utsname.h>
- #include <sys/systeminfo.h>
- #endif
-
- #ifdef NO_GETDTABLESIZE
- #include <sys/select.h>
- #endif
-
- #ifdef BSD_SIGHANDLERS
- #include <sys/wait.h>
- #endif
-
- #ifndef NO_LIMITS_H
- #include <limits.h>
- #endif
-
- #ifdef USE_MALLOC_H
- #include <malloc.h>
- #endif
-
- #ifdef USE_MEMORY_H
- #include <memory.h>
- #endif
-
- #ifndef _PATH_UTMP
- #ifndef UTMP_FILE
- #define _PATH_UTMP "/etc/utmp"
- #else
- #define _PATH_UTMP UTMP_FILE
- #endif
- #endif
-
- #ifndef PATH_MAX
- #ifdef MAXPATHLEN
- #define PATH_MAX MAXPATHLEN
- #else
- #define PATH_MAX 256
- #endif
- #endif
-
- #ifndef MAXHOSTNAMELEN
- #define MAXHOSTNAMELEN 64
- #endif
-
- #define DEFAULT_DEST "console"
- #define MAX_LOCK_FAILS 180
-
- #ifndef NO_POSIX_MEMFUNCS
- #define MEMCMP(d,s,l) memcmp(d,s,l)
- #define MEMZERO(d,l) memset(d,'\0',l)
- #define MEMSET(d,c,l) memset(d,c,l)
- #define MEMCPY(d,s,l) memcpy(d,s,l)
- #else
- #define MEMCMP(d,s,l) bcmp(d,s,l)
- #define MEMZERO(d,l) bzero(d,l)
- #define MEMSET(d,c,l) compat_memset(d,c,l)
- #define MEMCPY(d,s,l) bcopy(s,d,l)
- #endif
-
- #ifndef NO_POSIX_STRFUNCS
- #define STRCHR(s,c) strchr(s,c)
- #define STRSTR(d,s) strstr(d,s)
- #else
- #define STRCHR(s,c) index(s,c)
- #define STRSTR(d,s) compat_strstr(d,s)
- #endif
-
- #ifndef NO_STRCASECMP
- #define STRCASECMP(a,b) strcasecmp(a,b)
- #define STRNCASECMP(a,b,n) strncasecmp(a,b,n)
- #else
- #define STRCASECMP(a,b) compat_strcasecmp(a,b)
- #define STRNCASECMP(a,b,n) compat_strncasecmp(a,b,n)
- #endif
-
- #ifdef SECURE
- #define BIND(a,b,c) bindresvport(a,b,c)
- #else
- #define BIND(a,b,c) bind(a,b,c)
- #endif
-