Changeset 32023 in vbox
- Timestamp:
- Aug 27, 2010 8:56:34 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxControl/VBoxControl.cpp
r31052 r32023 621 621 /* must have exactly one argument: the new offset */ 622 622 if ( (argc != 1) 623 || ( strcmp(argv[0], "on")624 && strcmp(argv[0], "off")))623 || ( RTStrICmp(argv[0], "on") 624 && RTStrICmp(argv[0], "off"))) 625 625 { 626 626 usage(SET_VIDEO_ACCEL); … … 633 633 { 634 634 int fAccel = 0; 635 if ( !strcmp(argv[0], "on"))635 if (RTStrICmp(argv[0], "on") == 0) 636 636 fAccel = 1; 637 637 /* set a new value */ … … 894 894 using namespace guestProp; 895 895 896 bool verbose = false; 897 if ((2 == argc) && (0 == strcmp(argv[1], "-verbose"))) 898 verbose = true; 896 bool fVerbose = false; 897 if ( 2 == argc 898 && ( RTStrICmp(argv[1], "-verbose") == 0 899 || RTStrICmp(argv[1], "--verbose") == 0)) 900 { 901 fVerbose = true; 902 } 899 903 else if (argc != 1) 900 904 { … … 910 914 VBoxControlError("Failed to connect to the guest property service, error %Rrc\n", rc); 911 915 912 /*913 * Here we actually retrieve the value from the host.914 */916 /* 917 * Here we actually retrieve the value from the host. 918 */ 915 919 const char *pszName = argv[0]; 916 920 char *pszValue = NULL; … … 954 958 VBoxControlError("Failed to retrieve the property value, error %Rrc\n", rc); 955 959 } 956 /* 957 * And display it on the guest console. 958 */ 960 961 /* 962 * And display it on the guest console. 963 */ 959 964 if (VERR_NOT_FOUND == rc) 960 965 RTPrintf("No value set!\n"); … … 962 967 { 963 968 RTPrintf("Value: %S\n", pszValue); 964 if ( verbose)969 if (fVerbose) 965 970 { 966 971 RTPrintf("Timestamp: %lld ns\n", u64Timestamp); … … 985 990 static int setGuestProperty(int argc, char *argv[]) 986 991 { 987 /*988 * Check the syntax. We can deduce the correct syntax from the number of989 * arguments.990 */992 /* 993 * Check the syntax. We can deduce the correct syntax from the number of 994 * arguments. 995 */ 991 996 bool usageOK = true; 992 997 const char *pszName = NULL; … … 1002 1007 { 1003 1008 pszValue = argv[1]; 1004 if (strcmp(argv[2], "-flags") != 0) 1009 if ( RTStrICmp(argv[2], "-flags") != 0 1010 && RTStrICmp(argv[2], "--flags") != 0) 1005 1011 usageOK = false; 1006 1012 pszFlags = argv[3]; … … 1016 1022 pszName = argv[0]; 1017 1023 1018 /*1019 * Do the actual setting.1020 */1024 /* 1025 * Do the actual setting. 1026 */ 1021 1027 uint32_t u32ClientId = 0; 1022 1028 int rc = VINF_SUCCESS; … … 1056 1062 uint32_t cPatterns = 0; 1057 1063 if ( argc > 1 1058 && !strcmp(argv[0], "-patterns")) 1064 && ( RTStrICmp(argv[0], "-patterns") == 0) 1065 || RTStrICmp(argv[0], "--patterns") == 0) 1059 1066 { 1060 1067 papszPatterns = (char const * const *)&argv[1]; … … 1129 1136 for (int i = 1; usageOK && i < argc; ++i) 1130 1137 { 1131 if (strcmp(argv[i], "-timeout") == 0) 1138 if ( RTStrICmp(argv[i], "-timeout") == 0 1139 || RTStrICmp(argv[i], "--timeout") == 0) 1132 1140 { 1133 1141 if ( i + 1 >= argc … … 1139 1147 ++i; 1140 1148 } 1141 else if (strcmp(argv[i], "-timestamp") == 0) 1149 else if ( RTStrICmp(argv[i], "-timestamp") == 0 1150 || RTStrICmp(argv[i], "--timestamp") == 0) 1142 1151 { 1143 1152 if ( i + 1 >= argc … … 1216 1225 #endif 1217 1226 } 1218 /* 1219 * And display it on the guest console. 1220 */ 1227 1228 /* 1229 * And display it on the guest console. 1230 */ 1221 1231 if (VERR_NOT_FOUND == rc) 1222 1232 RTPrintf("No value set!\n"); … … 1252 1262 return 1; 1253 1263 } 1254 if (0 == strcmp(argv[0], "get"))1264 if (0 == RTStrICmp(argv[0], "get")) 1255 1265 return getGuestProperty(argc - 1, argv + 1); 1256 else if (0 == strcmp(argv[0], "set"))1266 else if (0 == RTStrICmp(argv[0], "set")) 1257 1267 return setGuestProperty(argc - 1, argv + 1); 1258 else if (0 == strcmp(argv[0], "enumerate"))1268 else if (0 == RTStrICmp(argv[0], "enumerate")) 1259 1269 return enumGuestProperty(argc - 1, argv + 1); 1260 else if (0 == strcmp(argv[0], "wait"))1270 else if (0 == RTStrICmp(argv[0], "wait")) 1261 1271 return waitGuestProperty(argc - 1, argv + 1); 1262 1272 /* else */ … … 1276 1286 if (argc == 1) 1277 1287 { 1278 if ( RTStrICmp(argv[0], "-automount") == 0 1279 || RTStrICmp(argv[0], "/automount") == 0) 1288 if ( RTStrICmp(argv[0], "-automount") == 0 1289 || RTStrICmp(argv[0], "--automount") == 0 1290 ) 1280 1291 { 1281 1292 fOnlyShowAutoMount = true; … … 1347 1358 return 1; 1348 1359 } 1349 if (0 == strcmp(argv[0], "list"))1360 if (0 == RTStrICmp(argv[0], "list")) 1350 1361 return listSharedFolders(argc - 1, argv + 1); 1351 1362 /* else */ … … 1393 1404 int iArg = 1; 1394 1405 /** Should we show the logo text? */ 1395 bool showlogo = true;1406 bool fShowLogo = true; 1396 1407 /** Should we print the usage after the logo? For the -help switch. */ 1397 bool dohelp = false;1408 bool fDoHelp = false; 1398 1409 /** Will we be executing a command or just printing information? */ 1399 bool onlyinfo = false;1400 1401 /*1402 * Start by handling command line switches1403 */1410 bool fOnlyInfo = false; 1411 1412 /* 1413 * Start by handling command line switches 1414 */ 1404 1415 1405 1416 /** Are we finished with handling switches? */ … … 1407 1418 while (!done && (iArg < argc)) 1408 1419 { 1409 if ( (0 == strcmp(argv[iArg], "-v"))1410 || (0 == strcmp(argv[iArg], "--version"))1411 || (0 == strcmp(argv[iArg], "-version"))1412 || (0 == strcmp(argv[iArg], "getversion"))1420 if ( 0 == RTStrICmp(argv[iArg], "-v") 1421 || 0 == RTStrICmp(argv[iArg], "--version") 1422 || 0 == RTStrICmp(argv[iArg], "-version") 1423 || 0 == RTStrICmp(argv[iArg], "getversion") 1413 1424 ) 1414 1425 { 1415 1426 /* Print version number, and do nothing else. */ 1416 1427 RTPrintf("%sr%u\n", VBOX_VERSION_STRING, RTBldCfgRevision()); 1417 onlyinfo = true;1418 showlogo = false;1428 fOnlyInfo = true; 1429 fShowLogo = false; 1419 1430 done = true; 1420 1431 } 1421 else if (0 == strcmp(argv[iArg], "-nologo")) 1422 showlogo = false; 1423 else if (0 == strcmp(argv[iArg], "-help")) 1424 { 1425 onlyinfo = true; 1426 dohelp = true; 1432 else if ( 0 == RTStrICmp(argv[iArg], "-nologo") 1433 || 0 == RTStrICmp(argv[iArg], "--nologo")) 1434 fShowLogo = false; 1435 else if ( 0 == RTStrICmp(argv[iArg], "-help") 1436 || 0 == RTStrICmp(argv[iArg], "--help")) 1437 { 1438 fOnlyInfo = true; 1439 fDoHelp = true; 1427 1440 done = true; 1428 1441 } … … 1435 1448 } 1436 1449 1437 /*1438 * Find the application name, show our logo if the user hasn't suppressed it,1439 * and show the usage if the user asked us to1440 */1450 /* 1451 * Find the application name, show our logo if the user hasn't suppressed it, 1452 * and show the usage if the user asked us to 1453 */ 1441 1454 1442 1455 g_pszProgName = RTPathFilename(argv[0]); 1443 if ( showlogo)1456 if (fShowLogo) 1444 1457 RTPrintf(VBOX_PRODUCT " Guest Additions Command Line Management Interface Version " 1445 1458 VBOX_VERSION_STRING "\n" 1446 1459 "(C) 2008-" VBOX_C_YEAR " " VBOX_VENDOR "\n" 1447 1460 "All rights reserved.\n\n"); 1448 if ( dohelp)1461 if (fDoHelp) 1449 1462 usage(); 1450 1463 1451 /*1452 * Do global initialisation for the programme if we will be handling a command1453 */1454 1455 if (! onlyinfo)1464 /* 1465 * Do global initialisation for the programme if we will be handling a command 1466 */ 1467 1468 if (!fOnlyInfo) 1456 1469 { 1457 1470 rrc = RTR3Init(); /** @todo r=bird: This ALWAYS goes first, the only exception is when you have to parse args to figure out which to call! */ … … 1473 1486 } 1474 1487 1475 /*1476 * Now look for an actual command in the argument list and handle it.1477 */1478 1479 if (! onlyinfo && (0 == rc))1488 /* 1489 * Now look for an actual command in the argument list and handle it. 1490 */ 1491 1492 if (!fOnlyInfo && (0 == rc)) 1480 1493 { 1481 1494 /* … … 1501 1514 && (g_commandHandlers[index].command != NULL)) 1502 1515 { 1503 if (0 == strcmp(argv[iArg], g_commandHandlers[index].command))1516 if (0 == RTStrICmp(argv[iArg], g_commandHandlers[index].command)) 1504 1517 found = true; 1505 1518 else … … 1529 1542 } 1530 1543 1531 /*1532 * And exit, returning the status1533 */1544 /* 1545 * And exit, returning the status 1546 */ 1534 1547 1535 1548 return rc;
Note:
See TracChangeset
for help on using the changeset viewer.