int cmdutils_read_file(const char *filename, char **bufptr, size_t *size)

{

    int ret;

    FILE *f = fopen(filename, "rb");



    if (!f) {

        av_log(NULL, AV_LOG_ERROR, "Cannot read file '%s': %s\n", filename,

               strerror(errno));

        return AVERROR(errno);

    }

    fseek(f, 0, SEEK_END);

    *size = ftell(f);

    fseek(f, 0, SEEK_SET);

    *bufptr = av_malloc(*size + 1);

    if (!*bufptr) {

        av_log(NULL, AV_LOG_ERROR, "Could not allocate file buffer\n");

        fclose(f);

        return AVERROR(ENOMEM);

    }

    ret = fread(*bufptr, 1, *size, f);

    if (ret < *size) {

        av_free(*bufptr);

        if (ferror(f)) {

            av_log(NULL, AV_LOG_ERROR, "Error while reading file '%s': %s\n",

                   filename, strerror(errno));

            ret = AVERROR(errno);

        } else

            ret = AVERROR_EOF;

    } else {

        ret = 0;

        (*bufptr)[(*size)++] = '\0';

    }



    fclose(f);

    return ret;

}

int cmdutils_read_file(const char *filename, char **bufptr, size_t *size)

{

    int ret;

    FILE *f = fopen(filename, "rb");



    if (!f) {

        av_log(NULL, AV_LOG_ERROR, "Cannot read file '%s': %s\n", filename,

               strerror(errno));

        return AVERROR(errno);

    }

    fseek(f, 0, SEEK_END);

    *size = ftell(f);

    fseek(f, 0, SEEK_SET);

    *bufptr = av_malloc(*size + 1);

    if (!*bufptr) {

        av_log(NULL, AV_LOG_ERROR, "Could not allocate file buffer\n");

        fclose(f);

        return AVERROR(ENOMEM);

    }

    ret = fread(*bufptr, 1, *size, f);

    if (ret < *size) {

        av_free(*bufptr);

        if (ferror(f)) {

            av_log(NULL, AV_LOG_ERROR, "Error while reading file '%s': %s\n",

                   filename, strerror(errno));

            ret = AVERROR(errno);

        } else

            ret = AVERROR_EOF;

    } else {

        ret = 0;

        (*bufptr)[(*size)++] = '\0';

    }



    fclose(f);

    return ret;

}

int FUNC_0(const char *VAR_0, char **VAR_1, size_t *VAR_2)

{

    int VAR_3;

    FILE *f = fopen(VAR_0, "rb");



    if (!f) {

        av_log(NULL, AV_LOG_ERROR, "Cannot read file '%s': %s\n", VAR_0,

               strerror(errno));

        return AVERROR(errno);

    }

    fseek(f, 0, SEEK_END);

    *VAR_2 = ftell(f);

    fseek(f, 0, SEEK_SET);

    *VAR_1 = av_malloc(*VAR_2 + 1);

    if (!*VAR_1) {

        av_log(NULL, AV_LOG_ERROR, "Could not allocate file buffer\n");

        fclose(f);

        return AVERROR(ENOMEM);

    }

    VAR_3 = fread(*VAR_1, 1, *VAR_2, f);

    if (VAR_3 < *VAR_2) {

        av_free(*VAR_1);

        if (ferror(f)) {

            av_log(NULL, AV_LOG_ERROR, "Error while reading file '%s': %s\n",

                   VAR_0, strerror(errno));

            VAR_3 = AVERROR(errno);

        } else

            VAR_3 = AVERROR_EOF;

    } else {

        VAR_3 = 0;

        (*VAR_1)[(*VAR_2)++] = '\0';

    }



    fclose(f);

    return VAR_3;

}

int FUNC_0(const char *VAR_0, char **VAR_1, size_t *VAR_2)
{ int VAR_3; FILE *f = fopen(VAR_0, "rb"); if (!f) { av_log(NULL, AV_LOG_ERROR, "Cannot read file '%s': %s\n", VAR_0,
strerror(errno)); return AVERROR(errno); } fseek(f, 0, SEEK_END); *VAR_2 = ftell(f); fseek(f, 0, SEEK_SET); *VAR_1 = av_malloc(*VAR_2 + 1); if (!*VAR_1) { av_log(NULL, AV_LOG_ERROR, "Could not allocate file buffer\n"); fclose(f); return AVERROR(ENOMEM); } VAR_3 = fread(*VAR_1, 1, *VAR_2, f); if (VAR_3 < *VAR_2) { av_free(*VAR_1); if (ferror(f)) { av_log(NULL, AV_LOG_ERROR, "Error while reading file '%s': %s\n",
VAR_0, strerror(errno)); VAR_3 = AVERROR(errno); } else VAR_3 = AVERROR_EOF; } else { VAR_3 = 0; (*VAR_1)[(*VAR_2)++] = '\0'; } fclose(f); return VAR_3; }