summaryrefslogtreecommitdiff
path: root/ext/ftp/php_ftp.c
diff options
context:
space:
mode:
authorAndreas Treichel <gmblar+github@gmail.com>2017-02-02 01:09:31 +0100
committerNikita Popov <nikita.ppv@gmail.com>2017-02-17 21:31:18 +0100
commit5b1300b6c94b346310c0dd1eb3f89fd786229da4 (patch)
tree3fdd22d87ebdaaf4bc031c42e981464f3ed012e6 /ext/ftp/php_ftp.c
parentefefb5276b18f11871bf5405209013c11e5c9e20 (diff)
downloadphp-git-5b1300b6c94b346310c0dd1eb3f89fd786229da4.tar.gz
ftp_mlsd(): Parse the MLSD response
Diffstat (limited to 'ext/ftp/php_ftp.c')
-rw-r--r--ext/ftp/php_ftp.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/ext/ftp/php_ftp.c b/ext/ftp/php_ftp.c
index dc7351ff82..bad5690039 100644
--- a/ext/ftp/php_ftp.c
+++ b/ext/ftp/php_ftp.c
@@ -755,13 +755,14 @@ PHP_FUNCTION(ftp_rawlist)
/* }}} */
/* {{{ proto array ftp_mlsd(resource stream, string directory)
- Returns a detailed listing of a directory as an array of output lines */
+ Returns a detailed listing of a directory as an array of parsed output lines */
PHP_FUNCTION(ftp_mlsd)
{
zval *z_ftp;
ftpbuf_t *ftp;
char **llist, **ptr, *dir;
size_t dir_len;
+ zval entry;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "rs", &z_ftp, &dir, &dir_len) == FAILURE) {
return;
@@ -778,8 +779,14 @@ PHP_FUNCTION(ftp_mlsd)
array_init(return_value);
for (ptr = llist; *ptr; ptr++) {
- add_next_index_string(return_value, *ptr);
+ array_init(&entry);
+ if (ftp_mlsd_parse_line(Z_ARRVAL_P(&entry), *ptr) == SUCCESS) {
+ zend_hash_next_index_insert(Z_ARRVAL_P(return_value), &entry);
+ } else {
+ zval_ptr_dtor(&entry);
+ }
}
+
efree(llist);
}
/* }}} */