xine-lib: xine-lib-1.2.13/src/input/input_ftp.c File Reference

xine-lib 1.2.13-20230125hg15249

Data Structures | Macros | Functions
input_ftp.c File Reference
`#include <stdio.h>`
`#include <stdlib.h>`
`#include <stdint.h>`
`#include <unistd.h>`
`#include <errno.h>`
`#include <xine/xine_internal.h>`
`#include <xine/xineutils.h>`
`#include <xine/input_plugin.h>`
`#include "group_network.h"`
`#include "http_helper.h"`
`#include "input_helper.h"`
`#include "net_buf_ctrl.h"`
`#include "tls/xine_tls.h"`

## Data Structures
struct | ftp_input_plugin_t
struct | ftp_input_class_t

## Macros
#define | LOG_MODULE "input_ftp"
#define | LOG_VERBOSE
#define | DEFAULT_FTP_PORT 21

## Functions
static int | _read_response (ftp_input_plugin_t *this)
static int | _write_command (ftp_input_plugin_t *this, const char *cmd)
static int | _send_command (ftp_input_plugin_t *this, const char *cmd)
static int | _auth_tls (ftp_input_plugin_t *this, const char *host)
static int | _connect (ftp_input_plugin_t *this, int *fd, const char *host, int port)
static int | _login (ftp_input_plugin_t *this, const char *user, const char *pass)
static int | _ftp_connect (ftp_input_plugin_t *this, xine_url_t *url)
static int | _connect_data (ftp_input_plugin_t *this, char type)
static int | _cwd (ftp_input_plugin_t *this, const char *dir)
static int | _list (ftp_input_plugin_t *this)
static off_t | _parse_off_t (const char *pt)
static int | _ftp_size (ftp_input_plugin_t *this, const char *uri)
static int | _abor (ftp_input_plugin_t *this)
static int | _rest (ftp_input_plugin_t *this, off_t offset)
static int | _retr (ftp_input_plugin_t *this, const char *uri, off_t offset)
static off_t | _ftp_read (input_plugin_t *this_gen, void *buf_gen, off_t len)
static off_t | _ftp_get_length (input_plugin_t *this_gen)
static off_t | _ftp_get_current_pos (input_plugin_t *this_gen)
static off_t | _ftp_seek (input_plugin_t *this_gen, off_t offset, int origin)
static const char * | _ftp_get_mrl (input_plugin_t *this_gen)
static int | _ftp_get_optional_data (input_plugin_t *this_gen, void *data, int data_type)
static void | _ftp_dispose (input_plugin_t *this_gen)
static int | _fill_preview (ftp_input_plugin_t *this)
static int | _ftp_open (input_plugin_t *this_gen)
static uint32_t | _ftp_get_capabilities (input_plugin_t *this_gen)
static input_plugin_t * | _get_instance (input_class_t *cls_gen, xine_stream_t *stream, const char *mrl)
static xine_mrl_t ** | _get_files (ftp_input_plugin_t *this, const char *uri, int *nFiles)
static xine_mrl_t ** | _get_dir_common (input_class_t *this_gen, const char *filename, int *nFiles)
static xine_mrl_t ** | _get_dir (input_class_t *this_gen, const char *filename, int *nFiles)
static xine_mrl_t ** | _get_dir_es (input_class_t *this_gen, const char *filename, int *nFiles)
static void | _dispose_class (input_class_t *this_gen)
void * | input_ftp_init_class (xine_t *xine, const void *data)
void * | input_ftpes_init_class (xine_t *xine, const void *data)

## Macro Definition Documentation

## ◆ DEFAULT_FTP_PORT

#define DEFAULT_FTP_PORT 21

Referenced by _connect().

## ◆ LOG_MODULE

#define LOG_MODULE "input_ftp"

Referenced by _connect_data(), _cwd(), _fill_preview(), _ftp_connect(), _ftp_read(), _ftp_seek(), _ftp_size(), _get_dir_common(), _get_files(), _list(), _retr(), and _write_command().

