36#ifdef HAVE_SYS_TYPES_H
39#include <sys/socket.h>
40#include <netinet/in.h>
50#ifdef HAVE_SYS_SELECT_H
51#include <sys/select.h>
55#include <openssl/ssl.h>
56#include <openssl/err.h>
64# define ETIMEDOUT WSAETIMEDOUT
75 const size_t args_len);
83static int ftp_readline(
ftpbuf_t *ftp);
86static int ftp_getresp(
ftpbuf_t *ftp);
98static void data_close(
ftpbuf_t *ftp);
101static char** ftp_genlist(
ftpbuf_t *ftp,
const char *cmd,
const size_t cmd_len,
const char *path,
const size_t path_len);
110 struct in_addr
ia[2];
125 ftp =
ecalloc(1,
sizeof(*ftp));
127 tv.tv_sec = timeout_sec;
143 if (getsockname(ftp->
fd, (
struct sockaddr*) &ftp->
localaddr, &
size) != 0) {
148 if (!ftp_getresp(ftp) || ftp->
resp != 220) {
171 if (ftp->last_ssl_session) {
172 SSL_SESSION_free(ftp->last_ssl_session);
181 if (ftp->ssl_active) {
182 ftp_ssl_shutdown(ftp, ftp->
fd, ftp->ssl_handle);
219 if (!ftp_putcmd(ftp,
"QUIT",
sizeof(
"QUIT")-1,
NULL, (
size_t) 0)) {
222 if (!ftp_getresp(ftp) || ftp->
resp != 221) {
236static int ftp_ssl_new_session_cb(SSL *ssl, SSL_SESSION *sess)
238 ftpbuf_t *ftp = SSL_get_app_data(ssl);
241 if (ftp->last_ssl_session) {
242 SSL_SESSION_free(ftp->last_ssl_session);
244 ftp->last_ssl_session = SSL_get1_session(ssl);
257 long ssl_ctx_options = SSL_OP_ALL;
266 if (ftp->use_ssl && !ftp->ssl_active) {
267 if (!ftp_putcmd(ftp,
"AUTH",
sizeof(
"AUTH")-1,
"TLS",
sizeof(
"TLS")-1)) {
270 if (!ftp_getresp(ftp)) {
274 if (ftp->
resp != 234) {
275 if (!ftp_putcmd(ftp,
"AUTH",
sizeof(
"AUTH")-1,
"SSL",
sizeof(
"SSL")-1)) {
278 if (!ftp_getresp(ftp)) {
282 if (ftp->
resp != 334) {
286 ftp->use_ssl_for_data = 1;
290 ctx = SSL_CTX_new(SSLv23_client_method());
296 ssl_ctx_options &= ~SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS;
297 SSL_CTX_set_options(ctx, ssl_ctx_options);
301 SSL_CTX_set_session_cache_mode(ctx, SSL_SESS_CACHE_BOTH | SSL_SESS_CACHE_NO_INTERNAL);
302 SSL_CTX_sess_set_new_cb(ctx, ftp_ssl_new_session_cb);
304 ftp->ssl_handle = SSL_new(ctx);
305 SSL_set_app_data(ftp->ssl_handle, ftp);
308 if (ftp->ssl_handle ==
NULL) {
313 SSL_set_fd(ftp->ssl_handle, ftp->
fd);
316 res = SSL_connect(ftp->ssl_handle);
317 err = SSL_get_error(ftp->ssl_handle,
res);
325 case SSL_ERROR_ZERO_RETURN:
327 SSL_shutdown(ftp->ssl_handle);
330 case SSL_ERROR_WANT_READ:
331 case SSL_ERROR_WANT_WRITE: {
347 SSL_shutdown(ftp->ssl_handle);
348 SSL_free(ftp->ssl_handle);
358 if (!ftp_putcmd(ftp,
"PBSZ",
sizeof(
"PBSZ")-1,
"0",
sizeof(
"0")-1)) {
361 if (!ftp_getresp(ftp)) {
366 if (!ftp_putcmd(ftp,
"PROT",
sizeof(
"PROT")-1,
"P",
sizeof(
"P")-1)) {
369 if (!ftp_getresp(ftp)) {
373 ftp->use_ssl_for_data = (ftp->
resp >= 200 && ftp->
resp <=299);
378 if (!ftp_putcmd(ftp,
"USER",
sizeof(
"USER")-1, user, user_len)) {
381 if (!ftp_getresp(ftp)) {
384 if (ftp->
resp == 230) {
387 if (ftp->
resp != 331) {
390 if (!ftp_putcmd(ftp,
"PASS",
sizeof(
"PASS")-1,
pass, pass_len)) {
393 if (!ftp_getresp(ftp)) {
396 return (ftp->
resp == 230);
412 if (!ftp_putcmd(ftp,
"REIN",
sizeof(
"REIN")-1,
NULL, (
size_t) 0)) {
415 if (!ftp_getresp(ftp) || ftp->
resp != 220) {
437 if (!ftp_putcmd(ftp,
"SYST",
sizeof(
"SYST")-1,
NULL, (
size_t) 0)) {
440 if (!ftp_getresp(ftp) || ftp->
resp != 215) {
444 while (*syst ==
' ') {
472 if (!ftp_putcmd(ftp,
"PWD",
sizeof(
"PWD")-1,
NULL, (
size_t) 0)) {
475 if (!ftp_getresp(ftp) || ftp->
resp != 257) {
498 if (!ftp_putcmd(ftp,
"SITE EXEC",
sizeof(
"SITE EXEC")-1, cmd, cmd_len)) {
501 if (!ftp_getresp(ftp) || ftp->
resp != 200) {
516 if (!ftp_putcmd(ftp, cmd, cmd_len,
NULL, (
size_t) 0)) {
520 while (ftp_readline(ftp)) {
522 if (isdigit(ftp->
inbuf[0]) && isdigit(ftp->
inbuf[1]) && isdigit(ftp->
inbuf[2]) && ftp->
inbuf[3] ==
' ') {
542 if (!ftp_putcmd(ftp,
"CWD",
sizeof(
"CWD")-1,
dir, dir_len)) {
545 if (!ftp_getresp(ftp) || ftp->
resp != 250) {
565 if (!ftp_putcmd(ftp,
"CDUP",
sizeof(
"CDUP")-1,
NULL, (
size_t) 0)) {
568 if (!ftp_getresp(ftp) || ftp->
resp != 250) {
585 if (!ftp_putcmd(ftp,
"MKD",
sizeof(
"MKD")-1,
dir, dir_len)) {
588 if (!ftp_getresp(ftp) || ftp->
resp != 257) {
593 return zend_string_init(
dir, dir_len, 0);
599 ret = zend_string_init(mkd,
end - mkd, 0);
613 if (!ftp_putcmd(ftp,
"RMD",
sizeof(
"RMD")-1,
dir, dir_len)) {
616 if (!ftp_getresp(ftp) || ftp->
resp != 250) {
640 if (!ftp_putcmd(ftp,
"SITE",
sizeof(
"SITE")-1,
buffer, buffer_len)) {
647 if (!ftp_getresp(ftp) || ftp->
resp != 200) {
668 if (buffer_len < 0) {
672 if (!ftp_putcmd(ftp,
"ALLO",
sizeof(
"ALLO")-1,
buffer, buffer_len)) {
676 if (!ftp_getresp(ftp)) {
684 if (ftp->
resp < 200 || ftp->
resp >= 300) {
696 return ftp_genlist(ftp,
"NLST",
sizeof(
"NLST")-1, path, path_len);
704 return ftp_genlist(ftp, ((recursive) ?
"LIST -R" :
"LIST"), ((recursive) ?
sizeof(
"LIST -R")-1 :
sizeof(
"LIST")-1), path, path_len);
712 return ftp_genlist(ftp,
"MLSD",
sizeof(
"MLSD")-1, path, path_len);
723 const char *sp = memchr(input,
' ',
end - input);
734 while (input <
end) {
735 const char *semi, *eq;
738 semi = memchr(input,
';',
end - input);
745 eq = memchr(input,
'=', semi - input);
764 const char *typechar;
779 if (!ftp_putcmd(ftp,
"TYPE",
sizeof(
"TYPE")-1, typechar, 1)) {
782 if (!ftp_getresp(ftp) || ftp->
resp != 200) {
800 struct sockaddr_in *
sin;
805 if (pasv && ftp->
pasv == 2) {
814 sa = (
struct sockaddr *) &ftp->
pasvaddr;
816 if (getpeername(ftp->
fd, sa, &
n) < 0) {
822 struct sockaddr_in6 *sin6 = (
struct sockaddr_in6 *) sa;
826 if (!ftp_putcmd(ftp,
"EPSV",
sizeof(
"EPSV")-1,
NULL, (
size_t) 0)) {
829 if (!ftp_getresp(ftp)) {
832 if (ftp->
resp == 229) {
840 if (*
ptr == delimiter) {
845 sin6->sin6_port = htons((
unsigned short) strtoul(
ptr, &
endptr, 10));
857 if (!ftp_putcmd(ftp,
"PASV",
sizeof(
"PASV")-1,
NULL, (
size_t) 0)) {
860 if (!ftp_getresp(ftp) || ftp->
resp != 227) {
865 n =
sscanf(
ptr,
"%lu,%lu,%lu,%lu,%lu,%lu", &b[0], &b[1], &b[2], &b[3], &b[4], &b[5]);
869 for (
n = 0;
n < 6;
n++) {
872 sin = (
struct sockaddr_in *) sa;
895 if (!ftp_type(ftp,
type)) {
899 if ((
data = ftp_getdata(ftp)) ==
NULL) {
909 if (!ftp_putcmd(ftp,
"REST",
sizeof(
"REST")-1,
arg, arg_len)) {
912 if (!ftp_getresp(ftp) || (ftp->
resp != 350)) {
917 if (!ftp_putcmd(ftp,
"RETR",
sizeof(
"RETR")-1, path, path_len)) {
920 if (!ftp_getresp(ftp) || (ftp->
resp != 150 && ftp->
resp != 125)) {
929 if (rcvd == (
size_t)-1) {
938 char *e =
ptr + rcvd;
947 while (e >
ptr && (
s = memchr(
ptr,
'\r', (e -
ptr)))) {
949 if (*(
s + 1) ==
'\n') {
966 if (!ftp_getresp(ftp) || (ftp->
resp != 226 && ftp->
resp != 250)) {
982 uint32_t old_flags = instream->
flags & flags_mask;
995 ptr += line_length - 1;
1011 instream->
flags = (instream->
flags & ~flags_mask) | old_flags;
1015 if (send_once_and_return) {
1021 instream->
flags = (instream->
flags & ~flags_mask) | old_flags;
1041 if (send_once_and_return) {
1060 if (!ftp_type(ftp,
type)) {
1063 if ((
data = ftp_getdata(ftp)) ==
NULL) {
1073 if (!ftp_putcmd(ftp,
"REST",
sizeof(
"REST")-1,
arg, arg_len)) {
1076 if (!ftp_getresp(ftp) || (ftp->
resp != 350)) {
1081 if (!ftp_putcmd(ftp,
"STOR",
sizeof(
"STOR")-1, path, path_len)) {
1084 if (!ftp_getresp(ftp) || (ftp->
resp != 150 && ftp->
resp != 125)) {
1091 if (ftp_send_stream_to_data_socket(ftp,
data, instream,
type,
false) !=
SUCCESS) {
1097 if (!ftp_getresp(ftp) || (ftp->
resp != 226 && ftp->
resp != 250 && ftp->
resp != 200)) {
1117 if (!ftp_type(ftp,
type)) {
1120 if ((
data = ftp_getdata(ftp)) ==
NULL) {
1125 if (!ftp_putcmd(ftp,
"APPE",
sizeof(
"APPE")-1, path, path_len)) {
1128 if (!ftp_getresp(ftp) || (ftp->
resp != 150 && ftp->
resp != 125)) {
1135 if (ftp_send_stream_to_data_socket(ftp,
data, instream,
type,
false) !=
SUCCESS) {
1141 if (!ftp_getresp(ftp) || (ftp->
resp != 226 && ftp->
resp != 250 && ftp->
resp != 200)) {
1161 if (!ftp_putcmd(ftp,
"SIZE",
sizeof(
"SIZE")-1, path, path_len)) {
1164 if (!ftp_getresp(ftp) || ftp->
resp != 213) {
1176 struct tm *gmt, tmbuf;
1184 if (!ftp_putcmd(ftp,
"MDTM",
sizeof(
"MDTM")-1, path, path_len)) {
1187 if (!ftp_getresp(ftp) || ftp->
resp != 213) {
1192 n =
sscanf(
ptr,
"%4d%2d%2d%2d%2d%2d", &tm.tm_year, &tm.tm_mon, &tm.tm_mday, &tm.tm_hour, &tm.tm_min, &tm.tm_sec);
1209 tm.tm_sec += stamp -
mktime(gmt);
1210 tm.tm_isdst = gmt->tm_isdst;
1225 if (!ftp_putcmd(ftp,
"DELE",
sizeof(
"DELE")-1, path, path_len)) {
1228 if (!ftp_getresp(ftp) || ftp->
resp != 250) {
1243 if (!ftp_putcmd(ftp,
"RNFR",
sizeof(
"RNFR")-1, src, src_len)) {
1246 if (!ftp_getresp(ftp) || ftp->
resp != 350) {
1249 if (!ftp_putcmd(ftp,
"RNTO",
sizeof(
"RNTO")-1, dest, dest_len)) {
1252 if (!ftp_getresp(ftp) || ftp->
resp != 250) {
1266 if (!ftp_putcmd(ftp,
"SITE",
sizeof(
"SITE")-1, cmd, cmd_len)) {
1269 if (!ftp_getresp(ftp) || ftp->
resp < 200 || ftp->
resp >= 300) {
1281ftp_putcmd(
ftpbuf_t *ftp,
const char *cmd,
const size_t cmd_len,
const char *
args,
const size_t args_len)
1310 ftp->
inbuf[0] =
'\0';
1339 for (eol =
data; rcvd; rcvd--, eol++) {
1342 ftp->
extra = eol + 1;
1343 if (rcvd > 1 && *(eol + 1) ==
'\n') {
1347 if ((ftp->
extralen = --rcvd) == 0) {
1351 }
else if (*eol ==
'\n') {
1353 ftp->
extra = eol + 1;
1354 if ((ftp->
extralen = --rcvd) == 0) {
1362 if ((rcvd = my_recv(ftp, ftp->
fd,
data,
size)) < 1) {
1384 if (!ftp_readline(ftp)) {
1389 if (isdigit(ftp->
inbuf[0]) && isdigit(ftp->
inbuf[1]) && isdigit(ftp->
inbuf[2]) && ftp->
inbuf[3] ==
' ') {
1395 if (!isdigit(ftp->
inbuf[0]) || !isdigit(ftp->
inbuf[1]) || !isdigit(ftp->
inbuf[2])) {
1399 ftp->
resp = 100 * (ftp->
inbuf[0] -
'0') + 10 * (ftp->
inbuf[1] -
'0') + (ftp->
inbuf[2] -
'0');
1434 if (ftp->use_ssl && ftp->
fd ==
s && ftp->ssl_active) {
1435 handle = ftp->ssl_handle;
1437 }
else if (ftp->use_ssl && ftp->
fd !=
s && ftp->use_ssl_for_data && ftp->
data->ssl_active) {
1441 return my_send_wrapper_with_restart(
s,
buf,
size, 0);
1449 case SSL_ERROR_NONE:
1453 case SSL_ERROR_ZERO_RETURN:
1458 case SSL_ERROR_WANT_READ:
1459 case SSL_ERROR_WANT_CONNECT: {
1480 return my_send_wrapper_with_restart(
s,
buf,
size, 0);
1490 n = php_pollfd_for_ms(
fd, events, (
int) (timeout_hr / 1000000));
1494 if (delta_ns > timeout_hr) {
1500 timeout_hr -= delta_ns;
1538 buf = (
char*)
buf + sent;
1572 if (ftp->use_ssl && ftp->
fd ==
s && ftp->ssl_active) {
1573 handle = ftp->ssl_handle;
1575 }
else if (ftp->use_ssl && ftp->
fd !=
s && ftp->use_ssl_for_data && ftp->
data->ssl_active) {
1586 case SSL_ERROR_NONE:
1590 case SSL_ERROR_ZERO_RETURN:
1595 case SSL_ERROR_WANT_READ:
1596 case SSL_ERROR_WANT_CONNECT: {
1617 nr_bytes = my_recv_wrapper_with_restart(
s,
buf,
len, 0);
1692 return accept(
s,
addr, addrlen);
1703 struct sockaddr *sa;
1706 char arg[
sizeof(
"255, 255, 255, 255, 255, 255")];
1717 data->listener = -1;
1721 sa = (
struct sockaddr *) &ftp->
localaddr;
1756 if (bind(
fd, (
struct sockaddr*) &
addr,
size) != 0) {
1761 if (getsockname(
fd, (
struct sockaddr*) &
addr, &
size) != 0) {
1766 if (listen(
fd, 5) != 0) {
1776 char eprtarg[INET6_ADDRSTRLEN +
sizeof(
"|x||xxxxx|")];
1777 char out[INET6_ADDRSTRLEN];
1783 eprtarg_len =
snprintf(eprtarg,
sizeof(eprtarg),
"|2|%s|%hu|",
out, ntohs(((
struct sockaddr_in6 *) &
addr)->sin6_port));
1785 if (eprtarg_len < 0) {
1789 if (!ftp_putcmd(ftp,
"EPRT",
sizeof(
"EPRT")-1, eprtarg, eprtarg_len)) {
1793 if (!ftp_getresp(ftp) || ftp->
resp != 200) {
1803 ipbox.
ia[0] = ((
struct sockaddr_in*) sa)->sin_addr;
1804 ipbox.
s[2] = ((
struct sockaddr_in*) &
addr)->sin_port;
1805 arg_len =
snprintf(
arg,
sizeof(
arg),
"%u,%u,%u,%u,%u,%u",
ipbox.
c[0],
ipbox.
c[1],
ipbox.
c[2],
ipbox.
c[3],
ipbox.
c[4],
ipbox.
c[5]);
1810 if (!ftp_putcmd(ftp,
"PORT",
sizeof(
"PORT")-1,
arg, arg_len)) {
1813 if (!ftp_getresp(ftp) || ftp->
resp != 200) {
1838 SSL_SESSION *session;
1843 if (
data->fd != -1) {
1847 data->fd = my_accept(ftp,
data->listener, (
struct sockaddr*) &
addr, &
size);
1849 data->listener = -1;
1851 if (
data->fd == -1) {
1860 if (ftp->use_ssl && ftp->use_ssl_for_data) {
1861 ctx = SSL_get_SSL_CTX(ftp->ssl_handle);
1867 data->ssl_handle = SSL_new(ctx);
1873 SSL_set_fd(
data->ssl_handle,
data->fd);
1876 SSL_copy_session_id(
data->ssl_handle, ftp->ssl_handle);
1880 session = ftp->last_ssl_session;
1881 if (session ==
NULL) {
1883 SSL_free(
data->ssl_handle);
1888 SSL_set_app_data(
data->ssl_handle, ftp);
1889 res = SSL_set_session(
data->ssl_handle, session);
1892 SSL_free(
data->ssl_handle);
1897 res = SSL_connect(
data->ssl_handle);
1901 case SSL_ERROR_NONE:
1905 case SSL_ERROR_ZERO_RETURN:
1907 SSL_shutdown(
data->ssl_handle);
1910 case SSL_ERROR_WANT_READ:
1911 case SSL_ERROR_WANT_WRITE: {
1927 SSL_shutdown(
data->ssl_handle);
1928 SSL_free(
data->ssl_handle);
1933 data->ssl_active = 1;
1951 int done = 1,
err, nread;
1952 unsigned long sslerror;
1954 err = SSL_shutdown(ssl_handle);
1958 else if (
err == 0) {
1965 nread = SSL_read(ssl_handle,
buf,
sizeof(
buf));
1967 err = SSL_get_error(ssl_handle, nread);
1969 case SSL_ERROR_NONE:
1970 case SSL_ERROR_ZERO_RETURN:
1975 case SSL_ERROR_WANT_READ:
1978 case SSL_ERROR_WANT_WRITE:
1982 case SSL_ERROR_SYSCALL:
1989 if ((sslerror = ERR_get_error())) {
1990 ERR_error_string_n(sslerror,
buf,
sizeof(
buf));
2000 (
void)SSL_free(ssl_handle);
2013 if (
data->listener != -1) {
2015 if (
data->ssl_active) {
2017 ftp_ssl_shutdown(ftp,
data->listener,
data->ssl_handle);
2018 data->ssl_active = 0;
2023 if (
data->fd != -1) {
2025 if (
data->ssl_active) {
2027 ftp_ssl_shutdown(ftp,
data->fd,
data->ssl_handle);
2028 data->ssl_active = 0;
2040ftp_genlist(
ftpbuf_t *ftp,
const char *cmd,
const size_t cmd_len,
const char *path,
const size_t path_len)
2062 if ((
data = ftp_getdata(ftp)) ==
NULL) {
2067 if (!ftp_putcmd(ftp, cmd, cmd_len, path, path_len)) {
2070 if (!ftp_getresp(ftp) || (ftp->
resp != 150 && ftp->
resp != 125 && ftp->
resp != 226)) {
2075 if (ftp->
resp == 226) {
2078 return ecalloc(1,
sizeof(
char*));
2089 if (rcvd == (
size_t)-1 || rcvd > ((
size_t)(-1))-
size) {
2097 if (*
ptr ==
'\n' && lastch ==
'\r') {
2115 if (
ch ==
'\n' && lastch ==
'\r') {
2127 if (!ftp_getresp(ftp) || (ftp->
resp != 226 && ftp->
resp != 250)) {
2157 if (!ftp_getresp(ftp) || (ftp->
resp != 226 && ftp->
resp != 250)) {
2162 if (!ftp_type(ftp,
type)) {
2166 if ((
data = ftp_getdata(ftp)) ==
NULL) {
2176 if (!ftp_putcmd(ftp,
"REST",
sizeof(
"REST")-1,
arg, arg_len)) {
2179 if (!ftp_getresp(ftp) || (ftp->
resp != 350)) {
2184 if (!ftp_putcmd(ftp,
"RETR",
sizeof(
"RETR")-1, path, path_len)) {
2187 if (!ftp_getresp(ftp) || (ftp->
resp != 150 && ftp->
resp != 125)) {
2229 if (rcvd == (
size_t)-1) {
2235 if (lastch ==
'\r' && *
ptr !=
'\n') {
2257 if (!ftp_getresp(ftp) || (ftp->
resp != 226 && ftp->
resp != 250)) {
2280 if (!ftp_type(ftp,
type)) {
2283 if ((
data = ftp_getdata(ftp)) ==
NULL) {
2292 if (!ftp_putcmd(ftp,
"REST",
sizeof(
"REST")-1,
arg, arg_len)) {
2295 if (!ftp_getresp(ftp) || (ftp->
resp != 350)) {
2300 if (!ftp_putcmd(ftp,
"STOR",
sizeof(
"STOR")-1, path, path_len)) {
2303 if (!ftp_getresp(ftp) || (ftp->
resp != 150 && ftp->
resp != 125)) {
2342 if (!ftp_getresp(ftp) || (ftp->
resp != 226 && ftp->
resp != 250)) {
sscanf(string $string, string $format, mixed &... $vars)
strrchr(string $haystack, string $needle, bool $before_needle=false)
dir(string $directory, $context=null)
strpbrk(string $string, string $characters)
strchr(string $haystack, string $needle, bool $before_needle=false)
memset(ptr, 0, type->size)
zend_ffi_ctype_name_buf buf
int ftp_delete(ftpbuf_t *ftp, const char *path, const size_t path_len)
int ftp_rename(ftpbuf_t *ftp, const char *src, const size_t src_len, const char *dest, const size_t dest_len)
int ftp_append(ftpbuf_t *ftp, const char *path, const size_t path_len, php_stream *instream, ftptype_t type)
time_t ftp_mdtm(ftpbuf_t *ftp, const char *path, const size_t path_len)
int ftp_get(ftpbuf_t *ftp, php_stream *outstream, const char *path, const size_t path_len, ftptype_t type, zend_long resumepos)
int ftp_put(ftpbuf_t *ftp, const char *path, const size_t path_len, php_stream *instream, ftptype_t type, zend_long startpos)
int ftp_nb_get(ftpbuf_t *ftp, php_stream *outstream, const char *path, const size_t path_len, ftptype_t type, zend_long resumepos)
char ** ftp_list(ftpbuf_t *ftp, const char *path, const size_t path_len, int recursive)
int ftp_mlsd_parse_line(HashTable *ht, const char *input)
const char * ftp_syst(ftpbuf_t *ftp)
zend_string * ftp_mkdir(ftpbuf_t *ftp, const char *dir, const size_t dir_len)
int data_writeable(ftpbuf_t *ftp, php_socket_t s)
int ftp_cdup(ftpbuf_t *ftp)
int ftp_site(ftpbuf_t *ftp, const char *cmd, const size_t cmd_len)
char ** ftp_nlist(ftpbuf_t *ftp, const char *path, const size_t path_len)
int data_available(ftpbuf_t *ftp, php_socket_t s)
char ** ftp_mlsd(ftpbuf_t *ftp, const char *path, const size_t path_len)
ftpbuf_t * ftp_close(ftpbuf_t *ftp)
int ftp_login(ftpbuf_t *ftp, const char *user, const size_t user_len, const char *pass, const size_t pass_len)
int ftp_chdir(ftpbuf_t *ftp, const char *dir, const size_t dir_len)
int ftp_nb_continue_read(ftpbuf_t *ftp)
int ftp_reinit(ftpbuf_t *ftp)
int ftp_rmdir(ftpbuf_t *ftp, const char *dir, const size_t dir_len)
ftpbuf_t * ftp_open(const char *host, short port, zend_long timeout_sec)
int ftp_quit(ftpbuf_t *ftp)
int ftp_nb_continue_write(ftpbuf_t *ftp)
int single_send(ftpbuf_t *ftp, php_socket_t s, void *buf, size_t size)
int ftp_alloc(ftpbuf_t *ftp, const zend_long size, zend_string **response)
void ftp_gc(ftpbuf_t *ftp)
const char * ftp_pwd(ftpbuf_t *ftp)
int ftp_chmod(ftpbuf_t *ftp, const int mode, const char *filename, const int filename_len)
int ftp_exec(ftpbuf_t *ftp, const char *cmd, const size_t cmd_len)
int ftp_nb_put(ftpbuf_t *ftp, const char *path, const size_t path_len, php_stream *instream, ftptype_t type, zend_long startpos)
void ftp_raw(ftpbuf_t *ftp, const char *cmd, const size_t cmd_len, zval *return_value)
int ftp_pasv(ftpbuf_t *ftp, int pasv)
zend_long ftp_size(ftpbuf_t *ftp, const char *path, const size_t path_len)
#define pass(a, b, c, mul)
PHPAPI ZEND_COLD void php_error_docref(const char *docref, int type, const char *format,...)
inet_ntop(AF_INET, addr, addr_str, sizeof(addr_str))
PHPAPI char * php_socket_strerror(long err, char *buf, size_t bufsize)
PHPAPI socklen_t php_sockaddr_size(php_sockaddr_storage *addr)
PHPAPI int php_poll2(php_pollfd *ufds, unsigned int nfds, int timeout)
php_socket_t php_network_connect_socket_to_host(const char *host, unsigned short port, int socktype, int asynchronous, struct timeval *timeout, zend_string **error_string, int *error_code, const char *bindto, unsigned short bindport, long sockopts)
PHPAPI void php_any_addr(int family, php_sockaddr_storage *addr, unsigned short port)
mktime(int $hour, ?int $minute=null, ?int $second=null, ?int $month=null, ?int $day=null, ?int $year=null)
unsigned const char * end
unsigned const char * text
#define php_connect_nonb(sock, addr, addrlen, timeout)
struct _php_pollfd php_pollfd
#define STREAM_SOCKOP_NONE
#define php_socket_errno()
PHPAPI struct tm * php_gmtime_r(const time_t *const timep, struct tm *p_tm)
#define php_stream_fopen_tmpfile()
#define php_stream_putc(stream, c)
struct _php_stream php_stream
#define php_stream_read(stream, buf, count)
#define php_stream_rewind(stream)
#define php_stream_get_line(stream, buf, maxlen, retlen)
#define PHP_STREAM_FLAG_EOL_UNIX
#define php_stream_getc(stream)
#define php_stream_eof(stream)
#define php_stream_close(stream)
#define PHP_STREAM_FLAG_DETECT_EOL
#define PHP_STREAM_FLAG_EOL_MAC
#define php_stream_write(stream, buf, count)
php_sockaddr_storage pasvaddr
php_sockaddr_storage localaddr
ZEND_API zend_result add_next_index_string(zval *arg, const char *str)
#define ZVAL_STRINGL(z, s, l)
#define estrndup(s, length)
#define ecalloc(nmemb, size)
#define safe_emalloc(nmemb, size, offset)
ZEND_API void(ZEND_FASTCALL *zend_touch_vm_stack_data)(void *vm_stack_data)
ZEND_API zval *ZEND_FASTCALL zend_hash_str_update(HashTable *ht, const char *str, size_t len, zval *pData)
ZEND_API zval *ZEND_FASTCALL zend_hash_update(HashTable *ht, zend_string *key, zval *pData)
#define MAX_LENGTH_OF_LONG
struct _zend_string zend_string
#define UNEXPECTED(condition)
struct _zend_array HashTable
ZEND_RESULT_CODE zend_result