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