external/libwebmdec/src/open-callbacks.c
static int nestegg_read(void *buffer, size_t length, void *userdata)
{
    webmdec_t *handle = (webmdec_t *)userdata;
    if (handle->data_length >= 0) {
        const long current_pos =
            (*handle->callbacks.tell)(handle->callback_data);
        if ((long)length > handle->data_length - current_pos) {
            return 0;
        }
    }
    const long bytes_read =
        (*handle->callbacks.read)(handle->callback_data, buffer, (long)length);
    if (bytes_read != (long)length) {
        if (handle->data_length >= 0) {
            /* This should never fail; treat failure as a fatal error. */
            handle->read_error_flag = 1;
            return -1;
        } else {
            /* We probably just hit the end of the stream. */
            return 0;
        }
    }
    return 1;
}
/*
 * libnestegg uses a slightly different I/O interface than our callbacks,
 * so we need to translate.
 */
libnestegg uses a slightly different I/O interface than our callbacks,
so we need to translate.
libnestegg uses a slightly different I / O interface than our callbacks so we need to translate .
static int nestegg_read(void *buffer, size_t length, void *userdata)
{
    webmdec_t *handle = (webmdec_t *)userdata;
    if (handle->data_length >= 0) {
        const long current_pos =
            (*handle->callbacks.tell)(handle->callback_data);
        if ((long)length > handle->data_length - current_pos) {
            return 0;
        }
    }
    const long bytes_read =
        (*handle->callbacks.read)(handle->callback_data, buffer, (long)length);
    if (bytes_read != (long)length) {
        if (handle->data_length >= 0) {
            handle->read_error_flag = 1;
            return -1;
        } else {
            return 0;
        }
    }
    return 1;
}
static int nestegg_read ( void * buffer , size_t length , void * userdata ) { webmdec_t * handle = ( webmdec_t * ) userdata ; if ( handle -> data_length >= 0 ) { const long current_pos = ( * handle -> callbacks . tell ) ( handle -> callback_data ) ; if ( ( long ) length > handle -> data_length - current_pos ) { return 0 ; } } const long bytes_read = ( * handle -> callbacks . read ) ( handle -> callback_data , buffer , ( long ) length ) ; if ( bytes_read != ( long ) length ) { if ( handle -> data_length >= 0 ) { handle -> read_error_flag = 1 ; return -1 ; } else { return 0 ; } } return 1 ; }
libnestegg uses a slightly different I/O interface than our callbacks,
 so we need to translate.
libnestegg uses a slightly different I / O interface than our callbacks so we need to translate .
/* This should never fail; treat failure as a fatal error. */ /* We probably just hit the end of the stream. */