1 | /** @file
|
---|
2 | * CFGLDR - Configuration Loader
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2006-2007 innotek GmbH
|
---|
7 | *
|
---|
8 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
9 | * available from http://www.virtualbox.org. This file is free software;
|
---|
10 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
11 | * General Public License as published by the Free Software Foundation,
|
---|
12 | * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
|
---|
13 | * distribution. VirtualBox OSE is distributed in the hope that it will
|
---|
14 | * be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
15 | *
|
---|
16 | * If you received this file as part of a commercial VirtualBox
|
---|
17 | * distribution, then only the terms of your commercial VirtualBox
|
---|
18 | * license agreement apply instead of the previous paragraph.
|
---|
19 | */
|
---|
20 |
|
---|
21 | #ifndef __VBox_cfgldr_h__
|
---|
22 | #define __VBox_cfgldr_h__
|
---|
23 |
|
---|
24 | #include <VBox/cdefs.h>
|
---|
25 | #include <VBox/types.h>
|
---|
26 | #include <iprt/string.h>
|
---|
27 |
|
---|
28 |
|
---|
29 | /** @defgroup grp_cfgldr The Configuration Loader API
|
---|
30 | * @{
|
---|
31 | */
|
---|
32 |
|
---|
33 | #ifndef IN_RING3
|
---|
34 | # error "There are no configuration loader APIs available in Ring-0 Context!"
|
---|
35 | #else /* IN_RING3 */
|
---|
36 |
|
---|
37 | /** @def IN_CFGLDR_R3
|
---|
38 | * Used to indicate whether we're inside the same link module as the
|
---|
39 | * Configuration Loader.
|
---|
40 | */
|
---|
41 | #ifdef IN_CFGLDR_R3
|
---|
42 | # define CFGLDRR3DECL(type) DECLEXPORT(type) VBOXCALL
|
---|
43 | #else
|
---|
44 | # define CFGLDRR3DECL(type) DECLIMPORT(type) VBOXCALL
|
---|
45 | #endif
|
---|
46 |
|
---|
47 | /** @type CFGHANDLE
|
---|
48 | * Configuration handle. */
|
---|
49 | /** @type CFGNODE
|
---|
50 | * Configuration node handle. */
|
---|
51 | #ifdef __cplusplus
|
---|
52 | class CfgLoader;
|
---|
53 | typedef CfgLoader *CFGHANDLE;
|
---|
54 |
|
---|
55 | class CfgNode;
|
---|
56 | typedef CfgNode *CFGNODE;
|
---|
57 | #else
|
---|
58 | struct CfgLoader;
|
---|
59 | typedef struct CfgLoader *CFGHANDLE;
|
---|
60 |
|
---|
61 | struct CfgNode;
|
---|
62 | typedef struct CfgNode *CFGNODE;
|
---|
63 | #endif
|
---|
64 |
|
---|
65 | /** Entity type */
|
---|
66 | typedef enum CFGLDRENTITYTYPE
|
---|
67 | {
|
---|
68 | CFGLDRENTITYTYPE_INVALID = 0, /**< Invalid type */
|
---|
69 | CFGLDRENTITYTYPE_HANDLE, /**< File handle */
|
---|
70 | CFGLDRENTITYTYPE_MEMORY /**< Memory buffer */
|
---|
71 | } CFGLDRENTITYTYPE;
|
---|
72 |
|
---|
73 | /** Entity descriptor for the entity resolver callback */
|
---|
74 | typedef struct CFGLDRENTITY
|
---|
75 | {
|
---|
76 | /** Entity type */
|
---|
77 | CFGLDRENTITYTYPE enmType;
|
---|
78 |
|
---|
79 | union
|
---|
80 | {
|
---|
81 | /** File handle (CFGLDRENTITYTYPE_HANDLE) */
|
---|
82 | struct
|
---|
83 | {
|
---|
84 | RTFILE hFile; /**< Handle of the file opened for reading entity data */
|
---|
85 | bool bClose; /**< Whether to close the handle when no more needed */
|
---|
86 | } handle;
|
---|
87 | /** Memory buffer (CFGLDRENTITYTYPE_MEMORY) */
|
---|
88 | struct
|
---|
89 | {
|
---|
90 | unsigned char *puchBuf; /**< Byte array containing entity data */
|
---|
91 | size_t cbBuf; /**< Size of the puchBuf array */
|
---|
92 | bool bFree; /**< Whether to free puchBuf using RTMemTmpFree()
|
---|
93 | when no more needed */
|
---|
94 | } memory;
|
---|
95 | } u;
|
---|
96 |
|
---|
97 | } CFGLDRRESOLVEDENTITY;
|
---|
98 |
|
---|
99 | /** Pointer to CFGLDRENTITY */
|
---|
100 | typedef CFGLDRENTITY *PCFGLDRENTITY;
|
---|
101 | /** Pointer to const CFGLDRENTITY */
|
---|
102 | typedef const CFGLDRENTITY *PCCFGLDRENTITY;
|
---|
103 |
|
---|
104 | /**
|
---|
105 | * Callback function used by CFGLDRLoad() to resolve external entities when
|
---|
106 | * loading and parsing the configuration file,
|
---|
107 | *
|
---|
108 | * First three arguments are input parameters, describing the entity to resolve.
|
---|
109 | * On return, the callback fills in a CFGLDRENTITY structure pointed to by the
|
---|
110 | * pEntity argument, with values corresponding to the given entity.
|
---|
111 | *
|
---|
112 | * @param pcszPublicId
|
---|
113 | * Public ID of the entity in question (UTF-8)
|
---|
114 | * @param pcszSystemId
|
---|
115 | * System ID (URI) of the entity in question (UTF-8)
|
---|
116 | * @param pcszBaseURI
|
---|
117 | * Base URI of the entity necessary to resolve relative URIs (UTF-8)
|
---|
118 | * @param pEntity
|
---|
119 | * Pointer to the entity descriptor structure to fill in
|
---|
120 | *
|
---|
121 | * @return
|
---|
122 | * VINF_SUCCESS to indicate that pEntity is successfully filled in by the
|
---|
123 | * callback. Any other value will cause the configuration
|
---|
124 | * loader to use the default entity resolver (see pfnEntityResolver in
|
---|
125 | * CFGLDRLoad()).
|
---|
126 | */
|
---|
127 | typedef DECLCALLBACK(int) FNCFGLDRENTITYRESOLVER(const char *pcszPublicId,
|
---|
128 | const char *pcszSystemId,
|
---|
129 | const char *pcszBaseURI,
|
---|
130 | PCFGLDRENTITY pEntity);
|
---|
131 | /** Pointer to entity resolver callback. */
|
---|
132 | typedef FNCFGLDRENTITYRESOLVER *PFNCFGLDRENTITYRESOLVER;
|
---|
133 |
|
---|
134 | __BEGIN_DECLS
|
---|
135 |
|
---|
136 | /**
|
---|
137 | * Initializes CFGLDR, have to be called at VBox startup before accessing any CFGLDR functions.
|
---|
138 | *
|
---|
139 | * @return VBox status code.
|
---|
140 | */
|
---|
141 | CFGLDRR3DECL(int) CFGLDRInitialize(void);
|
---|
142 |
|
---|
143 | /**
|
---|
144 | * Deletes all configurations and nodes at VBox termination. After calling this function all CFGLDR functions will be unavailable.
|
---|
145 | *
|
---|
146 | * @return VBox status code.
|
---|
147 | */
|
---|
148 | CFGLDRR3DECL(void) CFGLDRShutdown(void);
|
---|
149 |
|
---|
150 | /**
|
---|
151 | * Creates a configuration file from scratch. The file then can be saved
|
---|
152 | * using the CFGLDRSaveAs() function.
|
---|
153 | *
|
---|
154 | * @return VBox status code.
|
---|
155 | */
|
---|
156 | CFGLDRR3DECL(int) CFGLDRCreate(CFGHANDLE *phcfg);
|
---|
157 |
|
---|
158 | /**
|
---|
159 | * Loads a configuration file.
|
---|
160 | *
|
---|
161 | * @param phcfg
|
---|
162 | * Pointer to a handle that will be used to access the configuration.
|
---|
163 | * @param pszFilename
|
---|
164 | * Name of the file containing the configuration (UTF-8).
|
---|
165 | * @param hFileHandle
|
---|
166 | * Handle of the file containing the configuration. If equals to NIL_RTFILE,
|
---|
167 | * an attempt to open the specified file will be made; otherwise
|
---|
168 | * it must be a valid file handle corresponding to the given file name
|
---|
169 | * opened at least for reading.
|
---|
170 | * @param pszExternalSchemaLocation
|
---|
171 | * Name of the file containing namespaceless XML Schema for the configuration
|
---|
172 | * file or one or more pairs (separated by spaces) consiting of a namespace
|
---|
173 | * and an XML schema file for the given namespace, depending on the
|
---|
174 | * value of bDoNamespaces. The parameter can be NULL to indicate that
|
---|
175 | * no validation of the configuration file should be done.
|
---|
176 | * @param bDoNamespaces
|
---|
177 | * If TRUE, namespace processing is turned on and pszExternalSchemaLocation
|
---|
178 | * is assumed to contain "namespace schema-file" pairs; otherwise namespaces
|
---|
179 | * are disabled and pszExternalSchemaLocation is assumed to be a single file
|
---|
180 | * name. The parameter ignored if pszExternalSchemaLocation is NULL.
|
---|
181 | * @param pfnEntityResolver
|
---|
182 | * Callback used to resolve external entities in the configuration file.
|
---|
183 | * Note that the configuration file itself is always accessed directly
|
---|
184 | * (using the given file name or file handle), but all external entities it
|
---|
185 | * refers to, as well as all schema files, are resolved using this callback.
|
---|
186 | * This parameter can be NULL, in which case the default resolver is used
|
---|
187 | * which simply tries to open an entity by its system ID (URI).
|
---|
188 | * @param ppszErrorMessage
|
---|
189 | * Address of a variable that will receive a pointer to an UTF-8 string
|
---|
190 | * containing all error messages produced by a parser while parsing and
|
---|
191 | * validating the configuration file. If non-NULL pointer is returned, the
|
---|
192 | * caller must free the string using RTStrFree(). The parameter can be
|
---|
193 | * NULL on input (no error string will be returned), and it can point to
|
---|
194 | * NULL on output indicating that no error message was provided.
|
---|
195 | * If the function succeeds, the returned string is always NULL.
|
---|
196 | *
|
---|
197 | * @return VBox status code.
|
---|
198 | */
|
---|
199 | CFGLDRR3DECL(int) CFGLDRLoad(CFGHANDLE *phcfg,
|
---|
200 | const char *pszFileName, RTFILE hFileHandle,
|
---|
201 | const char *pszExternalSchemaLocation, bool bDoNamespaces,
|
---|
202 | PFNCFGLDRENTITYRESOLVER pfnEntityResolver,
|
---|
203 | char **ppszErrorMessage);
|
---|
204 |
|
---|
205 | /**
|
---|
206 | * Frees the previously loaded configuration.
|
---|
207 | *
|
---|
208 | * @return VBox status code.
|
---|
209 | * @param hcfg Handle of configuration that was loaded using CFGLDRLoad().
|
---|
210 | */
|
---|
211 | CFGLDRR3DECL(int) CFGLDRFree(CFGHANDLE hcfg);
|
---|
212 |
|
---|
213 | /**
|
---|
214 | * Saves the previously loaded configuration.
|
---|
215 | *
|
---|
216 | * @param hcfg
|
---|
217 | * Handle of the configuration that was loaded using CFGLDRLoad().
|
---|
218 | * @param ppszErrorMessage
|
---|
219 | * Address of a variable that will receive a pointer to an UTF-8 string
|
---|
220 | * containing all error messages produced by a writer while saving
|
---|
221 | * the configuration file. If non-NULL pointer is returned, the
|
---|
222 | * caller must free the string using RTStrFree(). The parameter can be
|
---|
223 | * NULL on input (no error string will be returned), and it can point to
|
---|
224 | * NULL on output indicating that no error message was provided.
|
---|
225 | * If the function succeeds, the returned string is always NULL.
|
---|
226 | *
|
---|
227 | * @return VBox status code.
|
---|
228 | */
|
---|
229 | CFGLDRR3DECL(int) CFGLDRSave(CFGHANDLE hcfg,
|
---|
230 | char **ppszErrorMessage);
|
---|
231 | /**
|
---|
232 | * Saves the configuration to a specified file.
|
---|
233 | *
|
---|
234 | * @param hcfg
|
---|
235 | * Handle of the configuration that was loaded using CFGLDRLoad().
|
---|
236 | * @param pszFilename
|
---|
237 | * Name of the file to save the configuration to (UTF-8).
|
---|
238 | * @param hFileHandle
|
---|
239 | * Handle of the file to save the configuration to. If equals to NIL_RTFILE,
|
---|
240 | * an attempt to open the specified file will be made; otherwise
|
---|
241 | * it must be a valid file handle corresponding to the given file name
|
---|
242 | * opened at least for writting.
|
---|
243 | * @param ppszErrorMessage
|
---|
244 | * Address of a variable that will receive a pointer to an UTF-8 string
|
---|
245 | * containing all error messages produced by a writer while saving
|
---|
246 | * the configuration file. If non-NULL pointer is returned, the
|
---|
247 | * caller must free the string using RTStrFree(). The parameter can be
|
---|
248 | * NULL on input (no error string will be returned), and it can point to
|
---|
249 | * NULL on output indicating that no error message was provided.
|
---|
250 | * If the function succeeds, the returned string is always NULL.
|
---|
251 | *
|
---|
252 | * @return VBox status code.
|
---|
253 | */
|
---|
254 | CFGLDRR3DECL(int) CFGLDRSaveAs(CFGHANDLE hcfg,
|
---|
255 | const char *pszFilename, RTFILE hFileHandle,
|
---|
256 | char **ppszErrorMessage);
|
---|
257 |
|
---|
258 | /**
|
---|
259 | * Applies an XSLT transformation to the given configuration handle.
|
---|
260 | *
|
---|
261 | * @param hcfg
|
---|
262 | * Handle of the configuration that was loaded using CFGLDRLoad().
|
---|
263 | * @param pszTemlateLocation
|
---|
264 | * Name of the file containing an XSL template to apply
|
---|
265 | * @param pfnEntityResolver
|
---|
266 | * Callback used to resolve external entities (the XSL template file).
|
---|
267 | * This parameter can be NULL, in which case the default resolver is used
|
---|
268 | * which simply tries to open an entity by its system ID (URI).
|
---|
269 | * @param ppszErrorMessage
|
---|
270 | * Address of a variable that will receive a pointer to an UTF-8 string
|
---|
271 | * containing all error messages produced by a parser while parsing and
|
---|
272 | * validating the configuration file. If non-NULL pointer is returned, the
|
---|
273 | * caller must free the string using RTStrFree(). The parameter can be
|
---|
274 | * NULL on input (no error string will be returned), and it can point to
|
---|
275 | * NULL on output indicating that no error message was provided.
|
---|
276 | * If the function succeeds, the returned string is always NULL.
|
---|
277 | */
|
---|
278 | CFGLDRR3DECL(int) CFGLDRTransform (CFGHANDLE hcfg,
|
---|
279 | const char *pszTemlateLocation,
|
---|
280 | PFNCFGLDRENTITYRESOLVER pfnEntityResolver,
|
---|
281 | char **ppszErrorMessage);
|
---|
282 |
|
---|
283 | /**
|
---|
284 | * Get node handle.
|
---|
285 | *
|
---|
286 | * @return VBox status code.
|
---|
287 | * @param hcfg Handle of configuration that was loaded using CFGLDRLoad().
|
---|
288 | * @param pszName Name of the node (UTF-8).
|
---|
289 | * @param uIndex Index of the node (0 based).
|
---|
290 | * @param phnode Pointer to a handle that will be used to access the node attributes, value and child nodes.
|
---|
291 | */
|
---|
292 | CFGLDRR3DECL(int) CFGLDRGetNode(CFGHANDLE hcfg, const char *pszName, unsigned uIndex, CFGNODE *phnode);
|
---|
293 |
|
---|
294 | /**
|
---|
295 | * Get child node handle.
|
---|
296 | *
|
---|
297 | * @return VBox status code.
|
---|
298 | * @param hparent Handle of parent node.
|
---|
299 | * @param pszName Name of the child node (UTF-8), NULL for any child.
|
---|
300 | * @param uIndex Index of the child node (0 based).
|
---|
301 | * @param phnode Pointer to a handle that will be used to access the node attributes, value and child nodes.
|
---|
302 | */
|
---|
303 | CFGLDRR3DECL(int) CFGLDRGetChildNode(CFGNODE hparent, const char *pszName, unsigned uIndex, CFGNODE *phnode);
|
---|
304 |
|
---|
305 | /**
|
---|
306 | * Creates a new node or returns the first one with a given name if
|
---|
307 | * already exists.
|
---|
308 | *
|
---|
309 | * @return VBox status code.
|
---|
310 | * @param hcfg Handle of the configuration.
|
---|
311 | * @param pszName Name of the node to be created (UTF-8).
|
---|
312 | * @param phnode Pointer to a handle that will be used to access the node attributes, value and child nodes.
|
---|
313 | */
|
---|
314 | CFGLDRR3DECL(int) CFGLDRCreateNode(CFGHANDLE hcfg, const char *pszName, CFGNODE *phnode);
|
---|
315 |
|
---|
316 | /**
|
---|
317 | * Creates a new child node or returns the first one with a given name if
|
---|
318 | * already exists.
|
---|
319 | *
|
---|
320 | * @return VBox status code.
|
---|
321 | * @param hparent Handle of parent node.
|
---|
322 | * @param pszName Name of the child node (UTF-8).
|
---|
323 | * @param phnode Pointer to a handle that will be used to access the node attributes, value and child nodes.
|
---|
324 | */
|
---|
325 | CFGLDRR3DECL(int) CFGLDRCreateChildNode(CFGNODE hparent, const char *pszName, CFGNODE *phnode);
|
---|
326 |
|
---|
327 | /**
|
---|
328 | * Appends a new child node.
|
---|
329 | *
|
---|
330 | * @return VBox status code.
|
---|
331 | * @param hparent Handle of parent node.
|
---|
332 | * @param pszName Name of the child node (UTF-8).
|
---|
333 | * @param phnode Pointer to a handle that will be used to access the node attributes, value and child nodes.
|
---|
334 | */
|
---|
335 | CFGLDRR3DECL(int) CFGLDRAppendChildNode(CFGNODE hparent, const char *pszName, CFGNODE *phnode);
|
---|
336 |
|
---|
337 | /**
|
---|
338 | * Release node handle.
|
---|
339 | *
|
---|
340 | * @return VBox status code.
|
---|
341 | * @param hnode Handle that will not be used anymore.
|
---|
342 | */
|
---|
343 | CFGLDRR3DECL(int) CFGLDRReleaseNode(CFGNODE hnode);
|
---|
344 |
|
---|
345 | /**
|
---|
346 | * Delete node. The handle is released and the entire node is removed.
|
---|
347 | *
|
---|
348 | * @return VBox status code.
|
---|
349 | * @param hnode Handle of node that will be deleted.
|
---|
350 | */
|
---|
351 | CFGLDRR3DECL(int) CFGLDRDeleteNode(CFGNODE hnode);
|
---|
352 |
|
---|
353 | /**
|
---|
354 | * Count child nodes with given name.
|
---|
355 | *
|
---|
356 | * @return VBox status code.
|
---|
357 | * @param hparent Handle of parent node.
|
---|
358 | * @param pszChildName Name of the child node (UTF-8), NULL for all children.
|
---|
359 | * @param pCount Pointer to unsigned variable where to store the count.
|
---|
360 | */
|
---|
361 | CFGLDRR3DECL(int) CFGLDRCountChildren(CFGNODE hnode, const char *pszChildName, unsigned *pCount);
|
---|
362 |
|
---|
363 | /**
|
---|
364 | * Query 32 bit unsigned value attribute.
|
---|
365 | *
|
---|
366 | * @return VBox status code.
|
---|
367 | * @param hnode Node which attribute will be queried.
|
---|
368 | * @param pszName Name of the attribute (UTF-8), NULL for the node value.
|
---|
369 | * @param pu32Value Pointer to 32 bit variable where to store the value.
|
---|
370 | */
|
---|
371 | CFGLDRR3DECL(int) CFGLDRQueryUInt32(CFGNODE hnode, const char *pszName, uint32_t *pu32Value);
|
---|
372 |
|
---|
373 | /**
|
---|
374 | * Set 32 bit unsigned value attribute.
|
---|
375 | *
|
---|
376 | * @return VBox status code.
|
---|
377 | * @param hnode Node which attribute will be set.
|
---|
378 | * @param pszName Name of the attribute (UTF-8), NULL for the node value.
|
---|
379 | * @param u32Value The value.
|
---|
380 | */
|
---|
381 | CFGLDRR3DECL(int) CFGLDRSetUInt32(CFGNODE hnode, const char *pszName, uint32_t u32Value);
|
---|
382 |
|
---|
383 | /**
|
---|
384 | * Query 64 bit unsigned value attribute.
|
---|
385 | *
|
---|
386 | * @return VBox status code.
|
---|
387 | * @param hnode Node which attribute will be queried.
|
---|
388 | * @param pszName Name of the attribute (UTF-8), NULL for the node value.
|
---|
389 | * @param pu64Value Pointer to 64 bit variable where to store the value.
|
---|
390 | */
|
---|
391 | CFGLDRR3DECL(int) CFGLDRQueryUInt64(CFGNODE hnode, const char *pszName, uint64_t *pu64Value);
|
---|
392 |
|
---|
393 | /**
|
---|
394 | * Set 64 bit unsigned value attribute.
|
---|
395 | *
|
---|
396 | * @return VBox status code.
|
---|
397 | * @param hnode Node which attribute will be set.
|
---|
398 | * @param pszName Name of the attribute (UTF-8), NULL for the node value.
|
---|
399 | * @param u64Value The value.
|
---|
400 | */
|
---|
401 | CFGLDRR3DECL(int) CFGLDRSetUInt64(CFGNODE hnode, const char *pszName, uint64_t u64Value);
|
---|
402 |
|
---|
403 | /**
|
---|
404 | * Query 32 bit signed integer value attribute.
|
---|
405 | *
|
---|
406 | * @return VBox status code.
|
---|
407 | * @param hnode Node which attribute will be queried.
|
---|
408 | * @param pszName Name of the attribute (UTF-8), NULL for the node value.
|
---|
409 | * @param pint32Value Pointer to 32 bit variable where to store the value.
|
---|
410 | */
|
---|
411 | CFGLDRR3DECL(int) CFGLDRQueryInt32(CFGNODE hnode, const char *pszName, int32_t *pint32Value);
|
---|
412 |
|
---|
413 | /**
|
---|
414 | * Set 32 bit signed integer value attribute.
|
---|
415 | *
|
---|
416 | * @return VBox status code.
|
---|
417 | * @param hnode Node which attribute will be set.
|
---|
418 | * @param pszName Name of the attribute (UTF-8), NULL for the node value.
|
---|
419 | * @param int32Value The value.
|
---|
420 | */
|
---|
421 | CFGLDRR3DECL(int) CFGLDRSetInt32(CFGNODE hnode, const char *pszName, int32_t int32Value);
|
---|
422 |
|
---|
423 | /**
|
---|
424 | * Query 64 bit signed integer value attribute.
|
---|
425 | *
|
---|
426 | * @return VBox status code.
|
---|
427 | * @param hnode Node which attribute will be queried.
|
---|
428 | * @param pszName Name of the attribute (UTF-8), NULL for the node value.
|
---|
429 | * @param pint64Value Pointer to 64 bit variable where to store the value.
|
---|
430 | */
|
---|
431 | CFGLDRR3DECL(int) CFGLDRQueryInt64(CFGNODE hnode, const char *pszName, int64_t *pint64Value);
|
---|
432 |
|
---|
433 | /**
|
---|
434 | * Set 64 bit signed integer value attribute.
|
---|
435 | *
|
---|
436 | * @return VBox status code.
|
---|
437 | * @param hnode Node which attribute will be set.
|
---|
438 | * @param pszName Name of the attribute (UTF-8), NULL for the node value.
|
---|
439 | * @param int64Value The value.
|
---|
440 | */
|
---|
441 | CFGLDRR3DECL(int) CFGLDRSetInt64(CFGNODE hnode, const char *pszName, int64_t int64Value);
|
---|
442 |
|
---|
443 | /**
|
---|
444 | * Query 16 bit unsigned integer value attribute.
|
---|
445 | *
|
---|
446 | * @return VBox status code.
|
---|
447 | * @param hnode Node which attribute will be queried.
|
---|
448 | * @param pszName Name of the attribute (UTF-8), NULL for the node value.
|
---|
449 | * @param pu16Value Pointer to 16 bit variable where to store the value.
|
---|
450 | */
|
---|
451 | CFGLDRR3DECL(int) CFGLDRQueryUInt16(CFGNODE hnode, const char *pszName, uint16_t *pu16Value);
|
---|
452 |
|
---|
453 | /**
|
---|
454 | * Set 16 bit unsigned integer value attribute.
|
---|
455 | *
|
---|
456 | * @return VBox status code.
|
---|
457 | * @param hnode Node which attribute will be set.
|
---|
458 | * @param pszName Name of the attribute (UTF-8), NULL for the node value.
|
---|
459 | * @param u16Value The value.
|
---|
460 | */
|
---|
461 | CFGLDRR3DECL(int) CFGLDRSetUInt16(CFGNODE hnode, const char *pszName, uint16_t u16Value);
|
---|
462 |
|
---|
463 | /**
|
---|
464 | * Query binary data attribute. If the size of the buffer (cbValue)
|
---|
465 | * is smaller than the binary data size, the VERR_BUFFER_OVERFLOW status
|
---|
466 | * code is returned and the actual data size is stored into the variable
|
---|
467 | * pointed to by pcbValue; pvValue is ignored in this case.
|
---|
468 | *
|
---|
469 | * @return VBox status code.
|
---|
470 | * @param hnode Node which attribute will be queried.
|
---|
471 | * @param pszName Name of the attribute (UTF-8), NULL for the node value.
|
---|
472 | * @param pvValue Where to store the binary data.
|
---|
473 | * @param cbValue Size of buffer pvValue points to.
|
---|
474 | * @param pcbValue Where to store the number of bytes actually retrieved.
|
---|
475 | */
|
---|
476 | CFGLDRR3DECL(int) CFGLDRQueryBin(CFGNODE hnode, const char *pszName, void *pvValue, unsigned cbValue, unsigned *pcbValue);
|
---|
477 |
|
---|
478 | /**
|
---|
479 | * Set binary data attribute.
|
---|
480 | *
|
---|
481 | * @return VBox status code.
|
---|
482 | * @param hnode Node which attribute will be set.
|
---|
483 | * @param pszName Name of the attribute (UTF-8), NULL for the node value.
|
---|
484 | * @param pvValue The binary data to store.
|
---|
485 | * @param cbValue Size of buffer pvValue points to.
|
---|
486 | */
|
---|
487 | CFGLDRR3DECL(int) CFGLDRSetBin(CFGNODE hnode, const char *pszName, void *pvValue, unsigned cbValue);
|
---|
488 |
|
---|
489 | /**
|
---|
490 | * Queries a string attribute. If the size of the buffer (cbValue)
|
---|
491 | * is smaller than the length of the string, the VERR_BUFFER_OVERFLOW status
|
---|
492 | * code is returned and the actual string length is stored into the variable
|
---|
493 | * pointed to by pcbValue; pszValue is ignored in this case.
|
---|
494 | *
|
---|
495 | * @return VBox status code.
|
---|
496 | * @param hnode Node which attribute will be queried.
|
---|
497 | * @param pszName Name of the attribute (UTF-8), NULL for the node value.
|
---|
498 | * @param pszValue Where to store the string (UTF-8).
|
---|
499 | * @param cbValue Size of buffer pszValue points to, including the terminating zero.
|
---|
500 | * @param pcbValue Where to store the number of bytes actually retrieved, including the terminating zero.
|
---|
501 | */
|
---|
502 | CFGLDRR3DECL(int) CFGLDRQueryString(CFGNODE hnode, const char *pszName, char *pszValue, unsigned cbValue, unsigned *pcbValue);
|
---|
503 |
|
---|
504 | #ifdef CFGLDR_HAVE_COM
|
---|
505 | /**
|
---|
506 | * Queries a string attribute and returns it as an allocated OLE BSTR.
|
---|
507 | *
|
---|
508 | * @return VBox status code.
|
---|
509 | * @param hnode Node which attribute will be queried.
|
---|
510 | * @param pszName Name of the attribute (UTF-8), NULL for the node value.
|
---|
511 | * @param ppuszValue Where to store the pointer to the allocated BSTR.
|
---|
512 | */
|
---|
513 | CFGLDRR3DECL(int) CFGLDRQueryBSTR(CFGNODE hnode, const char *pszName, BSTR *ppuszValue);
|
---|
514 | #endif // CFGLDR_HAVE_COM
|
---|
515 |
|
---|
516 | /**
|
---|
517 | * Queries a UUID attribute and returns it into the supplied buffer.
|
---|
518 | *
|
---|
519 | * @return VBox status code.
|
---|
520 | * @param hnode Node which attribute will be queried.
|
---|
521 | * @param pszName Name of the attribute (UTF-8), NULL for the node value.
|
---|
522 | * @param pUUID Where to store the UUID.
|
---|
523 | */
|
---|
524 | CFGLDRR3DECL(int) CFGLDRQueryUUID(CFGNODE hnode, const char *pszName, PRTUUID pUUID);
|
---|
525 |
|
---|
526 | /**
|
---|
527 | * Set UUID attribute. It will be put inside curly brackets.
|
---|
528 | *
|
---|
529 | * @return VBox status code.
|
---|
530 | * @param hnode Node which attribute will be set.
|
---|
531 | * @param pszName Name of the attribute (UTF-8), NULL for the node value.
|
---|
532 | * @param pUuid The uuid.
|
---|
533 | */
|
---|
534 | CFGLDRR3DECL(int) CFGLDRSetUUID(CFGNODE hnode, const char *pszName, PCRTUUID pUuid);
|
---|
535 |
|
---|
536 | /**
|
---|
537 | * Set string attribute.
|
---|
538 | *
|
---|
539 | * @return VBox status code.
|
---|
540 | * @param hnode Node which attribute will be set.
|
---|
541 | * @param pszName Name of the attribute (UTF-8), NULL for the node value.
|
---|
542 | * @param pszValue The string (UTF-8).
|
---|
543 | * @param cbValue Size of buffer pszValue points to.
|
---|
544 | */
|
---|
545 | CFGLDRR3DECL(int) CFGLDRSetString(CFGNODE hnode, const char *pszName, const char *pszValue);
|
---|
546 |
|
---|
547 | #ifdef CFGLDR_HAVE_COM
|
---|
548 | /**
|
---|
549 | * Set BSTR attribute.
|
---|
550 | *
|
---|
551 | * @return VBox status code.
|
---|
552 | * @param hnode Node which attribute will be set.
|
---|
553 | * @param pszName Name of the attribute (UTF-8), NULL for the node value.
|
---|
554 | * @param bstrValue The string (COM BSTR).
|
---|
555 | * @param cbValue Size of buffer pszValue points to.
|
---|
556 | */
|
---|
557 | CFGLDRR3DECL(int) CFGLDRSetBSTR(CFGNODE hnode, const char *pszName, const BSTR bstrValue);
|
---|
558 | #endif // CFGLDR_HAVE_COM
|
---|
559 |
|
---|
560 | /**
|
---|
561 | * Queries a boolean attribute.
|
---|
562 | *
|
---|
563 | * @return VBox status code.
|
---|
564 | * @param hnode Node which attribute will be queried.
|
---|
565 | * @param pszName Name of the attribute (UTF-8), NULL for the node value.
|
---|
566 | * @param pfValue Where to store the value.
|
---|
567 | */
|
---|
568 | CFGLDRR3DECL(int) CFGLDRQueryBool(CFGNODE hnode, const char *pszName, bool *pfValue);
|
---|
569 |
|
---|
570 | /**
|
---|
571 | * Sets a boolean attribute.
|
---|
572 | *
|
---|
573 | * @return VBox status code.
|
---|
574 | * @param hnode Node which attribute will be queried.
|
---|
575 | * @param pszName Name of the attribute (UTF-8), NULL for the node value.
|
---|
576 | * @param fValue The boolean value.
|
---|
577 | */
|
---|
578 | CFGLDRR3DECL(int) CFGLDRSetBool(CFGNODE hnode, const char *pszName, bool fValue);
|
---|
579 |
|
---|
580 | /**
|
---|
581 | * Query 64-bit unix time (in milliseconds since 1970-01-01 UTC).
|
---|
582 | * The specified node or attribute must be a string in xsd:dateTime format.
|
---|
583 | *
|
---|
584 | * Currently, only the UTC ('Z') time zone is supported and must always present.
|
---|
585 | * If there is a different timezone, or no timezone at all, VERR_PARSE_ERROR
|
---|
586 | * is returned (use XML Schema constarints to limit the value space and prevent
|
---|
587 | * this error).
|
---|
588 | *
|
---|
589 | * Also note that the minimum 64-bit unix date year is
|
---|
590 | * about -292269053 and the maximum year is about ~292272993.
|
---|
591 | * It's a good idea to limit the max and min date values in the XML Schema
|
---|
592 | * as well, to something like -200000000 to 200000000.
|
---|
593 | *
|
---|
594 | * @return VBox status code.
|
---|
595 | * @param hnode Node which attribute will be queried.
|
---|
596 | * @param pszName Name of the attribute (UTF-8), NULL for the node value.
|
---|
597 | * @param pu64Value Pointer to 64 bit variable where to store the time value.
|
---|
598 | */
|
---|
599 | CFGLDRR3DECL(int) CFGLDRQueryDateTime(CFGNODE hnode, const char *pszName, int64_t *pi64Value);
|
---|
600 |
|
---|
601 | /**
|
---|
602 | * Set 64-bit unix time (in milliseconds since 1970-01-01 UTC).
|
---|
603 | * Time is written to the specified node or attribute in the xsd:format.
|
---|
604 | *
|
---|
605 | * @return VBox status code.
|
---|
606 | * @param hnode Node which attribute will be set.
|
---|
607 | * @param pszName Name of the attribute (UTF-8), NULL for the node value.
|
---|
608 | * @param u64Value The time value.
|
---|
609 | */
|
---|
610 | CFGLDRR3DECL(int) CFGLDRSetDateTime(CFGNODE hnode, const char *pszName, int64_t i64Value);
|
---|
611 |
|
---|
612 | /**
|
---|
613 | * Delete an attribute.
|
---|
614 | *
|
---|
615 | * @return VBox status code.
|
---|
616 | * @param hnode Node which attribute will be deleted.
|
---|
617 | * @param pszName Name of the attribute (UTF-8), NULL for the node value.
|
---|
618 | */
|
---|
619 | CFGLDRR3DECL(int) CFGLDRDeleteAttribute(CFGNODE hnode, const char *pszName);
|
---|
620 |
|
---|
621 | // hack to not have to define BSTR
|
---|
622 | #ifdef BSTR_REDEFINED
|
---|
623 | #undef BSTR
|
---|
624 | #endif
|
---|
625 |
|
---|
626 | #endif /* IN_RING3 */
|
---|
627 |
|
---|
628 | __END_DECLS
|
---|
629 |
|
---|
630 | /** @} */
|
---|
631 |
|
---|
632 | #endif /* __VBox_cfgldr_h__ */
|
---|