xref: /illumos-gate/usr/src/tools/protocmp/list.h (revision c4d175c6)
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 (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef _LIST_H
27 #define	_LIST_H
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
33 /*
34  * Constants
35  */
36 #define	MAXNAME   256
37 #define	TYPESIZE  32
38 
39 
40 /*
41  * find_elem flags
42  */
43 
44 #define	FOLLOW_LINK    1
45 #define	NO_FOLLOW_LINK 0
46 
47 /*
48  * elem_list types
49  */
50 #define	PROTOLIST_LIST	1
51 #define	PROTODIR_LIST	2
52 #define	EXCEPTION_LIST	3
53 
54 
55 /*
56  * file types
57  */
58 
59 #define	CHAR_DEV_T	'c'
60 #define	BLOCK_DEV_T	'b'
61 #define	DIR_T		'd'
62 #define	FILE_T		'f'
63 #define	EDIT_T		'e'
64 #define	VOLATILE_T	'v'
65 #define	SYM_LINK_T	's'
66 #define	LINK_T		'l'
67 
68 /*
69  * Arch Values
70  */
71 
72 /* sparc */
73 #define	P_SPARC		1
74 #define	P_SUN4		2
75 #define	P_SUN4c		3
76 #define	P_SUN4d		4
77 #define	P_SUN4e		5
78 #define	P_SUN4m		6
79 #define	P_SUN4u		7
80 #define	P_SUN4v		8
81 
82 /* x86 values */
83 #define	P_I386		101
84 #define	P_I86PC		102
85 
86 /* ppc values */
87 #define	P_PPC		201
88 #define	P_PREP		202
89 
90 #if defined(sparc)
91 #define	P_ISA		P_SPARC
92 #elif defined(i386)
93 #define	P_ISA		P_I386
94 #elif defined(__ppc)
95 #define	P_ISA		P_PPC
96 #else
97 #error "Unknown instruction set"
98 #endif
99 
100 #define	P_ALL		P_ISA
101 
102 /*
103  * typedefs
104  */
105 typedef struct pkg_list {
106 	char		pkg_name[MAXNAME];
107 	struct pkg_list	*next;
108 } pkg_list;
109 
110 typedef struct elem {
111 	int		inode;
112 	short		perm;
113 	int		ref_cnt;
114 	short		flag;
115 	short		major;
116 	short		minor;
117 	short		arch;
118 	struct elem	*next;
119 	struct elem	*link_parent;
120 	struct elem	*link_sib;
121 	pkg_list	*pkgs;
122 	char		*symsrc;
123 	char		name[MAXNAME];
124 	char		owner[TYPESIZE];
125 	char		group[TYPESIZE];
126 	char		file_type;
127 } elem;
128 
129 
130 typedef struct {
131 	int	num_of_buckets;
132 	elem	**list;
133 	short	type;
134 } elem_list;
135 
136 #define	HASH_SIZE	4093
137 
138 /*
139  * Funcs
140  */
141 
142 
143 extern void add_elem(elem_list*, elem *);
144 extern pkg_list *add_pkg(pkg_list *, const char *);
145 extern elem *find_elem(elem_list *, elem *, int);
146 extern elem *find_elem_mach(elem_list *, elem *, int);
147 extern elem *find_elem_isa(elem_list *, elem *, int);
148 extern void init_list(elem_list *, int);
149 extern unsigned int hash(const char *str);
150 extern int processed_package(const char *pkgname);
151 extern void mark_processed(const char *pkgname);
152 #ifdef DEBUG
153 extern void examine_list(elem_list *list);
154 extern void print_list(elem_list *);
155 extern void print_type_list(elem_list *list, char file_type);
156 #endif
157 
158 /* Global statistics */
159 extern int max_list_depth;
160 
161 #ifdef __cplusplus
162 }
163 #endif
164 
165 #endif	/* _LIST_H */
166