openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/libnl/1_3.4.0-r0/libnl-3.4.0/lib/utils.c
long nl_prob2int(const char* str)
{
    char* p;
    double d = strtod(str, &p);

    if (p == str)
        return -NLE_INVAL;

    if (d > 1.0)
        d /= 100.0f;

    if (d > 1.0f || d < 0.0f)
        return -NLE_RANGE;

    if (*p && strcmp(p, "%") != 0)
        return -NLE_INVAL;

    return (long)(((d * NL_PROB_MAX) + 0.5));
}
/**
 * Convert a character string to a probability
 * @arg str		probability encoded as character string
 *
 * Converts the specified probability as character to the
 * corresponding probability number.
 *
 * Supported formats are:
 *  - 0.0-1.0
 *  - 0%-100%
 *
 * @return The probability relative to NL_PROB_MIN and NL_PROB_MAX
 */
Convert a character string to a probability
@arg str             probability encoded as character string

Converts the specified probability as character to the
corresponding probability number.



@return The probability relative to NL_PROB_MIN and NL_PROB_MAX
Convert a character string to a probability @arg str probability encoded as character string Converts the specified probability as character to the corresponding probability number . @return The probability relative to NL_PROB_MIN and NL_PROB_MAX
long nl_prob2int(const char* str)
{
    char* p;
    double d = strtod(str, &p);
    if (p == str)
        return -NLE_INVAL;
    if (d > 1.0)
        d /= 100.0f;
    if (d > 1.0f || d < 0.0f)
        return -NLE_RANGE;
    if (*p && strcmp(p, "%") != 0)
        return -NLE_INVAL;
    return (long)(((d * NL_PROB_MAX) + 0.5));
}
long nl_prob2int ( const char * str ) { char * p ; double d = strtod ( str , & p ) ; if ( p == str ) return - NLE_INVAL ; if ( d > 1.0 ) d /= 100.0f ; if ( d > 1.0f || d < 0.0f ) return - NLE_RANGE ; if ( * p && strcmp ( p , " " ) != 0 ) return - NLE_INVAL ; return ( long ) ( ( ( d * NL_PROB_MAX ) + 0.5 ) ) ; }
Convert a character string to a probability
 @arg str             probability encoded as character string
Convert a character string to a probability @arg str probability encoded as character string