src/rdkafka_broker.c
int16_t rd_kafka_broker_ApiVersion_supported (rd_kafka_broker_t *rkb,
                                              int16_t ApiKey,
                                              int16_t minver, int16_t maxver,
                                              int *featuresp) {
        struct rd_kafka_ApiVersion skel = { .ApiKey = ApiKey };
        struct rd_kafka_ApiVersion ret = RD_ZERO_INIT, *retp;

        rd_kafka_broker_lock(rkb);
        if (featuresp)
                *featuresp = rkb->rkb_features;

        if (rkb->rkb_features & RD_KAFKA_FEATURE_UNITTEST) {
                /* For unit tests let the broker support everything. */
                rd_kafka_broker_unlock(rkb);
                return maxver;
        }

        retp = bsearch(&skel, rkb->rkb_ApiVersions, rkb->rkb_ApiVersions_cnt,
                       sizeof(*rkb->rkb_ApiVersions),
                       rd_kafka_ApiVersion_key_cmp);
        if (retp)
                ret = *retp;
        rd_kafka_broker_unlock(rkb);

        if (!retp)
                return -1;

        if (ret.MaxVer < maxver) {
                if (ret.MaxVer < minver)
                        return -1;
                else
                        return ret.MaxVer;
        } else if (ret.MinVer > maxver)
                return -1;
        else
                return maxver;
}
/**
 * @brief Check and return supported ApiVersion for \p ApiKey.
 *
 * @returns the highest supported ApiVersion in the specified range (inclusive)
 *          or -1 if the ApiKey is not supported or no matching ApiVersion.
 *          The current feature set is also returned in \p featuresp
 * @locks none
 * @locality any
 */
@brief Check and return supported ApiVersion for \p ApiKey.
@returns the highest supported ApiVersion in the specified range (inclusive)
or -1 if the ApiKey is not supported or no matching ApiVersion.
The current feature set is also returned in \p featuresp
@locks none
@locality any
@brief Check and return supported ApiVersion for \ p ApiKey . @returns the highest supported ApiVersion in the specified range ( inclusive ) or - 1 if the ApiKey is not supported or no matching ApiVersion . The current feature set is also returned in \ p featuresp @locks none @locality any
int16_t rd_kafka_broker_ApiVersion_supported (rd_kafka_broker_t *rkb,
                                              int16_t ApiKey,
                                              int16_t minver, int16_t maxver,
                                              int *featuresp) {
        struct rd_kafka_ApiVersion skel = { .ApiKey = ApiKey };
        struct rd_kafka_ApiVersion ret = RD_ZERO_INIT, *retp;
        rd_kafka_broker_lock(rkb);
        if (featuresp)
                *featuresp = rkb->rkb_features;
        if (rkb->rkb_features & RD_KAFKA_FEATURE_UNITTEST) {
                rd_kafka_broker_unlock(rkb);
                return maxver;
        }
        retp = bsearch(&skel, rkb->rkb_ApiVersions, rkb->rkb_ApiVersions_cnt,
                       sizeof(*rkb->rkb_ApiVersions),
                       rd_kafka_ApiVersion_key_cmp);
        if (retp)
                ret = *retp;
        rd_kafka_broker_unlock(rkb);
        if (!retp)
                return -1;
        if (ret.MaxVer < maxver) {
                if (ret.MaxVer < minver)
                        return -1;
                else
                        return ret.MaxVer;
        } else if (ret.MinVer > maxver)
                return -1;
        else
                return maxver;
}
int16_t rd_kafka_broker_ApiVersion_supported ( rd_kafka_broker_t * rkb , int16_t ApiKey , int16_t minver , int16_t maxver , int * featuresp ) { struct rd_kafka_ApiVersion skel = { . ApiKey = ApiKey } ; struct rd_kafka_ApiVersion ret = RD_ZERO_INIT , * retp ; rd_kafka_broker_lock ( rkb ) ; if ( featuresp ) * featuresp = rkb -> rkb_features ; if ( rkb -> rkb_features & RD_KAFKA_FEATURE_UNITTEST ) { rd_kafka_broker_unlock ( rkb ) ; return maxver ; } retp = bsearch ( & skel , rkb -> rkb_ApiVersions , rkb -> rkb_ApiVersions_cnt , sizeof ( * rkb -> rkb_ApiVersions ) , rd_kafka_ApiVersion_key_cmp ) ; if ( retp ) ret = * retp ; rd_kafka_broker_unlock ( rkb ) ; if ( ! retp ) return -1 ; if ( ret . MaxVer < maxver ) { if ( ret . MaxVer < minver ) return -1 ; else return ret . MaxVer ; } else if ( ret . MinVer > maxver ) return -1 ; else return maxver ; }
@brief Check and return supported ApiVersion for \p ApiKey.
@brief Check and return supported ApiVersion for \ p ApiKey .
/* For unit tests let the broker support everything. */