vbox的更動 62800 路徑 trunk/src/VBox/HostServices
- 時間撮記:
- 2016-8-1 上午09:41:36 (8 年 以前)
- 位置:
- trunk/src/VBox/HostServices/GuestControl
- 檔案:
-
- 修改 4 筆資料
圖例:
- 未更動
- 新增
- 刪除
-
trunk/src/VBox/HostServices/GuestControl/gctrl.cpp
r62489 r62800 46 46 namespace guestControl { 47 47 48 #if 0 /* unused */ 48 49 /** 49 50 * Creates the argument list as an array used for executing a program. 50 51 * 51 52 * @returns VBox status code. 52 *53 * @todo54 *55 * @todo Respect spaces when quoting for arguments, e.g. "c:\\program files\\".56 * @todo Handle empty ("") arguments.57 53 */ 58 54 int gctrlPrepareExecArgv(char *pszArgs, void **ppvList, uint32_t *pcbList, uint32_t *pcArgs) 59 55 { 60 56 char **ppaArg; 61 int iArgs;62 int rc = RTGetOptArgvFromString(&ppaArg, & iArgs, pszArgs, RTGETOPTARGV_CNV_QUOTE_BOURNE_SH, NULL);57 int cArgs; 58 int rc = RTGetOptArgvFromString(&ppaArg, &cArgs, pszArgs, RTGETOPTARGV_CNV_QUOTE_BOURNE_SH, NULL); 63 59 if (RT_SUCCESS(rc)) 64 60 { 61 /** @todo calc size first, allocate buffer, copy stuff. */ 65 62 char *pszTemp = NULL; 66 63 *pcbList = 0; 67 for (int i =0; i<iArgs; i++)64 for (int i = 0; i < cArgs; i++) 68 65 { 69 66 if (i > 0) /* Insert space as delimiter. */ 67 { 70 68 rc = RTStrAAppendN(&pszTemp, " ", 1); 71 72 if (RT_FAILURE(rc))73 break;74 else75 {76 rc = RTStrAAppendN(&pszTemp, ppaArg[i], strlen(ppaArg[i]));77 69 if (RT_FAILURE(rc)) 78 70 break; 79 71 } 80 } 72 rc = RTStrAAppendN(&pszTemp, ppaArg[i], strlen(ppaArg[i])); 73 if (RT_FAILURE(rc)) 74 break; 75 } 76 81 77 RTGetOptArgvFree(ppaArg); 78 82 79 if (RT_SUCCESS(rc)) 83 80 { 84 81 *ppvList = pszTemp; 85 *pcArgs = iArgs;86 *pcbList = strlen(pszTemp) + 1; /* Include zero termination. */82 *pcArgs = cArgs; 83 *pcbList = (uint32_t)(strlen(pszTemp) + 1); /* Include zero termination. */ 87 84 } 88 85 else … … 91 88 return rc; 92 89 } 93 94 90 #endif 91 92 93 #if 0 /* unused */ 95 94 /** 96 * Appends environment variables to the environment block. Each var=value pair is separated 97 * by NULL (\0) sequence. The whole block will be stored in one blob and disassembled on the 98 * guest side later to fit into the HGCM param structure. 95 * Appends environment variables to the environment block. 96 * 97 * Each var=value pair is separated by NULL (\0) sequence. The whole block will 98 * be stored in one blob and disassembled on the guest side later to fit into 99 * the HGCM param structure. 99 100 * 100 101 * @returns VBox status code. 101 102 * 102 * @todo 103 * 103 * @todo Write proper documentation 104 * @remarks currently not used. 104 105 */ 105 106 int gctrlAddToExecEnvv(const char *pszEnv, void **ppvList, uint32_t *pcbList, uint32_t *pcEnv) 106 107 { 107 108 int rc = VINF_SUCCESS; 108 uint32_t cbLen = strlen(pszEnv);109 size_t cchLen = strlen(pszEnv); 109 110 if (*ppvList) 110 111 { 111 uint32_t cbNewLen = *pcbList + cbLen + 1; /* Include zero termination. */112 size_t cbNewLen = *pcbList + cchLen + 1; /* Include zero termination. */ 112 113 char *pvTmp = (char*)RTMemRealloc(*ppvList, cbNewLen); 113 114 if (NULL == pvTmp) … … 117 118 else 118 119 { 119 memcpy(pvTmp + *pcbList, pszEnv, c bLen);120 memcpy(pvTmp + *pcbList, pszEnv, cchLen); 120 121 pvTmp[cbNewLen - 1] = '\0'; /* Add zero termination. */ 121 122 *ppvList = (void**)pvTmp; … … 135 136 if (RT_SUCCESS(rc)) 136 137 { 137 *pcbList += cbLen + 1; /* Include zero termination. */ 138 *pcEnv += 1; /* Increase env pairs count. */ 139 } 140 return rc; 141 } 138 *pcbList += (uint32_t)(cchLen + 1); /* Include zero termination. */ 139 *pcEnv += 1; /* Increase env pairs count. */ 140 } 141 return rc; 142 } 143 #endif /* unused */ 142 144 143 145 /* -
trunk/src/VBox/HostServices/GuestControl/gctrl.h
r62489 r62800 23 23 namespace guestControl { 24 24 25 //unused: /** @todo write docs! */ 26 //unused: int gctrlPrepareExecArgv(char *pszArgs, void **ppvList, uint32_t *pcbList, uint32_t *pcArgs); 27 //unused: /** @todo write docs! */ 28 //unused: int gctrlAddToExecEnvv(const char *pszEnv, void **ppvList, uint32_t *pcbList, uint32_t *pcEnv); 29 #if 0 25 30 /** @todo write docs! */ 26 int gctrlPrepareExecArgv(char *pszArgs, void **ppvList, uint32_t *pcbList, uint32_t *pcArgs);27 /** @todo write docs! */28 int gctrlAddToExecEnvv(const char *pszEnv, void **ppvList, uint32_t *pcbList, uint32_t *pcEnv);29 /** @todo write docs! */30 #if 031 31 int gctrlAllocateExecBlock(PVBOXGUESTCTRLEXECBLOCK *ppBlock, 32 32 const char *pszCmd, uint32_t fFlags, -
trunk/src/VBox/HostServices/GuestControl/service.cpp
r60391 r62800 1028 1028 int sessionClose(uint32_t u32ClientID, VBOXHGCMCALLHANDLE callHandle, uint32_t cParms, VBOXHGCMSVCPARM paParms[]); 1029 1029 int uninit(void); 1030 1031 DECLARE_CLS_COPY_CTOR_ASSIGN_NOOP(Service); 1030 1032 }; 1031 1033 … … 1039 1041 int Service::clientConnect(uint32_t u32ClientID, void *pvClient) 1040 1042 { 1043 RT_NOREF1(pvClient); 1041 1044 LogFlowFunc(("[Client %RU32] Connected\n", u32ClientID)); 1042 1045 #ifdef VBOX_STRICT … … 1066 1069 int Service::clientDisconnect(uint32_t u32ClientID, void *pvClient) 1067 1070 { 1071 RT_NOREF1(pvClient); 1068 1072 LogFlowFunc(("[Client %RU32] Disconnected (%zu clients total)\n", 1069 1073 u32ClientID, mClientStateMap.size())); … … 1169 1173 uint32_t cParms, VBOXHGCMSVCPARM paParms[]) 1170 1174 { 1175 RT_NOREF1(callHandle); 1176 1171 1177 /* 1172 1178 * Lookup client in our list so that we can assign the context ID of … … 1182 1188 return VERR_INVALID_PARAMETER; 1183 1189 1184 uint32_t uValue , uMaskAdd, uMaskRemove;1190 uint32_t uValue; 1185 1191 int rc = paParms[0].getUInt32(&uValue); 1186 1192 if (RT_SUCCESS(rc)) 1193 { 1194 uint32_t uMaskAdd; 1187 1195 rc = paParms[1].getUInt32(&uMaskAdd); 1188 if (RT_SUCCESS(rc)) 1189 rc = paParms[2].getUInt32(&uMaskRemove); 1190 /** @todo paParm[3] (flags) not used yet. */ 1191 if (RT_SUCCESS(rc)) 1192 { 1193 ClientState &clientState = itClientState->second; 1194 1195 clientState.mFlags |= CLIENTSTATE_FLAG_CONTEXTFILTER; 1196 if (uMaskAdd) 1197 clientState.mFilterMask |= uMaskAdd; 1198 if (uMaskRemove) 1199 clientState.mFilterMask &= ~uMaskRemove; 1200 1201 clientState.mFilterValue = uValue; 1202 1203 LogFlowFunc(("[Client %RU32] Setting message filterMask=0x%x, filterVal=%RU32 set (flags=0x%x, maskAdd=0x%x, maskRemove=0x%x)\n", 1204 u32ClientID, clientState.mFilterMask, clientState.mFilterValue, 1205 clientState.mFlags, uMaskAdd, uMaskRemove)); 1196 if (RT_SUCCESS(rc)) 1197 { 1198 uint32_t uMaskRemove; 1199 rc = paParms[2].getUInt32(&uMaskRemove); 1200 /** @todo paParm[3] (flags) not used yet. */ 1201 if (RT_SUCCESS(rc)) 1202 { 1203 ClientState &clientState = itClientState->second; 1204 1205 clientState.mFlags |= CLIENTSTATE_FLAG_CONTEXTFILTER; 1206 if (uMaskAdd) 1207 clientState.mFilterMask |= uMaskAdd; 1208 if (uMaskRemove) 1209 clientState.mFilterMask &= ~uMaskRemove; 1210 1211 clientState.mFilterValue = uValue; 1212 1213 LogFlowFunc(("[Client %RU32] Setting message filterMask=0x%x, filterVal=%RU32 set (flags=0x%x, maskAdd=0x%x, maskRemove=0x%x)\n", 1214 u32ClientID, clientState.mFilterMask, clientState.mFilterValue, 1215 clientState.mFlags, uMaskAdd, uMaskRemove)); 1216 } 1217 } 1206 1218 } 1207 1219 … … 1212 1224 uint32_t cParms, VBOXHGCMSVCPARM paParms[]) 1213 1225 { 1226 RT_NOREF2(callHandle, paParms); 1227 1214 1228 /* 1215 1229 * Lookup client in our list so that we can assign the context ID of … … 1238 1252 uint32_t cParms, VBOXHGCMSVCPARM paParms[]) 1239 1253 { 1254 RT_NOREF2(callHandle, paParms); 1255 1240 1256 /* 1241 1257 * Lookup client in our list so that we can assign the context ID of … … 1560 1576 int Service::sessionClose(uint32_t u32ClientID, VBOXHGCMCALLHANDLE callHandle, uint32_t cParms, VBOXHGCMSVCPARM paParms[]) 1561 1577 { 1578 RT_NOREF2(u32ClientID, callHandle); 1562 1579 if (cParms < 2) 1563 1580 return VERR_INVALID_PARAMETER; … … 1574 1591 1575 1592 LogFlowFunc(("Closing guest session ID=%RU32 (from client ID=%RU32) returned with rc=%Rrc\n", 1576 uSessionID, u32ClientID, rc)); 1593 uSessionID, u32ClientID, rc)); NOREF(uSessionID); 1577 1594 return rc; 1578 1595 } -
trunk/src/VBox/HostServices/GuestControl/testcase/tstGuestControlSvc.cpp
r62489 r62800 154 154 RTTestSub(g_hTest, "Testing host commands ..."); 155 155 156 static VBOXHGCMSVCPARM s_aParms[1];157 s_aParms[0].setUInt32(1000 /* Context ID */);158 159 static CMDHOST s_aCmdHostAll[] =160 { 161 156 VBOXHGCMSVCPARM aParms[1]; 157 aParms[0].setUInt32(1000 /* Context ID */); 158 159 CMDHOST aCmdHostAll[] = 160 { 161 #if 0 162 162 /** No client connected. */ 163 163 { 1024 /* Not existing command */, 0, 0, false, VERR_NOT_FOUND }, 164 164 { -1 /* Invalid command */, 0, 0, false, VERR_NOT_FOUND }, 165 165 { HOST_CANCEL_PENDING_WAITS, 1024, 0, false, VERR_NOT_FOUND }, 166 { HOST_CANCEL_PENDING_WAITS, 0, & s_aParms[0], false, VERR_NOT_FOUND },166 { HOST_CANCEL_PENDING_WAITS, 0, &aParms[0], false, VERR_NOT_FOUND }, 167 167 168 168 /** No client connected, valid command. */ … … 176 176 /** Client connected, valid parameters given. */ 177 177 { HOST_CANCEL_PENDING_WAITS, 0, 0, true, VINF_SUCCESS }, 178 { HOST_CANCEL_PENDING_WAITS, 1024, & s_aParms[0], true, VINF_SUCCESS },179 { HOST_CANCEL_PENDING_WAITS, 0, & s_aParms[0], true, VINF_SUCCESS},180 178 { HOST_CANCEL_PENDING_WAITS, 1024, &aParms[0], true, VINF_SUCCESS }, 179 { HOST_CANCEL_PENDING_WAITS, 0, &aParms[0], true, VINF_SUCCESS}, 180 #endif 181 181 182 182 /** Client connected, invalid parameters given. */ … … 186 186 187 187 /** Client connected, parameters given. */ 188 { HOST_CANCEL_PENDING_WAITS, 1, & s_aParms[0], true, VINF_SUCCESS },189 { HOST_EXEC_CMD, 1, & s_aParms[0], true, VINF_SUCCESS },190 { HOST_EXEC_SET_INPUT, 1, & s_aParms[0], true, VINF_SUCCESS },191 { HOST_EXEC_GET_OUTPUT, 1, & s_aParms[0], true, VINF_SUCCESS },188 { HOST_CANCEL_PENDING_WAITS, 1, &aParms[0], true, VINF_SUCCESS }, 189 { HOST_EXEC_CMD, 1, &aParms[0], true, VINF_SUCCESS }, 190 { HOST_EXEC_SET_INPUT, 1, &aParms[0], true, VINF_SUCCESS }, 191 { HOST_EXEC_GET_OUTPUT, 1, &aParms[0], true, VINF_SUCCESS }, 192 192 193 193 /** Client connected, unknown command + valid parameters given. */ 194 { -1, 1, & s_aParms[0], true, VINF_SUCCESS }194 { -1, 1, &aParms[0], true, VINF_SUCCESS } 195 195 }; 196 196 197 int rc = testHostCmd(pTable, & s_aCmdHostAll[0], RT_ELEMENTS(s_aCmdHostAll));197 int rc = testHostCmd(pTable, &aCmdHostAll[0], RT_ELEMENTS(aCmdHostAll)); 198 198 RTTestSubDone(g_hTest); 199 199 return rc; … … 210 210 211 211 /* No commands from host yet. */ 212 static VBOXHGCMSVCPARM s_aParmsGuest[8];213 s_aParmsGuest[0].setUInt32(0 /* Msg type */);214 s_aParmsGuest[1].setUInt32(0 /* Parameters */);212 VBOXHGCMSVCPARM aParmsGuest[8]; 213 aParmsGuest[0].setUInt32(0 /* Msg type */); 214 aParmsGuest[1].setUInt32(0 /* Parameters */); 215 215 pTable->pfnCall(pTable->pvService, &callHandle, 1 /* Client ID */, NULL /* pvClient */, 216 GUEST_MSG_WAIT, 2, & s_aParmsGuest[0]);216 GUEST_MSG_WAIT, 2, &aParmsGuest[0]); 217 217 RTTEST_CHECK_RC_RET(g_hTest, callHandle.rc, VINF_SUCCESS, callHandle.rc); 218 218 219 219 /* Host: Add a dummy command. */ 220 static VBOXHGCMSVCPARM s_aParmsHost[8];221 s_aParmsHost[0].setUInt32(1000 /* Context ID */);222 s_aParmsHost[1].setString("foo.bar");223 s_aParmsHost[2].setString("baz");224 225 rc = pTable->pfnHostCall(pTable->pvService, HOST_EXEC_CMD, 3, & s_aParmsHost[0]);220 VBOXHGCMSVCPARM aParmsHost[8]; 221 aParmsHost[0].setUInt32(1000 /* Context ID */); 222 aParmsHost[1].setString("foo.bar"); 223 aParmsHost[2].setString("baz"); 224 225 rc = pTable->pfnHostCall(pTable->pvService, HOST_EXEC_CMD, 3, &aParmsHost[0]); 226 226 RTTEST_CHECK_RC_RET(g_hTest, rc, VINF_SUCCESS, rc); 227 227 … … 239 239 * Set environment variable "IPRT_TEST_MAX_LEVEL=all" to get more debug output! 240 240 */ 241 int main( int argc, char **argv)241 int main() 242 242 { 243 243 RTEXITCODE rcExit = RTTestInitAndCreate("tstGuestControlSvc", &g_hTest);
注意:
瀏覽 TracChangeset
來幫助您使用更動檢視器