static int GetPropertyIndex()

in CodeSnippets/Peripherals/ADC/AdvancedFunctions/advanced_functions.c [185:205]


static int GetPropertyIndex(const struct iio_ioctl_chan_spec *channelSpec, const char *propertyName)
{
    if (!channelSpec) {
        Log_Debug("ERROR: Channel specification input parameter is NULL.\n");
        return -1;
    }

    int propertyIndex = 0;
    const struct iio_ioctl_chan_spec_ext_info *extendedChannelSpecInfo = channelSpec->ext_info;
    while (extendedChannelSpecInfo) {
        if (extendedChannelSpecInfo->name &&
            strcmp(propertyName, extendedChannelSpecInfo->name) == 0) {
            return propertyIndex;
        }
        ++propertyIndex;
        extendedChannelSpecInfo = extendedChannelSpecInfo->next;
    }

    Log_Debug("ERROR: Failed to retrieve property index for property name %s.\n", propertyName);
    return -1;
}