Lines Matching refs:ftp
84 static int ftp_putcmd( ftpbuf_t *ftp,
89 static int my_send(ftpbuf_t *ftp, php_socket_t s, void *buf, size_t len);
90 static int my_recv(ftpbuf_t *ftp, php_socket_t s, void *buf, size_t len);
91 static int my_accept(ftpbuf_t *ftp, php_socket_t s, struct sockaddr *addr, socklen_t *addrlen);
94 static int ftp_readline(ftpbuf_t *ftp);
97 static int ftp_getresp(ftpbuf_t *ftp);
100 static int ftp_type(ftpbuf_t *ftp, ftptype_t type);
103 static databuf_t* ftp_getdata(ftpbuf_t *ftp TSRMLS_DC);
106 static databuf_t* data_accept(databuf_t *data, ftpbuf_t *ftp TSRMLS_DC);
109 static databuf_t* data_close(ftpbuf_t *ftp, databuf_t *data);
112 static char** ftp_genlist(ftpbuf_t *ftp, const char *cmd, const char *path TSRMLS_DC);
126 ftpbuf_t *ftp; in ftp_open() local
132 ftp = ecalloc(1, sizeof(*ftp)); in ftp_open()
137 ftp->fd = php_network_connect_socket_to_host(host, in ftp_open()
140 if (ftp->fd == -1) { in ftp_open()
145 ftp->timeout_sec = timeout_sec; in ftp_open()
146 ftp->nb = 0; in ftp_open()
148 size = sizeof(ftp->localaddr); in ftp_open()
149 memset(&ftp->localaddr, 0, size); in ftp_open()
150 if (getsockname(ftp->fd, (struct sockaddr*) &ftp->localaddr, &size) != 0) { in ftp_open()
155 if (!ftp_getresp(ftp) || ftp->resp != 220) { in ftp_open()
159 return ftp; in ftp_open()
162 if (ftp->fd != -1) { in ftp_open()
163 closesocket(ftp->fd); in ftp_open()
165 efree(ftp); in ftp_open()
173 ftp_close(ftpbuf_t *ftp) in ftp_close() argument
175 if (ftp == NULL) { in ftp_close()
178 if (ftp->data) { in ftp_close()
179 data_close(ftp, ftp->data); in ftp_close()
181 if (ftp->fd != -1) { in ftp_close()
183 if (ftp->ssl_active) { in ftp_close()
184 SSL_shutdown(ftp->ssl_handle); in ftp_close()
187 closesocket(ftp->fd); in ftp_close()
189 ftp_gc(ftp); in ftp_close()
190 efree(ftp); in ftp_close()
198 ftp_gc(ftpbuf_t *ftp) in ftp_gc() argument
200 if (ftp == NULL) { in ftp_gc()
203 if (ftp->pwd) { in ftp_gc()
204 efree(ftp->pwd); in ftp_gc()
205 ftp->pwd = NULL; in ftp_gc()
207 if (ftp->syst) { in ftp_gc()
208 efree(ftp->syst); in ftp_gc()
209 ftp->syst = NULL; in ftp_gc()
217 ftp_quit(ftpbuf_t *ftp) in ftp_quit() argument
219 if (ftp == NULL) { in ftp_quit()
223 if (!ftp_putcmd(ftp, "QUIT", NULL)) { in ftp_quit()
226 if (!ftp_getresp(ftp) || ftp->resp != 221) { in ftp_quit()
230 if (ftp->pwd) { in ftp_quit()
231 efree(ftp->pwd); in ftp_quit()
232 ftp->pwd = NULL; in ftp_quit()
242 ftp_login(ftpbuf_t *ftp, const char *user, const char *pass TSRMLS_DC) in ftp_login() argument
247 if (ftp == NULL) { in ftp_login()
252 if (ftp->use_ssl && !ftp->ssl_active) { in ftp_login()
253 if (!ftp_putcmd(ftp, "AUTH", "TLS")) { in ftp_login()
256 if (!ftp_getresp(ftp)) { in ftp_login()
260 if (ftp->resp != 234) { in ftp_login()
261 if (!ftp_putcmd(ftp, "AUTH", "SSL")) { in ftp_login()
264 if (!ftp_getresp(ftp)) { in ftp_login()
268 if (ftp->resp != 334) { in ftp_login()
271 ftp->old_ssl = 1; in ftp_login()
272 ftp->use_ssl_for_data = 1; in ftp_login()
284 ftp->ssl_handle = SSL_new(ctx); in ftp_login()
285 if (ftp->ssl_handle == NULL) { in ftp_login()
291 SSL_set_fd(ftp->ssl_handle, ftp->fd); in ftp_login()
293 if (SSL_connect(ftp->ssl_handle) <= 0) { in ftp_login()
295 SSL_shutdown(ftp->ssl_handle); in ftp_login()
299 ftp->ssl_active = 1; in ftp_login()
301 if (!ftp->old_ssl) { in ftp_login()
304 if (!ftp_putcmd(ftp, "PBSZ", "0")) { in ftp_login()
307 if (!ftp_getresp(ftp)) { in ftp_login()
312 if (!ftp_putcmd(ftp, "PROT", "P")) { in ftp_login()
315 if (!ftp_getresp(ftp)) { in ftp_login()
319 ftp->use_ssl_for_data = (ftp->resp >= 200 && ftp->resp <=299); in ftp_login()
324 if (!ftp_putcmd(ftp, "USER", user)) { in ftp_login()
327 if (!ftp_getresp(ftp)) { in ftp_login()
330 if (ftp->resp == 230) { in ftp_login()
333 if (ftp->resp != 331) { in ftp_login()
336 if (!ftp_putcmd(ftp, "PASS", pass)) { in ftp_login()
339 if (!ftp_getresp(ftp)) { in ftp_login()
342 return (ftp->resp == 230); in ftp_login()
349 ftp_reinit(ftpbuf_t *ftp) in ftp_reinit() argument
351 if (ftp == NULL) { in ftp_reinit()
355 ftp_gc(ftp); in ftp_reinit()
357 ftp->nb = 0; in ftp_reinit()
359 if (!ftp_putcmd(ftp, "REIN", NULL)) { in ftp_reinit()
362 if (!ftp_getresp(ftp) || ftp->resp != 220) { in ftp_reinit()
373 ftp_syst(ftpbuf_t *ftp) in ftp_syst() argument
377 if (ftp == NULL) { in ftp_syst()
382 if (ftp->syst) { in ftp_syst()
383 return ftp->syst; in ftp_syst()
385 if (!ftp_putcmd(ftp, "SYST", NULL)) { in ftp_syst()
388 if (!ftp_getresp(ftp) || ftp->resp != 215) { in ftp_syst()
391 syst = ftp->inbuf; in ftp_syst()
398 ftp->syst = estrdup(syst); in ftp_syst()
402 return ftp->syst; in ftp_syst()
409 ftp_pwd(ftpbuf_t *ftp) in ftp_pwd() argument
413 if (ftp == NULL) { in ftp_pwd()
418 if (ftp->pwd) { in ftp_pwd()
419 return ftp->pwd; in ftp_pwd()
421 if (!ftp_putcmd(ftp, "PWD", NULL)) { in ftp_pwd()
424 if (!ftp_getresp(ftp) || ftp->resp != 257) { in ftp_pwd()
428 if ((pwd = strchr(ftp->inbuf, '"')) == NULL) { in ftp_pwd()
434 ftp->pwd = estrndup(pwd, end - pwd); in ftp_pwd()
436 return ftp->pwd; in ftp_pwd()
443 ftp_exec(ftpbuf_t *ftp, const char *cmd) in ftp_exec() argument
445 if (ftp == NULL) { in ftp_exec()
448 if (!ftp_putcmd(ftp, "SITE EXEC", cmd)) { in ftp_exec()
451 if (!ftp_getresp(ftp) || ftp->resp != 200) { in ftp_exec()
462 ftp_raw(ftpbuf_t *ftp, const char *cmd, zval *return_value) in ftp_raw() argument
464 if (ftp == NULL || cmd == NULL) { in ftp_raw()
467 if (!ftp_putcmd(ftp, cmd, NULL)) { in ftp_raw()
471 while (ftp_readline(ftp)) { in ftp_raw()
472 add_next_index_string(return_value, ftp->inbuf, 1); in ftp_raw()
473 …if (isdigit(ftp->inbuf[0]) && isdigit(ftp->inbuf[1]) && isdigit(ftp->inbuf[2]) && ftp->inbuf[3] ==… in ftp_raw()
483 ftp_chdir(ftpbuf_t *ftp, const char *dir) in ftp_chdir() argument
485 if (ftp == NULL) { in ftp_chdir()
489 if (ftp->pwd) { in ftp_chdir()
490 efree(ftp->pwd); in ftp_chdir()
491 ftp->pwd = NULL; in ftp_chdir()
494 if (!ftp_putcmd(ftp, "CWD", dir)) { in ftp_chdir()
497 if (!ftp_getresp(ftp) || ftp->resp != 250) { in ftp_chdir()
507 ftp_cdup(ftpbuf_t *ftp) in ftp_cdup() argument
509 if (ftp == NULL) { in ftp_cdup()
513 if (ftp->pwd) { in ftp_cdup()
514 efree(ftp->pwd); in ftp_cdup()
515 ftp->pwd = NULL; in ftp_cdup()
518 if (!ftp_putcmd(ftp, "CDUP", NULL)) { in ftp_cdup()
521 if (!ftp_getresp(ftp) || ftp->resp != 250) { in ftp_cdup()
531 ftp_mkdir(ftpbuf_t *ftp, const char *dir) in ftp_mkdir() argument
535 if (ftp == NULL) { in ftp_mkdir()
538 if (!ftp_putcmd(ftp, "MKD", dir)) { in ftp_mkdir()
541 if (!ftp_getresp(ftp) || ftp->resp != 257) { in ftp_mkdir()
545 if ((mkd = strchr(ftp->inbuf, '"')) == NULL) { in ftp_mkdir()
563 ftp_rmdir(ftpbuf_t *ftp, const char *dir) in ftp_rmdir() argument
565 if (ftp == NULL) { in ftp_rmdir()
568 if (!ftp_putcmd(ftp, "RMD", dir)) { in ftp_rmdir()
571 if (!ftp_getresp(ftp) || ftp->resp != 250) { in ftp_rmdir()
581 ftp_chmod(ftpbuf_t *ftp, const int mode, const char *filename, const int filename_len) in ftp_chmod() argument
585 if (ftp == NULL || filename_len <= 0) { in ftp_chmod()
591 if (!ftp_putcmd(ftp, "SITE", buffer)) { in ftp_chmod()
598 if (!ftp_getresp(ftp) || ftp->resp != 200) { in ftp_chmod()
609 ftp_alloc(ftpbuf_t *ftp, const int size, char **response) in ftp_alloc() argument
613 if (ftp == NULL || size <= 0) { in ftp_alloc()
619 if (!ftp_putcmd(ftp, "ALLO", buffer)) { in ftp_alloc()
623 if (!ftp_getresp(ftp)) { in ftp_alloc()
627 if (response && ftp->inbuf) { in ftp_alloc()
628 *response = estrdup(ftp->inbuf); in ftp_alloc()
631 if (ftp->resp < 200 || ftp->resp >= 300) { in ftp_alloc()
642 ftp_nlist(ftpbuf_t *ftp, const char *path TSRMLS_DC) in ftp_nlist() argument
644 return ftp_genlist(ftp, "NLST", path TSRMLS_CC); in ftp_nlist()
651 ftp_list(ftpbuf_t *ftp, const char *path, int recursive TSRMLS_DC) in ftp_list() argument
653 return ftp_genlist(ftp, ((recursive) ? "LIST -R" : "LIST"), path TSRMLS_CC); in ftp_list()
660 ftp_type(ftpbuf_t *ftp, ftptype_t type) in ftp_type() argument
664 if (ftp == NULL) { in ftp_type()
667 if (type == ftp->type) { in ftp_type()
677 if (!ftp_putcmd(ftp, "TYPE", typechar)) { in ftp_type()
680 if (!ftp_getresp(ftp) || ftp->resp != 200) { in ftp_type()
683 ftp->type = type; in ftp_type()
692 ftp_pasv(ftpbuf_t *ftp, int pasv) in ftp_pasv() argument
701 if (ftp == NULL) { in ftp_pasv()
704 if (pasv && ftp->pasv == 2) { in ftp_pasv()
707 ftp->pasv = 0; in ftp_pasv()
711 n = sizeof(ftp->pasvaddr); in ftp_pasv()
712 memset(&ftp->pasvaddr, 0, n); in ftp_pasv()
713 sa = (struct sockaddr *) &ftp->pasvaddr; in ftp_pasv()
716 if (getpeername(ftp->fd, sa, &n) < 0) { in ftp_pasv()
724 if (!ftp_putcmd(ftp, "EPSV", NULL)) { in ftp_pasv()
727 if (!ftp_getresp(ftp)) { in ftp_pasv()
730 if (ftp->resp == 229) { in ftp_pasv()
732 for (ptr = ftp->inbuf; *ptr && *ptr != '('; ptr++); in ftp_pasv()
747 ftp->pasv = 2; in ftp_pasv()
755 if (!ftp_putcmd(ftp, "PASV", NULL)) { in ftp_pasv()
758 if (!ftp_getresp(ftp) || ftp->resp != 227) { in ftp_pasv()
762 for (ptr = ftp->inbuf; *ptr && !isdigit(*ptr); ptr++); in ftp_pasv()
775 ftp->pasv = 2; in ftp_pasv()
784 ftp_get(ftpbuf_t *ftp, php_stream *outstream, const char *path, ftptype_t type, int resumepos TSRML… in ftp_get() argument
791 if (ftp == NULL) { in ftp_get()
794 if (!ftp_type(ftp, type)) { in ftp_get()
798 if ((data = ftp_getdata(ftp TSRMLS_CC)) == NULL) { in ftp_get()
802 ftp->data = data; in ftp_get()
810 if (!ftp_putcmd(ftp, "REST", arg)) { in ftp_get()
813 if (!ftp_getresp(ftp) || (ftp->resp != 350)) { in ftp_get()
818 if (!ftp_putcmd(ftp, "RETR", path)) { in ftp_get()
821 if (!ftp_getresp(ftp) || (ftp->resp != 150 && ftp->resp != 125)) { in ftp_get()
825 if ((data = data_accept(data, ftp TSRMLS_CC)) == NULL) { in ftp_get()
830 while ((rcvd = my_recv(ftp, data->fd, data->buf, FTP_BUFSIZE))) { in ftp_get()
866 ftp->data = data = data_close(ftp, data); in ftp_get()
868 if (!ftp_getresp(ftp) || (ftp->resp != 226 && ftp->resp != 250)) { in ftp_get()
874 ftp->data = data_close(ftp, data); in ftp_get()
882 ftp_put(ftpbuf_t *ftp, const char *path, php_stream *instream, ftptype_t type, int startpos TSRMLS_… in ftp_put() argument
890 if (ftp == NULL) { in ftp_put()
893 if (!ftp_type(ftp, type)) { in ftp_put()
896 if ((data = ftp_getdata(ftp TSRMLS_CC)) == NULL) { in ftp_put()
899 ftp->data = data; in ftp_put()
907 if (!ftp_putcmd(ftp, "REST", arg)) { in ftp_put()
910 if (!ftp_getresp(ftp) || (ftp->resp != 350)) { in ftp_put()
915 if (!ftp_putcmd(ftp, "STOR", path)) { in ftp_put()
918 if (!ftp_getresp(ftp) || (ftp->resp != 150 && ftp->resp != 125)) { in ftp_put()
921 if ((data = data_accept(data, ftp TSRMLS_CC)) == NULL) { in ftp_put()
930 if (my_send(ftp, data->fd, data->buf, size) != size) { in ftp_put()
946 if (size && my_send(ftp, data->fd, data->buf, size) != size) { in ftp_put()
949 ftp->data = data = data_close(ftp, data); in ftp_put()
951 if (!ftp_getresp(ftp) || (ftp->resp != 226 && ftp->resp != 250 && ftp->resp != 200)) { in ftp_put()
956 ftp->data = data_close(ftp, data); in ftp_put()
964 ftp_size(ftpbuf_t *ftp, const char *path) in ftp_size() argument
966 if (ftp == NULL) { in ftp_size()
969 if (!ftp_type(ftp, FTPTYPE_IMAGE)) { in ftp_size()
972 if (!ftp_putcmd(ftp, "SIZE", path)) { in ftp_size()
975 if (!ftp_getresp(ftp) || ftp->resp != 213) { in ftp_size()
978 return atoi(ftp->inbuf); in ftp_size()
985 ftp_mdtm(ftpbuf_t *ftp, const char *path) in ftp_mdtm() argument
993 if (ftp == NULL) { in ftp_mdtm()
996 if (!ftp_putcmd(ftp, "MDTM", path)) { in ftp_mdtm()
999 if (!ftp_getresp(ftp) || ftp->resp != 213) { in ftp_mdtm()
1003 for (ptr = ftp->inbuf; *ptr && !isdigit(*ptr); ptr++); in ftp_mdtm()
1033 ftp_delete(ftpbuf_t *ftp, const char *path) in ftp_delete() argument
1035 if (ftp == NULL) { in ftp_delete()
1038 if (!ftp_putcmd(ftp, "DELE", path)) { in ftp_delete()
1041 if (!ftp_getresp(ftp) || ftp->resp != 250) { in ftp_delete()
1052 ftp_rename(ftpbuf_t *ftp, const char *src, const char *dest) in ftp_rename() argument
1054 if (ftp == NULL) { in ftp_rename()
1057 if (!ftp_putcmd(ftp, "RNFR", src)) { in ftp_rename()
1060 if (!ftp_getresp(ftp) || ftp->resp != 350) { in ftp_rename()
1063 if (!ftp_putcmd(ftp, "RNTO", dest)) { in ftp_rename()
1066 if (!ftp_getresp(ftp) || ftp->resp != 250) { in ftp_rename()
1076 ftp_site(ftpbuf_t *ftp, const char *cmd) in ftp_site() argument
1078 if (ftp == NULL) { in ftp_site()
1081 if (!ftp_putcmd(ftp, "SITE", cmd)) { in ftp_site()
1084 if (!ftp_getresp(ftp) || ftp->resp < 200 || ftp->resp >= 300) { in ftp_site()
1097 ftp_putcmd(ftpbuf_t *ftp, const char *cmd, const char *args) in ftp_putcmd() argument
1114 size = slprintf(ftp->outbuf, sizeof(ftp->outbuf), "%s %s\r\n", cmd, args); in ftp_putcmd()
1120 size = slprintf(ftp->outbuf, sizeof(ftp->outbuf), "%s\r\n", cmd); in ftp_putcmd()
1123 data = ftp->outbuf; in ftp_putcmd()
1126 ftp->extra = NULL; in ftp_putcmd()
1128 if (my_send(ftp, ftp->fd, data, size) != size) { in ftp_putcmd()
1138 ftp_readline(ftpbuf_t *ftp) in ftp_readline() argument
1146 if (ftp->extra) { in ftp_readline()
1147 memmove(ftp->inbuf, ftp->extra, ftp->extralen); in ftp_readline()
1148 rcvd = ftp->extralen; in ftp_readline()
1151 data = ftp->inbuf; in ftp_readline()
1158 ftp->extra = eol + 1; in ftp_readline()
1160 ftp->extra++; in ftp_readline()
1163 if ((ftp->extralen = --rcvd) == 0) { in ftp_readline()
1164 ftp->extra = NULL; in ftp_readline()
1169 ftp->extra = eol + 1; in ftp_readline()
1170 if ((ftp->extralen = --rcvd) == 0) { in ftp_readline()
1171 ftp->extra = NULL; in ftp_readline()
1178 if ((rcvd = my_recv(ftp, ftp->fd, data, size)) < 1) { in ftp_readline()
1190 ftp_getresp(ftpbuf_t *ftp) in ftp_getresp() argument
1194 if (ftp == NULL) { in ftp_getresp()
1197 buf = ftp->inbuf; in ftp_getresp()
1198 ftp->resp = 0; in ftp_getresp()
1202 if (!ftp_readline(ftp)) { in ftp_getresp()
1207 …if (isdigit(ftp->inbuf[0]) && isdigit(ftp->inbuf[1]) && isdigit(ftp->inbuf[2]) && ftp->inbuf[3] ==… in ftp_getresp()
1213 if (!isdigit(ftp->inbuf[0]) || !isdigit(ftp->inbuf[1]) || !isdigit(ftp->inbuf[2])) { in ftp_getresp()
1217 ftp->resp = 100 * (ftp->inbuf[0] - '0') + 10 * (ftp->inbuf[1] - '0') + (ftp->inbuf[2] - '0'); in ftp_getresp()
1219 memmove(ftp->inbuf, ftp->inbuf + 4, FTP_BUFSIZE - 4); in ftp_getresp()
1221 if (ftp->extra) { in ftp_getresp()
1222 ftp->extra -= 4; in ftp_getresp()
1231 my_send(ftpbuf_t *ftp, php_socket_t s, void *buf, size_t len) in my_send() argument
1237 n = php_pollfd_for_ms(s, POLLOUT, ftp->timeout_sec * 1000); in my_send()
1250 if (ftp->use_ssl && ftp->fd == s && ftp->ssl_active) { in my_send()
1251 sent = SSL_write(ftp->ssl_handle, buf, size); in my_send()
1252 } else if (ftp->use_ssl && ftp->fd != s && ftp->use_ssl_for_data && ftp->data->ssl_active) { in my_send()
1253 sent = SSL_write(ftp->data->ssl_handle, buf, size); in my_send()
1275 my_recv(ftpbuf_t *ftp, php_socket_t s, void *buf, size_t len) in my_recv() argument
1279 n = php_pollfd_for_ms(s, PHP_POLLREADABLE, ftp->timeout_sec * 1000); in my_recv()
1290 if (ftp->use_ssl && ftp->fd == s && ftp->ssl_active) { in my_recv()
1291 nr_bytes = SSL_read(ftp->ssl_handle, buf, len); in my_recv()
1292 } else if (ftp->use_ssl && ftp->fd != s && ftp->use_ssl_for_data && ftp->data->ssl_active) { in my_recv()
1293 nr_bytes = SSL_read(ftp->data->ssl_handle, buf, len); in my_recv()
1307 data_available(ftpbuf_t *ftp, php_socket_t s) in data_available() argument
1327 data_writeable(ftpbuf_t *ftp, php_socket_t s) in data_writeable() argument
1348 my_accept(ftpbuf_t *ftp, php_socket_t s, struct sockaddr *addr, socklen_t *addrlen) in my_accept() argument
1352 n = php_pollfd_for_ms(s, PHP_POLLREADABLE, ftp->timeout_sec * 1000); in my_accept()
1369 ftp_getdata(ftpbuf_t *ftp TSRMLS_DC) in ftp_getdata()
1382 if (ftp->pasv && !ftp_pasv(ftp, 1)) { in ftp_getdata()
1389 data->type = ftp->type; in ftp_getdata()
1391 sa = (struct sockaddr *) &ftp->localaddr; in ftp_getdata()
1399 if (ftp->pasv) { in ftp_getdata()
1401 ftp->pasv = 1; in ftp_getdata()
1405 size = php_sockaddr_size(&ftp->pasvaddr); in ftp_getdata()
1406 tv.tv_sec = ftp->timeout_sec; in ftp_getdata()
1408 if (php_connect_nonb(fd, (struct sockaddr*) &ftp->pasvaddr, size, &tv) == -1) { in ftp_getdata()
1415 ftp->data = data; in ftp_getdata()
1451 if (!ftp_putcmd(ftp, "EPRT", eprtarg)) { in ftp_getdata()
1455 if (!ftp_getresp(ftp) || ftp->resp != 200) { in ftp_getdata()
1459 ftp->data = data; in ftp_getdata()
1469 if (!ftp_putcmd(ftp, "PORT", arg)) { in ftp_getdata()
1472 if (!ftp_getresp(ftp) || ftp->resp != 200) { in ftp_getdata()
1476 ftp->data = data; in ftp_getdata()
1491 data_accept(databuf_t *data, ftpbuf_t *ftp TSRMLS_DC) in data_accept()
1504 data->fd = my_accept(ftp, data->listener, (struct sockaddr*) &addr, &size); in data_accept()
1517 if (ftp->use_ssl && ftp->use_ssl_for_data) { in data_accept()
1536 if (ftp->old_ssl) { in data_accept()
1537 SSL_copy_session_id(data->ssl_handle, ftp->ssl_handle); in data_accept()
1558 data_close(ftpbuf_t *ftp, databuf_t *data) in data_close() argument
1581 if (ftp) { in data_close()
1582 ftp->data = NULL; in data_close()
1592 ftp_genlist(ftpbuf_t *ftp, const char *cmd, const char *path TSRMLS_DC) in ftp_genlist() argument
1610 if (!ftp_type(ftp, FTPTYPE_ASCII)) { in ftp_genlist()
1614 if ((data = ftp_getdata(ftp TSRMLS_CC)) == NULL) { in ftp_genlist()
1617 ftp->data = data; in ftp_genlist()
1619 if (!ftp_putcmd(ftp, cmd, path)) { in ftp_genlist()
1622 if (!ftp_getresp(ftp) || (ftp->resp != 150 && ftp->resp != 125 && ftp->resp != 226)) { in ftp_genlist()
1627 if (ftp->resp == 226) { in ftp_genlist()
1628 ftp->data = data_close(ftp, data); in ftp_genlist()
1634 if ((data = data_accept(data, ftp TSRMLS_CC)) == NULL) { in ftp_genlist()
1640 while ((rcvd = my_recv(ftp, data->fd, data->buf, FTP_BUFSIZE))) { in ftp_genlist()
1658 ftp->data = data = data_close(ftp, data); in ftp_genlist()
1681 if (!ftp_getresp(ftp) || (ftp->resp != 226 && ftp->resp != 250)) { in ftp_genlist()
1688 ftp->data = data_close(ftp, data); in ftp_genlist()
1699 ftp_nb_get(ftpbuf_t *ftp, php_stream *outstream, const char *path, ftptype_t type, int resumepos TS… in ftp_nb_get() argument
1704 if (ftp == NULL) { in ftp_nb_get()
1708 if (!ftp_type(ftp, type)) { in ftp_nb_get()
1712 if ((data = ftp_getdata(ftp TSRMLS_CC)) == NULL) { in ftp_nb_get()
1725 if (!ftp_putcmd(ftp, "REST", arg)) { in ftp_nb_get()
1728 if (!ftp_getresp(ftp) || (ftp->resp != 350)) { in ftp_nb_get()
1733 if (!ftp_putcmd(ftp, "RETR", path)) { in ftp_nb_get()
1736 if (!ftp_getresp(ftp) || (ftp->resp != 150 && ftp->resp != 125)) { in ftp_nb_get()
1740 if ((data = data_accept(data, ftp TSRMLS_CC)) == NULL) { in ftp_nb_get()
1744 ftp->data = data; in ftp_nb_get()
1745 ftp->stream = outstream; in ftp_nb_get()
1746 ftp->lastch = 0; in ftp_nb_get()
1747 ftp->nb = 1; in ftp_nb_get()
1749 return (ftp_nb_continue_read(ftp TSRMLS_CC)); in ftp_nb_get()
1752 ftp->data = data_close(ftp, data); in ftp_nb_get()
1760 ftp_nb_continue_read(ftpbuf_t *ftp TSRMLS_DC) in ftp_nb_continue_read()
1768 data = ftp->data; in ftp_nb_continue_read()
1771 if (!data_available(ftp, data->fd)) { in ftp_nb_continue_read()
1775 type = ftp->type; in ftp_nb_continue_read()
1777 lastch = ftp->lastch; in ftp_nb_continue_read()
1778 if ((rcvd = my_recv(ftp, data->fd, data->buf, FTP_BUFSIZE))) { in ftp_nb_continue_read()
1786 php_stream_putc(ftp->stream, '\r'); in ftp_nb_continue_read()
1789 php_stream_putc(ftp->stream, *ptr); in ftp_nb_continue_read()
1793 } else if (rcvd != php_stream_write(ftp->stream, data->buf, rcvd)) { in ftp_nb_continue_read()
1797 ftp->lastch = lastch; in ftp_nb_continue_read()
1802 php_stream_putc(ftp->stream, '\r'); in ftp_nb_continue_read()
1805 ftp->data = data = data_close(ftp, data); in ftp_nb_continue_read()
1807 if (!ftp_getresp(ftp) || (ftp->resp != 226 && ftp->resp != 250)) { in ftp_nb_continue_read()
1811 ftp->nb = 0; in ftp_nb_continue_read()
1814 ftp->nb = 0; in ftp_nb_continue_read()
1815 ftp->data = data_close(ftp, data); in ftp_nb_continue_read()
1823 ftp_nb_put(ftpbuf_t *ftp, const char *path, php_stream *instream, ftptype_t type, int startpos TSRM… in ftp_nb_put() argument
1828 if (ftp == NULL) { in ftp_nb_put()
1831 if (!ftp_type(ftp, type)) { in ftp_nb_put()
1834 if ((data = ftp_getdata(ftp TSRMLS_CC)) == NULL) { in ftp_nb_put()
1843 if (!ftp_putcmd(ftp, "REST", arg)) { in ftp_nb_put()
1846 if (!ftp_getresp(ftp) || (ftp->resp != 350)) { in ftp_nb_put()
1851 if (!ftp_putcmd(ftp, "STOR", path)) { in ftp_nb_put()
1854 if (!ftp_getresp(ftp) || (ftp->resp != 150 && ftp->resp != 125)) { in ftp_nb_put()
1857 if ((data = data_accept(data, ftp TSRMLS_CC)) == NULL) { in ftp_nb_put()
1860 ftp->data = data; in ftp_nb_put()
1861 ftp->stream = instream; in ftp_nb_put()
1862 ftp->lastch = 0; in ftp_nb_put()
1863 ftp->nb = 1; in ftp_nb_put()
1865 return (ftp_nb_continue_write(ftp TSRMLS_CC)); in ftp_nb_put()
1868 ftp->data = data_close(ftp, data); in ftp_nb_put()
1877 ftp_nb_continue_write(ftpbuf_t *ftp TSRMLS_DC) in ftp_nb_continue_write()
1884 if (!data_writeable(ftp, ftp->data->fd)) { in ftp_nb_continue_write()
1889 ptr = ftp->data->buf; in ftp_nb_continue_write()
1890 while (!php_stream_eof(ftp->stream) && (ch = php_stream_getc(ftp->stream)) != EOF) { in ftp_nb_continue_write()
1892 if (ch == '\n' && ftp->type == FTPTYPE_ASCII) { in ftp_nb_continue_write()
1902 if (my_send(ftp, ftp->data->fd, ftp->data->buf, size) != size) { in ftp_nb_continue_write()
1909 if (size && my_send(ftp, ftp->data->fd, ftp->data->buf, size) != size) { in ftp_nb_continue_write()
1912 ftp->data = data_close(ftp, ftp->data); in ftp_nb_continue_write()
1914 if (!ftp_getresp(ftp) || (ftp->resp != 226 && ftp->resp != 250)) { in ftp_nb_continue_write()
1917 ftp->nb = 0; in ftp_nb_continue_write()
1920 ftp->data = data_close(ftp, ftp->data); in ftp_nb_continue_write()
1921 ftp->nb = 0; in ftp_nb_continue_write()