1 | /* $Id: VBoxServiceInternal.h 3725 2007-07-19 19:01:52Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBoxService - Guest Additions Services.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2007 innotek GmbH
|
---|
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 as published by the Free Software Foundation,
|
---|
13 | * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
|
---|
14 | * distribution. VirtualBox OSE is distributed in the hope that it will
|
---|
15 | * be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | *
|
---|
17 | * If you received this file as part of a commercial VirtualBox
|
---|
18 | * distribution, then only the terms of your commercial VirtualBox
|
---|
19 | * license agreement apply instead of the previous paragraph.
|
---|
20 | */
|
---|
21 |
|
---|
22 | #ifndef ___VBoxServiceInternal_h
|
---|
23 | #define ___VBoxServiceInternal_h
|
---|
24 |
|
---|
25 | /**
|
---|
26 | * A service descriptor.
|
---|
27 | */
|
---|
28 | typedef struct
|
---|
29 | {
|
---|
30 | /** The short service name. */
|
---|
31 | const char *pszName;
|
---|
32 | /** The longer service name. */
|
---|
33 | const char *pszDescription;
|
---|
34 | /** The usage options stuff for the --help screen. */
|
---|
35 | const char *pszUsage;
|
---|
36 | /** The option descriptions for the --help screen. */
|
---|
37 | const char *pszOptions;
|
---|
38 |
|
---|
39 | /**
|
---|
40 | * Called before parsing arguments.
|
---|
41 | * @returns VBox status code.
|
---|
42 | */
|
---|
43 | DECLCALLBACKMEMBER(int, pfnPreInit)(void);
|
---|
44 |
|
---|
45 | /**
|
---|
46 | * Tries to parse the given command line option.
|
---|
47 | *
|
---|
48 | * @returns 0 if we parsed, -1 if it didn't and anything else means exit.
|
---|
49 | * @param ppszShort If not NULL it points to the short option iterator. a short argument.
|
---|
50 | * If NULL examine argv[*pi].
|
---|
51 | * @param argc The argument count.
|
---|
52 | * @param argv The argument vector.
|
---|
53 | * @param pi The argument vector index. Update if any value(s) are eaten.
|
---|
54 | */
|
---|
55 | DECLCALLBACKMEMBER(int, pfnOption)(const char **ppszShort, int argc, char **argv, int *pi);
|
---|
56 |
|
---|
57 | /**
|
---|
58 | * Called before parsing arguments.
|
---|
59 | * @returns VBox status code.
|
---|
60 | */
|
---|
61 | DECLCALLBACKMEMBER(int, pfnInit)(void);
|
---|
62 |
|
---|
63 | /** Called from the worker thread.
|
---|
64 | *
|
---|
65 | * @returns VBox status code.
|
---|
66 | * @retval VINF_SUCCESS if exitting because *pfTerminate was set.
|
---|
67 | * @param pfTerminate Pointer to a per service termination flag to check
|
---|
68 | * before and after blocking.
|
---|
69 | */
|
---|
70 | DECLCALLBACKMEMBER(int, pfnWorker)(bool volatile *pfTerminate);
|
---|
71 |
|
---|
72 | /**
|
---|
73 | * Stop an service.
|
---|
74 | */
|
---|
75 | DECLCALLBACKMEMBER(void, pfnStop)(void);
|
---|
76 |
|
---|
77 | /**
|
---|
78 | * Does termination cleanups.
|
---|
79 | */
|
---|
80 | DECLCALLBACKMEMBER(void, pfnTerm)(void);
|
---|
81 | } VBOXSERVICE;
|
---|
82 | /** Pointer to a VBOXSERVICE. */
|
---|
83 | typedef VBOXSERVICE *PVBOXSERVICE;
|
---|
84 | /** Pointer to a const VBOXSERVICE. */
|
---|
85 | typedef VBOXSERVICE const *PCVBOXSERVICE;
|
---|
86 |
|
---|
87 |
|
---|
88 | __BEGIN_DECLS
|
---|
89 |
|
---|
90 | extern char *g_pszProgName;
|
---|
91 | extern int g_cVerbosity;
|
---|
92 | extern uint32_t g_DefaultInterval;
|
---|
93 |
|
---|
94 | extern int VBoxServiceSyntax(const char *pszFormat, ...);
|
---|
95 | extern int VBoxServiceError(const char *pszFormat, ...);
|
---|
96 | extern void VBoxServiceVerbose(int iLevel, const char *pszFormat, ...);
|
---|
97 | extern int VBoxServiceArgUInt32(int argc, char **argv, const char *psz, int *pi, uint32_t *pu32, uint32_t u32Min, uint32_t u32Max);
|
---|
98 |
|
---|
99 | #ifdef __OS2__
|
---|
100 | extern int daemon(int, int);
|
---|
101 | #endif
|
---|
102 |
|
---|
103 | extern VBOXSERVICE g_TimeSync;
|
---|
104 | extern VBOXSERVICE g_Clipboard;
|
---|
105 | extern VBOXSERVICE g_Control;
|
---|
106 |
|
---|
107 | __END_DECLS
|
---|
108 |
|
---|
109 | #endif
|
---|
110 |
|
---|