rules.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright (c) 1996, by Sun Microsystems, Inc.
* All Rights Reserved.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <locale.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <fcntl.h>
#include <stdlib.h>
#include "rules.h"
extern char *mstrdup(const char *);
void
{
char *s;
int base_active = 0;
int list_ent_cnt = 0;
int gign_ent_cnt = 0;
int lign_ent_cnt = 0;
char version[20];
if (s == (char *)0)
break;
if (*s == '#')
continue;
if (*s == '*')
continue;
#ifdef DEBUG
#endif /* DEBUG */
if (base_active) {
/*
* Tack local IGNORE strings to end of globals
*/
}
/*
* Process directives for previous BASE command
* if there was one. Also free up LIST items
* and local IGNORE items.
*/
rulefunc);
/*
* Free up space from LIST item list
*/
}
}
/*
* Free up space from local IGNORE item list
*/
}
}
}
base_active = 1;
/*
* Reset LIST item list and local IGNORE item
* list to be empty.
*/
/*
* Get BASE directory specified
*/
s = lex(0);
if (s == (char *)0) {
"illegal BASE command\n"));
return;
}
if (*s == '$') {
/*
* String starts with a '$', it must be an
* environment variable
*/
s = getenv(&s[1]);
if (s == (char *)NULL) {
gettext("cachefspack: "));
gettext("Can't find "
"environment variable\n"));
exit(1);
}
}
#ifdef DEBUG
#endif /* DEBUG */
continue;
}
#ifdef DEBUG
#endif /* DEBUG */
if (base_active) {
/*
* Local IGNORE rule
*/
while ((s = lex(0))
!= 0) {
}
} else {
/*
* Global IGNORE rule
*/
while ((s = lex(0)) != 0) {
}
}
continue;
}
#ifdef DEBUG
printf("LIST\n");
#endif /* DEBUG */
if (!base_active) {
"cachefspack: skipping LIST command - "));
gettext(" no active base\n"));
continue;
}
while ((s = lex(0)) != 0) {
}
continue;
}
s = lex(0);
if (s == (char *)0) {
exit(1);
}
"cachefspack: "));
"WARNING - version of packing rules "));
"does not match cachefspack version\n"));
}
}
}
/*
* Tack local IGNORE strings to end of globals
*/
}
}
struct item *
{
struct item * add_cmd_items();
} else {
sizeof (struct item));
}
return (last_item);
}
struct item *
{
char inbuf[MAX_RULE_SZ];
char *s;
void getcmd(char *, char *);
exit(1);
}
exit(1);
}
}
exit(1);
}
while (s = lex(0)) {
}
}
}
exit(1);
}
}
return (last_item);
}
void
{
char *s;
while (s = lex(0)) {
}
#ifdef DEBUG
#endif /* DEBUG */
}
/*
* routine:
* lex
*
* purpose:
* my own version of strtok that handles quoting and escaping
*
* parameters:
* string to be lexed (or 0 for same string)
*
* returns:
* pointer to next token
*
* notes:
* this routine makes no changes to the string it is passed,
* copying tokens into a static buffer.
*/
char *
{ char c, delim;
char *p;
const char *s;
static const char *savep = 0;
static char namebuf[MAX_RULE_SZ];
static char inbuf[MAX_RULE_SZ];
int len, space_left;
char *err;
/*
* if the file descriptor is non-zero read a new command. Otherwise
* get fields from current line.
*/
if (fd != 0) {
len = 0;
space_left = sizeof (inbuf);
if (len == 1) {
/*
* must be a blank line starting command.
* If a blank line occurs after the start of
* a command, blanks will be included in the
* command.
*/
len = 0;
continue;
}
len -= 2;
space_left -= len;
/*
* Continuation character
*/
if (strcmp(s, "\\\n") == 0) {
continue;
}
break;
}
return (err);
}
s = inbuf;
} else {
if (savep == 0)
return (0);
s = savep;
}
savep = 0;
/* skip over leading white space */
while (isspace(*s))
s++;
if (*s == 0) {
return (0);
}
/* see if this is a quoted string */
c = *s;
if (c == '\'' || c == '"') {
delim = c;
s++;
} else
delim = 0;
/* copy the token into the buffer */
for (p = namebuf; (c = *s) != 0; s++) {
savep = 0;
return (0);
}
/* literal escape */
if (c == '\\') {
s++;
*p++ = *s;
continue;
}
/* closing delimiter */
if (c == delim) {
s++;
break;
}
/* delimiting white space */
break;
/* ordinary characters */
*p++ = *s;
}
/* remember where we left off */
savep = *s ? s : 0;
/* null terminate and return the buffer */
*p = 0;
return (namebuf);
}
char *
{
static char pathb[MAXPATHLEN];
char *dnam;
char *get_dirname(char *);
int len;
/*
* absolute path name
*/
if (*linkpath == '/') {
} else {
/*
* relative path
*/
if (dnam == (char *)0) {
return ((char *) 0);
}
if (len == 0)
return (pathb);
/*
* path is relative to directory containing sym link
* remove "../" from beginning of linkpath
*/
} else {
/*
* path is relative to directory containing sym link
*/
}
}
return (pathb);
}