## ◆ LOG_VERBOSE

#define LOG_VERBOSE

## Function Documentation

## ◆ _abor()

static int _abor | ( | ftp_input_plugin_t * | this | ) |
| static

References _read_response(), _write_command(), and _x_io_tcp_close().

Referenced by _ftp_seek().

## ◆ _auth_tls()

static int _auth_tls | ( | ftp_input_plugin_t * | this,
|  | const char * | host )
| static

References _send_command(), and _x_tls_handshake().

Referenced by _ftp_connect().

## ◆ _connect()

static int _connect | ( | ftp_input_plugin_t * | this,
|  | int * | fd,
|  | const char * | host,
|  | int | port )
| static

References _x_assert, _x_io_tcp_connect(), _x_io_tcp_connect_finish(), DEFAULT_FTP_PORT, XIO_READY, and XIO_TIMEOUT.

Referenced by _connect_data(), and _ftp_connect().

## ◆ _connect_data()

static int _connect_data | ( | ftp_input_plugin_t * | this,
|  | char | type )
| static

References _connect(), _send_command(), _x_asprintf(), _x_assert, LOG_MODULE, type, XINE_VERBOSITY_LOG, and xprintf.

Referenced by _list(), and _retr().

## ◆ _cwd()

static int _cwd | ( | ftp_input_plugin_t * | this,
|  | const char * | dir )
| static

References _send_command(), _x_asprintf(), LOG_MODULE, XINE_VERBOSITY_LOG, and xprintf.

Referenced by _get_files().

## ◆ _dispose_class()

static void _dispose_class | ( | input_class_t * | this_gen | ) |
| static

References _x_input_free_mrls(), and ftp_input_class_t::mrls.

Referenced by input_ftp_init_class().

## ◆ _fill_preview()

static int _fill_preview | ( | ftp_input_plugin_t * | this | ) |
| static

References _ftp_read(), LOG_MODULE, XINE_VERBOSITY_LOG, and xprintf.

Referenced by _ftp_open().

## ◆ _ftp_connect()

static int _ftp_connect | ( | ftp_input_plugin_t * | this,
|  | xine_url_t * | url )
| static

References _auth_tls(), _connect(), _login(), _read_response(), _send_command(), _x_io_tcp_close(), _x_message(), _x_tls_get_verify_tls_cert(), _x_tls_init(), xine_url_t::host, LOG_MODULE, NULL, xine_url_t::password, xine_url_t::port, xine_url_t::proto, xine_url_t::user, XINE_MSG_AUTHENTICATION_NEEDED, XINE_MSG_SECURITY, XINE_VERBOSITY_LOG, and xprintf.

Referenced by _ftp_open(), and _get_dir_common().

## ◆ _ftp_dispose()

static void _ftp_dispose | ( | input_plugin_t * | this_gen | ) |
| static

References _x_freep(), _x_freep_wipe_string(), _x_io_tcp_close(), _x_tls_close(), nbc_close, and NULL.

Referenced by _get_instance().

## ◆ _ftp_get_capabilities()

static uint32_t _ftp_get_capabilities | ( | input_plugin_t * | this_gen | ) |
| static

References INPUT_CAP_PREVIEW, INPUT_CAP_SIZED_PREVIEW, and INPUT_CAP_SLOW_SEEKABLE.

Referenced by _get_instance().

## ◆ _ftp_get_current_pos()

static off_t _ftp_get_current_pos | ( | input_plugin_t * | this_gen | ) |
| static

Referenced by _get_instance().

## ◆ _ftp_get_length()

static off_t _ftp_get_length | ( | input_plugin_t * | this_gen | ) |
| static

Referenced by _get_instance().

## ◆ _ftp_get_mrl()

static const char * _ftp_get_mrl | ( | input_plugin_t * | this_gen | ) |
| static

