]> granicus.if.org Git - php/commitdiff
NetWare related additions/modifications
authorAnantha Kesari H Y <hyanantha@php.net>
Thu, 5 Sep 2002 14:25:07 +0000 (14:25 +0000)
committerAnantha Kesari H Y <hyanantha@php.net>
Thu, 5 Sep 2002 14:25:07 +0000 (14:25 +0000)
ext/standard/dl.c
ext/standard/dns.c
ext/standard/file.c
ext/standard/filestat.c
ext/standard/flock_compat.c
ext/standard/fsock.c
ext/standard/fsock.h
ext/standard/ftp_fopen_wrapper.c
ext/standard/head.c
ext/standard/http_fopen_wrapper.c
main/php_streams.h

index 07613a1ad2a926707ea0b629fa2bd7b00cf9fc1c..af4879cc64b6063870bbca2efdd69801d14b36f8 100644 (file)
@@ -26,7 +26,8 @@
 #include "ext/standard/info.h"
 #include "SAPI.h"
 
-#ifndef PHP_WIN32
+/*#ifndef PHP_WIN32*/
+#if !defined(PHP_WIN32) && !defined(NETWARE)
 #include "build-defs.h"
 #endif
 
@@ -34,7 +35,8 @@
 #include <stdlib.h>
 #include <stdio.h>
 
-#if HAVE_STRING_H
+/*#if HAVE_STRING_H*/
+#ifdef HAVE_STRING_H
 #include <string.h>
 #else
 #include <strings.h>
 #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() DL_ERROR()
@@ -141,7 +150,7 @@ void php_dl(pval *file, int type, pval *return_value TSRMLS_DC)
 
        efree(libpath);
 
-       
+#ifndef NETWARE
        get_module = (zend_module_entry *(*)(void)) DL_FETCH_SYMBOL(handle, "get_module");
 
        /*
@@ -152,6 +161,23 @@ 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");
+#else  
+       /* 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 the corresponding portion of code is also
+          not required for NetWare */
+#endif
 
        if (!get_module) {
                DL_UNLOAD(handle);
index 261a5e7c4cca4c70d71f065f6ef5080811bb3116..221c8afeb49c739076718ba8a1650b8ed576edae 100644 (file)
@@ -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>
 #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 */
index 84cc8020e70c3711a975d6b6496b77dab8175951..b55900aeb1cca538c838dde8c423438c488c42b4 100644 (file)
 #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
@@ -2114,7 +2124,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)
index 119773553f2f32bddcfbea9bd6412cca8c97b662..65dde0cfaa577f899d8dab44dcb51db1ab247da4 100644 (file)
@@ -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,8 @@ PHP_FUNCTION(disk_free_space)
    Change file group */
 PHP_FUNCTION(chgrp)
 {
-#ifndef WINDOWS
+/*#ifndef WINDOWS*/
+#if !defined(WINDOWS) && !defined(NETWARE)  /* I guess 'chgrp' won't be available on NetWare */
        pval **filename, **group;
        gid_t gid;
        struct group *gr=NULL;
@@ -383,7 +386,8 @@ PHP_FUNCTION(chgrp)
    Change file owner */
 PHP_FUNCTION(chown)
 {
-#ifndef WINDOWS
+/*#ifndef WINDOWS*/
+#if !defined(WINDOWS) && !defined(NETWARE)  /* I guess 'chown' won't be available on NetWare */
        pval **filename, **user;
        int ret;
        uid_t uid;
@@ -472,7 +476,11 @@ 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 +554,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"};
@@ -612,6 +624,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;
@@ -641,6 +654,7 @@ static void php_stat(const char *filename, php_stat_len filename_length, int typ
                        }
                }
        }
