rdproto – parse and process a proto file listing
typedef void Protoenum(char *new, char *old, Dir *d, void *a)
typedef void Protowarn(char *msg, void *a)
int rdproto(char *proto, char *root, Protoenum *enm,
Protowarn *warn, void *a)
reads and interprets the named
file relative to the
Each line of the
file specifies a file to copy except lines in the form of
which sets an attribute (see below).
Blank lines and lines beginning with
Indentation (usually tabs) is significant,
with each level of indentation corresponding to a level in the file tree.
Fields within a line are separated by white space.
The first field is the last path element in the destination file tree.
The second field specifies the permissions.
The third field is the owner of the file,
and the fourth is the group owning the file.
The fifth field is the name of the file from which to copy;
this file is read from the current name space,
not the source file tree.
All fields except the first are optional.
for permissions, owner, or group
to fetch the corresponding information
from the file rather than override it.
(This is the default behavior when the fields
are not present; explicitly specifying
is useful when one wishes to set, say,
the file owner without setting the permissions.)
Names beginning with a
are expanded as environment variables.
If the first file specified in a directory is
all of the files in that directory are considered listed.
If the first file is
all of the files are copied, and all subdirectories
are recursively considered listed.
All files are considered relative to
Attributes, lines in the form of
apply to all files in the current
indention level after the attribute line.
Attributes are inherited to deeper levels but
each level can override them individualy.
skips all file names matching the regular expression
If owner or group is left unspecified on a file, the attributes
will override these fields.
attribute adds, sets or masks file permission bits if permissions
where not explicitly specified on the file. If multiple
lines are given and
is not a set operation (forced by
the modes are combined.
Except for the special
has the same syntax as in
For each file named by the
is called with
pointing at the name of the file (without the root prefix),
pointing at the name of the source file (with the root prefix,
at the desired directory information for the new file.
fields are guaranteed to be valid.
is the same argument passed to
typically it points at some extra state
used by the enumeration function.
When files or directories do not exist or
cannot be read by
it formats a warning message, calls
and continues processing;
prints the warning message to standard error.
was processed, –1 if it could not be opened.
directory of prototype files.
generic prototype file.