Referenced by _get_instance().

## ◆ _ftp_get_optional_data()

static int _ftp_get_optional_data | ( | input_plugin_t * | this_gen,
|  | void * | data,
|  | int | data_type )
| static

References INPUT_OPTIONAL_DATA_PREVIEW, INPUT_OPTIONAL_DATA_SIZED_PREVIEW, and INPUT_OPTIONAL_UNSUPPORTED.

Referenced by _get_instance().

## ◆ _ftp_open()

static int _ftp_open | ( | input_plugin_t * | this_gen | ) |
| static

References _fill_preview(), _ftp_connect(), _ftp_size(), _retr(), _x_freep_wipe_string(), _x_message(), _x_url_cleanup(), _x_url_parse2(), NULL, xine_url_t::uri, and XINE_MSG_GENERAL_WARNING.

Referenced by _get_instance().

## ◆ _ftp_read()

static off_t _ftp_read | ( | input_plugin_t * | this_gen,
|  | void * | buf_gen,
|  | off_t | len )
| static

References _x_action_pending(), _x_io_tcp_read(), LOG_MODULE, XINE_VERBOSITY_LOG, and xprintf.

Referenced by _fill_preview(), and _get_instance().

## ◆ _ftp_seek()

static off_t _ftp_seek | ( | input_plugin_t * | this_gen,
|  | off_t | offset,
|  | int | origin )
| static

References _abor(), _retr(), _x_input_seek_preview(), _x_input_translate_seek(), LOG_MODULE, XINE_VERBOSITY_LOG, and xprintf.

Referenced by _get_instance().

## ◆ _ftp_size()

static int _ftp_size | ( | ftp_input_plugin_t * | this,
|  | const char * | uri )
| static

References _parse_off_t(), _send_command(), _x_asprintf(), LOG_MODULE, XINE_VERBOSITY_LOG, and xprintf.

Referenced by _ftp_open().

## ◆ _get_dir()

static xine_mrl_t ** _get_dir | ( | input_class_t * | this_gen,
|  | const char * | filename,
|  | int * | nFiles )
| static

References _get_dir_common(), _x_input_free_mrls(), _x_input_get_default_server_mrls(), xine_s::config, ftp_input_class_t::mrls, and ftp_input_class_t::xine.

Referenced by input_ftp_init_class().

## ◆ _get_dir_common()

static xine_mrl_t ** _get_dir_common | ( | input_class_t * | this_gen,
|  | const char * | filename,
|  | int * | nFiles )
| static

References _ftp_connect(), _get_files(), _get_instance(), _x_assert, _x_url_cleanup(), _x_url_parse2(), input(), LOG_MODULE, ftp_input_class_t::mrls, NULL, xine_url_t::uri, ftp_input_class_t::xine, XINE_VERBOSITY_LOG, and xprintf.

Referenced by _get_dir(), and _get_dir_es().

## ◆ _get_dir_es()

static xine_mrl_t ** _get_dir_es | ( | input_class_t * | this_gen,
|  | const char * | filename,
|  | int * | nFiles )
| static

References _get_dir_common(), _x_input_free_mrls(), _x_input_get_default_server_mrls(), xine_s::config, ftp_input_class_t::mrls, and ftp_input_class_t::xine.

Referenced by input_ftpes_init_class().

## ◆ _get_files()

static xine_mrl_t ** _get_files | ( | ftp_input_plugin_t * | this,
|  | const char * | uri,
|  | int * | nFiles )
| static

References _cwd(), _list(), _x_asprintf(), _x_input_alloc_mrls(), _x_input_get_show_hidden_files(), _x_input_realloc_mrls(), _x_input_sort_mrls(), _x_io_tcp_read_line(), xine_s::config, LOG_MODULE, lprintf, xine_mrl_s::mrl, mrl_file, mrl_file_directory, mrl_file_normal, mrl_net, ftp_input_class_t::mrls, NULL, xine_mrl_s::origin, xine_mrl_s::type, ftp_input_class_t::xine, XINE_VERBOSITY_LOG, and xprintf.

