Changeset 18779 in vbox for trunk/src/VBox
- Timestamp:
- Apr 6, 2009 3:43:23 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManageUSB.cpp
r17394 r18779 184 184 USBFilterCmd cmd; 185 185 186 /* at least: 0: command, 1: index, 2: - target, 3: <target value> */186 /* at least: 0: command, 1: index, 2: --target, 3: <target value> */ 187 187 if (a->argc < 4) 188 188 return errorSyntax(USAGE_USBFILTER, "Not enough parameters"); … … 190 190 /* which command? */ 191 191 cmd.mAction = USBFilterCmd::Invalid; 192 if ( strcmp (a->argv [0], "add") == 0) cmd.mAction = USBFilterCmd::Add;193 else if ( strcmp (a->argv [0], "modify") == 0) cmd.mAction = USBFilterCmd::Modify;194 else if ( strcmp (a->argv [0], "remove") == 0) cmd.mAction = USBFilterCmd::Remove;192 if (!strcmp(a->argv[0], "add")) cmd.mAction = USBFilterCmd::Add; 193 else if (!strcmp(a->argv[0], "modify")) cmd.mAction = USBFilterCmd::Modify; 194 else if (!strcmp(a->argv[0], "remove")) cmd.mAction = USBFilterCmd::Remove; 195 195 196 196 if (cmd.mAction == USBFilterCmd::Invalid) … … 206 206 case USBFilterCmd::Modify: 207 207 { 208 /* at least: 0: command, 1: index, 2: - target, 3: <target value>, 4:-name, 5: <name value> */208 /* at least: 0: command, 1: index, 2: --target, 3: <target value>, 4: --name, 5: <name value> */ 209 209 if (a->argc < 6) 210 210 { … … 223 223 for (int i = 2; i < a->argc; i++) 224 224 { 225 if (strcmp(a->argv [i], "-target") == 0) 225 if ( !strcmp(a->argv[i], "--target") 226 || !strcmp(a->argv[i], "-target")) 226 227 { 227 228 if (a->argc <= i + 1 || !*a->argv[i+1]) 228 229 return errorArgument("Missing argument to '%s'", a->argv[i]); 229 230 i++; 230 if ( strcmp (a->argv [i], "global") == 0)231 if (!strcmp(a->argv[i], "global")) 231 232 cmd.mGlobal = true; 232 233 else … … 241 242 } 242 243 } 243 else if (strcmp(a->argv [i], "-name") == 0) 244 else if ( !strcmp(a->argv[i], "--name") 245 || !strcmp(a->argv[i], "-name")) 244 246 { 245 247 if (a->argc <= i + 1 || !*a->argv[i+1]) 246 248 return errorArgument("Missing argument to '%s'", a->argv[i]); 247 249 i++; 248 cmd.mFilter.mName = a->argv [i]; 249 } 250 else if (strcmp(a->argv [i], "-active") == 0) 251 { 252 if (a->argc <= i + 1) 253 return errorArgument("Missing argument to '%s'", a->argv[i]); 254 i++; 255 if (strcmp (a->argv [i], "yes") == 0) 250 cmd.mFilter.mName = a->argv[i]; 251 } 252 else if ( !strcmp(a->argv[i], "--active") 253 || !strcmp(a->argv[i], "-active")) 254 { 255 if (a->argc <= i + 1) 256 return errorArgument("Missing argument to '%s'", a->argv[i]); 257 i++; 258 if (!strcmp(a->argv[i], "yes")) 256 259 cmd.mFilter.mActive = true; 257 else if ( strcmp (a->argv [i], "no") == 0)260 else if (!strcmp(a->argv[i], "no")) 258 261 cmd.mFilter.mActive = false; 259 262 else 260 return errorArgument("Invalid -active argument '%s'", a->argv[i]); 261 } 262 else if (strcmp(a->argv [i], "-vendorid") == 0) 263 { 264 if (a->argc <= i + 1) 265 return errorArgument("Missing argument to '%s'", a->argv[i]); 266 i++; 267 cmd.mFilter.mVendorId = a->argv [i]; 268 } 269 else if (strcmp(a->argv [i], "-productid") == 0) 270 { 271 if (a->argc <= i + 1) 272 return errorArgument("Missing argument to '%s'", a->argv[i]); 273 i++; 274 cmd.mFilter.mProductId = a->argv [i]; 275 } 276 else if (strcmp(a->argv [i], "-revision") == 0) 277 { 278 if (a->argc <= i + 1) 279 return errorArgument("Missing argument to '%s'", a->argv[i]); 280 i++; 281 cmd.mFilter.mRevision = a->argv [i]; 282 } 283 else if (strcmp(a->argv [i], "-manufacturer") == 0) 284 { 285 if (a->argc <= i + 1) 286 return errorArgument("Missing argument to '%s'", a->argv[i]); 287 i++; 288 cmd.mFilter.mManufacturer = a->argv [i]; 289 } 290 else if (strcmp(a->argv [i], "-product") == 0) 291 { 292 if (a->argc <= i + 1) 293 return errorArgument("Missing argument to '%s'", a->argv[i]); 294 i++; 295 cmd.mFilter.mProduct = a->argv [i]; 296 } 297 else if (strcmp(a->argv [i], "-remote") == 0) 263 return errorArgument("Invalid --active argument '%s'", a->argv[i]); 264 } 265 else if ( !strcmp(a->argv[i], "--vendorid") 266 || !strcmp(a->argv[i], "-vendorid")) 267 { 268 if (a->argc <= i + 1) 269 return errorArgument("Missing argument to '%s'", a->argv[i]); 270 i++; 271 cmd.mFilter.mVendorId = a->argv[i]; 272 } 273 else if ( !strcmp(a->argv[i], "--productid") 274 || !strcmp(a->argv[i], "-productid")) 275 { 276 if (a->argc <= i + 1) 277 return errorArgument("Missing argument to '%s'", a->argv[i]); 278 i++; 279 cmd.mFilter.mProductId = a->argv[i]; 280 } 281 else if ( !strcmp(a->argv[i], "--revision") 282 || !strcmp(a->argv[i], "-revision")) 283 { 284 if (a->argc <= i + 1) 285 return errorArgument("Missing argument to '%s'", a->argv[i]); 286 i++; 287 cmd.mFilter.mRevision = a->argv[i]; 288 } 289 else if ( !strcmp(a->argv[i], "--manufacturer") 290 || !strcmp(a->argv[i], "-manufacturer")) 291 { 292 if (a->argc <= i + 1) 293 return errorArgument("Missing argument to '%s'", a->argv[i]); 294 i++; 295 cmd.mFilter.mManufacturer = a->argv[i]; 296 } 297 else if ( !strcmp(a->argv[i], "--product") 298 || !strcmp(a->argv[i], "-product")) 299 { 300 if (a->argc <= i + 1) 301 return errorArgument("Missing argument to '%s'", a->argv[i]); 302 i++; 303 cmd.mFilter.mProduct = a->argv[i]; 304 } 305 else if ( !strcmp(a->argv[i], "--remote") 306 || !strcmp(a->argv[i], "-remote")) 298 307 { 299 308 if (a->argc <= i + 1) … … 302 311 cmd.mFilter.mRemote = a->argv[i]; 303 312 } 304 else if (strcmp(a->argv [i], "-serialnumber") == 0) 305 { 306 if (a->argc <= i + 1) 307 return errorArgument("Missing argument to '%s'", a->argv[i]); 308 i++; 309 cmd.mFilter.mSerialNumber = a->argv [i]; 310 } 311 else if (strcmp(a->argv [i], "-maskedinterfaces") == 0) 313 else if ( !strcmp(a->argv[i], "--serialnumber") 314 || !strcmp(a->argv[i], "-serialnumber")) 315 { 316 if (a->argc <= i + 1) 317 return errorArgument("Missing argument to '%s'", a->argv[i]); 318 i++; 319 cmd.mFilter.mSerialNumber = a->argv[i]; 320 } 321 else if ( !strcmp(a->argv[i], "--maskedinterfaces") 322 || !strcmp(a->argv[i], "-maskedinterfaces")) 312 323 { 313 324 if (a->argc <= i + 1) … … 317 328 rc = RTStrToUInt32Full(a->argv[i], 0, &u32); 318 329 if (RT_FAILURE(rc)) 319 return errorArgument("Failed to convert the - maskedinterfaces value '%s' to a number, rc=%Rrc", a->argv[i], rc);330 return errorArgument("Failed to convert the --maskedinterfaces value '%s' to a number, rc=%Rrc", a->argv[i], rc); 320 331 cmd.mFilter.mMaskedInterfaces = u32; 321 332 } 322 else if (strcmp(a->argv [i], "-action") == 0) 323 { 324 if (a->argc <= i + 1) 325 return errorArgument("Missing argument to '%s'", a->argv[i]); 326 i++; 327 if (strcmp (a->argv [i], "ignore") == 0) 333 else if ( !strcmp(a->argv[i], "--action") 334 || !strcmp(a->argv[i], "-action")) 335 { 336 if (a->argc <= i + 1) 337 return errorArgument("Missing argument to '%s'", a->argv[i]); 338 i++; 339 if (!strcmp(a->argv[i], "ignore")) 328 340 cmd.mFilter.mAction = USBDeviceFilterAction_Ignore; 329 else if ( strcmp (a->argv [i], "hold") == 0)341 else if (!strcmp(a->argv[i], "hold")) 330 342 cmd.mFilter.mAction = USBDeviceFilterAction_Hold; 331 343 else … … 359 371 case USBFilterCmd::Remove: 360 372 { 361 /* at least: 0: command, 1: index, 2: - target, 3: <target value> */373 /* at least: 0: command, 1: index, 2: --target, 3: <target value> */ 362 374 if (a->argc < 4) 363 375 return errorSyntax(USAGE_USBFILTER_REMOVE, "Not enough parameters"); … … 365 377 for (int i = 2; i < a->argc; i++) 366 378 { 367 if (strcmp(a->argv [i], "-target") == 0) 379 if ( !strcmp(a->argv[i], "--target") 380 || !strcmp(a->argv[i], "-target")) 368 381 { 369 382 if (a->argc <= i + 1 || !*a->argv[i+1]) 370 383 return errorArgument("Missing argument to '%s'", a->argv[i]); 371 384 i++; 372 if ( strcmp (a->argv [i], "global") == 0)385 if (!strcmp(a->argv[i], "global")) 373 386 cmd.mGlobal = true; 374 387 else
Note:
See TracChangeset
for help on using the changeset viewer.