UPS: apcupsd clean sources
[tomato.git] / release / src / router / apcupsd / include / apc_config.h
blobb3dca9c3defd1a8eba5340a17e1cb09fc9b7c20a
1 /*
2 * apc_config.h
4 * Platform compatibility cruft.
6 * Contributed by Riccardo Facchetti <riccardo@master.oasi.gpa.it>
7 * Modify it accordingly to configure.in file. Do _not_ use it for
8 * apcupsd-specific things, just for configure.
9 */
12 * Copyright (C) 1999-2002 Riccardo Facchetti <riccardo@master.oasi.gpa.it>
13 * Copyright (C) 1996-1999 Andre M. Hedrick <andre@suse.com>
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of version 2 of the GNU General
17 * Public License as published by the Free Software Foundation.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 * General Public License for more details.
24 * You should have received a copy of the GNU General Public
25 * License along with this program; if not, write to the Free
26 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
27 * MA 02111-1307, USA.
30 #ifndef _APC_CONFIG_H
31 #define _APC_CONFIG_H
33 #ifndef HAVE_STRFTIME
34 # define strftime(msg, max, format, tm) \
35 strncpy(msg, "time not available", max)
36 #endif /* !HAVE_STRFTIME */
38 /*
39 * wait macros.
41 #ifndef WEXITSTATUS
42 # define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)
43 #endif
44 #ifndef WIFEXITED
45 # define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
46 #endif
48 #ifndef HAVE_SOCKLEN_T
49 # define socklen_t unsigned int
50 #endif
52 /* Alpha Tru64 */
53 #ifdef HAVE_OSF1_OS
54 # define _SEM_SEMUN_UNDEFINED 1
55 #endif
57 #ifdef HAVE_HPUX_OS
58 # define _SEM_SEMUN_UNDEFINED 1
61 * These defines, related to serial devices, need to be clarified for HP-UX
62 * operating system.
64 # define TIOCM_LE 0
65 # define TIOCM_ST 0
66 # define TIOCM_SR 0
67 #endif
69 /* NetBSD */
70 #ifdef HAVE_NETBSD_OS
71 # define _SEM_SEMUN_UNDEFINED 1
72 #endif
74 #ifdef HAVE_SUN_OS
75 # define _SEM_SEMUN_UNDEFINED 1
76 #endif
78 #ifdef HAVE_AIX_OS
79 # define _SEM_SEMUN_UNDEFINED 1
80 #endif
82 #ifdef HAVE_OPENSERVER_OS
83 # define _SEM_SEMUN_UNDEFINED 1
84 #endif
86 #ifndef SHUT_RDWR
87 # define SHUT_RDWR 2 /* for socket shutdown() calls */
88 #endif
90 #ifdef SETPGRP_VOID
91 # define SETPGRP_ARGS(x, y) /* No arguments */
92 #else
93 # define SETPGRP_ARGS(x, y) x,y
94 #endif
96 /* If we have it, the init is not needed */
97 #ifdef HAVE_SETPROCTITLE
98 # undef init_proctitle
99 # define init_proctitle(x)
100 #endif
102 #ifndef ENABLE_NLS
103 # define textdomain(x)
104 #endif
106 #ifndef O_NDELAY
107 # define O_NDELAY 0
108 #endif
111 * For HP-UX the definition of FILENAME_MAX seems not conformant with
112 * POSIX standard. To avoid any problem we are forced to define a
113 * private macro. This accounts also for other possible problematic OSes.
114 * If none of the standard macros is defined, fall back to 256.
116 #if defined(FILENAME_MAX) && FILENAME_MAX > 255
117 # define APC_FILENAME_MAX FILENAME_MAX
118 #elif defined(PATH_MAX) && PATH_MAX > 255
119 # define APC_FILENAME_MAX PATH_MAX
120 #elif defined(MAXPATHLEN) && MAXPATHLEN > 255
121 # define APC_FILENAME_MAX MAXPATHLEN
122 #else
123 # define APC_FILENAME_MAX 256
124 #endif
126 /* ETIME not on BSD, incl. Darwin */
127 #ifndef ETIME
128 # define ETIME ETIMEDOUT
129 #endif
132 * apcupsd requires SHM_RDONLY even if compiling for pthreads: the
133 * attach_ipc interface is a wrapper for both.
135 #if !defined(HAVE_SYS_SHM_H) && !defined SHM_RDONLY
136 # define SHM_RDONLY O_RDONLY
137 #endif
139 /* If no system localtime_r(), forward declaration of our internal substitute. */
140 #if !defined(HAVE_LOCALTIME_R)
141 extern struct tm *localtime_r(const time_t *timep, struct tm *tm);
142 #endif
144 /* If no system inet_pton(), forward declaration of our internal substitute. */
145 #if !defined(HAVE_INETPTON)
147 /* Define constants based on RFC 883, RFC 1034, RFC 1035 */
148 #define NS_PACKETSZ 512 /* maximum packet size */
149 #define NS_MAXDNAME 1025 /* maximum domain name */
150 #define NS_MAXCDNAME 255 /* maximum compressed domain name */
151 #define NS_MAXLABEL 63 /* maximum length of domain label */
152 #define NS_HFIXEDSZ 12 /* #/bytes of fixed data in header */
153 #define NS_QFIXEDSZ 4 /* #/bytes of fixed data in query */
154 #define NS_RRFIXEDSZ 10 /* #/bytes of fixed data in r record */
155 #define NS_INT32SZ 4 /* #/bytes of data in a u_int32_t */
156 #define NS_INT16SZ 2 /* #/bytes of data in a u_int16_t */
157 #define NS_INT8SZ 1 /* #/bytes of data in a u_int8_t */
158 #define NS_INADDRSZ 4 /* IPv4 T_A */
159 #define NS_IN6ADDRSZ 16 /* IPv6 T_AAAA */
160 #define NS_CMPRSFLGS 0xc0 /* Flag bits indicating name compression. */
161 #define NS_DEFAULTPORT 53 /* For both TCP and UDP. */
162 extern int inet_pton(int af, const char *src, void *dst);
163 #endif
165 /* Determine if the C(++) compiler requires complete function prototype */
166 #ifndef __P
167 # if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
168 # define __P(x) x
169 # else
170 # define __P(x) ()
171 # endif
172 #endif
174 #ifndef __cplusplus
175 #define bool int
176 #define true 1
177 #define false 0
178 #endif
180 #endif /* _APC_CONFIG */