/*
* 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 (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
*/
/* 5-20-92 added newroot functions */
#include <stdio.h>
#include <limits.h>
#include <stdarg.h>
#include <unistd.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <dirent.h>
#include <pkginfo.h>
#include <pkgstrct.h>
#include <pkglocs.h>
#include <errno.h>
#include "libadm.h"
static char *svr4inst(char *);
static int ckinfo(char *, char *, char *);
static int ckinst(char *, char *, char *, char *, char *);
static int verscmp(char *, char *);
static int archcmp(char *, char *);
static int compver(char *, char *);
/*
* Globals:
* pkgdir - specifies the directory where information about packages
* resides, i.e. the pkginfo file is located in a subdirectory
*
* Caveats:
* The structure provided via "info" will contain malloc'd information;
* this will be free'd upon the next call to pkginfo with this
* same structure. Application calls must make sure this structure
* is null on the first call, or else we'll free static memory areas
* If the "pkg" argument is a wildcard specification, the next found
* instance available which matches the request will be returned
* If the "pkg" argument is a NULL pointer, the structure pointed to
* via "info" will have its elements deallocated and all files
* associated with this routine will be closed
*
* Return codes:
* A non-zero exit code indicates error with "errno" appropriately set:
* EINVAL - invalid argument
* ESRCH - there are no more instances of this package around
* EACCESS - unable to access files which should have been there
*/
/*VARARGS*/
int
{
int check;
return (-1);
}
return (0);
}
check = 0;
/* wild card specification */
return (-1);
} else {
/* request to check indicated instance */
check++;
}
return (-1);
if (check) {
/*
* verify that the provided instance matches
* any arch & vers specs that were provided
*/
ckvers)) {
return (-1);
}
}
return (0);
}
/*ARGSUSED*/
int
{
return (-1);
}
return (0);
return (-1);
}
pkgdir = get_PKGLOC();
return (-1);
}
return (0);
}
static void
{
/* free previously allocated space */
}
}
static int
{
int count;
return (-1);
}
*temp = '\0';
count = 0;
/* remove all whitespace from value */
while (*pt) {
pt++;
}
*copy = '\0';
}
count++;
temp[0] = '\0';
continue; /* not a parameter we're looking for */
if (!*memloc) {
return (-1); /* malloc from strdup failed */
}
}
if (!count) {
return (-1);
}
else {
}
}
return (0);
}
static int
{
if (pdirfp) {
}
/* determine pkginst - remove '.*' extension, if any */
*pt = '\0';
}
return (-1);
}
return (-1);
}
return (-1);
}
if (info) {
return (-1);
}
}
if (pt) {
/* eat leading space off of version spec */
pt++;
}
return (-1);
}
return (0);
}
static int
{
return (-1);
if (ckvers) {
/* Check for exact version match */
/* Check for compatible version */
return (-1);
}
}
return (0);
}
/*VARARGS*/
char *
{
/* request to close or rewind the file */
if (pdirfp) {
}
return (NULL);
}
if (!pkgdir)
pkgdir = get_PKGLOC();
return (NULL);
}
continue;
continue; /* ignore invalid SVR4 package names */
continue;
/*
* Leave directory open in case user requests another
* instance.
*/
return (pkginst);
}
/*
* If we are searching the directory which contains info about
* installed packages, check the pre-svr4 directory for an instance
* and be sure it matches any version specification provided to us
*/
/* search for pre-SVR4 instance */
return (pt);
}
/* close any file we might have open */
return (NULL);
}
/*ARGSUSED*/
static char *
{
char *pt;
if (pdirfp) {
}
return (NULL);
}
return (NULL);
continue;
/* the pkgnmchk function works on .name extensions */
continue;
continue;
continue;
*pt = '\0';
return (pkginst);
}
}
return (NULL);
}
static int
{
/* eat leading white space */
actual++;
request++;
/*
* Once the pointers don't match, return an error condition.
*/
return (-1);
/* eat white space if any in both the strings */
return (-1);
request++;
actual++;
}
}
return (0);
}
static int
{
get_PKGLOC(), pkginst);
return (-1);
if (*temp == '#')
continue;
return (0);
}
}
return (-1);
}
static int
{
char *pt;
return (0);
/* arch and archlist must not contain whitespace! */
while (*archlist) {
return (0);
while (*archlist) {
if (*archlist++ == ',')
break;
}
}
return (-1);
}
static int
{
int errflg;
return (1);
return (0);
}
temp[0] = '\0';
/* remove all whitespace from value */
while (*pt) {
pt++;
}
*copy = '\0';
if (myvers)
break;
if (myarch)
break;
} else
temp[0] = '\0';
}
errflg = 0;
errflg++;
if (myarch)
if (myvers)
return (errflg);
}