1 | /* $Id: UsbTestServiceCfg.h 60287 2016-04-01 12:49:19Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * UsbTestServ - Remote USB test configuration and execution server, Config file API.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2016 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | *
|
---|
17 | * The contents of this file may alternatively be used under the terms
|
---|
18 | * of the Common Development and Distribution License Version 1.0
|
---|
19 | * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
20 | * VirtualBox OSE distribution, in which case the provisions of the
|
---|
21 | * CDDL are applicable instead of those of the GPL.
|
---|
22 | *
|
---|
23 | * You may elect to license modified versions of this file under the
|
---|
24 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
25 | */
|
---|
26 |
|
---|
27 | #ifndef ___UsbTestServiceCfg_h___
|
---|
28 | #define ___UsbTestServiceCfg_h___
|
---|
29 |
|
---|
30 | #include <iprt/err.h>
|
---|
31 | #include <iprt/types.h>
|
---|
32 |
|
---|
33 | RT_C_DECLS_BEGIN
|
---|
34 |
|
---|
35 | /*******************************************************************************
|
---|
36 | * Constants And Macros, Structures and Typedefs *
|
---|
37 | *******************************************************************************/
|
---|
38 |
|
---|
39 | /**
|
---|
40 | * Config AST node types.
|
---|
41 | */
|
---|
42 | typedef enum CFGASTNODETYPE
|
---|
43 | {
|
---|
44 | /** Invalid. */
|
---|
45 | CFGASTNODETYPE_INVALID = 0,
|
---|
46 | /** Key/Value pair. */
|
---|
47 | CFGASTNODETYPE_KEYVALUE,
|
---|
48 | /** Compound type. */
|
---|
49 | CFGASTNODETYPE_COMPOUND,
|
---|
50 | /** List type. */
|
---|
51 | CFGASTNODETYPE_LIST,
|
---|
52 | /** 32bit hack. */
|
---|
53 | CFGASTNODETYPE_32BIT_HACK = 0x7fffffff
|
---|
54 | } CFGASTNODETYPE;
|
---|
55 | /** Pointer to a config AST node type. */
|
---|
56 | typedef CFGASTNODETYPE *PCFGASTNODETYPE;
|
---|
57 | /** Pointer to a const config AST node type. */
|
---|
58 | typedef const CFGASTNODETYPE *PCCFGASTNODETYPE;
|
---|
59 |
|
---|
60 | /**
|
---|
61 | * Config AST.
|
---|
62 | */
|
---|
63 | typedef struct CFGAST
|
---|
64 | {
|
---|
65 | /** AST node type. */
|
---|
66 | CFGASTNODETYPE enmType;
|
---|
67 | /** Key or scope id. */
|
---|
68 | char *pszKey;
|
---|
69 | /** Type dependent data. */
|
---|
70 | union
|
---|
71 | {
|
---|
72 | /** Key value pair. */
|
---|
73 | struct
|
---|
74 | {
|
---|
75 | /** Number of characters in the value - excluding terminator. */
|
---|
76 | size_t cchValue;
|
---|
77 | /** Value string - variable in size. */
|
---|
78 | char aszValue[1];
|
---|
79 | } KeyValue;
|
---|
80 | /** Compound type. */
|
---|
81 | struct
|
---|
82 | {
|
---|
83 | /** Number of AST node entries in the array. */
|
---|
84 | unsigned cAstNodes;
|
---|
85 | /** AST node array - variable in size. */
|
---|
86 | struct CFGAST *apAstNodes[1];
|
---|
87 | } Compound;
|
---|
88 | /** List type. */
|
---|
89 | struct
|
---|
90 | {
|
---|
91 | /** Number of entries in the list. */
|
---|
92 | unsigned cListEntries;
|
---|
93 | /** Array of list entries - variable in size. */
|
---|
94 | char *apszEntries[1];
|
---|
95 | } List;
|
---|
96 | } u;
|
---|
97 | } CFGAST, *PCFGAST;
|
---|
98 |
|
---|
99 | /**
|
---|
100 | * Parse the given configuration file and return the interesting config parameters.
|
---|
101 | *
|
---|
102 | * @returns VBox status code.
|
---|
103 | * @param pszFilename The config file to parse.
|
---|
104 | * @param ppCfgAst Where to store the pointer to the root AST node on success.
|
---|
105 | * @param ppErrInfo Where to store the pointer to the detailed error message on failure -
|
---|
106 | * optional.
|
---|
107 | */
|
---|
108 | DECLHIDDEN(int) utsParseConfig(const char *pszFilename, PCFGAST *ppCfgAst, PRTERRINFO *ppErrInfo);
|
---|
109 |
|
---|
110 | /**
|
---|
111 | * Destroys the config AST and frees all resources.
|
---|
112 | *
|
---|
113 | * @returns nothing.
|
---|
114 | * @param pCfgAst The config AST.
|
---|
115 | */
|
---|
116 | DECLHIDDEN(void) utsConfigAstDestroy(PCFGAST pCfgAst);
|
---|
117 |
|
---|
118 | /**
|
---|
119 | * Return the config AST node with the given name or NULL if it doesn't exist.
|
---|
120 | *
|
---|
121 | * @returns Matching config AST node for the given name or NULL if not found.
|
---|
122 | * @param pCfgAst The config ASt to search.
|
---|
123 | * @param pszName The name to search for.
|
---|
124 | */
|
---|
125 | DECLHIDDEN(PCFGAST) utsConfigAstGetByName(PCFGAST pCfgAst, const char *pszName);
|
---|
126 |
|
---|
127 | RT_C_DECLS_END
|
---|
128 |
|
---|
129 | #endif
|
---|
130 |
|
---|