* pwdgrp.h (etc): Move to path.h.

(pwdgrp::max_lines): New field.
(pwdgrp::curr_lines): New field.
(pwdgrp::pwdgrp_buf): Ditto.
(pwdgrp_buf_elem_size): Ditto.
(pwdgrp_parse): Ditto.
(pwdgrp::gets): Just declare here.
(pwdgrp::load): Ditto.  Just take one argument.
(pwdgrp::load): Define overloaded function accepting passwd buf.
(pwdgrp::load): Define overloaded function accepting group buf.
* grp.cc: Use pwdgrp elements rather than standalone static variables
throughout.
(curr_lines): Eliminate.
(max_lines): Ditto.
(add_grp_line): Ditto.
(parse_grp): Define as returning boolean.  Accept void * arg and line count.
Coerce first argument into __group32 buf reference.  Increment curr_line as
appropriate.
(read_etc_group): Pass pwdgrp buffer to gr.load.
* passwd.cc: Use pwdgrp elements rather than standalone static variables
throughout.
(curr_lines): Eliminate.
(max_lines): Ditto.
(add_grp_line): Ditto.
(parse_passwd): Define as returning boolean.  Accept void * arg and line count.
Coerce first argument into passwd buf reference.  Increment curr_line as
appropriate.
(read_etc_group): Pass pwdgrp buffer to pr.load.
* path.cc (etc::fn): Extend buffer size to allow index by 1 rather than zero.
(etc::last_modified): Ditto.
(etc::change_possible): Ditto.  Renamed from sawchange.  Change to signed char
since elements are now tri-state.
(etc::init): Assume "handle" is 1 based rather than 0.
(etc::test_file_change): New function.  Sets change_possible based on file date
comparison.
(etc::dir_changed): Check file states immediately after changed_h is
initialized to avoid a race.
(etc::file_changed): Use test_file_change to detect if file needs to be
updated.
* path.h (etc): Move class here from pwdgrp.h.
* uinfo.cc: Move etc:: functions to path.cc.  Move pwdgrp functions here.
(pwdgrp::gets): Eliminate buf checks.  Just check eptr and set lptr.
(pwdgrp::add_line): New function.
(pwdgrp::load): Call generic add_line function which will call correct parser.
This commit is contained in:
Christopher Faylor
2003-01-20 02:57:54 +00:00
parent 6f2480fbf7
commit 7905c4f158
7 changed files with 314 additions and 231 deletions

View File

@ -206,3 +206,20 @@ int pathmatch (const char *path1, const char *path2) __attribute__ ((regparm (2)
int pathnmatch (const char *path1, const char *path2, int len) __attribute__ ((regparm (2)));
int path_prefix_p (const char *path1, const char *path2, int len1) __attribute__ ((regparm (3)));
/* FIXME: Move to own include file eventually */
#define MAX_ETC_FILES 2
class etc
{
static int curr_ix;
static signed char change_possible[MAX_ETC_FILES + 1];
static const char *fn[MAX_ETC_FILES + 1];
static FILETIME last_modified[MAX_ETC_FILES + 1];
static bool dir_changed (int);
static int init (int, const char *);
static bool file_changed (int);
static void set_last_modified (int, FILETIME&);
static bool test_file_change (int);
friend class pwdgrp;
};