VirtualBox

Changeset 69742 in vbox for trunk/src/VBox/Runtime/common


Ignore:
Timestamp:
Nov 18, 2017 4:58:38 AM (7 years ago)
Author:
vboxsync
Message:

IPRT: Added RTGetOptFormatError.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/misc/getopt.cpp

    r69111 r69742  
    828828RT_EXPORT_SYMBOL(RTGetOptPrintError);
    829829
     830
     831RTDECL(ssize_t) RTGetOptFormatError(char *pszBuf, size_t cbBuf, int ch, PCRTGETOPTUNION pValueUnion)
     832{
     833    ssize_t cchRet;
     834    if (ch == VINF_GETOPT_NOT_OPTION)
     835        cchRet = RTStrPrintf2(pszBuf, cbBuf, "Invalid parameter: %s", pValueUnion->psz);
     836    else if (ch > 0)
     837    {
     838        if (RT_C_IS_GRAPH(ch))
     839            cchRet = RTStrPrintf2(pszBuf, cbBuf, "Unhandled option: -%c", ch);
     840        else
     841            cchRet = RTStrPrintf2(pszBuf, cbBuf, "Unhandled option: %i (%#x)", ch, ch);
     842    }
     843    else if (ch == VERR_GETOPT_UNKNOWN_OPTION)
     844        cchRet = RTStrPrintf2(pszBuf, cbBuf, "Unknown option: '%s'", pValueUnion->psz);
     845    else if (pValueUnion->pDef && ch == VERR_GETOPT_INVALID_ARGUMENT_FORMAT)
     846        /** @todo r=klaus not really ideal, as the value isn't available */
     847        cchRet = RTStrPrintf2(pszBuf, cbBuf, "The value given '%s' has an invalid format.", pValueUnion->pDef->pszLong);
     848    else if (pValueUnion->pDef)
     849        cchRet = RTStrPrintf2(pszBuf, cbBuf, "%s: %Rrs\n", pValueUnion->pDef->pszLong, ch);
     850    else
     851        cchRet = RTStrPrintf2(pszBuf, cbBuf, "%Rrs\n", ch);
     852
     853    return cchRet;
     854}
     855RT_EXPORT_SYMBOL(RTGetOptFormatError);
     856
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