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>
22 #define setutent setutxent
23 #define getutline(x) getutxline(x)
29 #endif /* HAVE_STRING_H */
36 #if !HAVE_GETUTLINE && !DOUTMPX
37 struct utmp *getutline __P((struct utmp *));
38 #endif /* HAVE_GETUTLINE && !DOUTMPX */
42 int __opiegetutmpentry FUNCTION((line, utmp), char *line AND struct utmp *utmp)
51 memset(&u, 0, sizeof(u));
53 if (!strncmp(line, "/dev/", 5)) {
54 strncpy(u.ut_line, line + 5, sizeof(u.ut_line));
56 if ((pu = getutline(&u)))
60 strcpy(u.ut_line, "pty/");
61 strncpy(u.ut_line + 4, line + 5, sizeof(u.ut_line) - 4);
63 if ((pu = getutline(&u)))
68 strncpy(u.ut_line, line, sizeof(u.ut_line));
70 if ((pu = getutline(&u)))
74 syslog(LOG_DEBUG, "__opiegetutmpentry: failed to find entry for line %s", line);
80 syslog(LOG_DEBUG, "__opiegetutmpentry: succeeded with line %s", pu->ut_line);
82 memcpy(utmp, pu, sizeof(struct utmp));