Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2001-12-28 18:53:27 +0300
committerCorinna Vinschen <corinna@vinschen.de>2001-12-28 18:53:27 +0300
commit971ec8d3102e6f32d24e44c56e8656a45bec4c4e (patch)
tree19d2664aceb96bd405ee7d5b950986c2049c8b21
parent423d5064f2ad2a1f5d4808e37bcb42cfdf8197d6 (diff)
* 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.
-rw-r--r--winsup/cygwin/ChangeLog12
-rw-r--r--winsup/cygwin/cygwin.din12
-rw-r--r--winsup/cygwin/include/cygwin/version.h3
-rw-r--r--winsup/cygwin/syscalls.cc98
4 files changed, 124 insertions, 1 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index dad164f6d..0370760ea 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -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.
diff --git a/winsup/cygwin/cygwin.din b/winsup/cygwin/cygwin.din
index 41da8fa4e..e915d86b8 100644
--- a/winsup/cygwin/cygwin.din
+++ b/winsup/cygwin/cygwin.din
@@ -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
diff --git a/winsup/cygwin/include/cygwin/version.h b/winsup/cygwin/include/cygwin/version.h
index d24e64a3c..f6c3b750f 100644
--- a/winsup/cygwin/include/cygwin/version.h
+++ b/winsup/cygwin/include/cygwin/version.h
@@ -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
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index d0896169b..7686eb155 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -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;
+}