Skip to content

Commit 8bfd3ab

Browse files
author
Anantha Kesari H Y
committed
NetWare related changes/modifications.
1 parent 3ee3b69 commit 8bfd3ab

File tree

11 files changed

+125
-21
lines changed

11 files changed

+125
-21
lines changed

ext/ftp/ftp.c

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,18 @@
3333
#include <time.h>
3434
#ifdef PHP_WIN32
3535
#include <winsock.h>
36+
#elif defined(NETWARE)
37+
#ifdef USE_WINSOCK /* Modified to use Winsock (NOVSOCK2.H), atleast for now */
38+
#include <novsock2.h>
39+
#else
40+
#ifdef NEW_LIBC
41+
#include <sys/socket.h>
42+
#include <netinet/in.h>
43+
#include <netdb.h>
44+
#else
45+
#include <sys/socket.h>
46+
#endif
47+
#endif
3648
#else
3749
#ifdef HAVE_SYS_TYPES_H
3850
#include <sys/types.h>
@@ -56,11 +68,16 @@
5668
#include "ext/standard/fsock.h"
5769

5870
/* define closesocket macro for portability */
59-
#ifndef PHP_WIN32
71+
#if !defined(PHP_WIN32) && !(defined(NETWARE) && defined(USE_WINSOCK))
6072
#undef closesocket
6173
#define closesocket close
6274
#endif
6375

76+
/* Additional headers for NetWare */
77+
#if defined(NETWARE) && defined(NEW_LIBC) && !defined(USE_WINSOCK)
78+
#include <sys/select.h>
79+
#endif
80+
6481
/* sends an ftp command, returns true on success, false on error.
6582
* it sends the string "cmd args\r\n" if args is non-null, or
6683
* "cmd\r\n" if args is null
@@ -130,7 +147,7 @@ ftp_open(const char *host, short port, long timeout_sec)
130147

131148
size = sizeof(ftp->localaddr);
132149
memset(&ftp->localaddr, 0, size);
133-
if (getsockname(ftp->fd, (struct sockaddr*) &ftp->localaddr, &size) == -1) {
150+
if (getsockname(ftp->fd, (struct sockaddr*) &ftp->localaddr, (unsigned int*)&size) == -1) {
134151
perror("getsockname");
135152
goto bail;
136153
}
@@ -946,7 +963,7 @@ my_send(ftpbuf_t *ftp, int s, void *buf, size_t len)
946963
FD_SET(s, &write_set);
947964
n = select(s + 1, NULL, &write_set, NULL, &tv);
948965
if (n < 1) {
949-
#ifndef PHP_WIN32
966+
#if !defined(PHP_WIN32) && !(defined(NETWARE) && defined(USE_WINSOCK))
950967
if (n == 0)
951968
errno = ETIMEDOUT;
952969
#endif
@@ -981,7 +998,7 @@ my_recv(ftpbuf_t *ftp, int s, void *buf, size_t len)
981998
FD_SET(s, &read_set);
982999
n = select(s + 1, &read_set, NULL, NULL, &tv);
9831000
if (n < 1) {
984-
#ifndef PHP_WIN32
1001+
#if !defined(PHP_WIN32) && !(defined(NETWARE) && defined(USE_WINSOCK))
9851002
if (n == 0)
9861003
errno = ETIMEDOUT;
9871004
#endif
@@ -1008,14 +1025,14 @@ my_accept(ftpbuf_t *ftp, int s, struct sockaddr *addr, int *addrlen)
10081025

10091026
n = select(s + 1, &accept_set, NULL, NULL, &tv);
10101027
if (n < 1) {
1011-
#ifndef PHP_WIN32
1028+
#if !defined(PHP_WIN32) && !(defined(NETWARE) && defined(USE_WINSOCK))
10121029
if (n == 0)
10131030
errno = ETIMEDOUT;
10141031
#endif
10151032
return -1;
10161033
}
10171034

1018-
return accept(s, addr, addrlen);
1035+
return accept(s, addr, (unsigned int*)addrlen);
10191036
}
10201037
/* }}} */
10211038

@@ -1087,7 +1104,7 @@ ftp_getdata(ftpbuf_t *ftp)
10871104
goto bail;
10881105
}
10891106

1090-
if (getsockname(fd, (struct sockaddr*) &addr, &size) == -1) {
1107+
if (getsockname(fd, (struct sockaddr*) &addr, (unsigned int*)&size) == -1) {
10911108
perror("getsockname");
10921109
goto bail;
10931110
}

ext/ftp/php_ftp.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,16 @@
2424

2525
#include "php.h"
2626

27+
#ifdef NETWARE
28+
#ifdef USE_WINSOCK
29+
#include <novsock2.h>
30+
#else
31+
#ifndef NEW_LIBC
32+
#include <sys/socket.h>
33+
#endif
34+
#endif
35+
#endif
36+
2737
#if HAVE_FTP
2838

2939
#include "ext/standard/info.h"
@@ -482,7 +492,7 @@ PHP_FUNCTION(ftp_get)
482492
RETURN_FALSE;
483493
}
484494

485-
#ifdef PHP_WIN32
495+
#if defined(PHP_WIN32) || defined(NETWARE) /* On Windows and NetWare, the file should always be opened in binary mode */
486496
if ((outfp = VCWD_FOPEN(local, "wb")) == NULL) {
487497
#else
488498
if ((outfp = VCWD_FOPEN(local, "w")) == NULL) {
@@ -557,7 +567,7 @@ PHP_FUNCTION(ftp_put)
557567
ZEND_FETCH_RESOURCE(ftp, ftpbuf_t*, &z_ftp, -1, le_ftpbuf_name, le_ftpbuf);
558568
XTYPE(xtype, mode);
559569

560-
#ifdef PHP_WIN32
570+
#if defined(PHP_WIN32) || defined(NETWARE) /* On Windows and NetWare, the file should always be opened in binary mode */
561571
if ((infp = VCWD_FOPEN(local, "rb")) == NULL) {
562572
#else
563573
if ((infp = VCWD_FOPEN(local, "r")) == NULL) {

ext/imap/php_imap.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ PHP_MINIT_FUNCTION(imap)
421421

422422
ZEND_INIT_MODULE_GLOBALS(imap, php_imap_init_globals, NULL)
423423

424-
#ifndef PHP_WIN32
424+
#if !defined(PHP_WIN32) && !defined(NETWARE)
425425
mail_link(&unixdriver); /* link in the unix driver */
426426
mail_link(&mhdriver); /* link in the mh driver */
427427
/* mail_link(&mxdriver); */ /* According to c-client docs (internal.txt) this shouldn't be used. */
@@ -437,7 +437,7 @@ PHP_MINIT_FUNCTION(imap)
437437
mail_link(&mtxdriver); /* link in the mtx driver */
438438
mail_link(&dummydriver); /* link in the dummy driver */
439439

440-
#ifndef PHP_WIN32
440+
#if !defined(PHP_WIN32) && !defined(NETWARE)
441441
auth_link(&auth_log); /* link in the log authenticator */
442442
auth_link(&auth_md5); /* link in the cram-md5 authenticator */
443443
#ifdef HAVE_IMAP_SSL

ext/ldap/ldap.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@
2929
#include "config.h"
3030
#endif
3131

32+
/* Additional headers for NetWare */
33+
#if defined(NETWARE) && (NEW_LIBC)
34+
#include <sys/select.h>
35+
#include <sys/timeval.h>
36+
#endif
37+
3238
#include "php.h"
3339
#include "php_ini.h"
3440

@@ -118,9 +124,11 @@ function_entry ldap_functions[] = {
118124
PHP_FE(ldap_rename, NULL)
119125
#endif
120126

127+
#ifndef NETWARE /* The below function not supported on NetWare */
121128
#if LDAP_API_VERSION > 2000
122129
PHP_FE(ldap_start_tls, NULL)
123130
#endif
131+
#endif /* NETWARE */
124132

125133
#if defined(LDAP_API_FEATURE_X_OPENLDAP) && defined(HAVE_3ARG_SETREBINDPROC)
126134
PHP_FE(ldap_set_rebind_proc, NULL)
@@ -492,7 +500,16 @@ PHP_FUNCTION(ldap_bind)
492500

493501
ZEND_FETCH_RESOURCE(ld, ldap_linkdata *, link, -1, "ldap link", le_link);
494502

503+
#ifndef NETWARE
495504
if (ldap_bind_s(ld->link, ldap_bind_rdn, ldap_bind_pw, LDAP_AUTH_SIMPLE) != LDAP_SUCCESS) {
505+
#else
506+
/* The function ldap_bind_s has been deprecated on NetWare. If it is used on NetWare,
507+
it gives the result, but will also result in the display of warning message
508+
that gets displayed on the web browser.
509+
ldap_simple_bind_s removes that warning.
510+
*/
511+
if (ldap_simple_bind_s(ld->link, (const char *)ldap_bind_rdn, (const char *)ldap_bind_pw) != LDAP_SUCCESS) {
512+
#endif
496513
php_error(E_WARNING, "LDAP: Unable to bind to server: %s", ldap_err2string(_get_lderrno(ld->link)));
497514
RETURN_FALSE;
498515
} else {
@@ -1992,6 +2009,7 @@ PHP_FUNCTION(ldap_rename)
19922009
/* }}} */
19932010
#endif
19942011

2012+
#ifndef NETWARE /* The below function not supported on NetWare */
19952013
#if LDAP_API_VERSION > 2000
19962014
/* {{{ proto bool ldap_start_tls(resource link)
19972015
Start TLS */
@@ -2016,6 +2034,7 @@ PHP_FUNCTION(ldap_start_tls)
20162034
}
20172035
/* }}} */
20182036
#endif
2037+
#endif /* NETWARE */
20192038

20202039

20212040
#if defined(LDAP_API_FEATURE_X_OPENLDAP) && defined(HAVE_3ARG_SETREBINDPROC)

ext/ldap/php_ldap.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,11 @@ PHP_FUNCTION(ldap_parse_reference);
8989
PHP_FUNCTION(ldap_rename);
9090
#endif
9191

92+
#ifndef NETWARE /* The below function not supported on NetWare */
9293
#if LDAP_API_VERSION > 2000
9394
PHP_FUNCTION(ldap_start_tls);
9495
#endif
96+
#endif /* NETWARE */
9597

9698
#if defined(LDAP_API_FEATURE_X_OPENLDAP) && defined(HAVE_3ARG_SETREBINDPROC)
9799
PHP_FUNCTION(ldap_set_rebind_proc);

ext/mysql/php_mysql.c

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@
3737
#ifdef PHP_WIN32
3838
#include <winsock.h>
3939
#define signal(a, b) NULL
40+
#elif defined(NETWARE)
41+
/*#include <ws2nlm.h>*/
42+
#include <sys/socket.h>
43+
#define signal(a, b) NULL
4044
#else
4145
#include "build-defs.h"
4246
#if HAVE_SIGNAL_H
@@ -124,10 +128,12 @@ function_entry mysql_functions[] = {
124128
PHP_FE(mysql_pconnect, NULL)
125129
PHP_FE(mysql_close, NULL)
126130
PHP_FE(mysql_select_db, NULL)
131+
#ifndef NETWARE /* The below two functions not supported on NetWare */
127132
#if MYSQL_VERSION_ID < 40000
128133
PHP_FE(mysql_create_db, NULL)
129134
PHP_FE(mysql_drop_db, NULL)
130135
#endif
136+
#endif /* NETWARE */
131137
PHP_FE(mysql_query, NULL)
132138
PHP_FE(mysql_unbuffered_query, NULL)
133139
PHP_FE(mysql_db_query, NULL)
@@ -173,10 +179,12 @@ function_entry mysql_functions[] = {
173179
PHP_FALIAS(mysql_fieldtype, mysql_field_type, NULL)
174180
PHP_FALIAS(mysql_fieldflags, mysql_field_flags, NULL)
175181
PHP_FALIAS(mysql_selectdb, mysql_select_db, NULL)
182+
#ifndef NETWARE /* The below two functions not supported on NetWare */
176183
#if MYSQL_VERSION_ID < 40000
177184
PHP_FALIAS(mysql_createdb, mysql_create_db, NULL)
178185
PHP_FALIAS(mysql_dropdb, mysql_drop_db, NULL)
179186
#endif
187+
#endif /* NETWARE */
180188
PHP_FALIAS(mysql_freeresult, mysql_free_result, NULL)
181189
PHP_FALIAS(mysql_numfields, mysql_num_fields, NULL)
182190
PHP_FALIAS(mysql_numrows, mysql_num_rows, NULL)
@@ -297,7 +305,7 @@ static void _close_mysql_plink(zend_rsrc_list_entry *rsrc TSRMLS_DC)
297305
static PHP_INI_MH(OnMySQLPort)
298306
{
299307
if (new_value==NULL) { /* default port */
300-
#ifndef PHP_WIN32
308+
#if !defined (PHP_WIN32) && ! defined (NETWARE)
301309
struct servent *serv_ptr;
302310
char *env;
303311

@@ -427,7 +435,7 @@ PHP_MINFO_FUNCTION(mysql)
427435
sprintf(buf, "%ld", MySG(num_links));
428436
php_info_print_table_row(2, "Active Links", buf);
429437
php_info_print_table_row(2, "Client API version", mysql_get_client_info());
430-
#ifndef PHP_WIN32
438+
#if !defined (PHP_WIN32) && !defined (NETWARE)
431439
php_info_print_table_row(2, "MYSQL_MODULE_TYPE", PHP_MYSQL_TYPE);
432440
php_info_print_table_row(2, "MYSQL_SOCKET", MYSQL_UNIX_ADDR);
433441
php_info_print_table_row(2, "MYSQL_INCLUDE", PHP_MYSQL_INCLUDE);
@@ -834,7 +842,7 @@ PHP_FUNCTION(mysql_get_client_info)
834842
WRONG_PARAM_COUNT;
835843
}
836844

837-
RETURN_STRING(mysql_get_client_info(),1);
845+
RETURN_STRING((char *)mysql_get_client_info(),1); /* Type-casting done due to NetWare */
838846
}
839847
/* }}} */
840848

@@ -864,7 +872,7 @@ PHP_FUNCTION(mysql_get_host_info)
864872

865873
ZEND_FETCH_RESOURCE2(mysql, php_mysql_conn *, mysql_link, id, "MySQL-Link", le_link, le_plink);
866874

867-
RETURN_STRING(mysql_get_host_info(&mysql->conn),1);
875+
RETURN_STRING((char *)mysql_get_host_info(&mysql->conn),1); /* Type-casting done due to NetWare */
868876
}
869877
/* }}} */
870878

@@ -924,12 +932,14 @@ PHP_FUNCTION(mysql_get_server_info)
924932

925933
ZEND_FETCH_RESOURCE2(mysql, php_mysql_conn *, mysql_link, id, "MySQL-Link", le_link, le_plink);
926934

927-
RETURN_STRING(mysql_get_server_info(&mysql->conn),1);
935+
RETURN_STRING((char *)mysql_get_server_info(&mysql->conn),1); /* Type-casting done due to NetWare */
928936
}
929937
/* }}} */
930938

931939
#endif
932940

941+
#ifndef NETWARE /* The below two functions not supported on NetWare */
942+
933943
#if MYSQL_VERSION_ID < 40000
934944
/* {{{ proto bool mysql_create_db(string database_name [, int link_identifier])
935945
Create a MySQL database */
@@ -1009,6 +1019,8 @@ PHP_FUNCTION(mysql_drop_db)
10091019
/* }}} */
10101020
#endif
10111021

1022+
#endif /* NETWARE */
1023+
10121024
/* {{{ php_mysql_do_query_general
10131025
*/
10141026
static void php_mysql_do_query_general(zval **query, zval **mysql_link, int link_id, zval **db, int use_store, zval *return_value TSRMLS_DC)
@@ -1310,7 +1322,7 @@ PHP_FUNCTION(mysql_error)
13101322

13111323
ZEND_FETCH_RESOURCE2(mysql, php_mysql_conn *, mysql_link, id, "MySQL-Link", le_link, le_plink);
13121324

1313-
RETURN_STRING(mysql_error(&mysql->conn), 1);
1325+
RETURN_STRING((char *)mysql_error(&mysql->conn), 1); /* Type-casting done due to NetWare */
13141326
}
13151327
/* }}} */
13161328

ext/pcre/pcrelib/internal.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ modules, but which are not relevant to the outside. */
3939

4040
#ifdef PHP_WIN32
4141
#include "config.w32.h"
42+
#elif defined(NETWARE)
43+
#include "config.nw.h"
4244
#else
4345
#include "php_config.h"
4446
#endif

ext/pgsql/php_pgsql.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ extern zend_module_entry pgsql_module_entry;
3434
#ifdef PHP_WIN32
3535
#define INV_WRITE 0x00020000
3636
#define INV_READ 0x00040000
37+
#elif defined NETWARE
38+
#include <libpq-fs.h>
3739
#else
3840
#include <libpq/libpq-fs.h>
3941
#endif

ext/session/mod_files.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,11 @@ static int ps_files_cleanup_dir(const char *dirname, int maxlifetime TSRMLS_DC)
156156
DIR *dir;
157157
char dentry[sizeof(struct dirent) + MAXPATHLEN];
158158
struct dirent *entry = (struct dirent *) &dentry;
159+
#if (defined(NETWARE) && defined(CLIB_STAT_PATCH))
160+
struct stat_libc sbuf;
161+
#else
159162
struct stat sbuf;
163+
#endif
160164
char buf[MAXPATHLEN];
161165
time_t now;
162166
int nrdels = 0;
@@ -190,7 +194,11 @@ static int ps_files_cleanup_dir(const char *dirname, int maxlifetime TSRMLS_DC)
190194
buf[dirname_len + entry_len + 1] = '\0';
191195
/* check whether its last access was more than maxlifet ago */
192196
if (VCWD_STAT(buf, &sbuf) == 0 &&
193-
(now - sbuf.st_atime) > maxlifetime) {
197+
#if (defined(NETWARE) && defined(NEW_LIBC))
198+
(now - sbuf.st_atime.tv_nsec) > maxlifetime) {
199+
#else
200+
(now - sbuf.st_atime) > maxlifetime) {
201+
#endif
194202
VCWD_UNLINK(buf);
195203
nrdels++;
196204
}
@@ -242,14 +250,22 @@ PS_CLOSE_FUNC(files)
242250
PS_READ_FUNC(files)
243251
{
244252
long n;
253+
#if (defined(NETWARE) && defined(CLIB_STAT_PATCH))
254+
struct stat_libc sbuf;
255+
#else
245256
struct stat sbuf;
257+
#endif
246258
PS_FILES_DATA;
247259

248260
ps_files_open(data, key TSRMLS_CC);
249261
if (data->fd < 0)
250262
return FAILURE;
251263

264+
#if (defined(NETWARE) && defined(CLIB_STAT_PATCH))
265+
if (fstat(data->fd, ((struct stat*)&sbuf)))
266+
#else
252267
if (fstat(data->fd, &sbuf))
268+
#endif
253269
return FAILURE;
254270

255271
data->st_size = *vallen = sbuf.st_size;

0 commit comments

Comments
 (0)