xref: /titanic_50/usr/src/lib/libcmdutils/libcmdutils.h (revision da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968)
1 /*
2  * CDDL HEADER START
3  *
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
7  * with the License.
8  *
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.
13  *
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]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 /*
28  * Declarations for the functions in libcmdutils.
29  */
30 
31 #ifndef	_LIBCMDUTILS_H
32 #define	_LIBCMDUTILS_H
33 
34 #pragma ident	"%Z%%M%	%I%	%E% SMI"
35 
36 /*
37  * This is a private header file.  Applications should not directly include
38  * this file.
39  */
40 
41 #include <sys/avl.h>
42 #include <sys/types.h>
43 #include <stdlib.h>
44 
45 #ifdef	__cplusplus
46 extern "C" {
47 #endif
48 
49 /* avltree */
50 #define	OFFSETOF(s, m)	((size_t)(&(((s *)0)->m)))
51 
52 /* Type used for a node containing a device id and inode number */
53 typedef struct tree_node {
54 	dev_t		node_dev;
55 	ino_t		node_ino;
56 	avl_node_t	avl_link;
57 } tree_node_t;
58 
59 /*
60  * Used to compare two nodes.  We are attempting to match the 1st
61  * argument (node) against the 2nd argument (a node which
62  * is already in the search tree).
63  */
64 extern int tnode_compare(const void *, const void *);
65 
66 /*
67  * Used to add a single node (containing the input device id and
68  * inode number) to the specified search tree.  The calling
69  * application must set the tree pointer to NULL before calling
70  * add_tnode() for the first time.
71  */
72 extern int add_tnode(avl_tree_t **, dev_t, ino_t);
73 
74 /*
75  * Used to destroy a whole tree (all nodes) without rebalancing.
76  * The calling application is responsible for setting the tree
77  * pointer to NULL upon return.
78  */
79 extern void destroy_tree(avl_tree_t *);
80 
81 #ifdef	__cplusplus
82 }
83 #endif
84 
85 #endif /* _LIBCMDUTILS_H */
86