FFmpeg
Data Structures | Macros | Enumerations | Functions | Variables
ftp.c File Reference
#include <string.h>
#include <time.h>
#include "libavutil/avstring.h"
#include "libavutil/internal.h"
#include "libavutil/parseutils.h"
#include "avformat.h"
#include "internal.h"
#include "url.h"
#include "urldecode.h"
#include "libavutil/opt.h"
#include "libavutil/bprint.h"

Go to the source code of this file.

Data Structures

struct  FTPContext
 

Macros

#define CONTROL_BUFFER_SIZE   1024
 
#define DIR_BUFFER_SIZE   4096
 
#define OFFSET(x)   offsetof(FTPContext, x)
 
#define D   AV_OPT_FLAG_DECODING_PARAM
 
#define E   AV_OPT_FLAG_ENCODING_PARAM
 

Enumerations

enum  FTPState {
  UNKNOWN, READY, DOWNLOADING, UPLOADING,
  LISTING_DIR, DISCONNECTED, ENDOFFILE
}
 
enum  FTPListingMethod { UNKNOWN_METHOD, NLST, MLSD }
 

Functions

static int ftp_close (URLContext *h)
 
static int ftp_getc (FTPContext *s)
 
static int ftp_get_line (FTPContext *s, char *line, int line_size)
 
static int ftp_status (FTPContext *s, char **line, const int response_codes[])
 
static int ftp_send_command (FTPContext *s, const char *command, const int response_codes[], char **response)
 
static void ftp_close_data_connection (FTPContext *s)
 
static void ftp_close_both_connections (FTPContext *s)
 
static int ftp_auth (FTPContext *s)
 
static int ftp_passive_mode_epsv (FTPContext *s)
 
static int ftp_passive_mode (FTPContext *s)
 
static int ftp_current_dir (FTPContext *s)
 
static int ftp_file_size (FTPContext *s)
 
static int ftp_retrieve (FTPContext *s)
 
static int ftp_store (FTPContext *s)
 
static int ftp_type (FTPContext *s)
 
static int ftp_restart (FTPContext *s, int64_t pos)
 
static int ftp_set_dir (FTPContext *s)
 
static int ftp_list_mlsd (FTPContext *s)
 
static int ftp_list_nlst (FTPContext *s)
 
static int ftp_list (FTPContext *s)
 
static int ftp_has_feature (FTPContext *s, const char *feature_name)
 
static int ftp_features (FTPContext *s)
 
static int ftp_connect_control_connection (URLContext *h)
 
static int ftp_connect_data_connection (URLContext *h)
 
static int ftp_abort (URLContext *h)
 
static int ftp_connect (URLContext *h, const char *url)
 
static int ftp_open (URLContext *h, const char *url, int flags)
 
static int64_t ftp_seek (URLContext *h, int64_t pos, int whence)
 
static int ftp_read (URLContext *h, unsigned char *buf, int size)
 
static int ftp_write (URLContext *h, const unsigned char *buf, int size)
 
static int ftp_get_file_handle (URLContext *h)
 
static int ftp_shutdown (URLContext *h, int flags)
 
static int ftp_open_dir (URLContext *h)
 
static int64_t ftp_parse_date (const char *date)
 
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 (URLContext *h, char *line, AVIODirEntry *next)
 
static int ftp_read_dir (URLContext *h, AVIODirEntry **next)
 
static int ftp_close_dir (URLContext *h)
 
static int ftp_delete (URLContext *h)
 
static int ftp_move (URLContext *h_src, URLContext *h_dst)
 

Variables

static const AVOption options []
 
static const AVClass ftp_context_class
 
const URLProtocol ff_ftp_protocol
 

Macro Definition Documentation

◆ CONTROL_BUFFER_SIZE

#define CONTROL_BUFFER_SIZE   1024

Definition at line 34 of file ftp.c.

◆ DIR_BUFFER_SIZE

#define DIR_BUFFER_SIZE   4096

