|
|
@ -19,6 +19,7 @@ |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
#include "libavutil/avstring.h" |
|
|
|
#include "libavutil/avstring.h" |
|
|
|
|
|
|
|
#include "libavutil/internal.h" |
|
|
|
#include "libavutil/parseutils.h" |
|
|
|
#include "libavutil/parseutils.h" |
|
|
|
#include "avformat.h" |
|
|
|
#include "avformat.h" |
|
|
|
#include "internal.h" |
|
|
|
#include "internal.h" |
|
|
@ -200,7 +201,7 @@ static int ftp_send_command(FTPContext *s, const char *command, |
|
|
|
{ |
|
|
|
{ |
|
|
|
int err; |
|
|
|
int err; |
|
|
|
|
|
|
|
|
|
|
|
av_dlog(s, "%s", command); |
|
|
|
ff_dlog(s, "%s", command); |
|
|
|
|
|
|
|
|
|
|
|
if (response) |
|
|
|
if (response) |
|
|
|
*response = NULL; |
|
|
|
*response = NULL; |
|
|
@ -283,7 +284,7 @@ static int ftp_passive_mode_epsv(FTPContext *s) |
|
|
|
end[-1] = '\0'; |
|
|
|
end[-1] = '\0'; |
|
|
|
|
|
|
|
|
|
|
|
s->server_data_port = atoi(start); |
|
|
|
s->server_data_port = atoi(start); |
|
|
|
av_dlog(s, "Server data port: %d\n", s->server_data_port); |
|
|
|
ff_dlog(s, "Server data port: %d\n", s->server_data_port); |
|
|
|
|
|
|
|
|
|
|
|
av_free(res); |
|
|
|
av_free(res); |
|
|
|
return 0; |
|
|
|
return 0; |
|
|
@ -329,7 +330,7 @@ static int ftp_passive_mode(FTPContext *s) |
|
|
|
start = av_strtok(end, ",", &end); |
|
|
|
start = av_strtok(end, ",", &end); |
|
|
|
if (!start) goto fail; |
|
|
|
if (!start) goto fail; |
|
|
|
s->server_data_port += atoi(start); |
|
|
|
s->server_data_port += atoi(start); |
|
|
|
av_dlog(s, "Server data port: %d\n", s->server_data_port); |
|
|
|
ff_dlog(s, "Server data port: %d\n", s->server_data_port); |
|
|
|
|
|
|
|
|
|
|
|
av_free(res); |
|
|
|
av_free(res); |
|
|
|
return 0; |
|
|
|
return 0; |
|
|
@ -698,7 +699,7 @@ static int ftp_open(URLContext *h, const char *url, int flags) |
|
|
|
FTPContext *s = h->priv_data; |
|
|
|
FTPContext *s = h->priv_data; |
|
|
|
int err; |
|
|
|
int err; |
|
|
|
|
|
|
|
|
|
|
|
av_dlog(h, "ftp protocol open\n"); |
|
|
|
ff_dlog(h, "ftp protocol open\n"); |
|
|
|
|
|
|
|
|
|
|
|
if ((err = ftp_connect(h, url)) < 0) |
|
|
|
if ((err = ftp_connect(h, url)) < 0) |
|
|
|
goto fail; |
|
|
|
goto fail; |
|
|
@ -726,7 +727,7 @@ static int64_t ftp_seek(URLContext *h, int64_t pos, int whence) |
|
|
|
int err; |
|
|
|
int err; |
|
|
|
int64_t new_pos, fake_pos; |
|
|
|
int64_t new_pos, fake_pos; |
|
|
|
|
|
|
|
|
|
|
|
av_dlog(h, "ftp protocol seek %"PRId64" %d\n", pos, whence); |
|
|
|
ff_dlog(h, "ftp protocol seek %"PRId64" %d\n", pos, whence); |
|
|
|
|
|
|
|
|
|
|
|
switch(whence) { |
|
|
|
switch(whence) { |
|
|
|
case AVSEEK_SIZE: |
|
|
|
case AVSEEK_SIZE: |
|
|
@ -768,7 +769,7 @@ static int ftp_read(URLContext *h, unsigned char *buf, int size) |
|
|
|
FTPContext *s = h->priv_data; |
|
|
|
FTPContext *s = h->priv_data; |
|
|
|
int read, err, retry_done = 0; |
|
|
|
int read, err, retry_done = 0; |
|
|
|
|
|
|
|
|
|
|
|
av_dlog(h, "ftp protocol read %d bytes\n", size); |
|
|
|
ff_dlog(h, "ftp protocol read %d bytes\n", size); |
|
|
|
retry: |
|
|
|
retry: |
|
|
|
if (s->state == DISCONNECTED) { |
|
|
|
if (s->state == DISCONNECTED) { |
|
|
|
/* optimization */ |
|
|
|
/* optimization */ |
|
|
@ -826,7 +827,7 @@ static int ftp_write(URLContext *h, const unsigned char *buf, int size) |
|
|
|
FTPContext *s = h->priv_data; |
|
|
|
FTPContext *s = h->priv_data; |
|
|
|
int written; |
|
|
|
int written; |
|
|
|
|
|
|
|
|
|
|
|
av_dlog(h, "ftp protocol write %d bytes\n", size); |
|
|
|
ff_dlog(h, "ftp protocol write %d bytes\n", size); |
|
|
|
|
|
|
|
|
|
|
|
if (s->state == DISCONNECTED) { |
|
|
|
if (s->state == DISCONNECTED) { |
|
|
|
if ((err = ftp_connect_data_connection(h)) < 0) |
|
|
|
if ((err = ftp_connect_data_connection(h)) < 0) |
|
|
@ -853,7 +854,7 @@ static int ftp_close(URLContext *h) |
|
|
|
{ |
|
|
|
{ |
|
|
|
FTPContext *s = h->priv_data; |
|
|
|
FTPContext *s = h->priv_data; |
|
|
|
|
|
|
|
|
|
|
|
av_dlog(h, "ftp protocol close\n"); |
|
|
|
ff_dlog(h, "ftp protocol close\n"); |
|
|
|
|
|
|
|
|
|
|
|
ftp_close_both_connections(s); |
|
|
|
ftp_close_both_connections(s); |
|
|
|
av_freep(&s->user); |
|
|
|
av_freep(&s->user); |
|
|
@ -869,7 +870,7 @@ static int ftp_get_file_handle(URLContext *h) |
|
|
|
{ |
|
|
|
{ |
|
|
|
FTPContext *s = h->priv_data; |
|
|
|
FTPContext *s = h->priv_data; |
|
|
|
|
|
|
|
|
|
|
|
av_dlog(h, "ftp protocol get_file_handle\n"); |
|
|
|
ff_dlog(h, "ftp protocol get_file_handle\n"); |
|
|
|
|
|
|
|
|
|
|
|
if (s->conn_data) |
|
|
|
if (s->conn_data) |
|
|
|
return ffurl_get_file_handle(s->conn_data); |
|
|
|
return ffurl_get_file_handle(s->conn_data); |
|
|
@ -881,7 +882,7 @@ static int ftp_shutdown(URLContext *h, int flags) |
|
|
|
{ |
|
|
|
{ |
|
|
|
FTPContext *s = h->priv_data; |
|
|
|
FTPContext *s = h->priv_data; |
|
|
|
|
|
|
|
|
|
|
|
av_dlog(h, "ftp protocol shutdown\n"); |
|
|
|
ff_dlog(h, "ftp protocol shutdown\n"); |
|
|
|
|
|
|
|
|
|
|
|
if (s->conn_data) |
|
|
|
if (s->conn_data) |
|
|
|
return ffurl_shutdown(s->conn_data, flags); |
|
|
|
return ffurl_shutdown(s->conn_data, flags); |
|
|
@ -933,7 +934,7 @@ static int ftp_parse_entry_nlst(char *line, AVIODirEntry *next) |
|
|
|
static int ftp_parse_entry_mlsd(char *mlsd, AVIODirEntry *next) |
|
|
|
static int ftp_parse_entry_mlsd(char *mlsd, AVIODirEntry *next) |
|
|
|
{ |
|
|
|
{ |
|
|
|
char *fact, *value; |
|
|
|
char *fact, *value; |
|
|
|
av_dlog(NULL, "%s\n", mlsd); |
|
|
|
ff_dlog(NULL, "%s\n", mlsd); |
|
|
|
while(fact = av_strtok(mlsd, ";", &mlsd)) { |
|
|
|
while(fact = av_strtok(mlsd, ";", &mlsd)) { |
|
|
|
if (fact[0] == ' ') { |
|
|
|
if (fact[0] == ' ') { |
|
|
|
next->name = av_strdup(&fact[1]); |
|
|
|
next->name = av_strdup(&fact[1]); |
|
|
|