Browse Source

Fixed ZTS build.

PHP-5
Ilia Alshanetsky 24 years ago
parent
commit
f0de896ed2
  1. 35
      ext/ftp/ftp.c
  2. 11
      ext/ftp/ftp.h
  3. 14
      ext/ftp/php_ftp.c

35
ext/ftp/ftp.c

@ -97,7 +97,7 @@ static int ftp_getresp(ftpbuf_t *ftp);
static int ftp_type(ftpbuf_t *ftp, ftptype_t type); static int ftp_type(ftpbuf_t *ftp, ftptype_t type);
/* opens up a data stream */ /* opens up a data stream */
static databuf_t* ftp_getdata(ftpbuf_t *ftp);
static databuf_t* ftp_getdata(ftpbuf_t *ftp TSRMLS_DC);
/* accepts the data connection, returns updated data buffer */ /* accepts the data connection, returns updated data buffer */
static databuf_t* data_accept(databuf_t *data, ftpbuf_t *ftp); static databuf_t* data_accept(databuf_t *data, ftpbuf_t *ftp);
@ -106,8 +106,7 @@ static databuf_t* data_accept(databuf_t *data, ftpbuf_t *ftp);
static databuf_t* data_close(ftpbuf_t *ftp, databuf_t *data); static databuf_t* data_close(ftpbuf_t *ftp, databuf_t *data);
/* generic file lister */ /* generic file lister */
static char** ftp_genlist(ftpbuf_t *ftp,
const char *cmd, const char *path);
static char** ftp_genlist(ftpbuf_t *ftp, const char *cmd, const char *path TSRMLS_DC);
/* IP and port conversion box */ /* IP and port conversion box */
union ipbox { union ipbox {
@ -228,12 +227,10 @@ ftp_quit(ftpbuf_t *ftp)
/* {{{ ftp_login /* {{{ ftp_login
*/ */
int int
ftp_login(ftpbuf_t *ftp, const char *user, const char *pass)
ftp_login(ftpbuf_t *ftp, const char *user, const char *pass TSRMLS_DC)
{ {
#if HAVE_OPENSSL_EXT #if HAVE_OPENSSL_EXT
SSL_CTX *ctx = NULL; SSL_CTX *ctx = NULL;
TSRMLS_FETCH();
#endif #endif
if (ftp == NULL) { if (ftp == NULL) {
return 0; return 0;
@ -541,18 +538,18 @@ ftp_rmdir(ftpbuf_t *ftp, const char *dir)
/* {{{ ftp_nlist /* {{{ ftp_nlist
*/ */
char** char**
ftp_nlist(ftpbuf_t *ftp, const char *path)
ftp_nlist(ftpbuf_t *ftp, const char *path TSRMLS_DC)
{ {
return ftp_genlist(ftp, "NLST", path);
return ftp_genlist(ftp, "NLST", path TSRMLS_CC);
} }
/* }}} */ /* }}} */
/* {{{ ftp_list /* {{{ ftp_list
*/ */
char** char**
ftp_list(ftpbuf_t *ftp, const char *path, int recursive)
ftp_list(ftpbuf_t *ftp, const char *path, int recursive TSRMLS_DC)
{ {
return ftp_genlist(ftp, ((recursive) ? "LIST -R" : "LIST"), path);
return ftp_genlist(ftp, ((recursive) ? "LIST -R" : "LIST"), path TSRMLS_CC);
} }
/* }}} */ /* }}} */
@ -699,7 +696,7 @@ ftp_get(ftpbuf_t *ftp, php_stream *outstream, const char *path, ftptype_t type,
goto bail; goto bail;
} }
if ((data = ftp_getdata(ftp)) == NULL) {
if ((data = ftp_getdata(ftp TSRMLS_CC)) == NULL) {
goto bail; goto bail;
} }
@ -785,7 +782,7 @@ ftp_put(ftpbuf_t *ftp, const char *path, php_stream *instream, ftptype_t type, i
if (!ftp_type(ftp, type)) { if (!ftp_type(ftp, type)) {
goto bail; goto bail;
} }
if ((data = ftp_getdata(ftp)) == NULL) {
if ((data = ftp_getdata(ftp TSRMLS_CC)) == NULL) {
goto bail; goto bail;
} }
ftp->data = data; ftp->data = data;
@ -1278,7 +1275,7 @@ my_accept(ftpbuf_t *ftp, int s, struct sockaddr *addr, int *addrlen)
/* {{{ ftp_getdata /* {{{ ftp_getdata
*/ */
databuf_t* databuf_t*
ftp_getdata(ftpbuf_t *ftp)
ftp_getdata(ftpbuf_t *ftp TSRMLS_DC)
{ {
int fd = -1; int fd = -1;
databuf_t *data; databuf_t *data;
@ -1500,7 +1497,7 @@ data_close(ftpbuf_t *ftp, databuf_t *data)
/* {{{ ftp_genlist /* {{{ ftp_genlist
*/ */
char** char**
ftp_genlist(ftpbuf_t *ftp, const char *cmd, const char *path)
ftp_genlist(ftpbuf_t *ftp, const char *cmd, const char *path TSRMLS_DC)
{ {
FILE *tmpfp = NULL; FILE *tmpfp = NULL;
databuf_t *data = NULL; databuf_t *data = NULL;
@ -1521,7 +1518,7 @@ ftp_genlist(ftpbuf_t *ftp, const char *cmd, const char *path)
goto bail; goto bail;
} }
if ((data = ftp_getdata(ftp)) == NULL) {
if ((data = ftp_getdata(ftp TSRMLS_CC)) == NULL) {
goto bail; goto bail;
} }
ftp->data = data; ftp->data = data;
@ -1605,7 +1602,7 @@ bail:
/* {{{ ftp_nb_get /* {{{ ftp_nb_get
*/ */
int int
ftp_nb_get(ftpbuf_t *ftp, php_stream *outstream, const char *path, ftptype_t type, int resumepos)
ftp_nb_get(ftpbuf_t *ftp, php_stream *outstream, const char *path, ftptype_t type, int resumepos TSRMLS_DC)
{ {
databuf_t *data = NULL; databuf_t *data = NULL;
char arg[11]; char arg[11];
@ -1618,7 +1615,7 @@ ftp_nb_get(ftpbuf_t *ftp, php_stream *outstream, const char *path, ftptype_t typ
goto bail; goto bail;
} }
if ((data = ftp_getdata(ftp)) == NULL) {
if ((data = ftp_getdata(ftp TSRMLS_CC)) == NULL) {
goto bail; goto bail;
} }
@ -1730,7 +1727,7 @@ bail:
/* {{{ ftp_nb_put /* {{{ ftp_nb_put
*/ */
int int
ftp_nb_put(ftpbuf_t *ftp, const char *path, php_stream *instream, ftptype_t type, int startpos)
ftp_nb_put(ftpbuf_t *ftp, const char *path, php_stream *instream, ftptype_t type, int startpos TSRMLS_DC)
{ {
databuf_t *data = NULL; databuf_t *data = NULL;
char arg[11]; char arg[11];
@ -1741,7 +1738,7 @@ ftp_nb_put(ftpbuf_t *ftp, const char *path, php_stream *instream, ftptype_t type
if (!ftp_type(ftp, type)) { if (!ftp_type(ftp, type)) {
goto bail; goto bail;
} }
if ((data = ftp_getdata(ftp)) == NULL) {
if ((data = ftp_getdata(ftp TSRMLS_CC)) == NULL) {
goto bail; goto bail;
} }
if (startpos > 0) { if (startpos > 0) {

11
ext/ftp/ftp.h

@ -107,7 +107,7 @@ void ftp_gc(ftpbuf_t *ftp);
ftpbuf_t* ftp_close(ftpbuf_t *ftp); ftpbuf_t* ftp_close(ftpbuf_t *ftp);
/* logs into the FTP server, returns true on success, false on error */ /* logs into the FTP server, returns true on success, false on error */
int ftp_login(ftpbuf_t *ftp, const char *user, const char *pass);
int ftp_login(ftpbuf_t *ftp, const char *user, const char *pass TSRMLS_DC);
/* reinitializes the connection, returns true on success, false on error */ /* reinitializes the connection, returns true on success, false on error */
int ftp_reinit(ftpbuf_t *ftp); int ftp_reinit(ftpbuf_t *ftp);
@ -139,14 +139,14 @@ int ftp_rmdir(ftpbuf_t *ftp, const char *dir);
* or NULL on error. the return array must be freed (but don't * or NULL on error. the return array must be freed (but don't
* free the array elements) * free the array elements)
*/ */
char** ftp_nlist(ftpbuf_t *ftp, const char *path);
char** ftp_nlist(ftpbuf_t *ftp, const char *path TSRMLS_DC);
/* returns a NULL-terminated array of lines returned by the ftp /* returns a NULL-terminated array of lines returned by the ftp
* LIST command for the given path or NULL on error. the return * LIST command for the given path or NULL on error. the return
* array must be freed (but don't * array must be freed (but don't
* free the array elements) * free the array elements)
*/ */
char** ftp_list(ftpbuf_t *ftp, const char *path, int recursive);
char** ftp_list(ftpbuf_t *ftp, const char *path, int recursive TSRMLS_DC);
/* switches passive mode on or off /* switches passive mode on or off
* returns true on success, false on error * returns true on success, false on error
@ -182,13 +182,12 @@ int ftp_site(ftpbuf_t *ftp, const char *cmd);
/* retrieves part of a file and saves its contents to outfp /* retrieves part of a file and saves its contents to outfp
* returns true on success, false on error * returns true on success, false on error
*/ */
int ftp_nb_get(ftpbuf_t *ftp, php_stream *outstream, const char *path,
ftptype_t type, int resumepos);
int ftp_nb_get(ftpbuf_t *ftp, php_stream *outstream, const char *path, ftptype_t type, int resumepos TSRMLS_DC);
/* stores the data from a file, socket, or process as a file on the remote server /* stores the data from a file, socket, or process as a file on the remote server
* returns true on success, false on error * returns true on success, false on error
*/ */
int ftp_nb_put(ftpbuf_t *ftp, const char *path, php_stream *instream, ftptype_t type, int startpos);
int ftp_nb_put(ftpbuf_t *ftp, const char *path, php_stream *instream, ftptype_t type, int startpos TSRMLS_DC);
/* continues a previous nb_(f)get command /* continues a previous nb_(f)get command
*/ */

14
ext/ftp/php_ftp.c

@ -225,7 +225,7 @@ PHP_FUNCTION(ftp_login)
ZEND_FETCH_RESOURCE(ftp, ftpbuf_t*, &z_ftp, -1, le_ftpbuf_name, le_ftpbuf); ZEND_FETCH_RESOURCE(ftp, ftpbuf_t*, &z_ftp, -1, le_ftpbuf_name, le_ftpbuf);
/* log in */ /* log in */
if (!ftp_login(ftp, user, pass)) {
if (!ftp_login(ftp, user, pass TSRMLS_CC)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", ftp->inbuf); php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", ftp->inbuf);
RETURN_FALSE; RETURN_FALSE;
} }
@ -396,7 +396,7 @@ PHP_FUNCTION(ftp_nlist)
ZEND_FETCH_RESOURCE(ftp, ftpbuf_t*, &z_ftp, -1, le_ftpbuf_name, le_ftpbuf); ZEND_FETCH_RESOURCE(ftp, ftpbuf_t*, &z_ftp, -1, le_ftpbuf_name, le_ftpbuf);
/* get list of files */ /* get list of files */
if (NULL == (nlist = ftp_nlist(ftp, dir))) {
if (NULL == (nlist = ftp_nlist(ftp, dir TSRMLS_CC))) {
RETURN_FALSE; RETURN_FALSE;
} }
@ -425,7 +425,7 @@ PHP_FUNCTION(ftp_rawlist)
ZEND_FETCH_RESOURCE(ftp, ftpbuf_t*, &z_ftp, -1, le_ftpbuf_name, le_ftpbuf); ZEND_FETCH_RESOURCE(ftp, ftpbuf_t*, &z_ftp, -1, le_ftpbuf_name, le_ftpbuf);
/* get raw directory listing */ /* get raw directory listing */
if (NULL == (llist = ftp_list(ftp, dir, recursive))) {
if (NULL == (llist = ftp_list(ftp, dir, recursive TSRMLS_CC))) {
RETURN_FALSE; RETURN_FALSE;
} }
@ -541,7 +541,7 @@ PHP_FUNCTION(ftp_nb_fget)
ftp->direction = 0; /* recv */ ftp->direction = 0; /* recv */
ftp->closestream = 0; /* do not close */ ftp->closestream = 0; /* do not close */
if ((ret = ftp_nb_get(ftp, stream, file, xtype, resumepos)) == PHP_FTP_FAILED) {
if ((ret = ftp_nb_get(ftp, stream, file, xtype, resumepos TSRMLS_CC)) == PHP_FTP_FAILED) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", ftp->inbuf); php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", ftp->inbuf);
RETURN_LONG(ret); RETURN_LONG(ret);
} }
@ -679,7 +679,7 @@ PHP_FUNCTION(ftp_nb_get)
ftp->direction = 0; /* recv */ ftp->direction = 0; /* recv */
ftp->closestream = 1; /* do close */ ftp->closestream = 1; /* do close */
if ((ret = ftp_nb_get(ftp, outstream, remote, xtype, resumepos)) == PHP_FTP_FAILED) {
if ((ret = ftp_nb_get(ftp, outstream, remote, xtype, resumepos TSRMLS_CC)) == PHP_FTP_FAILED) {
php_stream_close(outstream); php_stream_close(outstream);
php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", ftp->inbuf); php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", ftp->inbuf);
RETURN_LONG(PHP_FTP_FAILED); RETURN_LONG(PHP_FTP_FAILED);
@ -817,7 +817,7 @@ PHP_FUNCTION(ftp_nb_fput)
ftp->direction = 1; /* send */ ftp->direction = 1; /* send */
ftp->closestream = 0; /* do not close */ ftp->closestream = 0; /* do not close */
if (((ret = ftp_nb_put(ftp, remote, stream, xtype, startpos)) == PHP_FTP_FAILED)) {
if (((ret = ftp_nb_put(ftp, remote, stream, xtype, startpos TSRMLS_CC)) == PHP_FTP_FAILED)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", ftp->inbuf); php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", ftp->inbuf);
RETURN_LONG(ret); RETURN_LONG(ret);
} }
@ -927,7 +927,7 @@ PHP_FUNCTION(ftp_nb_put)
ftp->direction = 1; /* send */ ftp->direction = 1; /* send */
ftp->closestream = 1; /* do close */ ftp->closestream = 1; /* do close */
ret = ftp_nb_put(ftp, remote, instream, xtype, startpos);
ret = ftp_nb_put(ftp, remote, instream, xtype, startpos TSRMLS_CC);
if (ret != PHP_FTP_MOREDATA) { if (ret != PHP_FTP_MOREDATA) {
php_stream_close(instream); php_stream_close(instream);

Loading…
Cancel
Save