static int url_alloc_for_protocol (URLContext **puc, struct URLProtocol *up,

                                   const char *filename, int flags,

                                   const AVIOInterruptCB *int_cb)

{

    URLContext *uc;

    int err;



#if CONFIG_NETWORK

    if (up->flags & URL_PROTOCOL_FLAG_NETWORK && !ff_network_init())

        return AVERROR(EIO);

#endif

    if ((flags & AVIO_FLAG_READ) && !up->url_read) {

        av_log(NULL, AV_LOG_ERROR,

               "Impossible to open the '%s' protocol for reading\n", up->name);

        return AVERROR(EIO);


    if ((flags & AVIO_FLAG_WRITE) && !up->url_write) {

        av_log(NULL, AV_LOG_ERROR,

               "Impossible to open the '%s' protocol for writing\n", up->name);

        return AVERROR(EIO);


    uc = av_mallocz(sizeof(URLContext) + strlen(filename) + 1);

    if (!uc) {




    uc->av_class = &ffurl_context_class;

    uc->filename = (char *) &uc[1];

    strcpy(uc->filename, filename);

    uc->prot = up;

    uc->flags = flags;

    uc->is_streamed = 0; /* default = not streamed */

    uc->max_packet_size = 0; /* default: stream file */

    if (up->priv_data_size) {

        uc->priv_data = av_mallocz(up->priv_data_size);





        if (up->priv_data_class) {

            int proto_len= strlen(up->name);

            char *start = strchr(uc->filename, ',');

            *(const AVClass**)uc->priv_data = up->priv_data_class;

            av_opt_set_defaults(uc->priv_data);

            if(!strncmp(up->name, uc->filename, proto_len) && uc->filename + proto_len == start){

                int ret= 0;

                char *p= start;

                char sep= *++p;

                char *key, *val;

                p++;

                while(ret >= 0 && (key= strchr(p, sep)) && p<key && (val = strchr(key+1, sep))){

                    *val= *key= 0;

                    ret= av_opt_set(uc->priv_data, p, key+1, 0);

                    if (ret == AVERROR_OPTION_NOT_FOUND)

                        av_log(uc, AV_LOG_ERROR, "Key '%s' not found.\n", p);

                    *val= *key= sep;

                    p= val+1;


                if(ret<0 || p!=key){

                    av_log(uc, AV_LOG_ERROR, "Error parsing options string %s\n", start);

                    av_freep(&uc->priv_data);

                    av_freep(&uc);

                    err = AVERROR(EINVAL);



                memmove(start, key+1, strlen(key));




    if (int_cb)

        uc->interrupt_callback = *int_cb;



    *puc = uc;

    return 0;

 fail:

    *puc = NULL;

    if (uc)

        av_freep(&uc->priv_data);

    av_freep(&uc);

#if CONFIG_NETWORK

    if (up->flags & URL_PROTOCOL_FLAG_NETWORK)

        ff_network_close();

#endif

    return err;

static int url_alloc_for_protocol (URLContext **puc, struct URLProtocol *up,

                                   const char *filename, int flags,

                                   const AVIOInterruptCB *int_cb)

{

    URLContext *uc;

    int err;



#if CONFIG_NETWORK

    if (up->flags & URL_PROTOCOL_FLAG_NETWORK && !ff_network_init())

        return AVERROR(EIO);

#endif

    if ((flags & AVIO_FLAG_READ) && !up->url_read) {

        av_log(NULL, AV_LOG_ERROR,

               "Impossible to open the '%s' protocol for reading\n", up->name);

        return AVERROR(EIO);


    if ((flags & AVIO_FLAG_WRITE) && !up->url_write) {

        av_log(NULL, AV_LOG_ERROR,

               "Impossible to open the '%s' protocol for writing\n", up->name);

        return AVERROR(EIO);


    uc = av_mallocz(sizeof(URLContext) + strlen(filename) + 1);

    if (!uc) {




    uc->av_class = &ffurl_context_class;

    uc->filename = (char *) &uc[1];

    strcpy(uc->filename, filename);

    uc->prot = up;

    uc->flags = flags;

    uc->is_streamed = 0; 

    uc->max_packet_size = 0; 

    if (up->priv_data_size) {

        uc->priv_data = av_mallocz(up->priv_data_size);





        if (up->priv_data_class) {

            int proto_len= strlen(up->name);

            char *start = strchr(uc->filename, ',');

            *(const AVClass**)uc->priv_data = up->priv_data_class;

            av_opt_set_defaults(uc->priv_data);

            if(!strncmp(up->name, uc->filename, proto_len) && uc->filename + proto_len == start){

                int ret= 0;

                char *p= start;

                char sep= *++p;

                char *key, *val;

                p++;

                while(ret >= 0 && (key= strchr(p, sep)) && p<key && (val = strchr(key+1, sep))){

                    *val= *key= 0;

                    ret= av_opt_set(uc->priv_data, p, key+1, 0);

                    if (ret == AVERROR_OPTION_NOT_FOUND)

                        av_log(uc, AV_LOG_ERROR, "Key '%s' not found.\n", p);

                    *val= *key= sep;

                    p= val+1;


                if(ret<0 || p!=key){

                    av_log(uc, AV_LOG_ERROR, "Error parsing options string %s\n", start);

                    av_freep(&uc->priv_data);

                    av_freep(&uc);

                    err = AVERROR(EINVAL);



                memmove(start, key+1, strlen(key));




    if (int_cb)

        uc->interrupt_callback = *int_cb;



    *puc = uc;

    return 0;

 fail:

    *puc = NULL;

    if (uc)

        av_freep(&uc->priv_data);

    av_freep(&uc);

#if CONFIG_NETWORK

    if (up->flags & URL_PROTOCOL_FLAG_NETWORK)

        ff_network_close();

#endif

    return err;

static int FUNC_0 (URLContext **VAR_0, struct URLProtocol *VAR_1,

                                   const char *VAR_2, int VAR_3,

                                   const AVIOInterruptCB *VAR_4)

{

    URLContext *uc;

    int VAR_5;



#if CONFIG_NETWORK

    if (VAR_1->VAR_3 & URL_PROTOCOL_FLAG_NETWORK && !ff_network_init())

        return AVERROR(EIO);

#endif

    if ((VAR_3 & AVIO_FLAG_READ) && !VAR_1->url_read) {

        av_log(NULL, AV_LOG_ERROR,

               "Impossible to open the '%s' protocol for reading\n", VAR_1->name);

        return AVERROR(EIO);


    if ((VAR_3 & AVIO_FLAG_WRITE) && !VAR_1->url_write) {

        av_log(NULL, AV_LOG_ERROR,

               "Impossible to open the '%s' protocol for writing\n", VAR_1->name);

        return AVERROR(EIO);


    uc = av_mallocz(sizeof(URLContext) + strlen(VAR_2) + 1);

    if (!uc) {




    uc->av_class = &ffurl_context_class;

    uc->VAR_2 = (char *) &uc[1];

    strcpy(uc->VAR_2, VAR_2);

    uc->prot = VAR_1;

    uc->VAR_3 = VAR_3;

    uc->is_streamed = 0; 

    uc->max_packet_size = 0; 

    if (VAR_1->priv_data_size) {

        uc->priv_data = av_mallocz(VAR_1->priv_data_size);





        if (VAR_1->priv_data_class) {

            int VAR_6= strlen(VAR_1->name);

            char *VAR_7 = strchr(uc->VAR_2, ',');

            *(const AVClass**)uc->priv_data = VAR_1->priv_data_class;

            av_opt_set_defaults(uc->priv_data);

            if(!strncmp(VAR_1->name, uc->VAR_2, VAR_6) && uc->VAR_2 + VAR_6 == VAR_7){

                int VAR_8= 0;

                char *VAR_9= VAR_7;

                char VAR_10= *++VAR_9;

                char *VAR_11, *VAR_12;

                VAR_9++;

                while(VAR_8 >= 0 && (VAR_11= strchr(VAR_9, VAR_10)) && VAR_9<VAR_11 && (VAR_12 = strchr(VAR_11+1, VAR_10))){

                    *VAR_12= *VAR_11= 0;

                    VAR_8= av_opt_set(uc->priv_data, VAR_9, VAR_11+1, 0);

                    if (VAR_8 == AVERROR_OPTION_NOT_FOUND)

                        av_log(uc, AV_LOG_ERROR, "Key '%s' not found.\n", VAR_9);

                    *VAR_12= *VAR_11= VAR_10;

                    VAR_9= VAR_12+1;


                if(VAR_8<0 || VAR_9!=VAR_11){

                    av_log(uc, AV_LOG_ERROR, "Error parsing options string %s\n", VAR_7);

                    av_freep(&uc->priv_data);

                    av_freep(&uc);

                    VAR_5 = AVERROR(EINVAL);



                memmove(VAR_7, VAR_11+1, strlen(VAR_11));




    if (VAR_4)

        uc->interrupt_callback = *VAR_4;



    *VAR_0 = uc;

    return 0;

 fail:

    *VAR_0 = NULL;

    if (uc)

        av_freep(&uc->priv_data);

    av_freep(&uc);

#if CONFIG_NETWORK

    if (VAR_1->VAR_3 & URL_PROTOCOL_FLAG_NETWORK)

        ff_network_close();

#endif

    return VAR_5;

static int FUNC_0 (URLContext **VAR_0, struct URLProtocol *VAR_1,
const char *VAR_2, int VAR_3,
const AVIOInterruptCB *VAR_4)
{ URLContext *uc; int VAR_5; #if CONFIG_NETWORK
if (VAR_1->VAR_3 & URL_PROTOCOL_FLAG_NETWORK && !ff_network_init())
return AVERROR(EIO); #endif
if ((VAR_3 & AVIO_FLAG_READ) && !VAR_1->url_read) { av_log(NULL, AV_LOG_ERROR,
"Impossible to open the '%s' protocol for reading\n", VAR_1->name); return AVERROR(EIO); if ((VAR_3 & AVIO_FLAG_WRITE) && !VAR_1->url_write) { av_log(NULL, AV_LOG_ERROR,
"Impossible to open the '%s' protocol for writing\n", VAR_1->name); return AVERROR(EIO); uc = av_mallocz(sizeof(URLContext) + strlen(VAR_2) + 1); if (!uc) { uc->av_class = &ffurl_context_class; uc->VAR_2 = (char *) &uc[1]; strcpy(uc->VAR_2, VAR_2); uc->prot = VAR_1; uc->VAR_3 = VAR_3; uc->is_streamed = 0; uc->max_packet_size = 0; if (VAR_1->priv_data_size) { uc->priv_data = av_mallocz(VAR_1->priv_data_size); if (VAR_1->priv_data_class) { int VAR_6= strlen(VAR_1->name); char *VAR_7 = strchr(uc->VAR_2, ','); *(const AVClass**)uc->priv_data = VAR_1->priv_data_class; av_opt_set_defaults(uc->priv_data); if(!strncmp(VAR_1->name, uc->VAR_2, VAR_6) && uc->VAR_2 + VAR_6 == VAR_7){ int VAR_8= 0; char *VAR_9= VAR_7; char VAR_10= *++VAR_9; char *VAR_11, *VAR_12; VAR_9++; while(VAR_8 >= 0 && (VAR_11= strchr(VAR_9, VAR_10)) && VAR_9<VAR_11 && (VAR_12 = strchr(VAR_11+1, VAR_10))){ *VAR_12= *VAR_11= 0; VAR_8= av_opt_set(uc->priv_data, VAR_9, VAR_11+1, 0); if (VAR_8 == AVERROR_OPTION_NOT_FOUND)
av_log(uc, AV_LOG_ERROR, "Key '%s' not found.\n", VAR_9); *VAR_12= *VAR_11= VAR_10; VAR_9= VAR_12+1; if(VAR_8<0 || VAR_9!=VAR_11){ av_log(uc, AV_LOG_ERROR, "Error parsing options string %s\n", VAR_7); av_freep(&uc->priv_data); av_freep(&uc); VAR_5 = AVERROR(EINVAL); memmove(VAR_7, VAR_11+1, strlen(VAR_11)); if (VAR_4)
uc->interrupt_callback = *VAR_4; *VAR_0 = uc; return 0; fail:
*VAR_0 = NULL; if (uc)
av_freep(&uc->priv_data); av_freep(&uc); #if CONFIG_NETWORK
if (VAR_1->VAR_3 & URL_PROTOCOL_FLAG_NETWORK)
ff_network_close(); #endif
return VAR_5;