Definition at line 35 of file ftp.c.

◆ OFFSET

#define OFFSET (   x)    offsetof(FTPContext, x)

Definition at line 81 of file ftp.c.

◆ D

Definition at line 82 of file ftp.c.

◆ E

Definition at line 83 of file ftp.c.

Enumeration Type Documentation

◆ FTPState

enum FTPState
Enumerator
UNKNOWN 
READY 
DOWNLOADING 
UPLOADING 
LISTING_DIR 
DISCONNECTED 
ENDOFFILE 

Definition at line 37 of file ftp.c.

◆ FTPListingMethod

Enumerator
UNKNOWN_METHOD 
NLST 
MLSD 

Definition at line 47 of file ftp.c.

Function Documentation

◆ ftp_close()

static int ftp_close ( URLContext h)
static

Definition at line 903 of file ftp.c.

Referenced by ftp_delete(), ftp_move(), and ftp_open().

◆ ftp_getc()

static int ftp_getc ( FTPContext s)
static

Definition at line 102 of file ftp.c.

Referenced by ftp_get_line().

◆ ftp_get_line()

static int ftp_get_line ( FTPContext s,
char *  line,
int  line_size 
)
static

Definition at line 119 of file ftp.c.

Referenced by ftp_status().

◆ ftp_status()

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

Definition at line 147 of file ftp.c.

Referenced by ftp_abort(), ftp_connect_control_connection(), ftp_read(), and ftp_send_command().

◆ ftp_send_command()

static int ftp_send_command ( FTPContext s,
const char *  command,
const int  response_codes[],
char **  response 
)
static

◆ ftp_close_data_connection()

static void ftp_close_data_connection ( FTPContext s)
static

Definition at line 233 of file ftp.c.

Referenced by ftp_abort(), ftp_close_both_connections(), and ftp_read().

◆ ftp_close_both_connections()

static void ftp_close_both_connections ( FTPContext s)
static

Definition at line 239 of file ftp.c.

Referenced by ftp_abort(), and ftp_close().

◆ ftp_auth()

static int ftp_auth ( FTPContext s)
static

Definition at line 245 of file ftp.c.

Referenced by ftp_connect_control_connection().

◆ ftp_passive_mode_epsv()

static int ftp_passive_mode_epsv ( FTPContext s)
static

Definition at line 277 of file ftp.c.

Referenced by ftp_connect_data_connection().

◆ ftp_passive_mode()

static int ftp_passive_mode ( FTPContext s)
static

Definition at line 319 of file ftp.c.

Referenced by ftp_connect_data_connection().

◆ ftp_current_dir()

static int ftp_current_dir ( FTPContext s)
static

Definition at line 365 of file ftp.c.

Referenced by ftp_connect().

◆ ftp_file_size()

static int ftp_file_size ( FTPContext s)
static

Definition at line 403 of file ftp.c.

Referenced by ftp_open().

◆ ftp_retrieve()

static int ftp_retrieve ( FTPContext s)
static

Definition at line 426 of file ftp.c.

Referenced by ftp_read().

◆ ftp_store()

static int ftp_store ( FTPContext s)
static

Definition at line 445 of file ftp.c.

Referenced by ftp_write().

◆ ftp_type()

static int ftp_type ( FTPContext s)
static

Definition at line 464 of file ftp.c.

Referenced by ftp_connect_control_connection().

◆ ftp_restart()

static int ftp_restart ( FTPContext s,
int64_t  pos 
)
static

Definition at line 475 of file ftp.c.

Referenced by ftp_connect_data_connection(), and ftp_open().

◆ ftp_set_dir()

static int ftp_set_dir ( FTPContext s)
static

Definition at line 487 of file ftp.c.

Referenced by ftp_open_dir().

◆ ftp_list_mlsd()

static int ftp_list_mlsd ( FTPContext s)
static

Definition at line 502 of file ftp.c.

Referenced by ftp_list().

