From 4875a4b66eabdfee2d9186a694ea3599f19a51ed Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Fri, 10 Sep 2004 08:30:51 +0000 Subject: * Makefile.in: Create libutil.a from bsdlib.o exports. * bsdlib.cc (logwtmp): Move from syscalls.cc to here. (login): Ditto. (logout): Ditto. * winsup.h (EXPORT_ALIAS): New macro. * exec.cc: Define alias symbols using EXPORT_ALIAS macro. * syscalls.cc: Ditto. * times.cc: Ditto. --- winsup/cygwin/libc/bsdlib.cc | 49 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'winsup/cygwin/libc/bsdlib.cc') diff --git a/winsup/cygwin/libc/bsdlib.cc b/winsup/cygwin/libc/bsdlib.cc index 71393fb87..c25163e2e 100644 --- a/winsup/cygwin/libc/bsdlib.cc +++ b/winsup/cygwin/libc/bsdlib.cc @@ -260,3 +260,52 @@ setprogname (const char *newprogname) __progname = (char *)newprogname; } } + +extern "C" void +logwtmp (const char *line, const char *user, const char *host) +{ + struct utmp ut; + memset (&ut, 0, sizeof ut); + ut.ut_type = USER_PROCESS; + ut.ut_pid = getpid (); + if (line) + strncpy (ut.ut_line, line, sizeof ut.ut_line); + time (&ut.ut_time); + if (user) + strncpy (ut.ut_user, user, sizeof ut.ut_user); + if (host) + strncpy (ut.ut_host, host, sizeof ut.ut_host); + updwtmp (_PATH_WTMP, &ut); +} + +extern "C" void +login (struct utmp *ut) +{ + pututline (ut); + endutent (); + updwtmp (_PATH_WTMP, ut); +} + +extern "C" int +logout (char *line) +{ + struct utmp ut_buf, *ut; + + memset (&ut_buf, 0, sizeof ut_buf); + strncpy (ut_buf.ut_line, line, sizeof ut_buf.ut_line); + setutent (); + ut = getutline (&ut_buf); + + if (ut) + { + ut->ut_type = DEAD_PROCESS; + memset (ut->ut_user, 0, sizeof ut->ut_user); + memset (ut->ut_host, 0, sizeof ut->ut_host); + time (&ut->ut_time); + debug_printf ("set logout time for %s", line); + pututline (ut); + endutent (); + return 1; + } + return 0; +} -- cgit v1.2.3