17c478bd9Sstevel@tonic-gate /*
2*159d09a2SMark Phalan  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
37c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
47c478bd9Sstevel@tonic-gate  */
57c478bd9Sstevel@tonic-gate 
67c478bd9Sstevel@tonic-gate 
77c478bd9Sstevel@tonic-gate /*
87c478bd9Sstevel@tonic-gate  * prof_tree.c --- these routines maintain the parse tree of the
97c478bd9Sstevel@tonic-gate  * 	config file.
10505d05c7Sgtb  *
117c478bd9Sstevel@tonic-gate  * All of the details of how the tree is stored is abstracted away in
127c478bd9Sstevel@tonic-gate  * this file; all of the other profile routines build, access, and
137c478bd9Sstevel@tonic-gate  * modify the tree via the accessor functions found in this file.
147c478bd9Sstevel@tonic-gate  *
157c478bd9Sstevel@tonic-gate  * Each node may represent either a relation or a section header.
16505d05c7Sgtb  *
177c478bd9Sstevel@tonic-gate  * A section header must have its value field set to 0, and may a one
187c478bd9Sstevel@tonic-gate  * or more child nodes, pointed to by first_child.
19505d05c7Sgtb  *
207c478bd9Sstevel@tonic-gate  * A relation has as its value a pointer to allocated memory
217c478bd9Sstevel@tonic-gate  * containing a string.  Its first_child pointer must be null.
227c478bd9Sstevel@tonic-gate  *
237c478bd9Sstevel@tonic-gate  */
247c478bd9Sstevel@tonic-gate 
25505d05c7Sgtb 
26505d05c7Sgtb #include "prof_int.h"
27505d05c7Sgtb 
287c478bd9Sstevel@tonic-gate #include <stdio.h>
297c478bd9Sstevel@tonic-gate #include <string.h>
307c478bd9Sstevel@tonic-gate #ifdef HAVE_STDLIB_H
317c478bd9Sstevel@tonic-gate #include <stdlib.h>
327c478bd9Sstevel@tonic-gate #endif
337c478bd9Sstevel@tonic-gate #include <errno.h>
347c478bd9Sstevel@tonic-gate #include <ctype.h>
357c478bd9Sstevel@tonic-gate 
367c478bd9Sstevel@tonic-gate struct profile_node {
377c478bd9Sstevel@tonic-gate 	errcode_t	magic;
387c478bd9Sstevel@tonic-gate 	char *name;
397c478bd9Sstevel@tonic-gate 	char *value;
407c478bd9Sstevel@tonic-gate 	int group_level;
417c478bd9Sstevel@tonic-gate 	int final:1;		/* Indicate don't search next file */
42505d05c7Sgtb 	int deleted:1;
437c478bd9Sstevel@tonic-gate 	struct profile_node *first_child;
447c478bd9Sstevel@tonic-gate 	struct profile_node *parent;
457c478bd9Sstevel@tonic-gate 	struct profile_node *next, *prev;
467c478bd9Sstevel@tonic-gate };
477c478bd9Sstevel@tonic-gate 
487c478bd9Sstevel@tonic-gate #define CHECK_MAGIC(node) \
497c478bd9Sstevel@tonic-gate 	  if ((node)->magic != PROF_MAGIC_NODE) \
507c478bd9Sstevel@tonic-gate 		  return PROF_MAGIC_NODE;
517c478bd9Sstevel@tonic-gate 
527c478bd9Sstevel@tonic-gate /*
537c478bd9Sstevel@tonic-gate  * Free a node, and any children
547c478bd9Sstevel@tonic-gate  */
profile_free_node(struct profile_node * node)55505d05c7Sgtb void profile_free_node(struct profile_node *node)
567c478bd9Sstevel@tonic-gate {
577c478bd9Sstevel@tonic-gate 	struct profile_node *child, *next;
587c478bd9Sstevel@tonic-gate 
597c478bd9Sstevel@tonic-gate 	if (node->magic != PROF_MAGIC_NODE)
607c478bd9Sstevel@tonic-gate 		return;
617c478bd9Sstevel@tonic-gate 
627c478bd9Sstevel@tonic-gate 	if (node->name)
637c478bd9Sstevel@tonic-gate 		free(node->name);
647c478bd9Sstevel@tonic-gate 	if (node->value)
657c478bd9Sstevel@tonic-gate 		free(node->value);
667c478bd9Sstevel@tonic-gate 
677c478bd9Sstevel@tonic-gate 	for (child=node->first_child; child; child = next) {
687c478bd9Sstevel@tonic-gate 		next = child->next;
697c478bd9Sstevel@tonic-gate 		profile_free_node(child);
707c478bd9Sstevel@tonic-gate 	}
717c478bd9Sstevel@tonic-gate 	node->magic = 0;
727c478bd9Sstevel@tonic-gate 
737c478bd9Sstevel@tonic-gate 	free(node);
747c478bd9Sstevel@tonic-gate }
757c478bd9Sstevel@tonic-gate 
76505d05c7Sgtb #ifndef HAVE_STRDUP
77505d05c7Sgtb #undef strdup
78505d05c7Sgtb #define strdup MYstrdup
MYstrdup(const char * s)79505d05c7Sgtb static char *MYstrdup (const char *s)
80505d05c7Sgtb {
81505d05c7Sgtb     size_t sz = strlen(s) + 1;
82505d05c7Sgtb     char *p = malloc(sz);
83505d05c7Sgtb     if (p != 0)
84505d05c7Sgtb 	memcpy(p, s, sz);
85505d05c7Sgtb     return p;
86505d05c7Sgtb }
87505d05c7Sgtb #endif
88505d05c7Sgtb 
897c478bd9Sstevel@tonic-gate /*
907c478bd9Sstevel@tonic-gate  * Create a node
917c478bd9Sstevel@tonic-gate  */
profile_create_node(const char * name,const char * value,struct profile_node ** ret_node)92505d05c7Sgtb errcode_t profile_create_node(const char *name, const char *value,
93505d05c7Sgtb 			      struct profile_node **ret_node)
947c478bd9Sstevel@tonic-gate {
957c478bd9Sstevel@tonic-gate 	struct profile_node *new;
967c478bd9Sstevel@tonic-gate 
97*159d09a2SMark Phalan 	new = malloc(sizeof(struct profile_node));
987c478bd9Sstevel@tonic-gate 	if (!new)
997c478bd9Sstevel@tonic-gate 		return ENOMEM;
1007c478bd9Sstevel@tonic-gate 	memset(new, 0, sizeof(struct profile_node));
101*159d09a2SMark Phalan 	new->name = strdup(name);
1027c478bd9Sstevel@tonic-gate 	if (new->name == 0) {
103505d05c7Sgtb 	    profile_free_node(new);
104505d05c7Sgtb 	    return ENOMEM;
1057c478bd9Sstevel@tonic-gate 	}
1067c478bd9Sstevel@tonic-gate 	if (value) {
107*159d09a2SMark Phalan 		new->value = strdup(value);
1087c478bd9Sstevel@tonic-gate 		if (new->value == 0) {
109505d05c7Sgtb 		    profile_free_node(new);
110505d05c7Sgtb 		    return ENOMEM;
1117c478bd9Sstevel@tonic-gate 		}
1127c478bd9Sstevel@tonic-gate 	}
1137c478bd9Sstevel@tonic-gate 	new->magic = PROF_MAGIC_NODE;
1147c478bd9Sstevel@tonic-gate 
1157c478bd9Sstevel@tonic-gate 	*ret_node = new;
1167c478bd9Sstevel@tonic-gate 	return 0;
1177c478bd9Sstevel@tonic-gate }
1187c478bd9Sstevel@tonic-gate 
1197c478bd9Sstevel@tonic-gate /*
1207c478bd9Sstevel@tonic-gate  * This function verifies that all of the representation invarients of
1217c478bd9Sstevel@tonic-gate  * the profile are true.  If not, we have a programming bug somewhere,
1227c478bd9Sstevel@tonic-gate  * probably in this file.
1237c478bd9Sstevel@tonic-gate  */
profile_verify_node(struct profile_node * node)124505d05c7Sgtb errcode_t profile_verify_node(struct profile_node *node)
1257c478bd9Sstevel@tonic-gate {
1267c478bd9Sstevel@tonic-gate 	struct profile_node *p, *last;
1277c478bd9Sstevel@tonic-gate 	errcode_t	retval;
1287c478bd9Sstevel@tonic-gate 
1297c478bd9Sstevel@tonic-gate 	CHECK_MAGIC(node);
1307c478bd9Sstevel@tonic-gate 
1317c478bd9Sstevel@tonic-gate 	if (node->value && node->first_child)
1327c478bd9Sstevel@tonic-gate 		return PROF_SECTION_WITH_VALUE;
1337c478bd9Sstevel@tonic-gate 
1347c478bd9Sstevel@tonic-gate 	last = 0;
1357c478bd9Sstevel@tonic-gate 	for (p = node->first_child; p; last = p, p = p->next) {
1367c478bd9Sstevel@tonic-gate 		if (p->prev != last)
1377c478bd9Sstevel@tonic-gate 			return PROF_BAD_LINK_LIST;
1387c478bd9Sstevel@tonic-gate 		if (last && (last->next != p))
1397c478bd9Sstevel@tonic-gate 			return PROF_BAD_LINK_LIST;
1407c478bd9Sstevel@tonic-gate 		if (node->group_level+1 != p->group_level)
1417c478bd9Sstevel@tonic-gate 			return PROF_BAD_GROUP_LVL;
1427c478bd9Sstevel@tonic-gate 		if (p->parent != node)
1437c478bd9Sstevel@tonic-gate 			return PROF_BAD_PARENT_PTR;
1447c478bd9Sstevel@tonic-gate 		retval = profile_verify_node(p);
1457c478bd9Sstevel@tonic-gate 		if (retval)
1467c478bd9Sstevel@tonic-gate 			return retval;
1477c478bd9Sstevel@tonic-gate 	}
1487c478bd9Sstevel@tonic-gate 	return 0;
1497c478bd9Sstevel@tonic-gate }
1507c478bd9Sstevel@tonic-gate 
1517c478bd9Sstevel@tonic-gate /*
1527c478bd9Sstevel@tonic-gate  * Add a node to a particular section
1537c478bd9Sstevel@tonic-gate  */
profile_add_node(struct profile_node * section,const char * name,const char * value,struct profile_node ** ret_node)154505d05c7Sgtb errcode_t profile_add_node(struct profile_node *section, const char *name,
155505d05c7Sgtb 			   const char *value, struct profile_node **ret_node)
1567c478bd9Sstevel@tonic-gate {
1577c478bd9Sstevel@tonic-gate 	errcode_t retval;
1587c478bd9Sstevel@tonic-gate 	struct profile_node *p, *last, *new;
1597c478bd9Sstevel@tonic-gate 
1607c478bd9Sstevel@tonic-gate 	CHECK_MAGIC(section);
1617c478bd9Sstevel@tonic-gate 
1627c478bd9Sstevel@tonic-gate 	if (section->value)
1637c478bd9Sstevel@tonic-gate 		return PROF_ADD_NOT_SECTION;
1647c478bd9Sstevel@tonic-gate 
1657c478bd9Sstevel@tonic-gate 	/*
1667c478bd9Sstevel@tonic-gate 	 * Find the place to insert the new node.  We look for the
167505d05c7Sgtb 	 * place *after* the last match of the node name, since
1687c478bd9Sstevel@tonic-gate 	 * order matters.
1697c478bd9Sstevel@tonic-gate 	 */
1707c478bd9Sstevel@tonic-gate 	for (p=section->first_child, last = 0; p; last = p, p = p->next) {
171505d05c7Sgtb 		int cmp;
1727c478bd9Sstevel@tonic-gate 		cmp = strcmp(p->name, name);
1737c478bd9Sstevel@tonic-gate 		if (cmp > 0)
1747c478bd9Sstevel@tonic-gate 			break;
1757c478bd9Sstevel@tonic-gate 	}
1767c478bd9Sstevel@tonic-gate 	retval = profile_create_node(name, value, &new);
1777c478bd9Sstevel@tonic-gate 	if (retval)
1787c478bd9Sstevel@tonic-gate 		return retval;
1797c478bd9Sstevel@tonic-gate 	new->group_level = section->group_level+1;
180505d05c7Sgtb 	new->deleted = 0;
1817c478bd9Sstevel@tonic-gate 	new->parent = section;
1827c478bd9Sstevel@tonic-gate 	new->prev = last;
1837c478bd9Sstevel@tonic-gate 	new->next = p;
1847c478bd9Sstevel@tonic-gate 	if (p)
1857c478bd9Sstevel@tonic-gate 		p->prev = new;
1867c478bd9Sstevel@tonic-gate 	if (last)
1877c478bd9Sstevel@tonic-gate 		last->next = new;
1887c478bd9Sstevel@tonic-gate 	else
1897c478bd9Sstevel@tonic-gate 		section->first_child = new;
1907c478bd9Sstevel@tonic-gate 	if (ret_node)
1917c478bd9Sstevel@tonic-gate 		*ret_node = new;
1927c478bd9Sstevel@tonic-gate 	return 0;
1937c478bd9Sstevel@tonic-gate }
1947c478bd9Sstevel@tonic-gate 
1957c478bd9Sstevel@tonic-gate /*
1967c478bd9Sstevel@tonic-gate  * Set the final flag on a particular node.
1977c478bd9Sstevel@tonic-gate  */
profile_make_node_final(struct profile_node * node)198505d05c7Sgtb errcode_t profile_make_node_final(struct profile_node *node)
1997c478bd9Sstevel@tonic-gate {
2007c478bd9Sstevel@tonic-gate 	CHECK_MAGIC(node);
2017c478bd9Sstevel@tonic-gate 
2027c478bd9Sstevel@tonic-gate 	node->final = 1;
2037c478bd9Sstevel@tonic-gate 	return 0;
2047c478bd9Sstevel@tonic-gate }
2057c478bd9Sstevel@tonic-gate 
2067c478bd9Sstevel@tonic-gate /*
2077c478bd9Sstevel@tonic-gate  * Check the final flag on a node
2087c478bd9Sstevel@tonic-gate  */
profile_is_node_final(struct profile_node * node)209505d05c7Sgtb int profile_is_node_final(struct profile_node *node)
2107c478bd9Sstevel@tonic-gate {
2117c478bd9Sstevel@tonic-gate 	return (node->final != 0);
2127c478bd9Sstevel@tonic-gate }
2137c478bd9Sstevel@tonic-gate 
2147c478bd9Sstevel@tonic-gate /*
2157c478bd9Sstevel@tonic-gate  * Return the name of a node.  (Note: this is for internal functions
2167c478bd9Sstevel@tonic-gate  * only; if the name needs to be returned from an exported function,
2177c478bd9Sstevel@tonic-gate  * strdup it first!)
2187c478bd9Sstevel@tonic-gate  */
profile_get_node_name(struct profile_node * node)219505d05c7Sgtb const char *profile_get_node_name(struct profile_node *node)
2207c478bd9Sstevel@tonic-gate {
2217c478bd9Sstevel@tonic-gate 	return node->name;
2227c478bd9Sstevel@tonic-gate }
2237c478bd9Sstevel@tonic-gate 
2247c478bd9Sstevel@tonic-gate /*
2257c478bd9Sstevel@tonic-gate  * Return the value of a node.  (Note: this is for internal functions
2267c478bd9Sstevel@tonic-gate  * only; if the name needs to be returned from an exported function,
2277c478bd9Sstevel@tonic-gate  * strdup it first!)
2287c478bd9Sstevel@tonic-gate  */
profile_get_node_value(struct profile_node * node)229505d05c7Sgtb const char *profile_get_node_value(struct profile_node *node)
2307c478bd9Sstevel@tonic-gate {
2317c478bd9Sstevel@tonic-gate 	return node->value;
2327c478bd9Sstevel@tonic-gate }
2337c478bd9Sstevel@tonic-gate 
2347c478bd9Sstevel@tonic-gate /*
2357c478bd9Sstevel@tonic-gate  * Iterate through the section, returning the nodes which match
2367c478bd9Sstevel@tonic-gate  * the given name.  If name is NULL, then interate through all the
2377c478bd9Sstevel@tonic-gate  * nodes in the section.  If section_flag is non-zero, only return the
2387c478bd9Sstevel@tonic-gate  * section which matches the name; don't return relations.  If value
2397c478bd9Sstevel@tonic-gate  * is non-NULL, then only return relations which match the requested
2407c478bd9Sstevel@tonic-gate  * value.  (The value argument is ignored if section_flag is non-zero.)
241505d05c7Sgtb  *
2427c478bd9Sstevel@tonic-gate  * The first time this routine is called, the state pointer must be
2437c478bd9Sstevel@tonic-gate  * null.  When this profile_find_node_relation() returns, if the state
2447c478bd9Sstevel@tonic-gate  * pointer is non-NULL, then this routine should be called again.
2457c478bd9Sstevel@tonic-gate  * (This won't happen if section_flag is non-zero, obviously.)
2467c478bd9Sstevel@tonic-gate  *
2477c478bd9Sstevel@tonic-gate  */
profile_find_node(struct profile_node * section,const char * name,const char * value,int section_flag,void ** state,struct profile_node ** node)248505d05c7Sgtb errcode_t profile_find_node(struct profile_node *section, const char *name,
249505d05c7Sgtb 			    const char *value, int section_flag, void **state,
250505d05c7Sgtb 			    struct profile_node **node)
2517c478bd9Sstevel@tonic-gate {
2527c478bd9Sstevel@tonic-gate 	struct profile_node *p;
2537c478bd9Sstevel@tonic-gate 
2547c478bd9Sstevel@tonic-gate 	CHECK_MAGIC(section);
2557c478bd9Sstevel@tonic-gate 	p = *state;
2567c478bd9Sstevel@tonic-gate 	if (p) {
2577c478bd9Sstevel@tonic-gate 		CHECK_MAGIC(p);
2587c478bd9Sstevel@tonic-gate 	} else
2597c478bd9Sstevel@tonic-gate 		p = section->first_child;
2607c478bd9Sstevel@tonic-gate 
2617c478bd9Sstevel@tonic-gate 	for (; p; p = p->next) {
2627c478bd9Sstevel@tonic-gate 		if (name && (strcmp(p->name, name)))
2637c478bd9Sstevel@tonic-gate 			continue;
2647c478bd9Sstevel@tonic-gate 		if (section_flag) {
2657c478bd9Sstevel@tonic-gate 			if (p->value)
2667c478bd9Sstevel@tonic-gate 				continue;
2677c478bd9Sstevel@tonic-gate 		} else {
2687c478bd9Sstevel@tonic-gate 			if (!p->value)
2697c478bd9Sstevel@tonic-gate 				continue;
2707c478bd9Sstevel@tonic-gate 			if (value && (strcmp(p->value, value)))
2717c478bd9Sstevel@tonic-gate 				continue;
2727c478bd9Sstevel@tonic-gate 		}
273505d05c7Sgtb 		if (p->deleted)
274505d05c7Sgtb 		    continue;
2757c478bd9Sstevel@tonic-gate 		/* A match! */
2767c478bd9Sstevel@tonic-gate 		if (node)
2777c478bd9Sstevel@tonic-gate 			*node = p;
2787c478bd9Sstevel@tonic-gate 		break;
2797c478bd9Sstevel@tonic-gate 	}
2807c478bd9Sstevel@tonic-gate 	if (p == 0) {
2817c478bd9Sstevel@tonic-gate 		*state = 0;
2827c478bd9Sstevel@tonic-gate 		return section_flag ? PROF_NO_SECTION : PROF_NO_RELATION;
2837c478bd9Sstevel@tonic-gate 	}
2847c478bd9Sstevel@tonic-gate 	/*
2857c478bd9Sstevel@tonic-gate 	 * OK, we've found one match; now let's try to find another
2867c478bd9Sstevel@tonic-gate 	 * one.  This way, if we return a non-zero state pointer,
2877c478bd9Sstevel@tonic-gate 	 * there's guaranteed to be another match that's returned.
2887c478bd9Sstevel@tonic-gate 	 */
2897c478bd9Sstevel@tonic-gate 	for (p = p->next; p; p = p->next) {
2907c478bd9Sstevel@tonic-gate 		if (name && (strcmp(p->name, name)))
2917c478bd9Sstevel@tonic-gate 			continue;
2927c478bd9Sstevel@tonic-gate 		if (section_flag) {
2937c478bd9Sstevel@tonic-gate 			if (p->value)
2947c478bd9Sstevel@tonic-gate 				continue;
2957c478bd9Sstevel@tonic-gate 		} else {
2967c478bd9Sstevel@tonic-gate 			if (!p->value)
2977c478bd9Sstevel@tonic-gate 				continue;
2987c478bd9Sstevel@tonic-gate 			if (value && (strcmp(p->value, value)))
2997c478bd9Sstevel@tonic-gate 				continue;
3007c478bd9Sstevel@tonic-gate 		}
3017c478bd9Sstevel@tonic-gate 		/* A match! */
3027c478bd9Sstevel@tonic-gate 		break;
3037c478bd9Sstevel@tonic-gate 	}
3047c478bd9Sstevel@tonic-gate 	*state = p;
3057c478bd9Sstevel@tonic-gate 	return 0;
3067c478bd9Sstevel@tonic-gate }
3077c478bd9Sstevel@tonic-gate 
3087c478bd9Sstevel@tonic-gate 
3097c478bd9Sstevel@tonic-gate /*
3107c478bd9Sstevel@tonic-gate  * Iterate through the section, returning the relations which match
3117c478bd9Sstevel@tonic-gate  * the given name.  If name is NULL, then interate through all the
3127c478bd9Sstevel@tonic-gate  * relations in the section.  The first time this routine is called,
3137c478bd9Sstevel@tonic-gate  * the state pointer must be null.  When this profile_find_node_relation()
3147c478bd9Sstevel@tonic-gate  * returns, if the state pointer is non-NULL, then this routine should
3157c478bd9Sstevel@tonic-gate  * be called again.
3167c478bd9Sstevel@tonic-gate  *
3177c478bd9Sstevel@tonic-gate  * The returned character string in value points to the stored
3187c478bd9Sstevel@tonic-gate  * character string in the parse string.  Before this string value is
3197c478bd9Sstevel@tonic-gate  * returned to a calling application (profile_find_node_relation is not an
3207c478bd9Sstevel@tonic-gate  * exported interface), it should be strdup()'ed.
3217c478bd9Sstevel@tonic-gate  */
profile_find_node_relation(struct profile_node * section,const char * name,void ** state,char ** ret_name,char ** value)322505d05c7Sgtb errcode_t profile_find_node_relation(struct profile_node *section,
323505d05c7Sgtb 				     const char *name, void **state,
324505d05c7Sgtb 				     char **ret_name, char **value)
3257c478bd9Sstevel@tonic-gate {
3267c478bd9Sstevel@tonic-gate 	struct profile_node *p;
3277c478bd9Sstevel@tonic-gate 	errcode_t	retval;
3287c478bd9Sstevel@tonic-gate 
3297c478bd9Sstevel@tonic-gate 	retval = profile_find_node(section, name, 0, 0, state, &p);
3307c478bd9Sstevel@tonic-gate 	if (retval)
3317c478bd9Sstevel@tonic-gate 		return retval;
3327c478bd9Sstevel@tonic-gate 
3337c478bd9Sstevel@tonic-gate 	if (p) {
3347c478bd9Sstevel@tonic-gate 		if (value)
3357c478bd9Sstevel@tonic-gate 			*value = p->value;
3367c478bd9Sstevel@tonic-gate 		if (ret_name)
3377c478bd9Sstevel@tonic-gate 			*ret_name = p->name;
3387c478bd9Sstevel@tonic-gate 	}
3397c478bd9Sstevel@tonic-gate 	return 0;
3407c478bd9Sstevel@tonic-gate }
3417c478bd9Sstevel@tonic-gate 
3427c478bd9Sstevel@tonic-gate /*
3437c478bd9Sstevel@tonic-gate  * Iterate through the section, returning the subsections which match
3447c478bd9Sstevel@tonic-gate  * the given name.  If name is NULL, then interate through all the
3457c478bd9Sstevel@tonic-gate  * subsections in the section.  The first time this routine is called,
3467c478bd9Sstevel@tonic-gate  * the state pointer must be null.  When this profile_find_node_subsection()
3477c478bd9Sstevel@tonic-gate  * returns, if the state pointer is non-NULL, then this routine should
3487c478bd9Sstevel@tonic-gate  * be called again.
3497c478bd9Sstevel@tonic-gate  *
3507c478bd9Sstevel@tonic-gate  * This is (plus accessor functions for the name and value given a
3517c478bd9Sstevel@tonic-gate  * profile node) makes this function mostly syntactic sugar for
352505d05c7Sgtb  * profile_find_node.
3537c478bd9Sstevel@tonic-gate  */
profile_find_node_subsection(struct profile_node * section,const char * name,void ** state,char ** ret_name,struct profile_node ** subsection)354