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.14 by root, Wed Feb 16 20:32:05 2005 UTC vs.
Revision 1.16 by root, Wed Feb 16 21:37:10 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
47#if HAVE_STRUCT_UTMP
47int rxvt_write_bsd_utmp (int utmp_pos, struct utmp *wu); 48int rxvt_write_bsd_utmp (int utmp_pos, struct utmp *wu);
48void rxvt_update_wtmp (const char *fname, const struct utmp *putmp); 49void rxvt_update_wtmp (const char *fname, const struct utmp *putmp);
50#endif
51
49void rxvt_update_lastlog (const char *fname, const char *pty, const char *host); 52void rxvt_update_lastlog (const char *fname, const char *pty, const char *host);
50 53
51/* 54/*
52 * BSD style utmp entry 55 * BSD style utmp entry
53 * ut_line, ut_name, ut_host, ut_time 56 * ut_line, ut_name, ut_host, ut_time
137#ifdef HAVE_STRUCT_UTMPX 140#ifdef HAVE_STRUCT_UTMPX
138 strncpy (utx->ut_line, pty, sizeof (utx->ut_line)); 141 strncpy (utx->ut_line, pty, sizeof (utx->ut_line));
139 strncpy (utx->ut_user, (pwent && pwent->pw_name) ? pwent->pw_name : "?", 142 strncpy (utx->ut_user, (pwent && pwent->pw_name) ? pwent->pw_name : "?",
140 sizeof (utx->ut_user)); 143 sizeof (utx->ut_user));
141 strncpy (utx->ut_id, ut_id, sizeof (utx->ut_id)); 144 strncpy (utx->ut_id, ut_id, sizeof (utx->ut_id));
145# if HAVE_UTMPX_SESSION
142 utx->ut_session = getsid (0); 146 utx->ut_session = getsid (0);
147# endif
143 utx->ut_tv.tv_sec = time (NULL); 148 utx->ut_tv.tv_sec = time (NULL);
144 utx->ut_tv.tv_usec = 0; 149 utx->ut_tv.tv_usec = 0;
145 utx->ut_pid = cmd_pid; 150 utx->ut_pid = cmd_pid;
146# ifdef HAVE_UTMPX_HOST 151# ifdef HAVE_UTMPX_HOST
147 strncpy (utx->ut_host, hostname, sizeof (utx->ut_host)); 152 strncpy (utx->ut_host, hostname, sizeof (utx->ut_host));
208# else 213# else
209 rxvt_update_wtmp (RXVT_WTMP_FILE, ut); 214 rxvt_update_wtmp (RXVT_WTMP_FILE, ut);
210# endif 215# endif
211# endif 216# endif
212# ifdef HAVE_STRUCT_UTMPX 217# ifdef HAVE_STRUCT_UTMPX
218# if HAVE_UPDWTMPX
213 updwtmpx (RXVT_WTMPX_FILE, utx); 219 updwtmpx (RXVT_WTMPX_FILE, utx);
220# else
221 pututxline (utx);
222# endif
214# endif 223# endif
215 } 224 }
216#endif 225#endif
217#if defined(LASTLOG_SUPPORT) && defined(RXVT_LASTLOG_FILE) 226#if defined(LASTLOG_SUPPORT) && defined(RXVT_LASTLOG_FILE)
218 if (options & Opt_loginShell) 227 if (options & Opt_loginShell)
262 strncpy (utx->ut_id, ut_id, sizeof (utx->ut_id)); 271 strncpy (utx->ut_id, ut_id, sizeof (utx->ut_id));
263 utx->ut_type = USER_PROCESS; 272 utx->ut_type = USER_PROCESS;
264 if ((tmputx = getutxid (utx))) /* position to entry in utmp file */ 273 if ((tmputx = getutxid (utx))) /* position to entry in utmp file */
265 utx = tmputx; 274 utx = tmputx;
266 utx->ut_type = DEAD_PROCESS; 275 utx->ut_type = DEAD_PROCESS;
276# if HAVE_UTMPX_SESSION
267 utx->ut_session = getsid (0); 277 utx->ut_session = getsid (0);
278# endif
268 utx->ut_tv.tv_sec = time (NULL); 279 utx->ut_tv.tv_sec = time (NULL);
269 utx->ut_tv.tv_usec = 0; 280 utx->ut_tv.tv_usec = 0;
270#endif 281#endif
271 282
272 /* 283 /*
283# else 294# else
284 rxvt_update_wtmp (RXVT_WTMP_FILE, ut); 295 rxvt_update_wtmp (RXVT_WTMP_FILE, ut);
285# endif 296# endif
286# endif 297# endif
287# ifdef HAVE_STRUCT_UTMPX 298# ifdef HAVE_STRUCT_UTMPX
299# if HAVE_UPDWTMPX
288 updwtmpx (RXVT_WTMPX_FILE, utx); 300 updwtmpx (RXVT_WTMPX_FILE, utx);
301# else
302 pututxline (utx);
303# endif
289# endif 304# endif
290 } 305 }
291#endif 306#endif
292 307
293 /* 308 /*
313/* ------------------------------------------------------------------------- */ 328/* ------------------------------------------------------------------------- */
314/* 329/*
315 * Write a BSD style utmp entry 330 * Write a BSD style utmp entry
316 */ 331 */
317#ifdef HAVE_UTMP_H 332#ifdef HAVE_UTMP_H
318/* INTPROTO */
319int 333int
320rxvt_write_bsd_utmp (int utmp_pos, struct utmp *wu) 334rxvt_write_bsd_utmp (int utmp_pos, struct utmp *wu)
321{ 335{
322 int fd; 336 int fd;
323 337
333 347
334/* ------------------------------------------------------------------------- */ 348/* ------------------------------------------------------------------------- */
335/* 349/*
336 * Update a BSD style wtmp entry 350 * Update a BSD style wtmp entry
337 */ 351 */
338#if defined(WTMP_SUPPORT) && !defined(HAVE_UPDWTMP) 352#if defined(WTMP_SUPPORT) && !defined(HAVE_UPDWTMP) && defined(HAVE_STRUCT_UTMP)
339/* INTPROTO */
340void 353void
341rxvt_update_wtmp (const char *fname, const struct utmp *putmp) 354rxvt_update_wtmp (const char *fname, const struct utmp *putmp)
342{ 355{
343 int fd, gotlock, retry; 356 int fd, gotlock, retry;
344 struct flock lck; /* fcntl locking scheme */ 357 struct flock lck; /* fcntl locking scheme */
376} 389}
377#endif 390#endif
378 391
379/* ------------------------------------------------------------------------- */ 392/* ------------------------------------------------------------------------- */
380#ifdef LASTLOG_SUPPORT 393#ifdef LASTLOG_SUPPORT
381/* INTPROTO */
382void 394void
383rxvt_update_lastlog (const char *fname, const char *pty, const char *host) 395rxvt_update_lastlog (const char *fname, const char *pty, const char *host)
384{ 396{
385# ifdef HAVE_STRUCT_LASTLOGX 397# ifdef HAVE_STRUCT_LASTLOGX
386 struct lastlogx llx; 398 struct lastlogx llx;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines