static int ftp_auth(FTPContext *s, char *auth)

{

    const char *user = NULL, *pass = NULL;

    char *end = NULL, buf[CONTROL_BUFFER_SIZE];

    int err;

    av_assert2(auth);



    user = av_strtok(auth, ":", &end);

    pass = av_strtok(end, ":", &end);



    if (user) {

        snprintf(buf, sizeof(buf), "USER %s\r\n", user);

        if ((err = ffurl_write(s->conn_control, buf, strlen(buf))) < 0)

            return err;

        ftp_status(s, &err, NULL, NULL, NULL, -1);

        if (err == 3) {

            if (pass) {

                snprintf(buf, sizeof(buf), "PASS %s\r\n", pass);

                if ((err = ffurl_write(s->conn_control, buf, strlen(buf))) < 0)

                    return err;

                ftp_status(s, &err, NULL, NULL, NULL, -1);

            } else

                return AVERROR(EACCES);

        }

        if (err != 2) {

            return AVERROR(EACCES);

        }

    } else {

        const char* command = "USER anonymous\r\n";

        if ((err = ffurl_write(s->conn_control, command, strlen(command))) < 0)

            return err;

        ftp_status(s, &err, NULL, NULL, NULL, -1);

        if (err == 3) {

            if (s->anonymous_password) {

                snprintf(buf, sizeof(buf), "PASS %s\r\n", s->anonymous_password);

            } else

                snprintf(buf, sizeof(buf), "PASS nopassword\r\n");

            if ((err = ffurl_write(s->conn_control, buf, strlen(buf))) < 0)

                return err;

            ftp_status(s, &err, NULL, NULL, NULL, -1);

        }

        if (err != 2) {

            return AVERROR(EACCES);

        }

    }



    return 0;

}

static int ftp_auth(FTPContext *s, char *auth)

{

    const char *user = NULL, *pass = NULL;

    char *end = NULL, buf[CONTROL_BUFFER_SIZE];

    int err;

    av_assert2(auth);



    user = av_strtok(auth, ":", &end);

    pass = av_strtok(end, ":", &end);



    if (user) {

        snprintf(buf, sizeof(buf), "USER %s\r\n", user);

        if ((err = ffurl_write(s->conn_control, buf, strlen(buf))) < 0)

            return err;

        ftp_status(s, &err, NULL, NULL, NULL, -1);

        if (err == 3) {

            if (pass) {

                snprintf(buf, sizeof(buf), "PASS %s\r\n", pass);

                if ((err = ffurl_write(s->conn_control, buf, strlen(buf))) < 0)

                    return err;

                ftp_status(s, &err, NULL, NULL, NULL, -1);

            } else

                return AVERROR(EACCES);

        }

        if (err != 2) {

            return AVERROR(EACCES);

        }

    } else {

        const char* command = "USER anonymous\r\n";

        if ((err = ffurl_write(s->conn_control, command, strlen(command))) < 0)

            return err;

        ftp_status(s, &err, NULL, NULL, NULL, -1);

        if (err == 3) {

            if (s->anonymous_password) {

                snprintf(buf, sizeof(buf), "PASS %s\r\n", s->anonymous_password);

            } else

                snprintf(buf, sizeof(buf), "PASS nopassword\r\n");

            if ((err = ffurl_write(s->conn_control, buf, strlen(buf))) < 0)

                return err;

            ftp_status(s, &err, NULL, NULL, NULL, -1);

        }

        if (err != 2) {

            return AVERROR(EACCES);

        }

    }



    return 0;

}

static int FUNC_0(FTPContext *VAR_0, char *VAR_1)

{

    const char *VAR_2 = NULL, *VAR_3 = NULL;

    char *VAR_4 = NULL, buf[CONTROL_BUFFER_SIZE];

    int VAR_5;

    av_assert2(VAR_1);



    VAR_2 = av_strtok(VAR_1, ":", &VAR_4);

    VAR_3 = av_strtok(VAR_4, ":", &VAR_4);



    if (VAR_2) {

        snprintf(buf, sizeof(buf), "USER %VAR_0\r\n", VAR_2);

        if ((VAR_5 = ffurl_write(VAR_0->conn_control, buf, strlen(buf))) < 0)

            return VAR_5;

        ftp_status(VAR_0, &VAR_5, NULL, NULL, NULL, -1);

        if (VAR_5 == 3) {

            if (VAR_3) {

                snprintf(buf, sizeof(buf), "PASS %VAR_0\r\n", VAR_3);

                if ((VAR_5 = ffurl_write(VAR_0->conn_control, buf, strlen(buf))) < 0)

                    return VAR_5;

                ftp_status(VAR_0, &VAR_5, NULL, NULL, NULL, -1);

            } else

                return AVERROR(EACCES);

        }

        if (VAR_5 != 2) {

            return AVERROR(EACCES);

        }

    } else {

        const char* VAR_6 = "USER anonymous\r\n";

        if ((VAR_5 = ffurl_write(VAR_0->conn_control, VAR_6, strlen(VAR_6))) < 0)

            return VAR_5;

        ftp_status(VAR_0, &VAR_5, NULL, NULL, NULL, -1);

        if (VAR_5 == 3) {

            if (VAR_0->anonymous_password) {

                snprintf(buf, sizeof(buf), "PASS %VAR_0\r\n", VAR_0->anonymous_password);

            } else

                snprintf(buf, sizeof(buf), "PASS nopassword\r\n");

            if ((VAR_5 = ffurl_write(VAR_0->conn_control, buf, strlen(buf))) < 0)

                return VAR_5;

            ftp_status(VAR_0, &VAR_5, NULL, NULL, NULL, -1);

        }

        if (VAR_5 != 2) {

            return AVERROR(EACCES);

        }

    }



    return 0;

}

static int FUNC_0(FTPContext *VAR_0, char *VAR_1)
{ const char *VAR_2 = NULL, *VAR_3 = NULL; char *VAR_4 = NULL, buf[CONTROL_BUFFER_SIZE]; int VAR_5; av_assert2(VAR_1); VAR_2 = av_strtok(VAR_1, ":", &VAR_4); VAR_3 = av_strtok(VAR_4, ":", &VAR_4); if (VAR_2) { snprintf(buf, sizeof(buf), "USER %VAR_0\r\n", VAR_2); if ((VAR_5 = ffurl_write(VAR_0->conn_control, buf, strlen(buf))) < 0)
return VAR_5; ftp_status(VAR_0, &VAR_5, NULL, NULL, NULL, -1); if (VAR_5 == 3) { if (VAR_3) { snprintf(buf, sizeof(buf), "PASS %VAR_0\r\n", VAR_3); if ((VAR_5 = ffurl_write(VAR_0->conn_control, buf, strlen(buf))) < 0)
return VAR_5; ftp_status(VAR_0, &VAR_5, NULL, NULL, NULL, -1); } else return AVERROR(EACCES); } if (VAR_5 != 2) { return AVERROR(EACCES); } } else { const char* VAR_6 = "USER anonymous\r\n"; if ((VAR_5 = ffurl_write(VAR_0->conn_control, VAR_6, strlen(VAR_6))) < 0)
return VAR_5; ftp_status(VAR_0, &VAR_5, NULL, NULL, NULL, -1); if (VAR_5 == 3) { if (VAR_0->anonymous_password) { snprintf(buf, sizeof(buf), "PASS %VAR_0\r\n", VAR_0->anonymous_password); } else snprintf(buf, sizeof(buf), "PASS nopassword\r\n"); if ((VAR_5 = ffurl_write(VAR_0->conn_control, buf, strlen(buf))) < 0)
return VAR_5; ftp_status(VAR_0, &VAR_5, NULL, NULL, NULL, -1); } if (VAR_5 != 2) { return AVERROR(EACCES); } } return 0; }