Lines Matching defs:node

126 	hp_node_t	node;
140 for (node = root; node != NULL; node = node->hp_sibling)
141 node->hp_basepath = NULL;
146 node = root;
147 while (node) {
148 sibling = node->hp_sibling;
149 if (node->hp_child)
150 hp_fini(node->hp_child);
151 if (node->hp_name)
152 free(node->hp_name);
153 if (node->hp_usage)
154 free(node->hp_usage);
155 if (node->hp_description)
156 free(node->hp_description);
157 free(node);
158 node = sibling;
165 * Walk a graph of hotplug nodes, executing a callback on each node.
171 hp_node_t node;
183 for (node = root; node; node = node->hp_sibling) {
184 rv = hp_callback(node, arg);
191 if (node->hp_child && (rv != HP_WALK_PRUNECHILD))
192 if (hp_traverse(node->hp_child, arg, hp_callback) ==
208 * Return a node's type.
211 hp_type(hp_node_t node)
213 i_hp_dprintf("hp_type: node=%p\n", (void *)node);
215 if (node == NULL) {
221 return (node->hp_type);
227 * Return a node's name.
230 hp_name(hp_node_t node)
232 i_hp_dprintf("hp_name: node=%p\n", (void *)node);
234 if (node == NULL) {
240 if (node->hp_name == NULL) {
245 return (node->hp_name);
251 * Return a node's current state.
254 hp_state(hp_node_t node)
256 i_hp_dprintf("hp_state: node=%p\n", (void *)node);
258 if (node == NULL) {
264 if ((node->hp_type != HP_NODE_CONNECTOR) &&
265 (node->hp_type != HP_NODE_PORT)) {
271 return (node->hp_state);
280 hp_usage(hp_node_t node)
282 i_hp_dprintf("hp_usage: node=%p\n", (void *)node);
284 if (node == NULL) {
290 if (node->hp_type != HP_NODE_USAGE) {
296 if (node->hp_usage == NULL) {
301 return (node->hp_usage);
310 hp_description(hp_node_t node)
312 i_hp_dprintf("hp_description: node=%p\n", (void *)node);
314 if (node == NULL) {
320 if ((node->hp_type != HP_NODE_CONNECTOR) &&
321 (node->hp_type != HP_NODE_PORT)) {
327 if (node->hp_description == NULL) {
332 return (node->hp_description);
341 hp_last_change(hp_node_t node)
343 i_hp_dprintf("hp_last_change: node=%p\n", (void *)node);
345 if (node == NULL) {
351 if ((node->hp_type != HP_NODE_CONNECTOR) &&
352 (node->hp_type != HP_NODE_PORT)) {
358 return (node->hp_last_change);
364 * Return a node's parent node.
367 hp_parent(hp_node_t node)
369 i_hp_dprintf("hp_parent: node=%p\n", (void *)node);
371 if (node == NULL) {
377 if (node->hp_parent == NULL) {
378 i_hp_dprintf("hp_parent: node has no parent.\n");
382 return (node->hp_parent);
388 * Return a node's first child node.
391 hp_child(hp_node_t node)
393 i_hp_dprintf("hp_child: node=%p\n", (void *)node);
395 if (node == NULL) {
401 if (node->hp_child == NULL) {
402 i_hp_dprintf("hp_child: node has no child.\n");
406 return (node->hp_child);
412 * Return a node's next sibling node.
415 hp_sibling(hp_node_t node)
417 i_hp_dprintf("hp_sibling: node=%p\n", (void *)node);
419 if (node == NULL) {
425 if (node->hp_sibling == NULL) {
426 i_hp_dprintf("hp_sibling: node has no sibling.\n");
430 return (node->hp_sibling);
436 * Return the path (and maybe connection name) of a node.
440 hp_path(hp_node_t node, char *path, char *connection)
448 i_hp_dprintf("hp_path: node=%p, path=%p, connection=%p\n", (void *)node,
451 if ((node == NULL) || (path == NULL) || (connection == NULL)) {
461 if ((node->hp_type == HP_NODE_CONNECTOR) ||
462 (node->hp_type == HP_NODE_PORT))
463 (void) strlcpy(connection, node->hp_name, MAXPATHLEN);
465 /* Trace back to the root node, accumulating components */
466 for (parent = node; parent != NULL; parent = parent->hp_parent) {
483 * node, then append the accumulated components in reverse order.
504 * Initiate a state change operation on a node.
507 hp_set_state(hp_node_t node, uint_t flags, int state, hp_node_t *resultsp)
516 i_hp_dprintf("hp_set_state: node=%p, flags=0x%x, state=0x%x, "
517 "resultsp=%p\n", (void *)node, flags, state, (void *)resultsp);
520 if ((node == NULL) || (resultsp == NULL) ||
526 /* Check node type */
527 if ((node->hp_type != HP_NODE_CONNECTOR) &&
528 (node->hp_type != HP_NODE_PORT)) {
538 if (node->hp_type != HP_NODE_CONNECTOR) {
546 if (node->hp_type != HP_NODE_PORT) {
556 /* Get path and connection of specified node */
557 if ((rv = hp_path(node, path, connection)) != 0)
586 * indicated by the given hotplug information node.
589 hp_set_private(hp_node_t node, const char *options, char **resultsp)
598 i_hp_dprintf("hp_set_private: node=%p, options=%p, resultsp=%p\n",
599 (void *)node, (void *)options, (void *)resultsp);
602 if ((node == NULL) || (options == NULL) || (resultsp == NULL)) {
607 /* Check node type */
608 if (node->hp_type != HP_NODE_CONNECTOR) {
616 /* Get path and connection of specified node */
617 if ((rv = hp_path(node, path, connection)) != 0)
646 * indicated by the given hotplug information node.
649 hp_get_private(hp_node_t node, const char *options, char **resultsp)
658 i_hp_dprintf("hp_get_private: node=%p, options=%p, resultsp=%p\n",
659 (void *)node, (void *)options, (void *)resultsp);
662 if ((node == NULL) || (options == NULL) || (resultsp == NULL)) {
667 /* Check node type */
668 if (node->hp_type != HP_NODE_CONNECTOR) {
676 /* Get path and connection of specified node */
677 if ((rv = hp_path(node, path, connection)) != 0)
712 hp_node_t node;
743 for (node = root; node != NULL; node = node->hp_sibling) {
744 if ((rv = i_hp_pack_branch(node, &buf, &len)) == 0) {
841 /* Store the base path in each root node */
933 * Pack an individual node of a hotplug information snapshot.
936 i_hp_pack_node(hp_node_t node, char **bufp, size_t *lenp)
947 (uint32_t)node->hp_type)) != 0)
950 if ((node->hp_name) &&
951 ((rv = nvlist_add_string(nvl, HP_INFO_NAME, node->hp_name)) != 0))
954 if ((node->hp_usage) &&
955 ((rv = nvlist_add_string(nvl, HP_INFO_USAGE, node->hp_usage)) != 0))
958 if ((node->hp_description) &&
960 node->hp_description)) != 0))
963 if ((rv = nvlist_add_uint32(nvl, HP_INFO_STATE, node->hp_state)) != 0)
966 if ((node->hp_last_change != 0) &&
968 node->hp_last_change)) != 0))
995 hp_node_t node = NULL;
1013 * always the root node. And zero or more subordinate
1023 /* Check that there is only one root node */
1024 if (node != NULL) {
1025 hp_fini(node);
1032 rv = i_hp_unpack_node(buf, len, parent, &node);
1043 rv = i_hp_unpack_branch(buf, len, node, &child);
1046 hp_fini(node);
1054 node->hp_child = child;
1061 *retp = node;
1068 * Unpack an individual hotplug information node.
1073 hp_node_t node;
1083 /* Unpack node into an nvlist */
1087 /* Allocate the new node */
1088 if ((node = (hp_node_t)calloc(1, sizeof (struct hp_node))) == NULL) {
1100 node->hp_type = val_uint32;
1106 if ((node->hp_name = strdup(val_string)) == NULL) {
1115 node->hp_state = val_uint32;
1121 if ((node->hp_usage = strdup(val_string)) == NULL) {
1130 if ((node->hp_description = strdup(val_string))
1140 node->hp_last_change = (time_t)val_uint32;
1153 hp_fini(node);
1158 node->hp_parent = parent;
1159 *retp = node;