Exemplo n.º 1
0
void mpack_expect_utf8_cstr(mpack_reader_t* reader, char* buf, size_t bufsize) {
    size_t length = mpack_expect_cstr_unchecked(reader, buf, bufsize);

    // check encoding
    if (!mpack_utf8_check_no_null(buf, length)) {
        buf[0] = 0;
        mpack_reader_flag_error(reader, mpack_error_type);
    }
}
Exemplo n.º 2
0
void mpack_read_utf8_cstr(mpack_reader_t* reader, char* buf, size_t buffer_size, size_t byte_count) {
    mpack_read_cstr_unchecked(reader, buf, buffer_size, byte_count);

    // check encoding
    if (mpack_reader_error(reader) == mpack_ok && !mpack_utf8_check_no_null(buf, byte_count)) {
        buf[0] = 0;
        mpack_reader_flag_error(reader, mpack_error_type);
    }
}
Exemplo n.º 3
0
char* mpack_expect_utf8_cstr_alloc(mpack_reader_t* reader, size_t maxsize) {
    size_t length;
    char* str = mpack_expect_cstr_alloc_unchecked(reader, maxsize, &length);

    if (str && !mpack_utf8_check_no_null(str, length)) {
        MPACK_FREE(str);
        mpack_reader_flag_error(reader, mpack_error_type);
        return NULL;
    }

    return str;
}