BSD 3 development
[unix-history] / usr / src / cmd / uucp / getpwinfo.c
CommitLineData
f7bd9e3e
BJ
1#include "uucp.h"
2#include <pwd.h>
3
4
5/*******
6 * guinfo(uid, name, path) get passwd file info for uid
7 * int uid;
8 * char *path, *name;
9 *
10 * return codes: 0 | FAIL
11 */
12
13guinfo(uid, name, path)
14int uid;
15char *path, *name;
16{
17 struct passwd *pwd;
18 struct passwd *getpwuid();
19
20 if ((pwd = getpwuid(uid)) == NULL) {
21 /* can not find uid in passwd file */
22 *path = '\0';
23 return(FAIL);
24 }
25
26 strcpy(path, pwd->pw_dir);
27 strcpy(name, pwd->pw_name);
28 return(0);
29}
30
31
32/***
33 * gninfo(name, uid, path) get passwd file info for name
34 * char *path, *name;
35 * int *uid;
36 *
37 * return codes: 0 | FAIL
38 */
39
40gninfo(name, uid, path)
41char *path, *name;
42int *uid;
43{
44 struct passwd *pwd;
45 struct passwd *getpwnam();
46
47 if ((pwd = getpwnam(name)) == NULL) {
48 /* can not find name in passwd file */
49 *path = '\0';
50 return(FAIL);
51 }
52
53 strcpy(path, pwd->pw_dir);
54 *uid = pwd->pw_uid;
55 return(0);
56}
57
58