1*2fe8fb19SBen Gras /* $NetBSD: pwd.h,v 1.2 2009/01/11 02:46:25 christos Exp $ */
2*2fe8fb19SBen Gras
3*2fe8fb19SBen Gras #ifndef _COMPAT_PWD_H_
4*2fe8fb19SBen Gras #define _COMPAT_PWD_H_
5*2fe8fb19SBen Gras
6*2fe8fb19SBen Gras #include <sys/cdefs.h>
7*2fe8fb19SBen Gras #include <sys/featuretest.h>
8*2fe8fb19SBen Gras #include <sys/types.h>
9*2fe8fb19SBen Gras
10*2fe8fb19SBen Gras struct passwd;
11*2fe8fb19SBen Gras struct passwd50 {
12*2fe8fb19SBen Gras __aconst char *pw_name; /* user name */
13*2fe8fb19SBen Gras __aconst char *pw_passwd; /* encrypted password */
14*2fe8fb19SBen Gras uid_t pw_uid; /* user uid */
15*2fe8fb19SBen Gras gid_t pw_gid; /* user gid */
16*2fe8fb19SBen Gras int32_t pw_change; /* password change time */
17*2fe8fb19SBen Gras __aconst char *pw_class; /* user login class */
18*2fe8fb19SBen Gras __aconst char *pw_gecos; /* general information */
19*2fe8fb19SBen Gras __aconst char *pw_dir; /* home directory */
20*2fe8fb19SBen Gras __aconst char *pw_shell; /* default shell */
21*2fe8fb19SBen Gras int32_t pw_expire; /* account expiration */
22*2fe8fb19SBen Gras };
23*2fe8fb19SBen Gras
24*2fe8fb19SBen Gras __BEGIN_DECLS
25*2fe8fb19SBen Gras static __inline void
passwd_to_passwd50(const struct passwd * p,struct passwd50 * q)26*2fe8fb19SBen Gras passwd_to_passwd50(const struct passwd *p, struct passwd50 *q)
27*2fe8fb19SBen Gras {
28*2fe8fb19SBen Gras q->pw_name = p->pw_name;
29*2fe8fb19SBen Gras q->pw_passwd = p->pw_passwd;
30*2fe8fb19SBen Gras q->pw_uid = p->pw_uid;
31*2fe8fb19SBen Gras q->pw_gid = p->pw_gid;
32*2fe8fb19SBen Gras q->pw_change = (int32_t)p->pw_change;
33*2fe8fb19SBen Gras q->pw_class = p->pw_class;
34*2fe8fb19SBen Gras q->pw_gecos = p->pw_gecos;
35*2fe8fb19SBen Gras q->pw_dir = p->pw_dir;
36*2fe8fb19SBen Gras q->pw_shell = p->pw_shell;
37*2fe8fb19SBen Gras q->pw_expire = (int32_t)p->pw_expire;
38*2fe8fb19SBen Gras }
39*2fe8fb19SBen Gras
40*2fe8fb19SBen Gras static __inline void
passwd50_to_passwd(const struct passwd50 * p,struct passwd * q)41*2fe8fb19SBen Gras passwd50_to_passwd(const struct passwd50 *p, struct passwd *q)
42*2fe8fb19SBen Gras {
43*2fe8fb19SBen Gras q->pw_name = p->pw_name;
44*2fe8fb19SBen Gras q->pw_passwd = p->pw_passwd;
45*2fe8fb19SBen Gras q->pw_uid = p->pw_uid;
46*2fe8fb19SBen Gras q->pw_gid = p->pw_gid;
47*2fe8fb19SBen Gras q->pw_change = p->pw_change;
48*2fe8fb19SBen Gras q->pw_class = p->pw_class;
49*2fe8fb19SBen Gras q->pw_gecos = p->pw_gecos;
50*2fe8fb19SBen Gras q->pw_dir = p->pw_dir;
51*2fe8fb19SBen Gras q->pw_shell = p->pw_shell;
52*2fe8fb19SBen Gras q->pw_expire = p->pw_expire;
53*2fe8fb19SBen Gras }
54*2fe8fb19SBen Gras
55*2fe8fb19SBen Gras struct passwd50 *getpwuid(uid_t);
56*2fe8fb19SBen Gras struct passwd50 *getpwnam(const char *);
57*2fe8fb19SBen Gras #if (_POSIX_C_SOURCE - 0) >= 199506L || (_XOPEN_SOURCE - 0) >= 500 || \
58*2fe8fb19SBen Gras defined(_REENTRANT) || defined(_NETBSD_SOURCE)
59*2fe8fb19SBen Gras int getpwnam_r(const char *, struct passwd50 *, char *, size_t,
60*2fe8fb19SBen Gras struct passwd50 **);
61*2fe8fb19SBen Gras int getpwuid_r(uid_t, struct passwd50 *, char *, size_t,
62*2fe8fb19SBen Gras struct passwd50 **);
63*2fe8fb19SBen Gras #endif
64*2fe8fb19SBen Gras #if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)
65*2fe8fb19SBen Gras struct passwd50 *getpwent(void);
66*2fe8fb19SBen Gras #endif
67*2fe8fb19SBen Gras #if defined(_NETBSD_SOURCE)
68*2fe8fb19SBen Gras int pw_scan(char *, struct passwd50 *, int *);
69*2fe8fb19SBen Gras int getpwent_r(struct passwd50 *, char *, size_t, struct passwd50 **);
70*2fe8fb19SBen Gras #endif
71*2fe8fb19SBen Gras #if defined(_NETBSD_SOURCE)
72*2fe8fb19SBen Gras int pwcache_userdb(int (*)(int), void (*)(void),
73*2fe8fb19SBen Gras struct passwd50 * (*)(const char *), struct passwd50 * (*)(uid_t));
74*2fe8fb19SBen Gras #endif
75*2fe8fb19SBen Gras
76*2fe8fb19SBen Gras struct passwd *__getpwuid50(uid_t);
77*2fe8fb19SBen Gras struct passwd *__getpwnam50(const char *);
78*2fe8fb19SBen Gras #if (_POSIX_C_SOURCE - 0) >= 199506L || (_XOPEN_SOURCE - 0) >= 500 || \
79*2fe8fb19SBen Gras defined(_REENTRANT) || defined(_NETBSD_SOURCE)
80*2fe8fb19SBen Gras int __getpwnam_r50(const char *, struct passwd *, char *, size_t,
81*2fe8fb19SBen Gras struct passwd **);
82*2fe8fb19SBen Gras int __getpwuid_r50(uid_t, struct passwd *, char *, size_t,
83*2fe8fb19SBen Gras struct passwd **);
84*2fe8fb19SBen Gras #endif
85*2fe8fb19SBen Gras #if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)
86*2fe8fb19SBen Gras struct passwd *__getpwent50(void);
87*2fe8fb19SBen Gras #endif
88*2fe8fb19SBen Gras #if defined(_NETBSD_SOURCE)
89*2fe8fb19SBen Gras int __pw_scan50(char *, struct passwd *, int *);
90*2fe8fb19SBen Gras int __getpwent_r50(struct passwd *, char *, size_t, struct passwd **);
91*2fe8fb19SBen Gras #endif
92*2fe8fb19SBen Gras int setpassent(int);
93*2fe8fb19SBen Gras #if defined(_NETBSD_SOURCE)
94*2fe8fb19SBen Gras int __pwcache_userdb50(int (*)(int), void (*)(void),
95*2fe8fb19SBen Gras struct passwd * (*)(const char *), struct passwd * (*)(uid_t));
96*2fe8fb19SBen Gras #endif
97*2fe8fb19SBen Gras __END_DECLS
98*2fe8fb19SBen Gras
99*2fe8fb19SBen Gras #endif /* !_COMPAT_PWD_H_ */
100