VirtualBox

Changeset 24825 in vbox


Ignore:
Timestamp:
Nov 20, 2009 2:41:05 PM (15 years ago)
Author:
vboxsync
Message:

IPRT: Added RTMsgError, RTMsgErrorV and RTGetOptPrintError.

Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/getopt.h

    r24140 r24825  
    359359RTDECL(int) RTGetOptFetchValue(PRTGETOPTSTATE pState, PRTGETOPTUNION pValueUnion, uint32_t fFlags);
    360360
     361/**
     362 * Print error messages for a RTGetOpt default case.
     363 *
     364 * Uses RTMsgError.
     365 *
     366 * @returns Suitable exit code.
     367 *
     368 * @param   ch          The RTGetOpt return value.
     369 * @param   pValueUnion The value union returned by RTGetOpt.
     370 */
     371RTDECL(int) RTGetOptPrintError(int ch, PCRTGETOPTUNION pValueUnion);
     372
    361373/** @} */
    362374
  • trunk/src/VBox/Runtime/Makefile.kmk

    r24662 r24825  
    239239        common/misc/handletablectx.cpp \
    240240        common/misc/handletablesimple.cpp \
     241        common/misc/message.cpp \
    241242        common/misc/once.cpp \
    242243        common/misc/req.cpp \
  • trunk/src/VBox/Runtime/common/misc/getopt.cpp

    r24140 r24825  
    3636#include "internal/iprt.h"
    3737
    38 #include <iprt/err.h>
    39 #include <iprt/string.h>
    4038#include <iprt/assert.h>
    4139#include <iprt/ctype.h>
     40#include <iprt/err.h>
     41#include <iprt/message.h>
     42#include <iprt/string.h>
    4243#include <iprt/uuid.h>
    4344
     
    640641}
    641642RT_EXPORT_SYMBOL(RTGetOptFetchValue);
     643
     644
     645RTDECL(int) RTGetOptPrintError(int ch, PCRTGETOPTUNION pValueUnion)
     646{
     647    if (ch == VINF_GETOPT_NOT_OPTION)
     648        RTMsgError("Invalid parameter: %s", pValueUnion->psz);
     649    else if (ch > 0)
     650    {
     651        if (RT_C_IS_GRAPH(ch))
     652            RTMsgError("Unhandled option: -%c", ch);
     653        else
     654            RTMsgError("Unhandled option: %i (%#x)", ch, ch);
     655    }
     656    else if (ch == VERR_GETOPT_UNKNOWN_OPTION)
     657        RTMsgError("Unknown option: '%s'", pValueUnion->psz);
     658    else if (pValueUnion->pDef)
     659        RTMsgError("%s: %Rrs\n", pValueUnion->pDef->pszLong, ch);
     660    else
     661        RTMsgError("%Rrs\n", ch);
     662
     663    return 2; /** @todo add defines for EXIT_SUCCESS, EXIT_FAILURE, EXIT_INVAL, etc... */
     664}
     665RT_EXPORT_SYMBOL(RTGetOptPrintError);
     666
Note: See TracChangeset for help on using the changeset viewer.

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