static int ftp_write(URLContext *h, const unsigned char *buf, int size)

{

    int err;

    FTPContext *s = h->priv_data;

    int written;



    av_dlog(h, "ftp protocol write %d bytes\n", size);



    if (s->state == DISCONNECTED) {

        if ((err = ftp_connect_data_connection(h)) < 0)

            return err;

    }

    if (s->state == READY) {

        if ((err = ftp_store(s)) < 0)

            return err;

    }

    if (s->conn_data && s->state == UPLOADING) {

        written = ffurl_write(s->conn_data, buf, size);

        if (written > 0) {

            s->position += written;

            s->filesize = FFMAX(s->filesize, s->position);

        }

        return written;

    }



    av_log(h, AV_LOG_ERROR, "FTP write failed\n");

    return AVERROR(EIO);

}

static int ftp_write(URLContext *h, const unsigned char *buf, int size)

{

    int err;

    FTPContext *s = h->priv_data;

    int written;



    av_dlog(h, "ftp protocol write %d bytes\n", size);



    if (s->state == DISCONNECTED) {

        if ((err = ftp_connect_data_connection(h)) < 0)

            return err;

    }

    if (s->state == READY) {

        if ((err = ftp_store(s)) < 0)

            return err;

    }

    if (s->conn_data && s->state == UPLOADING) {

        written = ffurl_write(s->conn_data, buf, size);

        if (written > 0) {

            s->position += written;

            s->filesize = FFMAX(s->filesize, s->position);

        }

        return written;

    }



    av_log(h, AV_LOG_ERROR, "FTP write failed\n");

    return AVERROR(EIO);

}

static int FUNC_0(URLContext *VAR_0, const unsigned char *VAR_1, int VAR_2)

{

    int VAR_3;

    FTPContext *s = VAR_0->priv_data;

    int VAR_4;



    av_dlog(VAR_0, "ftp protocol write %d bytes\n", VAR_2);



    if (s->state == DISCONNECTED) {

        if ((VAR_3 = ftp_connect_data_connection(VAR_0)) < 0)

            return VAR_3;

    }

    if (s->state == READY) {

        if ((VAR_3 = ftp_store(s)) < 0)

            return VAR_3;

    }

    if (s->conn_data && s->state == UPLOADING) {

        VAR_4 = ffurl_write(s->conn_data, VAR_1, VAR_2);

        if (VAR_4 > 0) {

            s->position += VAR_4;

            s->filesize = FFMAX(s->filesize, s->position);

        }

        return VAR_4;

    }



    av_log(VAR_0, AV_LOG_ERROR, "FTP write failed\n");

    return AVERROR(EIO);

}

static int FUNC_0(URLContext *VAR_0, const unsigned char *VAR_1, int VAR_2)
{ int VAR_3; FTPContext *s = VAR_0->priv_data; int VAR_4; av_dlog(VAR_0, "ftp protocol write %d bytes\n", VAR_2); if (s->state == DISCONNECTED) { if ((VAR_3 = ftp_connect_data_connection(VAR_0)) < 0)
return VAR_3; } if (s->state == READY) { if ((VAR_3 = ftp_store(s)) < 0)
return VAR_3; } if (s->conn_data && s->state == UPLOADING) { VAR_4 = ffurl_write(s->conn_data, VAR_1, VAR_2); if (VAR_4 > 0) { s->position += VAR_4; s->filesize = FFMAX(s->filesize, s->position); } return VAR_4; } av_log(VAR_0, AV_LOG_ERROR, "FTP write failed\n"); return AVERROR(EIO); }