1 | /* $Id: tstVBoxControl.cpp 32705 2010-09-23 07:06:34Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBoxControl - Guest Additions Command Line Management Interface, test case
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2007 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 |
|
---|
19 |
|
---|
20 | /*******************************************************************************
|
---|
21 | * Header Files *
|
---|
22 | *******************************************************************************/
|
---|
23 | #include <iprt/cpp/autores.h>
|
---|
24 | #include <iprt/initterm.h>
|
---|
25 | #include <iprt/mem.h>
|
---|
26 | #include <iprt/path.h>
|
---|
27 | #include <iprt/stream.h>
|
---|
28 | #include <iprt/string.h>
|
---|
29 | #include <VBox/log.h>
|
---|
30 | #include <VBox/version.h>
|
---|
31 | #include <VBox/VBoxGuestLib.h>
|
---|
32 | #ifdef VBOX_WITH_GUEST_PROPS
|
---|
33 | # include <VBox/HostServices/GuestPropertySvc.h>
|
---|
34 | #endif
|
---|
35 |
|
---|
36 | VBGLR3DECL(int) VbglR3Init(void)
|
---|
37 | {
|
---|
38 | RTPrintf("Initialising guest library...\n");
|
---|
39 | return VINF_SUCCESS;
|
---|
40 | }
|
---|
41 |
|
---|
42 | VBGLR3DECL(int) VbglR3GuestPropConnect(uint32_t *pu32ClientId)
|
---|
43 | {
|
---|
44 | AssertPtrReturn(pu32ClientId, VERR_INVALID_POINTER);
|
---|
45 | RTPrintf("Connect to guest property service...\n");
|
---|
46 | *pu32ClientId = 1;
|
---|
47 | return VINF_SUCCESS;
|
---|
48 | }
|
---|
49 |
|
---|
50 | VBGLR3DECL(int) VbglR3GuestPropDisconnect(uint32_t u32ClientId)
|
---|
51 | {
|
---|
52 | RTPrintf("Disconnect client %d from guest property service...\n", u32ClientId);
|
---|
53 | return VINF_SUCCESS;
|
---|
54 | }
|
---|
55 |
|
---|
56 | VBGLR3DECL(int) VbglR3GuestPropWrite(uint32_t u32ClientId,
|
---|
57 | const char *pszName,
|
---|
58 | const char *pszValue,
|
---|
59 | const char *pszFlags)
|
---|
60 | {
|
---|
61 | RTPrintf("Called SET_PROP, client %d, name %s, value %s, flags %s...\n",
|
---|
62 | u32ClientId, pszName, pszValue, pszFlags);
|
---|
63 | return VINF_SUCCESS;
|
---|
64 | }
|
---|
65 |
|
---|
66 | VBGLR3DECL(int) VbglR3GuestPropWriteValue(uint32_t u32ClientId,
|
---|
67 | const char *pszName,
|
---|
68 | const char *pszValue)
|
---|
69 | {
|
---|
70 | RTPrintf("Called SET_PROP_VALUE, client %d, name %s, value %s...\n",
|
---|
71 | u32ClientId, pszName, pszValue);
|
---|
72 | return VINF_SUCCESS;
|
---|
73 | }
|
---|
74 |
|
---|
75 | #ifdef VBOX_WITH_GUEST_PROPS
|
---|
76 | VBGLR3DECL(int) VbglR3GuestPropRead(uint32_t u32ClientId,
|
---|
77 | const char *pszName,
|
---|
78 | void *pvBuf,
|
---|
79 | uint32_t cbBuf,
|
---|
80 | char **ppszValue,
|
---|
81 | uint64_t *pu64Timestamp,
|
---|
82 | char **ppszFlags,
|
---|
83 | uint32_t *pcbBufActual)
|
---|
84 | {
|
---|
85 | RTPrintf("Called GET_PROP, client %d, name %s...\n",
|
---|
86 | u32ClientId, pszName);
|
---|
87 | static char szValue[] = "Value";
|
---|
88 | static char szFlags[] = "TRANSIENT";
|
---|
89 | if (VALID_PTR(ppszValue))
|
---|
90 | *ppszValue = szValue;
|
---|
91 | if (VALID_PTR(pu64Timestamp))
|
---|
92 | *pu64Timestamp = 12345;
|
---|
93 | if (VALID_PTR(ppszFlags))
|
---|
94 | *ppszFlags = szFlags;
|
---|
95 | if (VALID_PTR(pcbBufActual))
|
---|
96 | *pcbBufActual = 256;
|
---|
97 | return VINF_SUCCESS;
|
---|
98 | }
|
---|
99 |
|
---|
100 | struct VBGLR3GUESTPROPENUM
|
---|
101 | {
|
---|
102 | uint32_t u32;
|
---|
103 | };
|
---|
104 |
|
---|
105 | VBGLR3DECL(int) VbglR3GuestPropEnum(uint32_t u32ClientId,
|
---|
106 | char const * const *ppaszPatterns,
|
---|
107 | uint32_t cPatterns,
|
---|
108 | PVBGLR3GUESTPROPENUM *ppHandle,
|
---|
109 | char const **ppszName,
|
---|
110 | char const **ppszValue,
|
---|
111 | uint64_t *pu64Timestamp,
|
---|
112 | char const **ppszFlags)
|
---|
113 | {
|
---|
114 | RTPrintf("Called ENUM_PROPS, client %d...\n", u32ClientId);
|
---|
115 | AssertPtrReturn(ppHandle, VERR_INVALID_POINTER);
|
---|
116 | static VBGLR3GUESTPROPENUM Handle = { 0 };
|
---|
117 | static char szName[] = "Name";
|
---|
118 | static char szValue[] = "Value";
|
---|
119 | static char szFlags[] = "TRANSIENT";
|
---|
120 | *ppHandle = &Handle;
|
---|
121 | if (VALID_PTR(ppszName))
|
---|
122 | *ppszName = szName;
|
---|
123 | if (VALID_PTR(ppszValue))
|
---|
124 | *ppszValue = szValue;
|
---|
125 | if (VALID_PTR(pu64Timestamp))
|
---|
126 | *pu64Timestamp = 12345;
|
---|
127 | if (VALID_PTR(ppszFlags))
|
---|
128 | *ppszFlags = szFlags;
|
---|
129 | return VINF_SUCCESS;
|
---|
130 | }
|
---|
131 |
|
---|
132 | VBGLR3DECL(int) VbglR3GuestPropEnumNext(PVBGLR3GUESTPROPENUM pHandle,
|
---|
133 | char const **ppszName,
|
---|
134 | char const **ppszValue,
|
---|
135 | uint64_t *pu64Timestamp,
|
---|
136 | char const **ppszFlags)
|
---|
137 | {
|
---|
138 | RTPrintf("Called enumerate next...\n");
|
---|
139 | AssertReturn(VALID_PTR(ppszName) || VALID_PTR(ppszValue) || VALID_PTR(ppszFlags),
|
---|
140 | VERR_INVALID_POINTER);
|
---|
141 | if (VALID_PTR(ppszName))
|
---|
142 | *ppszName = NULL;
|
---|
143 | if (VALID_PTR(ppszValue))
|
---|
144 | *ppszValue = NULL;
|
---|
145 | if (VALID_PTR(pu64Timestamp))
|
---|
146 | *pu64Timestamp = 0;
|
---|
147 | if (VALID_PTR(ppszFlags))
|
---|
148 | *ppszFlags = NULL;
|
---|
149 | return VINF_SUCCESS;
|
---|
150 | }
|
---|
151 |
|
---|
152 | VBGLR3DECL(void) VbglR3GuestPropEnumFree(PVBGLR3GUESTPROPENUM pHandle)
|
---|
153 | {
|
---|
154 | RTPrintf("Called enumerate free...\n");
|
---|
155 | }
|
---|
156 |
|
---|
157 | VBGLR3DECL(int) VbglR3GuestPropWait(uint32_t u32ClientId,
|
---|
158 | const char *pszPatterns,
|
---|
159 | void *pvBuf,
|
---|
160 | uint32_t cbBuf,
|
---|
161 | uint64_t u64Timestamp,
|
---|
162 | uint32_t u32Timeout,
|
---|
163 | char ** ppszName,
|
---|
164 | char **ppszValue,
|
---|
165 | uint64_t *pu64Timestamp,
|
---|
166 | char **ppszFlags,
|
---|
167 | uint32_t *pcbBufActual)
|
---|
168 | {
|
---|
169 | if (u32Timeout == RT_INDEFINITE_WAIT)
|
---|
170 | RTPrintf("Called GET_NOTIFICATION, client %d, patterns %s, timestamp %llu,\n"
|
---|
171 | " timeout RT_INDEFINITE_WAIT...\n",
|
---|
172 | u32ClientId, pszPatterns, u64Timestamp);
|
---|
173 | else
|
---|
174 | RTPrintf("Called GET_NOTIFICATION, client %d, patterns %s, timestamp %llu,\n"
|
---|
175 | " timeout %u...\n",
|
---|
176 | u32ClientId, pszPatterns, u64Timestamp, u32Timeout);
|
---|
177 | static char szName[] = "Name";
|
---|
178 | static char szValue[] = "Value";
|
---|
179 | static char szFlags[] = "TRANSIENT";
|
---|
180 | if (VALID_PTR(ppszName))
|
---|
181 | *ppszName = szName;
|
---|
182 | if (VALID_PTR(ppszValue))
|
---|
183 | *ppszValue = szValue;
|
---|
184 | if (VALID_PTR(pu64Timestamp))
|
---|
185 | *pu64Timestamp = 12345;
|
---|
186 | if (VALID_PTR(ppszFlags))
|
---|
187 | *ppszFlags = szFlags;
|
---|
188 | if (VALID_PTR(pcbBufActual))
|
---|
189 | *pcbBufActual = 256;
|
---|
190 | return VINF_SUCCESS;
|
---|
191 | }
|
---|
192 |
|
---|
193 | #endif
|
---|