/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (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 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <ctype.h>
#include <limits.h>
#include <pkgstrct.h>
#include <pkginfo.h>
#include <locale.h>
#include <libintl.h>
#include <unistd.h>
#include <stdlib.h>
#include <pkglib.h>
#include <install.h>
#include <libadm.h>
#include <libinst.h>
/*
* IMPORTANT NOTE: PLEASE SEE THE DEFINITION OF temp[] BELOW BEFORE
* CHANGING THE DEFINITION OF PATH_LGTH!!!!
*/
"path <%s>."
static int nrdonly = 0;
static int errflg = 0;
extern void attrdefault();
static int popenv(void);
static int doattrib(void);
static void doinclude(void);
static void dorsearch(void);
static void dosearch(void);
static void lputenv(char *s);
int
{
char **envsave;
int c, fakebasedir;
int i, n;
/*
* NOTE: THE SIZE OF temp IS HARD CODED INTO CALLS TO fscanf.
* YOU *MUST* MAKE SURE TO CHANGE THOSE CALLS IF THE SIZE OF temp
* IS EVER CHANGED!!!!!!
*/
quit(99);
}
attrdefault(); /* assume no default attributes */
/*
* Environment parameters are optional, so variable
* (envparam[i]) could be NULL.
*/
*pt = '\0';
*pt = '=';
quit(99);
}
quit(1);
}
}
errflg = 0;
fakebasedir = 0;
while (isspace(c))
if (c == '#') {
continue;
}
if (c == EOF)
break;
if (c == '!') {
/*
* IMPORTANT NOTE: THE SIZE OF temp IS HARD CODED INTO
* the FOLLOWING CALL TO fscanf -- YOU MUST CHANGE THIS
* LINE IF THE SIZE OF fscanf IS EVER CHANGED!!!
*/
doinclude();
dorsearch();
dosearch();
if (doattrib())
break;
/* put this into the local environment */
} else {
error(1);
}
continue;
}
char *errstr;
error(1);
"Unknown");
break;
}
if (n == 0)
break; /* done with file */
/* don't allow classname to be parametric */
error(1);
}
}
/*
* We don't need to search for things without any
* contents in them.
*/
error(1);
}
}
} else {
if (!path)
continue;
error(1);
}
}
}
/* Warn if attributes are not set correctly. */
int dowarning = 0;
int hasbadmode = 0;
dowarning = 1;
hasbadmode = 1;
}
dowarning = 1;
}
dowarning = 1;
}
if (dowarning) {
if (hasbadmode)
"?",
else
}
}
/*
* Resolve build parameters (initial lower case) in
* the link and target paths.
*/
error(1);
break;
}
}
}
/*
* Warn if top level file or directory is an install
* parameter
*/
fakebasedir = 1;
}
error(1);
break;
}
error(1);
break;
}
}
if (fakebasedir) {
fakebasedir = 0;
}
if (popenv())
goto again;
return (errflg ? 1 : 0);
}
static char *
{
register char *pt;
int i;
/*
* map any parameters specified in path to their corresponding values
* and make sure the path is in its canonical form; any parmeters for
* which a value is not defined will be left unexpanded. Since this
* is an actual search for a real file (which will not end up in the
* package) - we map ALL variables (both build and Install).
*/
*host = '\0';
/*
* search for path in the pseudo-root/basedir directory; note
* that package information files should NOT be included in
* this list
*/
}
/* looking for local object file */
/*
* file. Otherwise, we'll really be writing stuff, so we need
* to verify the source.
*/
error(1);
return (NULL);
}
}
return (host);
}
return (host);
}
}
if (!pt++)
return (host);
}
}
/* check current directory as a last resort */
return (host);
error(1);
return (NULL);
}
static void
dosearch(void)
{
int n;
n = 0;
do {
if (*pt != '/') {
/* make relative path an absolute directory */
}
}
}
static void
dorsearch(void)
{
int n;
n = 0;
do {
if (*pt != '/') {
/* make relative path an absolute directory */
}
}
/*
* This function reads the default mode, owner and group from the prototype
* file and makes that available.
*/
static int
doattrib(void)
{
int mode;
/*
* Now resolve any variables that may be present. Start on group and
* move backward since that keeps the resolved string from
* overwriting any of the other entries. This is required since
* mapvar() writes the resolved string over the string provided.
*/
/* extra tokens on the line */
error(1);
gettext("unreadable at end of line"));
return (1);
}
else {
error(1);
gettext("unreadable at group"));
return (1);
}
else {
error(1);
gettext("unreadable at owner"));
return (1);
}
/*
* For mode, don't use scanf, since we want to force an octal
* interpretation and need to limit the length of the owner and group
* specifications.
*/
else {
error(1);
gettext("unreadable at mode"));
return (1);
}
/* free any previous memory from qstrdup */
return (0);
}
static void
doinclude(void)
{
/*
* IMPORTANT NOTE: THE SIZE OF temp IS HARD CODED INTO THE
* FOLLOWING CALL TO fscanf -- YOU MUST CHANGE THIS LINE IF
* THE SIZE OF fscanf IS EVER CHANGED!!!
*/
return;
else if (*temp != '/')
else
}
/*
* This does what mappath() does except that it does it for ALL variables
* using whitespace as a token separator. This is used to resolve search
* paths and assignment statements. It doesn't effect the build versus
* install decision made for pkgmap variables.
*/
static void
{
/* eat white space */
pt++;
if (*pt == '$') {
*pt2 = '\0';
while (*pt2)
}
} else
}
if (*pt) {
*copy++ = ' ';
goto token;
}
*copy = '\0';
}
static void
{
}
if (flag)
errflg++;
}
/* Set up defaults and change to the build directory. */
static void
{
register char *pt;
error(1);
return;
}
error(1);
if (nfp >= 0) {
return;
} else
quit(1);
}
if (!nfp) {
/* upper level proto file */
if (file[0] == '/')
else {
/* path is relative to the prototype file specified */
quit(99);
}
}
if (topdir[0] == '\0')
} else {
*pt = '\0';
else {
/* same directory as the last prototype */
return; /* no need to canonize() or chdir() */
}
}
error(1);
if (!nfp)
(void) popenv();
}
}
/* Restore defaults and return to the prior directory. */
static int
popenv(void)
{
int i;
if (nfp) {
error(1);
return (popenv());
}
return (1);
}
return (0);
}
/*
* If this parameter isn't already in place, put it into the local
* environment. This means that command line directives override prototype
* file directives.
*/
static void
lputenv(char *s)
{
char *pt;
int i;
if (!pt)
return;
*pt = '\0';
for (i = 0; i < nrdonly; i++) {
*pt = '=';
return;
}
}
*pt = '=';
quit(99);
}
}
static char *
{
int i;
i = 0;
do {
/* convert with root & basedir info */
/* make it pretty again */
continue; /* host source must be a regular file */
}
return (copy);
error(1);
return (NULL);
}