+#endif
 
        switch (type) {
        case FS_PERMS:
@@ -654,11 +668,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:
-               RETURN_LONG((long)BG(sb).st_atime);
+#if defined(NETWARE) && defined(NEW_LIBC)
+        RETURN_LONG((long)(BG(sb).st_atime).tv_nsec);
+#else
+        RETURN_LONG((long)BG(sb).st_atime);
+#endif
        case FS_MTIME:
-               RETURN_LONG((long)BG(sb).st_mtime);
+#if defined(NETWARE) && defined(NEW_LIBC)
+               RETURN_LONG((long)(BG(sb).st_mtime).tv_nsec);
+#else
+        RETURN_LONG((long)BG(sb).st_mtime);
+#endif
        case FS_CTIME:
-               RETURN_LONG((long)BG(sb).st_ctime);
+#if defined(NETWARE) && defined(NEW_LIBC)
+               RETURN_LONG((long)(BG(sb).st_ctime).tv_nsec);
+#else
+        RETURN_LONG((long)BG(sb).st_ctime);
+#endif
        case FS_TYPE:
 #if HAVE_SYMLINK
                if (S_ISLNK(BG(lsb).st_mode)) {
@@ -678,16 +704,25 @@ static void php_stat(const char *filename, php_stat_len filename_length, int typ
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown file type (%d)", BG(sb).st_mode&S_IFMT);
                RETURN_STRING("unknown", 1);
        case FS_IS_W:
+#ifdef NETWARE
+        RETURN_LONG(0);
+#else
                if (getuid()==0) {
                        RETURN_TRUE; /* root */
                }
                RETURN_BOOL((BG(sb).st_mode & wmask) != 0);
        case FS_IS_R:
+#ifdef NETWARE
+        RETURN_LONG(0);
+#else
                if (getuid()==0) {
                        RETURN_TRUE; /* root */
                }
                RETURN_BOOL((BG(sb).st_mode&rmask)!=0);
        case FS_IS_X:
+#ifdef NETWARE
+        RETURN_LONG(0);
+#else
                if (getuid()==0) {
                        xmask = S_IXROOT; /* root */
                }
@@ -726,9 +761,15 @@ static void php_stat(const char *filename, php_stat_len filename_length, int typ
                MAKE_LONG_ZVAL_INCREF(stat_rdev, -1); 
 #endif
                MAKE_LONG_ZVAL_INCREF(stat_size, stat_sb->st_size);
+#if defined(NETWARE) && defined(NEW_LIBC)
+               MAKE_LONG_ZVAL_INCREF(stat_atime, (stat_sb->st_atime).tv_nsec);
+               MAKE_LONG_ZVAL_INCREF(stat_mtime, (stat_sb->st_mtime).tv_nsec);
+               MAKE_LONG_ZVAL_INCREF(stat_ctime, (stat_sb->st_ctime).tv_nsec);
+#else
                MAKE_LONG_ZVAL_INCREF(stat_atime, stat_sb->st_atime);
                MAKE_LONG_ZVAL_INCREF(stat_mtime, stat_sb->st_mtime);
                MAKE_LONG_ZVAL_INCREF(stat_ctime, stat_sb->st_ctime);
+#endif
 #ifdef HAVE_ST_BLKSIZE
                MAKE_LONG_ZVAL_INCREF(stat_blksize, stat_sb->st_blksize); 
 #else
index 7cec78dbe9676cac3c660d3215cd5a260f93c3e9..35f7ea411e383169ad45539697eecb02aa75fb50 100644 (file)
 #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
index b12a533ec3924517bf1e71937de0c0405417042b..ec181f125ea646c124b0574f7f02d2277e599511 100644 (file)
 #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>
@@ -54,7 +67,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)
@@ -88,6 +101,10 @@ static int fsock_globals_id;
 
 #ifdef PHP_WIN32
 #define EWOULDBLOCK WSAEWOULDBLOCK
+#elif defined(NETWARE)
+#ifdef USE_WINSOCK
+#define EWOULDBLOCK WSAEWOULDBLOCK
+#endif
 #else
 #include "build-defs.h"
 #endif
index fb134e97bcac5d1259443f524f7e5dcc39286a7d..5297bbf72976e22fca6f10a1d5b0f3ab5991f650 100644 (file)
 #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"
 
 #include "php_network.h"
index 054d39a5e31bb67834c7bb3d54d0d6f1b992d1ea..003fd1e65c86902b2a439df13b8fa57513bf8610 100644 (file)
 #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
 
index 8845d8c86fd1a2b78fe7c65eaca8f9ede90c959f..a6672239aaba8538c1394cb9ea7736d297626557 100644 (file)
 /* $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"
index 71989e53bd08148c6538c3b231ad051779e00b25..b48cb90de6e2fc8b93a00bc00650c33a75fdf4d6 100644 (file)
 #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
@@ -50,6 +58,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>
@@ -58,7 +69,7 @@
 #endif
 #endif
 
-#if defined(PHP_WIN32) || defined(__riscos__)
+#if defined(PHP_WIN32) || defined(__riscos__) || defined(NETWARE)
 #undef AF_UNIX
 #endif
 
index 9745105d650959508900471cc08cc37d368c7326..0bbd9d954e7d19e0ab7c68de45e0333ba9397906 100755 (executable)
@@ -101,7 +101,11 @@ typedef void (*php_stream_notification_func)(php_stream_context *context,
                void * ptr TSRMLS_DC);
 
 typedef struct _php_stream_statbuf {
+#if defined(NETWARE) && defined(CLIB_STAT_PATCH)
+       struct stat_libc sb; /* regular info */
+#else
        struct stat sb; /* regular info */
+#endif
        /* extended info to go here some day: content-type etc. etc. */
 } php_stream_statbuf;