mirror of
https://github.com/php/php-src.git
synced 2025-08-17 14:38:49 +02:00
NetWare related additions/modifications into FTP files
This commit is contained in:
parent
6c51af03e5
commit
77e2ed4834
2 changed files with 124 additions and 4 deletions
118
ext/ftp/ftp.c
118
ext/ftp/ftp.c
|
@ -34,6 +34,23 @@
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#ifdef PHP_WIN32
|
#ifdef PHP_WIN32
|
||||||
#include <winsock.h>
|
#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
|
#else
|
||||||
#ifdef HAVE_SYS_TYPES_H
|
#ifdef HAVE_SYS_TYPES_H
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
@ -130,7 +147,11 @@ ftp_open(const char *host, short port, long timeout_sec TSRMLS_DC)
|
||||||
|
|
||||||
size = sizeof(ftp->localaddr);
|
size = sizeof(ftp->localaddr);
|
||||||
memset(&ftp->localaddr, 0, size);
|
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) {
|
if (getsockname(ftp->fd, (struct sockaddr*) &ftp->localaddr, &size) == -1) {
|
||||||
|
#endif
|
||||||
perror("getsockname");
|
perror("getsockname");
|
||||||
goto bail;
|
goto bail;
|
||||||
}
|
}
|
||||||
|
@ -213,12 +234,30 @@ ftp_login(ftpbuf_t *ftp, const char *user, const char *pass)
|
||||||
return 0;
|
return 0;
|
||||||
if (!ftp_getresp(ftp))
|
if (!ftp_getresp(ftp))
|
||||||
return 0;
|
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)
|
if (ftp->resp == 230)
|
||||||
return 1;
|
return 1;
|
||||||
if (ftp->resp != 331)
|
if (ftp->resp != 331)
|
||||||
return 0;
|
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))
|
if (!ftp_putcmd(ftp, "PASS", pass))
|
||||||
return 0;
|
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))
|
if (!ftp_getresp(ftp))
|
||||||
return 0;
|
return 0;
|
||||||
return (ftp->resp == 230);
|
return (ftp->resp == 230);
|
||||||
|
@ -833,6 +872,11 @@ ftp_putcmd(ftpbuf_t *ftp, const char *cmd, const char *args)
|
||||||
int size;
|
int size;
|
||||||
char *data;
|
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 */
|
/* build the output buffer */
|
||||||
if (args && args[0]) {
|
if (args && args[0]) {
|
||||||
/* "cmd args\r\n\0" */
|
/* "cmd args\r\n\0" */
|
||||||
|
@ -848,6 +892,12 @@ ftp_putcmd(ftpbuf_t *ftp, const char *cmd, const char *args)
|
||||||
}
|
}
|
||||||
|
|
||||||
data = ftp->outbuf;
|
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)
|
if (my_send(ftp, ftp->fd, data, size) != size)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -896,6 +946,11 @@ ftp_readline(ftpbuf_t *ftp)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#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;
|
data = eol;
|
||||||
if ((rcvd = my_recv(ftp, ftp->fd, data, size)) < 1) {
|
if ((rcvd = my_recv(ftp, ftp->fd, data, size)) < 1) {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -917,6 +972,11 @@ ftp_getresp(ftpbuf_t *ftp)
|
||||||
buf = ftp->inbuf;
|
buf = ftp->inbuf;
|
||||||
ftp->resp = 0;
|
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) {
|
while (1) {
|
||||||
|
|
||||||
if (!ftp_readline(ftp)) {
|
if (!ftp_readline(ftp)) {
|
||||||
|
@ -944,6 +1004,11 @@ ftp_getresp(ftpbuf_t *ftp)
|
||||||
10 * (ftp->inbuf[1] - '0') +
|
10 * (ftp->inbuf[1] - '0') +
|
||||||
(ftp->inbuf[2] - '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);
|
memmove(ftp->inbuf, ftp->inbuf + 4, FTP_BUFSIZE - 4);
|
||||||
|
|
||||||
if (ftp->extra)
|
if (ftp->extra)
|
||||||
|
@ -969,15 +1034,38 @@ my_send(ftpbuf_t *ftp, int s, void *buf, size_t len)
|
||||||
|
|
||||||
FD_ZERO(&write_set);
|
FD_ZERO(&write_set);
|
||||||
FD_SET(s, &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);
|
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) {
|
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)
|
if (n == 0)
|
||||||
errno = ETIMEDOUT;
|
errno = ETIMEDOUT;
|
||||||
#endif
|
#endif
|
||||||
return -1;
|
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);
|
sent = send(s, buf, size, 0);
|
||||||
if (sent == -1)
|
if (sent == -1)
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -1004,9 +1092,16 @@ my_recv(ftpbuf_t *ftp, int s, void *buf, size_t len)
|
||||||
|
|
||||||
FD_ZERO(&read_set);
|
FD_ZERO(&read_set);
|
||||||
FD_SET(s, &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);
|
n = select(s + 1, &read_set, NULL, NULL, &tv);
|
||||||
if (n < 1) {
|
if (n < 1) {
|
||||||
#ifndef PHP_WIN32
|
/*#ifndef PHP_WIN32*/
|
||||||
|
#if !defined(PHP_WIN32) && !(defined(NETWARE) && defined(USE_WINSOCK))
|
||||||
if (n == 0)
|
if (n == 0)
|
||||||
errno = ETIMEDOUT;
|
errno = ETIMEDOUT;
|
||||||
#endif
|
#endif
|
||||||
|
@ -1033,7 +1128,8 @@ data_available(ftpbuf_t *ftp, int s)
|
||||||
FD_SET(s, &read_set);
|
FD_SET(s, &read_set);
|
||||||
n = select(s + 1, &read_set, NULL, NULL, &tv);
|
n = select(s + 1, &read_set, NULL, NULL, &tv);
|
||||||
if (n < 1) {
|
if (n < 1) {
|
||||||
#ifndef PHP_WIN32
|
/*#ifndef PHP_WIN32*/
|
||||||
|
#if !defined(PHP_WIN32) && !(defined(NETWARE) && defined(USE_WINSOCK))
|
||||||
if (n == 0)
|
if (n == 0)
|
||||||
errno = ETIMEDOUT;
|
errno = ETIMEDOUT;
|
||||||
#endif
|
#endif
|
||||||
|
@ -1084,16 +1180,26 @@ my_accept(ftpbuf_t *ftp, int s, struct sockaddr *addr, int *addrlen)
|
||||||
FD_ZERO(&accept_set);
|
FD_ZERO(&accept_set);
|
||||||
FD_SET(s, &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);
|
n = select(s + 1, &accept_set, NULL, NULL, &tv);
|
||||||
if (n < 1) {
|
if (n < 1) {
|
||||||
#ifndef PHP_WIN32
|
/*#ifndef PHP_WIN32*/
|
||||||
|
#if !defined(PHP_WIN32) && !(defined(NETWARE) && defined(USE_WINSOCK))
|
||||||
if (n == 0)
|
if (n == 0)
|
||||||
errno = ETIMEDOUT;
|
errno = ETIMEDOUT;
|
||||||
#endif
|
#endif
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(NETWARE) && !defined(USE_WINSOCK)
|
||||||
|
return accept(s, addr, (unsigned int*)addrlen);
|
||||||
|
#else
|
||||||
return accept(s, addr, addrlen);
|
return accept(s, addr, addrlen);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
|
@ -1165,7 +1271,11 @@ ftp_getdata(ftpbuf_t *ftp)
|
||||||
goto bail;
|
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) {
|
if (getsockname(fd, (struct sockaddr*) &addr, &size) == -1) {
|
||||||
|
#endif
|
||||||
perror("getsockname");
|
perror("getsockname");
|
||||||
goto bail;
|
goto bail;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,16 @@
|
||||||
|
|
||||||
#include "php.h"
|
#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
|
#if HAVE_FTP
|
||||||
|
|
||||||
#include "ext/standard/info.h"
|
#include "ext/standard/info.h"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue