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