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 (c) 2000-2001 by Sun Microsystems, Inc.
24  * All rights reserved.
25  */
26 
27 #ifndef _ANCESTOR_H
28 #define	_ANCESTOR_H
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 #ifdef	__cplusplus
35 }
36 #endif
37 
38 #include "libfru.h"
39 #include "libfrureg.h"
40 #include "fru_tag.h"
41 #include "Str.h"
42 
43 // the object used to determine the ancestory of a particular element.
44 struct Ancestor
45 {
46 	Ancestor(Str field, fru_tag_t t, const fru_regdef_t *d);
47 	~Ancestor();
48 
49 	void addInstance(const char *path, uint32_t offset);
50 
51 	Str getFieldName(void);
52 	fru_tag_t getTag(void);
53 
54 	const fru_regdef_t *getDef(void);
55 
56 	int getNumInstances(void);
57 	uint32_t getInstOffset(int num);
58 	const char *getPath(int num);
59 /*
60  *	void print(void);
61  */
62 
63 	// returns a NULL terminated list of Ancestor objects which contain
64 	// information about all the Ancestors of element.
65 	static Ancestor *listTaggedAncestors(char *element);
66 
67 public:
68 	Ancestor *next;
69 
70 private:
71 	Str field_name;
72 	fru_tag_t tag;
73 	const fru_regdef_t *def;
74 	int numInstances;
75 #define	ANCESTOR_INST_BUF_SIZE 256
76 	int numBufs;
77 	uint32_t *offsets;
78 	char **paths;
79 
80 	// internal calls
81 	static Ancestor * createTaggedAncestor(const fru_regdef_t *def,
82 						Str element);
83 	static int definitionContains(const fru_regdef_t *def,
84 					const fru_regdef_t *parent_def,
85 					Str element,
86 					uint32_t offset,
87 					Ancestor *ant,
88 					Str path);
89 
90 private:
91 	Ancestor(const Ancestor&);
92 	void operator=(const Ancestor&);
93 };
94 
95 #ifdef __cplusplus
96 extern "C" {
97 #endif
98 
99 #ifdef	__cplusplus
100 }
101 #endif
102 
103 #endif /* _ANCESTOR_H */
104