* Copyright (c) 1989, 1993
* The Regents of the University of California. All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
static char sccsid
[] = "@(#)spec.c 8.2 (Berkeley) 4/28/95";
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. */
(void)fprintf(stderr
, "line %d: {%s}\n", lineno
, p
);
/* 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
, &value
);
if (value
&& (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
= strtouq(val
, &ep
, 10);
err("invalid size %s", val
);
if ((ip
->slink
= strdup(val
)) == NULL
)
err("%s", strerror(errno
));
ip
->st_mtimespec
.ts_sec
= strtoul(val
, &ep
, 10);
err("invalid time %s", val
);
ip
->st_mtimespec
.ts_nsec
= 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
, NULL
);