mirror of
https://github.com/samba-team/samba.git
synced 2024-12-23 17:34:34 +03:00
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 commit is contained in:
parent
5d1fad53c2
commit
ef6df590fd
@ -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);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
|
Loading…
Reference in New Issue
Block a user