static int ftp_auth(FTPContext *s)

{

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

    char *end = NULL, buf[CONTROL_BUFFER_SIZE], credencials[CREDENTIALS_BUFFER_SIZE];

    int err;

    const int user_codes[] = {331, 230, 0};

    const int pass_codes[] = {230, 0};



    /* Authentication may be repeated, original string has to be saved */

    av_strlcpy(credencials, s->credencials, sizeof(credencials));



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

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



    if (!user) {

        user = "anonymous";

        pass = s->anonymous_password ? s->anonymous_password : "nopassword";

    }



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

    err = ftp_send_command(s, buf, user_codes, NULL);

    if (err == 331) {

        if (pass) {

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

            err = ftp_send_command(s, buf, pass_codes, NULL);

        } else

            return AVERROR(EACCES);

    }

    if (!err)

        return AVERROR(EACCES);



    return 0;

}

static int ftp_auth(FTPContext *s)

{

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

    char *end = NULL, buf[CONTROL_BUFFER_SIZE], credencials[CREDENTIALS_BUFFER_SIZE];

    int err;

    const int user_codes[] = {331, 230, 0};

    const int pass_codes[] = {230, 0};



    

    av_strlcpy(credencials, s->credencials, sizeof(credencials));



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

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



    if (!user) {

        user = "anonymous";

        pass = s->anonymous_password ? s->anonymous_password : "nopassword";

    }



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

    err = ftp_send_command(s, buf, user_codes, NULL);

    if (err == 331) {

        if (pass) {

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

            err = ftp_send_command(s, buf, pass_codes, NULL);

        } else

            return AVERROR(EACCES);

    }

    if (!err)

        return AVERROR(EACCES);



    return 0;

}

static int FUNC_0(FTPContext *VAR_0)

{

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

    char *VAR_3 = NULL, buf[CONTROL_BUFFER_SIZE], credencials[CREDENTIALS_BUFFER_SIZE];

    int VAR_4;

    const int VAR_5[] = {331, 230, 0};

    const int VAR_6[] = {230, 0};



    

    av_strlcpy(credencials, VAR_0->credencials, sizeof(credencials));



    VAR_1 = av_strtok(credencials, ":", &VAR_3);

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



    if (!VAR_1) {

        VAR_1 = "anonymous";

        VAR_2 = VAR_0->anonymous_password ? VAR_0->anonymous_password : "nopassword";

    }



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

    VAR_4 = ftp_send_command(VAR_0, buf, VAR_5, NULL);

    if (VAR_4 == 331) {

        if (VAR_2) {

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

            VAR_4 = ftp_send_command(VAR_0, buf, VAR_6, NULL);

        } else

            return AVERROR(EACCES);

    }

    if (!VAR_4)

        return AVERROR(EACCES);



    return 0;

}

static int FUNC_0(FTPContext *VAR_0)
{ const char *VAR_1 = NULL, *VAR_2 = NULL; char *VAR_3 = NULL, buf[CONTROL_BUFFER_SIZE], credencials[CREDENTIALS_BUFFER_SIZE]; int VAR_4; const int VAR_5[] = {331, 230, 0}; const int VAR_6[] = {230, 0}; av_strlcpy(credencials, VAR_0->credencials, sizeof(credencials)); VAR_1 = av_strtok(credencials, ":", &VAR_3); VAR_2 = av_strtok(VAR_3, ":", &VAR_3); if (!VAR_1) { VAR_1 = "anonymous"; VAR_2 = VAR_0->anonymous_password ? VAR_0->anonymous_password : "nopassword"; } snprintf(buf, sizeof(buf), "USER %VAR_0\r\n", VAR_1); VAR_4 = ftp_send_command(VAR_0, buf, VAR_5, NULL); if (VAR_4 == 331) { if (VAR_2) { snprintf(buf, sizeof(buf), "PASS %VAR_0\r\n", VAR_2); VAR_4 = ftp_send_command(VAR_0, buf, VAR_6, NULL); } else return AVERROR(EACCES); } if (!VAR_4)
return AVERROR(EACCES); return 0; }