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); const char *inotype(u_int);
u_int parsekey(char *, int *); u_int parsekey(char *, int *);
char *rlink(char *); char *rlink(char *);
NODE *spec(void); NODE *mtree_readspec(FILE *fi);
int verify(void); int mtree_verifyspec(FILE *fi);
int check_excludes(const char *, const char *); int check_excludes(const char *, const char *);
void init_excludes(void); void init_excludes(void);

View File

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

View File

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

View File

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