/*
* 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 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#ifdef _KERNEL
#else
#include <string.h>
#include <strings.h>
#endif
#include <sys/mdesc_impl.h>
static int
/*
* Walk the machine description directed graph from a starting
* node searching for nodes of a given node name and using a
* given arc type. Call a callback function for each node found.
* Each node will be visited only once.
*
* Input Description
* ------------------- ----------------------------------------
* md_t * Pointer to md session
* mde_cookie_t Index of the starting node
* mde_str_cookie_t Node name cookie of the nodes to call
* the walk function
* mde_str_cookie_t Arc name cookie of the path to follow
* md_walk_fn_t The function to call for each node
* void * Private data to pass to the walker function
*
*/
int
{
int res;
return (-1);
}
/*
* Possible the caller was lazy and didn't check the
* validitiy of either the node name or the arc name
* on calling ... in which case fail to find any
* nodes.
* This is distinct, from a fail (-1) since we return
* that nothing was found.
*/
if (node_name_cookie == MDE_INVAL_STR_COOKIE ||
return (0);
}
/*
* if we want to start at the top, start at index 0
*/
if (start == MDE_INVAL_ELEM_COOKIE) {
start = 0;
}
/*
* Scan from the start point until the first node.
*/
start++;
}
/*
* This was a bogus start point if no node found
*/
return (-1); /* illegal start node specified */
}
/*
* Allocate a recursion detection structure so we only visit
* each node once.
*/
return (-1);
}
/*
* Now build the list of requested nodes.
*/
}
static int
{
int result;
/* Get the node element from the session */
/* see if cookie is infact a node */
return (MDE_WALK_ERROR);
}
/* have we been here before ? */
return (MDE_WALK_NEXT);
}
#ifdef DEBUG_LIBMDESC
{
int x;
for (x = 0; x < level; x++) {
printf("-");
}
}
#endif
/* is this node of the type we seek ? */
/*
* Yes. Call the callback function.
*/
if (result != MDE_WALK_NEXT) {
return (result);
}
}
/*
* Simply walk the elements in the node.
* if we find a matching arc, then recursively call
* the subordinate looking for a match
*/
/*
* The current node becomes the parent node, and the
* arc index is the new current node.
*/
if (result != MDE_WALK_NEXT) {
/* The walk is complete or terminated. */
return (result);
}
}
}
return (result);
}