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.17 by root, Thu Feb 17 15:07:48 2005 UTC vs.
Revision 1.21 by root, Sat Jan 14 10:17:40 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
47#if HAVE_STRUCT_UTMP 48#if HAVE_STRUCT_UTMP
48int rxvt_write_bsd_utmp (int utmp_pos, struct utmp *wu); 49int rxvt_write_bsd_utmp (int utmp_pos, struct utmp *wu);
49void rxvt_update_wtmp (const char *fname, const struct utmp *putmp); 50void rxvt_update_wtmp (const char *fname, const struct utmp *putmp);
97# ifdef HAVE_UTMP_PID 98# ifdef HAVE_UTMP_PID
98 setutent (); 99 setutent ();
99 strncpy (ut->ut_id, ut_id, sizeof (ut->ut_id)); 100 strncpy (ut->ut_id, ut_id, sizeof (ut->ut_id));
100 ut->ut_type = DEAD_PROCESS; 101 ut->ut_type = DEAD_PROCESS;
101 getutid (ut); /* position to entry in utmp file */ 102 getutid (ut); /* position to entry in utmp file */
102 strncpy (ut_id, ut_id, sizeof (ut_id)); 103 strncpy (this->ut_id, ut_id, sizeof (this->ut_id));
103# endif 104# endif
104#endif 105#endif
105 106
106#ifdef HAVE_STRUCT_UTMPX 107#ifdef HAVE_STRUCT_UTMPX
107 memset (utx, 0, sizeof (struct utmpx)); 108 memset (utx, 0, sizeof (struct utmpx));
108 setutxent (); 109 setutxent ();
109 strncpy (utx->ut_id, ut_id, sizeof (utx->ut_id)); 110 strncpy (utx->ut_id, ut_id, sizeof (utx->ut_id));
110 utx->ut_type = DEAD_PROCESS; 111 utx->ut_type = DEAD_PROCESS;
111 getutxid (utx); /* position to entry in utmp file */ 112 getutxid (utx); /* position to entry in utmp file */
112 strncpy (ut_id, ut_id, sizeof (ut_id)); 113 strncpy (this->ut_id, ut_id, sizeof (this->ut_id));
113#endif 114#endif
114 115
115#ifdef HAVE_STRUCT_UTMP 116#ifdef HAVE_STRUCT_UTMP
116 strncpy (ut->ut_line, pty, sizeof (ut->ut_line)); 117 strncpy (ut->ut_line, pty, sizeof (ut->ut_line));
117 ut->ut_time = time (NULL); 118 ut->ut_time = time (NULL);
176# else 177# else
177 FILE *fd0; 178 FILE *fd0;
178 179
179 if ((fd0 = fopen (TTYTAB_FILENAME, "r")) != NULL) 180 if ((fd0 = fopen (TTYTAB_FILENAME, "r")) != NULL)
180 { 181 {
181 char buf[256], name[256]; 182 char buf[256], name[256];
182 183
183 buf[sizeof (buf) - 1] = '\0'; 184 buf[sizeof (buf) - 1] = '\0';
184 for (i = 1; (fgets (buf, sizeof (buf) - 1, fd0) != NULL);) 185 for (i = 1; (fgets (buf, sizeof (buf) - 1, fd0) != NULL);)
185 { 186 {
186 if (*buf == '#' || sscanf (buf, "%s", name) != 1) 187 if (*buf == '#' || sscanf (buf, "%s", name) != 1)
202 } 203 }
203#endif 204#endif
204 205
205#ifdef WTMP_SUPPORT 206#ifdef WTMP_SUPPORT
206# ifdef WTMP_ONLY_ON_LOGIN 207# ifdef WTMP_ONLY_ON_LOGIN
207 if (options & Opt_loginShell) 208 if (OPTION (Opt_loginShell))
208# endif 209# endif
209 { 210 {
210# ifdef HAVE_STRUCT_UTMP 211# ifdef HAVE_STRUCT_UTMP
211# ifdef HAVE_UPDWTMP 212# ifdef HAVE_UPDWTMP
212 updwtmp (RXVT_WTMP_FILE, ut); 213 updwtmp (RXVT_WTMP_FILE, ut);
222# endif 223# endif
223# endif 224# endif
224 } 225 }
225#endif 226#endif
226#if defined(LASTLOG_SUPPORT) && defined(RXVT_LASTLOG_FILE) 227#if defined(LASTLOG_SUPPORT) && defined(RXVT_LASTLOG_FILE)
227 if (options & Opt_loginShell) 228 if (OPTION (Opt_loginShell))
228 rxvt_update_lastlog (RXVT_LASTLOG_FILE, pty, hostname); 229 rxvt_update_lastlog (RXVT_LASTLOG_FILE, pty, hostname);
229#endif 230#endif
230} 231}
231 232
232/* ------------------------------------------------------------------------- */ 233/* ------------------------------------------------------------------------- */
245 246
246#ifdef HAVE_STRUCT_UTMP 247#ifdef HAVE_STRUCT_UTMP
247# ifdef HAVE_UTMP_PID 248# ifdef HAVE_UTMP_PID
248 memset (ut, 0, sizeof (struct utmp)); 249 memset (ut, 0, sizeof (struct utmp));
249 setutent (); 250 setutent ();
250 strncpy (ut->ut_id, ut_id, sizeof (ut->ut_id)); 251 strncpy (ut->ut_id, this->ut_id, sizeof (ut->ut_id));
251 ut->ut_type = USER_PROCESS; 252 ut->ut_type = USER_PROCESS;
252 { 253 {
253 struct utmp *tmput = getutid (ut); 254 struct utmp *tmput = getutid (ut);
254 255
255 if (tmput) /* position to entry in utmp file */ 256 if (tmput) /* position to entry in utmp file */
266#endif 267#endif
267 268
268#ifdef HAVE_STRUCT_UTMPX 269#ifdef HAVE_STRUCT_UTMPX
269 memset (utx, 0, sizeof (struct utmpx)); 270 memset (utx, 0, sizeof (struct utmpx));
270 setutxent (); 271 setutxent ();
271 strncpy (utx->ut_id, ut_id, sizeof (utx->ut_id)); 272 strncpy (utx->ut_id, this->ut_id, sizeof (utx->ut_id));
272 utx->ut_type = USER_PROCESS; 273 utx->ut_type = USER_PROCESS;
273 if ((tmputx = getutxid (utx))) /* position to entry in utmp file */ 274 if ((tmputx = getutxid (utx))) /* position to entry in utmp file */
274 utx = tmputx; 275 utx = tmputx;
275 utx->ut_type = DEAD_PROCESS; 276 utx->ut_type = DEAD_PROCESS;
276# if HAVE_UTMPX_SESSION 277# if HAVE_UTMPX_SESSION
283 /* 284 /*
284 * Write ending wtmp entry 285 * Write ending wtmp entry
285 */ 286 */
286#ifdef WTMP_SUPPORT 287#ifdef WTMP_SUPPORT
287# ifdef WTMP_ONLY_ON_LOGIN 288# ifdef WTMP_ONLY_ON_LOGIN
288 if (options & Opt_loginShell) 289 if (OPTION (Opt_loginShell))
289# endif 290# endif
290 { 291 {
291# ifdef HAVE_STRUCT_UTMP 292# ifdef HAVE_STRUCT_UTMP
292# ifdef HAVE_UPDWTMP 293# ifdef HAVE_UPDWTMP
293 updwtmp (RXVT_WTMP_FILE, ut); 294 updwtmp (RXVT_WTMP_FILE, ut);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines