openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/libcap/2.27-r0/libcap-2.27/libcap/cap_flag.c
int cap_set_flag(cap_t cap_d, cap_flag_t set, int no_values,
                 const cap_value_t* array_values, cap_flag_value_t raise)
{
    /*
     * Do we have a set and a place to store its value?
     * Is it a known capability?
     */

    if (good_cap_t(cap_d) && no_values > 0 && no_values <= __CAP_BITS &&
        (set >= 0) && (set < NUMBER_OF_CAP_SETS) &&
        (raise == CAP_SET || raise == CAP_CLEAR))
    {
        int i;
        for (i = 0; i < no_values; ++i)
        {
            if (array_values[i] < 0 || array_values[i] >= __CAP_BITS)
            {
                _cap_debug("weird capability (%d) - skipped", array_values[i]);
            }
            else
            {
                int value = array_values[i];

                if (raise == CAP_SET)
                {
                    cap_d->raise_cap(value, set);
                }
                else
                {
                    cap_d->lower_cap(value, set);
                }
            }
        }
        return 0;
    }
    else
    {

        _cap_debug("invalid arguments");
        errno = EINVAL;
        return -1;
    }
}
/*
 * raise/lower a selection of capabilities
 */
raise/lower a selection of capabilities
raise / lower a selection of capabilities
int cap_set_flag(cap_t cap_d, cap_flag_t set, int no_values,
                 const cap_value_t* array_values, cap_flag_value_t raise)
{
    if (good_cap_t(cap_d) && no_values > 0 && no_values <= __CAP_BITS &&
        (set >= 0) && (set < NUMBER_OF_CAP_SETS) &&
        (raise == CAP_SET || raise == CAP_CLEAR))
    {
        int i;
        for (i = 0; i < no_values; ++i)
        {
            if (array_values[i] < 0 || array_values[i] >= __CAP_BITS)
            {
                _cap_debug("weird capability (%d) - skipped", array_values[i]);
            }
            else
            {
                int value = array_values[i];
                if (raise == CAP_SET)
                {
                    cap_d->raise_cap(value, set);
                }
                else
                {
                    cap_d->lower_cap(value, set);
                }
            }
        }
        return 0;
    }
    else
    {
        _cap_debug("invalid arguments");
        errno = EINVAL;
        return -1;
    }
}
int cap_set_flag ( cap_t cap_d , cap_flag_t set , int no_values , const cap_value_t * array_values , cap_flag_value_t raise ) { if ( good_cap_t ( cap_d ) && no_values > 0 && no_values <= __CAP_BITS && ( set >= 0 ) && ( set < NUMBER_OF_CAP_SETS ) && ( raise == CAP_SET || raise == CAP_CLEAR ) ) { int i ; for ( i = 0 ; i < no_values ; ++ i ) { if ( array_values [ i ] < 0 || array_values [ i ] >= __CAP_BITS ) { _cap_debug ( " " , array_values [ i ] ) ; } else { int value = array_values [ i ] ; if ( raise == CAP_SET ) { cap_d -> raise_cap ( value , set ) ; } else { cap_d -> lower_cap ( value , set ) ; } } } return 0 ; } else { _cap_debug ( " " ) ; errno = EINVAL ; return -1 ; } }
raise/lower a selection of capabilities
raise / lower a selection of capabilities
/*
     * Do we have a set and a place to store its value?
     * Is it a known capability?
     */