VirtualBox

source: vbox/trunk/src/VBox/Additions/x11/VBoxClient/VBoxClient.h@ 86969

Last change on this file since 86969 was 86871, checked in by vboxsync, 4 years ago

Additions/VBoxClient: Big revamp of the internal service handling and termination fixes. A service now runs as part of a worker thread, while the main thread is used for initialization / shutdown and signal handling.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.9 KB
Line 
1/* $Id: VBoxClient.h 86871 2020-11-12 10:15:18Z vboxsync $ */
2/** @file
3 *
4 * VirtualBox additions user session daemon.
5 */
6
7/*
8 * Copyright (C) 2006-2020 Oracle Corporation
9 *
10 * This file is part of VirtualBox Open Source Edition (OSE), as
11 * available from http://www.virtualbox.org. This file is free software;
12 * you can redistribute it and/or modify it under the terms of the GNU
13 * General Public License (GPL) as published by the Free Software
14 * Foundation, in version 2 as it comes in the "COPYING" file of the
15 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
16 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
17 */
18
19#ifndef GA_INCLUDED_SRC_x11_VBoxClient_VBoxClient_h
20#define GA_INCLUDED_SRC_x11_VBoxClient_VBoxClient_h
21#ifndef RT_WITHOUT_PRAGMA_ONCE
22# pragma once
23#endif
24
25#include <VBox/log.h>
26#include <iprt/cpp/utils.h>
27#include <iprt/string.h>
28
29void VBClLogInfo(const char *pszFormat, ...);
30void VBClLogError(const char *pszFormat, ...);
31void VBClLogFatalError(const char *pszFormat, ...);
32void VBClLogVerbose(unsigned iLevel, const char *pszFormat, ...);
33
34int VBClLogCreate(const char *pszLogFile);
35void VBClLogDestroy(void);
36
37/** Call clean-up for the current service and exit. */
38extern void VBClShutdown(bool fExit = true);
39
40/**
41 * A service descriptor.
42 */
43typedef struct
44{
45 /** The short service name. 16 chars maximum (RTTHREAD_NAME_LEN). */
46 const char *pszName;
47 /** The longer service name. */
48 const char *pszDesc;
49 /** Get the services default path to pidfile, relative to $HOME */
50 /** @todo Should this also have a component relative to the X server number?
51 */
52 const char *pszPidFilePath;
53 /** The usage options stuff for the --help screen. */
54 const char *pszUsage;
55 /** The option descriptions for the --help screen. */
56 const char *pszOptions;
57
58 /**
59 * Tries to parse the given command line option.
60 *
61 * @returns 0 if we parsed, -1 if it didn't and anything else means exit.
62 * @param ppszShort If not NULL it points to the short option iterator. a short argument.
63 * If NULL examine argv[*pi].
64 * @param argc The argument count.
65 * @param argv The argument vector.
66 * @param pi The argument vector index. Update if any value(s) are eaten.
67 */
68 DECLCALLBACKMEMBER(int, pfnOption,(const char **ppszShort, int argc, char **argv, int *pi));
69
70 /**
71 * Called before parsing arguments.
72 * @returns VBox status code, or
73 * VERR_NOT_AVAILABLE if service is supported on this platform in general but not available at the moment.
74 * VERR_NOT_SUPPORTED if service is not supported on this platform. */
75 DECLCALLBACKMEMBER(int, pfnInit,(void));
76
77 /** Called from the worker thread.
78 *
79 * @returns VBox status code.
80 * @retval VINF_SUCCESS if exitting because *pfShutdown was set.
81 * @param pfShutdown Pointer to a per service termination flag to check
82 * before and after blocking.
83 */
84 DECLCALLBACKMEMBER(int, pfnWorker,(bool volatile *pfShutdown));
85
86 /**
87 * Asks the service to stop.
88 *
89 * @remarks Will be called from the signal handler.
90 */
91 DECLCALLBACKMEMBER(void, pfnStop,(void));
92
93 /**
94 * Does termination cleanups.
95 *
96 * @remarks This will be called even if pfnInit hasn't been called or pfnStop failed!
97 */
98 DECLCALLBACKMEMBER(int, pfnTerm,(void));
99} VBCLSERVICE;
100/** Pointer to a VBCLSERVICE. */
101typedef VBCLSERVICE *PVBCLSERVICE;
102/** Pointer to a const VBCLSERVICE. */
103typedef VBCLSERVICE const *PCVBCLSERVICE;
104
105RT_C_DECLS_BEGIN
106extern VBCLSERVICE g_SvcClipboard;
107extern VBCLSERVICE g_SvcDisplayDRM;
108extern VBCLSERVICE g_SvcDisplaySVGA;
109extern VBCLSERVICE g_SvcDragAndDrop;
110extern VBCLSERVICE g_SvcHostVersion;
111extern VBCLSERVICE g_SvcSeamless;
112
113extern bool g_fDaemonized;
114RT_C_DECLS_END
115
116#endif /* !GA_INCLUDED_SRC_x11_VBoxClient_VBoxClient_h */
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