* 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"
* 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
#ifdef WTMP_SUPPORT
# ifdef WTMP_ONLY_ON_LOGIN
- if (OPTION (Opt_loginShell))
+ if (login_shell)
# endif
{
# ifdef HAVE_STRUCT_UTMP
}
#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
}
* remove utmp and wtmp entries
*/
void
-rxvt_term::cleanutent ()
+rxvt_session::logout ()
{
#ifdef HAVE_STRUCT_UTMP
struct utmp *ut = &this->ut;
*/
#ifdef WTMP_SUPPORT
# ifdef WTMP_ONLY_ON_LOGIN
- if (OPTION (Opt_loginShell))
+ if (login_shell)
# endif
{
# ifdef HAVE_STRUCT_UTMP
#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 <utmpx.h>
+# endif
+# ifdef HAVE_UTMP_H
+# include <utmp.h>
+# endif
+
# if ! defined(HAVE_STRUCT_UTMPX) && ! defined(HAVE_STRUCT_UTMP)
# error cannot build with utmp support - no utmp or utmpx struct found
# endif
# ifdef HAVE_LASTLOG_H
# include <lastlog.h>
# endif
+
# include <pwd.h>
# ifdef RXVT_UTMP_SYSV
# 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_ */
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);
}
# 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 <utmpx.h>
-# endif
-# ifdef HAVE_UTMP_H
-# include <utmp.h>
-# endif
-#endif
-
#ifdef DEBUG_CMD
# define D_CMD(x) fprintf x ; fputc('\n', stderr)
#else
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;
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
// 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 ();
#endif
#include "ptytty.h"
+#include "logging.h"
extern "C" {
#include <X11/Intrinsic.h> /* Xlib, Xutil, Xresource, Xfuncproto */
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