1 /* $Id: defines.h,v 1.20 2001/11/19 09:23:52 kloczek Exp $ */
2 /* some useful defines */
7 #define ISDIGIT_LOCALE(c) (IN_CTYPE_DOMAIN (c) && isdigit (c))
9 /* Take care of NLS matters. */
15 # define setlocale(Category, Locale) /* empty */
18 #define gettext_noop(String) (String)
19 /* #define gettext_def(String) "#define String" */
23 # define _(Text) gettext (Text)
25 # undef bindtextdomain
26 # define bindtextdomain(Domain, Directory) /* empty */
28 # define textdomain(Domain) /* empty */
35 #else /* not STDC_HEADERS */
38 # define strrchr rindex
40 char *strchr(), *strrchr(), *strtok();
42 # define memcpy(d, s, n) bcopy((s), (d), (n))
44 #endif /* not STDC_HEADERS */
50 /* Solaris 2.4 defines __SVR4, but not SVR4 -j. */
59 #include <sys/types.h>
61 # include <sys/wait.h>
64 # define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)
67 # define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
74 #if TIME_WITH_SYS_TIME
75 # include <sys/time.h>
77 #else /* not TIME_WITH_SYS_TIME */
79 # include <sys/time.h>
83 #endif /* not TIME_WITH_SYS_TIME */
86 # define memzero(ptr, size) memset((void *)(ptr), 0, (size))
88 # define memzero(ptr, size) bzero((char *)(ptr), (size))
90 #define strzero(s) memzero(s, strlen(s)) /* warning: evaluates twice */
92 #ifdef HAVE_DIRENT_H /* DIR_SYSV */
94 # define DIRECT dirent
96 # ifdef HAVE_SYS_NDIR_H /* DIR_XENIX */
97 # include <sys/ndir.h>
99 # ifdef HAVE_SYS_DIR_H /* DIR_??? */
100 # include <sys/dir.h>
102 # ifdef HAVE_NDIR_H /* DIR_BSD */
105 # define DIRECT direct
111 * - /usr/include/shadow.h exists and includes the shadow group stuff.
112 * - /usr/include/shadow.h exists, but we use our own gshadow.h.
113 * - /usr/include/shadow.h doesn't exist, use our own shadow.h and gshadow.h.
117 #if defined(SHADOWGRP) && !defined(GSHADOW)
118 #include "gshadow_.h"
120 #else /* not HAVE_SHADOW_H */
123 #include "gshadow_.h"
125 #endif /* not HAVE_SHADOW_H */
126 #endif /* SHADOWPWD */
132 #define NGROUPS_MAX NGROUPS
134 #define NGROUPS_MAX 64
142 #define LOG_WARN LOG_WARNING
145 /* LOG_NOWAIT is deprecated */
150 /* LOG_AUTH is deprecated, use LOG_AUTHPRIV instead */
152 #define LOG_AUTHPRIV LOG_AUTH
155 /* cleaner than lots of #ifdefs everywhere - use this as follows:
156 SYSLOG((LOG_CRIT, "user %s cracked root", user)); */
158 /* Temporarily set LC_TIME to "C" to avoid strange dates in syslog.
159 This is a workaround for a more general syslog(d) design problem -
160 syslogd should log the current system time for each event, and not
161 trust the formatted time received from the unix domain (or worse,
165 char *saved_locale = setlocale(LC_ALL, NULL); \
167 saved_locale = strdup(saved_locale); \
169 setlocale(LC_TIME, "C"); \
171 if (saved_locale) { \
172 setlocale(LC_ALL, saved_locale); \
173 free(saved_locale); \
176 #else /* !HAVE_SETLOCALE */
177 #define SYSLOG(x) syslog x
178 #endif /* !HAVE_SETLOCALE */
180 #else /* !USE_SYSLOG */
182 #define SYSLOG(x) /* empty */
183 #define openlog(a,b,c) /* empty */
184 #define closelog() /* empty */
186 #endif /* !USE_SYSLOG */
188 /* The default syslog settings can now be changed here,
189 in just one place. */
191 #ifndef SYSLOG_OPTIONS
192 /* #define SYSLOG_OPTIONS (LOG_PID | LOG_CONS | LOG_NOWAIT) */
193 #define SYSLOG_OPTIONS (LOG_PID)
196 #ifndef SYSLOG_FACILITY
197 #define SYSLOG_FACILITY LOG_AUTHPRIV
200 #define OPENLOG(progname) openlog(progname, SYSLOG_OPTIONS, SYSLOG_FACILITY)
215 #ifdef STAT_MACROS_BROKEN
216 # define S_ISDIR(x) ((x) & S_IFMT) == S_IFDIR)
217 # define S_ISREG(x) ((x) & S_IFMT) == S_IFREG)
219 # define S_ISLNK(x) ((x) & S_IFMT) == S_IFLNK)
224 #define S_ISLNK(x) (0)
228 #define LCHOWN lchown
240 # include <termios.h>
241 # define STTY(fd, termio) tcsetattr(fd, TCSANOW, termio)
242 # define GTTY(fd, termio) tcgetattr(fd, termio)
243 # define TERMIO struct termios
245 #else /* assumed HAVE_TERMIO_H */
246 # include <sys/ioctl.h>
248 # define STTY(fd, termio) ioctl(fd, TCSETA, termio)
249 # define GTTY(fd, termio) ioctl(fd, TCGETA, termio)
250 # define TEMRIO struct termio
255 * Password aging constants
257 * DAY - seconds / day
258 * WEEK - seconds / week
259 * SCALE - seconds / aging unit
262 /* Solaris defines this in shadow.h */
264 #define DAY (24L*3600L)
275 /* Copy string pointed by B to array A with size checking. It was originally
276 in lmain.c but is _very_ useful elsewhere. Some setuid root programs with
277 very sloppy coding used to assume that BUFSIZ will always be enough... */
279 /* danger - side effects */
280 #define STRFCPY(A,B) \
281 (strncpy((A), (B), sizeof(A) - 1), (A)[sizeof(A) - 1] = '\0')
283 /* get rid of a few ugly repeated #ifdefs in pwent.c and grent.c */
284 /* XXX - this is ugly too, configure should test it and not check for
285 any hardcoded system names, if possible. --marekm */
286 #if defined(SVR4) || defined(AIX) || defined(__linux__)
287 #define SETXXENT_TYPE void
288 #define SETXXENT_RET(x) return
289 #define SETXXENT_TEST(x) x; if (0) /* compiler should optimize this away */
291 #define SETXXENT_TYPE int
292 #define SETXXENT_RET(x) return(x)
293 #define SETXXENT_TEST(x) if (x)
297 #define PASSWD_FILE "/etc/passwd"
301 #define GROUP_FILE "/etc/group"
306 #define SHADOW_FILE "/etc/shadow"
312 #define SGROUP_FILE "/etc/gshadow"
316 #define PASSWD_PAG_FILE PASSWD_FILE ".pag"
317 #define GROUP_PAG_FILE GROUP_FILE ".pag"
318 #define SHADOW_PAG_FILE SHADOW_FILE ".pag"
319 #define SGROUP_PAG_FILE SGROUP_FILE ".pag"
322 #define NULL ((void *) 0)
325 #ifdef sun /* hacks for compiling on SunOS */
328 extern char *strdup();
329 extern char *strerror();
333 #ifndef HAVE_SNPRINTF
334 #include "snprintf.h"
338 * string to use for the pw_passwd field in /etc/passwd when using
339 * shadow passwords - most systems use "x" but there are a few
340 * exceptions, so it can be changed here if necessary. --marekm
342 #ifndef SHADOW_PASSWD_STRING
343 #define SHADOW_PASSWD_STRING "x"
346 #endif /* _DEFINES_H_ */