1 | /** @file
|
---|
2 | * CFGLDR - Configuration Loader
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2006 InnoTek Systemberatung 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 16 bit unsigned 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 pu16Value Pointer to 16 bit variable where to store the value.
|
---|
430 | */
|
---|
431 | CFGLDRR3DECL(int) CFGLDRQueryUInt16(CFGNODE hnode, const char *pszName, uint16_t *pu16Value);
|
---|
432 |
|
---|
433 | /**
|
---|
434 | * Set 16 bit unsigned 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 u16Value The value.
|
---|
440 | */
|
---|
441 | CFGLDRR3DECL(int) CFGLDRSetUInt16(CFGNODE hnode, const char *pszName, uint16_t u16Value);
|
---|
442 |
|
---|
443 | /**
|
---|
444 | * Query binary data attribute. If the size of the buffer (cbValue)
|
---|
445 | * is smaller than the binary data size, the VERR_BUFFER_OVERFLOW status
|
---|
446 | * code is returned and the actual data size is stored into the variable
|
---|
447 | * pointed to by pcbValue; pvValue is ignored in this case.
|
---|
448 | *
|
---|
449 | * @return VBox status code.
|
---|
450 | * @param hnode Node which attribute will be queried.
|
---|
451 | * @param pszName Name of the attribute (UTF-8), NULL for the node value.
|
---|
452 | * @param pvValue Where to store the binary data.
|
---|
453 | * @param cbValue Size of buffer pvValue points to.
|
---|
454 | * @param pcbValue Where to store the number of bytes actually retrieved.
|
---|
455 | */
|
---|
456 | CFGLDRR3DECL(int) CFGLDRQueryBin(CFGNODE hnode, const char *pszName, void *pvValue, unsigned cbValue, unsigned *pcbValue);
|
---|
457 |
|
---|
458 | /**
|
---|
459 | * Set binary data attribute.
|
---|
460 | *
|
---|
461 | * @return VBox status code.
|
---|
462 | * @param hnode Node which attribute will be set.
|
---|
463 | * @param pszName Name of the attribute (UTF-8), NULL for the node value.
|
---|
464 | * @param pvValue The binary data to store.
|
---|
465 | * @param cbValue Size of buffer pvValue points to.
|
---|
466 | */
|
---|
467 | CFGLDRR3DECL(int) CFGLDRSetBin(CFGNODE hnode, const char *pszName, void *pvValue, unsigned cbValue);
|
---|
468 |
|
---|
469 | /**
|
---|
470 | * Queries a string attribute. If the size of the buffer (cbValue)
|
---|
471 | * is smaller than the length of the string, the VERR_BUFFER_OVERFLOW status
|
---|
472 | * code is returned and the actual string length is stored into the variable
|
---|
473 | * pointed to by pcbValue; pszValue is ignored in this case.
|
---|
474 | *
|
---|
475 | * @return VBox status code.
|
---|
476 | * @param hnode Node which attribute will be queried.
|
---|
477 | * @param pszName Name of the attribute (UTF-8), NULL for the node value.
|
---|
478 | * @param pszValue Where to store the string (UTF-8).
|
---|
479 | * @param cbValue Size of buffer pszValue points to, including the terminating zero.
|
---|
480 | * @param pcbValue Where to store the number of bytes actually retrieved, including the terminating zero.
|
---|
481 | */
|
---|
482 | CFGLDRR3DECL(int) CFGLDRQueryString(CFGNODE hnode, const char *pszName, char *pszValue, unsigned cbValue, unsigned *pcbValue);
|
---|
483 |
|
---|
484 | #ifdef CFGLDR_HAVE_COM
|
---|
485 | /**
|
---|
486 | * Queries a string attribute and returns it as an allocated OLE BSTR.
|
---|
487 | *
|
---|
488 | * @return VBox status code.
|
---|
489 | * @param hnode Node which attribute will be queried.
|
---|
490 | * @param pszName Name of the attribute (UTF-8), NULL for the node value.
|
---|
491 | * @param ppuszValue Where to store the pointer to the allocated BSTR.
|
---|
492 | */
|
---|
493 | CFGLDRR3DECL(int) CFGLDRQueryBSTR(CFGNODE hnode, const char *pszName, BSTR *ppuszValue);
|
---|
494 | #endif // CFGLDR_HAVE_COM
|
---|
495 |
|
---|
496 | /**
|
---|
497 | * Queries a UUID attribute and returns it into the supplied buffer.
|
---|
498 | *
|
---|
499 | * @return VBox status code.
|
---|
500 | * @param hnode Node which attribute will be queried.
|
---|
501 | * @param pszName Name of the attribute (UTF-8), NULL for the node value.
|
---|
502 | * @param pUUID Where to store the UUID.
|
---|
503 | */
|
---|
504 | CFGLDRR3DECL(int) CFGLDRQueryUUID(CFGNODE hnode, const char *pszName, PRTUUID pUUID);
|
---|
505 |
|
---|
506 | /**
|
---|
507 | * Set UUID attribute. It will be put inside curly brackets.
|
---|
508 | *
|
---|
509 | * @return VBox status code.
|
---|
510 | * @param hnode Node which attribute will be set.
|
---|
511 | * @param pszName Name of the attribute (UTF-8), NULL for the node value.
|
---|
512 | * @param pUuid The uuid.
|
---|
513 | */
|
---|
514 | CFGLDRR3DECL(int) CFGLDRSetUUID(CFGNODE hnode, const char *pszName, PCRTUUID pUuid);
|
---|
515 |
|
---|
516 | /**
|
---|
517 | * Set string attribute.
|
---|
518 | *
|
---|
519 | * @return VBox status code.
|
---|
520 | * @param hnode Node which attribute will be set.
|
---|
521 | * @param pszName Name of the attribute (UTF-8), NULL for the node value.
|
---|
522 | * @param pszValue The string (UTF-8).
|
---|
523 | * @param cbValue Size of buffer pszValue points to.
|
---|
524 | */
|
---|
525 | CFGLDRR3DECL(int) CFGLDRSetString(CFGNODE hnode, const char *pszName, const char *pszValue);
|
---|
526 |
|
---|
527 | #ifdef CFGLDR_HAVE_COM
|
---|
528 | /**
|
---|
529 | * Set BSTR attribute.
|
---|
530 | *
|
---|
531 | * @return VBox status code.
|
---|
532 | * @param hnode Node which attribute will be set.
|
---|
533 | * @param pszName Name of the attribute (UTF-8), NULL for the node value.
|
---|
534 | * @param bstrValue The string (COM BSTR).
|
---|
535 | * @param cbValue Size of buffer pszValue points to.
|
---|
536 | */
|
---|
537 | CFGLDRR3DECL(int) CFGLDRSetBSTR(CFGNODE hnode, const char *pszName, const BSTR bstrValue);
|
---|
538 | #endif // CFGLDR_HAVE_COM
|
---|
539 |
|
---|
540 | /**
|
---|
541 | * Queries a boolean attribute.
|
---|
542 | *
|
---|
543 | * @return VBox status code.
|
---|
544 | * @param hnode Node which attribute will be queried.
|
---|
545 | * @param pszName Name of the attribute (UTF-8), NULL for the node value.
|
---|
546 | * @param pfValue Where to store the value.
|
---|
547 | */
|
---|
548 | CFGLDRR3DECL(int) CFGLDRQueryBool(CFGNODE hnode, const char *pszName, bool *pfValue);
|
---|
549 |
|
---|
550 | /**
|
---|
551 | * Sets a boolean attribute.
|
---|
552 | *
|
---|
553 | * @return VBox status code.
|
---|
554 | * @param hnode Node which attribute will be queried.
|
---|
555 | * @param pszName Name of the attribute (UTF-8), NULL for the node value.
|
---|
556 | * @param fValue The boolean value.
|
---|
557 | */
|
---|
558 | CFGLDRR3DECL(int) CFGLDRSetBool(CFGNODE hnode, const char *pszName, bool fValue);
|
---|
559 |
|
---|
560 | /**
|
---|
561 | * Query 64-bit unix time (in milliseconds since 1970-01-01 UTC).
|
---|
562 | * The specified node or attribute must be a string in xsd:dateTime format.
|
---|
563 | *
|
---|
564 | * Currently, only the UTC ('Z') time zone is supported and must always present.
|
---|
565 | * If there is a different timezone, or no timezone at all, VERR_PARSE_ERROR
|
---|
566 | * is returned (use XML Schema constarints to limit the value space and prevent
|
---|
567 | * this error).
|
---|
568 | *
|
---|
569 | * Also note that the minimum 64-bit unix date year is
|
---|
570 | * about -292269053 and the maximum year is about ~292272993.
|
---|
571 | * It's a good idea to limit the max and min date values in the XML Schema
|
---|
572 | * as well, to something like -200000000 to 200000000.
|
---|
573 | *
|
---|
574 | * @return VBox status code.
|
---|
575 | * @param hnode Node which attribute will be queried.
|
---|
576 | * @param pszName Name of the attribute (UTF-8), NULL for the node value.
|
---|
577 | * @param pu64Value Pointer to 64 bit variable where to store the time value.
|
---|
578 | */
|
---|
579 | CFGLDRR3DECL(int) CFGLDRQueryDateTime(CFGNODE hnode, const char *pszName, int64_t *pi64Value);
|
---|
580 |
|
---|
581 | /**
|
---|
582 | * Set 64-bit unix time (in milliseconds since 1970-01-01 UTC).
|
---|
583 | * Time is written to the specified node or attribute in the xsd:format.
|
---|
584 | *
|
---|
585 | * @return VBox status code.
|
---|
586 | * @param hnode Node which attribute will be set.
|
---|
587 | * @param pszName Name of the attribute (UTF-8), NULL for the node value.
|
---|
588 | * @param u64Value The time value.
|
---|
589 | */
|
---|
590 | CFGLDRR3DECL(int) CFGLDRSetDateTime(CFGNODE hnode, const char *pszName, int64_t i64Value);
|
---|
591 |
|
---|
592 | /**
|
---|
593 | * Delete an attribute.
|
---|
594 | *
|
---|
595 | * @return VBox status code.
|
---|
596 | * @param hnode Node which attribute will be deleted.
|
---|
597 | * @param pszName Name of the attribute (UTF-8), NULL for the node value.
|
---|
598 | */
|
---|
599 | CFGLDRR3DECL(int) CFGLDRDeleteAttribute(CFGNODE hnode, const char *pszName);
|
---|
600 |
|
---|
601 | // hack to not have to define BSTR
|
---|
602 | #ifdef BSTR_REDEFINED
|
---|
603 | #undef BSTR
|
---|
604 | #endif
|
---|
605 |
|
---|
606 | #endif /* IN_RING3 */
|
---|
607 |
|
---|
608 | __END_DECLS
|
---|
609 |
|
---|
610 | /** @} */
|
---|
611 |
|
---|
612 | #endif /* __VBox_cfgldr_h__ */
|
---|