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