add support for converting to and checking new inode format filesystems;
[unix-history] / usr / src / usr.bin / mail / getname.c
CommitLineData
9552e6b8
DF
1/*
2 * Copyright (c) 1980 Regents of the University of California.
0c5f72fb
KB
3 * All rights reserved.
4 *
f15db449 5 * %sccs.include.redist.c%
9552e6b8
DF
6 */
7
acfc7e9b 8#ifndef lint
f15db449 9static char sccsid[] = "@(#)getname.c 5.8 (Berkeley) %G%";
acfc7e9b 10#endif /* not lint */
9552e6b8 11
26801b28 12#include <sys/types.h>
4e161d3b 13#include <pwd.h>
b0f79ad7
KS
14
15/*
4e161d3b 16 * Getname / getuserid for those with
b0f79ad7 17 * hashed passwd data base).
b0f79ad7 18 *
b0f79ad7
KS
19 */
20
b0f79ad7
KS
21#include "rcv.h"
22
b0f79ad7
KS
23/*
24 * Search the passwd file for a uid. Return name through ref parameter
25 * if found, indicating success with 0 return. Return -1 on error.
b0f79ad7 26 */
f674e088
EW
27char *
28getname(uid)
b0f79ad7 29{
4e161d3b 30 struct passwd *pw;
b0f79ad7 31
4e161d3b 32 if ((pw = getpwuid(uid)) == NULL)
f674e088
EW
33 return NOSTR;
34 return pw->pw_name;
b0f79ad7
KS
35}
36
37/*
38 * Convert the passed name to a user id and return it. Return -1
828615a1 39 * on error.
b0f79ad7 40 */
b0f79ad7
KS
41getuserid(name)
42 char name[];
43{
4e161d3b 44 struct passwd *pw;
b0f79ad7 45
4e161d3b 46 if ((pw = getpwnam(name)) == NULL)
828615a1 47 return -1;
4e161d3b 48 return pw->pw_uid;
b0f79ad7 49}