Skip to content

cbor_value_byte_string_equals ? #223

@jeremyherbert

Description

@jeremyherbert

Hi,

There is a function in cborparser.c: cbor_value_text_string_equals which checks if a char array is equal to the cbor value string. It would be helpful to also have this for a byte string, ie:

CborError cbor_value_byte_string_equals(const CborValue *value, const char *string, size_t len, bool *result)
{
    CborValue copy = *value;
    CborError err = cbor_value_skip_tag(&copy);
    if (err)
        return err;
    if (!cbor_value_is_byte_string(&copy)) {
        *result = false;
        return CborNoError;
    }

    return iterate_string_chunks(&copy, CONST_CAST(char *, string), &len, result, NULL, iterate_memcmp);
}

This can't easily be implemented outside of the cborparser.c file because iterate_string_chunks is a static method contained to just this file.

I am happy to create a PR with this if that would help (I'm also happy to have someone else add it too), but I just wanted to check if this would be accepted?

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions