1 krisbash 1.1 #ifndef _omiutils_h
2 #define _omiutils_h
3
4 #include <MI.h>
5 #ifndef _NO_PAL
6 #include <pal/palcommon.h>
7 #include <pal/intlstr.h>
8 #include <pal/strings.h>
9
10 PAL_BEGIN_EXTERNC
11
12 PAL_INLINE int Tcscmp_s(
13 _In_opt_z_ const TChar* s1,
14 _In_opt_z_ const TChar* s2)
15 {
16 if (!s1)
17 return (!s2)? 0:-1;
18 else if (!s2)
19 return 1;
20
21 return Tcscmp(s1, s2);
22 krisbash 1.1 }
23
24 PAL_INLINE int Tcscasecmp_s(
25 _In_opt_z_ const TChar* s1,
26 _In_opt_z_ const TChar* s2)
27 {
28 if (!s1)
29 return (!s2)? 0:-1;
30 else if (!s2)
31 return 1;
32
33 return Tcscasecmp(s1, s2);
34 }
35
36 MI_Result MI_CALL Instance_New(
37 _In_ const MI_ClassDecl* classDecl,
38 _Out_ MI_Instance **instance);
39
40 /* Create ref-counted MI_Class with minimal memory allocations that allows properties/etc to be added efficiently.
41 No reallocations should happen as all arrays like qualifier arrays will be pre-created to the correct size based on client telling us when necessary.
42 Note!!! If you say there are 5 items for an array and you add 6 it will corrupt the object as the arrays have a size, but don't have an allocated size.
43 krisbash 1.1 MI_Class_Delete will be overloaded for this class such that it will bump down the refcount and if zero will delete it.
44 MI_Class_Clone can be overloaded to just bump the refcount (optional perf improvement).
45 All other MI_Class_* methods can be a pass-through to the main functions with no change as the rest of the object is the same.
46 */
47 MI_Result RCClass_New(
48 _In_opt_ MI_Class *parentClass,
49 _In_opt_z_ const MI_Char *namespaceName, /* Not needed if parentClass is passed in */
50 _In_opt_z_ const MI_Char *serverName, /* Not needed if parentClass is passed in */
51 _In_z_ const MI_Char *className,
52 MI_Uint32 numberClassQualifiers, /* number of extra class qualifiers you want to create. Allowes us to pre-create array of correct size */
53 MI_Uint32 numberProperties, /* number of extra properties you want to create. Allowes us to pre-create array of correct size */
54 MI_Uint32 numberMethods, /* number of extra methods you want to create. Allowes us to pre-create array of correct size */
55 _Out_ MI_Class **newClass /* Object that is ready to receive new qualifiers/properties/methods */
56 );
57
58 /* Add a qualifier to a ref-counted class. The qualifier array needs to be pre-created by passing in the number of classQualifiers
59 to the RCClass_New API
60 */
61 MI_Result RCClass_AddClassQualifier(
62 _In_ MI_Class *refcountedClass, /* Object created from RCClass_New only */
63 _In_z_ const MI_Char *name, /* qualifier name */
64 krisbash 1.1 MI_Type type, /* Type of qualifier */
65 MI_Value value, /* Value of qualifier */
66 MI_Uint32 flavors); /* Flavor of qualifier */
67
68 /* Array verion of RCClass_AddClassQualifier. Pass in how many items there are and it returns a qualifier index to be used to add each
69 * item in tern.
70 */
71 MI_Result RCClass_AddClassQualifierArray(
72 _In_ MI_Class *refcountedClass,/* Object created from RCClass_New only */
73 _In_z_ const MI_Char *name, /* qualifier name */
74 MI_Type type, /* Type of qualifier */
75 MI_Uint32 flavors, /* Flavor of qualifier */
76 MI_Uint32 numberArrayItems, /* Number of items in qualifier array */
77 _Out_ MI_Uint32 *qualifierIndex);/* this qualifier index */
78
79 /* Add an array item to the array created with call to RCClass_AddClassQualifierArray
80 */
81 MI_Result RCClass_AddClassQualifierArrayItem(
82 _In_ MI_Class *refcountedClass, /* Object created from RCClass_New only */
83 MI_Uint32 qualifierIndex, /* qualifier index */
84 MI_Value value); /* value to add to array */
85 krisbash 1.1
86 /* Add a element to a ref-counted class. The element array needs to be pre-created by passing in the number of classProperties
87 to the RCClass_New API
88 */
89 MI_Result RCClass_AddElement(
90 _In_ MI_Class *refcountedClass, /* Object created from RCClass_New only */
91 _In_z_ const MI_Char *name, /* element name */
92 MI_Type type, /* Element type */
93 MI_Value value, /* element default value */
94 MI_Uint32 flags, /* element flags */
95 _In_opt_z_ const MI_Char *associatedClassName, /* EmbeddedInstance class name or reference class name */
96 MI_Boolean propagated,
97 _In_opt_z_ const MI_Char *classOrigin,
98 MI_Uint32 numberElementQualifiers, /* Number of qualifiers this element is going to get. Allows us to pre-create array of correct size */
99 _Out_ MI_Uint32 *elementId);
100
101 MI_Result RCClass_AddElementArray(
102 _In_ MI_Class *refcountedClass, /* Object created from RCClass_New only */
103 _In_z_ const MI_Char *name, /* element name */
104 MI_Type type, /* Element type */
105 MI_Uint32 flags, /* element flags */
106 krisbash 1.1 _In_opt_z_ const MI_Char *associatedClassName, /* EmbeddedInstance class name or reference class name */
107 MI_Boolean propagated,
108 _In_opt_z_ const MI_Char *originClass,
109 MI_Uint32 maxArrayLength,
110 MI_Uint32 numberElementQualifiers, /* Number of qualifiers this element is going to get. Allows us to pre-create array of correct size */
111 MI_Uint32 numberPropertyArrayItems,
112 _Out_ MI_Uint32 *elementId);
113
114 MI_Result RCClass_AddElementArrayItem(
115 _In_ MI_Class *refcountedClass, /* Object created from RCClass_New only */
116 MI_Uint32 elementId,
117 MI_Value value); /* element array item*/
118
119 /* Add a element qualifierto a ref-counted class. The element property qualifier array needs to be pre-created by passing in the correct numberPropertyQualifiers
120 to the RCClass_AddElement API
121 */
122 MI_Result RCClass_AddElementQualifier(
123 _In_ MI_Class *refcountedClass,
124 MI_Uint32 elementIndex,
125 _In_z_ const MI_Char *name,
126 MI_Type type,
127 krisbash 1.1 MI_Value value,
128 MI_Uint32 flavor) ;
129
130 MI_Result RCClass_AddElementQualifierArray(
131 _In_ MI_Class *refcountedClass, /* Object created from RCClass_New only */
132 MI_Uint32 elementId, /* element index returned from RCClass_AddElement */
133 _In_z_ const MI_Char *name,
134 MI_Type type,
135 MI_Uint32 flavor,
136 MI_Uint32 numberItemsInQualifierArray,
137 _Out_ MI_Uint32 *qualifierIndex) ;
138
139 MI_Result RCClass_AddElementQualifierArrayItem(
140 _In_ MI_Class *refcountedClass,
141 MI_Uint32 elementIndex,
142 MI_Uint32 qualifierIndex,
143 MI_Value value) ;
144
145 /* Add a method to a refcounted class. The class method array was precreated by passing numberMethods to RCClass_New.
146 Add the method in the next slot by querying how many methods are currently there. Don't add more methods than
147 you said you wanted as the array is fixed.
148 krisbash 1.1 */
149 MI_Result RCClass_AddMethod(
150 _In_ MI_Class *refcountedClass,
151 _In_z_ const MI_Char *name,
152 MI_Uint32 flags, /* Is this needed? */
153 MI_Uint32 numberParameters,
154 MI_Uint32 numberQualifiers,
155 _Out_ MI_Uint32 *methodID);
156
157 /* Add a method qualifier to a refcounted class. The method qualifier array was precreated by passing numberQualifiers to RCClass_AddMethod.
158 Add the qualifier in the next slot by querying how many qualifiers are currently there. Don't add more qualifiers than
159 you said you wanted as the array is fixed
160 */
161 MI_Result RCClass_AddMethodQualifier(
162 _In_ MI_Class *refcountedClass,
163 MI_Uint32 methodIndex,
164 _In_z_ const MI_Char *name,
165 MI_Type type,
166 MI_Value value,
167 MI_Uint32 flavor);
168
169 krisbash 1.1 MI_Result RCClass_AddMethodQualifierArray(
170 _In_ MI_Class *refcountedClass,
171 MI_Uint32 methodIndex,
172 _In_z_ const MI_Char *name,
173 MI_Type type,
174 MI_Uint32 flavor,
175 MI_Uint32 numberItemsInArray,
176 _Out_ MI_Uint32 *qualifierId);
177
178 MI_Result RCClass_AddMethodQualifierArrayItem(
179 _In_ MI_Class *refcountedClass,
180 MI_Uint32 methodIndex,
181 MI_Uint32 qualifierId,
182 MI_Value value);
183
184 /* Add a method parameter to a refcounted class. The method parameter array was precreated by passing numberParameters to RCClass_AddMethod.
185 Add the parameter in the next slot by querying how many qualifiers are currently there. Don't add more properties than
186 you said you wanted as the array is fixed
187 */
188 MI_Result RCClass_AddMethodParameter(
189 _In_ MI_Class *refcountedClass,
190 krisbash 1.1 MI_Uint32 methodIndex,
191 _In_z_ const MI_Char *name,
192 _In_opt_z_ const MI_Char *refClassname,
193 MI_Type type,
194 MI_Uint32 flags,
195 MI_Uint32 maxArrayLength,
196 MI_Uint32 numberQualifiers,
197 _Out_ MI_Uint32 *parameterIndex);
198
199 /* Add a method parameter qualifier to a refcounted class. The method parameter qualifier array was precreated by passing numberQualifiers to RCClass_AddMethodProperty.
200 Add the qualifier in the next slot by querying how many method property qualifiers are currently there. Don't add more qualifiers than
201 you said you wanted as the array is fixed
202 */
203 MI_Result RCClass_AddMethodParameterQualifier(
204 _In_ MI_Class *refcountedClass,
205 MI_Uint32 methodIndex,
206 MI_Uint32 parameterIndex,
207 _In_z_ const MI_Char *name,
208 MI_Type type,
209 MI_Value value,
210 MI_Uint32 flavor);
211 krisbash 1.1
212 MI_Result RCClass_AddMethodParameterQualifierArray(
213 _In_ MI_Class *refcountedClass,
214 MI_Uint32 methodIndex,
215 MI_Uint32 parameterIndex,
216 _In_z_ const MI_Char *name,
217 MI_Type type,
218 MI_Uint32 flavor,
219 MI_Uint32 numberItemsInArray,
220 _Out_ MI_Uint32 *qualifierIndex);
221
222 MI_Result RCClass_AddMethodParameterQualifierArrayItem(
223 _In_ MI_Class *refcountedClass,
224 MI_Uint32 methodIndex,
225 MI_Uint32 parameterIndex,
226 MI_Uint32 qualifierIndex,
227 MI_Value value);
228
229 MI_Result Class_New(
230 _In_ const MI_ClassDecl *classDecl,
231 _In_opt_z_ const MI_Char *namespaceName,
232 krisbash 1.1 _In_opt_z_ const MI_Char *serverName,
233 _In_opt_ void *batch,
234 _Out_ MI_Class **newClass);
235
236 MI_Result Instance_InitDynamic(
237 MI_Instance** self,
238 const MI_Char* className,
239 MI_Uint32 metaType);
240
241 MI_Uint64 GetClassDeclId(_In_ const MI_ClassDecl* classDecl);
242
243
244 #endif
245
246 /*------------------------------------------------------------------------------
247 Creates a new instance of OMI_Error and sets the values of Message,
248 OMI_ErrorCode, OMI_ErrorType and OMI_ErrorCategory properties.
249 ------------------------------------------------------------------------------*/
250 MI_Result MI_CALL CreateOMIError(
251 _In_opt_z_ const MI_Char* message,
252 MI_Uint32 errorCode,
253 krisbash 1.1 _In_z_ const MI_Char* errorType,
254 MI_Uint16 errorCategory,
255 _Outptr_ MI_Instance **omiError);
256
257 #ifndef _NO_PAL
258 PAL_INLINE MI_Result CreateOMIError_IntlstrMessage(
259 _In_ _At_(message.str, _Post_invalid_) Intlstr message,
260 MI_Uint32 errorCode,
261 _In_z_ const MI_Char* errorType,
262 MI_Uint16 errorCategory,
263 _Outptr_ MI_Instance **omiError)
264 {
265 MI_Result result = CreateOMIError(message.str, errorCode, errorType, errorCategory, omiError);
266 Intlstr_Free(message);
267 return result;
268 }
269 #endif
270
271 /*------------------------------------------------------------------------------
272 Creates a new instance of OMI_DebugError and sets the values of Message,
273 OMI_ErrorCode, OMI_ErrorType and OMI_ErrorCategory properties.
274 krisbash 1.1 ------------------------------------------------------------------------------*/
275 MI_Result MI_CALL CreateOMIDebugError(
276 _In_opt_z_ const MI_Char* message,
277 MI_Uint32 errorCode,
278 _In_z_ const MI_Char* errorType,
279 MI_Uint16 errorCategory,
280 _Outptr_ MI_Instance **omiError);
281
282 #ifndef _NO_PAL
283 PAL_INLINE MI_Result CreateOMIDebugError_IntlstrMessage(
284 _In_ _At_(message.str, _Post_invalid_) Intlstr message,
285 MI_Uint32 errorCode,
286 _In_z_ const MI_Char* errorType,
287 MI_Uint16 errorCategory,
288 _Outptr_ MI_Instance **omiError)
289 {
290 MI_Result result = CreateOMIDebugError(message.str, errorCode, errorType, errorCategory, omiError);
291 Intlstr_Free(message);
292 return result;
293 }
294 #endif
295 krisbash 1.1
296 MI_Result MI_CALL CreateOMIError_FromMiResult(
297 MI_Result miResult,
298 _Outptr_ MI_Instance **omiError);
299
300 MI_Result MI_CALL CreateOMIDebugError_FromMiResult(
301 MI_Result miResult,
302 _Outptr_ MI_Instance **omiError);
303
304 #ifndef _NO_PAL
305 PAL_END_EXTERNC
306 #endif
307
308 #endif /* _omiutils_h */
|