4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright (c) 1994, by Sun Microsytems, Inc.
26 #pragma ident "%Z%%M% %I% %E% SMI"
44 static queue_node_t g_setlist
= {
50 * Forward Declarations
53 static void set_destroy(set_t
* set_p
);
54 static void set_print(FILE * stream
, set_t
* set_p
);
58 * set() - creates a set
62 set(char *setname_p
, expr_t
* exprlist_p
)
67 /* does this setname exist already? */
68 old_p
= set_find(setname_p
);
72 /* create a new set */
74 queue_init(&new_p
->qn
);
75 new_p
->setname_p
= setname_p
;
76 new_p
->exprlist_p
= exprlist_p
;
78 /* append the new set to the global list */
79 (void) queue_append(&g_setlist
, &new_p
->qn
);
87 * set_destroy() - destroys a set and related resources
91 set_destroy(set_t
* set_p
)
96 /* remove ourselves from any list */
97 if (!queue_isempty(&set_p
->qn
))
98 (void) queue_remove(&set_p
->qn
);
100 if (set_p
->setname_p
)
101 free(set_p
->setname_p
);
103 /* destroy the exprlist */
104 expr_destroy(set_p
->exprlist_p
);
108 } /* end set_destroy */
112 * set_list() - pretty prints the global setlist
120 set_p
= (set_t
*) & g_setlist
;
121 while ((set_p
= (set_t
*) queue_next(&g_setlist
, &set_p
->qn
))) {
122 (void) printf("$%-8s ", set_p
->setname_p
);
123 set_print(stdout
, set_p
);
131 * set_print() - pretty prints a set
135 set_print(FILE * stream
, set_t
* set_p
)
140 expr_print(stream
, set_p
->exprlist_p
);
142 } /* end set_print */
147 * set_match() - discerns whether a probe is in a set
151 set_match(set_t
* set_p
, const char *name
, const char *keys
)
156 return (expr_match(set_p
->exprlist_p
, name
, keys
));
158 } /* end set_match */
163 * set_find() - finds a set by name
167 set_find(char *setname_p
)
174 set_p
= (set_t
*) & g_setlist
;
175 while ((set_p
= (set_t
*) queue_next(&g_setlist
, &set_p
->qn
)))
176 if (strcmp(setname_p
, set_p
->setname_p
) == 0)