Release bumped to "gts4".
[tac_plus.git] / tac_plus.h
1 #ifndef TAC_PLUS_H
2 #define TAC_PLUS_H 1
3
4 /*
5    Copyright (c) 1995-1998 by Cisco systems, Inc.
6
7    Permission to use, copy, modify, and distribute this software for
8    any purpose and without fee is hereby granted, provided that this
9    copyright and permission notice appear on all copies of the
10    software and supporting documentation, the name of Cisco Systems,
11    Inc. not be used in advertising or publicity pertaining to
12    distribution of the program without specific prior permission, and
13    notice be given in supporting documentation that modification,
14    copying and distribution is by permission of Cisco Systems, Inc.
15
16    Cisco Systems, Inc. makes no representations about the suitability
17    of this software for any purpose.  THIS SOFTWARE IS PROVIDED ``AS
18    IS'' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
19    WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
20    FITNESS FOR A PARTICULAR PURPOSE.
21 */
22
23
24 #ifdef HAVE_CONFIG_H
25 #include "config.h"
26 #endif
27
28
29 /*
30  * If you are defining a system from scratch, the following may be useful.
31  * Otherwise, just use the system definitions below this section.
32  */
33
34 /* Define this for minor include file differences on SYSV-based systems */
35 /* #define SYSV */
36
37 /* Define this if your sys_errlist is defined using const */
38 /* #define CONST_SYSERRLIST */
39
40 /* Do you need tacacs+ versions of bzero etc. */
41 /* #define NEED_BZERO */
42
43 /* Define this if your wait call status is a union as opposed to an int */
44 /* #define UNIONWAIT */
45
46 /* Define this if you need a getdtablesize routine defined */
47 /* #define GETDTABLESIZE */
48
49 /* Define this if your system does not reap children automatically
50  * when you ignore SIGCLD */
51 /* #define REAPCHILD */
52
53 /* Define this if you have DES routines you can link to for ARAP (See
54  * the user's guide for more details).
55  */
56 /* #define ARAP_DES */
57
58 #define VERSION_TAIL " (Extended Tac_plus)"
59
60 /*
61  * System definitions.
62  */
63
64 #ifdef NETBSD
65 #define CONST_SYSERRLIST
66 #endif
67
68 #ifdef AIX
69
70 /*
71  * The only way to properly compile BSD stuff on AIX is to define a
72  * "bsdcc" compiler on your system. See /usr/lpp/bos/bsdport on your
73  * system for details. People who do NOT do this tell me that the code
74  * still compiles but that it then doesn't behave correctly e.g. child
75  * processes are not reaped correctly. Don't expect much sympathy if
76  * you do this.
77  */
78
79 #define _BSD 1
80 #define _BSD_INCLUDES
81 #define UNIONWAIT
82 #endif /* AIX */
83
84 #ifdef LINUX
85 #define REAPCHILD
86 #ifdef GLIBC
87 #define CONST_SYSERRLIST
88 #endif
89 #endif /* LINUX */
90
91 #ifdef MIPS
92 #define SYSV
93 #define GETDTABLESIZE
94 #define REAPCHILD
95 #define NEED_BZERO
96 #endif /* MIPS */
97
98 #ifdef SOLARIS
99 #define SYSV
100 #define GETDTABLESIZE
101 #define REAPCHILD
102 #define NEED_BZERO
103 #endif /* SOLARIS */
104
105 #ifdef HPUX
106 #define SYSV
107 #define GETDTABLESIZE
108 #define REAPCHILD
109 #endif /* HPUX */
110
111 #ifdef FREEBSD
112 #define CONST_SYSERRLIST
113 #endif
114
115 #define MD5_LEN           16
116 #ifdef MSCHAP
117 #define MSCHAP_DIGEST_LEN 49
118 #endif /* MSCHAP */
119
120 #ifdef SYSV
121 #ifdef HAVE_FCNTL_H
122 #include <fcntl.h>
123 #endif
124 #define index strchr
125 #endif  /* SYSV */
126
127 /* Sometimes are bzero/bcopy/bcmp declared as prototypes with non-void argument
128  * pointers. In such case we would generate too much warnings.
129  */
130 #include <string.h>
131 #ifdef HAVE_STRINGS_H
132 #include <strings.h>
133 #endif
134
135 #define bzero(s, n) bzero((void *)(s), (size_t)(n))
136 #define bcopy(src, dest, n) bcopy((const void *)(src), (void *)(dest), (size_t)(n))
137 #define bcmp(s1, s2, n) bcmp((const void *)(s1), (const void *)(s2), (size_t)(n))
138
139
140 #ifndef TACPLUS_PIDFILE
141 #define TACPLUS_PIDFILE "/var/run/tac_plus.pid"
142 #endif
143
144
145 /*
146  * You probably shouldn't be changing much below this line unless you really
147  * know what you are doing.
148  */
149
150 /* Stolen from pbmplus.h of netpbm: */
151
152 #if __STDC__
153 #define TAC_ARGS(alist) alist
154 #else /*__STDC__*/
155 #define TAC_ARGS(alist) ()
156 #endif /*__STDC__*/
157
158 /* Stolen from glib of Gnome/GTK+ environment: */
159
160 /* Provide macros to feature the GCC function attribute.
161  */
162 #if     __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
163 #define G_GNUC_PRINTF( format_idx, arg_idx )    \
164         __attribute__((format (printf, format_idx, arg_idx)))
165 #define G_GNUC_NORETURN                         \
166         __attribute__((noreturn))
167 #define G_GNUC_CONST                            \
168         __attribute__((const))
169 #define G_GNUC_UNUSED                           \
170         __attribute__((unused))
171 #else   /* !__GNUC__ */
172 #define G_GNUC_PRINTF( format_idx, arg_idx )
173 #define G_GNUC_NORETURN
174 #define G_GNUC_CONST
175 #define G_GNUC_UNUSED
176 #endif  /* !__GNUC__ */
177
178 /* Provide convenience macros for handling structure
179  * fields through their offsets.
180  * Project tac_plus changed "gulong" to "glong" to be able to recover
181  * original structure base from pointer to its member.
182  */
183 #define G_STRUCT_OFFSET(struct_type, member)                    \
184         ((long) ((char*) &((struct_type*) 0)->member))
185 #define G_STRUCT_MEMBER_P(struct_p, struct_offset)              \
186         ((void*) ((char*) (struct_p) + (long) (struct_offset)))
187 #define G_STRUCT_MEMBER(member_type, struct_p, struct_offset)   \
188         (*(member_type*) G_STRUCT_MEMBER_P ((struct_p), (struct_offset)))
189
190 /* reversed, in fact: for inside "member_p" calculate "struct" address */
191 #define TAC_MEMBER_STRUCT(struct_type, member_p, member)        \
192         (G_STRUCT_MEMBER(struct_type,member_p,-G_STRUCT_OFFSET(struct_type,member)))
193
194
195 /* <sys/param.h> may define MAX & MIN without checking whether they
196  * were previously already defined:
197  */
198 #ifdef HAVE_SYS_PARAM_H
199 #include <sys/param.h>
200 #endif
201
202 /* Provide definitions for some commonly used macros.
203  *  Some of them are only provided if they haven't already
204  *  been defined. It is assumed that if they are already
205  *  defined then the current definition is correct.
206  */
207 #ifndef NULL
208 #define NULL    ((void*) 0)
209 #endif
210
211 #undef  MAX
212 #define MAX(a, b)  (((a) > (b)) ? (a) : (b))
213
214 #undef  MIN
215 #define MIN(a, b)  (((a) < (b)) ? (a) : (b))
216
217
218 /* The following code is not needed or used. It exists solely to
219    prevent compilers from "helpfully" complaining that this source
220    file is empty, which upsets novices building the software */
221
222 #define TAC_SOURCEFILE_EMPTY \
223         static int dummy_unused G_GNUC_UNUSED = 0;
224
225
226 #define DOLLARSIGN '$'
227
228 /* Odds and ends */
229 #define STREQ(a,b) (strcmp(a,b)==0)
230 #define MAX_INPUT_LINE_LEN 255
231
232 /* miscellaneous */
233 #ifdef CONST_SYSERRLIST
234 extern const char *const sys_errlist[];
235 #else
236 extern char *sys_errlist[];
237 #endif
238
239
240 #endif /* TAC_PLUS_H */