/* {{{ ftp_mkdir
*/
-char*
+zend_string*
ftp_mkdir(ftpbuf_t *ftp, const char *dir)
{
char *mkd, *end;
+ zend_string *ret;
if (ftp == NULL) {
return NULL;
}
/* copy out the dir from response */
if ((mkd = strchr(ftp->inbuf, '"')) == NULL) {
- mkd = estrdup(dir);
- return mkd;
+ return STR_INIT(dir, strlen(dir), 0);
}
if ((end = strrchr(++mkd, '"')) == NULL) {
return NULL;
}
*end = 0;
- mkd = estrdup(mkd);
+ ret = STR_INIT(mkd, end - mkd, 0);
*end = '"';
- return mkd;
+ return ret;
}
/* }}} */
/* {{{ ftp_alloc
*/
int
-ftp_alloc(ftpbuf_t *ftp, const long size, char **response)
+ftp_alloc(ftpbuf_t *ftp, const long size, zend_string **response)
{
char buffer[64];
}
if (response) {
- *response = estrdup(ftp->inbuf);
+ *response = STR_INIT(ftp->inbuf, strlen(ftp->inbuf), 0);
}
if (ftp->resp < 200 || ftp->resp >= 300) {
/* creates a directory, return the directory name on success, NULL on error.
* the return value must be freed
*/
-char* ftp_mkdir(ftpbuf_t *ftp, const char *dir);
+zend_string* ftp_mkdir(ftpbuf_t *ftp, const char *dir);
/* removes a directory, return true on success, false on error */
int ftp_rmdir(ftpbuf_t *ftp, const char *dir);
* however some servers will not accept STOR or APPE until ALLO is confirmed.
* If response is passed, it is estrdup()ed from ftp->inbuf and must be freed
* or assigned to a zval returned to the user */
-int ftp_alloc(ftpbuf_t *ftp, const long size, char **response);
+int ftp_alloc(ftpbuf_t *ftp, const long size, zend_string **response);
/* returns a NULL-terminated array of filenames in the given path
* or NULL on error. the return array must be freed (but don't
{
zval *z_ftp;
ftpbuf_t *ftp;
- char *dir, *tmp;
+ char *dir;
+ zend_string *tmp;
int dir_len;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &z_ftp, &dir, &dir_len) == FAILURE) {
RETURN_FALSE;
}
- RETURN_STRING(tmp);
+ RETURN_STR(tmp);
}
/* }}} */
zval *z_ftp, *zresponse = NULL;
ftpbuf_t *ftp;
long size, ret;
- char *response = NULL;
+ zend_string *response = NULL;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl|z", &z_ftp, &size, &zresponse) == FAILURE) {
RETURN_FALSE;
ret = ftp_alloc(ftp, size, zresponse ? &response : NULL);
if (response) {
+ ZVAL_DEREF(zresponse);
zval_dtor(zresponse);
- ZVAL_STRING(zresponse, response);
+ ZVAL_STR(zresponse, response);
}
if (!ret) {