From 0ad513f42c10266bf4ab61089eb212efd05366f6 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Tue, 13 Jul 1999 19:54:40 +0000 Subject: renamed getfilepwent() and endfilepwent() to getfileent() and endfileent() as they are generic "file line-by-line" reading routines. lines with "#" at the front are ignored (as comments). this code started out as the password file reading code. (This used to be commit ef6df590fdf65a6d94b343998bac3a4d48ae07e0) --- source3/groupdb/aliasfile.c | 4 ++-- source3/groupdb/groupfile.c | 4 ++-- source3/include/proto.h | 4 ++-- source3/lib/util_file.c | 15 +++++++-------- source3/passdb/smbpass.c | 4 ++-- source3/passdb/smbpassgroup.c | 4 ++-- 6 files changed, 17 insertions(+), 18 deletions(-) diff --git a/source3/groupdb/aliasfile.c b/source3/groupdb/aliasfile.c index 00638f9411..c09d6cc23e 100644 --- a/source3/groupdb/aliasfile.c +++ b/source3/groupdb/aliasfile.c @@ -33,7 +33,7 @@ static char s_readbuf[1024]; static void *startalsfilepwent(BOOL update) { - return startfilepwent(lp_smb_alias_file(), + return startfileent(lp_smb_alias_file(), s_readbuf, sizeof(s_readbuf), &al_file_lock_depth, update); } @@ -44,7 +44,7 @@ static void *startalsfilepwent(BOOL update) static void endalsfilepwent(void *vp) { - endfilepwent(vp, &al_file_lock_depth); + endfileent(vp, &al_file_lock_depth); } /************************************************************************* diff --git a/source3/groupdb/groupfile.c b/source3/groupdb/groupfile.c index 0e10b801d8..dba190ce56 100644 --- a/source3/groupdb/groupfile.c +++ b/source3/groupdb/groupfile.c @@ -36,7 +36,7 @@ extern fstring global_sam_name; static void *startgrpfilepwent(BOOL update) { - return startfilepwent(lp_smb_group_file(), + return startfileent(lp_smb_group_file(), s_readbuf, sizeof(s_readbuf), &gp_file_lock_depth, update); } @@ -47,7 +47,7 @@ static void *startgrpfilepwent(BOOL update) static void endgrpfilepwent(void *vp) { - endfilepwent(vp, &gp_file_lock_depth); + endfileent(vp, &gp_file_lock_depth); } /************************************************************************* diff --git a/source3/include/proto.h b/source3/include/proto.h index 182c74ed6f..97398c553c 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -490,9 +490,9 @@ BOOL become_user_permanently(uid_t uid, gid_t gid); BOOL do_file_lock(int fd, int waitsecs, int type); BOOL file_lock(int fd, int type, int secs, int *plock_depth); BOOL file_unlock(int fd, int *plock_depth); -void *startfilepwent(char *pfile, char *s_readbuf, int bufsize, +void *startfileent(char *pfile, char *s_readbuf, int bufsize, int *file_lock_depth, BOOL update); -void endfilepwent(void *vp, int *file_lock_depth); +void endfileent(void *vp, int *file_lock_depth); SMB_BIG_UINT getfilepwpos(void *vp); BOOL setfilepwpos(void *vp, SMB_BIG_UINT tok); int getfileline(void *vp, char *linebuf, int linebuf_size); diff --git a/source3/lib/util_file.c b/source3/lib/util_file.c index faceed1dbd..37489086d8 100644 --- a/source3/lib/util_file.c +++ b/source3/lib/util_file.c @@ -113,22 +113,22 @@ BOOL file_unlock(int fd, int *plock_depth) update to be set = True if modification is required. ****************************************************************/ -void *startfilepwent(char *pfile, char *s_readbuf, int bufsize, +void *startfileent(char *pfile, char *s_readbuf, int bufsize, int *file_lock_depth, BOOL update) { FILE *fp = NULL; if (!*pfile) { - DEBUG(0, ("startfilepwent: No file set\n")); + DEBUG(0, ("startfileent: No file set\n")); return (NULL); } - DEBUG(10, ("startfilepwent: opening file %s\n", pfile)); + DEBUG(10, ("startfileent: opening file %s\n", pfile)); fp = sys_fopen(pfile, update ? "r+b" : "rb"); if (fp == NULL) { - DEBUG(0, ("startfilepwent: unable to open file %s\n", pfile)); + DEBUG(0, ("startfileent: unable to open file %s\n", pfile)); return NULL; } @@ -137,7 +137,7 @@ void *startfilepwent(char *pfile, char *s_readbuf, int bufsize, if (!file_lock(fileno(fp), (update ? F_WRLCK : F_RDLCK), 5, file_lock_depth)) { - DEBUG(0, ("startfilepwent: unable to lock file %s\n", pfile)); + DEBUG(0, ("startfileent: unable to lock file %s\n", pfile)); fclose(fp); return NULL; } @@ -152,13 +152,13 @@ void *startfilepwent(char *pfile, char *s_readbuf, int bufsize, /*************************************************************** End enumeration of the file. ****************************************************************/ -void endfilepwent(void *vp, int *file_lock_depth) +void endfileent(void *vp, int *file_lock_depth) { FILE *fp = (FILE *)vp; file_unlock(fileno(fp), file_lock_depth); fclose(fp); - DEBUG(7, ("endfilepwent: closed file.\n")); + DEBUG(7, ("endfileent: closed file.\n")); } /************************************************************************* @@ -181,7 +181,6 @@ BOOL setfilepwpos(void *vp, SMB_BIG_UINT tok) /************************************************************************* gets a line out of a file. - line is of format "xxxx:xxxxxx:xxxxx:". lines with "#" at the front are ignored. *************************************************************************/ int getfileline(void *vp, char *linebuf, int linebuf_size) diff --git a/source3/passdb/smbpass.c b/source3/passdb/smbpass.c index 464cec015c..e7adbe6d45 100644 --- a/source3/passdb/smbpass.c +++ b/source3/passdb/smbpass.c @@ -33,7 +33,7 @@ static char s_readbuf[1024]; static void *startsmbfilepwent(BOOL update) { - return startfilepwent(lp_smb_passwd_file(), s_readbuf, sizeof(s_readbuf), + return startfileent(lp_smb_passwd_file(), s_readbuf, sizeof(s_readbuf), &pw_file_lock_depth, update); } @@ -43,7 +43,7 @@ static void *startsmbfilepwent(BOOL update) static void endsmbfilepwent(void *vp) { - endfilepwent(vp, &pw_file_lock_depth); + endfileent(vp, &pw_file_lock_depth); } /************************************************************************* diff --git a/source3/passdb/smbpassgroup.c b/source3/passdb/smbpassgroup.c index 33b848cc76..056f198074 100644 --- a/source3/passdb/smbpassgroup.c +++ b/source3/passdb/smbpassgroup.c @@ -32,7 +32,7 @@ extern int DEBUGLEVEL; static void *startsmbfilegrpent(BOOL update) { static char s_readbuf[1024]; - return startfilepwent(lp_smb_passgrp_file(), s_readbuf, sizeof(s_readbuf), + return startfileent(lp_smb_passgrp_file(), s_readbuf, sizeof(s_readbuf), &grp_file_lock_depth, update); } @@ -42,7 +42,7 @@ static void *startsmbfilegrpent(BOOL update) static void endsmbfilegrpent(void *vp) { - endfilepwent(vp, &grp_file_lock_depth); + endfileent(vp, &grp_file_lock_depth); } /************************************************************************* -- cgit