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