xref: /illumos-gate/usr/src/tools/protocmp/list.h (revision ae115bc7)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*ae115bc7Smrj  * Common Development and Distribution License (the "License").
6*ae115bc7Smrj  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
22*ae115bc7Smrj  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
26*ae115bc7Smrj #ifndef _LIST_H
27*ae115bc7Smrj #define	_LIST_H
287c478bd9Sstevel@tonic-gate 
29*ae115bc7Smrj #pragma ident	"%Z%%M%	%I%	%E% SMI"
307c478bd9Sstevel@tonic-gate 
31*ae115bc7Smrj #ifdef __cplusplus
32*ae115bc7Smrj extern "C" {
33*ae115bc7Smrj #endif
347c478bd9Sstevel@tonic-gate 
357c478bd9Sstevel@tonic-gate /*
367c478bd9Sstevel@tonic-gate  * Constants
377c478bd9Sstevel@tonic-gate  */
387c478bd9Sstevel@tonic-gate #define	MAXNAME   256
397c478bd9Sstevel@tonic-gate #define	TYPESIZE  32
407c478bd9Sstevel@tonic-gate 
417c478bd9Sstevel@tonic-gate 
427c478bd9Sstevel@tonic-gate /*
437c478bd9Sstevel@tonic-gate  * find_elem flags
447c478bd9Sstevel@tonic-gate  */
457c478bd9Sstevel@tonic-gate 
467c478bd9Sstevel@tonic-gate #define	FOLLOW_LINK    1
477c478bd9Sstevel@tonic-gate #define	NO_FOLLOW_LINK 0
487c478bd9Sstevel@tonic-gate 
497c478bd9Sstevel@tonic-gate /*
507c478bd9Sstevel@tonic-gate  * elem_list types
517c478bd9Sstevel@tonic-gate  */
527c478bd9Sstevel@tonic-gate #define	PROTOLIST_LIST	1
537c478bd9Sstevel@tonic-gate #define	PROTODIR_LIST	2
547c478bd9Sstevel@tonic-gate #define	EXCEPTION_LIST	3
557c478bd9Sstevel@tonic-gate 
567c478bd9Sstevel@tonic-gate 
577c478bd9Sstevel@tonic-gate /*
587c478bd9Sstevel@tonic-gate  * file types
597c478bd9Sstevel@tonic-gate  */
607c478bd9Sstevel@tonic-gate 
617c478bd9Sstevel@tonic-gate #define	CHAR_DEV_T	'c'
627c478bd9Sstevel@tonic-gate #define	BLOCK_DEV_T	'b'
637c478bd9Sstevel@tonic-gate #define	DIR_T		'd'
647c478bd9Sstevel@tonic-gate #define	FILE_T		'f'
657c478bd9Sstevel@tonic-gate #define	EDIT_T		'e'
667c478bd9Sstevel@tonic-gate #define	VOLATILE_T	'v'
677c478bd9Sstevel@tonic-gate #define	SYM_LINK_T	's'
687c478bd9Sstevel@tonic-gate #define	LINK_T		'l'
697c478bd9Sstevel@tonic-gate 
707c478bd9Sstevel@tonic-gate /*
717c478bd9Sstevel@tonic-gate  * Arch Values
727c478bd9Sstevel@tonic-gate  */
737c478bd9Sstevel@tonic-gate 
747c478bd9Sstevel@tonic-gate /* sparc */
757c478bd9Sstevel@tonic-gate #define	P_SPARC		1
767c478bd9Sstevel@tonic-gate #define	P_SUN4		2
777c478bd9Sstevel@tonic-gate #define	P_SUN4c		3
787c478bd9Sstevel@tonic-gate #define	P_SUN4d		4
797c478bd9Sstevel@tonic-gate #define	P_SUN4e		5
807c478bd9Sstevel@tonic-gate #define	P_SUN4m		6
817c478bd9Sstevel@tonic-gate #define	P_SUN4u		7
827c478bd9Sstevel@tonic-gate #define	P_SUN4v		8
837c478bd9Sstevel@tonic-gate 
847c478bd9Sstevel@tonic-gate /* x86 values */
857c478bd9Sstevel@tonic-gate #define	P_I386		101
867c478bd9Sstevel@tonic-gate #define	P_I86PC		102
877c478bd9Sstevel@tonic-gate 
887c478bd9Sstevel@tonic-gate /* ppc values */
897c478bd9Sstevel@tonic-gate #define	P_PPC		201
907c478bd9Sstevel@tonic-gate #define	P_PREP		202
917c478bd9Sstevel@tonic-gate 
927c478bd9Sstevel@tonic-gate #if defined(sparc)
937c478bd9Sstevel@tonic-gate #define	P_ISA		P_SPARC
947c478bd9Sstevel@tonic-gate #elif defined(i386)
957c478bd9Sstevel@tonic-gate #define	P_ISA		P_I386
967c478bd9Sstevel@tonic-gate #elif defined(__ppc)
977c478bd9Sstevel@tonic-gate #define	P_ISA		P_PPC
987c478bd9Sstevel@tonic-gate #else
997c478bd9Sstevel@tonic-gate #error "Unknown instruction set"
1007c478bd9Sstevel@tonic-gate #endif
1017c478bd9Sstevel@tonic-gate 
1027c478bd9Sstevel@tonic-gate #define	P_ALL		P_ISA
1037c478bd9Sstevel@tonic-gate 
1047c478bd9Sstevel@tonic-gate /*
1057c478bd9Sstevel@tonic-gate  * typedefs
1067c478bd9Sstevel@tonic-gate  */
1077c478bd9Sstevel@tonic-gate typedef struct pkg_list {
1087c478bd9Sstevel@tonic-gate 	char		pkg_name[MAXNAME];
1097c478bd9Sstevel@tonic-gate 	struct pkg_list	*next;
1107c478bd9Sstevel@tonic-gate } pkg_list;
1117c478bd9Sstevel@tonic-gate 
1127c478bd9Sstevel@tonic-gate typedef struct elem {
1137c478bd9Sstevel@tonic-gate 	int		inode;
1147c478bd9Sstevel@tonic-gate 	short		perm;
1157c478bd9Sstevel@tonic-gate 	int		ref_cnt;
1167c478bd9Sstevel@tonic-gate 	short		flag;
1177c478bd9Sstevel@tonic-gate 	short		major;
1187c478bd9Sstevel@tonic-gate 	short		minor;
1197c478bd9Sstevel@tonic-gate 	short		arch;
1207c478bd9Sstevel@tonic-gate 	struct elem	*next;
1217c478bd9Sstevel@tonic-gate 	struct elem	*link_parent;
1227c478bd9Sstevel@tonic-gate 	struct elem	*link_sib;
1237c478bd9Sstevel@tonic-gate 	pkg_list	*pkgs;
1247c478bd9Sstevel@tonic-gate 	char		*symsrc;
1257c478bd9Sstevel@tonic-gate 	char		name[MAXNAME];
1267c478bd9Sstevel@tonic-gate 	char		owner[TYPESIZE];
1277c478bd9Sstevel@tonic-gate 	char		group[TYPESIZE];
1287c478bd9Sstevel@tonic-gate 	char		file_type;
1297c478bd9Sstevel@tonic-gate } elem;
1307c478bd9Sstevel@tonic-gate 
1317c478bd9Sstevel@tonic-gate 
1327c478bd9Sstevel@tonic-gate typedef struct {
1337c478bd9Sstevel@tonic-gate 	int	num_of_buckets;
1347c478bd9Sstevel@tonic-gate 	elem	**list;
1357c478bd9Sstevel@tonic-gate 	short	type;
1367c478bd9Sstevel@tonic-gate } elem_list;
1377c478bd9Sstevel@tonic-gate 
1387c478bd9Sstevel@tonic-gate #define	HASH_SIZE	4093
1397c478bd9Sstevel@tonic-gate 
1407c478bd9Sstevel@tonic-gate /*
1417c478bd9Sstevel@tonic-gate  * Funcs
1427c478bd9Sstevel@tonic-gate  */
1437c478bd9Sstevel@tonic-gate 
1447c478bd9Sstevel@tonic-gate 
1457c478bd9Sstevel@tonic-gate extern void add_elem(elem_list*, elem *);
1467c478bd9Sstevel@tonic-gate extern pkg_list *add_pkg(pkg_list *, const char *);
1477c478bd9Sstevel@tonic-gate extern elem *find_elem(elem_list *, elem *, int);
1487c478bd9Sstevel@tonic-gate extern elem *find_elem_mach(elem_list *, elem *, int);
1497c478bd9Sstevel@tonic-gate extern elem *find_elem_isa(elem_list *, elem *, int);
1507c478bd9Sstevel@tonic-gate extern void init_list(elem_list *, int);
1517c478bd9Sstevel@tonic-gate extern unsigned int hash(const char *str);
1527c478bd9Sstevel@tonic-gate extern int processed_package(const char *pkgname);
1537c478bd9Sstevel@tonic-gate extern void mark_processed(const char *pkgname);
1547c478bd9Sstevel@tonic-gate #ifdef DEBUG
1557c478bd9Sstevel@tonic-gate extern void examine_list(elem_list *list);
1567c478bd9Sstevel@tonic-gate extern void print_list(elem_list *);
1577c478bd9Sstevel@tonic-gate extern void print_type_list(elem_list *list, char file_type);
1587c478bd9Sstevel@tonic-gate #endif
1597c478bd9Sstevel@tonic-gate 
1607c478bd9Sstevel@tonic-gate /* Global statistics */
1617c478bd9Sstevel@tonic-gate extern int max_list_depth;
162*ae115bc7Smrj 
163*ae115bc7Smrj #ifdef __cplusplus
164*ae115bc7Smrj }
165*ae115bc7Smrj #endif
166*ae115bc7Smrj 
167