config.c revision b6c60aa36ecfa580eac0ad61b2b4b327ee2a9b34
/*
* 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.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* config.c -- system configuration cache module
*
* this module caches the system configuration in a format useful
* to eft. the information is loaded into this module by
* config_snapshot() at the beginning of each FME. config_snapshot()
* calls the platform-specific platform_config_snapshot() to get
* the configuration information loaded up.
*/
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <strings.h>
#include "alloc.h"
#include "out.h"
#include "literals.h"
#include "stable.h"
#include "lut.h"
#include "tree.h"
#include "itree.h"
#include "ipath.h"
#include "ptree.h"
#include "eval.h"
#include "config.h"
#include "fme.h"
#include "platform.h"
/*
* private data structure for storing config. all access to
* to this information happens using the config.h interfaces.
*/
struct config {
const char *s;
int num;
};
/*
* newcnode -- local function to allocate new config node
*/
static struct config *
{
retval->s = s;
return (retval);
}
/*
* If we need to cache certain types of nodes for reverse look-up or
* somesuch, do it here. Currently we need to cache nodes representing
* cpus.
*/
static void
{
if (n->s != stable("cpu"))
return;
}
/*
*/
struct config *
{
char *thiscom; /* this component */
char *nextcom; /* next component */
char svdigit;
int len;
int num;
const char *s;
int exists;
while (*path) {
*nextcom = '\0';
/* start at end of string and work backwards */
"component \"%s\" has no number following it",
path);
thiscom--;
"component \"%s\" has no name part", path);
thiscom++; /* move to first numeric character */
*thiscom = '\0';
*nextcom++ = '/';
/* now we have s & num, figure out if it exists already */
exists = 0;
exists = 1;
}
if (!exists) {
/* creating new node */
if (!add) {
/*
* indicate component not found by copying
* it to path (allows better error messages
* in the caller).
*/
return (NULL);
}
if (lastcp)
else
}
return (parent); /* all done */
/* move on to next component */
}
return (parent);
}
/*
* addconfigprop -- add a config prop to a config cache entry
*/
static void
{
}
/*
* addconfig -- add a config from parse tree to given configuration cache
*/
/*ARGSUSED*/
static void
{
const char *s;
int num;
int exists;
/* now we have s & num, figure out if it exists already */
exists = 0;
exists = 1;
}
if (!exists) {
/* creating new node */
if (lastcp)
else
}
/* move on to next component */
}
/* add configuration properties */
}
/*
* config_cook -- convert raw config strings to eft internal representation
*/
void
{
char *pv;
return;
goto eftcfgs;
}
if (!*cfgstr)
(void *)(cfgstr + 1));
else
cfgstr++;
}
/* skip the initial slash from libtopo */
/*
* Note we'll only cache nodes that have
* properties on them. Intermediate nodes
* will have been added to the config tree,
* but we don't have easy means of accessing
* them except if we climb the tree from this
* newnode to the root.
*
* Luckily, the nodes we care to cache
* (currently just cpus) always have some
* properties attached to them
* so we don't bother climbing the tree.
*/
}
break;
cfgstr);
"property missing equals.\n", (void *)cfgstr);
break;
}
*equals = '\0';
/*
* If this property is a device path, cache it for quick lookup
*/
}
*equals = '=';
}
/* now run through Configs table, adding to config cache */
}
/*
* config_snapshot -- gather a snapshot of the current configuration
*/
struct cfgdata *
config_snapshot(void)
{
return (rawcfg);
}
/*
* prop_destructor -- free a prop value
*/
/*ARGSUSED*/
static void
{
}
/*
* structconfig_free -- free a struct config pointer and all its relatives
*/
static void
{
return;
}
/*
* config_free -- free a configuration snapshot
*/
void
{
return;
return;
}
/*
* config_next -- get the "next" config node
*/
struct config *
{
}
/*
* config_child -- get the "child" of a config node
*/
struct config *
{
}
/*
* config_setprop -- add a property to a config node
*/
void
{
}
/*
* config_getprop -- lookup a config property
*/
const char *
{
}
/*
* config_getcompname -- get the component name of a config node
*/
void
{
}
/*
* config_nodeize -- convert the config element represented by cp to struct
* node format
*/
static struct node *
{
const char *sname;
return (NULL);
return (tmpn);
}
/*ARGSUSED*/
static void
{
}
/*ARGSUSED*/
static void
{
}
/*
* config_bydev_lookup -- look up the path in our DEVcache lut. If we find
* it return the config path, but as a struct node.
*/
struct node *
{
return (NULL);
}
return (np);
}
/*
* config_bycpuid_lookup -- look up the cpu id in our CPUcache lut.
* If we find it return the config path, but as a struct node.
*/
struct node *
{
return (NULL);
}
return (np);
}
/*
* given the following:
* - np of type T_NAME which denotes a pathname
* - croot, the root node of a configuration
*
* return the cp for the last component in np's path
*/
static struct config *
{
char *path;
return (cp);
}
int
{
const char *s;
return (1);
/* for now s will point to a quote [see addconfigprop()] */
if (s == NULL)
return (1);
return (0);
}
#define CONNECTED_SEPCHARS " ,"
int
{
char *nameslist, *w;
int i, j;
valuep->v = 0;
for (i = 0; i < 2; i++) {
return (1);
}
/* to thine self always be connected */
valuep->v = 1;
return (0);
}
/*
* set one of the cp[]s to compcp and extract its "connected"
* property. search this property for the name associated with the
* other cp[].
*/
for (i = 0; i < 2 && valuep->v == 0; i++) {
FREE((void *)searchforname);
if (s != NULL) {
while (w != NULL) {
valuep->v = 1;
break;
}
}
}
}
}
/* a path shouldn't have more than one cp node */
if (valuep->v == 0)
return (0);
}
int
{
const char *s;
int i;
valuep->v = 0;
return (1);
for (i = 0; typestrings[i] != NULL; i++) {
if (s != NULL) {
break;
}
}
/* no entry for "type" */
if (valuep->v == 0)
return (1);
return (0);
}
int
{
"true", "TRUE", "t", "T",
"1", NULL };
const char *s;
int i, j;
valuep->v = 0;
return (1);
if (s != NULL) {
s = stable(s);
for (j = 0; truestrings[j] != NULL; j++) {
if (s == stable(truestrings[j])) {
valuep->v = 1;
return (0);
}
}
}
}
return (0);
}
int
{
valuep->v = 0;
valuep->v = 1;
return (0);
}
/*
* printprop -- print prop associated with config node
*/
static void
{
}
/*
* pconf -- internal printing function to recurse through the tree
*/
static void
{
char *sep = "/";
if (offset)
sep = "/";
else
sep = "";
} else
}
/*
* config_print -- spew the current configuration cache
*/
#define MAXCONFLINE 4096
void
{
char buf[MAXCONFLINE];
else
}