* cygwin.din: Add symbols for endutent(), getutent(), getutid(),
getutline(), setutent() and utmpname(). * syscalls.cc (setutent): New function. (endutent): Ditto. (utmpname): Ditto. (getutent): Ditto. (getutid): Ditto. (getutline): Ditto. * include/cygwin/version.h: Bump API minor version.
This commit is contained in:
parent
423d5064f2
commit
971ec8d310
@ -1,3 +1,15 @@
|
||||
2001-12-28 Corinna Vinschen <corinna@vinschen.de>
|
||||
|
||||
* cygwin.din: Add symbols for endutent(), getutent(), getutid(),
|
||||
getutline(), setutent() and utmpname().
|
||||
* syscalls.cc (setutent): New function.
|
||||
(endutent): Ditto.
|
||||
(utmpname): Ditto.
|
||||
(getutent): Ditto.
|
||||
(getutid): Ditto.
|
||||
(getutline): Ditto.
|
||||
* include/cygwin/version.h: Bump API minor version.
|
||||
|
||||
2001-12-26 Christopher Faylor <cgf@redhat.com>
|
||||
|
||||
* cygmagic: Add define name to warning.
|
||||
|
@ -159,6 +159,8 @@ ecvtf
|
||||
_ecvtf = ecvtf
|
||||
endgrent
|
||||
_endgrent = endgrent
|
||||
endutent
|
||||
_endutent = endutent
|
||||
erf
|
||||
_erf = erf
|
||||
erfc
|
||||
@ -376,6 +378,12 @@ gettimeofday
|
||||
_gettimeofday = gettimeofday
|
||||
getuid
|
||||
_getuid = getuid
|
||||
getutent
|
||||
_getutent = getutent
|
||||
getutid
|
||||
_getutid = getutid
|
||||
getutline
|
||||
_getutline = getutline
|
||||
glob
|
||||
_glob = glob
|
||||
globfree
|
||||
@ -660,6 +668,8 @@ setegid
|
||||
_setegid = setegid
|
||||
setuid
|
||||
_setuid = setuid
|
||||
setutent
|
||||
_setutent = setutent
|
||||
chroot
|
||||
_chroot = chroot
|
||||
setvbuf
|
||||
@ -868,6 +878,8 @@ utime
|
||||
_utime = utime
|
||||
utimes
|
||||
_utimes = utimes
|
||||
utmpname
|
||||
_utmpname = utmpname
|
||||
vfiprintf
|
||||
_vfiprintf = vfiprintf
|
||||
vfork
|
||||
|
@ -146,12 +146,13 @@ details. */
|
||||
46: Remove cygwin_getshared
|
||||
47: Report EOTWarningZoneSize in struct mtget.
|
||||
48: Export "posix" regex functions
|
||||
49: Export setutent, endutent, utmpname, getutent, getutid, getutline.
|
||||
*/
|
||||
|
||||
/* Note that we forgot to bump the api for ualarm, strtoll, strtoull */
|
||||
|
||||
#define CYGWIN_VERSION_API_MAJOR 0
|
||||
#define CYGWIN_VERSION_API_MINOR 48
|
||||
#define CYGWIN_VERSION_API_MINOR 49
|
||||
|
||||
/* There is also a compatibity version number associated with the
|
||||
shared memory regions. It is incremented when incompatible
|
||||
|
@ -2407,3 +2407,101 @@ logout (char *line)
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static int utmp_fd = -2;
|
||||
static char *utmp_file = (char *) _PATH_UTMP;
|
||||
|
||||
static struct utmp utmp_data;
|
||||
|
||||
extern "C" void
|
||||
setutent ()
|
||||
{
|
||||
sigframe thisframe (mainthread);
|
||||
if (utmp_fd == -2)
|
||||
{
|
||||
utmp_fd = _open (utmp_file, O_RDONLY);
|
||||
}
|
||||
_lseek (utmp_fd, 0, SEEK_SET);
|
||||
}
|
||||
|
||||
extern "C" void
|
||||
endutent ()
|
||||
{
|
||||
sigframe thisframe (mainthread);
|
||||
_close (utmp_fd);
|
||||
utmp_fd = -2;
|
||||
}
|
||||
|
||||
extern "C" void
|
||||
utmpname (_CONST char *file)
|
||||
{
|
||||
sigframe thisframe (mainthread);
|
||||
if (check_null_empty_str (file))
|
||||
{
|
||||
debug_printf ("Invalid file");
|
||||
return;
|
||||
}
|
||||
utmp_file = strdup (file);
|
||||
debug_printf ("New UTMP file: %s", utmp_file);
|
||||
}
|
||||
|
||||
extern "C" struct utmp *
|
||||
getutent ()
|
||||
{
|
||||
sigframe thisframe (mainthread);
|
||||
if (utmp_fd == -2)
|
||||
setutent ();
|
||||
if (_read (utmp_fd, &utmp_data, sizeof (utmp_data)) != sizeof (utmp_data))
|
||||
return NULL;
|
||||
return &utmp_data;
|
||||
}
|
||||
|
||||
extern "C" struct utmp *
|
||||
getutid (struct utmp *id)
|
||||
{
|
||||
sigframe thisframe (mainthread);
|
||||
if (check_null_invalid_struct_errno (id))
|
||||
return NULL;
|
||||
while (_read (utmp_fd, &utmp_data, sizeof (utmp_data)) == sizeof (utmp_data))
|
||||
{
|
||||
switch (id->ut_type)
|
||||
{
|
||||
#if 0 /* Not available in Cygwin. */
|
||||
case RUN_LVL:
|
||||
case BOOT_TIME:
|
||||
case OLD_TIME:
|
||||
case NEW_TIME:
|
||||
if (id->ut_type == utmp_data.ut_type)
|
||||
return &utmp_data;
|
||||
break;
|
||||
#endif
|
||||
case INIT_PROCESS:
|
||||
case LOGIN_PROCESS:
|
||||
case USER_PROCESS:
|
||||
case DEAD_PROCESS:
|
||||
if (id->ut_id == utmp_data.ut_id)
|
||||
return &utmp_data;
|
||||
break;
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
extern "C" struct utmp *
|
||||
getutline (struct utmp *line)
|
||||
{
|
||||
sigframe thisframe (mainthread);
|
||||
if (check_null_invalid_struct_errno (line))
|
||||
return NULL;
|
||||
while (_read (utmp_fd, &utmp_data, sizeof (utmp_data)) == sizeof (utmp_data))
|
||||
{
|
||||
if ((utmp_data.ut_type == LOGIN_PROCESS ||
|
||||
utmp_data.ut_type == USER_PROCESS) &&
|
||||
!strncmp (utmp_data.ut_line, line->ut_line,
|
||||
sizeof (utmp_data.ut_line)))
|
||||
return &utmp_data;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user