1 mike 1.1 /*
2 **==============================================================================
3 **
4 ** Open Management Infrastructure (OMI)
5 **
6 ** Copyright (c) Microsoft Corporation
7 **
8 ** Licensed under the Apache License, Version 2.0 (the "License"); you may not
9 ** use this file except in compliance with the License. You may obtain a copy
10 ** of the License at
11 **
12 ** http://www.apache.org/licenses/LICENSE-2.0
13 **
14 ** THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 ** KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
16 ** WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
17 ** MERCHANTABLITY OR NON-INFRINGEMENT.
18 **
19 ** See the Apache 2 License for the specific language governing permissions
20 ** and limitations under the License.
21 **
22 mike 1.1 **==============================================================================
23 */
24
|
25 mike 1.2 #ifndef _mof_types_h
26 #define _mof_types_h
27
28 #ifndef MI_CHAR_TYPE
29 # define MI_CHAR_TYPE 1
30 #endif
31
32 #include <MI.h>
33 #include "config.h"
34 #include <stdlib.h>
35 #include <stdio.h>
36 #include <assert.h>
37 #include <string.h>
38 #include <base/strings.h>
39 #include <base/io.h>
40 #include "heap.h"
41 #include "strids.h"
42
43 #define MOF_TRACE printf("MOF_TRACE: %s(%u)\n", __FILE__, __LINE__)
44
45 #define MOF_NOT_FOUND ((MI_Uint32)0xFFFFFFFF)
46 mike 1.2
47 #define MOF_ASSERT(COND) assert(COND)
48
49 /* Type-aware forms of memory allocation functions */
50 #define CALLOC_T(T, N) ((T*)MOF_Calloc(&state.heap, N, sizeof(T)))
51 #define MALLOC_T(T, N) ((T*)MOF_Malloc(&state.heap, N * sizeof(T)))
52 #define REALLOC_T(T, PTR, N) ((T*)MOF_Realloc(&state.heap,PTR,(N)*sizeof(T)))
53
54 /*
55 **==============================================================================
56 **
57 ** error reporting functions.
58 **
59 **==============================================================================
60 */
61 extern void yyerror(const char* msg);
62
63 PRINTF_FORMAT(2, 3)
64 extern void yyerrorf(int id, const char *fmt, ...);
65
66 PRINTF_FORMAT(2, 3)
67 mike 1.2 extern void yywarnf(int id, const char *fmt, ...);
68
69 /*
70 **==============================================================================
71 **
72 ** MOF_QualifierList
73 **
74 **==============================================================================
75 */
76
77 typedef struct _MOF_QualifierList
78 {
79 MI_Qualifier** data;
80 MI_Uint32 size;
81 }
82 MOF_QualifierList;
83
84 /*
85 **==============================================================================
86 **
87 ** MOF_QualifierDeclList
88 mike 1.2 **
89 **==============================================================================
90 */
91
92 typedef struct _MOF_QualifierDeclList
93 {
94 MI_QualifierDecl** data;
95 MI_Uint32 size;
96 }
97 MOF_QualifierDeclList;
98
99 extern MOF_QualifierDeclList g_qualifierDecls;
100
101 /*
102 **==============================================================================
103 **
104 ** MOF_ClassDeclList
105 **
106 **==============================================================================
107 */
108
109 mike 1.2 typedef struct _MOF_ClassDeclList
110 {
111 MI_ClassDecl** data;
112 MI_Uint32 size;
113 }
114 MOF_ClassDeclList;
115
116 /*
117 **==============================================================================
118 **
119 ** MOF_InstanceDeclList
120 **
121 **==============================================================================
122 */
123
124 typedef struct _MOF_InstanceDeclList
125 {
126 MI_InstanceDecl** data;
127 MI_Uint32 size;
128 }
129 MOF_InstanceDeclList;
130 mike 1.2
131 /*
132 **==============================================================================
133 **
134 ** MOF_LineList
135 **
136 ** Track the line where EmbeddedInstance qualifiers were encountered for
137 ** post processing.
138 **
139 **==============================================================================
140 */
141
142 typedef struct _MOF_EmbeddedInstance
143 {
144 /* Pointer to embedded instance qualifier */
145 MI_Qualifier* qualifier;
146
147 /* Line where EmbeddedInstance qualifier was encountered */
148 unsigned int line;
149 }
150 MOF_EmbeddedInstance;
151 mike 1.2
152 typedef struct _MOF_EmbeddedInstanceList
153 {
154 MOF_EmbeddedInstance** data;
155 MI_Uint32 size;
156 }
157 MOF_EmbeddedInstanceList;
158
159 /*
160 **==============================================================================
161 **
162 ** MOF_PropertyList
163 **
164 **==============================================================================
165 */
166
167 typedef struct _MOF_PropertyList
168 {
169 MI_PropertyDecl** data;
170 MI_Uint32 size;
171 }
172 mike 1.2 MOF_PropertyList;
173
174 /*
175 **==============================================================================
176 **
177 ** MOF_MethodList
178 **
179 **==============================================================================
180 */
181
182 typedef struct _MOF_MethodList
183 {
184 MI_MethodDecl** data;
185 MI_Uint32 size;
186 }
187 MOF_MethodList;
188
189 /*
190 **==============================================================================
191 **
192 ** MOF_ParameterList
193 mike 1.2 **
194 **==============================================================================
195 */
196
197 typedef struct _MOF_ParameterList
198 {
199 MI_ParameterDecl** data;
200 MI_Uint32 size;
201 }
202 MOF_ParameterList;
203
204 /*
205 **==============================================================================
206 **
207 ** MOF_FeatureList
208 **
209 **==============================================================================
210 */
211
212 typedef struct _MOFFeatureList
213 {
214 mike 1.2 MOF_PropertyList propertySet;
215 MOF_MethodList methodList;
216 }
217 MOF_FeatureList;
218
219 /*
220 **==============================================================================
221 **
222 ** MOF_ConstantValue
223 **
224 ** Represents a MOF constant value. The type field must be one of the
225 ** following:
226 ** TOK_INTEGER_VALUE
227 ** TOK_REAL_VALUE
228 ** TOK_CHAR_VALUE
229 ** TOK_STRING_VALUE
230 ** TOK_NULL
231 **
232 ** The union holds the value (or nothing if it is null).
233 **
234 **==============================================================================
235 mike 1.2 */
236
237 typedef struct _MOF_ConstantValue
238 {
239 int type;
240 union
241 {
242 MI_Sint64 integer;
243 MI_Real64 real;
244 MI_Char16 character;
245 MI_Boolean boolean;
246 char* string;
247 }
248 value;
249 /* str-to-int conversion flag: boolean flag that indicates value is too big for sint64 */
250 MI_Boolean tooBigForSint64;
251 }
252 MOF_ConstantValue;
253
254 /*
255 **==============================================================================
256 mike 1.2 **
257 ** MOF_Initializer
258 **
259 ** Represents a MOF initializer (both scalar and array). Scalars are
260 ** represented by a single constant value element with size set to 1.
261 ** Arrays are are represented by an array of constant values with size
262 ** set to the size of the array.
263 **
264 **==============================================================================
265 */
266
267 typedef struct _MOF_Initializer
268 {
269 MOF_ConstantValue* data;
270 MI_Uint32 size;
271 MI_Boolean isArray;
272 }
273 MOF_Initializer;
274
275 /*
276 **==============================================================================
277 mike 1.2 **
278 ** Functions
279 **
280 **==============================================================================
281 */
282
283 /* Convert this initializer to a Statik value of the given type */
284 int InitializerToValue(
285 MOF_Initializer* self,
286 MI_Uint32 /*MI_Type*/ type,
287 void** value);
288
289 /* Release all memory held by this initializer */
290 void ReleaseInitializer(
291 MOF_Initializer* self);
292
293 void FreeQualifierDeclaration(
294 MI_QualifierDecl* self);
295
296 int AddQualifierDeclaration(
297 MI_QualifierDecl* qd);
298 mike 1.2
299 const MI_QualifierDecl* FindQualifierDeclaration(
300 const char* name);
301
302 int AddClassDecl(
303 MI_ClassDecl* cd);
304
305 const MI_ClassDecl* FindClassDecl(
306 const char* name);
307
308 void MOF_PrintQualifierDecl(
309 const MI_QualifierDecl* self,
310 FILE* file);
311
312 void PrintValue(
313 const void* value,
314 MI_Type type,
315 FILE* file);
316
317 void PrintQualifier(
318 const MI_Qualifier* self,
319 mike 1.2 size_t level,
320 FILE* file);
321
322 void PrintProperty(
323 const MI_PropertyDecl* self,
324 size_t level,
325 FILE* file);
326
327 void PrintMethod(
328 const MI_MethodDecl* self,
329 size_t level,
330 FILE* file);
331
332 MI_PropertyDecl* FindProperty(
333 MOF_PropertyList* self,
334 const char* name);
335
336 MI_ParameterDecl* FindParameter(
337 MOF_ParameterList* self,
338 const char* name);
339
340 mike 1.2 MI_MethodDecl* FindMethod(
341 MOF_MethodList* self,
342 const char* name);
343
344 void MOF_PrintClassDecl(
345 const MI_ClassDecl* self,
346 FILE* file);
347
348 void MOF_PrintInstanceDecl(
349 const MI_InstanceDecl* self,
350 FILE* file);
351
352 MI_Uint32 GetQualFlags(
353 MI_Qualifier** qualifiers,
354 size_t numQualifiers);
355
356 void* NewTrueValue();
357
358 int FinalizeClass(
359 MI_ClassDecl* cd);
360
361 mike 1.2 int FinalizeInstance(
362 MI_InstanceDecl* decl);
363
364 /* Propagate flavors from 'from' mask to 'to' mask (return result mask) */
365 MI_Uint32 PropagateFlavors(MI_Uint32 to, MI_Uint32 from);
366
367 /* Find the given qualifier */
368 MI_Qualifier* FindQualifier(
369 MOF_QualifierList* self,
370 const char* name);
371
372 int CheckScope(MI_Uint32 scope, MOF_QualifierList* qualifiers);
373
374 int CheckPropertyValueConstraints(
375 const MI_PropertyDecl* pd);
376
377 int PerformPostProcessing();
378
379 MI_Type InitializerToType(const MOF_Initializer* initializer);
380
381 int AddInstanceDecl(
382 mike 1.2 MI_InstanceDecl* instanceDecl);
383
384 #endif /* _mof_types_h */
|