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