Changeset 11042 in vbox for trunk/src/VBox/Frontends/VBoxManage
- Timestamp:
- Jul 31, 2008 6:01:38 PM (17 years ago)
- svn:sync-xref-src-repo-rev:
- 33937
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManageGuestProp.cpp
r11033 r11042 27 27 #include <VBox/com/com.h> 28 28 #include <VBox/com/string.h> 29 #include <VBox/com/array.h> 29 30 #include <VBox/com/ErrorInfo.h> 30 31 … … 45 46 RTPrintf("VBoxManage guestproperty set <vmname>|<uuid>\n" 46 47 " <property> [<value>] [-flags <flags>]\n" 48 "\n"); 49 RTPrintf("VBoxManage guestproperty enumerate <vmname>|<uuid>\n" 50 " [-patterns <patterns>]\n" 47 51 "\n"); 48 52 } … … 149 153 } 150 154 155 /** 156 * Enumerates the properties in the guest property store. 157 * 158 * @returns 0 on success, 1 on failure 159 * @note see the command line API description for parameters 160 */ 161 static int handleEnumGuestProperty(int argc, char *argv[], 162 ComPtr<IVirtualBox> aVirtualBox, ComPtr<ISession> aSession) 163 { 164 /* 165 * Check the syntax. We can deduce the correct syntax from the number of 166 * arguments. 167 */ 168 const char *paszPatterns = NULL; 169 if ((argc > 2) && (0 == strcmp(argv[0], "-patterns"))) 170 paszPatterns = argv[1]; 171 else if (argc != 1) 172 return errorSyntax(USAGE_GUESTPROPERTY, "Incorrect parameters"); 173 174 /* 175 * Count the size of the patterns and pack them. 176 */ 177 size_t cchPatterns = 0; 178 if (argc > 2) 179 for (int i = 1; i < argc; ++i) 180 cchPatterns += strlen(argv[i]) + 1; 181 Utf8Str Utf8Patterns(cchPatterns); 182 if ((cchPatterns > 0) && Utf8Patterns.isNull()) 183 return errorArgument ("out of memory"); 184 char *pszPatterns = Utf8Patterns.mutableRaw(); 185 size_t iPatterns = 0; 186 if (argc > 2) 187 { 188 for (int i = 1; i < argc; ++i) 189 { 190 strcpy(pszPatterns + iPatterns, argv[i]); 191 iPatterns += strlen(argv[i]) + 1; 192 pszPatterns[iPatterns - 1] = ','; 193 } 194 pszPatterns[iPatterns - 1] = '\0'; 195 } 196 197 /* 198 * Make the actual call to Main. 199 */ 200 ComPtr<IMachine> machine; 201 /* assume it's a UUID */ 202 HRESULT rc = aVirtualBox->GetMachine(Guid(argv[0]), machine.asOutParam()); 203 if (FAILED(rc) || !machine) 204 { 205 /* must be a name */ 206 CHECK_ERROR(aVirtualBox, FindMachine(Bstr(argv[0]), machine.asOutParam())); 207 } 208 if (machine) 209 { 210 com::SafeArray <BSTR> names; 211 com::SafeArray <BSTR> values; 212 com::SafeArray <ULONG64> timestamps; 213 com::SafeArray <BSTR> flags; 214 CHECK_ERROR(machine, EnumerateGuestProperties(Bstr(Utf8Patterns), 215 ComSafeArrayAsOutParam(names), 216 ComSafeArrayAsOutParam(values), 217 ComSafeArrayAsOutParam(timestamps), 218 ComSafeArrayAsOutParam(flags))); 219 if (SUCCEEDED(rc)) 220 { 221 if (names.size() == 0) 222 RTPrintf("No properties found.\n"); 223 for (unsigned i = 0; i < names.size(); ++i) 224 RTPrintf("Name: %lS, value: %lS, timestamp: %lld, flags: %lS\n", 225 names[i], values[i], timestamps[i], flags[i]); 226 } 227 } 228 return SUCCEEDED(rc) ? 0 : 1; 229 } 151 230 152 231 /** … … 165 244 else if (0 == strcmp(argv[0], "set")) 166 245 return handleSetGuestProperty(argc - 1, argv + 1, aVirtualBox, aSession); 246 else if (0 == strcmp(argv[0], "enumerate")) 247 return handleEnumGuestProperty(argc - 1, argv + 1, aVirtualBox, aSession); 167 248 /* else */ 168 249 return errorSyntax(USAGE_GUESTPROPERTY, "Incorrect parameters");
Note:
See TracChangeset
for help on using the changeset viewer.