VBoxAutostart.h revision b6013430932520fe58eba109db1dfce66a7cad88
/* $Id$ */
/** @file
* VBoxAutostart - VirtualBox Autostart service.
*/
/*
* Copyright (C) 2012 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
#ifndef __VBoxAutostart_h__
#define __VBoxAutostart_h__
/*******************************************************************************
* Header Files *
*******************************************************************************/
/*******************************************************************************
* Constants And Macros, Structures and Typedefs *
*******************************************************************************/
/**
* Config AST node types.
*/
typedef enum CFGASTNODETYPE
{
/** Invalid. */
/** Compound type. */
/** List type. */
/** 32bit hack. */
CFGASTNODETYPE_32BIT_HACK = 0x7fffffff
/** Pointer to a config AST node type. */
typedef CFGASTNODETYPE *PCFGASTNODETYPE;
/** Pointer to a const config AST node type. */
typedef const CFGASTNODETYPE *PCCFGASTNODETYPE;
/**
* Config AST.
*/
typedef struct CFGAST
{
/** AST node type. */
/** Key or scope id. */
char *pszKey;
/** Type dependent data. */
union
{
/** Key value pair. */
struct
{
/** Number of characters in the value - excluding terminator. */
/** Value string - variable in size. */
char aszValue[1];
} KeyValue;
/** Compound type. */
struct
{
/** Number of AST node entries in the array. */
unsigned cAstNodes;
/** AST node array - variable in size. */
} Compound;
/** List type. */
struct
{
/** Number of entries in the list. */
unsigned cListEntries;
/** Array of list entries - variable in size. */
char *apszEntries[1];
} List;
} u;
/** Flag whether we are in verbose logging mode. */
extern bool g_fVerbose;
/** Handle to the VirtualBox interface. */
/** Handle to the session interface. */
/** handle to the VirtualBox interface. */
/**
* System log type.
*/
typedef enum AUTOSTARTLOGTYPE
{
/** Invalid log type. */
/** Log info message. */
/** Log error message. */
/** Log warning message. */
/** Log verbose message, only if verbose mode is activated. */
/** Famous 32bit hack. */
AUTOSTARTLOGTYPE_32BIT_HACK = 0x7fffffff
/**
* Log messages to the system and release log.
*
* @returns nothing.
* @param pszMsg Message to log.
* @param enmLogType Log type to use.
*/
/**
* Print out progress on the console.
*
* This runs the main event queue every now and then to prevent piling up
* unhandled things (which doesn't cause real problems, just makes things
* react a little slower than in the ideal case).
*/
/**
* Converts the machine state to a human readable string.
*
* @returns Pointer to the human readable state.
* @param enmMachineState Machine state to convert.
* @param fShort Flag whether to return a short form.
*/
/**
* Parse the given configuration file and return the interesting config parameters.
*
* @returns VBox status code.
* @param pszFilename The config file to parse.
* @param ppCfgAst Where to store the pointer to the root AST node on success.
*/
/**
* Destroys the config AST and frees all resources.
*
* @returns nothing.
* @param pCfgAst The config AST.
*/
/**
* Return the config AST node with the given name or NULL if it doesn't exist.
*
* @returns Matching config AST node for the given name or NULL if not found.
* @param pCfgAst The config ASt to search.
* @param pszName The name to search for.
*/
/**
* Main routine for the autostart daemon.
*
* @returns exit status code.
* @param pCfgAst Config AST for the startup part of the autostart daemon.
*/
/**
* Main routine for the autostart daemon when stopping virtual machines
* during system shutdown.
*
* @returns exit status code.
* @param pCfgAst Config AST for the shutdown part of the autostart daemon.
*/
/**
* Logs a verbose message to the appropriate system log.
*
* @param pszFormat The log string. No trailing newline.
* @param ... Format arguments.
*/
/**
* Logs a verbose message to the appropriate system log.
*
* @param pszFormat The log string. No trailing newline.
* @param ... Format arguments.
*/
/**
* Logs a warning message to the appropriate system log.
*
* @param pszFormat The log string. No trailing newline.
* @param ... Format arguments.
*/
/**
* Logs a warning message to the appropriate system log.
*
* @param pszFormat The log string. No trailing newline.
* @param ... Format arguments.
*/
/**
* Logs a info message to the appropriate system log.
*
* @param pszFormat The log string. No trailing newline.
* @param ... Format arguments.
*/
/**
* Logs a info message to the appropriate system log.
*
* @param pszFormat The log string. No trailing newline.
* @param ... Format arguments.
*/
/**
* Logs the message to the appropriate system log.
*
* In debug builds this will also put it in the debug log.
*
* @param pszFormat The log string. No trailing newline.
* @param ... Format arguments.
*
* @todo This should later be replaced by the release logger and callback destination(s).
*/
/**
* Logs the error message to the appropriate system log.
*
* In debug builds this will also put it in the debug log.
*
* @param pszFormat The log string. No trailing newline.
* @param ... Format arguments.
*
* @todo This should later be replaced by the release logger and callback destination(s).
*/
/**
* Deals with RTGetOpt failure, bitching in the system log.
*
* @returns 1
* @param pszAction The action name.
* @param rc The RTGetOpt return value.
* @param argc The argument count.
* @param argv The argument vector.
* @param iArg The argument index.
* @param pValue The value returned by RTGetOpt.
*/
DECLHIDDEN(RTEXITCODE) autostartSvcLogGetOptError(const char *pszAction, int rc, int argc, char **argv, int iArg, PCRTGETOPTUNION pValue);
/**
* Bitch about too many arguments (after RTGetOpt stops) in the system log.
*
* @returns 1
* @param pszAction The action name.
* @param argc The argument count.
* @param argv The argument vector.
* @param iArg The argument index.
*/
DECLHIDDEN(RTEXITCODE) autostartSvcLogTooManyArgsError(const char *pszAction, int argc, char **argv, int iArg);
/**
* Prints an error message to the screen.
*
* @param pszFormat The message format string.
* @param va Format arguments.
*/
/**
* Prints an error message to the screen.
*
* @param pszFormat The message format string.
* @param ... Format arguments.
*/
/**
* Deals with RTGetOpt failure.
*
* @returns 1
* @param pszAction The action name.
* @param rc The RTGetOpt return value.
* @param argc The argument count.
* @param argv The argument vector.
* @param iArg The argument index.
* @param pValue The value returned by RTGetOpt.
*/
DECLHIDDEN(RTEXITCODE) autostartSvcDisplayGetOptError(const char *pszAction, int rc, int argc, char **argv, int iArg, PCRTGETOPTUNION pValue);
/**
* Bitch about too many arguments (after RTGetOpt stops).
*
* @returns RTEXITCODE_FAILURE
* @param pszAction The action name.
* @param argc The argument count.
* @param argv The argument vector.
* @param iArg The argument index.
*/
DECLHIDDEN(RTEXITCODE) autostartSvcDisplayTooManyArgsError(const char *pszAction, int argc, char **argv, int iArg);
DECLHIDDEN(int) autostartSetup();
DECLHIDDEN(void) autostartShutdown();
#endif /* __VBoxAutostart_h__ */