Changeset 10931 in vbox
- Timestamp:
- Jul 29, 2008 1:26:38 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxControl/VBoxControl.cpp
r10859 r10931 30 30 #include <iprt/path.h> 31 31 #include <iprt/initterm.h> 32 #include <iprt/autores> 32 33 #include <VBox/log.h> 33 34 #include <VBox/VBoxGuest.h> … … 106 107 { 107 108 doUsage("get <property> [-verbose]\n", g_pszProgName, "guestproperty"); 108 doUsage("set <property> [<value>] [--flags <flags>]\n", g_pszProgName, "guestproperty"); 109 doUsage("set <property> [<value>] [-flags <flags>]\n", g_pszProgName, "guestproperty"); 110 doUsage("enumerate [-patterns <patterns>]\n", g_pszProgName, "guestproperty"); 109 111 } 110 112 #endif … … 891 893 * Here we actually retrieve the value from the host. 892 894 */ 893 void *pvBuf = NULL;894 895 const char *pszName = argv[0]; 895 896 char *pszValue = NULL; 896 897 uint64_t u64Timestamp = 0; 897 898 char *pszFlags = NULL; 899 /* The buffer for storing the data and its initial size. We leave a bit 900 * of space here in case the maximum values are raised. */ 901 void *pvBuf = NULL; 902 uint32_t cbBuf = MAX_VALUE_LEN + MAX_FLAGS_LEN + 1024; 898 903 if (RT_SUCCESS(rc)) 899 904 { … … 903 908 * enough with buffer space. */ 904 909 bool finish = false; 905 /* We leave a bit of space here in case the maximum values are raised. */906 uint32_t cbBuf = MAX_VALUE_LEN + MAX_FLAGS_LEN + 1024;907 910 for (unsigned i = 0; (i < 10) && !finish; ++i) 908 911 { … … 1023 1026 1024 1027 /** 1028 * Enumerates the properties in the guest property store. 1029 * This is accessed through the "VBoxGuestPropSvc" HGCM service. 1030 * 1031 * @returns 0 on success, 1 on failure 1032 * @note see the command line API description for parameters 1033 */ 1034 static int enumGuestProperty(int argc, char *argv[]) 1035 { 1036 /* 1037 * Check the syntax. We can deduce the correct syntax from the number of 1038 * arguments. 1039 */ 1040 const char *paszPatterns = NULL; 1041 if ((argc > 1) && (0 == strcmp(argv[0], "-patterns"))) 1042 paszPatterns = argv[1]; 1043 else if (argc != 0) 1044 { 1045 usage(GUEST_PROP); 1046 return 1; 1047 } 1048 1049 /* 1050 * Do the actual enumeration. 1051 */ 1052 uint32_t u32ClientId = 0; 1053 PVBGLR3GUESTPROPENUM pHandleRaw = NULL; 1054 RTMemAutoPtr<VBGLR3GUESTPROPENUM, VbglR3GuestPropEnumFree> pHandle; 1055 char *pszName = NULL, *pszValue = NULL, *pszFlags = NULL; 1056 uint64_t u64Timestamp = 0; 1057 int rc = VINF_SUCCESS; 1058 rc = VbglR3GuestPropConnect(&u32ClientId); 1059 if (!RT_SUCCESS(rc)) 1060 VBoxControlError("Failed to connect to the guest property service, error %Rrc\n", rc); 1061 if (RT_SUCCESS(rc)) 1062 { 1063 char **ppaszPatterns = argc > 1 ? argv + 1 : NULL; 1064 int cPatterns = argc > 1 ? argc - 1 : 0; 1065 rc = VbglR3GuestPropEnum(u32ClientId, ppaszPatterns, cPatterns, &pHandleRaw, 1066 &pszName, &pszValue, &u64Timestamp, &pszFlags); 1067 if (RT_SUCCESS(rc)) 1068 { 1069 pHandle = pHandleRaw; 1070 } 1071 else if (VERR_NOT_FOUND == rc) 1072 RTPrintf("No properties found.\n"); 1073 else 1074 VBoxControlError("Failed to enumerate the guest properties, error %Rrc.\n", rc); 1075 } 1076 while (RT_SUCCESS(rc) && (pszName != NULL)) 1077 { 1078 RTPrintf("Name: %s, value: %s, timestamp: %lld, flags: %s\n", 1079 pszName, pszValue, u64Timestamp, pszFlags); 1080 rc = VbglR3GuestPropEnumNext(pHandle.get(), &pszName, &pszValue, &u64Timestamp, &pszFlags); 1081 if (!RT_SUCCESS(rc)) 1082 VBoxControlError("Error while enumerating guest propertied: %Rrc\n", rc); 1083 } 1084 1085 if (u32ClientId != 0) 1086 VbglR3GuestPropDisconnect(u32ClientId); 1087 return RT_SUCCESS(rc) ? 0 : 1; 1088 } 1089 1090 1091 /** 1025 1092 * Access the guest property store through the "VBoxGuestPropSvc" HGCM 1026 1093 * service. … … 1040 1107 else if (0 == strcmp(argv[0], "set")) 1041 1108 return setGuestProperty(argc - 1, argv + 1); 1109 else if (0 == strcmp(argv[0], "enumerate")) 1110 return enumGuestProperty(argc - 1, argv + 1); 1042 1111 /* else */ 1043 1112 usage(GUEST_PROP);
Note:
See TracChangeset
for help on using the changeset viewer.