Rename spec() and verify() functions to have mtree_ prefix and take

explicit file descriptor instead of assuming stdin.
This commit is contained in:
Poul-Henning Kamp 2003-11-05 20:07:40 +00:00
parent 11333b51ca
commit 93347ded1a
4 changed files with 10 additions and 13 deletions

View File

@ -39,8 +39,8 @@ char *flags_to_string(u_long);
const char *inotype(u_int);
u_int parsekey(char *, int *);
char *rlink(char *);
NODE *spec(void);
int verify(void);
NODE *mtree_readspec(FILE *fi);
int mtree_verifyspec(FILE *fi);
int check_excludes(const char *, const char *);
void init_excludes(void);

View File

@ -157,7 +157,7 @@ main(int argc, char *argv[])
cwalk();
exit(0);
}
status = verify();
status = mtree_verifyspec(stdin);
if (Uflag & (status == MISMATCHEXIT))
status = 0;
exit(status);

View File

@ -55,7 +55,7 @@ static void set(char *, NODE *);
static void unset(char *, NODE *);
NODE *
spec(void)
mtree_readspec(FILE *fi)
{
NODE *centry, *last;
char *p;
@ -66,7 +66,7 @@ spec(void)
centry = last = root = NULL;
bzero(&ginfo, sizeof(ginfo));
c_cur = c_next = 0;
for (lineno = 1; fgets(buf, sizeof(buf), stdin);
for (lineno = 1; fgets(buf, sizeof(buf), fi);
++lineno, c_cur = c_next, c_next = 0) {
/* Skip empty lines. */
if (buf[0] == '\n')
@ -186,21 +186,18 @@ set(char *t, NODE *ip)
break;
case F_MD5:
ip->md5digest = strdup(val);
if(!ip->md5digest) {
if(!ip->md5digest)
errx(1, "strdup");
}
break;
case F_SHA1:
ip->sha1digest = strdup(val);
if(!ip->sha1digest) {
if(!ip->sha1digest)
errx(1, "strdup");
}
break;
case F_RMD160:
ip->rmd160digest = strdup(val);
if(!ip->rmd160digest) {
if(!ip->rmd160digest)
errx(1, "strdup");
}
break;
case F_FLAGS:
if (strcmp("none", val) == 0)

View File

@ -59,11 +59,11 @@ static void miss(NODE *, char *);
static int vwalk(void);
int
verify(void)
mtree_verifyspec(FILE *fi)
{
int rval;
root = spec();
root = mtree_readspec(fi);
rval = vwalk();
miss(root, path);
return (rval);