Referenced by _get_dir_common().

## ◆ _get_instance()

static input_plugin_t * _get_instance | ( | input_class_t * | cls_gen,
|  | xine_stream_t * | stream,
|  | const char * | mrl )
| static

References _ftp_dispose(), _ftp_get_capabilities(), _ftp_get_current_pos(), _ftp_get_length(), _ftp_get_mrl(), _ftp_get_optional_data(), _ftp_open(), _ftp_read(), _ftp_seek(), _x_input_default_get_blocksize(), _x_input_default_read_block(), _x_mrl_remove_auth(), nbc_init, NULL, and ftp_input_class_t::xine.

Referenced by _get_dir_common(), and input_ftp_init_class().

## ◆ _list()

static int _list | ( | ftp_input_plugin_t * | this | ) |
| static

References _connect_data(), _send_command(), LOG_MODULE, XINE_VERBOSITY_DEBUG, XINE_VERBOSITY_LOG, and xprintf.

Referenced by _get_files().

## ◆ _login()

static int _login | ( | ftp_input_plugin_t * | this,
|  | const char * | user,
|  | const char * | pass )
| static

References _send_command(), _x_asprintf(), and _x_freep_wipe_string().

Referenced by _ftp_connect().

## ◆ _parse_off_t()

static off_t _parse_off_t | ( | const char * | pt | ) |
| static

Referenced by _ftp_size(), and _retr().

## ◆ _read_response()

static int _read_response | ( | ftp_input_plugin_t * | this | ) |
| static

References _x_tls_read_line(), and lprintf.

Referenced by _abor(), _ftp_connect(), and _send_command().

## ◆ _rest()

static int _rest | ( | ftp_input_plugin_t * | this,
|  | off_t | offset )
| static

References _send_command(), and _x_asprintf().

Referenced by _retr().

## ◆ _retr()

static int _retr | ( | ftp_input_plugin_t * | this,
|  | const char * | uri,
|  | off_t | offset )
| static

References _connect_data(), _parse_off_t(), _rest(), _send_command(), _x_asprintf(), LOG_MODULE, XINE_VERBOSITY_LOG, and xprintf.

Referenced by _ftp_open(), and _ftp_seek().

## ◆ _send_command()

static int _send_command | ( | ftp_input_plugin_t * | this,
|  | const char * | cmd )
| static

References _read_response(), and _write_command().

Referenced by _auth_tls(), _connect_data(), _cwd(), _ftp_connect(), _ftp_size(), _list(), _login(), _rest(), and _retr().

## ◆ _write_command()

static int _write_command | ( | ftp_input_plugin_t * | this,
|  | const char * | cmd )
| static

References _x_tls_write(), LOG_MODULE, lprintf, XINE_VERBOSITY_LOG, and xprintf.

Referenced by _abor(), and _send_command().

## ◆ input_ftp_init_class()

void * input_ftp_init_class | ( | xine_t * | xine,
|  | const void * | data )

References _dispose_class(), _get_dir(), _get_instance(), _x_input_register_default_servers(), _x_input_register_show_hidden_files(), xine_s::config, input_class_s::description, input_class_s::dispose, input_class_s::eject_media, input_class_s::get_autoplay_list, input_class_s::get_dir, input_class_s::get_instance, input_class_s::identifier, ftp_input_class_t::input_class, N_, NULL, and ftp_input_class_t::xine.

Referenced by input_ftpes_init_class().

## ◆ input_ftpes_init_class()

void * input_ftpes_init_class | ( | xine_t * | xine,
|  | const void * | data )

References _get_dir_es(), input_class_s::description, input_class_s::get_dir, input_class_s::identifier, ftp_input_class_t::input_class, input_ftp_init_class(), N_, and ftp_input_class_t::xine.