cvs: php4 /ext/ftp ftp.c php_ftp.c

From: Date: Thu, 05 Sep 2002 10:13:27 +0000
Subject: cvs: php4 /ext/ftp ftp.c php_ftp.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-13843@lists.php.net to get a copy of this message
hyanantha Thu Sep 5 06:13:27 2002 EDT Modified files: /php4/ext/ftp ftp.c php_ftp.c Log: NetWare related additions/modifications into FTP files Index: php4/ext/ftp/ftp.c diff -u php4/ext/ftp/ftp.c:1.60 php4/ext/ftp/ftp.c:1.61 --- php4/ext/ftp/ftp.c:1.60 Sun Aug 25 18:17:55 2002 +++ php4/ext/ftp/ftp.c Thu Sep 5 06:13:27 2002 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: ftp.c,v 1.60 2002/08/25 22:17:55 sebastian Exp $ */ +/* $Id: ftp.c,v 1.61 2002/09/05 10:13:27 hyanantha Exp $ */ #include "php.h" @@ -34,6 +34,23 @@ #include <time.h> #ifdef PHP_WIN32 #include <winsock.h> +#elif defined(NETWARE) +#ifdef USE_WINSOCK /* Modified to use Winsock (NOVSOCK2.H), atleast for now */ +#include <novsock2.h> +#else +#ifdef NEW_LIBC +#include <sys/socket.h> +#include <netinet/in.h> +#include <netdb.h> +#else +#include <sys/socket.h> +#endif +#endif + +/* Below stuff to introduce delay so that sockets are freed */ +#define THREAD_SWITCH_DELAY 1000 +#define THREAD_SWITCH_WITH_DELAY NXThreadDelay(THREAD_SWITCH_DELAY) + #else #ifdef HAVE_SYS_TYPES_H #include <sys/types.h> @@ -130,7 +147,11 @@ size = sizeof(ftp->localaddr); memset(&ftp->localaddr, 0, size); +#if defined(NETWARE) && !defined(USE_WINSOCK) + if (getsockname(ftp->fd, (struct sockaddr*) &ftp->localaddr, (unsigned int*)&size) == -1) { +#else if (getsockname(ftp->fd, (struct sockaddr*) &ftp->localaddr, &size) == -1) { +#endif perror("getsockname"); goto bail; } @@ -213,12 +234,30 @@ return 0; if (!ftp_getresp(ftp)) return 0; + +#if defined(NETWARE) && defined(USE_WINSOCK) /* Atleast for now, to allow sockets to be freed */ + /*THREAD_SWITCH_WITH_DELAY;*/ + printf ("PHP | ftp_login: response = %d\n", ftp->resp); +#endif + if (ftp->resp == 230) return 1; if (ftp->resp != 331) return 0; + +#if defined(NETWARE) && defined(USE_WINSOCK) /* Atleast for now, to allow sockets to be freed */ + /*THREAD_SWITCH_WITH_DELAY;*/ + printf ("PHP | ftp_login: sending password...\n"); +#endif + if (!ftp_putcmd(ftp, "PASS", pass)) return 0; + +#if defined(NETWARE) && defined(USE_WINSOCK) /* Atleast for now, to allow sockets to be freed */ + /*THREAD_SWITCH_WITH_DELAY;*/ + printf ("PHP | ftp_login: getting response...\n"); +#endif + if (!ftp_getresp(ftp)) return 0; return (ftp->resp == 230); @@ -833,6 +872,11 @@ int size; char *data; +#if defined(NETWARE) && defined(USE_WINSOCK) /* Atleast for now, to allow sockets to be freed */ + /*THREAD_SWITCH_WITH_DELAY;*/ + printf ("PHP | ftp_putcmd: building output buffer...\n"); +#endif + /* build the output buffer */ if (args && args[0]) { /* "cmd args\r\n\0" */ @@ -848,6 +892,12 @@ } data = ftp->outbuf; + +#if defined(NETWARE) && defined(USE_WINSOCK) /* Atleast for now, to allow sockets to be freed */ + /*THREAD_SWITCH_WITH_DELAY;*/ + printf ("PHP | ftp_putcmd: sending data...\n"); +#endif + if (my_send(ftp, ftp->fd, data, size) != size) return 0; @@ -896,6 +946,11 @@ } } +#if defined(NETWARE) && defined(USE_WINSOCK) /* Atleast for now, to allow sockets to be freed */ + /*THREAD_SWITCH_WITH_DELAY;*/ + printf ("PHP | ftp_readline: receiving data...\n"); +#endif + data = eol; if ((rcvd = my_recv(ftp, ftp->fd, data, size)) < 1) { return 0; @@ -917,6 +972,11 @@ buf = ftp->inbuf; ftp->resp = 0; +#if defined(NETWARE) && defined(USE_WINSOCK) /* Atleast for now, to allow sockets to be freed */ + /*THREAD_SWITCH_WITH_DELAY;*/ + printf ("PHP | ftp_getresp: getting response...\n"); +#endif + while (1) { if (!ftp_readline(ftp)) { @@ -944,6 +1004,11 @@ 10 * (ftp->inbuf[1] - '0') + (ftp->inbuf[2] - '0'); +#if defined(NETWARE) && defined(USE_WINSOCK) /* Atleast for now, to allow sockets to be freed */ + /*THREAD_SWITCH_WITH_DELAY;*/ + printf ("PHP | ftp_getresp: response = %c%c%c\n", ftp->inbuf[0], ftp->inbuf[1], ftp->inbuf[2]); +#endif + memmove(ftp->inbuf, ftp->inbuf + 4, FTP_BUFSIZE - 4); if (ftp->extra) @@ -969,15 +1034,38 @@ FD_ZERO(&write_set); FD_SET(s, &write_set); + +#if defined(NETWARE) && defined(USE_WINSOCK) /* Atleast for now, to allow sockets to be freed */ + /*THREAD_SWITCH_WITH_DELAY;*/ + printf ("PHP | my_send: calling select()...\n"); +#endif + n = select(s + 1, NULL, &write_set, NULL, &tv); + +#if defined(NETWARE) && defined(USE_WINSOCK) /* Atleast for now, to allow sockets to be freed */ + /*THREAD_SWITCH_WITH_DELAY;*/ + printf ("PHP | my_send: select() returned %d\n", n); +#endif + if (n < 1) { -#ifndef PHP_WIN32 +#if defined(NETWARE) && defined(USE_WINSOCK) /* Atleast for now, to allow sockets to be freed */ + /*THREAD_SWITCH_WITH_DELAY;*/ + printf ("PHP | my_send: error = %d\n", errno); +#endif + +/*#ifndef PHP_WIN32*/ +#if !defined(PHP_WIN32) && !(defined(NETWARE) && defined(USE_WINSOCK)) if (n == 0) errno = ETIMEDOUT; #endif return -1; } +#if defined(NETWARE) && defined(USE_WINSOCK) /* Atleast for now, to allow sockets to be freed */ + /*THREAD_SWITCH_WITH_DELAY;*/ + printf ("PHP | my_send: FTP request **%s**\n", buf); +#endif + sent = send(s, buf, size, 0); if (sent == -1) return -1; @@ -1004,9 +1092,16 @@ FD_ZERO(&read_set); FD_SET(s, &read_set); + +#if defined(NETWARE) && defined(USE_WINSOCK) /* Atleast for now, to allow sockets to be freed */ + /*THREAD_SWITCH_WITH_DELAY;*/ + printf ("PHP | my_recv: calling select()...\n"); +#endif + n = select(s + 1, &read_set, NULL, NULL, &tv); if (n < 1) { -#ifndef PHP_WIN32 +/*#ifndef PHP_WIN32*/ +#if !defined(PHP_WIN32) && !(defined(NETWARE) && defined(USE_WINSOCK)) if (n == 0) errno = ETIMEDOUT; #endif @@ -1033,7 +1128,8 @@ FD_SET(s, &read_set); n = select(s + 1, &read_set, NULL, NULL, &tv); if (n < 1) { -#ifndef PHP_WIN32 +/*#ifndef PHP_WIN32*/ +#if !defined(PHP_WIN32) && !(defined(NETWARE) && defined(USE_WINSOCK)) if (n == 0) errno = ETIMEDOUT; #endif @@ -1084,16 +1180,26 @@ FD_ZERO(&accept_set); FD_SET(s, &accept_set); +#if defined(NETWARE) && defined(USE_WINSOCK) /* Atleast for now, to allow sockets to be freed */ + /*THREAD_SWITCH_WITH_DELAY;*/ + printf ("PHP | FTP: calling select()...\n"); +#endif + n = select(s + 1, &accept_set, NULL, NULL, &tv); if (n < 1) { -#ifndef PHP_WIN32 +/*#ifndef PHP_WIN32*/ +#if !defined(PHP_WIN32) && !(defined(NETWARE) && defined(USE_WINSOCK)) if (n == 0) errno = ETIMEDOUT; #endif return -1; } +#if defined(NETWARE) && !defined(USE_WINSOCK) + return accept(s, addr, (unsigned int*)addrlen); +#else return accept(s, addr, addrlen); +#endif } /* }}} */ @@ -1165,7 +1271,11 @@ goto bail; } +#if defined(NETWARE) && !defined(USE_WINSOCK) + if (getsockname(fd, (struct sockaddr*) &addr, (unsigned int*)&size) == -1) { +#else if (getsockname(fd, (struct sockaddr*) &addr, &size) == -1) { +#endif perror("getsockname"); goto bail; } Index: php4/ext/ftp/php_ftp.c diff -u php4/ext/ftp/php_ftp.c:1.70 php4/ext/ftp/php_ftp.c:1.71 --- php4/ext/ftp/php_ftp.c:1.70 Sun Aug 25 18:17:55 2002 +++ php4/ext/ftp/php_ftp.c Thu Sep 5 06:13:27 2002 @@ -17,13 +17,23 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_ftp.c,v 1.70 2002/08/25 22:17:55 sebastian Exp $ */ +/* $Id: php_ftp.c,v 1.71 2002/09/05 10:13:27 hyanantha Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include "php.h" + +#ifdef NETWARE +#ifdef USE_WINSOCK +#include <novsock2.h> +#else +#ifndef NEW_LIBC +#include <sys/socket.h> +#endif +#endif +#endif #if HAVE_FTP

« previous php.cvs (#13843) next »