◆ ftp_list_nlst()

static int ftp_list_nlst ( FTPContext s)
static

Definition at line 513 of file ftp.c.

Referenced by ftp_list().

◆ ftp_list()

static int ftp_list ( FTPContext s)
static

Definition at line 524 of file ftp.c.

Referenced by ftp_open_dir().

◆ ftp_has_feature()

static int ftp_has_feature ( FTPContext s,
const char *  feature_name 
)
static

Definition at line 535 of file ftp.c.

Referenced by ftp_features().

◆ ftp_features()

static int ftp_features ( FTPContext s)
static

Definition at line 543 of file ftp.c.

Referenced by ftp_connect_control_connection().

◆ ftp_connect_control_connection()

static int ftp_connect_control_connection ( URLContext h)
static

Definition at line 564 of file ftp.c.

Referenced by ftp_abort(), and ftp_connect().

◆ ftp_connect_data_connection()

static int ftp_connect_data_connection ( URLContext h)
static

Definition at line 613 of file ftp.c.

Referenced by ftp_open_dir(), ftp_read(), and ftp_write().

◆ ftp_abort()

static int ftp_abort ( URLContext h)
static

Definition at line 647 of file ftp.c.

Referenced by ftp_read(), and ftp_seek().

◆ ftp_connect()

static int ftp_connect ( URLContext h,
const char *  url 
)
static

Definition at line 685 of file ftp.c.

Referenced by ftp_delete(), ftp_move(), ftp_open(), and ftp_open_dir().

◆ ftp_open()

static int ftp_open ( URLContext h,
const char *  url,
int  flags 
)
static

Definition at line 751 of file ftp.c.

◆ ftp_seek()

static int64_t ftp_seek ( URLContext h,
int64_t  pos,
int  whence 
)
static

Definition at line 777 of file ftp.c.

◆ ftp_read()

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

Definition at line 819 of file ftp.c.

◆ ftp_write()

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

Definition at line 874 of file ftp.c.

◆ ftp_get_file_handle()

static int ftp_get_file_handle ( URLContext h)
static

Definition at line 919 of file ftp.c.

◆ ftp_shutdown()

static int ftp_shutdown ( URLContext h,
int  flags 
)
static

Definition at line 931 of file ftp.c.

◆ ftp_open_dir()

static int ftp_open_dir ( URLContext h)
static

Definition at line 943 of file ftp.c.

◆ ftp_parse_date()

static int64_t ftp_parse_date ( const char *  date)
static

Definition at line 970 of file ftp.c.

Referenced by ftp_parse_entry_mlsd().

◆ ftp_parse_entry_nlst()

static int ftp_parse_entry_nlst ( char *  line,
AVIODirEntry next 
)
static

Definition at line 978 of file ftp.c.

Referenced by ftp_parse_entry().

◆ ftp_parse_entry_mlsd()

static int ftp_parse_entry_mlsd ( char *  mlsd,
AVIODirEntry next 
)
static

Definition at line 984 of file ftp.c.

Referenced by ftp_parse_entry().

◆ ftp_parse_entry()

static int ftp_parse_entry ( URLContext h,
char *  line,
AVIODirEntry next 
)
static
Returns
0 on success, negative on error, positive on entry to discard.

Definition at line 1024 of file ftp.c.

Referenced by ftp_read_dir().

◆ ftp_read_dir()

static int ftp_read_dir ( URLContext h,
AVIODirEntry **  next 
)
static

Definition at line 1039 of file ftp.c.

◆ ftp_close_dir()

static int ftp_close_dir ( URLContext h)
static

Definition at line 1086 of file ftp.c.

◆ ftp_delete()

static int ftp_delete ( URLContext h)
static

Definition at line 1095 of file ftp.c.

◆ ftp_move()

static int ftp_move ( URLContext h_src,
URLContext h_dst 
)
static

Definition at line 1133 of file ftp.c.

Variable Documentation

◆ options

