1: /* $Header$ */ 2: 3: /* 4: * Author: Peter J. Nicklin 5: */ 6: 7: /* 8: * getpwdir() searchs from the beginning of the passwd file until a 9: * matching home directory is found. If found, a pointer is returned 10: * to a passwd struct, otherwise NULL. 11: */ 12: #include <pwd.h> 13: #include "macro.h" 14: #include "null.h" 15: 16: struct passwd * 17: getpwdir(dir) 18: char *dir; /* directory to be matched */ 19: { 20: register struct passwd *pw; /* pointer to current passwd entry */ 21: int endpwent(); /* close passwd file */ 22: struct passwd *getpwent(); /* get next passwd entry */ 23: 24: for (;;) 25: { 26: if ((pw = getpwent()) == NULL) 27: break; 28: if (EQUAL(dir, pw->pw_dir)) 29: break; 30: } 31: endpwent(); 32: return(pw); 33: }