VirtualBox

Changeset 26517 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Feb 14, 2010 9:39:00 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
57688
Message:

*: RTGetOpt cleanup related to --help and --version (now standard option). Use RTGetOptPrintError.

Location:
trunk/src/VBox
Files:
29 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Network/testcase/tstIntNet-1.cpp

    r20864 r26517  
    684684        { "--xmit-test",    'x', RTGETOPT_REQ_NOTHING },
    685685        { "--ping-test",    'P', RTGETOPT_REQ_NOTHING },
    686         { "--help",         'h', RTGETOPT_REQ_NOTHING },
    687         { "--?",            '?', RTGETOPT_REQ_NOTHING },
    688686    };
    689687
     
    805803                break;
    806804
    807             case '?':
    808805            case 'h':
    809806                RTPrintf("syntax: tstIntNet-1 <options>\n"
     
    818815                return 1;
    819816
    820             case VINF_GETOPT_NOT_OPTION:
    821                 RTPrintf("tstIntNetR0: invalid argument: %s\n", Value.psz);
    822                 return 1;
     817            case 'V':
     818                RTPrintf("$Revision$\n");
     819                return 0;
    823820
    824821            default:
    825                 if (RT_SUCCESS(ch))
    826                     RTPrintf("tstIntNetR0: invalid argument (%#x): %s\n", ch, Value.psz);
    827                 else if (Value.pDef)
    828                     RTPrintf("tstIntNetR0: invalid argument: %Rrc - %s\n", ch, Value.pDef->pszLong);
    829                 else
    830                     RTPrintf("tstIntNetR0: invalid argument: %Rrc - %s\n", ch, argv[iArg]);
    831                 return 1;
     822                return RTGetOptPrintError(ch, &Value);
    832823        }
    833824
  • trunk/src/VBox/Devices/Network/testcase/tstIntNetR0.cpp

    r26296 r26517  
    412412    RTGETOPTUNION Value;
    413413    RTGETOPTSTATE GetState;
    414     RTGetOptInit(&GetState, argc, argv, s_aOptions, RT_ELEMENTS(s_aOptions), 1, 0 /* fFlags */);
     414    RTGetOptInit(&GetState, argc, argv, s_aOptions, RT_ELEMENTS(s_aOptions), 1, RTGETOPTINIT_FLAGS_NO_STD_OPTS);
    415415    while ((ch = RTGetOpt(&GetState, &Value)))
    416416        switch (ch)
     
    424424                break;
    425425
    426             case VINF_GETOPT_NOT_OPTION:
    427                 RTPrintf("tstIntNetR0: invalid argument: %s\n", Value.psz);
    428                 return 1;
    429 
    430426            default:
    431                 RTPrintf("tstIntNetR0: invalid argument: %s\n", Value.psz);
    432                 return 1;
     427                return RTGetOptPrintError(ch, &Value);
    433428        }
    434429
  • trunk/src/VBox/Disassembler/testcase/tstDisasm-2.cpp

    r24011 r26517  
    823823        { "--address",      'a', RTGETOPT_REQ_UINT64 },
    824824        { "--cpumode",      'c', RTGETOPT_REQ_UINT32 },
    825         { "--help",         'h', RTGETOPT_REQ_NOTHING },
    826825        { "--bytes",        'b', RTGETOPT_REQ_INT64 },
    827826        { "--listing",      'l', RTGETOPT_REQ_NOTHING },
     
    836835    RTGETOPTUNION ValueUnion;
    837836    RTGETOPTSTATE GetState;
    838     RTGetOptInit(&GetState, argc, argv, g_aOptions, RT_ELEMENTS(g_aOptions), 1, 0 /* fFlags */);
    839     while ((ch = RTGetOpt(&GetState, &ValueUnion)))
     837    RTGetOptInit(&GetState, argc, argv, g_aOptions, RT_ELEMENTS(g_aOptions), 1, RTGETOPTINIT_FLAGS_OPTS_FIRST);
     838    while (   (ch = RTGetOpt(&GetState, &ValueUnion))
     839           && ch != VINF_GETOPT_NOT_OPTION)
    840840    {
    841841        switch (ch)
     
    914914                break;
    915915
    916             case VINF_GETOPT_NOT_OPTION:
    917                 break;
     916            case 'V':
     917                RTPrintf("$Revision: $\n");
     918                return 0;
    918919
    919920            default:
    920                 RTStrmPrintf(g_pStdErr, "%s: syntax error: %Rrc\n", argv0, ch);
    921                 return 1;
     921                return RTGetOptPrintError(ch, &ValueUnion);
    922922        }
    923923    }
  • trunk/src/VBox/Frontends/VBoxHeadless/VBoxHeadless.cpp

    r26439 r26517  
    3939# include <VBox/vrdpapi.h>
    4040#endif
     41#include <iprt/buildconfig.h>
    4142#include <iprt/ctype.h>
    4243#include <iprt/initterm.h>
     
    681682        { "--capture", 'c', 0 },
    682683        { "--width", 'w', RTGETOPT_REQ_UINT32 },
    683         { "--height", 'h', RTGETOPT_REQ_UINT32 },
     684        { "--height", 'h', RTGETOPT_REQ_UINT32 }, /* great choice of short option! */
    684685        { "--bitrate", 'r', RTGETOPT_REQ_UINT32 },
    685686        { "--filename", 'f', RTGETOPT_REQ_STRING },
     
    746747                ulFrameWidth = ValueUnion.u32;
    747748                break;
    748             case 'h':
    749                 ulFrameHeight = ValueUnion.u32;
    750                 break;
    751749            case 'r':
    752750                ulBitRate = ValueUnion.u32;
     
    756754                break;
    757755#endif /* VBOX_FFMPEG defined */
    758             case VINF_GETOPT_NOT_OPTION:
    759                 RTPrintf("Invalid parameter '%s'\n\n", ValueUnion.psz);
     756            case 'h':
     757#ifdef VBOX_FFMPEG
     758                if ((GetState.pDef->fFlags & RTGETOPT_REQ_MASK) != RTGETOPT_REQ_NOTHING)
     759                {
     760                    ulFrameHeight = ValueUnion.u32;
     761                    break;
     762                }
     763#endif
    760764                show_usage();
    761                 return -1;
     765                return 0;
    762766            case OPT_COMMENT:
    763767                /* nothing to do */
    764768                break;
     769            case 'V':
     770                RTPrintf("%sr%s\n", RTBldCfgVersion(), RTBldCfgRevisionStr());
     771                return 0;
    765772            default:
    766                 if (ch > 0)
    767                 {
    768                     if (RT_C_IS_PRINT(ch))
    769                         RTPrintf("Invalid option -%c\n\n", ch);
    770                     else
    771                         RTPrintf("Invalid option case %i\n\n", ch);
    772                 }
    773                 else if (ch == VERR_GETOPT_UNKNOWN_OPTION)
    774                     RTPrintf("Unknown option: %s\n\n", ValueUnion.psz);
    775                 else if (ValueUnion.pDef)
    776                     RTPrintf("%s: %Rrs\n\n", ValueUnion.pDef->pszLong, ch);
    777                 else
    778                     RTPrintf("Error: %Rrs\n\n", ch);
     773                ch = RTGetOptPrintError(ch, &ValueUnion);
    779774                show_usage();
    780                 return -1;
     775                return ch;
    781776        }
    782777    }
     
    786781    {
    787782        LogError("VBoxHeadless: ERROR: please specify an even frame width between 512 and 2048", 0);
    788         return -1;
     783        return 1;
    789784    }
    790785    if (ulFrameHeight < 384 || ulFrameHeight > 1536 || ulFrameHeight % 2)
    791786    {
    792787        LogError("VBoxHeadless: ERROR: please specify an even frame height between 384 and 1536", 0);
    793         return -1;
     788        return 1;
    794789    }
    795790    if (ulBitRate < 300000 || ulBitRate > 1000000)
    796791    {
    797792        LogError("VBoxHeadless: ERROR: please specify an even bitrate between 300000 and 1000000", 0);
    798         return -1;
     793        return 1;
    799794    }
    800795    /* Make sure we only have %d or %u (or none) in the file name specified */
     
    803798    {
    804799        LogError("VBoxHeadless: ERROR: Only %%d and %%u are allowed in the capture file name.", -1);
    805         return -1;
     800        return 1;
    806801    }
    807802    /* And no more than one % in the name */
     
    809804    {
    810805        LogError("VBoxHeadless: ERROR: Only one format modifier is allowed in the capture file name.", -1);
    811         return -1;
     806        return 1;
    812807    }
    813808    RTStrPrintf(&pszMPEGFile[0], RTPATH_MAX, pszFileNameParam, RTProcSelf());
     
    817812    {
    818813        show_usage();
    819         return -1;
     814        return 1;
    820815    }
    821816
     
    826821    {
    827822        RTPrintf("VBoxHeadless: ERROR: failed to initialize COM!\n");
    828         return rc;
     823        return 1;
    829824    }
    830825
     
    11721167    LogFlow(("VBoxHeadless FINISHED.\n"));
    11731168
    1174     return rc;
     1169    return FAILED(rc) ? 1 : 0;
    11751170}
    11761171
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageControlVM.cpp

    r26371 r26517  
    883883            };
    884884            RTGETOPTSTATE GetOptState;
    885             RTGetOptInit(&GetOptState, a->argc, a->argv, s_aTeleportOptions, RT_ELEMENTS(s_aTeleportOptions), 2, 0 /*fFlags*/);
     885            RTGetOptInit(&GetOptState, a->argc, a->argv, s_aTeleportOptions, RT_ELEMENTS(s_aTeleportOptions), 2, RTGETOPTINIT_FLAGS_NO_STD_OPTS);
    886886            int ch;
    887887            RTGETOPTUNION Value;
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageDHCPServer.cpp

    r26163 r26517  
    107107                 a->argv,
    108108                 g_aDHCPIPOptions,
    109                  enmCode != OP_REMOVE ? RT_ELEMENTS(g_aDHCPIPOptions): 4, /* we use only --netname and --ifname for remove*/
     109                 enmCode != OP_REMOVE ? RT_ELEMENTS(g_aDHCPIPOptions) : 4, /* we use only --netname and --ifname for remove*/
    110110                 index,
    111                  0 /* fFlags */);
     111                 RTGETOPTINIT_FLAGS_NO_STD_OPTS);
    112112    while ((c = RTGetOpt(&GetState, &ValueUnion)))
    113113    {
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageDisk.cpp

    r26163 r26517  
    187187    RTGETOPTSTATE GetState;
    188188    // start at 0 because main() has hacked both the argc and argv given to us
    189     RTGetOptInit(&GetState, a->argc, a->argv, g_aCreateHardDiskOptions, RT_ELEMENTS(g_aCreateHardDiskOptions), 0, 0 /* fFlags */);
     189    RTGetOptInit(&GetState, a->argc, a->argv, g_aCreateHardDiskOptions, RT_ELEMENTS(g_aCreateHardDiskOptions),
     190                 0, RTGETOPTINIT_FLAGS_NO_STD_OPTS);
    190191    while ((c = RTGetOpt(&GetState, &ValueUnion)))
    191192    {
     
    365366    RTGETOPTSTATE GetState;
    366367    // start at 0 because main() has hacked both the argc and argv given to us
    367     RTGetOptInit(&GetState, a->argc, a->argv, g_aModifyHardDiskOptions, RT_ELEMENTS(g_aModifyHardDiskOptions), 0, 0 /* fFlags */);
     368    RTGetOptInit(&GetState, a->argc, a->argv, g_aModifyHardDiskOptions, RT_ELEMENTS(g_aModifyHardDiskOptions),
     369                 0, RTGETOPTINIT_FLAGS_NO_STD_OPTS);
    368370    while ((c = RTGetOpt(&GetState, &ValueUnion)))
    369371    {
     
    532534    RTGETOPTSTATE GetState;
    533535    // start at 0 because main() has hacked both the argc and argv given to us
    534     RTGetOptInit(&GetState, a->argc, a->argv, g_aCloneHardDiskOptions, RT_ELEMENTS(g_aCloneHardDiskOptions), 0, 0 /* fFlags */);
     536    RTGetOptInit(&GetState, a->argc, a->argv, g_aCloneHardDiskOptions, RT_ELEMENTS(g_aCloneHardDiskOptions),
     537                 0, RTGETOPTINIT_FLAGS_NO_STD_OPTS);
    535538    while ((c = RTGetOpt(&GetState, &ValueUnion)))
    536539    {
     
    751754    RTGETOPTSTATE GetState;
    752755    // start at 0 because main() has hacked both the argc and argv given to us
    753     RTGetOptInit(&GetState, argc, argv, g_aConvertFromRawHardDiskOptions, RT_ELEMENTS(g_aConvertFromRawHardDiskOptions), 0, 0 /* fFlags */);
     756    RTGetOptInit(&GetState, argc, argv, g_aConvertFromRawHardDiskOptions, RT_ELEMENTS(g_aConvertFromRawHardDiskOptions),
     757                 0, RTGETOPTINIT_FLAGS_NO_STD_OPTS);
    754758    while ((c = RTGetOpt(&GetState, &ValueUnion)))
    755759    {
     
    943947    RTGETOPTSTATE GetState;
    944948    // start at 0 because main() has hacked both the argc and argv given to us
    945     RTGetOptInit(&GetState, a->argc, a->argv, g_aAddiSCSIDiskOptions, RT_ELEMENTS(g_aAddiSCSIDiskOptions), 0, 0 /* fFlags */);
     949    RTGetOptInit(&GetState, a->argc, a->argv, g_aAddiSCSIDiskOptions, RT_ELEMENTS(g_aAddiSCSIDiskOptions),
     950                 0, RTGETOPTINIT_FLAGS_NO_STD_OPTS);
    946951    while ((c = RTGetOpt(&GetState, &ValueUnion)))
    947952    {
     
    11041109    RTGETOPTSTATE GetState;
    11051110    // start at 0 because main() has hacked both the argc and argv given to us
    1106     RTGetOptInit(&GetState, a->argc, a->argv, g_aShowHardDiskInfoOptions, RT_ELEMENTS(g_aShowHardDiskInfoOptions), 0, 0 /* fFlags */);
     1111    RTGetOptInit(&GetState, a->argc, a->argv, g_aShowHardDiskInfoOptions, RT_ELEMENTS(g_aShowHardDiskInfoOptions),
     1112                 0, RTGETOPTINIT_FLAGS_NO_STD_OPTS);
    11071113    while ((c = RTGetOpt(&GetState, &ValueUnion)))
    11081114    {
     
    13101316    RTGETOPTSTATE GetState;
    13111317    // start at 0 because main() has hacked both the argc and argv given to us
    1312     RTGetOptInit(&GetState, a->argc, a->argv, g_aOpenMediumOptions, RT_ELEMENTS(g_aOpenMediumOptions), 0, 0 /* fFlags */);
     1318    RTGetOptInit(&GetState, a->argc, a->argv, g_aOpenMediumOptions, RT_ELEMENTS(g_aOpenMediumOptions),
     1319                 0, RTGETOPTINIT_FLAGS_NO_STD_OPTS);
    13131320    while ((c = RTGetOpt(&GetState, &ValueUnion)))
    13141321    {
     
    14851492    RTGETOPTSTATE GetState;
    14861493    // start at 0 because main() has hacked both the argc and argv given to us
    1487     RTGetOptInit(&GetState, a->argc, a->argv, g_aCloseMediumOptions, RT_ELEMENTS(g_aCloseMediumOptions), 0, 0 /* fFlags */);
     1494    RTGetOptInit(&GetState, a->argc, a->argv, g_aCloseMediumOptions, RT_ELEMENTS(g_aCloseMediumOptions),
     1495                 0, RTGETOPTINIT_FLAGS_NO_STD_OPTS);
    14881496    while ((c = RTGetOpt(&GetState, &ValueUnion)))
    14891497    {
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageHostonly.cpp

    r24879 r26517  
    173173                 RT_ELEMENTS(g_aHostOnlyIPOptions),
    174174                 index,
    175                  0 /* fFlags */);
     175                 RTGETOPTINIT_FLAGS_NO_STD_OPTS);
    176176    while ((c = RTGetOpt(&GetState, &ValueUnion)))
    177177    {
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageImport.cpp

    r25165 r26517  
    129129    RTGETOPTSTATE GetState;
    130130    // start at 0 because main() has hacked both the argc and argv given to us
    131     RTGetOptInit(&GetState, arg->argc, arg->argv, g_aImportApplianceOptions, RT_ELEMENTS(g_aImportApplianceOptions), 0, 0 /* fFlags */);
     131    RTGetOptInit(&GetState, arg->argc, arg->argv, g_aImportApplianceOptions, RT_ELEMENTS(g_aImportApplianceOptions),
     132                 0, RTGETOPTINIT_FLAGS_NO_STD_OPTS);
    132133    while ((c = RTGetOpt(&GetState, &ValueUnion)))
    133134    {
     
    742743        // start at 0 because main() has hacked both the argc and argv given to us
    743744        RTGetOptInit(&GetState, a->argc, a->argv, g_aExportOptions,
    744                      RT_ELEMENTS(g_aExportOptions), 0, 0 /* fFlags */);
     745                     RT_ELEMENTS(g_aExportOptions), 0, RTGETOPTINIT_FLAGS_NO_STD_OPTS);
    745746
    746747        Utf8Str strProductUrl;
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageInfo.cpp

    r26294 r26517  
    19651965    RTGETOPTSTATE GetState;
    19661966    // start at 0 because main() has hacked both the argc and argv given to us
    1967     RTGetOptInit(&GetState, a->argc, a->argv, g_aShowVMInfoOptions, RT_ELEMENTS(g_aShowVMInfoOptions), 0, 0 /* fFlags */);
     1967    RTGetOptInit(&GetState, a->argc, a->argv, g_aShowVMInfoOptions, RT_ELEMENTS(g_aShowVMInfoOptions),
     1968                 0, RTGETOPTINIT_FLAGS_NO_STD_OPTS);
    19681969    while ((c = RTGetOpt(&GetState, &ValueUnion)))
    19691970    {
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageList.cpp

    r25019 r26517  
    126126    RTGETOPTUNION ValueUnion;
    127127    RTGETOPTSTATE GetState;
    128     RTGetOptInit(&GetState, a->argc, a->argv, g_aListOptions, RT_ELEMENTS(g_aListOptions), 0, 0 /* fFlags */);
     128    RTGetOptInit(&GetState, a->argc, a->argv, g_aListOptions, RT_ELEMENTS(g_aListOptions),
     129                 0, RTGETOPTINIT_FLAGS_NO_STD_OPTS);
    129130    while ((c = RTGetOpt(&GetState, &ValueUnion)))
    130131    {
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageMisc.cpp

    r26323 r26517  
    115115    RTGETOPTSTATE GetState;
    116116    // start at 0 because main() has hacked both the argc and argv given to us
    117     RTGetOptInit(&GetState, a->argc, a->argv, g_aUnregisterVMOptions, RT_ELEMENTS(g_aUnregisterVMOptions), 0, 0 /* fFlags */);
     117    RTGetOptInit(&GetState, a->argc, a->argv, g_aUnregisterVMOptions, RT_ELEMENTS(g_aUnregisterVMOptions),
     118                 0, RTGETOPTINIT_FLAGS_NO_STD_OPTS);
    118119    while ((c = RTGetOpt(&GetState, &ValueUnion)))
    119120    {
     
    285286    RTGETOPTSTATE GetState;
    286287    // start at 0 because main() has hacked both the argc and argv given to us
    287     RTGetOptInit(&GetState, a->argc, a->argv, s_aStartVMOptions, RT_ELEMENTS(s_aStartVMOptions), 0, 0 /* fFlags */);
     288    RTGetOptInit(&GetState, a->argc, a->argv, s_aStartVMOptions, RT_ELEMENTS(s_aStartVMOptions),
     289                 0, RTGETOPTINIT_FLAGS_NO_STD_OPTS);
    288290    while ((c = RTGetOpt(&GetState, &ValueUnion)))
    289291    {
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageModifyVM.cpp

    r26294 r26517  
    269269
    270270    RTGetOptInit(&GetOptState, a->argc, a->argv, g_aModifyVMOptions,
    271                  RT_ELEMENTS(g_aModifyVMOptions), 1, 0 /* fFlags */);
     271                 RT_ELEMENTS(g_aModifyVMOptions), 1, RTGETOPTINIT_FLAGS_NO_STD_OPTS);
    272272
    273273    while (   SUCCEEDED (rc)
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageSnapshot.cpp

    r26163 r26517  
    279279            };
    280280            RTGETOPTSTATE GetOptState;
    281             RTGetOptInit(&GetOptState, a->argc, a->argv, s_aTakeOptions, RT_ELEMENTS(s_aTakeOptions), 3, 0 /*fFlags*/);
     281            RTGetOptInit(&GetOptState, a->argc, a->argv, s_aTakeOptions, RT_ELEMENTS(s_aTakeOptions),
     282                         3, RTGETOPTINIT_FLAGS_NO_STD_OPTS);
    282283            int ch;
    283284            RTGETOPTUNION Value;
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageStorageController.cpp

    r25676 r26517  
    8383
    8484    RTGetOptInit(&GetState, a->argc, a->argv, g_aStorageAttachOptions,
    85                  RT_ELEMENTS(g_aStorageAttachOptions), 1, 0 /* fFlags */);
     85                 RT_ELEMENTS(g_aStorageAttachOptions), 1, RTGETOPTINIT_FLAGS_NO_STD_OPTS);
    8686
    8787    while (   SUCCEEDED(rc)
     
    679679
    680680    RTGetOptInit (&GetState, a->argc, a->argv, g_aStorageControllerOptions,
    681                   RT_ELEMENTS(g_aStorageControllerOptions), 1, 0 /* fFlags */);
     681                  RT_ELEMENTS(g_aStorageControllerOptions), 1, RTGETOPTINIT_FLAGS_NO_STD_OPTS);
    682682
    683683    while (   SUCCEEDED(rc)
  • trunk/src/VBox/HostDrivers/Support/testcase/SUPLoggerCtl.cpp

    r26498 r26517  
    3333*******************************************************************************/
    3434#include <VBox/sup.h>
     35#include <iprt/buildconfig.h>
    3536#include <iprt/initterm.h>
    3637#include <iprt/getopt.h>
     
    7980        { "--what",     'o', RTGETOPT_REQ_STRING },
    8081        { "--which",    'l', RTGETOPT_REQ_STRING },
    81         { "--help",     'h', 0 },
    8282    };
    8383
     
    141141                return usage();
    142142
     143            case 'V':
     144                RTPrintf("%sr%s\n", RTBldCfgVersion(), RTBldCfgRevisionStr());
     145                return 0;
     146
    143147            case VINF_GETOPT_NOT_OPTION:
    144148                RTStrmPrintf(g_pStdErr, "SUPLoggerCtl: error: Unexpected argument '%s'.\n", Val.psz);
     
    146150
    147151            default:
    148                 if (ch > 0)
    149                 {
    150                     if (RT_C_IS_GRAPH(ch))
    151                         RTStrmPrintf(g_pStdErr, "SUPLoggerCtl: error: unhandled option: -%c\n", ch);
    152                     else
    153                         RTStrmPrintf(g_pStdErr, "SUPLoggerCtl: error: unhandled option: %i\n", ch);
    154                 }
    155                 else if (ch == VERR_GETOPT_UNKNOWN_OPTION)
    156                     RTStrmPrintf(g_pStdErr, "SUPLoggerCtl: error: unknown option: %s\n", Val.psz);
    157                 else if (Val.pDef)
    158                     RTStrmPrintf(g_pStdErr, "SUPLoggerCtl: error: %s: %Rrs\n", Val.pDef->pszLong, ch);
    159                 else
    160                     RTStrmPrintf(g_pStdErr, "SUPLoggerCtl: error: %Rrs\n", ch);
    161                 return 1;
     152                return RTGetOptPrintError(ch, &Val);
    162153        }
    163154    }
  • trunk/src/VBox/HostDrivers/Support/testcase/tstGIP-2.cpp

    r22077 r26517  
    6666    RTGETOPTUNION ValueUnion;
    6767    RTGETOPTSTATE GetState;
    68     RTGetOptInit(&GetState, argc, argv, g_aOptions, RT_ELEMENTS(g_aOptions), 1, 0 /* fFlags */);
     68    RTGetOptInit(&GetState, argc, argv, g_aOptions, RT_ELEMENTS(g_aOptions), 1, RTGETOPTINIT_FLAGS_NO_STD_OPTS);
    6969    while ((ch = RTGetOpt(&GetState, &ValueUnion)))
    7070    {
     
    8787                break;
    8888
    89             case VINF_GETOPT_NOT_OPTION:
    90                 RTPrintf("tstGIP-2: syntax error: %s\n", ValueUnion.psz);
    91                 return 1;
    92 
    9389            default:
    94                 if (ch < 0)
    95                     RTPrintf("tstGIP-2: %Rrc: %s\n", ch, ValueUnion.psz);
    96                 else
    97                     RTPrintf("tstGIP-2: syntax error: %s\n", ValueUnion.psz);
    98                 return 1;
     90                return RTGetOptPrintError(ch, &ValueUnion);
    9991        }
    10092    }
  • trunk/src/VBox/HostDrivers/Support/testcase/tstSupLoadModule.cpp

    r26498 r26517  
    6161    static const RTGETOPTDEF s_aOptions[] =
    6262    {
    63         { "--help",             'h', 0 }
     63        { "--help",             'h', RTGETOPT_REQ_NOTHING } /* (dummy entry) */
    6464    };
    6565
     
    9696                return 1;
    9797
     98            case 'V':
     99                RTPrintf("$Revision$\n");
     100                return 0;
     101
    98102            default:
    99103                return RTGetOptPrintError(ch, &ValueUnion);
  • trunk/src/VBox/HostDrivers/Support/win/SUPSvc-win.cpp

    r22077 r26517  
    270270    RTGETOPTUNION Value;
    271271    RTGETOPTSTATE GetState;
    272     RTGetOptInit(&GetState, argc, argv, s_aOptions, RT_ELEMENTS(s_aOptions), 0, 0 /* fFlags*/);
     272    RTGetOptInit(&GetState, argc, argv, s_aOptions, RT_ELEMENTS(s_aOptions), 0, RTGETOPTINIT_FLAGS_NO_STD_OPTS);
    273273    while ((ch = RTGetOpt(&GetState, &Value)))
    274274        switch (ch)
  • trunk/src/VBox/Main/generic/OpenGLTestApp.cpp

    r26098 r26517  
    232232            { "--log",            'l',   RTGETOPT_REQ_STRING },
    233233#endif
    234             { "--help",           'h',   RTGETOPT_REQ_NOTHING },
    235234        };
    236235
     
    307306                    break;
    308307
     308                case 'V':
     309                    RTPrintf("$Revision: $\n");
     310                    return 0;
     311
    309312                case VERR_GETOPT_UNKNOWN_OPTION:
    310313                case VINF_GETOPT_NOT_OPTION:
     
    312315
    313316                default:
     317                    /* complain? RTGetOptPrintError(rc, &Val); */
    314318                    break;
    315319            }
    316320
    317             if(rc)
     321            if (rc)
    318322                break;
    319323        }
  • trunk/src/VBox/Main/webservice/vboxweb.cpp

    r26450 r26517  
    3232#include <VBox/version.h>
    3333
     34#include <iprt/buildconfig.h>
    3435#include <iprt/thread.h>
    3536#include <iprt/rand.h>
     
    143144static const RTGETOPTDEF g_aOptions[]
    144145    = {
    145         { "--help",             'h', RTGETOPT_REQ_NOTHING },
     146        { "--help",             'h', RTGETOPT_REQ_NOTHING }, /* for DisplayHelp() */
    146147#if defined(RT_OS_DARWIN) || defined(RT_OS_LINUX) || defined (RT_OS_SOLARIS) || defined(RT_OS_FREEBSD)
    147148        { "--background",       'b', RTGETOPT_REQ_NOTHING },
     
    588589    RTGETOPTUNION ValueUnion;
    589590    RTGETOPTSTATE GetState;
    590     RTGetOptInit(&GetState, argc, argv, g_aOptions, RT_ELEMENTS(g_aOptions), 1, 0 /* fFlags */);
     591    RTGetOptInit(&GetState, argc, argv, g_aOptions, RT_ELEMENTS(g_aOptions), 1, 0 /*fFlags*/);
    591592    while ((c = RTGetOpt(&GetState, &ValueUnion)))
    592593    {
     
    629630            case 'h':
    630631                DisplayHelp();
    631                 exit(0);
    632             break;
     632            return 0;
    633633
    634634            case 'v':
     
    641641            break;
    642642#endif
    643             case VINF_GETOPT_NOT_OPTION:
    644                 RTStrmPrintf(g_pStdErr, "unhandled parameter: %s\n", ValueUnion.psz);
    645             return 1;
     643            case 'V':
     644                RTPrintf("%sr%s\n", RTBldCfgVersion(), RTBldCfgRevisionStr());
     645            return 0;
    646646
    647647            default:
    648                 if (c > 0)
    649                 {
    650                     if (RT_C_IS_GRAPH(c))
    651                         RTStrmPrintf(g_pStdErr, "unhandled option: -%c", c);
    652                     else
    653                         RTStrmPrintf(g_pStdErr, "unhandled option: %i", c);
    654                 }
    655                 else if (c == VERR_GETOPT_UNKNOWN_OPTION)
    656                     RTStrmPrintf(g_pStdErr, "unknown option: %s", ValueUnion.psz);
    657                 else if (ValueUnion.pDef)
    658                     RTStrmPrintf(g_pStdErr, "%s: %Rrs", ValueUnion.pDef->pszLong, c);
    659                 else
    660                     RTStrmPrintf(g_pStdErr, "%Rrs", c);
    661                 exit(1);
    662             break;
     648                rc = RTGetOptPrintError(c, &ValueUnion);
     649            return rc;
    663650        }
    664651    }
  • trunk/src/VBox/Main/xpcom/server.cpp

    r26186 r26517  
    3939#include <VBox/version.h>
    4040
     41#include <iprt/buildconfig.h>
    4142#include <iprt/initterm.h>
    4243#include <iprt/critsect.h>
     
    798799            }
    799800
     801            case 'h':
     802            {
     803                RTPrintf("no help\n");
     804                return 1;
     805            }
     806
     807            case 'V':
     808            {
     809                RTPrintf("%sr%s\n", RTBldCfgVersion(), RTBldCfgRevisionStr());
     810                return 0;
     811            }
     812
    800813            default:
    801814                return RTGetOptPrintError(vrc, &ValueUnion);
  • trunk/src/VBox/NetworkServices/DHCP/VBoxNetDHCP.cpp

    r25771 r26517  
    710710        { "--upper-ip",       'u',   RTGETOPT_REQ_IPV4ADDR },
    711711        { "--netmask",        'm',   RTGETOPT_REQ_IPV4ADDR },
    712 
    713         { "--help",           'h',   RTGETOPT_REQ_NOTHING },
    714         { "--version ",       'V',   RTGETOPT_REQ_NOTHING },
    715712    };
    716713
    717714    RTGETOPTSTATE State;
    718     int rc = RTGetOptInit(&State, argc, argv, &s_aOptionDefs[0], RT_ELEMENTS(s_aOptionDefs), 0, 0);
     715    int rc = RTGetOptInit(&State, argc, argv, &s_aOptionDefs[0], RT_ELEMENTS(s_aOptionDefs), 0, 0 /*fFlags*/);
    719716    AssertRCReturn(rc, 49);
    720717
     
    833830                return 1;
    834831
    835             case VERR_GETOPT_UNKNOWN_OPTION:
    836             case VINF_GETOPT_NOT_OPTION:
    837                 RTPrintf("Unknown option '%s'. Use --help for more information.\n", Val.psz);
    838                 return 1;
    839 
    840832            default:
    841                 break;
     833                rc = RTGetOptPrintError(rc, &Val);
     834                RTPrintf("Use --help for more information.\n");
     835                return rc;
    842836        }
    843837    }
  • trunk/src/VBox/Runtime/testcase/tstHandleTable.cpp

    r17093 r26517  
    460460        { "--max",          'm', RTGETOPT_REQ_UINT32 },
    461461        { "--threads",      't', RTGETOPT_REQ_UINT32 },
    462         { "--help",         'h', RTGETOPT_REQ_NOTHING },
    463         { "--?",            '?', RTGETOPT_REQ_NOTHING },
    464462    };
    465463
     
    489487                break;
    490488
    491             case '?':
    492489            case 'h':
    493490                RTPrintf("syntax: tstHandleTable [-b <base>] [-m <max>] [-t <threads>]\n");
    494491                return 1;
    495492
    496             case VINF_GETOPT_NOT_OPTION:
    497                 RTPrintf("tstHandleTable: unexpected non-option: %s\n", Value.psz);
    498                 break;
     493            case 'V':
     494                RTPrintf("$Revision: $\n");
     495                return 0;
    499496
    500497            default:
    501                 if (RT_SUCCESS(ch))
    502                     RTPrintf("tstHandleTable: invalid argument (%#x): %s\n", ch, Value.psz);
    503                 else
    504                     RTPrintf("tstHandleTable: invalid argument: %Rrc - \n", ch, Value.pDef->pszLong);
    505                 return 1;
     498                return RTGetOptPrintError(ch, &Value);
    506499        }
    507500
  • trunk/src/VBox/Runtime/testcase/tstRTCritSect.cpp

    r25766 r26517  
    4747#include <iprt/mem.h>
    4848#include <iprt/semaphore.h>
     49#include <iprt/stream.h>
    4950#include <iprt/string.h>
    5051#include <iprt/test.h>
     
    495496                return 1;
    496497
    497             case VINF_GETOPT_NOT_OPTION:
    498                 RTTestIFailed("%Rrs\n", ch);
    499                 return RTTestSummaryAndDestroy(hTest);
     498            case 'V':
     499                RTPrintf("$Revision: $\n");
     500                return 0;
    500501
    501502            default:
    502                 if (ch > 0)
    503                 {
    504                     if (RT_C_IS_GRAPH(ch))
    505                         RTTestIFailed("unhandled option: -%c\n", ch);
    506                     else
    507                         RTTestIFailed("unhandled option: %i\n", ch);
    508                 }
    509                 else if (ch == VERR_GETOPT_UNKNOWN_OPTION)
    510                     RTTestIFailed("unknown option: %s\n", ValueUnion.psz);
    511                 else if (ValueUnion.pDef)
    512                     RTTestIFailed("%s: %Rrs\n", ValueUnion.pDef->pszLong, ch);
    513                 else
    514                     RTTestIFailed("%Rrs\n", ch);
    515                 return RTTestSummaryAndDestroy(hTest);
     503                return RTGetOptPrintError(ch, &ValueUnion);
    516504        }
    517505    }
  • trunk/src/VBox/Runtime/testcase/tstRTDigest.cpp

    r23507 r26517  
    300300
    301301             default:
    302                  if (ch > 0)
    303                  {
    304                      if (RT_C_IS_GRAPH(ch))
    305                          Error("unhandled option: -%c\n", ch);
    306                      else
    307                          Error("unhandled option: %i\n", ch);
    308                  }
    309                  else if (ch == VERR_GETOPT_UNKNOWN_OPTION)
    310                      Error("unknown option: %s\n", ValueUnion.psz);
    311                  else if (ValueUnion.pDef)
    312                      Error("%s: %Rrs\n", ValueUnion.pDef->pszLong, ch);
    313                  else
    314                      Error("%Rrs\n", ch);
    315                  return 1;
     302                return RTGetOptPrintError(ch, &ValueUnion);
    316303         }
    317304     }
  • trunk/src/VBox/Runtime/testcase/tstTSC.cpp

    r25000 r26517  
    420420        { "--duration",         'd', RTGETOPT_REQ_UINT32 },
    421421        { "--calc-frequency",   'f', RTGETOPT_REQ_NOTHING },
    422         { "--help",             'h', RTGETOPT_REQ_NOTHING }
    423422    };
    424423    int iArg = 1;
     
    430429        switch (ch)
    431430        {
    432             case 'd':   cMsDuration = Value.u32; break;
    433             case 'f':   fCalcFrequency = true; break;
     431            case 'd':   cMsDuration = Value.u32;
     432                break;
     433
     434            case 'f':   fCalcFrequency = true;
     435                break;
     436
    434437            case 'h':
    435438                RTPrintf("usage: tstTSC\n"
     
    437440                return 1;
    438441
    439             case VINF_GETOPT_NOT_OPTION:
    440                 RTStrmPrintf(g_pStdErr, "tstTSC: too many arguments\n");
    441                 break;
     442            case 'V':
     443                RTPrintf("$Revision: $\n");
     444                return 0;
    442445
    443446            default:
    444                 RTStrmPrintf(g_pStdErr, "tstTSC: Unknown arg or error (ch=%d)\n", ch);
    445                 return 1;
     447                return RTGetOptPrintError(ch, &Value);
    446448        }
    447449
  • trunk/src/VBox/VMM/testcase/tstCompressionBenchmark.cpp

    r23513 r26517  
    2626#include <iprt/asm.h>
    2727#include <iprt/assert.h>
     28#include <iprt/buildconfig.h>
    2829#include <iprt/crc.h>
    2930#include <iprt/ctype.h>
     
    248249        { "--page-file",      'f', RTGETOPT_REQ_STRING },
    249250        { "--offset",         'o', RTGETOPT_REQ_UINT64 },
    250         { "--help",           'h', RTGETOPT_REQ_NOTHING },
    251251    };
    252252
     
    315315                return 0;
    316316
     317            case 'V':
     318                RTPrintf("%sr%s\n", RTBldCfgVersion(), RTBldCfgRevisionStr());
     319                return 0;
     320
    317321            default:
    318                 if (rc == VINF_GETOPT_NOT_OPTION)
    319                     Error("unknown argument: %s\n", Val.psz);
    320                 else if (rc > 0)
    321                 {
    322                     if (RT_C_IS_GRAPH(rc))
    323                         Error("unhandled option: -%c\n", rc);
    324                     else
    325                         Error("unhandled option: %d\n", rc);
    326                 }
    327                 else if (rc == VERR_GETOPT_UNKNOWN_OPTION)
    328                     Error("unknown option: %s\n", Val.psz);
    329                 else if (Val.pDef)
    330                     Error("%s: %Rrs\n", Val.pDef->pszLong, rc);
    331                 else
    332                     Error("%Rrs\n", rc);
    333                 return 1;
     322                return RTGetOptPrintError(rc, &Val);
    334323        }
    335324    }
  • trunk/src/VBox/VMM/testcase/tstVMM.cpp

    r26153 r26517  
    205205        { "--cpus",          'c', RTGETOPT_REQ_UINT8 },
    206206        { "--test",          't', RTGETOPT_REQ_STRING },
    207         { "--help",          'h', 0 },
    208207    };
    209208    enum
     
    241240                return 1;
    242241
    243             case VINF_GETOPT_NOT_OPTION:
    244                 RTPrintf("tstVMM: syntax error: non option '%s'\n", ValueUnion.psz);
    245                 break;
     242            case 'V':
     243                RTPrintf("$Revision: $\n");
     244                return 0;
    246245
    247246            default:
    248                 if (ch > 0)
    249                 {
    250                     if (RT_C_IS_GRAPH(ch))
    251                         RTPrintf("tstVMM: unhandled option: -%c\n", ch);
    252                     else
    253                         RTPrintf("tstVMM: unhandled option: %i\n", ch);
    254                 }
    255                 else if (ch == VERR_GETOPT_UNKNOWN_OPTION)
    256                     RTPrintf("tstVMM: unknown option: %s\n", ValueUnion.psz);
    257                 else if (ValueUnion.pDef)
    258                     RTPrintf("tstVMM: %s: %Rrs\n", ValueUnion.pDef->pszLong, ch);
    259                 else
    260                     RTPrintf("tstVMM: %Rrs\n", ch);
    261                 return 1;
     247                return RTGetOptPrintError(ch, &ValueUnion);
    262248        }
    263249    }
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette