VirtualBox

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

Last change on this file since 43629 was 43378, checked in by vboxsync, 12 years ago

Autostart: Implement stop feature for Linux hosts

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.3 KB
Line 
1/* $Id: VBoxAutostart.h 43378 2012-09-20 20:16:58Z 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 * Print out progress on the console.
116 *
117 * This runs the main event queue every now and then to prevent piling up
118 * unhandled things (which doesn't cause real problems, just makes things
119 * react a little slower than in the ideal case).
120 */
121DECLHIDDEN(HRESULT) showProgress(ComPtr<IProgress> progress);
122
123/**
124 * Converts the machine state to a human readable string.
125 *
126 * @returns Pointer to the human readable state.
127 * @param enmMachineState Machine state to convert.
128 * @param fShort Flag whether to return a short form.
129 */
130DECLHIDDEN(const char *) machineStateToName(MachineState_T enmMachineState, bool fShort);
131
132/**
133 * Parse the given configuration file and return the interesting config parameters.
134 *
135 * @returns VBox status code.
136 * @param pszFilename The config file to parse.
137 * @param ppCfgAst Where to store the pointer to the root AST node on success.
138 */
139DECLHIDDEN(int) autostartParseConfig(const char *pszFilename, PCFGAST *ppCfgAst);
140
141/**
142 * Destroys the config AST and frees all resources.
143 *
144 * @returns nothing.
145 * @param pCfgAst The config AST.
146 */
147DECLHIDDEN(void) autostartConfigAstDestroy(PCFGAST pCfgAst);
148
149/**
150 * Return the config AST node with the given name or NULL if it doesn't exist.
151 *
152 * @returns Matching config AST node for the given name or NULL if not found.
153 * @param pCfgAst The config ASt to search.
154 * @param pszName The name to search for.
155 */
156DECLHIDDEN(PCFGAST) autostartConfigAstGetByName(PCFGAST pCfgAst, const char *pszName);
157
158/**
159 * Main routine for the autostart daemon.
160 *
161 * @returns exit status code.
162 * @param pCfgAst Config AST for the startup part of the autostart daemon.
163 */
164DECLHIDDEN(RTEXITCODE) autostartStartMain(PCFGAST pCfgAst);
165
166/**
167 * Main routine for the autostart daemon when stopping virtual machines
168 * during system shutdown.
169 *
170 * @returns exit status code.
171 * @param pCfgAst Config AST for the shutdown part of the autostart daemon.
172 */
173DECLHIDDEN(RTEXITCODE) autostartStopMain(PCFGAST pCfgAst);
174
175#endif /* __VBoxAutostart_h__ */
176
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