* Copyright (c) 1989 The Regents of the University of California.
* %sccs.include.redist.c%
static char sccsid
[] = "@(#)spec.c 5.15 (Berkeley) %G%";
int lineno
; /* Current spec line number. */
static void set
__P((char *, NODE
*));
static void unset
__P((char *, NODE
*));
register NODE
*centry
, *last
;
bzero(&ginfo
, sizeof(ginfo
));
for (lineno
= 1; fgets(buf
, sizeof(buf
), stdin
);
++lineno
, c_cur
= c_next
, c_next
= 0) {
if ((p
= index(buf
, '\n')) == NULL
)
err("line %d too long", lineno
);
/* See if next line is continuation line. */
/* Null-terminate the line. */
/* Skip leading whitespace. */
for (p
= buf
; *p
&& isspace(*p
); ++p
);
/* If nothing but whitespace or comment char, continue. */
/* Grab file name, "$", "set", or "unset". */
if ((p
= strtok(p
, "\n\t ")) == NULL
)
if (strcmp(p
+ 1, "set"))
if (strcmp(p
+ 1, "unset"))
err("slash character in file name");
/* Don't go up, if haven't gone down. */
if (last
->type
!= F_DIR
|| last
->flags
& F_DONE
) {
noparent
: err("no parent node");
if ((centry
= calloc(1, sizeof(NODE
) + strlen(p
))) == NULL
)
err("%s", strerror(errno
));
(void)strcpy(centry
->name
, p
);
centry
->flags
|= F_MAGIC
;
} else if (last
->type
== F_DIR
&& !(last
->flags
& F_DONE
)) {
last
= last
->child
= centry
;
centry
->parent
= last
->parent
;
last
= last
->next
= centry
;
for (; kw
= strtok(t
, "= \t\n"); t
= NULL
) {
ip
->flags
|= type
= parsekey(kw
);
if ((val
= strtok(NULL
, " \t\n")) == NULL
)
ip
->cksum
= strtoul(val
, &ep
, 10);
err("invalid checksum %s", val
);
ip
->st_gid
= strtoul(val
, &ep
, 10);
err("invalid gid %s", val
);
if ((gr
= getgrnam(val
)) == NULL
)
err("unknown group %s", val
);
if ((m
= setmode(val
)) == NULL
)
err("invalid file mode %s", val
);
ip
->st_mode
= getmode(m
, 0);
ip
->st_nlink
= strtoul(val
, &ep
, 10);
err("invalid link count %s", val
);
ip
->st_size
= strtoul(val
, &ep
, 10);
err("invalid size %s", val
);
if ((ip
->slink
= strdup(val
)) == NULL
)
err("%s", strerror(errno
));
ip
->st_mtime
= strtoul(val
, &ep
, 10);
err("invalid time %s", val
);
if (!strcmp(val
, "block"))
if (!strcmp(val
, "char"))
if (!strcmp(val
, "file"))
if (!strcmp(val
, "fifo"))
if (!strcmp(val
, "link"))
if (!strcmp(val
, "socket"))
err("unknown file type %s", val
);
ip
->st_uid
= strtoul(val
, &ep
, 10);
err("invalid uid %s", val
);
if ((pw
= getpwnam(val
)) == NULL
)
err("unknown user %s", val
);
while (p
= strtok(t
, "\n\t "))
ip
->flags
&= ~parsekey(p
);