Lines Matching +full:123 +full:- +full:db

1 /*-
2 * SPDX-License-Identifier: BSD-3-Clause
39 #include <db.h>
63 if (!strcasecmp(pw->pw_name, user)) in match()
70 (void)strncpy(p = tbuf, pw->pw_gecos, sizeof(tbuf)); in match()
71 tbuf[sizeof(tbuf) - 1] = '\0'; in match()
79 for (t = name; t < &name[sizeof(name) - 1] && (*t = *p) != '\0'; ++p) { in match()
81 (void)strncpy(t, pw->pw_name, in match()
82 sizeof(name) - (t - name)); in match()
83 name[sizeof(name) - 1] = '\0'; in match()
84 while (t < &name[sizeof(name) - 1] && *++t) in match()
105 ut = getutxuser(pn->name); in enter_lastlog()
106 if ((w = pn->whead) == NULL) in enter_lastlog()
108 else if (ut != NULL && ut->ut_type == USER_PROCESS) { in enter_lastlog()
110 for (; !doit && w != NULL; w = w->next) in enter_lastlog()
111 if (w->info == LOGGEDIN && in enter_lastlog()
112 w->loginat < ut->ut_tv.tv_sec) in enter_lastlog()
119 for (w = pn->whead; doit && w != NULL; w = w->next) in enter_lastlog()
120 if (w->info == LOGGEDIN && in enter_lastlog()
121 strcmp(w->tty, ut->ut_line) == 0) in enter_lastlog()
126 w->info = LASTLOG; in enter_lastlog()
127 strcpy(w->tty, ut->ut_line); in enter_lastlog()
128 strcpy(w->host, ut->ut_host); in enter_lastlog()
129 w->loginat = ut->ut_tv.tv_sec; in enter_lastlog()
140 w->info = LOGGEDIN; in enter_where()
141 strcpy(w->tty, ut->ut_line); in enter_where()
142 strcpy(w->host, ut->ut_host); in enter_where()
143 w->loginat = ut->ut_tv.tv_sec; in enter_where()
153 if (db == NULL && in enter_person()
154 (db = dbopen(NULL, O_RDWR, 0, DB_BTREE, NULL)) == NULL) in enter_person()
157 key.data = pw->pw_name; in enter_person()
158 key.size = strlen(pw->pw_name); in enter_person()
160 switch ((*db->get)(db, &key, &data, 0)) { in enter_person()
165 case -1: in enter_person()
166 err(1, "db get"); in enter_person()
172 pn->whead = NULL; in enter_person()
176 if ((*db->put)(db, &key, &data, 0)) in enter_person()
177 err(1, "db put"); in enter_person()
190 if (!db) in find_person()
199 if ((*db->get)(db, &key, &data, 0)) in find_person()
222 if (pn->whead == NULL) in walloc()
223 pn->whead = pn->wtail = w; in walloc()
225 pn->wtail->next = w; in walloc()
226 pn->wtail = w; in walloc()
228 w->next = NULL; in walloc()
243 len = p - num; in prphone()
246 case 11: /* +0-123-456-7890 */ in prphone()
249 *p++ = '-'; in prphone()
251 case 10: /* 012-345-6789 */ in prphone()
255 *p++ = '-'; in prphone()
257 case 7: /* 012-3456 */ in prphone()
262 case 5: /* x0-1234 */ in prphone()
271 *p++ = '-'; in prphone()
288 (void)snprintf(tbuf, sizeof(tbuf), "%s/%s", _PATH_DEV, w->tty); in find_idle_and_ttywrite()
295 * out the idle time, which is non-ideal but better in find_idle_and_ttywrite()
298 w->idletime = -1; in find_idle_and_ttywrite()
302 w->idletime = -1; in find_idle_and_ttywrite()
306 if (touched < w->loginat) { in find_idle_and_ttywrite()
308 touched = w->loginat; in find_idle_and_ttywrite()
310 w->idletime = now < touched ? 0 : now - touched; in find_idle_and_ttywrite()
313 w->writable = ((sb.st_mode & TALKABLE) == TALKABLE); in find_idle_and_ttywrite()
323 pn->realname = pn->office = pn->officephone = pn->homephone = NULL; in userinfo()
325 pn->uid = pw->pw_uid; in userinfo()
326 if ((pn->name = strdup(pw->pw_name)) == NULL) in userinfo()
328 if ((pn->dir = strdup(pw->pw_dir)) == NULL) in userinfo()
330 if ((pn->shell = strdup(pw->pw_shell)) == NULL) in userinfo()
334 (void)strncpy(bp = tbuf, pw->pw_gecos, sizeof(tbuf)); in userinfo()
335 tbuf[sizeof(tbuf) - 1] = '\0'; in userinfo()
342 for (t = name; t < &name[sizeof(name) - 1] && (*t = *p) != '\0'; ++p) { in userinfo()
344 (void)strncpy(t, pw->pw_name, in userinfo()
345 sizeof(name) - (t - name)); in userinfo()
346 name[sizeof(name) - 1] = '\0'; in userinfo()
349 while (t < &name[sizeof(name) - 1] && *++t) in userinfo()
356 if ((pn->realname = strdup(name)) == NULL) in userinfo()
358 pn->office = ((p = strsep(&bp, ",")) && *p) ? in userinfo()
360 pn->officephone = ((p = strsep(&bp, ",")) && *p) ? in userinfo()
362 pn->homephone = ((p = strsep(&bp, ",")) && *p) ? in userinfo()
364 (void)snprintf(tbuf, sizeof(tbuf), "%s/%s", _PATH_MAILDIR, pw->pw_name); in userinfo()
365 pn->mailrecv = -1; /* -1 == not_valid */ in userinfo()
372 pn->mailrecv = sb.st_mtime; in userinfo()
373 pn->mailread = sb.st_atime; in userinfo()
389 if (invoker_root || !pw->pw_dir) in hide()
392 snprintf(buf, sizeof(buf), "%s/%s", pw->pw_dir, _PATH_NOFINGER); in hide()