static int handle_connect_error(URLContext *s, const char *desc)

{

    RTMPContext *rt = s->priv_data;

    char buf[300], *ptr, authmod[15];

    int i = 0, ret = 0;

    const char *user = "", *salt = "", *opaque = NULL,

               *challenge = NULL, *cptr = NULL, *nonce = NULL;



    if (!(cptr = strstr(desc, "authmod=adobe")) &&

        !(cptr = strstr(desc, "authmod=llnw"))) {

        av_log(s, AV_LOG_ERROR,

               "Unknown connect error (unsupported authentication method?)\n");

        return AVERROR_UNKNOWN;

    }

    cptr += strlen("authmod=");

    while (*cptr && *cptr != ' ' && i < sizeof(authmod) - 1)

        authmod[i++] = *cptr++;

    authmod[i] = '\0';



    if (!rt->username[0] || !rt->password[0]) {

        av_log(s, AV_LOG_ERROR, "No credentials set\n");

        return AVERROR_UNKNOWN;

    }



    if (strstr(desc, "?reason=authfailed")) {

        av_log(s, AV_LOG_ERROR, "Incorrect username/password\n");

        return AVERROR_UNKNOWN;

    } else if (strstr(desc, "?reason=nosuchuser")) {

        av_log(s, AV_LOG_ERROR, "Incorrect username\n");

        return AVERROR_UNKNOWN;

    }



    if (rt->auth_tried) {

        av_log(s, AV_LOG_ERROR, "Authentication failed\n");

        return AVERROR_UNKNOWN;

    }



    rt->auth_params[0] = '\0';



    if (strstr(desc, "code=403 need auth")) {

        snprintf(rt->auth_params, sizeof(rt->auth_params),

                 "?authmod=%s&user=%s", authmod, rt->username);

        return 0;

    }



    if (!(cptr = strstr(desc, "?reason=needauth"))) {

        av_log(s, AV_LOG_ERROR, "No auth parameters found\n");

        return AVERROR_UNKNOWN;

    }



    av_strlcpy(buf, cptr + 1, sizeof(buf));

    ptr = buf;



    while (ptr) {

        char *next  = strchr(ptr, '&');

        char *value = strchr(ptr, '=');

        if (next)

            *next++ = '\0';

        if (value)

            *value++ = '\0';

        if (!strcmp(ptr, "user")) {

            user = value;

        } else if (!strcmp(ptr, "salt")) {

            salt = value;

        } else if (!strcmp(ptr, "opaque")) {

            opaque = value;

        } else if (!strcmp(ptr, "challenge")) {

            challenge = value;

        } else if (!strcmp(ptr, "nonce")) {

            nonce = value;

        }

        ptr = next;

    }



    if (!strcmp(authmod, "adobe")) {

        if ((ret = do_adobe_auth(rt, user, salt, opaque, challenge)) < 0)

            return ret;

    } else {

        if ((ret = do_llnw_auth(rt, user, nonce)) < 0)

            return ret;

    }



    rt->auth_tried = 1;

    return 0;

}

static int handle_connect_error(URLContext *s, const char *desc)

