ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/logging.C
(Generate patch)

Comparing rxvt-unicode/src/logging.C (file contents):
Revision 1.11 by root, Sun Aug 15 22:09:24 2004 UTC vs.
Revision 1.14 by root, Wed Feb 16 20:32:05 2005 UTC

42#include "../config.h" /* NECESSARY */ 42#include "../config.h" /* NECESSARY */
43#include "rxvt.h" /* NECESSARY */ 43#include "rxvt.h" /* NECESSARY */
44#include "logging.h" 44#include "logging.h"
45#ifdef UTMP_SUPPORT 45#ifdef UTMP_SUPPORT
46 46
47int rxvt_write_bsd_utmp (int utmp_pos, struct utmp *wu);
48void rxvt_update_wtmp (const char *fname, const struct utmp *putmp);
49void rxvt_update_lastlog (const char *fname, const char *pty, const char *host);
50
47/* 51/*
48 * BSD style utmp entry 52 * BSD style utmp entry
49 * ut_line, ut_name, ut_host, ut_time 53 * ut_line, ut_name, ut_host, ut_time
50 * SYSV style utmp (and utmpx) entry 54 * SYSV style utmp (and utmpx) entry
51 * ut_user, ut_id, ut_line, ut_pid, ut_type, ut_exit, ut_time 55 * ut_user, ut_id, ut_line, ut_pid, ut_type, ut_exit, ut_time
58 */ 62 */
59void 63void
60rxvt_term::makeutent (const char *pty, const char *hostname) 64rxvt_term::makeutent (const char *pty, const char *hostname)
61{ 65{
62#ifdef HAVE_STRUCT_UTMP 66#ifdef HAVE_STRUCT_UTMP
63 struct utmp *ut = & (this->ut); 67 struct utmp *ut = &this->ut;
64#endif 68#endif
65#ifdef HAVE_STRUCT_UTMPX 69#ifdef HAVE_STRUCT_UTMPX
66 struct utmpx *utx = & (this->utx); 70 struct utmpx *utx = &this->utx;
67#endif 71#endif
68#ifdef HAVE_UTMP_PID 72#ifdef HAVE_UTMP_PID
69 int i; 73 int i;
70#endif 74#endif
71 char ut_id[5];
72 struct passwd *pwent = getpwuid (getuid ()); 75 struct passwd *pwent = getpwuid (getuid ());
73 76
74 if (!strncmp (pty, "/dev/", 5)) 77 if (!strncmp (pty, "/dev/", 5))
75 pty += 5; /* skip /dev/ prefix */ 78 pty += 5; /* skip /dev/ prefix */
76 79
80#ifdef HAVE_UTMP_PID
77 if (!strncmp (pty, "pty", 3) || !strncmp (pty, "tty", 3)) 81 if (!strncmp (pty, "pty", 3) || !strncmp (pty, "tty", 3))
78 {
79 strncpy (ut_id, (pty + 3), sizeof (ut_id)); 82 strncpy (ut_id, pty + 3, sizeof (ut_id));
80 }
81#ifdef HAVE_UTMP_PID
82 else if (sscanf (pty, "pts/%d", &i) == 1) 83 else if (sscanf (pty, "pts/%d", &i) == 1)
83 sprintf (ut_id, "vt%02x", (i & 0xff)); /* sysv naming */ 84 sprintf (ut_id, "vt%02x", (i & 0xff)); /* sysv naming */
84#endif
85 else if (strncmp (pty, "pty", 3) && strncmp (pty, "tty", 3)) 85 else if (strncmp (pty, "pty", 3) && strncmp (pty, "tty", 3))
86 { 86 {
87 rxvt_warn ("can't parse tty name \"%s\", not adding utmp entry.\n", pty); 87 rxvt_warn ("can't parse tty name \"%s\", not adding utmp entry.\n", pty);
88 return; 88 return;
89 } 89 }
90#endif
90 91
91#ifdef HAVE_STRUCT_UTMP 92#ifdef HAVE_STRUCT_UTMP
92 memset (ut, 0, sizeof (struct utmp)); 93 memset (ut, 0, sizeof (struct utmp));
93# ifdef HAVE_UTMP_PID 94# ifdef HAVE_UTMP_PID
94 setutent (); 95 setutent ();
225 */ 226 */
226void 227void
227rxvt_term::cleanutent () 228rxvt_term::cleanutent ()
228{ 229{
229#ifdef HAVE_STRUCT_UTMP 230#ifdef HAVE_STRUCT_UTMP
230 struct utmp *ut = & (this->ut); 231 struct utmp *ut = &this->ut;
231#endif 232#endif
232#ifdef HAVE_STRUCT_UTMPX 233#ifdef HAVE_STRUCT_UTMPX
233 struct utmpx *tmputx, *utx = & (this->utx); 234 struct utmpx *tmputx, *utx = &this->utx;
234#endif 235#endif
235 236
236#ifdef HAVE_STRUCT_UTMP 237#ifdef HAVE_STRUCT_UTMP
237# ifdef HAVE_UTMP_PID 238# ifdef HAVE_UTMP_PID
238 memset (ut, 0, sizeof (struct utmp)); 239 memset (ut, 0, sizeof (struct utmp));

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines