VirtualBox

source: vbox/trunk/src/VBox/Additions/common/VBoxControl/testcase/tstVBoxControl.cpp@ 32178

Last change on this file since 32178 was 28800, checked in by vboxsync, 15 years ago

Automated rebranding to Oracle copyright/license strings via filemuncher

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.9 KB
Line 
1/* $Id: tstVBoxControl.cpp 28800 2010-04-27 08:22:32Z 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
36VBGLR3DECL(int) VbglR3Init(void)
37{
38 RTPrintf("Initialising guest library...\n");
39 return VINF_SUCCESS;
40}
41
42VBGLR3DECL(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
50VBGLR3DECL(int) VbglR3GuestPropDisconnect(uint32_t u32ClientId)
51{
52 RTPrintf("Disconnect client %d from guest property service...\n", u32ClientId);
53 return VINF_SUCCESS;
54}
55
56VBGLR3DECL(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
66VBGLR3DECL(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
75VBGLR3DECL(int) VbglR3GuestPropRead(uint32_t u32ClientId,
76 const char *pszName,
77 void *pvBuf,
78 uint32_t cbBuf,
79 char **ppszValue,
80 uint64_t *pu64Timestamp,
81 char **ppszFlags,
82 uint32_t *pcbBufActual)
83{
84 RTPrintf("Called GET_PROP, client %d, name %s...\n",
85 u32ClientId, pszName);
86 static char szValue[] = "Value";
87 static char szFlags[] = "TRANSIENT";
88 if (VALID_PTR(ppszValue))
89 *ppszValue = szValue;
90 if (VALID_PTR(pu64Timestamp))
91 *pu64Timestamp = 12345;
92 if (VALID_PTR(ppszFlags))
93 *ppszFlags = szFlags;
94 if (VALID_PTR(pcbBufActual))
95 *pcbBufActual = 256;
96 return VINF_SUCCESS;
97}
98
99struct VBGLR3GUESTPROPENUM
100{
101 uint32_t u32;
102};
103
104VBGLR3DECL(int) VbglR3GuestPropEnum(uint32_t u32ClientId,
105 char const * const *ppaszPatterns,
106 uint32_t cPatterns,
107 PVBGLR3GUESTPROPENUM *ppHandle,
108 char const **ppszName,
109 char const **ppszValue,
110 uint64_t *pu64Timestamp,
111 char const **ppszFlags)
112{
113 RTPrintf("Called ENUM_PROPS, client %d...\n", u32ClientId);
114 AssertPtrReturn(ppHandle, VERR_INVALID_POINTER);
115 static VBGLR3GUESTPROPENUM Handle = { 0 };
116 static char szName[] = "Name";
117 static char szValue[] = "Value";
118 static char szFlags[] = "TRANSIENT";
119 *ppHandle = &Handle;
120 if (VALID_PTR(ppszName))
121 *ppszName = szName;
122 if (VALID_PTR(ppszValue))
123 *ppszValue = szValue;
124 if (VALID_PTR(pu64Timestamp))
125 *pu64Timestamp = 12345;
126 if (VALID_PTR(ppszFlags))
127 *ppszFlags = szFlags;
128 return VINF_SUCCESS;
129}
130
131VBGLR3DECL(int) VbglR3GuestPropEnumNext(PVBGLR3GUESTPROPENUM pHandle,
132 char const **ppszName,
133 char const **ppszValue,
134 uint64_t *pu64Timestamp,
135 char const **ppszFlags)
136{
137 RTPrintf("Called enumerate next...\n");
138 AssertReturn(VALID_PTR(ppszName) || VALID_PTR(ppszValue) || VALID_PTR(ppszFlags),
139 VERR_INVALID_POINTER);
140 if (VALID_PTR(ppszName))
141 *ppszName = NULL;
142 if (VALID_PTR(ppszValue))
143 *ppszValue = NULL;
144 if (VALID_PTR(pu64Timestamp))
145 *pu64Timestamp = 0;
146 if (VALID_PTR(ppszFlags))
147 *ppszFlags = NULL;
148 return VINF_SUCCESS;
149}
150
151VBGLR3DECL(void) VbglR3GuestPropEnumFree(PVBGLR3GUESTPROPENUM pHandle)
152{
153 RTPrintf("Called enumerate free...\n");
154}
155
156VBGLR3DECL(int) VbglR3GuestPropWait(uint32_t u32ClientId,
157 const char *pszPatterns,
158 void *pvBuf,
159 uint32_t cbBuf,
160 uint64_t u64Timestamp,
161 uint32_t u32Timeout,
162 char ** ppszName,
163 char **ppszValue,
164 uint64_t *pu64Timestamp,
165 char **ppszFlags,
166 uint32_t *pcbBufActual)
167{
168 if (u32Timeout == RT_INDEFINITE_WAIT)
169 RTPrintf("Called GET_NOTIFICATION, client %d, patterns %s, timestamp %llu,\n"
170 " timeout RT_INDEFINITE_WAIT...\n",
171 u32ClientId, pszPatterns, u64Timestamp);
172 else
173 RTPrintf("Called GET_NOTIFICATION, client %d, patterns %s, timestamp %llu,\n"
174 " timeout %u...\n",
175 u32ClientId, pszPatterns, u64Timestamp, u32Timeout);
176 static char szName[] = "Name";
177 static char szValue[] = "Value";
178 static char szFlags[] = "TRANSIENT";
179 if (VALID_PTR(ppszName))
180 *ppszName = szName;
181 if (VALID_PTR(ppszValue))
182 *ppszValue = szValue;
183 if (VALID_PTR(pu64Timestamp))
184 *pu64Timestamp = 12345;
185 if (VALID_PTR(ppszFlags))
186 *ppszFlags = szFlags;
187 if (VALID_PTR(pcbBufActual))
188 *pcbBufActual = 256;
189 return VINF_SUCCESS;
190}
191
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette