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.21 by root, Sat Jan 14 10:17:40 2006 UTC vs.
Revision 1.22 by root, Sun Jan 15 05:14:12 2006 UTC

44#include "logging.h" 44#include "logging.h"
45 45
46#ifdef UTMP_SUPPORT 46#ifdef UTMP_SUPPORT
47 47
48#if HAVE_STRUCT_UTMP 48#if HAVE_STRUCT_UTMP
49int rxvt_write_bsd_utmp (int utmp_pos, struct utmp *wu); 49static int rxvt_write_bsd_utmp (int utmp_pos, struct utmp *wu);
50void rxvt_update_wtmp (const char *fname, const struct utmp *putmp); 50static void rxvt_update_wtmp (const char *fname, const struct utmp *putmp);
51#endif 51#endif
52 52
53void rxvt_update_lastlog (const char *fname, const char *pty, const char *host); 53static void rxvt_update_lastlog (const char *fname, const char *pty, const char *host);
54 54
55/* 55/*
56 * BSD style utmp entry 56 * BSD style utmp entry
57 * ut_line, ut_name, ut_host, ut_time 57 * ut_line, ut_name, ut_host, ut_time
58 * SYSV style utmp (and utmpx) entry 58 * SYSV style utmp (and utmpx) entry
71 struct utmp *ut = &this->ut; 71 struct utmp *ut = &this->ut;
72#endif 72#endif
73#ifdef HAVE_STRUCT_UTMPX 73#ifdef HAVE_STRUCT_UTMPX
74 struct utmpx *utx = &this->utx; 74 struct utmpx *utx = &this->utx;
75#endif 75#endif
76#ifdef HAVE_UTMP_PID
77 int i; 76 int i;
78#endif
79 struct passwd *pwent = getpwuid (getuid ()); 77 struct passwd *pwent = getpwuid (getuid ());
80 78
81 if (!strncmp (pty, "/dev/", 5)) 79 if (!strncmp (pty, "/dev/", 5))
82 pty += 5; /* skip /dev/ prefix */ 80 pty += 5; /* skip /dev/ prefix */
83 81
84#ifdef HAVE_UTMP_PID 82#if defined(HAVE_UTMP_PID) || defined(HAVE_STRUCT_UTMPX)
85 if (!strncmp (pty, "pty", 3) || !strncmp (pty, "tty", 3)) 83 if (!strncmp (pty, "pty", 3) || !strncmp (pty, "tty", 3))
86 strncpy (ut_id, pty + 3, sizeof (ut_id)); 84 strncpy (ut_id, pty + 3, sizeof (ut_id));
87 else if (sscanf (pty, "pts/%d", &i) == 1) 85 else if (sscanf (pty, "pts/%d", &i) == 1)
88 sprintf (ut_id, "vt%02x", (i & 0xff)); /* sysv naming */ 86 sprintf (ut_id, "vt%02x", (i & 0xff)); /* sysv naming */
89 else if (strncmp (pty, "pty", 3) && strncmp (pty, "tty", 3)) 87 else if (strncmp (pty, "pty", 3) && strncmp (pty, "tty", 3))
167#endif 165#endif
168 166
169#if defined(HAVE_STRUCT_UTMP) && !defined(HAVE_UTMP_PID) 167#if defined(HAVE_STRUCT_UTMP) && !defined(HAVE_UTMP_PID)
170 168
171 { 169 {
172 int i;
173# ifdef HAVE_TTYSLOT 170# ifdef HAVE_TTYSLOT
174 i = ttyslot (); 171 i = ttyslot ();
175 if (rxvt_write_bsd_utmp (i, ut)) 172 if (rxvt_write_bsd_utmp (i, ut))
176 utmp_pos = i; 173 utmp_pos = i;
177# else 174# else
328 325
329/* ------------------------------------------------------------------------- */ 326/* ------------------------------------------------------------------------- */
330/* 327/*
331 * Write a BSD style utmp entry 328 * Write a BSD style utmp entry
332 */ 329 */
333#ifdef HAVE_UTMP_H 330#if defined(HAVE_STRUCT_UTMP) && !defined(HAVE_UTMP_PID)
334int 331static int
335rxvt_write_bsd_utmp (int utmp_pos, struct utmp *wu) 332rxvt_write_bsd_utmp (int utmp_pos, struct utmp *wu)
336{ 333{
337 int fd; 334 int fd;
338 335
339 if (utmp_pos <= 0 || (fd = open (RXVT_UTMP_FILE, O_WRONLY)) == -1) 336 if (utmp_pos <= 0 || (fd = open (RXVT_UTMP_FILE, O_WRONLY)) == -1)
349/* ------------------------------------------------------------------------- */ 346/* ------------------------------------------------------------------------- */
350/* 347/*
351 * Update a BSD style wtmp entry 348 * Update a BSD style wtmp entry
352 */ 349 */
353#if defined(WTMP_SUPPORT) && !defined(HAVE_UPDWTMP) && defined(HAVE_STRUCT_UTMP) 350#if defined(WTMP_SUPPORT) && !defined(HAVE_UPDWTMP) && defined(HAVE_STRUCT_UTMP)
354void 351static void
355rxvt_update_wtmp (const char *fname, const struct utmp *putmp) 352rxvt_update_wtmp (const char *fname, const struct utmp *putmp)
356{ 353{
357 int fd, gotlock, retry; 354 int fd, gotlock, retry;
358 struct flock lck; /* fcntl locking scheme */ 355 struct flock lck; /* fcntl locking scheme */
359 struct stat sbuf; 356 struct stat sbuf;
390} 387}
391#endif 388#endif
392 389
393/* ------------------------------------------------------------------------- */ 390/* ------------------------------------------------------------------------- */
394#ifdef LASTLOG_SUPPORT 391#ifdef LASTLOG_SUPPORT
395void 392static void
396rxvt_update_lastlog (const char *fname, const char *pty, const char *host) 393rxvt_update_lastlog (const char *fname, const char *pty, const char *host)
397{ 394{
398# ifdef HAVE_STRUCT_LASTLOGX 395# ifdef HAVE_STRUCT_LASTLOGX
399 struct lastlogx llx; 396 struct lastlogx llx;
400# endif 397# endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines