Lines Matching refs:home
94 static const char *hd_getpwd(HomeDir *home);
104 HomeDir *home; /* The object to be returned */ in _new_HomeDir() local
109 home = (HomeDir *) malloc(sizeof(HomeDir)); in _new_HomeDir()
110 if(!home) { in _new_HomeDir()
119 home->err = NULL; in _new_HomeDir()
120 home->buffer = NULL; in _new_HomeDir()
121 home->buflen = 0; in _new_HomeDir()
125 home->err = _new_ErrMsg(); in _new_HomeDir()
126 if(!home->err) in _new_HomeDir()
127 return _del_HomeDir(home); in _new_HomeDir()
138 home->buflen = DEF_GETPW_R_SIZE_MAX; in _new_HomeDir()
141 home->buflen = sysconf(_SC_GETPW_R_SIZE_MAX); in _new_HomeDir()
145 if(home->buflen < 0 || errno) in _new_HomeDir()
146 home->buflen = DEF_GETPW_R_SIZE_MAX; in _new_HomeDir()
154 if(pathlen > home->buflen) in _new_HomeDir()
155 home->buflen = pathlen; in _new_HomeDir()
159 home->buffer = (char *) malloc(home->buflen); in _new_HomeDir()
160 if(!home->buffer) { in _new_HomeDir()
162 return _del_HomeDir(home); in _new_HomeDir()
164 return home; in _new_HomeDir()
175 HomeDir *_del_HomeDir(HomeDir *home) in _del_HomeDir() argument
177 if(home) { in _del_HomeDir()
178 home->err = _del_ErrMsg(home->err); in _del_HomeDir()
179 if(home->buffer) in _del_HomeDir()
180 free(home->buffer); in _del_HomeDir()
181 free(home); in _del_HomeDir()
212 const char *_hd_lookup_home_dir(HomeDir *home, const char *user) in _hd_lookup_home_dir() argument
223 if(!home) { in _hd_lookup_home_dir()
232 home_dir = hd_getpwd(home); in _hd_lookup_home_dir()
234 _err_record_msg(home->err, "Can't determine current directory", in _hd_lookup_home_dir()
261 status = getpwuid_r(geteuid(), &home->pwd, home->buffer, home->buflen, in _hd_lookup_home_dir()
264 status = getpwnam_r(user, &home->pwd, home->buffer, home->buflen, &ret); in _hd_lookup_home_dir()
266 _err_record_msg(home->err, "User '", user, "' doesn't exist.", in _hd_lookup_home_dir()
273 home_dir = home->pwd.pw_dir; in _hd_lookup_home_dir()
282 _err_record_msg(home->err, "User '", user, "' doesn't exist.", in _hd_lookup_home_dir()
304 const char *_hd_last_home_dir_error(HomeDir *home) in _hd_last_home_dir_error() argument
306 return home ? _err_get_msg(home->err) : "NULL HomeDir argument"; in _hd_last_home_dir_error()
330 int _hd_scan_user_home_dirs(HomeDir *home, const char *prefix, argument
338 if(!home || !prefix || !callback_fn) {
339 if(home) {
340 _err_record_msg(home->err,
372 _err_get_msg(home->err), ERR_MSG_LEN);
381 _err_get_msg(home->err), ERR_MSG_LEN);
401 while((pwd = getpwent_r(&pwd_buffer, home->buffer, home->buflen)) != NULL && !waserr) {
407 _err_get_msg(home->err), ERR_MSG_LEN);
420 const char *pwd = hd_getpwd(home);
422 waserr = callback_fn(data, "+", pwd, _err_get_msg(home->err),ERR_MSG_LEN);
425 _err_record_msg(home->err, "Can't determine current directory.",
448 static const char *hd_getpwd(HomeDir *home) argument
453 char *cwd = getcwd(home->buffer, home->buflen);