ftp

FTP Protocol Helpers

Functions

FunctionDescription
_ftp_byte_atInternal byte reader.
_ftp_copyInternal: copy bytes.
_ftp_crlfInternal: write CRLF.
ftp_format_userFormat USER command: “USER user\r\n”
ftp_format_passFormat PASS command: “PASS pass\r\n”
ftp_format_retrFormat RETR command: “RETR name\r\n”
ftp_format_cwdFormat CWD command: “CWD path\r\n”
ftp_format_listFormat LIST command: “LIST\r\n”
ftp_parse_replyParse FTP reply code from buffer (first 3 digits).
_ftp_parse_numInternal: parse a decimal number from buf starting at pos, until comma or ‘)’.
_ftp_skip_numInternal: find next comma or ‘)’ position from pos.
ftp_parse_pasvParse PASV response: “227 Entering Passive Mode (h1,h2,h3,h4,p1,p2).” Extract…

Details

_ftp_byte_at

fn _ftp_byte_at(buf: &i8, idx: i64) -> i64

Internal byte reader.

_ftp_copy

fn _ftp_copy(dst: &i8, doff: i64, src: &i8, soff: i64, n: i64) -> i64

Internal: copy bytes.

_ftp_crlf

fn _ftp_crlf(out: &i8, pos: i64) -> i64

Internal: write CRLF.

ftp_format_user

fn ftp_format_user(user: &i8, ulen: i64, out: &i8) -> i64

Format USER command: “USER user\r\n”

ftp_format_pass

fn ftp_format_pass(pass: &i8, plen: i64, out: &i8) -> i64

Format PASS command: “PASS pass\r\n”

ftp_format_retr

fn ftp_format_retr(name: &i8, nlen: i64, out: &i8) -> i64

Format RETR command: “RETR name\r\n”

ftp_format_cwd

fn ftp_format_cwd(path: &i8, plen: i64, out: &i8) -> i64

Format CWD command: “CWD path\r\n”

ftp_format_list

fn ftp_format_list(out: &i8) -> i64

Format LIST command: “LIST\r\n”

ftp_parse_reply

fn ftp_parse_reply(buf: &i8, len: i64) -> i64

Parse FTP reply code from buffer (first 3 digits).

_ftp_parse_num

fn _ftp_parse_num(buf: &i8, pos: i64, len: i64) -> i64

Internal: parse a decimal number from buf starting at pos, until comma or ‘)’.

_ftp_skip_num

fn _ftp_skip_num(buf: &i8, pos: i64, len: i64) -> i64

Internal: find next comma or ‘)’ position from pos.

ftp_parse_pasv

fn ftp_parse_pasv(buf: &i8, len: i64, out_port: &i64) -> i64

Parse PASV response: “227 Entering Passive Mode (h1,h2,h3,h4,p1,p2).” Extracts port = p1*256 + p2 into out_port[0]. Returns 1 if ok.