From 0432c37dcb474d68385d498fcd5cbd945f20ee80 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 17 Jan 2006 06:06:42 +0000 Subject: [PATCH] *** empty log message *** --- src/logging.C | 21 ++++++++------------- src/logging.h | 38 ++++++++++++++++++++++++++++++++++++++ src/main.C | 4 ++-- src/rxvt.h | 36 +++--------------------------------- src/rxvtlib.h.in | 2 +- 5 files changed, 52 insertions(+), 49 deletions(-) diff --git a/src/logging.C b/src/logging.C index 4b2eed0e..c3d73962 100644 --- a/src/logging.C +++ b/src/logging.C @@ -30,14 +30,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *----------------------------------------------------------------------*/ -/*----------------------------------------------------------------------* - * Public: - * extern void cleanutent (void); - * extern void makeutent (const char * pty, const char * hostname); - * - * Private: - * rxvt_update_wtmp (); - *----------------------------------------------------------------------*/ #include "../config.h" #include "rxvt.h" @@ -65,8 +57,11 @@ static void rxvt_update_lastlog (const char *fname, con * make and write utmp and wtmp entries */ void -rxvt_term::makeutent (const char *pty, const char *hostname) +rxvt_session::login (const char *pty, int cmd_pid, bool login_shell, const char *hostname) { + this->cmd_pid = cmd_pid; + this->login_shell = login_shell; + #ifdef HAVE_STRUCT_UTMP struct utmp *ut = &this->ut; #endif @@ -201,7 +196,7 @@ rxvt_term::makeutent (const char *pty, const char *hostname) #ifdef WTMP_SUPPORT # ifdef WTMP_ONLY_ON_LOGIN - if (OPTION (Opt_loginShell)) + if (login_shell) # endif { # ifdef HAVE_STRUCT_UTMP @@ -217,7 +212,7 @@ rxvt_term::makeutent (const char *pty, const char *hostname) } #endif #if defined(LASTLOG_SUPPORT) && defined(RXVT_LASTLOG_FILE) - if (OPTION (Opt_loginShell)) + if (login_shell) rxvt_update_lastlog (RXVT_LASTLOG_FILE, pty, hostname); #endif } @@ -227,7 +222,7 @@ rxvt_term::makeutent (const char *pty, const char *hostname) * remove utmp and wtmp entries */ void -rxvt_term::cleanutent () +rxvt_session::logout () { #ifdef HAVE_STRUCT_UTMP struct utmp *ut = &this->ut; @@ -278,7 +273,7 @@ rxvt_term::cleanutent () */ #ifdef WTMP_SUPPORT # ifdef WTMP_ONLY_ON_LOGIN - if (OPTION (Opt_loginShell)) + if (login_shell) # endif { # ifdef HAVE_STRUCT_UTMP diff --git a/src/logging.h b/src/logging.h index 4b173d9b..7bb9ebd8 100644 --- a/src/logging.h +++ b/src/logging.h @@ -2,6 +2,22 @@ #define LOGGING_H_ #ifdef UTMP_SUPPORT +# if !defined(RXVT_UTMPX_FILE) || !defined(HAVE_STRUCT_UTMPX) +# undef HAVE_UTMPX_H +# undef HAVE_STRUCT_UTMPX +# endif +# if !defined(RXVT_UTMP_FILE) || !defined(HAVE_STRUCT_UTMP) +# undef HAVE_UTMP_H +# undef HAVE_STRUCT_UTMP +# endif + +# ifdef HAVE_UTMPX_H +# include +# endif +# ifdef HAVE_UTMP_H +# include +# endif + # if ! defined(HAVE_STRUCT_UTMPX) && ! defined(HAVE_STRUCT_UTMP) # error cannot build with utmp support - no utmp or utmpx struct found # endif @@ -9,6 +25,7 @@ # ifdef HAVE_LASTLOG_H # include # endif + # include # ifdef RXVT_UTMP_SYSV @@ -25,5 +42,26 @@ # define ut_name ut_user # endif +struct rxvt_session +{ + int utmp_pos; + int cmd_pid; + bool login_shell; + +#ifdef HAVE_STRUCT_UTMP + struct utmp ut; +#endif +#ifdef HAVE_STRUCT_UTMPX + struct utmpx utx; #endif +#if (defined(HAVE_STRUCT_UTMP) && defined(HAVE_UTMP_PID)) || defined(HAVE_STRUCT_UTMPX) + char ut_id[5]; +#endif + + void login (const char *pty, int cmd_pid, bool login_shell, const char *hostname); + void logout (); +}; + +#endif + #endif /* _LOGGING_H_ */ diff --git a/src/main.C b/src/main.C index 08b622af..01898c3b 100644 --- a/src/main.C +++ b/src/main.C @@ -726,9 +726,9 @@ rxvt_term::privileged_utmp (rxvt_privaction action) rxvt_privileges (RESTORE); if (action == SAVE) - makeutent (pty.name, rs[Rs_display_name]); + session.login (pty.name, cmd_pid, OPTION (Opt_loginShell), rs[Rs_display_name]); else - cleanutent (); + session.logout (); rxvt_privileges (IGNORE); } diff --git a/src/rxvt.h b/src/rxvt.h index 208f3527..9736d61b 100644 --- a/src/rxvt.h +++ b/src/rxvt.h @@ -791,24 +791,6 @@ enum { # define XPMClearArea(a, b, c, d, e, f, g) #endif -#ifdef UTMP_SUPPORT -# if !defined(RXVT_UTMPX_FILE) || !defined(HAVE_STRUCT_UTMPX) -# undef HAVE_UTMPX_H -# undef HAVE_STRUCT_UTMPX -# endif -# if !defined(RXVT_UTMP_FILE) || !defined(HAVE_STRUCT_UTMP) -# undef HAVE_UTMP_H -# undef HAVE_STRUCT_UTMP -# endif - -# ifdef HAVE_UTMPX_H -# include -# endif -# ifdef HAVE_UTMP_H -# include -# endif -#endif - #ifdef DEBUG_CMD # define D_CMD(x) fprintf x ; fputc('\n', stderr) #else @@ -1100,18 +1082,6 @@ struct rxvt_term : zero_initialized, rxvt_vars { struct mouse_event MEvent; XComposeStatus compose; ttymode_t tio; -#ifdef UTMP_SUPPORT -# ifdef HAVE_STRUCT_UTMP - struct utmp ut; -# endif -# ifdef HAVE_STRUCT_UTMPX - struct utmpx utx; -# endif -# if (defined(HAVE_STRUCT_UTMP) && defined(HAVE_UTMP_PID)) || defined(HAVE_STRUCT_UTMPX) - char ut_id[5]; -# endif - int utmp_pos; -#endif row_col_t oldcursor; #ifdef XPM_BACKGROUND bgPixmap_t bgPixmap; @@ -1154,6 +1124,9 @@ struct rxvt_term : zero_initialized, rxvt_vars { char *cmdbuf_ptr, *cmdbuf_endp; char cmdbuf_base[CBUFSIZ]; + rxvt_ptytty pty; + rxvt_session session; + rxvt_salloc *talloc; // text line allocator rxvt_salloc *ralloc; // rend line allocator @@ -1331,9 +1304,6 @@ struct rxvt_term : zero_initialized, rxvt_vars { // init.C void Get_Colours (); void get_ourmods (); - // logging.C - void makeutent (const char *pty, const char *hostname); - void cleanutent (); // main.C void privileged_utmp (rxvt_privaction action); bool set_fonts (); diff --git a/src/rxvtlib.h.in b/src/rxvtlib.h.in index fdc7d6cd..60c32312 100644 --- a/src/rxvtlib.h.in +++ b/src/rxvtlib.h.in @@ -31,6 +31,7 @@ #endif #include "ptytty.h" +#include "logging.h" extern "C" { #include /* Xlib, Xutil, Xresource, Xfuncproto */ @@ -245,7 +246,6 @@ struct rxvt_vars : TermWin_t { short numpix_colors; Cursor TermWin_cursor; /* cursor for vt window */ int sb_shadow; /* scrollbar shadow width */ - rxvt_ptytty pty; int numlock_state; line_t *row_buf; // all lines, scrollback + terminal, circular, followed by temp_buf line_t *drawn_buf; // text on screen -- 2.34.1