main.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-1998, 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>
#define MAIN 1
#include "rules.h"
#include "elfrd.h"
int verbose = 0;
int
{
int prtfn();
int packfn();
int unpackfn();
int inquirefn();
FILE *open_rulesfile();
int c;
int fflag = 0;
int Bflag = 0;
int index;
char *rulesfile;
int typearg = 0;
int (*wrkfunc)();
extern char *optarg;
extern void bld_pack_list();
extern void usage();
#if !defined(TEXT_DOMAIN)
#define TEXT_DOMAIN "SYS_TEST"
#endif
(void) textdomain(TEXT_DOMAIN);
rfd = open_rulesfile();
/* create hash table for tracking libraries */
if (hcreate(10000) == 0) {
/* unlikely this ever happens or I would work around it */
gettext("cachefspack: can't create hash table\n"));
exit(1);
}
switch (c) {
case 'd':
typearg++;
break;
case 'f':
fflag++;
break;
case 'h':
usage();
exit(0);
break;
case 'i':
typearg++;
break;
case 'p':
typearg++;
break;
case 'r':
global_flags |= LF_REGEX;
break;
case 's':
break;
case 'u':
typearg++;
break;
case 'v':
verbose = 1;
break;
case 'B':
Bflag++;
break;
case 'I':
break;
case 'L':
break;
case 'U':
typearg++;
break;
default:
usage();
exit(1);
}
}
if (global_flags != 0) {
}
"cachefspack: B and f options are mutually exclusive\n"));
exit(1);
}
if (fflag) {
"cachefspack: can't open file associated"
" with -f\n"));
exit(1);
}
}
if (typearg != 1) {
if (typearg == 0) {
} else {
"cachefspack: only one 'd', 'i', 'p' or 'u' "));
gettext(" option allowed\n"));
exit(1);
}
}
"cachefspack: 'B' or 'f' specified "));
gettext("with filenames\n"));
exit(1);
}
#ifdef DEBUG
#endif /* DEBUG */
}
}
exit(0);
}
/*
* The bld_pack_list() function is used to write the temporary packing
* list function. When the BASE directory changes, a new BASE command is
* generated. If the filename argument(fnam) starts with a '/', then the
* filename is assumed to be an absolute pathname. Otherwise, the filename
* is assumed to be realtive to the current directory.
*/
void
{
static int last_base_sz = 1;
char *lastsl_pos;
int sz;
int endpos;
char *cwd;
/* strip off any trailing /'s */
else
break;
}
if ((last_base_sz != sz) ||
last_base_sz = sz;
}
} else { /* relative pathname */
/* Really only need to call this once, ... */
if ((last_base_sz != sz) ||
last_base_sz = sz;
}
}
}
void
usage()
{
#ifdef DEBUG
gettext("cachefspack -[dipu] -[fBIL] [-h] [-r] [-s] [-U dir]"));
#else /* DEBUG */
gettext("cachefspack -[dipu] -[f] [-h] [-r] [-s] [-U dir]"));
#endif /* DEBUG */
printf("\n");
gettext("Must select 1 and only 1 of the following 5 options\n"));
#ifdef DEBUG
#endif /* DEBUG */
"-r Interpret strings in LIST rules as regular expressions\n"));
}