summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnantha Kesari H Y <hyanantha@php.net>2002-10-24 11:34:14 +0000
committerAnantha Kesari H Y <hyanantha@php.net>2002-10-24 11:34:14 +0000
commite966a0433c317b4cfd50effea5843893d9a2e642 (patch)
treeab3b866c0df9e0d0fe3ddd210d1619c5908e4707
parent4bc5295e742f39f0efb15dabe13b80bd312dce6c (diff)
downloadphp-git-e966a0433c317b4cfd50effea5843893d9a2e642.tar.gz
NetWare related changes/modifications.
-rw-r--r--ext/standard/base64.c8
-rw-r--r--ext/standard/basic_functions.c26
-rw-r--r--ext/standard/datetime.c3
-rw-r--r--ext/standard/dl.c28
-rw-r--r--ext/standard/dns.c9
-rw-r--r--ext/standard/file.c14
-rw-r--r--ext/standard/filestat.c84
-rw-r--r--ext/standard/flock_compat.c8
-rw-r--r--ext/standard/fsock.c23
-rw-r--r--ext/standard/fsock.h8
-rw-r--r--ext/standard/ftp_fopen_wrapper.c13
-rw-r--r--ext/standard/head.c5
-rw-r--r--ext/standard/html.c6
-rw-r--r--ext/standard/http_fopen_wrapper.c13
-rw-r--r--ext/standard/image.c30
-rw-r--r--ext/standard/info.c6
-rw-r--r--ext/standard/iptc.c26
-rw-r--r--ext/standard/lcg.c6
-rw-r--r--ext/standard/link.c2
-rw-r--r--ext/standard/mail.c14
-rw-r--r--ext/standard/math.c4
-rw-r--r--ext/standard/md5.c2
-rw-r--r--ext/standard/microtime.c6
-rw-r--r--ext/standard/pack.c14
-rw-r--r--ext/standard/pageinfo.c13
-rw-r--r--ext/standard/rand.c4
-rw-r--r--ext/standard/string.c24
-rw-r--r--ext/standard/syslog.c4
-rw-r--r--ext/standard/var_unserializer.c5
-rw-r--r--ext/xml/expat/xmltok_impl.c5
-rw-r--r--ext/xml/xml.c2
-rw-r--r--main/SAPI.c10
-rw-r--r--main/SAPI.h8
-rw-r--r--main/fopen_wrappers.c19
-rw-r--r--main/main.c20
-rw-r--r--main/mergesort.c5
-rw-r--r--main/network.c26
-rw-r--r--main/php.h26
-rw-r--r--main/php_compat.h2
-rw-r--r--main/php_ini.c2
-rw-r--r--main/php_logos.c2
-rw-r--r--main/php_open_temporary_file.c24
-rw-r--r--main/php_sprintf.c4
-rw-r--r--main/php_syslog.h5
-rw-r--r--main/reentrancy.c50
-rw-r--r--main/safe_mode.c12
-rw-r--r--sapi/apache/mod_php4.c141
47 files changed, 691 insertions, 80 deletions
diff --git a/ext/standard/base64.c b/ext/standard/base64.c
index b709a2db76..945bd1fba8 100644
--- a/ext/standard/base64.c
+++ b/ext/standard/base64.c
@@ -160,9 +160,9 @@ PHP_FUNCTION(base64_encode)
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &str_len) == FAILURE) {
return;
}
- result = php_base64_encode(str, str_len, &ret_length);
+ result = php_base64_encode((const unsigned char*)str, str_len, &ret_length); /* type-casting done due to NetWare */
if (result != NULL) {
- RETVAL_STRINGL(result, ret_length, 0);
+ RETVAL_STRINGL((char*)result, ret_length, 0); /* type-casting done due to NetWare */
} else {
RETURN_FALSE;
}
@@ -181,9 +181,9 @@ PHP_FUNCTION(base64_decode)
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &str_len) == FAILURE) {
return;
}
- result = php_base64_decode(str, str_len, &ret_length);
+ result = php_base64_decode((const unsigned char*)str, str_len, &ret_length); /* type-casting done due to NetWare */
if (result != NULL) {
- RETVAL_STRINGL(result, ret_length, 0);
+ RETVAL_STRINGL((char*)result, ret_length, 0); /* type-casting done due to NetWare */
} else {
RETURN_FALSE;
}
diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c
index f647981d8c..4cffc878b7 100644
--- a/ext/standard/basic_functions.c
+++ b/ext/standard/basic_functions.c
@@ -38,6 +38,20 @@
#include <stdio.h>
#include <netdb.h>
+/* Additional headers for NetWare */
+#ifdef NETWARE
+/*#include "netware/env.h"*/ /* Temporary */
+#ifdef NEW_LIBC /* Same headers hold good for Winsock and Berkeley sockets */
+#include <netinet/in.h>
+/*#include <arpa/inet.h>*/
+#include <netdb.h>
+#else
+#include <sys/socket.h>
+#endif
+#else
+#include <netdb.h>
+#endif
+
#if HAVE_ARPA_INET_H
# include <arpa/inet.h>
#endif
@@ -415,7 +429,7 @@ function_entry basic_functions[] = {
PHP_FE(gethostbyname, NULL)
PHP_FE(gethostbynamel, NULL)
-#if HAVE_RES_SEARCH && !(defined(__BEOS__) || defined(PHP_WIN32))
+#if HAVE_RES_SEARCH && !(defined(__BEOS__) || defined(PHP_WIN32) || defined(NETWARE))
PHP_FE(checkdnsrr, NULL)
PHP_FE(getmxrr,second_and_third_args_force_ref)
#else
@@ -447,7 +461,7 @@ function_entry basic_functions[] = {
PHP_FE(cosh, NULL)
PHP_FE(tanh, NULL)
-#ifndef PHP_WIN32
+#if !defined(PHP_WIN32) && !defined(NETWARE)
PHP_FE(asinh, NULL)
PHP_FE(acosh, NULL)
PHP_FE(atanh, NULL)
@@ -634,7 +648,7 @@ function_entry basic_functions[] = {
PHP_FE(socket_get_status, NULL)
-#if (!defined(PHP_WIN32) && !defined(__BEOS__) && HAVE_REALPATH) || defined(ZTS)
+#if (!defined(PHP_WIN32) && !defined(__BEOS__) && HAVE_REALPATH && !defined(NETWARE)) || defined(ZTS)
PHP_FE(realpath, NULL)
#else
PHP_FALIAS(realpath, warn_not_available, NULL)
@@ -1001,7 +1015,9 @@ PHP_MINIT_FUNCTION(basic)
PHP_MINIT(lcg) (INIT_FUNC_ARGS_PASSTHRU);
PHP_MINIT(dir) (INIT_FUNC_ARGS_PASSTHRU);
+#ifdef HAVE_SYSLOG_H
PHP_MINIT(syslog) (INIT_FUNC_ARGS_PASSTHRU);
+#endif
PHP_MINIT(array) (INIT_FUNC_ARGS_PASSTHRU);
PHP_MINIT(assert) (INIT_FUNC_ARGS_PASSTHRU);
PHP_MINIT(url_scanner_ex) (INIT_FUNC_ARGS_PASSTHRU);
@@ -1082,7 +1098,9 @@ PHP_RINIT_FUNCTION(basic)
PHP_RINIT(lcg) (INIT_FUNC_ARGS_PASSTHRU);
PHP_RINIT(filestat) (INIT_FUNC_ARGS_PASSTHRU);
+#ifdef HAVE_SYSLOG_H
PHP_RINIT(syslog) (INIT_FUNC_ARGS_PASSTHRU);
+#endif
PHP_RINIT(dir) (INIT_FUNC_ARGS_PASSTHRU);
/* Reset magic_quotes_runtime */
@@ -1113,7 +1131,9 @@ PHP_RSHUTDOWN_FUNCTION(basic)
PHP_RSHUTDOWN(fsock) (SHUTDOWN_FUNC_ARGS_PASSTHRU);
PHP_RSHUTDOWN(filestat) (SHUTDOWN_FUNC_ARGS_PASSTHRU);
+#ifdef HAVE_SYSLOG_H
PHP_RSHUTDOWN(syslog) (SHUTDOWN_FUNC_ARGS_PASSTHRU);
+#endif
PHP_RSHUTDOWN(assert) (SHUTDOWN_FUNC_ARGS_PASSTHRU);
if (BG(user_tick_functions)) {
diff --git a/ext/standard/datetime.c b/ext/standard/datetime.c
index d7fc392dcd..fccc1dfcba 100644
--- a/ext/standard/datetime.c
+++ b/ext/standard/datetime.c
@@ -55,6 +55,9 @@ char *day_short_names[] =
};
#if !defined(HAVE_TM_ZONE) && !defined(_TIMEZONE) && !defined(HAVE_DECLARED_TIMEZONE)
+#if defined(NETWARE) && (NEW_LIBC)
+#define timezone _timezone /* Do not know why this is called '_timezone' in new version of LibC */
+#endif
extern time_t timezone;
extern int daylight;
#endif
diff --git a/ext/standard/dl.c b/ext/standard/dl.c
index fae9ef4fbc..64dd1499d5 100644
--- a/ext/standard/dl.c
+++ b/ext/standard/dl.c
@@ -26,7 +26,7 @@
#include "ext/standard/info.h"
#include "SAPI.h"
-#ifndef PHP_WIN32
+#if !defined(PHP_WIN32) && !defined(NETWARE)
#include "build-defs.h"
#endif
@@ -43,6 +43,13 @@
#include "win32/param.h"
#include "win32/winutil.h"
#define GET_DL_ERROR() php_win_err()
+#elif defined(NETWARE)
+#ifdef NEW_LIBC
+#include <sys/param.h>
+#else
+#include "netware/param.h"
+#endif
+#define GET_DL_ERROR() dlerror()
#else
#include <sys/param.h>
#define GET_DL_ERROR() dlerror()
@@ -141,7 +148,23 @@ void php_dl(pval *file, int type, pval *return_value TSRMLS_DC)
efree(libpath);
-
+
+#ifdef NETWARE
+ /* NetWare doesn't support two NLMs exporting same symbol */
+ {
+ char symbol_name[64] = "\0";
+ int module_name_length = Z_STRLEN_P(file) - 4; /* '.nlm' is 4 characters; knock it off */
+
+ /* Take the module name (e.g.: 'php_ldap') and append '@get_module' to it */
+ strncpy(symbol_name, Z_STRVAL_P(file), module_name_length);
+ symbol_name[module_name_length] = '\0';
+ strcat(symbol_name, "@");
+ strcat(symbol_name, "get_module");
+
+ get_module = (zend_module_entry *(*)(void)) DL_FETCH_SYMBOL(handle, symbol_name);
+ }
+ /* NetWare doesn't prepend _ to symbol names. So, that portion of code is also not necessary */
+#else
get_module = (zend_module_entry *(*)(void)) DL_FETCH_SYMBOL(handle, "get_module");
/*
@@ -152,6 +175,7 @@ void php_dl(pval *file, int type, pval *return_value TSRMLS_DC)
if (!get_module)
get_module = (zend_module_entry *(*)(void)) DL_FETCH_SYMBOL(handle, "_get_module");
+#endif
if (!get_module) {
DL_UNLOAD(handle);
diff --git a/ext/standard/dns.c b/ext/standard/dns.c
index f41b19ea3e..db6d6c5e20 100644
--- a/ext/standard/dns.c
+++ b/ext/standard/dns.c
@@ -42,7 +42,7 @@
#endif
#endif
#include <winsock.h>
-#else
+#else /* This holds good for NetWare too, both for Winsock and Berkeley sockets */
#include <netinet/in.h>
#if HAVE_ARPA_INET_H
#include <arpa/inet.h>
@@ -60,6 +60,11 @@
#endif
#endif
+/* Borrowed from SYS/SOCKET.H */
+#if defined(NETWARE) && defined(USE_WINSOCK)
+#define AF_INET 2 /* internetwork: UDP, TCP, etc. */
+#endif
+
#include "dns.h"
/* }}} */
@@ -201,7 +206,7 @@ static char *php_gethostbyname(char *name)
}
/* }}} */
-#if HAVE_RES_SEARCH && !(defined(__BEOS__)||defined(PHP_WIN32))
+#if HAVE_RES_SEARCH && !(defined(__BEOS__)||defined(PHP_WIN32) || defined(NETWARE))
/* {{{ proto int checkdnsrr(string host [, string type])
Check DNS records corresponding to a given Internet host name or IP address */
diff --git a/ext/standard/file.c b/ext/standard/file.c
index 72b7317c20..b224bda44a 100644
--- a/ext/standard/file.c
+++ b/ext/standard/file.c
@@ -47,11 +47,19 @@
#define O_RDONLY _O_RDONLY
#include "win32/param.h"
#include "win32/winutil.h"
+#elif defined(NETWARE) && !defined(NEW_LIBC)
+/*#include <ws2nlm.h>*/
+#include <sys/socket.h>
+#include "netware/param.h"
#else
#include <sys/param.h>
+#if defined(NETWARE) && defined(USE_WINSOCK)
+#include <novsock2.h>
+#else
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
+#endif
#if HAVE_ARPA_INET_H
#include <arpa/inet.h>
#endif
@@ -63,6 +71,8 @@
#if HAVE_PWD_H
#ifdef PHP_WIN32
#include "win32/pwd.h"
+#elif defined(NETWARE)
+#include "netware/pwd.h"
#else
#include <pwd.h>
#endif
@@ -802,7 +812,7 @@ PHPAPI int php_set_sock_blocking(int socketd, int block)
int flags;
int myflag = 0;
-#ifdef PHP_WIN32
+#if defined(PHP_WIN32) || (defined(NETWARE) && defined(USE_WINSOCK))
/* with ioctlsocket, a non-zero sets nonblocking, a zero sets blocking */
flags = !block;
if (ioctlsocket(socketd, FIONBIO, &flags)==SOCKET_ERROR){
@@ -2187,7 +2197,7 @@ PHP_FUNCTION(fgetcsv)
/* }}} */
-#if (!defined(PHP_WIN32) && !defined(__BEOS__) && HAVE_REALPATH) || defined(ZTS)
+#if (!defined(PHP_WIN32) && !defined(__BEOS__) && !defined(NETWARE) && HAVE_REALPATH) || defined(ZTS)
/* {{{ proto string realpath(string path)
Return the resolved path */
PHP_FUNCTION(realpath)
diff --git a/ext/standard/filestat.c b/ext/standard/filestat.c
index c1e4c2138b..1516906b7c 100644
--- a/ext/standard/filestat.c
+++ b/ext/standard/filestat.c
@@ -54,6 +54,8 @@
#if HAVE_PWD_H
# ifdef PHP_WIN32
# include "win32/pwd.h"
+# elif defined(NETWARE)
+# include "netware/pwd.h"
# else
# include <pwd.h>
# endif
@@ -335,7 +337,7 @@ PHP_FUNCTION(disk_free_space)
Change file group */
PHP_FUNCTION(chgrp)
{
-#ifndef WINDOWS
+#if !defined(WINDOWS) && !defined(NETWARE) /* 'chgrp' is not available on NetWare also */
pval **filename, **group;
gid_t gid;
struct group *gr=NULL;
@@ -383,7 +385,7 @@ PHP_FUNCTION(chgrp)
Change file owner */
PHP_FUNCTION(chown)
{
-#ifndef WINDOWS
+#if !defined(WINDOWS) && !defined(NETWARE) /* 'chown' is not available on NetWare also */
pval **filename, **user;
int ret;
uid_t uid;
@@ -472,7 +474,12 @@ PHP_FUNCTION(touch)
{
pval **filename, **filetime, **fileatime;
int ret;
+#if defined(NETWARE) && defined(CLIB_STAT_PATCH)
+ struct stat_libc sb;
+#else
struct stat sb;
+#endif
+
FILE *file;
struct utimbuf newtimebuf;
struct utimbuf *newtime = NULL;
@@ -546,7 +553,11 @@ static void php_stat(const char *filename, php_stat_len filename_length, int typ
{
zval *stat_dev, *stat_ino, *stat_mode, *stat_nlink, *stat_uid, *stat_gid, *stat_rdev,
*stat_size, *stat_atime, *stat_mtime, *stat_ctime, *stat_blksize, *stat_blocks;
+#if (defined(NETWARE) && defined(CLIB_STAT_PATCH))
+ struct stat_libc *stat_sb;
+#else
struct stat *stat_sb;
+#endif
int rmask=S_IROTH, wmask=S_IWOTH, xmask=S_IXOTH; /* access rights defaults to other */
char *stat_sb_names[13]={"dev", "ino", "mode", "nlink", "uid", "gid", "rdev",
"size", "atime", "mtime", "ctime", "blksize", "blocks"};
@@ -559,7 +570,11 @@ static void php_stat(const char *filename, php_stat_len filename_length, int typ
RETURN_FALSE;
}
+#if (defined(NETWARE) && defined(CLIB_STAT_PATCH))
+ stat_sb = (struct stat_libc *)&BG(sb);
+#else
stat_sb = &BG(sb);
+#endif
if (!BG(CurrentStatFile) || strcmp(filename, BG(CurrentStatFile))) {
if (!BG(CurrentStatFile) || filename_length > BG(CurrentStatLength)) {
@@ -574,7 +589,12 @@ static void php_stat(const char *filename, php_stat_len filename_length, int typ
#if HAVE_SYMLINK
BG(lsb).st_mode = 0; /* mark lstat buf invalid */
#endif
+
+#if (defined(NETWARE) && defined(CLIB_STAT_PATCH))
+ if (VCWD_STAT(BG(CurrentStatFile), (struct stat_libc *)&BG(sb)) == -1) {
+#else
if (VCWD_STAT(BG(CurrentStatFile), &BG(sb)) == -1) {
+#endif
if (!IS_LINK_OPERATION(type) && (!IS_EXISTS_CHECK(type) || errno != ENOENT)) { /* fileexists() test must print no error */
php_error(E_WARNING, "stat failed for %s (errno=%d - %s)", BG(CurrentStatFile), errno, strerror(errno));
}
@@ -599,6 +619,7 @@ static void php_stat(const char *filename, php_stat_len filename_length, int typ
#endif
+#ifndef NETWARE
if (type >= FS_IS_W && type <= FS_IS_X) {
if(BG(sb).st_uid==getuid()) {
rmask=S_IRUSR;
@@ -628,6 +649,7 @@ static void php_stat(const char *filename, php_stat_len filename_length, int typ
}
}
}
+#endif /* NETWARE */
switch (type) {
case FS_PERMS:
@@ -641,11 +663,23 @@ static void php_stat(const char *filename, php_stat_len filename_length, int typ
case FS_GROUP:
RETURN_LONG((long)BG(sb).st_gid);
case FS_ATIME:
+#if defined(NETWARE) && defined(NEW_LIBC)
+ RETURN_LONG((long)((((struct stat_libc *)stat_sb)->st_atime).tv_sec));
+#else
RETURN_LONG((long)BG(sb).st_atime);
+#endif
case FS_MTIME:
+#if defined(NETWARE) && defined(NEW_LIBC)
+ RETURN_LONG((long)((((struct stat_libc *)stat_sb)->st_mtime).tv_sec));
+#else
RETURN_LONG((long)BG(sb).st_mtime);
+#endif
case FS_CTIME:
+#if defined(NETWARE) && defined(NEW_LIBC)
+ RETURN_LONG((long)((((struct stat_libc *)stat_sb)->st_ctime).tv_sec));
+#else
RETURN_LONG((long)BG(sb).st_ctime);
+#endif
case FS_TYPE:
#if HAVE_SYMLINK
if (S_ISLNK(BG(lsb).st_mode)) {
@@ -665,19 +699,25 @@ static void php_stat(const char *filename, php_stat_len filename_length, int typ
php_error(E_WARNING, "Unknown file type (%d)", BG(sb).st_mode&S_IFMT);
RETURN_STRING("unknown", 1);
case FS_IS_W:
+ #ifndef NETWARE /* getuid is not available on NetWare */
if (getuid()==0) {
RETURN_TRUE; /* root */
}
+ #endif /* NETWARE */
RETURN_BOOL((BG(sb).st_mode & wmask) != 0);
case FS_IS_R:
+ #ifndef NETWARE /* getuid is not available on NetWare */
if (getuid()==0) {
RETURN_TRUE; /* root */
}
+ #endif /* NETWARE */
RETURN_BOOL((BG(sb).st_mode&rmask)!=0);
case FS_IS_X:
+ #ifndef NETWARE /* getuid is not available on NetWare */
if (getuid()==0) {
xmask = S_IXROOT; /* root */
}
+ #endif /* NETWARE */
RETURN_BOOL((BG(sb).st_mode&xmask)!=0 && !S_ISDIR(BG(sb).st_mode));
case FS_IS_FILE:
RETURN_BOOL(S_ISREG(BG(sb).st_mode));
@@ -700,7 +740,42 @@ static void php_stat(const char *filename, php_stat_len filename_length, int typ
if (array_init(return_value) == FAILURE) {
RETURN_FALSE;
}
-
+
+#if defined(NETWARE) && defined(CLIB_STAT_PATCH)
+ MAKE_LONG_ZVAL_INCREF(stat_dev, ((struct stat_libc*)stat_sb)->st_dev);
+ MAKE_LONG_ZVAL_INCREF(stat_ino, ((struct stat_libc*)stat_sb)->st_ino);
+ MAKE_LONG_ZVAL_INCREF(stat_mode, ((struct stat_libc*)stat_sb)->st_mode);
+ MAKE_LONG_ZVAL_INCREF(stat_nlink, ((struct stat_libc*)stat_sb)->st_nlink);
+ MAKE_LONG_ZVAL_INCREF(stat_uid, ((struct stat_libc*)stat_sb)->st_uid);
+ MAKE_LONG_ZVAL_INCREF(stat_gid, ((struct stat_libc*)stat_sb)->st_gid);
+#ifdef HAVE_ST_RDEV
+ MAKE_LONG_ZVAL_INCREF(stat_rdev, ((struct stat_libc*)stat_sb)->st_rdev);
+#else
+ MAKE_LONG_ZVAL_INCREF(stat_rdev, -1);
+#endif
+ MAKE_LONG_ZVAL_INCREF(stat_size, ((struct stat_libc*)stat_sb)->st_size);
+#ifdef NEW_LIBC
+ MAKE_LONG_ZVAL_INCREF(stat_atime, (((struct stat_libc*)stat_sb)->st_atime).tv_sec);
+ MAKE_LONG_ZVAL_INCREF(stat_mtime, (((struct stat_libc*)stat_sb)->st_mtime).tv_sec);
+ MAKE_LONG_ZVAL_INCREF(stat_ctime, (((struct stat_libc*)stat_sb)->st_ctime).tv_sec);
+#else
+ MAKE_LONG_ZVAL_INCREF(stat_atime, ((struct stat_libc*)stat_sb)->st_atime);
+ MAKE_LONG_ZVAL_INCREF(stat_mtime, ((struct stat_libc*)stat_sb)->st_mtime);
+ MAKE_LONG_ZVAL_INCREF(stat_ctime, ((struct stat_libc*)stat_sb)->st_ctime);
+#endif
+#ifdef HAVE_ST_BLKSIZE
+ MAKE_LONG_ZVAL_INCREF(stat_blksize, ((struct stat_libc*)stat_sb)->st_blksize);
+#else
+ MAKE_LONG_ZVAL_INCREF(stat_blksize,-1);
+#endif
+#ifdef HAVE_ST_BLOCKS
+ MAKE_LONG_ZVAL_INCREF(stat_blocks, ((struct stat_libc*)stat_sb)->st_blocks);
+#else
+ MAKE_LONG_ZVAL_INCREF(stat_blocks,-1);
+#endif
+
+#else /* NETWARE && CLIB_STAT_PATCH */
+
MAKE_LONG_ZVAL_INCREF(stat_dev, stat_sb->st_dev);
MAKE_LONG_ZVAL_INCREF(stat_ino, stat_sb->st_ino);
MAKE_LONG_ZVAL_INCREF(stat_mode, stat_sb->st_mode);
@@ -726,6 +801,9 @@ static void php_stat(const char *filename, php_stat_len filename_length, int typ
#else
MAKE_LONG_ZVAL_INCREF(stat_blocks,-1);
#endif
+
+#endif /* NETWARE && CLIB_STAT_PATCH */
+
/* Store numeric indexes in propper order */
zend_hash_next_index_insert(HASH_OF(return_value), (void *)&stat_dev, sizeof(zval *), NULL);
zend_hash_next_index_insert(HASH_OF(return_value), (void *)&stat_ino, sizeof(zval *), NULL);
diff --git a/ext/standard/flock_compat.c b/ext/standard/flock_compat.c
index 7cec78dbe9..35f7ea411e 100644
--- a/ext/standard/flock_compat.c
+++ b/ext/standard/flock_compat.c
@@ -32,6 +32,14 @@
#include <io.h>
#endif
+#ifdef NETWARE
+#ifdef NEW_LIBC
+#include <netinet/in.h>
+#else
+#include <sys/socket.h>
+#endif
+#endif
+
#ifndef HAVE_FLOCK
int flock(int fd, int operation)
#if HAVE_STRUCT_FLOCK
diff --git a/ext/standard/fsock.c b/ext/standard/fsock.c
index 05a65b39b5..3c7b116f19 100644
--- a/ext/standard/fsock.c
+++ b/ext/standard/fsock.c
@@ -45,6 +45,19 @@
#endif
#ifdef PHP_WIN32
#include <winsock.h>
+#elif defined(NETWARE)
+#ifdef NEW_LIBC
+#ifdef USE_WINSOCK
+#include <novsock2.h>
+#else
+#include <netinet/in.h>
+#include <netdb.h>
+/*#include <sys/socket.h>*/
+#include <sys/select.h>
+/*#else
+#include <sys/socket.h>*/
+#endif
+#endif
#else
#include <netinet/in.h>
#include <netdb.h>
@@ -52,7 +65,7 @@
#include <arpa/inet.h>
#endif
#endif
-#if defined(PHP_WIN32) || defined(__riscos__)
+#if defined(PHP_WIN32) || defined(__riscos__) || defined(NETWARE)
#undef AF_UNIX
#endif
#if defined(AF_UNIX)
@@ -111,6 +124,10 @@ extern int le_fp;
#ifdef PHP_WIN32
#define EWOULDBLOCK WSAEWOULDBLOCK
+#elif defined(NETWARE)
+#ifdef USE_WINSOCK
+#define EWOULDBLOCK WSAEWOULDBLOCK
+#endif
#else
#include "build-defs.h"
#endif
@@ -320,7 +337,7 @@ PHPAPI void php_cleanup_sockbuf(int persistent TSRMLS_DC)
}
#define TOREAD(sock) ((sock)->writepos - (sock)->readpos)
-#define READPTR(sock) ((sock)->readbuf + (sock)->readpos)
+#define READPTR(sock) ((char *)(sock)->readbuf + (sock)->readpos) /* Type-casting done due to NetWare */
#define WRITEPTR(sock) ((sock)->readbuf + (sock)->writepos)
#define SOCK_FIND(sock, socket) \
php_sockbuf *sock; \
@@ -393,7 +410,7 @@ PHPAPI int php_sockdestroy(int socket)
return ret;
}
-#if !defined(PHP_WIN32)
+#if !defined(PHP_WIN32) && !(defined(NETWARE) && defined(USE_WINSOCK))
#undef closesocket
#define closesocket close
#endif
diff --git a/ext/standard/fsock.h b/ext/standard/fsock.h
index 13e5c5f196..1f52842119 100644
--- a/ext/standard/fsock.h
+++ b/ext/standard/fsock.h
@@ -25,6 +25,14 @@
#ifndef FSOCK_H
#define FSOCK_H
+#ifdef NETWARE
+#ifdef NEW_LIBC
+#include "sys/timeval.h"
+#else
+#include "netware/time_nw.h" /* For 'timeval' */
+#endif
+#endif
+
#include "file.h"
#define PHP_FSOCK_CHUNK_SIZE 8192
diff --git a/ext/standard/ftp_fopen_wrapper.c b/ext/standard/ftp_fopen_wrapper.c
index 98552e1143..1fd42e219f 100644
--- a/ext/standard/ftp_fopen_wrapper.c
+++ b/ext/standard/ftp_fopen_wrapper.c
@@ -35,6 +35,14 @@
#include <winsock.h>
#define O_RDONLY _O_RDONLY
#include "win32/param.h"
+#elif defined(NETWARE)
+/*#include <ws2nlm.h>*/
+/*#include <sys/socket.h>*/
+#ifdef NEW_LIBC
+#include <sys/param.h>
+#else
+#include "netware/param.h"
+#endif
#else
#include <sys/param.h>
#endif
@@ -48,6 +56,9 @@
#ifdef PHP_WIN32
#include <winsock.h>
+#elif defined(NETWARE) && defined(USE_WINSOCK)
+/*#include <ws2nlm.h>*/
+#include <novsock2.h>
#else
#include <netinet/in.h>
#include <netdb.h>
@@ -56,7 +67,7 @@
#endif
#endif
-#if defined(PHP_WIN32) || defined(__riscos__)
+#if defined(PHP_WIN32) || defined(__riscos__) || defined(NETWARE)
#undef AF_UNIX
#endif
diff --git a/ext/standard/head.c b/ext/standard/head.c
index e69905725a..3307202681 100644
--- a/ext/standard/head.c
+++ b/ext/standard/head.c
@@ -18,6 +18,11 @@
/* $Id$ */
#include <stdio.h>
+
+#if defined(NETWARE) && !defined(NEW_LIBC)
+#include <sys/socket.h>
+#endif
+
#include "php.h"
#include "ext/standard/php_standard.h"
#include "SAPI.h"
diff --git a/ext/standard/html.c b/ext/standard/html.c
index ebd4f0c538..43dfc540e5 100644
--- a/ext/standard/html.c
+++ b/ext/standard/html.c
@@ -451,8 +451,8 @@ PHPAPI char *php_escape_html_entities(unsigned char *old, int oldlen, int *newle
if (matches_map) {
new[len++] = '&';
- strcpy(new + len, rep);
- len += strlen(rep);
+ strcpy(new + len, (const char*)rep); /* Type-casting done due to NetWare */
+ len += strlen((const char*)rep); /* Type-casting done due to NetWare */
new[len++] = ';';
}
}
@@ -503,7 +503,7 @@ static void php_html_entities(INTERNAL_FUNCTION_PARAMETERS, int all)
return;
}
- new = php_escape_html_entities(str, str_len, &len, all, quote_style, hint_charset);
+ new = php_escape_html_entities((unsigned char*)str, str_len, &len, all, quote_style, hint_charset); /* Type-casting done due to NetWare */
RETVAL_STRINGL(new, len, 0);
}
/* }}} */
diff --git a/ext/standard/http_fopen_wrapper.c b/ext/standard/http_fopen_wrapper.c
index e71c524e70..c507e58bdf 100644
--- a/ext/standard/http_fopen_wrapper.c
+++ b/ext/standard/http_fopen_wrapper.c
@@ -35,6 +35,14 @@
#include <winsock.h>
#define O_RDONLY _O_RDONLY
#include "win32/param.h"
+#elif defined(NETWARE)
+/*#include <ws2nlm.h>*/
+/*#include <sys/socket.h>*/
+#ifdef NEW_LIBC
+#include <sys/param.h>
+#else
+#include "netware/param.h"
+#endif
#else
#include <sys/param.h>
#endif
@@ -48,6 +56,9 @@
#ifdef PHP_WIN32
#include <winsock.h>
+#elif defined(NETWARE) && defined(USE_WINSOCK)
+/*#include <ws2nlm.h>*/
+#include <novsock2.h>
#else
#include <netinet/in.h>
#include <netdb.h>
@@ -56,7 +67,7 @@
#endif
#endif
-#if defined(PHP_WIN32) || defined(__riscos__)
+#if defined(PHP_WIN32) || defined(__riscos__) || defined(NETWARE)
#undef AF_UNIX
#endif
diff --git a/ext/standard/image.c b/ext/standard/image.c
index de91aa3332..8d0d0705e1 100644
--- a/ext/standard/image.c
+++ b/ext/standard/image.c
@@ -39,6 +39,11 @@
#include "php.h"
#include <stdio.h>
+
+#if defined(NETWARE) && !defined(NEW_LIBC)
+#include <sys/socket.h>
+#endif
+
#if HAVE_FCNTL_H
#include <fcntl.h>
#endif
@@ -82,10 +87,10 @@ static struct gfxinfo *php_handle_gif (int socketd, FILE *fp, int issock)
FP_FREAD(temp, 3, socketd, fp, issock); /* fseek(fp, 6L, SEEK_SET); */
- FP_FREAD(a, sizeof(a), socketd, fp, issock); /* fread(a, sizeof(a), 1, fp); */
+ FP_FREAD((char*)a, sizeof(a), socketd, fp, issock); /* fread(a, sizeof(a), 1, fp); */ /* Type-casting done due to NetWare */
result->width = (unsigned short)a[0] | (((unsigned short)a[1])<<8);
- FP_FREAD(a, sizeof(a), socketd, fp, issock); /* fread(a, sizeof(a), 1, fp); */
+ FP_FREAD((char *)a, sizeof(a), socketd, fp, issock); /* fread(a, sizeof(a), 1, fp); */ /* Type-casting done due to NetWare */
result->height = (unsigned short)a[0] | (((unsigned short)a[1])<<8);
return result;
@@ -104,7 +109,7 @@ static struct gfxinfo *php_handle_psd (int socketd, FILE *fp, int issock)
result = (struct gfxinfo *) ecalloc(1, sizeof(struct gfxinfo));
FP_FREAD(temp, sizeof(temp), socketd, fp, issock);
- if((FP_FREAD(a, sizeof(a), socketd, fp, issock)) <= 0) {
+ if((FP_FREAD((char *)a, sizeof(a), socketd, fp, issock)) <= 0) { /* Type-casting done due to NetWare */
in_height = 0;
in_width = 0;
} else {
@@ -169,7 +174,7 @@ static struct gfxinfo *php_handle_swf (int socketd, FILE *fp, int issock)
result = (struct gfxinfo *) ecalloc (1, sizeof (struct gfxinfo));
FP_FREAD(temp, 5, socketd, fp, issock); /* fseek(fp, 8L, SEEK_SET); */
- FP_FREAD(a, sizeof(a), socketd, fp, issock); /* fread(a, sizeof(a), 1, fp); */
+ FP_FREAD((char *)a, sizeof(a), socketd, fp, issock); /* fread(a, sizeof(a), 1, fp); */ /* Type-casting done due to NetWare */
bits = php_swf_get_bits (a, 0, 5);
result->width = (php_swf_get_bits (a, 5 + bits, bits) -
php_swf_get_bits (a, 5, bits)) / 20;
@@ -192,7 +197,7 @@ static struct gfxinfo *php_handle_png (int socketd, FILE *fp, int issock)
FP_FREAD(temp, sizeof(temp), socketd, fp, issock); /* fseek(fp, 16L, SEEK_SET); */
- if((FP_FREAD(a, sizeof(a), socketd, fp, issock)) <= 0) {
+ if((FP_FREAD((char *)a, sizeof(a), socketd, fp, issock)) <= 0) { /* Type-casting done due to NetWare */
in_width = 0;
in_height = 0;
} else {
@@ -249,8 +254,7 @@ static unsigned short php_read2(int socketd, FILE *fp, int issock)
unsigned char a[2];
/* just return 0 if we hit the end-of-file */
- if((FP_FREAD(a, sizeof(a), socketd, fp, issock)) <= 0) return 0;
-
+ if((FP_FREAD((char *)a, sizeof(a), socketd, fp, issock)) <= 0) return 0; /* Type-casting done due to NetWare */
return (((unsigned short) a[ 0 ]) << 8) + ((unsigned short) a[ 1 ]);
}
/* }}} */
@@ -316,16 +320,16 @@ static void php_read_APP(int socketd, FILE *fp, int issock, unsigned int marker,
buffer = emalloc(length);
if ( !buffer) return;
- if (FP_FREAD(buffer, (long) length, socketd, fp, issock) <= 0) {
+ if (FP_FREAD((char *)buffer, (long) length, socketd, fp, issock) <= 0) { /* Type-casting done due to NetWare */
efree(buffer);
return;
}
- sprintf(markername, "APP%d", marker - M_APP0);
+ sprintf((char *)markername, "APP%d", marker - M_APP0); /* Type-casting done due to NetWare */
- if (zend_hash_find(Z_ARRVAL_P(info), markername, strlen(markername)+1, (void **) &tmp) == FAILURE) {
+ if (zend_hash_find(Z_ARRVAL_P(info), (char *)markername, strlen((char *)markername)+1, (void **) &tmp) == FAILURE) { /* Type-casting done due to NetWare */
/* XXX we onyl catch the 1st tag of it's kind! */
- add_assoc_stringl(info, markername, buffer, length, 1);
+ add_assoc_stringl(info, (char *)markername, (char *)buffer, length, 1); /* Type-casting done due to NetWare */
}
efree(buffer);
@@ -362,7 +366,7 @@ static struct gfxinfo *php_handle_jpeg (int socketd, FILE *fp, int issock, pval
result = (struct gfxinfo *) ecalloc(1, sizeof(struct gfxinfo));
length = php_read2(socketd, fp, issock);
result->bits = FP_FGETC(socketd, fp, issock);
- FP_FREAD(a, sizeof(a), socketd, fp, issock);
+ FP_FREAD((char *)a, sizeof(a), socketd, fp, issock); /* Type-casting done due to NetWare */
result->height = (((unsigned short) a[ 0 ]) << 8) + ((unsigned short) a[ 1 ]);
result->width = (((unsigned short) a[ 2 ]) << 8) + ((unsigned short) a[ 3 ]);
result->channels = FP_FGETC(socketd, fp, issock);
@@ -507,7 +511,7 @@ static struct gfxinfo *php_handle_tiff (int socketd, FILE *fp, int issock, pval
/* now we have the directory we can look how long it should be */
ifd_size = dir_size;
for(i=0;i<num_entries;i++) {
- dir_entry = ifd_data+2+i*12;
+ dir_entry = (unsigned char *)ifd_data+2+i*12; /* Type-casting done due to NetWare */
entry_tag = php_ifd_get16u(dir_entry+0, motorola_intel);
entry_type = php_ifd_get16u(dir_entry+2, motorola_intel);
entry_length = php_ifd_get32u(dir_entry+4, motorola_intel) * php_tiff_bytes_per_format[entry_type];
diff --git a/ext/standard/info.c b/ext/standard/info.c
index 026e00db87..eed3eea188 100644
--- a/ext/standard/info.c
+++ b/ext/standard/info.c
@@ -28,12 +28,16 @@
#include "SAPI.h"
#include <time.h>
#include "php_main.h"
-#if !defined(PHP_WIN32)
+#if !defined(PHP_WIN32) && !defined(NETWARE)
#include "build-defs.h"
#endif
#include "zend_globals.h" /* needs ELS */
#include "zend_highlight.h"
+/*#ifdef NETWARE*/
+/*#include "netware/env.h"*/ /* Temporary */
+/*#endif*/
+
#define SECTION(name) PUTS("<h2 align=\"center\">" name "</h2>\n")
PHPAPI extern char *php_ini_opened_path;
diff --git a/ext/standard/iptc.c b/ext/standard/iptc.c
index 616d1b0815..0e7fe06c4e 100644
--- a/ext/standard/iptc.c
+++ b/ext/standard/iptc.c
@@ -184,7 +184,11 @@ PHP_FUNCTION(iptcembed)
unsigned int marker;
unsigned int spool = 0, done = 0, inx, len;
unsigned char *spoolbuf=0, *poi=0;
+#if (defined(NETWARE) && defined(CLIB_STAT_PATCH))
+ struct stat_libc sb;
+#else
struct stat sb;
+#endif
switch(ZEND_NUM_ARGS()){
case 3:
@@ -222,9 +226,15 @@ PHP_FUNCTION(iptcembed)
len = Z_STRLEN_PP(iptcdata);
if (spool < 2) {
+#if (defined(NETWARE) && defined(CLIB_STAT_PATCH))
+ fstat(fileno(fp), ((struct stat*)&sb));
+
+ poi = spoolbuf = emalloc(len + sizeof(psheader) + ((struct stat*)&sb)->st_size + 1024);
+#else
fstat(fileno(fp), &sb);
poi = spoolbuf = emalloc(len + sizeof(psheader) + sb.st_size + 1024);
+#endif
if (! spoolbuf) {
fclose(fp);
@@ -293,7 +303,7 @@ PHP_FUNCTION(iptcembed)
fclose(fp);
if (spool < 2) {
- RETVAL_STRINGL(spoolbuf, poi - spoolbuf, 0);
+ RETVAL_STRINGL((char*)spoolbuf, poi - spoolbuf, 0); /* Type-casting done due to NetWare */
} else {
RETURN_TRUE;
}
@@ -317,7 +327,7 @@ PHP_FUNCTION(iptcparse)
inx = 0;
length = Z_STRLEN_PP(str);
- buffer = Z_STRVAL_PP(str);
+ buffer = (unsigned char *)Z_STRVAL_PP(str); /* Type-casting done due to NetWare */
inheader = 0; /* have we already found the IPTC-Header??? */
tagsfound = 0; /* number of tags already found */
@@ -350,7 +360,7 @@ PHP_FUNCTION(iptcparse)
inx += 2;
}
- sprintf(key, "%d#%03d", (unsigned int) dataset, (unsigned int) recnum);
+ sprintf((char*)key, "%d#%03d", (unsigned int) dataset, (unsigned int) recnum); /* Type-casting done due to NetWare */
if ((len > length) || (inx + len) > length)
break;
@@ -362,7 +372,7 @@ PHP_FUNCTION(iptcparse)
}
}
- if (zend_hash_find(Z_ARRVAL_P(return_value), key, strlen(key) + 1, (void **) &element) == FAILURE) {
+ if (zend_hash_find(Z_ARRVAL_P(return_value), (char*)key, strlen((char*)key) + 1, (void **) &element) == FAILURE) { /* Type-casting done due to NetWare */
ALLOC_ZVAL(values);
INIT_PZVAL(values);
if (array_init(values) == FAILURE) {
@@ -370,10 +380,10 @@ PHP_FUNCTION(iptcparse)
RETURN_FALSE;
}
- zend_hash_update(Z_ARRVAL_P(return_value), key, strlen(key)+1, (void *) &values, sizeof(pval*), (void **) &element);
- }
-
- add_next_index_stringl(*element, buffer+inx, len, 1);
+ zend_hash_update(Z_ARRVAL_P(return_value), (char*)key, strlen((char*)key)+1, (void *) &values, sizeof(pval*), (void **) &element); /* Type-casting done due to NetWare */
+ }
+
+ add_next_index_stringl(*element, (char*)(buffer+inx), len, 1); /* Type-casting done due to NetWare */
inx += len;
diff --git a/ext/standard/lcg.c b/ext/standard/lcg.c
index 2683c789ce..66a3254776 100644
--- a/ext/standard/lcg.c
+++ b/ext/standard/lcg.c
@@ -27,6 +27,12 @@
#ifdef PHP_WIN32
#include "win32/time.h"
+#elif defined(NETWARE)
+#ifdef NEW_LIBC
+#include <sys/timeval.h>
+#else
+#include "netware/time_nw.h"
+#endif
#else
#include <sys/time.h>
#endif
diff --git a/ext/standard/link.c b/ext/standard/link.c
index 23036067e7..b24e269596 100644
--- a/ext/standard/link.c
+++ b/ext/standard/link.c
@@ -33,6 +33,8 @@
#if HAVE_PWD_H
#ifdef PHP_WIN32
#include "win32/pwd.h"
+#elif defined(NETWARE)
+#include "netware/pwd.h"
#else
#include <pwd.h>
#endif
diff --git a/ext/standard/mail.c b/ext/standard/mail.c
index 41f79d28ac..74eeddb80d 100644
--- a/ext/standard/mail.c
+++ b/ext/standard/mail.c
@@ -23,7 +23,7 @@
#include <stdio.h>
#include "php.h"
#include "ext/standard/info.h"
-#if !defined(PHP_WIN32)
+#if !defined(PHP_WIN32) && !defined(NETWARE)
#include "build-defs.h"
#if HAVE_SYSEXITS_H
#include <sysexits.h>
@@ -42,6 +42,12 @@
#include "win32/sendmail.h"
#endif
+/* Additional headers for NetWare */
+#ifdef NETWARE
+#include "netware/pipe.h" /* For popen(), pclose() */
+#include "netware/sysexits.h" /* For exit status codes like EX_OK */
+#endif
+
/* {{{ proto int ezmlm_hash(string addr)
Calculate EZMLM list hash value. */
PHP_FUNCTION(ezmlm_hash)
@@ -128,7 +134,7 @@ PHP_FUNCTION(mail)
*/
PHPAPI int php_mail(char *to, char *subject, char *message, char *headers, char *extra_cmd)
{
-#ifdef PHP_WIN32
+#if (defined PHP_WIN32) || (defined NETWARE)
int tsm_err;
#endif
FILE *sendmail;
@@ -137,10 +143,10 @@ PHPAPI int php_mail(char *to, char *subject, char *message, char *headers, char
char *sendmail_cmd = NULL;
if (!sendmail_path) {
-#ifdef PHP_WIN32
+#if (defined PHP_WIN32) || (defined NETWARE)
/* handle old style win smtp sending */
if (TSendMail(INI_STR("SMTP"), &tsm_err, headers, subject, to, message) != SUCCESS){
- php_error(E_WARNING, GetSMErrorText(tsm_err));
+ php_error(E_WARNING, (const char *)GetSMErrorText(tsm_err)); /* Type-casting done due to NetWare */
return 0;
}
return 1;
diff --git a/ext/standard/math.c b/ext/standard/math.c
index eccf5ab5be..4c705f8d6c 100644
--- a/ext/standard/math.c
+++ b/ext/standard/math.c
@@ -314,7 +314,7 @@ PHP_FUNCTION(tanh)
/* }}} */
-#ifndef PHP_WIN32
+#if !defined(PHP_WIN32) && !defined(NETWARE)
/* {{{ proto float asinh(float number)
Returns the inverse hyperbolic sine of the number, i.e. the value whose hyperbolic sine is number */
@@ -471,7 +471,7 @@ PHP_FUNCTION(exp)
/* }}} */
-#ifndef PHP_WIN32
+#if !defined(PHP_WIN32) && !defined(NETWARE)
/* {{{ proto float expm1(float number)
Returns exp(number) - 1, computed in a way that accurate even when the value of number is close to zero */
diff --git a/ext/standard/md5.c b/ext/standard/md5.c
index 9021506003..e1eb2bab47 100644
--- a/ext/standard/md5.c
+++ b/ext/standard/md5.c
@@ -56,7 +56,7 @@ PHP_NAMED_FUNCTION(php_if_md5)
md5str[0] = '\0';
PHP_MD5Init(&context);
- PHP_MD5Update(&context, Z_STRVAL_PP(arg), Z_STRLEN_PP(arg));
+ PHP_MD5Update(&context, (const unsigned char*)Z_STRVAL_PP(arg), Z_STRLEN_PP(arg)); /* Type-casting done due to NetWare */
PHP_MD5Final(digest, &context);
make_digest(md5str, digest);
RETVAL_STRING(md5str, 1);
diff --git a/ext/standard/microtime.c b/ext/standard/microtime.c
index 5d6da7c2fa..05b8d7421c 100644
--- a/ext/standard/microtime.c
+++ b/ext/standard/microtime.c
@@ -25,6 +25,12 @@
#endif
#ifdef PHP_WIN32
#include "win32/time.h"
+#elif defined(NETWARE)
+#ifdef NEW_LIBC
+#include <sys/timeval.h>
+#else
+#include "netware/time_nw.h"
+#endif
#else
#include <sys/time.h>
#endif
diff --git a/ext/standard/pack.c b/ext/standard/pack.c
index 3d47e0609c..cd5b7eb8d4 100644
--- a/ext/standard/pack.c
+++ b/ext/standard/pack.c
@@ -30,6 +30,18 @@
#include <winsock.h>
#define O_RDONLY _O_RDONLY
#include "win32/param.h"
+#elif defined(NETWARE)
+#ifdef USE_WINSOCK
+/*#include <ws2nlm.h>*/
+#include <novsock2.h>
+#else
+#include <sys/socket.h>
+#endif
+#ifdef NEW_LIBC
+#include <sys/param.h>
+#else
+#include "netware/param.h"
+#endif
#else
#include <sys/param.h>
#endif
@@ -40,6 +52,8 @@
#if HAVE_PWD_H
#ifdef PHP_WIN32
#include "win32/pwd.h"
+#elif defined(NETWARE)
+#include "netware/pwd.h"
#else
#include <pwd.h>
#endif
diff --git a/ext/standard/pageinfo.c b/ext/standard/pageinfo.c
index e1ea9c54f2..32c5a51271 100644
--- a/ext/standard/pageinfo.c
+++ b/ext/standard/pageinfo.c
@@ -27,6 +27,11 @@
#if HAVE_PWD_H
#ifdef PHP_WIN32
#include "win32/pwd.h"
+#elif defined(NETWARE)
+#ifdef ZTS
+extern int basic_globals_id;
+#endif
+#include "netware/pwd.h"
#else
#include <pwd.h>
#endif
@@ -45,7 +50,11 @@
*/
PHPAPI void php_statpage(TSRMLS_D)
{
+#if (defined(NETWARE) && defined(CLIB_STAT_PATCH))
+ struct stat_libc *pstat;
+#else
struct stat *pstat;
+#endif
pstat = sapi_get_stat(TSRMLS_C);
@@ -54,7 +63,11 @@ PHPAPI void php_statpage(TSRMLS_D)
BG(page_uid) = pstat->st_uid;
BG(page_gid) = pstat->st_gid;
BG(page_inode) = pstat->st_ino;
+#if defined(NETWARE) && defined(NEW_LIBC)
+ BG(page_mtime) = (pstat->st_mtime).tv_nsec;
+#else
BG(page_mtime) = pstat->st_mtime;
+#endif
}
}
}
diff --git a/ext/standard/rand.c b/ext/standard/rand.c
index 3386eb6a6a..8be4ba2363 100644
--- a/ext/standard/rand.c
+++ b/ext/standard/rand.c
@@ -31,6 +31,10 @@
# include <windows.h>
#endif
+#if defined(NETWARE) && !defined(NEW_LIBC) /* For getpid() */
+#include "netware/pwd.h"
+#endif
+
#include "php.h"
#include "php_math.h"
#include "php_rand.h"
diff --git a/ext/standard/string.c b/ext/standard/string.c
index c6d9844ca3..51a8158a13 100644
--- a/ext/standard/string.c
+++ b/ext/standard/string.c
@@ -105,9 +105,9 @@ static char *php_bin2hex(const unsigned char *old, const size_t oldlen, size_t *
register unsigned char *result = NULL;
size_t i, j;
- result = (char *) emalloc(oldlen * 2 * sizeof(char) + 1);
+ result = (unsigned char*) emalloc(oldlen * 2 * sizeof(char) + 1); /* Type-casting done due to NetWare */
if(!result) {
- return result;
+ return (char*)result; /* Type-casting done due to NetWare */
}
for(i = j = 0; i < oldlen; i++) {
@@ -119,7 +119,7 @@ static char *php_bin2hex(const unsigned char *old, const size_t oldlen, size_t *
if (newlen)
*newlen = oldlen * 2 * sizeof(char);
- return result;
+ return (char *)result; /* Type-casting done due to NetWare */
}
/* }}} */
@@ -183,7 +183,7 @@ PHP_FUNCTION(bin2hex)
}
convert_to_string_ex(data);
- result = php_bin2hex(Z_STRVAL_PP(data), Z_STRLEN_PP(data), &newlen);
+ result = php_bin2hex((const unsigned char*)Z_STRVAL_PP(data), Z_STRLEN_PP(data), &newlen); /* Type-casting done due to NetWare */
if (!result) {
RETURN_FALSE;
@@ -514,9 +514,9 @@ PHPAPI void php_trim2(zval **str, zval **what, zval *return_value, int mode TSRM
char mask[256];
if (what) {
- php_charmask(Z_STRVAL_PP(what), Z_STRLEN_PP(what), mask TSRMLS_CC);
+ php_charmask((unsigned char*)Z_STRVAL_PP(what), Z_STRLEN_PP(what), mask TSRMLS_CC); /* Type-casting done due to NetWare */
} else {
- php_charmask(" \n\r\t\v\0", 6, mask TSRMLS_CC);
+ php_charmask((unsigned char*)" \n\r\t\v\0", 6, mask TSRMLS_CC); /* Type-casting done due to NetWare */
}
if (mode & 1) {
@@ -1238,9 +1238,9 @@ PHP_FUNCTION(pathinfo)
PHPAPI char *php_stristr(unsigned char *s, unsigned char *t,
size_t s_len, size_t t_len)
{
- php_strtolower(s, s_len);
- php_strtolower(t, t_len);
- return php_memnstr(s, t, t_len, s + s_len);
+ php_strtolower((char*)s, s_len); /* Type-casting done due to NetWare */
+ php_strtolower((char*)t, t_len); /* Type-casting done due to NetWare */
+ return php_memnstr((char*)s, (char*)t, t_len, (char*)(s + s_len)); /* Type-casting done due to NetWare */
}
/* }}} */
@@ -1313,7 +1313,7 @@ PHP_FUNCTION(stristr)
RETURN_FALSE;
}
- found = php_stristr(Z_STRVAL_PP(haystack), Z_STRVAL_PP(needle),
+ found = php_stristr((unsigned char*)Z_STRVAL_PP(haystack), (unsigned char*)Z_STRVAL_PP(needle), /* Type-casting done due to NetWare */
Z_STRLEN_PP(haystack), Z_STRLEN_PP(needle));
}
else {
@@ -1321,7 +1321,7 @@ PHP_FUNCTION(stristr)
needle_char[0] = (char) Z_LVAL_PP(needle);
needle_char[1] = 0;
- found = php_stristr(Z_STRVAL_PP(haystack), needle_char,
+ found = php_stristr((unsigned char*)Z_STRVAL_PP(haystack), (unsigned char*)needle_char, /* Type-casting done due to NetWare */
Z_STRLEN_PP(haystack), 1);
}
@@ -2367,7 +2367,7 @@ PHPAPI char *php_addcslashes(char *str, int length, int *new_length, int should_
length = strlen(str);
}
- php_charmask(what, wlength, flags TSRMLS_CC);
+ php_charmask((unsigned char*)what, wlength, flags TSRMLS_CC); /* Type-casting done due to NetWare */
for (source=str, end=source+length, target=new_str; (c=*source) || source<end; source++) {
if (flags[(unsigned char)c]) {
diff --git a/ext/standard/syslog.c b/ext/standard/syslog.c
index 05e74b0381..890361131d 100644
--- a/ext/standard/syslog.c
+++ b/ext/standard/syslog.c
@@ -75,7 +75,7 @@ PHP_MINIT_FUNCTION(syslog)
/* AIX doesn't have LOG_AUTHPRIV */
REGISTER_LONG_CONSTANT("LOG_AUTHPRIV", LOG_AUTHPRIV, CONST_CS | CONST_PERSISTENT);
#endif
-#if !defined(PHP_WIN32)
+#if !defined(PHP_WIN32) && !defined(NETWARE)
REGISTER_LONG_CONSTANT("LOG_LOCAL0", LOG_LOCAL0, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("LOG_LOCAL1", LOG_LOCAL1, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("LOG_LOCAL2", LOG_LOCAL2, CONST_CS | CONST_PERSISTENT);
@@ -159,7 +159,7 @@ static void start_syslog(TSRMLS_D)
/* AIX doesn't have LOG_AUTHPRIV */
SET_VAR_LONG("LOG_AUTHPRIV", LOG_AUTHPRIV);
#endif
-#if !defined(PHP_WIN32)
+#if !defined(PHP_WIN32) && !defined(NETWARE)
SET_VAR_LONG("LOG_LOCAL0", LOG_LOCAL0);
SET_VAR_LONG("LOG_LOCAL1", LOG_LOCAL1);
SET_VAR_LONG("LOG_LOCAL2", LOG_LOCAL2);
diff --git a/ext/standard/var_unserializer.c b/ext/standard/var_unserializer.c
index 63fc307b64..5fd2e284a8 100644
--- a/ext/standard/var_unserializer.c
+++ b/ext/standard/var_unserializer.c
@@ -217,7 +217,12 @@ static inline int object_common2(UNSERIALIZE_PARAMETER, int elements)
PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER)
{
+#ifndef NETWARE
const unsigned char *cursor, *limit, *marker, *start;
+#else
+ const char *cursor, *start;
+ const char *limit=NULL, *marker=NULL;
+#endif /* NETWARE */
zval **rval_ref;
cursor = *p;
diff --git a/ext/xml/expat/xmltok_impl.c b/ext/xml/expat/xmltok_impl.c
index 70131c0fcc..e1088957cd 100644
--- a/ext/xml/expat/xmltok_impl.c
+++ b/ext/xml/expat/xmltok_impl.c
@@ -3,6 +3,11 @@ Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
See the file COPYING for copying permission.
*/
+#ifdef NETWARE /* Check whether these two files are really required for NetWare */
+#include "xmltok.h"
+#include "xmltok_impl.h"
+#endif
+
#include "php_compat.h"
#ifndef IS_INVALID_CHAR
diff --git a/ext/xml/xml.c b/ext/xml/xml.c
index bb0bf5111e..a12c0ecdd5 100644
--- a/ext/xml/xml.c
+++ b/ext/xml/xml.c
@@ -35,7 +35,7 @@
#if HAVE_LIBEXPAT
-#ifndef PHP_WIN32
+#if !defined(PHP_WIN32) && !defined(NETWARE)
# include "build-defs.h"
# endif
# include "ext/standard/head.h"
diff --git a/main/SAPI.c b/main/SAPI.c
index d1d6a5b204..f8acf3ab08 100644
--- a/main/SAPI.c
+++ b/main/SAPI.c
@@ -683,10 +683,20 @@ SAPI_API int sapi_flush(TSRMLS_D)
}
}
+#if (defined(NETWARE) && defined(CLIB_STAT_PATCH))
+SAPI_API struct stat_libc *sapi_get_stat(TSRMLS_D)
+#else
SAPI_API struct stat *sapi_get_stat(TSRMLS_D)
+#endif
{
if (sapi_module.get_stat) {
+#if (defined(NETWARE) && defined(CLIB_STAT_PATCH))
+ /* This kind of type-casting is actually wrong;
+ but doing it for now since global_stat doesn't seem to be used anywhere particularly */
+ return ((struct stat_libc*)sapi_module.get_stat(TSRMLS_C));
+#else
return sapi_module.get_stat(TSRMLS_C);
+#endif
} else {
if (!SG(request_info).path_translated || (VCWD_STAT(SG(request_info).path_translated, &SG(global_stat))==-1)) {
return NULL;
diff --git a/main/SAPI.h b/main/SAPI.h
index 4f84b5f8d4..c747b5577a 100644
--- a/main/SAPI.h
+++ b/main/SAPI.h
@@ -111,7 +111,11 @@ typedef struct _sapi_globals_struct {
sapi_headers_struct sapi_headers;
int read_post_bytes;
unsigned char headers_sent;
+#if (defined(NETWARE) && defined(CLIB_STAT_PATCH))
+ struct stat_libc global_stat;
+#else
struct stat global_stat;
+#endif
char *default_mimetype;
char *default_charset;
HashTable *rfc1867_uploaded_files;
@@ -147,7 +151,11 @@ SAPI_API void sapi_unregister_post_entry(sapi_post_entry *post_entry);
SAPI_API int sapi_register_default_post_reader(void (*default_post_reader)(TSRMLS_D));
SAPI_API int sapi_flush(TSRMLS_D);
+#if (defined(NETWARE) && defined(CLIB_STAT_PATCH))
+SAPI_API struct stat_libc *sapi_get_stat(TSRMLS_D);
+#else
SAPI_API struct stat *sapi_get_stat(TSRMLS_D);
+#endif
SAPI_API char *sapi_getenv(char *name, size_t name_len TSRMLS_DC);
SAPI_API char *sapi_get_default_content_type(TSRMLS_D);
diff --git a/main/fopen_wrappers.c b/main/fopen_wrappers.c
index a71669aec9..6ba1a84513 100644
--- a/main/fopen_wrappers.c
+++ b/main/fopen_wrappers.c
@@ -36,7 +36,15 @@
#include <winsock.h>
#define O_RDONLY _O_RDONLY
#include "win32/param.h"
+#elif defined(NETWARE)
+/*#include <ws2nlm.h>*/
+/*#include <sys/socket.h>*/
+#ifdef NEW_LIBC
+#include <sys/param.h>
#else
+#include "netware/param.h"
+#endif
+#else /* NETWARE */
#include <sys/param.h>
#endif
@@ -49,6 +57,8 @@
#if HAVE_PWD_H
#ifdef PHP_WIN32
#include "win32/pwd.h"
+#elif defined(NETWARE)
+#include "netware/pwd.h"
#else
#include <pwd.h>
#endif
@@ -65,6 +75,9 @@
#ifdef PHP_WIN32
#include <winsock.h>
+#elif defined(NETWARE) && defined(USE_WINSOCK)
+/*#include <ws2nlm.h>*/
+#include <novsock2.h>
#else
#include <netinet/in.h>
#include <netdb.h>
@@ -73,7 +86,7 @@
#endif
#endif
-#if defined(PHP_WIN32) || defined(__riscos__)
+#if defined(PHP_WIN32) || defined(__riscos__) || defined(NETWARE)
#undef AF_UNIX
#endif
@@ -426,7 +439,11 @@ PHPAPI FILE *php_fopen_with_path(char *filename, char *mode, char *path, char **
char *pathbuf, *ptr, *end;
char *exec_fname;
char trypath[MAXPATHLEN];
+#if defined(NETWARE) && defined(CLIB_STAT_PATCH)
+ struct stat_libc sb;
+#else
struct stat sb;
+#endif
FILE *fp;
int path_length;
int filename_length;
diff --git a/main/main.c b/main/main.c
index 44e3e05bb3..654ad138a6 100644
--- a/main/main.c
+++ b/main/main.c
@@ -28,6 +28,18 @@
#include "win32/time.h"
#include "win32/signal.h"
#include <process.h>
+#elif defined(NETWARE)
+#ifdef NEW_LIBC
+#include <sys/timeval.h>
+#else
+#include "netware/time_nw.h"
+#endif
+/*#include "netware/signal_nw.h"*/
+/*#include "netware/env.h"*/ /* Temporary */
+/*#include <process.h>*/
+#ifdef USE_WINSOCK
+#include <novsock2.h>
+#endif
#else
#include "build-defs.h"
#endif
@@ -857,7 +869,7 @@ int php_module_startup(sapi_module_struct *sf)
php_core_globals *core_globals;
sapi_globals_struct *sapi_globals = ts_resource(sapi_globals_id);
#endif
-#ifdef PHP_WIN32
+#if defined(PHP_WIN32) || (defined(NETWARE) && (USE_WINSOCK))
WORD wVersionRequested = MAKEWORD(2, 0);
WSADATA wsaData;
#endif
@@ -923,7 +935,7 @@ int php_module_startup(sapi_module_struct *sf)
setlocale(LC_CTYPE, "");
#endif
-#ifdef PHP_WIN32
+#if defined(PHP_WIN32) || (defined(NETWARE) && (USE_WINSOCK))
/* start up winsock services */
if (WSAStartup(wVersionRequested, &wsaData) != 0) {
php_printf("\nwinsock.dll unusable. %d\n", WSAGetLastError());
@@ -1045,7 +1057,7 @@ void php_module_shutdown(TSRMLS_D)
return;
}
-#ifdef PHP_WIN32
+#if defined(PHP_WIN32) || (defined(NETWARE) && (USE_WINSOCK))
/*close winsock */
WSACleanup();
#endif
@@ -1421,7 +1433,7 @@ PHPAPI int php_handle_auth_data(const char *auth TSRMLS_DC)
char *pass;
char *user;
- user = php_base64_decode(auth + 6, strlen(auth) - 6, NULL);
+ user = (char*)php_base64_decode((const unsigned char*)auth + 6, strlen(auth) - 6, NULL); /* Type-casting done due to NetWare */
if (user) {
pass = strchr(user, ':');
if (pass) {
diff --git a/main/mergesort.c b/main/mergesort.c
index eaa6317c84..7ee4ee00ef 100644
--- a/main/mergesort.c
+++ b/main/mergesort.c
@@ -64,6 +64,11 @@ static char sccsid[] = "@(#)merge.c 8.2 (Berkeley) 2/14/94";
#include <winsock.h> /* Includes definition for u_char */
#endif
+#if defined(NETWARE) && !defined(NEW_LIBC)
+/*#include <ws2nlm.h>*/
+#include <sys/socket.h>
+#endif
+
static void setup(u_char *list1, u_char *list2, size_t n, size_t size, int (*cmp)(const void *, const void * TSRMLS_DC) TSRMLS_DC);
static void insertionsort(u_char *a, size_t n, size_t size, int (*cmp)(const void *, const void * TSRMLS_DC) TSRMLS_DC);
diff --git a/main/network.c b/main/network.c
index 6be650875a..b3615272f4 100644
--- a/main/network.c
+++ b/main/network.c
@@ -24,6 +24,13 @@
#include <winsock.h>
#define O_RDONLY _O_RDONLY
#include "win32/param.h"
+#elif defined(NETWARE)
+#ifdef NEW_LIBC
+#include <sys/timeval.h>
+#include <sys/param.h>
+#else
+#include "netware/time_nw.h"
+#endif
#else
#include <sys/param.h>
#endif
@@ -41,7 +48,21 @@
#include <sys/select.h>
#endif
-#ifndef PHP_WIN32
+/* Rearranging... */
+#if defined(NETWARE)
+#ifdef USE_WINSOCK
+/*#include <ws2nlm.h>*/
+#include <novsock2.h>
+#else
+/* New headers for socket stuff */
+#ifdef NEW_LIBC
+#include <netinet/in.h>
+#include <netdb.h>
+#include <sys/select.h>
+#endif
+#include <sys/socket.h>
+#endif
+#elif !defined(PHP_WIN32)
#include <netinet/in.h>
#include <netdb.h>
#if HAVE_ARPA_INET_H
@@ -49,13 +70,14 @@
#endif
#endif
+
#ifndef HAVE_INET_ATON
int inet_aton(const char *, struct in_addr *);
#endif
#include "php_network.h"
-#if defined(PHP_WIN32) || defined(__riscos__)
+#if defined(PHP_WIN32) || defined(__riscos__) || defined(NETWARE)
#undef AF_UNIX
#endif
diff --git a/main/php.h b/main/php.h
index e17d6d886a..21afbd7410 100644
--- a/main/php.h
+++ b/main/php.h
@@ -61,6 +61,13 @@
#define PHP_DIR_SEPARATOR '/'
#endif
+#ifdef NETWARE
+/*#include <utsname.h>*/
+#define PHP_UNAME "NetWare" /* For php_get_uname() function */
+#define PHP_OS PHP_UNAME /* This is obtained using 'uname' on Unix and assigned in the case of Windows.
+ For NetWare, we'll do it this way atleast for now */
+#endif
+
#include "php_regex.h"
@@ -171,6 +178,13 @@ char *strerror(int);
# ifdef PHP_WIN32
#include "win32/pwd.h"
#include "win32/param.h"
+#elif defined(NETWARE)
+#ifdef NEW_LIBC
+#include <sys/param.h>
+#else
+#include "NetWare/param.h"
+#endif
+#include "NetWare/pwd.h"
# else
#include <pwd.h>
#include <sys/param.h>
@@ -212,7 +226,17 @@ char *strerror(int);
extern pval *data;
#if !defined(PHP_WIN32)
extern char **environ;
+#ifdef NETWARE
+#ifdef NEW_LIBC
+/*#undef environ*/ /* For now, so that our 'environ' implementation is used */
#define php_sleep sleep
+#else
+#define php_sleep delay /* sleep() and usleep() are not available */
+#define usleep delay
+#endif
+#else
+#define php_sleep sleep
+#endif
#endif
#ifdef PHP_PWRITE_64
@@ -291,7 +315,7 @@ PHPAPI int cfg_get_string(char *varname, char **result);
#include "main/php_output.h"
#define PHPWRITE(str, str_len) php_body_write((str), (str_len) TSRMLS_CC)
#define PUTS(str) php_body_write((str), strlen((str)) TSRMLS_CC)
-#define PUTC(c) (php_body_write(&(c), 1 TSRMLS_CC), (c))
+#define PUTC(c) (php_body_write((const char*)(&(c)), 1 TSRMLS_CC), (c)) /* Type-casting done due to NetWare */
#define PHPWRITE_H(str, str_len) php_header_write((str), (str_len) TSRMLS_CC)
#define PUTS_H(str) php_header_write((str), strlen((str)) TSRMLS_CC)
#define PUTC_H(c) (php_header_write(&(c), 1 TSRMLS_CC), (c))
diff --git a/main/php_compat.h b/main/php_compat.h
index 7c9a16480c..0cc54442bc 100644
--- a/main/php_compat.h
+++ b/main/php_compat.h
@@ -3,6 +3,8 @@
#ifdef PHP_WIN32
#include "config.w32.h"
+#elif defined(NETWARE)
+# include "config.nw.h"
#else
#include "php_config.h"
#endif
diff --git a/main/php_ini.c b/main/php_ini.c
index ba24ea260b..8fd18666d3 100644
--- a/main/php_ini.c
+++ b/main/php_ini.c
@@ -19,7 +19,7 @@
/* $Id$ */
#include "php.h"
-#ifndef PHP_WIN32
+#if !defined(PHP_WIN32) && !defined(NETWARE)
#include "build-defs.h"
#endif
#include "ext/standard/info.h"
diff --git a/main/php_logos.c b/main/php_logos.c
index e93fa4abfe..5e875523be 100644
--- a/main/php_logos.c
+++ b/main/php_logos.c
@@ -84,7 +84,7 @@ int php_info_logos(const char *logo_string TSRMLS_DC)
sapi_add_header(content_header, len, 1);
free(content_header);
- PHPWRITE(logo_image->data, logo_image->size);
+ PHPWRITE((const char*)logo_image->data, logo_image->size); /* Type-casting done due to NetWare */
return 1;
}
diff --git a/main/php_open_temporary_file.c b/main/php_open_temporary_file.c
index 258e920a4f..cdfe13be22 100644
--- a/main/php_open_temporary_file.c
+++ b/main/php_open_temporary_file.c
@@ -29,6 +29,19 @@
#define O_RDONLY _O_RDONLY
#include "win32/param.h"
#include "win32/winutil.h"
+#elif defined(NETWARE)
+#ifdef USE_WINSOCK
+/*#include <ws2nlm.h>*/
+#include <novsock2.h>
+#else
+#include <sys/socket.h>
+#endif
+#ifdef NEW_LIBC
+#include <sys/param.h>
+#else
+#include "netware/param.h"
+#endif
+#include "netware/mktemp.h"
#else
#include <sys/param.h>
#include <sys/socket.h>
@@ -95,6 +108,9 @@ static FILE *php_do_open_temporary_file(char *path, const char *pfx, char **open
#ifndef PHP_WIN32
int fd;
#endif
+#ifdef NETWARE
+ char *file_path = NULL;
+#endif
if (!path) {
return NULL;
@@ -118,6 +134,14 @@ static FILE *php_do_open_temporary_file(char *path, const char *pfx, char **open
} else {
fp = NULL;
}
+#elif defined(NETWARE)
+ /* Using standard mktemp() implementation for NetWare */
+ file_path = mktemp(opened_path);
+ if (file_path) {
+ fp = VCWD_FOPEN(file_path, "wb");
+ } else {
+ fp = NULL;
+ }
#elif defined(HAVE_MKSTEMP)
fd = mkstemp(opened_path);
if (fd==-1) {
diff --git a/main/php_sprintf.c b/main/php_sprintf.c
index 1b8e516d44..a29925a099 100644
--- a/main/php_sprintf.c
+++ b/main/php_sprintf.c
@@ -20,7 +20,11 @@
#include <stdio.h>
#include <stdarg.h>
+#ifndef NETWARE
#include "php_config.h"
+#else
+#include "config.nw.h"
+#endif
#if PHP_BROKEN_SPRINTF
diff --git a/main/php_syslog.h b/main/php_syslog.h
index 279da71c92..92b09800fb 100644
--- a/main/php_syslog.h
+++ b/main/php_syslog.h
@@ -3,6 +3,11 @@
#ifdef PHP_WIN32
#include "win32/syslog.h"
+#elif defined(NETWARE)
+# include "config.nw.h"
+#ifdef HAVE_SYSLOG_H
+#include <syslog.h>
+#endif
#else
#include "php_config.h"
#ifdef HAVE_SYSLOG_H
diff --git a/main/reentrancy.c b/main/reentrancy.c
index d5f4909760..b992c310da 100644
--- a/main/reentrancy.c
+++ b/main/reentrancy.c
@@ -28,6 +28,11 @@
#include "win32/readdir.h"
#endif
+#if defined(NETWARE) && !defined(NEW_LIBC)
+/*#include <ws2nlm.h>*/
+#include <sys/socket.h>
+#endif
+
#include "php_reentrancy.h"
#include "ext/standard/php_rand.h" /* for RAND_MAX */
@@ -114,6 +119,51 @@ PHPAPI struct tm *php_gmtime_r(const time_t *const timep, struct tm *p_tm)
#endif
+/*
+ Re-entrant versions of functions seem to be better for loading NLMs in different address space.
+ Since we have them now in LibC, we might as well make use of them.
+*/
+#if defined(NETWARE)
+
+#define HAVE_LOCALTIME_R 1
+#define HAVE_CTIME_R 1
+#define HAVE_ASCTIME_R 1
+#define HAVE_GMTIME_R 1
+
+PHPAPI struct tm *php_localtime_r(const time_t *const timep, struct tm *p_tm)
+{
+ /* Modified according to LibC definition : Venkat (1/5/02) */
+ if (localtime_r(timep, p_tm) != NULL)
+ return (p_tm);
+ return (NULL);
+}
+
+PHPAPI char *php_ctime_r(const time_t *clock, char *buf)
+{
+ /* Modified according to LibC definition : Venkat (30/4/02) */
+ if (ctime_r(clock, buf) != NULL)
+ return (buf);
+ return (NULL);
+}
+
+PHPAPI char *php_asctime_r(const struct tm *tm, char *buf)
+{
+ /* Modified according to LibC definition : Venkat (30/4/02) */
+ if (asctime_r(tm, buf) != NULL)
+ return (buf);
+ return (NULL);
+}
+
+PHPAPI struct tm *php_gmtime_r(const time_t *const timep, struct tm *p_tm)
+{
+ /* Modified according to LibC definition : Venkat (1/5/02) */
+ if (gmtime_r(timep, p_tm) != NULL)
+ return (p_tm);
+ return (NULL);
+}
+
+#endif /* NETWARE */
+
#if !defined(HAVE_POSIX_READDIR_R)
PHPAPI int php_readdir_r(DIR *dirp, struct dirent *entry,
diff --git a/main/safe_mode.c b/main/safe_mode.c
index d3ffab6a3f..a213730e29 100644
--- a/main/safe_mode.c
+++ b/main/safe_mode.c
@@ -45,7 +45,11 @@
PHPAPI int php_checkuid(const char *filename, char *fopen_mode, int mode)
{
+#if (defined(NETWARE) && defined(CLIB_STAT_PATCH))
+ struct stat_libc sb;
+#else
struct stat sb;
+#endif
int ret, nofile=0;
long uid=0L, gid=0L, duid=0L, dgid=0L;
char path[MAXPATHLEN];
@@ -170,7 +174,11 @@ PHPAPI int php_checkuid(const char *filename, char *fopen_mode, int mode)
PHPAPI char *php_get_current_user()
{
struct passwd *pwd;
+#if (defined(NETWARE) && defined(CLIB_STAT_PATCH))
+ struct stat_libc *pstat;
+#else
struct stat *pstat;
+#endif
TSRMLS_FETCH();
if (SG(request_info).current_user) {
@@ -181,7 +189,11 @@ PHPAPI char *php_get_current_user()
USE_SAPI is defined, because cgi will also be
interfaced in USE_SAPI */
+#if (defined(NETWARE) && defined(CLIB_STAT_PATCH))
+ pstat = (struct stat_libc *)sapi_get_stat(TSRMLS_C);
+#else
pstat = sapi_get_stat(TSRMLS_C);
+#endif
if (!pstat) {
return empty_string;
diff --git a/sapi/apache/mod_php4.c b/sapi/apache/mod_php4.c
index d0806e641b..6044147bcb 100644
--- a/sapi/apache/mod_php4.c
+++ b/sapi/apache/mod_php4.c
@@ -25,6 +25,18 @@
#include <stddef.h>
#endif
+#ifdef NETWARE
+#define SIGPIPE SIGINT
+#ifdef NEW_LIBC /* Works fine for both Winsock and Berkeley sockets */
+#include <netinet/in.h>
+#else /* NEW_LIBC */
+#include <sys/socket.h>
+#endif /* NEW_LIBC */
+/* Security related functions: Using the dynamically exported functions */
+extern int NWSECInitializeSession(unsigned int ScriptLangType, unsigned int ExecutionMode, char *pszPublicDocDir);
+extern int NWSECTerminateSession();
+#endif /* NETWARE */
+
#include "zend.h"
#include "php.h"
#include "php_variables.h"
@@ -127,13 +139,20 @@ void php_save_umask(void)
static int sapi_apache_ub_write(const char *str, uint str_length TSRMLS_DC)
{
int ret=0;
-
+
+#if defined(NETWARE) && defined(NETWARE_CLIB_BROKER)
+ EnterClib();
+#endif
+
if (SG(server_context)) {
ret = rwrite(str, str_length, (request_rec *) SG(server_context));
}
if (ret != str_length) {
php_handle_aborted_connection();
}
+#if defined(NETWARE) && defined(NETWARE_CLIB_BROKER)
+ ExitClib();
+#endif
return ret;
}
/* }}} */
@@ -142,6 +161,9 @@ static int sapi_apache_ub_write(const char *str, uint str_length TSRMLS_DC)
*/
static void sapi_apache_flush(void *server_context)
{
+#if defined(NETWARE) && defined(NETWARE_CLIB_BROKER)
+ EnterClib();
+#endif
if (server_context) {
#if MODULE_MAGIC_NUMBER > 19970110
rflush((request_rec *) server_context);
@@ -149,6 +171,9 @@ static void sapi_apache_flush(void *server_context)
bflush((request_rec *) server_context->connection->client);
#endif
}
+#if defined(NETWARE) && defined(NETWARE_CLIB_BROKER)
+ ExitClib();
+#endif
}
/* }}} */
@@ -160,7 +185,13 @@ int sapi_apache_read_post(char *buffer, uint count_bytes TSRMLS_DC)
request_rec *r = (request_rec *) SG(server_context);
void (*handler)(int);
+#if defined(NETWARE) && defined(NETWARE_CLIB_BROKER)
+ EnterClib();
+#endif
+
+#ifndef NETWARE
handler = signal(SIGPIPE, SIG_IGN);
+#endif
while (total_read_bytes<count_bytes) {
hard_timeout("Read POST information", r); /* start timeout timer */
read_bytes = get_client_block(r, buffer+total_read_bytes, count_bytes-total_read_bytes);
@@ -170,7 +201,12 @@ int sapi_apache_read_post(char *buffer, uint count_bytes TSRMLS_DC)
}
total_read_bytes += read_bytes;
}
- signal(SIGPIPE, handler);
+#ifndef NETWARE
+ signal(SIGPIPE, handler);
+#endif
+#if defined(NETWARE) && defined(NETWARE_CLIB_BROKER)
+ ExitClib();
+#endif
return total_read_bytes;
}
/* }}} */
@@ -179,7 +215,17 @@ int sapi_apache_read_post(char *buffer, uint count_bytes TSRMLS_DC)
*/
char *sapi_apache_read_cookies(TSRMLS_D)
{
+#if !(defined(NETWARE) && defined(NETWARE_CLIB_BROKER))
return (char *) table_get(((request_rec *) SG(server_context))->subprocess_env, "HTTP_COOKIE");
+#else
+ char *temp;
+
+ EnterClib();
+ temp = (char *) table_get(((request_rec *) SG(server_context))->subprocess_env, "HTTP_COOKIE");
+ ExitClib();
+
+ return temp;
+#endif
}
/* }}} */
@@ -202,6 +248,9 @@ int sapi_apache_header_handler(sapi_header_struct *sapi_header, sapi_headers_str
header_content++;
} while (*header_content==' ');
+#if defined(NETWARE) && defined(NETWARE_CLIB_BROKER)
+ EnterClib();
+#endif
if (!strcasecmp(header_name, "Content-Type")) {
r->content_type = pstrdup(r->pool, header_content);
} else if (!strcasecmp(header_name, "Set-Cookie")) {
@@ -214,6 +263,9 @@ int sapi_apache_header_handler(sapi_header_struct *sapi_header, sapi_headers_str
efree(sapi_header->header);
+#if defined(NETWARE) && defined(NETWARE_CLIB_BROKER)
+ ExitClib();
+#endif
return 0; /* don't use the default SAPI mechanism, Apache duplicates this functionality */
}
/* }}} */
@@ -226,8 +278,14 @@ int sapi_apache_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC)
return SAPI_HEADER_SEND_FAILED;
}
+#if defined(NETWARE) && defined(NETWARE_CLIB_BROKER)
+ EnterClib();
+#endif
((request_rec *) SG(server_context))->status = SG(sapi_headers).http_response_code;
send_http_header((request_rec *) SG(server_context));
+#if defined(NETWARE) && defined(NETWARE_CLIB_BROKER)
+ ExitClib();
+#endif
return SAPI_HEADER_SENT_SUCCESSFULLY;
}
/* }}} */
@@ -242,6 +300,9 @@ static void sapi_apache_register_server_variables(zval *track_vars_array TSRMLS_
zval **path_translated;
HashTable *symbol_table;
+#if defined(NETWARE) && defined(NETWARE_CLIB_BROKER)
+ EnterClib();
+#endif
for (i = 0; i < arr->nelts; i++) {
char *val;
@@ -269,6 +330,9 @@ static void sapi_apache_register_server_variables(zval *track_vars_array TSRMLS_
}
php_register_variable("PHP_SELF", ((request_rec *) SG(server_context))->uri, track_vars_array TSRMLS_CC);
+#if defined(NETWARE) && defined(NETWARE_CLIB_BROKER)
+ ExitClib();
+#endif
}
/* }}} */
@@ -291,6 +355,9 @@ static void php_apache_log_message(char *message)
{
TSRMLS_FETCH();
+#if defined(NETWARE) && defined(NETWARE_CLIB_BROKER)
+ EnterClib();
+#endif
if (SG(server_context)) {
#if MODULE_MAGIC_NUMBER >= 19970831
aplog_error(NULL, 0, APLOG_ERR | APLOG_NOERRNO, ((request_rec *) SG(server_context))->server, "%s", message);
@@ -301,6 +368,9 @@ static void php_apache_log_message(char *message)
fprintf(stderr, "%s", message);
fprintf(stderr, "\n");
}
+#if defined(NETWARE) && defined(NETWARE_CLIB_BROKER)
+ ExitClib();
+#endif
}
/* }}} */
@@ -310,12 +380,18 @@ static void php_apache_request_shutdown(void *dummy)
{
TSRMLS_FETCH();
+#if defined(NETWARE) && defined(NETWARE_CLIB_BROKER)
+ EnterClib();
+#endif
php_output_set_status(0 TSRMLS_CC);
SG(server_context) = NULL; /* The server context (request) is invalid by the time run_cleanups() is called */
if (AP(in_request)) {
AP(in_request) = 0;
php_request_shutdown(dummy);
}
+#if defined(NETWARE) && defined(NETWARE_CLIB_BROKER)
+ ExitClib();
+#endif
}
/* }}} */
@@ -325,6 +401,9 @@ static int php_apache_sapi_activate(TSRMLS_D)
{
request_rec *r = (request_rec *) SG(server_context);
+#if defined(NETWARE) && defined(NETWARE_CLIB_BROKER)
+ EnterClib();
+#endif
/*
* For the Apache module version, this bit of code registers a cleanup
* function that gets triggered when our request pool is destroyed.
@@ -342,6 +421,9 @@ static int php_apache_sapi_activate(TSRMLS_D)
* send headers.
*/
SG(request_info).headers_only = r->header_only;
+#if defined(NETWARE) && defined(NETWARE_CLIB_BROKER)
+ ExitClib();
+#endif
return SUCCESS;
}
/* }}} */
@@ -422,6 +504,9 @@ static void init_request_info(TSRMLS_D)
const char *authorization=NULL;
char *tmp;
+#if defined(NETWARE) && defined(NETWARE_CLIB_BROKER)
+ EnterClib();
+#endif
SG(request_info).query_string = r->args;
SG(request_info).path_translated = r->filename;
SG(request_info).request_uri = r->uri;
@@ -451,6 +536,9 @@ static void init_request_info(TSRMLS_D)
SG(request_info).auth_user = NULL;
SG(request_info).auth_password = NULL;
}
+#if defined(NETWARE) && defined(NETWARE_CLIB_BROKER)
+ ExitClib();
+#endif
}
/* }}} */
@@ -491,6 +579,9 @@ static int send_php(request_rec *r, int display_source_mode, char *filename)
HashTable *per_dir_conf;
TSRMLS_FETCH();
+#if defined(NETWARE) && defined(NETWARE_CLIB_BROKER)
+ EnterClib();
+#endif
if (AP(in_request)) {
zend_file_handle fh;
@@ -499,9 +590,15 @@ static int send_php(request_rec *r, int display_source_mode, char *filename)
fh.free_filename = 0;
fh.type = ZEND_HANDLE_FILENAME;
zend_execute_scripts(ZEND_INCLUDE TSRMLS_CC, NULL, 1, &fh);
+#if defined(NETWARE) && defined(NETWARE_CLIB_BROKER)
+ ExitClib();
+#endif
return OK;
}
+#if defined(NETWARE) && defined(NETWARE_CLIB_BROKER)
+ ExitClib();
+#endif
zend_first_try {
/* We don't accept OPTIONS requests, but take everything else */
if (r->method_number == M_OPTIONS) {
@@ -514,6 +611,9 @@ static int send_php(request_rec *r, int display_source_mode, char *filename)
return DECLINED;
}
+#if defined(NETWARE) && defined(NETWARE_CLIB_BROKER)
+ EnterClib();
+#endif
per_dir_conf = (HashTable *) get_module_config(r->per_dir_config, &php4_module);
if (per_dir_conf) {
zend_hash_apply((HashTable *) per_dir_conf, (apply_func_t) php_apache_alter_ini_entries TSRMLS_CC);
@@ -528,6 +628,9 @@ static int send_php(request_rec *r, int display_source_mode, char *filename)
zend_try {
zend_ini_deactivate(TSRMLS_C);
} zend_end_try();
+#if defined(NETWARE) && defined(NETWARE_CLIB_BROKER)
+ ExitClib();
+#endif
return DECLINED;
}
if (filename == NULL) {
@@ -540,6 +643,9 @@ static int send_php(request_rec *r, int display_source_mode, char *filename)
zend_try {
zend_ini_deactivate(TSRMLS_C);
} zend_end_try();
+#if defined(NETWARE) && defined(NETWARE_CLIB_BROKER)
+ ExitClib();
+#endif
return retval;
}
#endif
@@ -550,6 +656,9 @@ static int send_php(request_rec *r, int display_source_mode, char *filename)
zend_try {
zend_ini_deactivate(TSRMLS_C);
} zend_end_try();
+#if defined(NETWARE) && defined(NETWARE_CLIB_BROKER)
+ ExitClib();
+#endif
return retval;
}
#else
@@ -579,6 +688,9 @@ static int send_php(request_rec *r, int display_source_mode, char *filename)
kill_timeout(r);
} zend_end_try();
+#if defined(NETWARE) && defined(NETWARE_CLIB_BROKER)
+ ExitClib();
+#endif
return OK;
}
/* }}} */
@@ -587,8 +699,24 @@ static int send_php(request_rec *r, int display_source_mode, char *filename)
*/
static int send_parsed_php(request_rec * r)
{
+#ifndef NETWARE
int result = send_php(r, 0, NULL);
+#else
+ int result;
+
+ /* Security changes */
+ /* 102 is used for PHP Scripts */
+ NWSECInitializeSession(102, 1, NULL);
+
+ result = send_php(r, 0, NULL);
+ /* Security changes */
+ NWSECTerminateSession();
+#endif
+
+#if defined(NETWARE) && defined(NETWARE_CLIB_BROKER)
+ EnterClib();
+#endif
#if MEMORY_LIMIT
{
char *mem_usage;
@@ -600,6 +728,9 @@ static int send_parsed_php(request_rec * r)
}
#endif
+#if defined(NETWARE) && defined(NETWARE_CLIB_BROKER)
+ ExitClib();
+#endif
return result;
}
/* }}} */
@@ -665,10 +796,16 @@ static void *php_create_dir(pool *p, char *dummy)
{
HashTable *per_dir_info;
+#if defined(NETWARE) && defined(NETWARE_CLIB_BROKER)
+ EnterClib();
+#endif
per_dir_info = (HashTable *) malloc(sizeof(HashTable));
zend_hash_init_ex(per_dir_info, 5, NULL, (void (*)(void *)) destroy_per_dir_entry, 1, 0);
register_cleanup(p, (void *) per_dir_info, (void (*)(void *)) php_destroy_per_dir_info, (void (*)(void *)) zend_hash_destroy);
+#if defined(NETWARE) && defined(NETWARE_CLIB_BROKER)
+ ExitClib();
+#endif
return per_dir_info;
}
/* }}} */