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-09-09 20:52:37 +0400
committerCorinna Vinschen <corinna@vinschen.de>2001-09-09 20:52:37 +0400
commit49eef6d5f7868a67b9ae84d747fb466d3335cf78 (patch)
tree6cb9f04cdfd2aaa8db8e2e5833211e4026305d66 /winsup/cygwin/pwdgrp.h
parentd961def403a334176adb4c79cb02385bfca230e7 (diff)
* cygheap.cc (init_cygheap::etc_changed): New method to signal
a change in /etc. * cygheap.h (struct init_cygheap): Add member `etc_changed_h' and method `etc_changed'. * grp.cc (enum grp_state): Eliminate. (class grp_check): Ditto. (group_state): Define as `class pwdgrp_check'. (parse_grp): Remeber path and modification time of /etc/group file. * passwd.cc (enum_pwd_state): Eliminate. (class pwd_check): Ditto. (passwd_state): Define as `class pwdgrp_check'. (read_etc_passwd): Remember path and modification time of /etc/passwd file. * pwdgrp.h: New file. (enum pwdgrp_state): Substitutes `pwd_state' and `grp_state'. (class pwdgrp_check): Substitutes `pwd_check' and `grp_check'.
Diffstat (limited to 'winsup/cygwin/pwdgrp.h')
-rw-r--r--winsup/cygwin/pwdgrp.h57
1 files changed, 57 insertions, 0 deletions
diff --git a/winsup/cygwin/pwdgrp.h b/winsup/cygwin/pwdgrp.h
new file mode 100644
index 000000000..bc27c7bb8
--- /dev/null
+++ b/winsup/cygwin/pwdgrp.h
@@ -0,0 +1,57 @@
+/* pwdgrp.h
+
+ Copyright 2001 Red Hat inc.
+
+ Stuff common to pwd and grp handling.
+
+This file is part of Cygwin.
+
+This software is a copyrighted work licensed under the terms of the
+Cygwin license. Please consult the file "CYGWIN_LICENSE" for
+details. */
+
+enum pwdgrp_state {
+ uninitialized = 0,
+ initializing,
+ emulated,
+ loaded
+};
+
+class pwdgrp_check {
+ pwdgrp_state state;
+ FILETIME last_modified;
+ char file_w32[MAX_PATH];
+
+public:
+ pwdgrp_check () : state (uninitialized) {}
+ operator pwdgrp_state ()
+ {
+ if (state != uninitialized && file_w32[0] && cygheap->etc_changed ())
+ {
+ HANDLE h;
+ WIN32_FIND_DATA data;
+
+ if ((h = FindFirstFile (file_w32, &data)) != INVALID_HANDLE_VALUE)
+ {
+ if (CompareFileTime (&data.ftLastWriteTime, &last_modified) > 0)
+ state = uninitialized;
+ FindClose (h);
+ }
+ }
+ return state;
+ }
+ void operator = (pwdgrp_state nstate)
+ {
+ state = nstate;
+ }
+ void set_last_modified (FILE *f)
+ {
+ if (!file_w32[0])
+ strcpy (file_w32, cygheap->fdtab[fileno (f)]->get_win32_name ());
+
+ BY_HANDLE_FILE_INFORMATION inf;
+ if (GetFileInformationByHandle (cygheap->fdtab[fileno (f)]->get_handle (),
+ &inf))
+ last_modified = inf.ftLastWriteTime;
+ }
+};