diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2004-12-15 17:29:01 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2004-12-15 17:29:01 +0000 |
commit | 2ef89b220a96cca8c1c92e434548a0a9cd0e0567 (patch) | |
tree | a4d0a7945e092d51946b8a0da7d30ad103eea129 /winsup/cygwin/syscalls.cc | |
parent | 4931fc2b3a00f9985945add29c6f5abbce991603 (diff) | |
download | cygnal-2ef89b220a96cca8c1c92e434548a0a9cd0e0567.tar.gz cygnal-2ef89b220a96cca8c1c92e434548a0a9cd0e0567.tar.bz2 cygnal-2ef89b220a96cca8c1c92e434548a0a9cd0e0567.zip |
* cygwin.din: Add utmpx symbols.
* syscalls.cc: Include utmpx.h. Implement utmpx functions as stubs
to utmp functions.
(copy_ut_to_utx): New static function.
(pututline): Change from void to struct utmp * as on Linux.
(setutxent): New function.
(endutxent): New function.
(getutxent): New function.
(getutxid): New function.
(getutxline): New function.
(pututxline): New function.
* include/utmpx.h: New file.
* include/cygwin/utmp.h: New file.
* include/cygwin/version.h: Bump API minor number.
* include/sys/utmp.h: Include cygwin/utmp.h. Move stuff common with
utmpx functionality there.
(pututline): Declare struct utmp *.
Diffstat (limited to 'winsup/cygwin/syscalls.cc')
-rw-r--r-- | winsup/cygwin/syscalls.cc | 71 |
1 files changed, 68 insertions, 3 deletions
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index c6a662f75..e7abeab22 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -29,6 +29,7 @@ details. */ #include <stdio.h> #include <process.h> #include <utmp.h> +#include <utmpx.h> #include <sys/uio.h> #include <errno.h> #include <ctype.h> @@ -2559,6 +2560,17 @@ static unsigned utix = 0; utmp_data_buf + utix++; \ }) +static struct utmpx * +copy_ut_to_utx (struct utmp *ut, struct utmpx *utx) +{ + if (!ut) + return NULL; + memcpy (utx, ut, sizeof *ut); + utx->ut_tv.tv_sec = ut->ut_time; + utx->ut_tv.tv_usec = 0; + return utx; +} + extern "C" struct utmp * getutent () { @@ -2635,16 +2647,16 @@ getutline (struct utmp *line) return NULL; } -extern "C" void +extern "C" struct utmp * pututline (struct utmp *ut) { if (check_null_invalid_struct (ut)) - return; + return NULL; internal_setutent (true); if (utmp_fd < 0) { debug_printf ("error: utmp_fd %d", utmp_fd); - return; + return NULL; } debug_printf ("ut->ut_type %d, ut->ut_pid %d, ut->ut_line '%s', ut->ut_id '%s'\n", ut->ut_type, ut->ut_pid, ut->ut_line, ut->ut_id); @@ -2659,6 +2671,59 @@ pututline (struct utmp *ut) } else locked_append (utmp_fd, ut, sizeof *ut); + return ut; +} + +extern "C" void +setutxent () +{ + internal_setutent (false); +} + +extern "C" void +endutxent () +{ + endutent (); +} + +extern "C" struct utmpx * +getutxent () +{ + static struct utmpx utx; + return copy_ut_to_utx (getutent (), &utx); +} + +extern "C" struct utmpx * +getutxid (const struct utmpx *id) +{ + static struct utmpx utx; + + if (__check_invalid_read_ptr (id, sizeof *id)) + return NULL; + ((struct utmpx *)id)->ut_time = id->ut_tv.tv_sec; + return copy_ut_to_utx (getutid ((struct utmp *) id), &utx); +} + +extern "C" struct utmpx * +getutxline (const struct utmpx *line) +{ + static struct utmpx utx; + + if (__check_invalid_read_ptr (line, sizeof *line)) + return NULL; + ((struct utmpx *)line)->ut_time = line->ut_tv.tv_sec; + return copy_ut_to_utx (getutline ((struct utmp *) line), &utx); +} + +extern "C" struct utmpx * +pututxline (const struct utmpx *utmpx) +{ + static struct utmpx utx; + + if (__check_invalid_read_ptr (utmpx, sizeof *utmpx)) + return NULL; + ((struct utmpx *)utmpx)->ut_time = utmpx->ut_tv.tv_sec; + return copy_ut_to_utx (pututline ((struct utmp *) utmpx), &utx); } extern "C" |