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.15 by root, Wed Feb 16 21:21:43 2005 UTC vs.
Revision 1.20 by root, Fri Jan 13 07:03:48 2006 UTC

37 * 37 *
38 * Private: 38 * Private:
39 * rxvt_update_wtmp (); 39 * rxvt_update_wtmp ();
40 *----------------------------------------------------------------------*/ 40 *----------------------------------------------------------------------*/
41 41
42#include "../config.h" /* NECESSARY */ 42#include "../config.h"
43#include "rxvt.h" /* NECESSARY */ 43#include "rxvt.h"
44#include "logging.h" 44#include "logging.h"
45
45#ifdef UTMP_SUPPORT 46#ifdef UTMP_SUPPORT
46 47
48#if HAVE_STRUCT_UTMP
47int rxvt_write_bsd_utmp (int utmp_pos, struct utmp *wu); 49int rxvt_write_bsd_utmp (int utmp_pos, struct utmp *wu);
48void rxvt_update_wtmp (const char *fname, const struct utmp *putmp); 50void rxvt_update_wtmp (const char *fname, const struct utmp *putmp);
51#endif
52
49void rxvt_update_lastlog (const char *fname, const char *pty, const char *host); 53void rxvt_update_lastlog (const char *fname, const char *pty, const char *host);
50 54
51/* 55/*
52 * BSD style utmp entry 56 * BSD style utmp entry
53 * ut_line, ut_name, ut_host, ut_time 57 * ut_line, ut_name, ut_host, ut_time
70 struct utmpx *utx = &this->utx; 74 struct utmpx *utx = &this->utx;
71#endif 75#endif
72#ifdef HAVE_UTMP_PID 76#ifdef HAVE_UTMP_PID
73 int i; 77 int i;
74#endif 78#endif
75 struct passwd *pwent = getpwuid (getuid ()); 79 struct passwd *pwent = getpwuid (getuid ());
76 80
77 if (!strncmp (pty, "/dev/", 5)) 81 if (!strncmp (pty, "/dev/", 5))
78 pty += 5; /* skip /dev/ prefix */ 82 pty += 5; /* skip /dev/ prefix */
79 83
80#ifdef HAVE_UTMP_PID 84#ifdef HAVE_UTMP_PID
173# else 177# else
174 FILE *fd0; 178 FILE *fd0;
175 179
176 if ((fd0 = fopen (TTYTAB_FILENAME, "r")) != NULL) 180 if ((fd0 = fopen (TTYTAB_FILENAME, "r")) != NULL)
177 { 181 {
178 char buf[256], name[256]; 182 char buf[256], name[256];
179 183
180 buf[sizeof (buf) - 1] = '\0'; 184 buf[sizeof (buf) - 1] = '\0';
181 for (i = 1; (fgets (buf, sizeof (buf) - 1, fd0) != NULL);) 185 for (i = 1; (fgets (buf, sizeof (buf) - 1, fd0) != NULL);)
182 { 186 {
183 if (*buf == '#' || sscanf (buf, "%s", name) != 1) 187 if (*buf == '#' || sscanf (buf, "%s", name) != 1)
199 } 203 }
200#endif 204#endif
201 205
202#ifdef WTMP_SUPPORT 206#ifdef WTMP_SUPPORT
203# ifdef WTMP_ONLY_ON_LOGIN 207# ifdef WTMP_ONLY_ON_LOGIN
204 if (options & Opt_loginShell) 208 if (OPTION (Opt_loginShell))
205# endif 209# endif
206 { 210 {
207# ifdef HAVE_STRUCT_UTMP 211# ifdef HAVE_STRUCT_UTMP
208# ifdef HAVE_UPDWTMP 212# ifdef HAVE_UPDWTMP
209 updwtmp (RXVT_WTMP_FILE, ut); 213 updwtmp (RXVT_WTMP_FILE, ut);
212# endif 216# endif
213# endif 217# endif
214# ifdef HAVE_STRUCT_UTMPX 218# ifdef HAVE_STRUCT_UTMPX
215# if HAVE_UPDWTMPX 219# if HAVE_UPDWTMPX
216 updwtmpx (RXVT_WTMPX_FILE, utx); 220 updwtmpx (RXVT_WTMPX_FILE, utx);
221# else
222 pututxline (utx);
217# endif 223# endif
218# endif 224# endif
219 } 225 }
220#endif 226#endif
221#if defined(LASTLOG_SUPPORT) && defined(RXVT_LASTLOG_FILE) 227#if defined(LASTLOG_SUPPORT) && defined(RXVT_LASTLOG_FILE)
222 if (options & Opt_loginShell) 228 if (OPTION (Opt_loginShell))
223 rxvt_update_lastlog (RXVT_LASTLOG_FILE, pty, hostname); 229 rxvt_update_lastlog (RXVT_LASTLOG_FILE, pty, hostname);
224#endif 230#endif
225} 231}
226 232
227/* ------------------------------------------------------------------------- */ 233/* ------------------------------------------------------------------------- */
278 /* 284 /*
279 * Write ending wtmp entry 285 * Write ending wtmp entry
280 */ 286 */
281#ifdef WTMP_SUPPORT 287#ifdef WTMP_SUPPORT
282# ifdef WTMP_ONLY_ON_LOGIN 288# ifdef WTMP_ONLY_ON_LOGIN
283 if (options & Opt_loginShell) 289 if (OPTION (Opt_loginShell))
284# endif 290# endif
285 { 291 {
286# ifdef HAVE_STRUCT_UTMP 292# ifdef HAVE_STRUCT_UTMP
287# ifdef HAVE_UPDWTMP 293# ifdef HAVE_UPDWTMP
288 updwtmp (RXVT_WTMP_FILE, ut); 294 updwtmp (RXVT_WTMP_FILE, ut);
291# endif 297# endif
292# endif 298# endif
293# ifdef HAVE_STRUCT_UTMPX 299# ifdef HAVE_STRUCT_UTMPX
294# if HAVE_UPDWTMPX 300# if HAVE_UPDWTMPX
295 updwtmpx (RXVT_WTMPX_FILE, utx); 301 updwtmpx (RXVT_WTMPX_FILE, utx);
302# else
303 pututxline (utx);
296# endif 304# endif
297# endif 305# endif
298 } 306 }
299#endif 307#endif
300 308
321/* ------------------------------------------------------------------------- */ 329/* ------------------------------------------------------------------------- */
322/* 330/*
323 * Write a BSD style utmp entry 331 * Write a BSD style utmp entry
324 */ 332 */
325#ifdef HAVE_UTMP_H 333#ifdef HAVE_UTMP_H
326/* INTPROTO */
327int 334int
328rxvt_write_bsd_utmp (int utmp_pos, struct utmp *wu) 335rxvt_write_bsd_utmp (int utmp_pos, struct utmp *wu)
329{ 336{
330 int fd; 337 int fd;
331 338
341 348
342/* ------------------------------------------------------------------------- */ 349/* ------------------------------------------------------------------------- */
343/* 350/*
344 * Update a BSD style wtmp entry 351 * Update a BSD style wtmp entry
345 */ 352 */
346#if defined(WTMP_SUPPORT) && !defined(HAVE_UPDWTMP) 353#if defined(WTMP_SUPPORT) && !defined(HAVE_UPDWTMP) && defined(HAVE_STRUCT_UTMP)
347/* INTPROTO */
348void 354void
349rxvt_update_wtmp (const char *fname, const struct utmp *putmp) 355rxvt_update_wtmp (const char *fname, const struct utmp *putmp)
350{ 356{
351 int fd, gotlock, retry; 357 int fd, gotlock, retry;
352 struct flock lck; /* fcntl locking scheme */ 358 struct flock lck; /* fcntl locking scheme */
384} 390}
385#endif 391#endif
386 392
387/* ------------------------------------------------------------------------- */ 393/* ------------------------------------------------------------------------- */
388#ifdef LASTLOG_SUPPORT 394#ifdef LASTLOG_SUPPORT
389/* INTPROTO */
390void 395void
391rxvt_update_lastlog (const char *fname, const char *pty, const char *host) 396rxvt_update_lastlog (const char *fname, const char *pty, const char *host)
392{ 397{
393# ifdef HAVE_STRUCT_LASTLOGX 398# ifdef HAVE_STRUCT_LASTLOGX
394 struct lastlogx llx; 399 struct lastlogx llx;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines