static int ftp_current_dir(FTPContext *s)

{

    char *res = NULL, *start = NULL, *end = NULL;

    int i;

    const char *command = "PWD\r\n";

    const int pwd_codes[] = {257, 0};



    if (!ftp_send_command(s, command, pwd_codes, &res))

        goto fail;



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

        if (res[i] == '"') {

            if (!start) {

                start = res + i + 1;

                continue;

            }

            end = res + i;

            break;

        }

    }



    if (!end)

        goto fail;



    if (end > res && end[-1] == '/') {

        end[-1] = '\0';

    } else

        *end = '\0';

    av_strlcpy(s->path, start, sizeof(s->path));



    av_free(res);

    return 0;



  fail:

    av_free(res);

    return AVERROR(EIO);

}

static int ftp_current_dir(FTPContext *s)

{

    char *res = NULL, *start = NULL, *end = NULL;

    int i;

    const char *command = "PWD\r\n";

    const int pwd_codes[] = {257, 0};



    if (!ftp_send_command(s, command, pwd_codes, &res))

        goto fail;



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

        if (res[i] == '"') {

            if (!start) {

                start = res + i + 1;

                continue;

            }

            end = res + i;

            break;

        }

    }



    if (!end)

        goto fail;



    if (end > res && end[-1] == '/') {

        end[-1] = '\0';

    } else

        *end = '\0';

    av_strlcpy(s->path, start, sizeof(s->path));



    av_free(res);

    return 0;



  fail:

    av_free(res);

    return AVERROR(EIO);

}

static int FUNC_0(FTPContext *VAR_0)

{

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

    int VAR_4;

    const char *VAR_5 = "PWD\r\n";

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



    if (!ftp_send_command(VAR_0, VAR_5, VAR_6, &VAR_1))

        goto fail;



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

        if (VAR_1[VAR_4] == '"') {

            if (!VAR_2) {

                VAR_2 = VAR_1 + VAR_4 + 1;

                continue;

            }

            VAR_3 = VAR_1 + VAR_4;

            break;

        }

    }



    if (!VAR_3)

        goto fail;



    if (VAR_3 > VAR_1 && VAR_3[-1] == '/') {

        VAR_3[-1] = '\0';

    } else

        *VAR_3 = '\0';

    av_strlcpy(VAR_0->path, VAR_2, sizeof(VAR_0->path));



    av_free(VAR_1);

    return 0;



  fail:

    av_free(VAR_1);

    return AVERROR(EIO);

}

static int FUNC_0(FTPContext *VAR_0)
{ char *VAR_1 = NULL, *VAR_2 = NULL, *VAR_3 = NULL; int VAR_4; const char *VAR_5 = "PWD\r\n"; const int VAR_6[] = {257, 0}; if (!ftp_send_command(VAR_0, VAR_5, VAR_6, &VAR_1))
goto fail; for (VAR_4 = 0; VAR_1[VAR_4]; ++VAR_4) { if (VAR_1[VAR_4] == '"') { if (!VAR_2) { VAR_2 = VAR_1 + VAR_4 + 1; continue; } VAR_3 = VAR_1 + VAR_4; break; } } if (!VAR_3)
goto fail; if (VAR_3 > VAR_1 && VAR_3[-1] == '/') { VAR_3[-1] = '\0'; } else *VAR_3 = '\0'; av_strlcpy(VAR_0->path, VAR_2, sizeof(VAR_0->path)); av_free(VAR_1); return 0; fail:
av_free(VAR_1); return AVERROR(EIO); }