xref: /titanic_51/usr/src/tools/protocmp/list.h (revision 2a9459bdd821c1cf59590a7a9069ac9c591e8a6b)
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 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
35 /*
36  * Constants
37  */
38 #define	MAXNAME   256
39 #define	TYPESIZE  32
40 
41 
42 /*
43  * find_elem flags
44  */
45 
46 #define	FOLLOW_LINK    1
47 #define	NO_FOLLOW_LINK 0
48 
49 /*
50  * elem_list types
51  */
52 #define	PROTOLIST_LIST	1
53 #define	PROTODIR_LIST	2
54 #define	EXCEPTION_LIST	3
55 
56 
57 /*
58  * file types
59  */
60 
61 #define	CHAR_DEV_T	'c'
62 #define	BLOCK_DEV_T	'b'
63 #define	DIR_T		'd'
64 #define	FILE_T		'f'
65 #define	EDIT_T		'e'
66 #define	VOLATILE_T	'v'
67 #define	SYM_LINK_T	's'
68 #define	LINK_T		'l'
69 
70 /*
71  * Arch Values
72  */
73 
74 /* sparc */
75 #define	P_SPARC		1
76 #define	P_SUN4		2
77 #define	P_SUN4c		3
78 #define	P_SUN4d		4
79 #define	P_SUN4e		5
80 #define	P_SUN4m		6
81 #define	P_SUN4u		7
82 #define	P_SUN4v		8
83 
84 /* x86 values */
85 #define	P_I386		101
86 #define	P_I86PC		102
87 
88 /* ppc values */
89 #define	P_PPC		201
90 #define	P_PREP		202
91 
92 #if defined(sparc)
93 #define	P_ISA		P_SPARC
94 #elif defined(i386)
95 #define	P_ISA		P_I386
96 #elif defined(__ppc)
97 #define	P_ISA		P_PPC
98 #else
99 #error "Unknown instruction set"
100 #endif
101 
102 #define	P_ALL		P_ISA
103 
104 /*
105  * typedefs
106  */
107 typedef struct pkg_list {
108 	char		pkg_name[MAXNAME];
109 	struct pkg_list	*next;
110 } pkg_list;
111 
112 typedef struct elem {
113 	int		inode;
114 	short		perm;
115 	int		ref_cnt;
116 	short		flag;
117 	short		major;
118 	short		minor;
119 	short		arch;
120 	struct elem	*next;
121 	struct elem	*link_parent;
122 	struct elem	*link_sib;
123 	pkg_list	*pkgs;
124 	char		*symsrc;
125 	char		name[MAXNAME];
126 	char		owner[TYPESIZE];
127 	char		group[TYPESIZE];
128 	char		file_type;
129 } elem;
130 
131 
132 typedef struct {
133 	int	num_of_buckets;
134 	elem	**list;
135 	short	type;
136 } elem_list;
137 
138 #define	HASH_SIZE	4093
139 
140 /*
141  * Funcs
142  */
143 
144 
145 extern void add_elem(elem_list*, elem *);
146 extern pkg_list *add_pkg(pkg_list *, const char *);
147 extern elem *find_elem(elem_list *, elem *, int);
148 extern elem *find_elem_mach(elem_list *, elem *, int);
149 extern elem *find_elem_isa(elem_list *, elem *, int);
150 extern void init_list(elem_list *, int);
151 extern unsigned int hash(const char *str);
152 extern int processed_package(const char *pkgname);
153 extern void mark_processed(const char *pkgname);
154 #ifdef DEBUG
155 extern void examine_list(elem_list *list);
156 extern void print_list(elem_list *);
157 extern void print_type_list(elem_list *list, char file_type);
158 #endif
159 
160 /* Global statistics */
161 extern int max_list_depth;
162 
163 #ifdef __cplusplus
164 }
165 #endif
166 
167 #endif	/* _LIST_H */
168