1 /* getutmpentry.c: The __opiegetutmpentry() library function.
4 This software is Copyright 1996-2001 by Craig Metz, All Rights Reserved.
5 The Inner Net License Version 3 applies to this software.
6 You should have received a copy of the license with this software. If
7 you didn't get a copy, you may request one from <license@inner.net>.
11 Modified by cmetz for OPIE 2.31. Cache result.
12 Created by cmetz for OPIE 2.3 (re-write).
17 #include <sys/types.h>
21 #define setutent setutxent
22 #define getutline(x) getutxline(x)
30 #endif /* HAVE_STRING_H */
37 #if !HAVE_GETUTLINE && !DOUTMPX
38 struct utmp *getutline __P((struct utmp *));
39 #endif /* HAVE_GETUTLINE && !DOUTMPX */
43 int __opiegetutmpentry FUNCTION((line, utmp), char *line AND struct utmp *utmp)
52 memset(&u, 0, sizeof(u));
54 if (!strncmp(line, "/dev/", 5)) {
55 strncpy(u.ut_line, line + 5, sizeof(u.ut_line));
57 if ((pu = getutline(&u)))
61 strcpy(u.ut_line, "pty/");
62 strncpy(u.ut_line + 4, line + 5, sizeof(u.ut_line) - 4);
64 if ((pu = getutline(&u)))
69 strncpy(u.ut_line, line, sizeof(u.ut_line));
71 if ((pu = getutline(&u)))
75 syslog(LOG_DEBUG, "__opiegetutmpentry: failed to find entry for line %s", line);
81 syslog(LOG_DEBUG, "__opiegetutmpentry: succeeded with line %s", pu->ut_line);
83 memcpy(utmp, pu, sizeof(struct utmp));