VirtualBox

Changeset 26517 in vbox for trunk/src/VBox/Main/webservice


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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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    }
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