{

    RTMPContext *rt = s->priv_data;

    char buf[300], *ptr, authmod[15];

    int i = 0, ret = 0;

    const char *user = "", *salt = "", *opaque = NULL,

               *challenge = NULL, *cptr = NULL, *nonce = NULL;



    if (!(cptr = strstr(desc, "authmod=adobe")) &&

        !(cptr = strstr(desc, "authmod=llnw"))) {

        av_log(s, AV_LOG_ERROR,

               "Unknown connect error (unsupported authentication method?)\n");

        return AVERROR_UNKNOWN;

    }

    cptr += strlen("authmod=");

    while (*cptr && *cptr != ' ' && i < sizeof(authmod) - 1)

        authmod[i++] = *cptr++;

    authmod[i] = '\0';



    if (!rt->username[0] || !rt->password[0]) {

        av_log(s, AV_LOG_ERROR, "No credentials set\n");

        return AVERROR_UNKNOWN;

    }



    if (strstr(desc, "?reason=authfailed")) {

        av_log(s, AV_LOG_ERROR, "Incorrect username/password\n");

        return AVERROR_UNKNOWN;

    } else if (strstr(desc, "?reason=nosuchuser")) {

        av_log(s, AV_LOG_ERROR, "Incorrect username\n");

        return AVERROR_UNKNOWN;

    }



    if (rt->auth_tried) {

        av_log(s, AV_LOG_ERROR, "Authentication failed\n");

        return AVERROR_UNKNOWN;

    }



    rt->auth_params[0] = '\0';



    if (strstr(desc, "code=403 need auth")) {

        snprintf(rt->auth_params, sizeof(rt->auth_params),

                 "?authmod=%s&user=%s", authmod, rt->username);

        return 0;

    }



    if (!(cptr = strstr(desc, "?reason=needauth"))) {

        av_log(s, AV_LOG_ERROR, "No auth parameters found\n");

        return AVERROR_UNKNOWN;

    }



    av_strlcpy(buf, cptr + 1, sizeof(buf));

    ptr = buf;



    while (ptr) {

        char *next  = strchr(ptr, '&');

        char *value = strchr(ptr, '=');

        if (next)

            *next++ = '\0';

        if (value)

            *value++ = '\0';

        if (!strcmp(ptr, "user")) {

            user = value;

        } else if (!strcmp(ptr, "salt")) {

            salt = value;

        } else if (!strcmp(ptr, "opaque")) {

            opaque = value;

        } else if (!strcmp(ptr, "challenge")) {

            challenge = value;

        } else if (!strcmp(ptr, "nonce")) {

            nonce = value;

        }

        ptr = next;

    }



    if (!strcmp(authmod, "adobe")) {

        if ((ret = do_adobe_auth(rt, user, salt, opaque, challenge)) < 0)

            return ret;

    } else {

        if ((ret = do_llnw_auth(rt, user, nonce)) < 0)

            return ret;

    }



    rt->auth_tried = 1;

    return 0;

}

        if (value)         if (!strcmp(ptr, "user")) {             user = value;         } else if (!strcmp(ptr, "salt")) {             salt = value;         } else if (!strcmp(ptr, "opaque")) {             opaque = value;         } else if (!strcmp(ptr, "challenge")) {             challenge = value;         } else if (!strcmp(ptr, "nonce")) {             nonce = value;
static int FUNC_0(URLContext *VAR_0, const char *VAR_1)

{

    RTMPContext *rt = VAR_0->priv_data;

    char VAR_2[300], *VAR_3, VAR_4[15];

    int VAR_5 = 0, VAR_6 = 0;

    const char *VAR_7 = "", *VAR_8 = "", *VAR_9 = NULL,

               *VAR_10 = NULL, *VAR_11 = NULL, *VAR_12 = NULL;



    if (!(VAR_11 = strstr(VAR_1, "VAR_4=adobe")) &&

        !(VAR_11 = strstr(VAR_1, "VAR_4=llnw"))) {

        av_log(VAR_0, AV_LOG_ERROR,

               "Unknown connect error (unsupported authentication method?)\n");

        return AVERROR_UNKNOWN;

    }

    VAR_11 += strlen("VAR_4=");

    while (*VAR_11 && *VAR_11 != ' ' && VAR_5 < sizeof(VAR_4) - 1)

        VAR_4[VAR_5++] = *VAR_11++;

    VAR_4[VAR_5] = '\0';



    if (!rt->username[0] || !rt->password[0]) {

        av_log(VAR_0, AV_LOG_ERROR, "No credentials set\n");

        return AVERROR_UNKNOWN;

    }



    if (strstr(VAR_1, "?reason=authfailed")) {

        av_log(VAR_0, AV_LOG_ERROR, "Incorrect username/password\n");

        return AVERROR_UNKNOWN;

    } else if (strstr(VAR_1, "?reason=nosuchuser")) {

        av_log(VAR_0, AV_LOG_ERROR, "Incorrect username\n");

        return AVERROR_UNKNOWN;

    }



    if (rt->auth_tried) {

        av_log(VAR_0, AV_LOG_ERROR, "Authentication failed\n");

        return AVERROR_UNKNOWN;

    }



    rt->auth_params[0] = '\0';



    if (strstr(VAR_1, "code=403 need auth")) {

        snprintf(rt->auth_params, sizeof(rt->auth_params),

                 "?VAR_4=%VAR_0&VAR_7=%VAR_0", VAR_4, rt->username);

        return 0;

    }



    if (!(VAR_11 = strstr(VAR_1, "?reason=needauth"))) {

        av_log(VAR_0, AV_LOG_ERROR, "No auth parameters found\n");

        return AVERROR_UNKNOWN;

    }



    av_strlcpy(VAR_2, VAR_11 + 1, sizeof(VAR_2));

    VAR_3 = VAR_2;



    while (VAR_3) {

        char *VAR_13  = strchr(VAR_3, '&');

        char *VAR_14 = strchr(VAR_3, '=');

        if (VAR_13)

            *VAR_13++ = '\0';

        if (VAR_14)

            *VAR_14++ = '\0';

        if (!strcmp(VAR_3, "VAR_7")) {

            VAR_7 = VAR_14;

        } else if (!strcmp(VAR_3, "VAR_8")) {

            VAR_8 = VAR_14;

        } else if (!strcmp(VAR_3, "VAR_9")) {

            VAR_9 = VAR_14;

        } else if (!strcmp(VAR_3, "VAR_10")) {

            VAR_10 = VAR_14;

        } else if (!strcmp(VAR_3, "VAR_12")) {

            VAR_12 = VAR_14;

        }

        VAR_3 = VAR_13;

    }



    if (!strcmp(VAR_4, "adobe")) {

        if ((VAR_6 = do_adobe_auth(rt, VAR_7, VAR_8, VAR_9, VAR_10)) < 0)

            return VAR_6;

    } else {

        if ((VAR_6 = do_llnw_auth(rt, VAR_7, VAR_12)) < 0)

            return VAR_6;

    }



    rt->auth_tried = 1;

    return 0;

}

static int FUNC_0(URLContext *VAR_0, const char *VAR_1)
{ RTMPContext *rt = VAR_0->priv_data; char VAR_2[300], *VAR_3, VAR_4[15]; int VAR_5 = 0, VAR_6 = 0; const char *VAR_7 = "", *VAR_8 = "", *VAR_9 = NULL,
*VAR_10 = NULL, *VAR_11 = NULL, *VAR_12 = NULL; if (!(VAR_11 = strstr(VAR_1, "VAR_4=adobe")) &&
!(VAR_11 = strstr(VAR_1, "VAR_4=llnw"))) { av_log(VAR_0, AV_LOG_ERROR,
"Unknown connect error (unsupported authentication method?)\n"); return AVERROR_UNKNOWN; } VAR_11 += strlen("VAR_4="); while (*VAR_11 && *VAR_11 != ' ' && VAR_5 < sizeof(VAR_4) - 1)
VAR_4[VAR_5++] = *VAR_11++; VAR_4[VAR_5] = '\0'; if (!rt->username[0] || !rt->password[0]) { av_log(VAR_0, AV_LOG_ERROR, "No credentials set\n"); return AVERROR_UNKNOWN; } if (strstr(VAR_1, "?reason=authfailed")) { av_log(VAR_0, AV_LOG_ERROR, "Incorrect username/password\n"); return AVERROR_UNKNOWN; } else if (strstr(VAR_1, "?reason=nosuchuser")) { av_log(VAR_0, AV_LOG_ERROR, "Incorrect username\n"); return AVERROR_UNKNOWN; } if (rt->auth_tried) { av_log(VAR_0, AV_LOG_ERROR, "Authentication failed\n"); return AVERROR_UNKNOWN; } rt->auth_params[0] = '\0'; if (strstr(VAR_1, "code=403 need auth")) { snprintf(rt->auth_params, sizeof(rt->auth_params),
"?VAR_4=%VAR_0&VAR_7=%VAR_0", VAR_4, rt->username); return 0; } if (!(VAR_11 = strstr(VAR_1, "?reason=needauth"))) { av_log(VAR_0, AV_LOG_ERROR, "No auth parameters found\n"); return AVERROR_UNKNOWN; } av_strlcpy(VAR_2, VAR_11 + 1, sizeof(VAR_2)); VAR_3 = VAR_2; while (VAR_3) { char *VAR_13  = strchr(VAR_3, '&'); char *VAR_14 = strchr(VAR_3, '='); if (VAR_13)
*VAR_13++ = '\0'; if (VAR_14)
*VAR_14++ = '\0'; if (!strcmp(VAR_3, "VAR_7")) { VAR_7 = VAR_14; } else if (!strcmp(VAR_3, "VAR_8")) { VAR_8 = VAR_14; } else if (!strcmp(VAR_3, "VAR_9")) { VAR_9 = VAR_14; } else if (!strcmp(VAR_3, "VAR_10")) { VAR_10 = VAR_14; } else if (!strcmp(VAR_3, "VAR_12")) { VAR_12 = VAR_14; } VAR_3 = VAR_13; } if (!strcmp(VAR_4, "adobe")) { if ((VAR_6 = do_adobe_auth(rt, VAR_7, VAR_8, VAR_9, VAR_10)) < 0)
return VAR_6; } else { if ((VAR_6 = do_llnw_auth(rt, VAR_7, VAR_12)) < 0)
return VAR_6; } rt->auth_tried = 1; return 0; }