rpm  5.2.1
About: RPM is a powerful and mature command-line driven package management system capable of installing, uninstalling, verifying, querying, and updating Unix software packages ("no longer Linux-centric"). Hint: The RPM homepage may offer newer releases (but in rpm format).
  Fossies Dox: rpm-5.2.1.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

defines.h
Go to the documentation of this file.
1 /*
2  * This file was originally distributed as part of
3  * shadow-utils-4.0.17-12.fc6.src.rpm and has been modified
4  * in WRLinux for inclusion in rpm.
5  */
6 
7 /* $Id: defines.h,v 1.3 2008/08/18 18:19:30 jbj Exp $ */
8 /* some useful defines */
9 
10 #ifndef _DEFINES_H_
11 #define _DEFINES_H_
12 
13 #define ISDIGIT_LOCALE(c) (IN_CTYPE_DOMAIN (c) && isdigit (c))
14 
15 #define gettext_noop(String) (String)
16 /* #define gettext_def(String) "#define String" */
17 
18 #if STDC_HEADERS
19 #else /* not STDC_HEADERS */
20 # ifndef HAVE_STRCHR
21 # define strchr index
22 # define strrchr rindex
23 char *strchr (), *strrchr (), *strtok ();
24 # endif
25 
26 # ifndef HAVE_MEMCPY
27 # define memcpy(d, s, n) bcopy((s), (d), (n))
28 # endif
29 #endif /* not STDC_HEADERS */
30 
31 #if HAVE_ERRNO_H
32 # include <errno.h>
33 #endif
34 
35 #ifndef WEXITSTATUS
36 # define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)
37 #endif
38 #ifndef WIFEXITED
39 # define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
40 #endif
41 
42 #ifdef HAVE_MEMSET
43 # define memzero(ptr, size) memset((void *)(ptr), 0, (size))
44 #else
45 # define memzero(ptr, size) bzero((char *)(ptr), (size))
46 #endif
47 #define strzero(s) memzero(s, strlen(s)) /* warning: evaluates twice */
48 
49 #ifdef HAVE_DIRENT_H /* DIR_SYSV */
50 # define DIRECT dirent
51 #else
52 # define DIRECT direct
53 #endif
54 
55 /*
56  * Possible cases:
57  * - /usr/include/shadow.h exists and includes the shadow group stuff.
58  * - /usr/include/shadow.h exists, but we use our own gshadow.h.
59  * - /usr/include/shadow.h doesn't exist, use our own shadow.h and gshadow.h.
60  */
61 #if HAVE_SHADOW_H
62 #include <shadow.h>
63 #if defined(SHADOWGRP) && !defined(GSHADOW)
64 #include "gshadow_.h"
65 #endif
66 #else /* not HAVE_SHADOW_H */
67 #include "shadow_.h"
68 #ifdef SHADOWGRP
69 #include "gshadow_.h"
70 #endif
71 #endif /* not HAVE_SHADOW_H */
72 
73 #ifndef NGROUPS_MAX
74 #ifdef NGROUPS
75 #define NGROUPS_MAX NGROUPS
76 #else
77 #define NGROUPS_MAX 64
78 #endif
79 #endif
80 
81 #ifdef USE_SYSLOG
82 #include <syslog.h>
83 
84 #ifndef LOG_WARN
85 #define LOG_WARN LOG_WARNING
86 #endif
87 
88 /* LOG_NOWAIT is deprecated */
89 #ifndef LOG_NOWAIT
90 #define LOG_NOWAIT 0
91 #endif
92 
93 /* LOG_AUTH is deprecated, use LOG_AUTHPRIV instead */
94 #ifndef LOG_AUTHPRIV
95 #define LOG_AUTHPRIV LOG_AUTH
96 #endif
97 
98 /* cleaner than lots of #ifdefs everywhere - use this as follows:
99  SYSLOG((LOG_CRIT, "user %s cracked root", user)); */
100 #if ENABLE_NLS
101 /* Temporarily set LC_TIME to "C" to avoid strange dates in syslog.
102  This is a workaround for a more general syslog(d) design problem -
103  syslogd should log the current system time for each event, and not
104  trust the formatted time received from the unix domain (or worse,
105  UDP) socket. -MM */
106 #define SYSLOG(x) \
107  do { \
108  char *saved_locale = setlocale(LC_ALL, NULL); \
109  if (saved_locale) \
110  saved_locale = strdup(saved_locale); \
111  if (saved_locale) \
112  setlocale(LC_TIME, "C"); \
113  syslog x ; \
114  if (saved_locale) { \
115  setlocale(LC_ALL, saved_locale); \
116  free(saved_locale); \
117  } \
118  } while (0)
119 #else /* !ENABLE_NLS */
120 #define SYSLOG(x) syslog x
121 #endif /* !ENABLE_NLS */
122 
123 #else /* !USE_SYSLOG */
124 
125 #define SYSLOG(x) /* empty */
126 #define openlog(a,b,c) /* empty */
127 #define closelog() /* empty */
128 
129 #endif /* !USE_SYSLOG */
130 
131 /* The default syslog settings can now be changed here,
132  in just one place. */
133 
134 #ifndef SYSLOG_OPTIONS
135 /* #define SYSLOG_OPTIONS (LOG_PID | LOG_CONS | LOG_NOWAIT) */
136 #define SYSLOG_OPTIONS (LOG_PID)
137 #endif
138 
139 #ifndef SYSLOG_FACILITY
140 #define SYSLOG_FACILITY LOG_AUTHPRIV
141 #endif
142 
143 #define OPENLOG(progname) openlog(progname, SYSLOG_OPTIONS, SYSLOG_FACILITY)
144 
145 #ifdef STAT_MACROS_BROKEN
146 # define S_ISDIR(x) ((x) & S_IFMT) == S_IFDIR)
147 # define S_ISREG(x) ((x) & S_IFMT) == S_IFREG)
148 # ifdef S_IFLNK
149 # define S_ISLNK(x) ((x) & S_IFMT) == S_IFLNK)
150 # endif
151 #endif
152 
153 #ifndef S_ISLNK
154 #define S_ISLNK(x) (0)
155 #endif
156 
157 #if HAVE_LCHOWN
158 #define LCHOWN lchown
159 #else
160 #define LCHOWN chown
161 #endif
162 
163 #if HAVE_LSTAT
164 #define LSTAT lstat
165 #else
166 #define LSTAT stat
167 #endif
168 
169 #if HAVE_TERMIOS_H
170 # include <termios.h>
171 # define STTY(fd, termio) tcsetattr(fd, TCSANOW, termio)
172 # define GTTY(fd, termio) tcgetattr(fd, termio)
173 # define TERMIO struct termios
174 # define USE_TERMIOS
175 #else /* assumed HAVE_TERMIO_H */
176 # include <sys/ioctl.h>
177 # include <termio.h>
178 # define STTY(fd, termio) ioctl(fd, TCSETA, termio)
179 # define GTTY(fd, termio) ioctl(fd, TCGETA, termio)
180 # define TEMRIO struct termio
181 # define USE_TERMIO
182 #endif
183 
184 /*
185  * Password aging constants
186  *
187  * DAY - seconds / day
188  * WEEK - seconds / week
189  * SCALE - seconds / aging unit
190  */
191 
192 /* Solaris defines this in shadow.h */
193 #ifndef DAY
194 #define DAY (24L*3600L)
195 #endif
196 
197 #define WEEK (7*DAY)
198 
199 #ifdef ITI_AGING
200 #define SCALE 1
201 #else
202 #define SCALE DAY
203 #endif
204 
205 /* Copy string pointed by B to array A with size checking. It was originally
206  in lmain.c but is _very_ useful elsewhere. Some setuid root programs with
207  very sloppy coding used to assume that BUFSIZ will always be enough... */
208 
209  /* danger - side effects */
210 #define STRFCPY(A,B) \
211  (strncpy((A), (B), sizeof(A) - 1), (A)[sizeof(A) - 1] = '\0')
212 
213 /* get rid of a few ugly repeated #ifdefs in pwent.c and grent.c */
214 /* XXX - this is ugly too, configure should test it and not check for
215  any hardcoded system names, if possible. --marekm */
216 #if defined(AIX) || defined(__linux__)
217 #define SETXXENT_TYPE void
218 #define SETXXENT_RET(x) return
219 #define SETXXENT_TEST(x) x; if (0) /* compiler should optimize this away */
220 #else
221 #define SETXXENT_TYPE int
222 #define SETXXENT_RET(x) return(x)
223 #define SETXXENT_TEST(x) if (x)
224 #endif
225 
226 #ifndef PASSWD_FILE
227 #define PASSWD_FILE "/etc/passwd"
228 #endif
229 
230 #ifndef GROUP_FILE
231 #define GROUP_FILE "/etc/group"
232 #endif
233 
234 #ifndef SHADOW_FILE
235 #define SHADOW_FILE "/etc/shadow"
236 #endif
237 
238 #ifdef SHADOWGRP
239 #ifndef SGROUP_FILE
240 #define SGROUP_FILE "/etc/gshadow"
241 #endif
242 #endif
243 
244 #define PASSWD_PAG_FILE PASSWD_FILE ".pag"
245 #define GROUP_PAG_FILE GROUP_FILE ".pag"
246 #define SHADOW_PAG_FILE SHADOW_FILE ".pag"
247 #define SGROUP_PAG_FILE SGROUP_FILE ".pag"
248 
249 #ifndef NULL
250 #define NULL ((void *) 0)
251 #endif
252 
253 #ifdef sun /* hacks for compiling on SunOS */
254 # ifndef SOLARIS
255 extern int fputs ();
256 extern char *strdup ();
257 extern char *strerror ();
258 # endif
259 #endif
260 
261 #ifndef HAVE_SNPRINTF
262 #include "snprintf.h"
263 #endif
264 
265 /*
266  * string to use for the pw_passwd field in /etc/passwd when using
267  * shadow passwords - most systems use "x" but there are a few
268  * exceptions, so it can be changed here if necessary. --marekm
269  */
270 #ifndef SHADOW_PASSWD_STRING
271 #define SHADOW_PASSWD_STRING "x"
272 #endif
273 
274 #ifdef WITH_AUDIT
275 #ifdef __u8 /* in case we use pam < 0.80 */
276 #undef __u8
277 #endif
278 #ifdef __u32
279 #undef __u32
280 #endif
281 
282 #include <libaudit.h>
283 #endif
284 
285 #endif /* _DEFINES_H_ */
strdup
#define strdup(a)
Definition: brew_db.h:80
strchr
#define strchr
Definition: defines.h:21
strrchr
#define strrchr
Definition: defines.h:22
gshadow_.h
strerror
#define strerror
Definition: clib_port.h:249
strtok
char * strtok()