Changeset 10143 in vbox for trunk/src/VBox/Additions/common
- Timestamp:
- Jul 3, 2008 9:19:25 AM (17 years ago)
- svn:sync-xref-src-repo-rev:
- 32669
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxControl/VBoxControl.cpp
r10111 r10143 113 113 uint32_t u32ClientID = 0; 114 114 int rc = VINF_SUCCESS; 115 115 char *pszKey = NULL; 116 116 char szValue[KEY_MAX_VALUE_LEN]; 117 117 118 if (argc != 1) 118 119 { … … 120 121 return 1; 121 122 } 122 rc = VbglR3InfoSvcConnect(&u32ClientID);123 rc = RTStrCurrentCPToUtf8(&pszKey, argv[0]); 123 124 if (!RT_SUCCESS(rc)) 124 VBoxControlError("Failed to connect to the guest property service, error %Rrc\n", rc); 125 VBoxControlError("Failed to convert the key name to Utf8, error %Rrc\n", rc); 126 if (RT_SUCCESS(rc)) 127 { 128 rc = VbglR3InfoSvcConnect(&u32ClientID); 129 if (!RT_SUCCESS(rc)) 130 VBoxControlError("Failed to connect to the guest property service, error %Rrc\n", rc); 131 } 125 132 if (RT_SUCCESS(rc)) 126 133 { … … 129 136 VBoxControlError("Failed to retrieve the property value, error %Rrc\n", rc); 130 137 } 131 if (RT_SUCCESS(rc) || (VERR_NOT_FOUND == rc)) 132 { 133 if (RT_SUCCESS(rc)) 134 RTPrintf("Value: %s\n", szValue); 135 else 136 RTPrintf("No value set!\n"); 137 } 138 if (VERR_NOT_FOUND == rc) 139 RTPrintf("No value set!\n"); 140 if (RT_SUCCESS(rc)) 141 RTPrintf("Value: %S\n", szValue); 138 142 if (u32ClientID != 0) 139 143 VbglR3InfoSvcDisconnect(u32ClientID); 144 RTStrFree(pszKey); 140 145 return RT_SUCCESS(rc) ? 0 : 1; 141 146 } … … 153 158 static int setGuestProperty(int argc, char *argv[]) 154 159 { 160 uint32_t u32ClientID = 0; 161 int rc = VINF_SUCCESS; 162 char *pszKey = NULL; 163 char *pszValue = NULL; 164 155 165 if (argc != 1 && argc != 2) 156 166 { … … 158 168 return 1; 159 169 } 160 char *pszValue = NULL; 161 int rc = VINF_SUCCESS; 162 uint32_t u32ClientID = 0; 163 164 if (2 == argc) 165 pszValue = argv[1]; 166 rc = VbglR3InfoSvcConnect(&u32ClientID); 170 rc = RTStrCurrentCPToUtf8(&pszKey, argv[0]); 167 171 if (!RT_SUCCESS(rc)) 168 VBoxControlError("Failed to connect to the host/guest registry service, error %Rrc\n", rc); 172 VBoxControlError("Failed to convert the key name to Utf8, error %Rrc\n", rc); 173 if (RT_SUCCESS(rc) && (2 == argc)) 174 { 175 rc = RTStrCurrentCPToUtf8(&pszValue, argv[1]); 176 if (!RT_SUCCESS(rc)) 177 VBoxControlError("Failed to convert the key value to Utf8, error %Rrc\n", rc); 178 } 179 if (RT_SUCCESS(rc)) 180 { 181 rc = VbglR3InfoSvcConnect(&u32ClientID); 182 if (!RT_SUCCESS(rc)) 183 VBoxControlError("Failed to connect to the host/guest registry service, error %Rrc\n", rc); 184 } 169 185 if (RT_SUCCESS(rc)) 170 186 { … … 175 191 if (u32ClientID != 0) 176 192 VbglR3InfoSvcDisconnect(u32ClientID); 193 RTStrFree(pszKey); 194 RTStrFree(pszValue); 177 195 return RT_SUCCESS(rc) ? 0 : 1; 178 196 }
Note:
See TracChangeset
for help on using the changeset viewer.