perl -i -npe "s/[ \t]+$//g" `find src -name "*.[ch]" -print`
[freeradius.git] / src / modules / rlm_unix / compat.h
1 /*
2  * compat.h   Compability library for systems that don't have some
3  *              of the routines that we would like to use...
4  *
5  * Version: cache.c  0.99  04-13-1999  jeff@apex.net
6  */
7 #ifndef _COMPAT_H
8 #define _COMPAT_H
9
10 #ifdef HAVE_GETSPNAM
11 #if defined(M_UNIX)
12
13         typedef struct passwd shadow_pwd_t;
14 #define GET_SP_NAME(sp) ((sp)->pw_name)
15 #define GET_SP_PWD(sp) ((sp)->pw_passwd)
16
17 #else /* M_UNIX */
18
19         typedef struct spwd shadow_pwd_t;
20 #define GET_SP_NAME(sp)  ((sp)->sp_namp)
21 #define GET_SP_PWD(sp)    ((sp)->sp_pwdp)
22 #define GET_SP_LSTCHG(sp) ((sp)->sp_lstchg)
23 #define GET_SP_MIN(sp)    ((sp)->sp_min)
24 #define GET_SP_MAX(sp)    ((sp)->sp_max)
25 #define GET_SP_WARN(sp)   ((sp)->sp_warn)
26 #define GET_SP_INACT(sp)  ((sp)->sp_inact)
27 #define GET_SP_EXPIRE(sp) ((sp)->sp_expire)
28
29 #endif  /* M_UNIX */
30
31 #else /* HAVE_GETSPNAM */
32
33 typedef struct my_shadow_t {
34         char *sp_namp;
35         char *sp_pwdp;
36         long int sp_lstchg;         /* Date of last change.  */
37         long int sp_min;
38         long int sp_max;
39         long int sp_warn;
40         long int sp_inact;
41         long int sp_expire;
42 } shadow_pwd_t;
43 #define GET_SP_NAME(sp)  ((sp)->sp_namp)
44 #define GET_SP_PWD(sp)    ((sp)->sp_pwdp)
45 #define GET_SP_LSTCHG(sp) ((sp)->sp_lstchg)
46 #define GET_SP_MIN(sp)    ((sp)->sp_min)
47 #define GET_SP_MAX(sp)    ((sp)->sp_max)
48 #define GET_SP_WARN(sp)   ((sp)->sp_warn)
49 #define GET_SP_INACT(sp)  ((sp)->sp_inact)
50 #define GET_SP_EXPIRE(sp) ((sp)->sp_expire)
51
52 #endif  /* HAVE_GETSPNAM */
53
54
55
56
57 #ifndef HAVE_FGETPWENT
58 extern struct passwd *rad_fgetpwent(FILE *pwhandle);
59 static inline struct passwd *fgetpwent(FILE *pw) {
60         return rad_fgetpwent(pw);
61 }
62 #endif /* HAVE_FGETPWENT */
63
64 #ifndef HAVE_FGETSPENT
65 extern shadow_pwd_t *rad_fgetspent(FILE *sphandle);
66 static inline shadow_pwd_t *fgetspent(FILE *sp) {
67         return rad_fgetspent(sp);
68 }
69 #endif /* HAVE_FGETSPENT */
70
71 #ifndef HAVE_FGETGRENT
72 extern struct group *rad_fgetgrent(FILE *grhandle);
73 static inline struct group *fgetgrent(FILE *gr) {
74         return rad_fgetgrent(gr);
75 }
76 #endif /* HAVE_FGETGRENT */
77
78 #endif /* _COMPAT_H */