static int ftp_status(FTPContext *s, char **line, const int response_codes[])

{

    int err, i, result = 0, pref_code_found = 0, wait_count = 100;

    char buf[CONTROL_BUFFER_SIZE];



    /* Set blocking mode */

    s->conn_control_block_flag = 0;

    for (;;) {

        if ((err = ftp_get_line(s, buf, sizeof(buf))) < 0) {

            if (err == AVERROR_EXIT) {

                if (!pref_code_found && wait_count--) {

                    av_usleep(10000);

                    continue;

                }

            }

            return result;

        }



        av_log(s, AV_LOG_DEBUG, "%s\n", buf);



        if (!pref_code_found) {

            if (strlen(buf) < 3)

                continue;



            err = 0;

            for (i = 0; i < 3; ++i) {

                if (buf[i] < '0' || buf[i] > '9')

                    continue;

                err *= 10;

                err += buf[i] - '0';

            }



            for (i = 0; response_codes[i]; ++i) {

                if (err == response_codes[i]) {

                    /* first code received. Now get all lines in non blocking mode */

                    s->conn_control_block_flag = 1;

                    pref_code_found = 1;

                    result = err;

                    if (line)

                        *line = av_strdup(buf);

                    break;

                }

            }

        }

    }

    return result;

}

static int ftp_status(FTPContext *s, char **line, const int response_codes[])

{

    int err, i, result = 0, pref_code_found = 0, wait_count = 100;

    char buf[CONTROL_BUFFER_SIZE];



    

    s->conn_control_block_flag = 0;

    for (;;) {

        if ((err = ftp_get_line(s, buf, sizeof(buf))) < 0) {

            if (err == AVERROR_EXIT) {

                if (!pref_code_found && wait_count--) {

                    av_usleep(10000);

                    continue;

                }

            }

            return result;

        }



        av_log(s, AV_LOG_DEBUG, "%s\n", buf);



        if (!pref_code_found) {

            if (strlen(buf) < 3)

                continue;



            err = 0;

            for (i = 0; i < 3; ++i) {

                if (buf[i] < '0' || buf[i] > '9')

                    continue;

                err *= 10;

                err += buf[i] - '0';

            }



            for (i = 0; response_codes[i]; ++i) {

                if (err == response_codes[i]) {

                    

                    s->conn_control_block_flag = 1;

                    pref_code_found = 1;

                    result = err;

                    if (line)

                        *line = av_strdup(buf);

                    break;

                }

            }

        }

    }

    return result;

}

static int FUNC_0(FTPContext *VAR_0, char **VAR_1, const int VAR_2[])

{

    int VAR_3, VAR_4, VAR_5 = 0, VAR_6 = 0, VAR_7 = 100;

    char VAR_8[CONTROL_BUFFER_SIZE];



    

    VAR_0->conn_control_block_flag = 0;

    for (;;) {

        if ((VAR_3 = ftp_get_line(VAR_0, VAR_8, sizeof(VAR_8))) < 0) {

            if (VAR_3 == AVERROR_EXIT) {

                if (!VAR_6 && VAR_7--) {

                    av_usleep(10000);

                    continue;

                }

            }

            return VAR_5;

        }



        av_log(VAR_0, AV_LOG_DEBUG, "%VAR_0\n", VAR_8);



        if (!VAR_6) {

            if (strlen(VAR_8) < 3)

                continue;



            VAR_3 = 0;

            for (VAR_4 = 0; VAR_4 < 3; ++VAR_4) {

                if (VAR_8[VAR_4] < '0' || VAR_8[VAR_4] > '9')

                    continue;

                VAR_3 *= 10;

                VAR_3 += VAR_8[VAR_4] - '0';

            }



            for (VAR_4 = 0; VAR_2[VAR_4]; ++VAR_4) {

                if (VAR_3 == VAR_2[VAR_4]) {

                    

                    VAR_0->conn_control_block_flag = 1;

                    VAR_6 = 1;

                    VAR_5 = VAR_3;

                    if (VAR_1)

                        *VAR_1 = av_strdup(VAR_8);

                    break;

                }

            }

        }

    }

    return VAR_5;

}

static int FUNC_0(FTPContext *VAR_0, char **VAR_1, const int VAR_2[])
{ int VAR_3, VAR_4, VAR_5 = 0, VAR_6 = 0, VAR_7 = 100; char VAR_8[CONTROL_BUFFER_SIZE]; VAR_0->conn_control_block_flag = 0; for (;;) { if ((VAR_3 = ftp_get_line(VAR_0, VAR_8, sizeof(VAR_8))) < 0) { if (VAR_3 == AVERROR_EXIT) { if (!VAR_6 && VAR_7--) { av_usleep(10000); continue; } } return VAR_5; } av_log(VAR_0, AV_LOG_DEBUG, "%VAR_0\n", VAR_8); if (!VAR_6) { if (strlen(VAR_8) < 3)
continue; VAR_3 = 0; for (VAR_4 = 0; VAR_4 < 3; ++VAR_4) { if (VAR_8[VAR_4] < '0' || VAR_8[VAR_4] > '9')
continue; VAR_3 *= 10; VAR_3 += VAR_8[VAR_4] - '0'; } for (VAR_4 = 0; VAR_2[VAR_4]; ++VAR_4) { if (VAR_3 == VAR_2[VAR_4]) { VAR_0->conn_control_block_flag = 1; VAR_6 = 1; VAR_5 = VAR_3; if (VAR_1)
*VAR_1 = av_strdup(VAR_8); break; } } } } return VAR_5; }