VirtualBox

source: vbox/trunk/src/VBox/Frontends/VBoxAutostart/VBoxAutostart.h@ 43342

Last change on this file since 43342 was 42732, checked in by vboxsync, 12 years ago

VBoxAutostart: Rewritten config parser for more flexibility in the future, changes config format

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.7 KB
Line 
1/* $Id: VBoxAutostart.h 42732 2012-08-09 22:32:48Z vboxsync $ */
2/** @file
3 * VBoxAutostart - VirtualBox Autostart service.
4 */
5
6/*
7 * Copyright (C) 2012 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
18#ifndef __VBoxAutostart_h__
19#define __VBoxAutostart_h__
20
21/*******************************************************************************
22* Header Files *
23*******************************************************************************/
24#include <VBox/cdefs.h>
25#include <VBox/types.h>
26
27#include <VBox/com/com.h>
28#include <VBox/com/VirtualBox.h>
29
30/*******************************************************************************
31* Constants And Macros, Structures and Typedefs *
32*******************************************************************************/
33
34/**
35 * Config AST node types.
36 */
37typedef enum CFGASTNODETYPE
38{
39 /** Invalid. */
40 CFGASTNODETYPE_INVALID = 0,
41 /** Key/Value pair. */
42 CFGASTNODETYPE_KEYVALUE,
43 /** Compound type. */
44 CFGASTNODETYPE_COMPOUND,
45 /** List type. */
46 CFGASTNODETYPE_LIST,
47 /** 32bit hack. */
48 CFGASTNODETYPE_32BIT_HACK = 0x7fffffff
49} CFGASTNODETYPE;
50/** Pointer to a config AST node type. */
51typedef CFGASTNODETYPE *PCFGASTNODETYPE;
52/** Pointer to a const config AST node type. */
53typedef const CFGASTNODETYPE *PCCFGASTNODETYPE;
54
55/**
56 * Config AST.
57 */
58typedef struct CFGAST
59{
60 /** AST node type. */
61 CFGASTNODETYPE enmType;
62 /** Key or scope id. */
63 char *pszKey;
64 /** Type dependent data. */
65 union
66 {
67 /** Key value pair. */
68 struct
69 {
70 /** Number of characters in the value - excluding terminator. */
71 size_t cchValue;
72 /** Value string - variable in size. */
73 char aszValue[1];
74 } KeyValue;
75 /** Compound type. */
76 struct
77 {
78 /** Number of AST node entries in the array. */
79 unsigned cAstNodes;
80 /** AST node array - variable in size. */
81 struct CFGAST *apAstNodes[1];
82 } Compound;
83 /** List type. */
84 struct
85 {
86 /** Number of entries in the list. */
87 unsigned cListEntries;
88 /** Array of list entries - variable in size. */
89 char *apszEntries[1];
90 } List;
91 } u;
92} CFGAST, *PCFGAST;
93
94/** Flag whether we are in verbose logging mode. */
95extern bool g_fVerbose;
96/** Handle to the VirtualBox interface. */
97extern ComPtr<IVirtualBox> g_pVirtualBox;
98/** Handle to the session interface. */
99extern ComPtr<ISession> g_pSession;
100
101/**
102 * Log information in verbose mode.
103 */
104#define serviceLogVerbose(a) if (g_fVerbose) { serviceLog a; }
105
106/**
107 * Log messages to the release log.
108 *
109 * @returns nothing.
110 * @param pszFormat Format string.
111 */
112DECLHIDDEN(void) serviceLog(const char *pszFormat, ...);
113
114/**
115 * Parse the given configuration file and return the interesting config parameters.
116 *
117 * @returns VBox status code.
118 * @param pszFilename The config file to parse.
119 * @param ppCfgAst Where to store the pointer to the root AST node on success.
120 */
121DECLHIDDEN(int) autostartParseConfig(const char *pszFilename, PCFGAST *ppCfgAst);
122
123/**
124 * Destroys the config AST and frees all resources.
125 *
126 * @returns nothing.
127 * @param pCfgAst The config AST.
128 */
129DECLHIDDEN(void) autostartConfigAstDestroy(PCFGAST pCfgAst);
130
131/**
132 * Return the config AST node with the given name or NULL if it doesn't exist.
133 *
134 * @returns Matching config AST node for the given name or NULL if not found.
135 * @param pCfgAst The config ASt to search.
136 * @param pszName The name to search for.
137 */
138DECLHIDDEN(PCFGAST) autostartConfigAstGetByName(PCFGAST pCfgAst, const char *pszName);
139
140/**
141 * Main routine for the autostart daemon.
142 *
143 * @returns exit status code.
144 * @param pCfgAst Config AST for the startup part of the autostart daemon.
145 */
146DECLHIDDEN(RTEXITCODE) autostartStartMain(PCFGAST pCfgAst);
147
148/**
149 * Main routine for the autostart daemon when stopping virtual machines
150 * during system shutdown.
151 *
152 * @returns exit status code.
153 * @param pCfgAst Config AST for the shutdown part of the autostart daemon.
154 */
155DECLHIDDEN(RTEXITCODE) autostartStopMain(PCFGAST pCfgAst);
156
157#endif /* __VBoxAutostart_h__ */
158
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette