static int open_url(HLSContext *c, URLContext **uc, const char *url, AVDictionary *opts)

{

    AVDictionary *tmp = NULL;

    int ret;

    const char *proto_name = avio_find_protocol_name(url);

    // only http(s) & file are allowed

    if (!av_strstart(proto_name, "http", NULL) && !av_strstart(proto_name, "file", NULL))

        return AVERROR_INVALIDDATA;

    if (!strncmp(proto_name, url, strlen(proto_name)) && url[strlen(proto_name)] == ':')

        ;

    else if (strcmp(proto_name, "file") || !strcmp(url, "file,"))

        return AVERROR_INVALIDDATA;



    av_dict_copy(&tmp, c->avio_opts, 0);

    av_dict_copy(&tmp, opts, 0);



    ret = ffurl_open(uc, url, AVIO_FLAG_READ, c->interrupt_callback, &tmp);

    if( ret >= 0) {

        // update cookies on http response with setcookies.

        URLContext *u = *uc;

        update_options(&c->cookies, "cookies", u->priv_data);

        av_dict_set(&opts, "cookies", c->cookies, 0);

    }



    av_dict_free(&tmp);



    return ret;

}

static int open_url(HLSContext *c, URLContext **uc, const char *url, AVDictionary *opts)

{

    AVDictionary *tmp = NULL;

    int ret;

    const char *proto_name = avio_find_protocol_name(url);

    

    if (!av_strstart(proto_name, "http", NULL) && !av_strstart(proto_name, "file", NULL))

        return AVERROR_INVALIDDATA;

    if (!strncmp(proto_name, url, strlen(proto_name)) && url[strlen(proto_name)] == ':')

        ;

    else if (strcmp(proto_name, "file") || !strcmp(url, "file,"))

        return AVERROR_INVALIDDATA;



    av_dict_copy(&tmp, c->avio_opts, 0);

    av_dict_copy(&tmp, opts, 0);



    ret = ffurl_open(uc, url, AVIO_FLAG_READ, c->interrupt_callback, &tmp);

    if( ret >= 0) {

        

        URLContext *u = *uc;

        update_options(&c->cookies, "cookies", u->priv_data);

        av_dict_set(&opts, "cookies", c->cookies, 0);

    }



    av_dict_free(&tmp);



    return ret;

}

    else if (strcmp(proto_name, "file") || !strcmp(url, "file,"))
static int FUNC_0(HLSContext *VAR_0, URLContext **VAR_1, const char *VAR_2, AVDictionary *VAR_3)

{

    AVDictionary *tmp = NULL;

    int VAR_4;

    const char *VAR_5 = avio_find_protocol_name(VAR_2);

    

    if (!av_strstart(VAR_5, "http", NULL) && !av_strstart(VAR_5, "file", NULL))

        return AVERROR_INVALIDDATA;

    if (!strncmp(VAR_5, VAR_2, strlen(VAR_5)) && VAR_2[strlen(VAR_5)] == ':')

        ;

    else if (strcmp(VAR_5, "file") || !strcmp(VAR_2, "file,"))

        return AVERROR_INVALIDDATA;



    av_dict_copy(&tmp, VAR_0->avio_opts, 0);

    av_dict_copy(&tmp, VAR_3, 0);



    VAR_4 = ffurl_open(VAR_1, VAR_2, AVIO_FLAG_READ, VAR_0->interrupt_callback, &tmp);

    if( VAR_4 >= 0) {

        

        URLContext *u = *VAR_1;

        update_options(&VAR_0->cookies, "cookies", u->priv_data);

        av_dict_set(&VAR_3, "cookies", VAR_0->cookies, 0);

    }



    av_dict_free(&tmp);



    return VAR_4;

}

static int FUNC_0(HLSContext *VAR_0, URLContext **VAR_1, const char *VAR_2, AVDictionary *VAR_3)
{ AVDictionary *tmp = NULL; int VAR_4; const char *VAR_5 = avio_find_protocol_name(VAR_2); if (!av_strstart(VAR_5, "http", NULL) && !av_strstart(VAR_5, "file", NULL))
return AVERROR_INVALIDDATA; if (!strncmp(VAR_5, VAR_2, strlen(VAR_5)) && VAR_2[strlen(VAR_5)] == ':')
; else if (strcmp(VAR_5, "file") || !strcmp(VAR_2, "file,"))
return AVERROR_INVALIDDATA; av_dict_copy(&tmp, VAR_0->avio_opts, 0); av_dict_copy(&tmp, VAR_3, 0); VAR_4 = ffurl_open(VAR_1, VAR_2, AVIO_FLAG_READ, VAR_0->interrupt_callback, &tmp); if( VAR_4 >= 0) { URLContext *u = *VAR_1; update_options(&VAR_0->cookies, "cookies", u->priv_data); av_dict_set(&VAR_3, "cookies", VAR_0->cookies, 0); } av_dict_free(&tmp); return VAR_4; }