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 1999-2002 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_PICLD_PLUGINUTIL_IMPL_H
28 #define	_PICLD_PLUGINUTIL_IMPL_H
29 
30 #ifdef	__cplusplus
31 extern "C" {
32 #endif
33 
34 #define	PER_ALLOC_COUNT		256
35 #define	RECORD_SIZE_MAX		1024
36 #define	STARTING_INDEX		0
37 #define	SUPPORTED_VERSION_NUM	1.1
38 
39 /* reserved keyword (case insensitive) */
40 #define	KEYWORD_INT_TYPE	"int"
41 #define	KEYWORD_UINT_TYPE	"uint"
42 #define	KEYWORD_FLOAT_TYPE	"float"
43 #define	KEYWORD_STRING_TYPE	"string"
44 #define	KEYWORD_VOID_TYPE	"void"
45 #define	KEYWORD_READ_MODE	"r"
46 #define	KEYWORD_WRITE_MODE	"w"
47 #define	KEYWORD_READWRITE_MODE	"rw"
48 #define	KEYWORD_WITH_STR	"with"
49 
50 #define	WHITESPACE		" \t\n"
51 #define	RECORD_WHITESPACE	": \t\n"
52 #define	DOUBLE_QUOTE		"\""
53 
54 typedef	struct {
55 	char			*path;
56 } path_cmd_t;
57 
58 typedef	struct {
59 	picl_nodehdl_t		nodeh;
60 	char			*nodename;
61 	char			*classname;
62 } node_cmd_t;
63 
64 typedef	struct {
65 	picl_prophdl_t		proph;
66 	size_t			size;
67 	int			type;
68 	int			accessmode;
69 	char			*pname;
70 	void			*valbuf;
71 } prop_cmd_t;
72 
73 typedef	struct {
74 	picl_prophdl_t		proph;
75 	char			*pname;
76 	char			*dstnode;
77 } refprop_cmd_t;
78 
79 typedef	struct {
80 	picl_nodehdl_t		nodeh;
81 	char			*newnodename;
82 	char			*newnodeclass;
83 	char			*dstnode;
84 } refnode_cmd_t;
85 
86 typedef	struct {
87 	picl_prophdl_t		tblh;
88 	int			newtbl;
89 	char			*tname;
90 } table_cmd_t;
91 
92 typedef	struct {
93 	int			index;
94 	int			nproph;
95 	picl_prophdl_t		*prophs;
96 } row_cmd_t;
97 
98 typedef	struct {
99 	int32_t			level;
100 } verbose_cmd_t;
101 
102 typedef struct {
103 	int			type;
104 	union {
105 		path_cmd_t	path;
106 		node_cmd_t	node;
107 		prop_cmd_t	prop;
108 		refprop_cmd_t	refprop;
109 		refnode_cmd_t	refnode;
110 		table_cmd_t	table;
111 		row_cmd_t	row;
112 		verbose_cmd_t	verbose;
113 	} u;
114 } command_t;
115 
116 typedef struct {
117 	int		count;
118 	int		allocated;
119 	float		version_no;
120 	int		inside_node_block;
121 	int		verbose;
122 	const char	*fname;
123 	int		inside_table_block;
124 	int		current_tbl;
125 	int		inside_row_block;
126 	int		current_row;
127 	command_t	*commands;
128 } cmdbuf_t;
129 
130 #define	pathcmd_name		u.path.path
131 #define	nodecmd_nodeh		u.node.nodeh
132 #define	nodecmd_nodename	u.node.nodename
133 #define	nodecmd_classname	u.node.classname
134 #define	nodecmd_classname	u.node.classname
135 #define	propcmd_proph		u.prop.proph
136 #define	propcmd_pname		u.prop.pname
137 #define	propcmd_type		u.prop.type
138 #define	propcmd_accessmode	u.prop.accessmode
139 #define	propcmd_size		u.prop.size
140 #define	propcmd_valbuf		u.prop.valbuf
141 #define	refpropcmd_proph	u.refprop.proph
142 #define	refpropcmd_pname	u.refprop.pname
143 #define	refpropcmd_dstnode	u.refprop.dstnode
144 #define	refnodecmd_nodeh	u.refnode.nodeh
145 #define	refnodecmd_name		u.refnode.newnodename
146 #define	refnodecmd_class	u.refnode.newnodeclass
147 #define	refnodecmd_dstnode	u.refnode.dstnode
148 #define	tablecmd_tblh		u.table.tblh
149 #define	tablecmd_newtbl		u.table.newtbl
150 #define	tablecmd_tname		u.table.tname
151 #define	rowcmd_index		u.row.index
152 #define	rowcmd_nproph		u.row.nproph
153 #define	rowcmd_prophs		u.row.prophs
154 #define	verbosecmd_level	u.verbose.level
155 
156 #ifdef	__cplusplus
157 }
158 #endif
159 
160 #endif	/* _PICLD_PLUGINUTIL_IMPL_H */
161