const AVOption options[]
static
Initial value:
= {
{"timeout", "set timeout of socket I/O operations", OFFSET(rw_timeout), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, D|E },
{"ftp-write-seekable", "control seekability of connection during encoding", OFFSET(write_seekable), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, E },
{"ftp-anonymous-password", "password for anonymous login. E-mail address should be used.", OFFSET(anonymous_password), AV_OPT_TYPE_STRING, { 0 }, 0, 0, D|E },
{"ftp-user", "user for FTP login. Overridden by whatever is in the URL.", OFFSET(option_user), AV_OPT_TYPE_STRING, { 0 }, 0, 0, D|E },
{"ftp-password", "password for FTP login. Overridden by whatever is in the URL.", OFFSET(option_password), AV_OPT_TYPE_STRING, { 0 }, 0, 0, D|E },
{NULL}
}

Definition at line 84 of file ftp.c.

◆ ftp_context_class

const AVClass ftp_context_class
static
Initial value:
= {
.class_name = "ftp",
.item_name = av_default_item_name,
.option = options,
}

Definition at line 93 of file ftp.c.

◆ ff_ftp_protocol

const URLProtocol ff_ftp_protocol
Initial value:
= {
.name = "ftp",
.url_open = ftp_open,
.url_read = ftp_read,
.url_write = ftp_write,
.url_seek = ftp_seek,
.url_close = ftp_close,
.url_get_file_handle = ftp_get_file_handle,
.url_shutdown = ftp_shutdown,
.priv_data_size = sizeof(FTPContext),
.priv_data_class = &ftp_context_class,
.url_open_dir = ftp_open_dir,
.url_read_dir = ftp_read_dir,
.url_close_dir = ftp_close_dir,
.url_delete = ftp_delete,
.url_move = ftp_move,
.default_whitelist = "tcp",
}

Definition at line 1174 of file ftp.c.

ftp_seek
static int64_t ftp_seek(URLContext *h, int64_t pos, int whence)
Definition: ftp.c:777
URL_PROTOCOL_FLAG_NETWORK
#define URL_PROTOCOL_FLAG_NETWORK
Definition: url.h:33
ftp_write
static int ftp_write(URLContext *h, const unsigned char *buf, int size)
Definition: ftp.c:874
FTPContext
Definition: ftp.c:53
OFFSET
#define OFFSET(x)
Definition: ftp.c:81
ftp_open
static int ftp_open(URLContext *h, const char *url, int flags)
Definition: ftp.c:751
ftp_close
static int ftp_close(URLContext *h)
Definition: ftp.c:903
ftp_shutdown
static int ftp_shutdown(URLContext *h, int flags)
Definition: ftp.c:931
ftp_context_class
static const AVClass ftp_context_class
Definition: ftp.c:93
ftp_read_dir
static int ftp_read_dir(URLContext *h, AVIODirEntry **next)
Definition: ftp.c:1039
D
#define D
Definition: ftp.c:82
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
NULL
#define NULL
Definition: coverity.c:32
E
#define E
Definition: ftp.c:83
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:237
ftp_get_file_handle
static int ftp_get_file_handle(URLContext *h)
Definition: ftp.c:919
ftp_delete
static int ftp_delete(URLContext *h)
Definition: ftp.c:1095
options
static const AVOption options[]
Definition: ftp.c:84
ftp_close_dir
static int ftp_close_dir(URLContext *h)
Definition: ftp.c:1086
ftp_open_dir
static int ftp_open_dir(URLContext *h)
Definition: ftp.c:943
ftp_read
static int ftp_read(URLContext *h, unsigned char *buf, int size)
Definition: ftp.c:819
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:225
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Definition: opt.h:244
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:474
ftp_move
static int ftp_move(URLContext *h_src, URLContext *h_dst)
Definition: ftp.c:1133
AV_OPT_TYPE_STRING
@ AV_OPT_TYPE_STRING
Definition: opt.h:229