From 1b7a2b100eec3c58bf29be47d2d84014f79d30f5 Mon Sep 17 00:00:00 2001 From: Anantha Kesari H Y Date: Tue, 26 Jul 2005 13:34:52 +0000 Subject: [PATCH] TSRM/TSRM.h NetWare can make use of autoconf based build. PTHREADS implementation of NetWare is good enough so dropping the code for NetWare specific thread implementation in preference to PTHREADS TSRM/TSRM.c PTHREADS implementation of NetWare is good enough so dropping the code for NetWare specific thread implementation in preference to PTHREADS TSRM/tsrm_virtual_cwd.c NetWare can make use of autoconf based build. Removed redundant CLIB_STAT_PATCH checks NetWare specific fixes from PHP_5_0. TSRM/tsrm_virtual_cwd.h Removed redundant CLIB_STAT_PATCH checks NetWare specific fixes from PHP_5_0. --Kamesh --- TSRM/TSRM.c | 16 ---------- TSRM/TSRM.h | 8 +---- TSRM/tsrm_virtual_cwd.c | 67 +++++++++++++++++++---------------------- TSRM/tsrm_virtual_cwd.h | 10 ++---- 4 files changed, 35 insertions(+), 66 deletions(-) diff --git a/TSRM/TSRM.c b/TSRM/TSRM.c index c4a710f19d..e5e57a228f 100644 --- a/TSRM/TSRM.c +++ b/TSRM/TSRM.c @@ -428,8 +428,6 @@ TSRM_API THREAD_T tsrm_thread_id(void) { #ifdef TSRM_WIN32 return GetCurrentThreadId(); -#elif defined(NETWARE) - return NXThreadGetId(); #elif defined(GNUPTH) return pth_self(); #elif defined(PTHREADS) @@ -450,17 +448,9 @@ TSRM_API THREAD_T tsrm_thread_id(void) TSRM_API MUTEX_T tsrm_mutex_alloc(void) { MUTEX_T mutexp; -#ifdef NETWARE - long flags = 0; /* Don't require NX_MUTEX_RECURSIVE, I guess */ - NXHierarchy_t order = 0; - NX_LOCK_INFO_ALLOC (lockInfo, "PHP-TSRM", 0); -#endif - #ifdef TSRM_WIN32 mutexp = malloc(sizeof(CRITICAL_SECTION)); InitializeCriticalSection(mutexp); -#elif defined(NETWARE) - mutexp = NXMutexAlloc(flags, order, &lockInfo); /* return value ignored for now */ #elif defined(GNUPTH) mutexp = (MUTEX_T) malloc(sizeof(*mutexp)); pth_mutex_init(mutexp); @@ -492,8 +482,6 @@ TSRM_API void tsrm_mutex_free(MUTEX_T mutexp) #ifdef TSRM_WIN32 DeleteCriticalSection(mutexp); free(mutexp); -#elif defined(NETWARE) - NXMutexFree(mutexp); #elif defined(GNUPTH) free(mutexp); #elif defined(PTHREADS) @@ -523,8 +511,6 @@ TSRM_API int tsrm_mutex_lock(MUTEX_T mutexp) #ifdef TSRM_WIN32 EnterCriticalSection(mutexp); return 1; -#elif defined(NETWARE) - return NXLock(mutexp); #elif defined(GNUPTH) return pth_mutex_acquire(mutexp, 0, NULL); #elif defined(PTHREADS) @@ -550,8 +536,6 @@ TSRM_API int tsrm_mutex_unlock(MUTEX_T mutexp) #ifdef TSRM_WIN32 LeaveCriticalSection(mutexp); return 1; -#elif defined(NETWARE) - return NXUnlock(mutexp); #elif defined(GNUPTH) return pth_mutex_release(mutexp); #elif defined(PTHREADS) diff --git a/TSRM/TSRM.h b/TSRM/TSRM.h index 46f9702bd2..f77f783f8f 100644 --- a/TSRM/TSRM.h +++ b/TSRM/TSRM.h @@ -14,7 +14,7 @@ #define TSRM_H /* #ifndef WIN32 */ -#if !defined(WIN32) && !defined(NETWARE) +#if !defined(WIN32) # include #endif @@ -38,9 +38,6 @@ #ifdef TSRM_WIN32 # include -#elif defined(NETWARE) -# include -# include #elif defined(GNUPTH) # include #elif defined(PTHREADS) @@ -58,9 +55,6 @@ typedef int ts_rsrc_id; #ifdef TSRM_WIN32 # define THREAD_T DWORD # define MUTEX_T CRITICAL_SECTION * -#elif defined(NETWARE) -# define THREAD_T NXThreadId_t -# define MUTEX_T NXMutex_t * #elif defined(GNUPTH) # define THREAD_T pth_t # define MUTEX_T pth_mutex_t * diff --git a/TSRM/tsrm_virtual_cwd.c b/TSRM/tsrm_virtual_cwd.c index 3c8ba90d37..82d102bcba 100644 --- a/TSRM/tsrm_virtual_cwd.c +++ b/TSRM/tsrm_virtual_cwd.c @@ -37,8 +37,7 @@ #endif #ifdef NETWARE -/*#include "pipe.h"*/ -#include "tsrm_nw.h" +#include #endif #ifndef HAVE_REALPATH @@ -137,15 +136,9 @@ static int php_check_dots(const char *element, int n) static int php_is_dir_ok(const cwd_state *state) { -#if !(defined(NETWARE) && defined(CLIB_STAT_PATCH)) struct stat buf; if (stat(state->cwd, &buf) == 0 && S_ISDIR(buf.st_mode)) -#else - struct stat_libc buf; - - if (stat(state->cwd, (struct stat*)(&buf)) == 0 && S_ISDIR(buf.st_mode)) -#endif return (0); return (1); @@ -153,15 +146,9 @@ static int php_is_dir_ok(const cwd_state *state) static int php_is_file_ok(const cwd_state *state) { -#if !(defined(NETWARE) && defined(CLIB_STAT_PATCH)) struct stat buf; if (stat(state->cwd, &buf) == 0 && S_ISREG(buf.st_mode)) -#else - struct stat_libc buf; - - if (stat(state->cwd, (struct stat*)(&buf)) == 0 && S_ISREG(buf.st_mode)) -#endif return (0); return (1); @@ -196,8 +183,20 @@ CWD_API void virtual_cwd_startup(void) { char cwd[MAXPATHLEN]; char *result; - - result = getcwd(cwd, sizeof(cwd)); +#ifdef NETWARE + result = getcwdpath(cwd, NULL, 1); + if(result) + { + char *c=cwd; + while(c = strchr(c, '\\')) + { + *c='/'; + ++c; + } + } +#else + result = getcwd(cwd, sizeof(cwd)); +#endif if (!result) { cwd[0] = '\0'; } @@ -210,7 +209,7 @@ CWD_API void virtual_cwd_startup(void) cwd_globals_ctor(&cwd_globals TSRMLS_CC); #endif -#if defined(TSRM_WIN32) && defined(ZTS) +#if (defined(TSRM_WIN32) || defined(NETWARE)) && defined(ZTS) cwd_mutex = tsrm_mutex_alloc(); #endif } @@ -220,7 +219,7 @@ CWD_API void virtual_cwd_shutdown(void) #ifndef ZTS cwd_globals_dtor(&cwd_globals TSRMLS_CC); #endif -#if defined(TSRM_WIN32) && defined(ZTS) +#if (defined(TSRM_WIN32) || defined(NETWARE)) && defined(ZTS) tsrm_mutex_free(cwd_mutex); #endif @@ -418,8 +417,20 @@ CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func state->cwd[state->cwd_length++] = DEFAULT_SLASH; } #elif defined(NETWARE) - /* If the token is a volume name, it will have colon at the end -- so, no slash before it */ - if (ptr[ptr_length-1] != ':') { + /* + Below code keeps appending to state->cwd a File system seperator + cases where this appending should not happen is given below, + a) sys: should just be left as it is + b) sys:system should just be left as it is, + Colon is allowed only in the first token as volume names alone can have the : in their names. + Files and Directories cannot have : in their names + So the check goes like this, + For second token and above simply append the DEFAULT_SLASH to the state->cwd. + For first token check for the existence of : + if it exists don't append the DEFAULT_SLASH to the state->cwd. + */ + if(((state->cwd_length == 0) && (strchr(ptr, ':') == NULL)) || (state->cwd_length > 0)) + { state->cwd[state->cwd_length++] = DEFAULT_SLASH; } #else @@ -683,7 +694,6 @@ CWD_API int virtual_rename(char *oldname, char *newname TSRMLS_DC) return retval; } -#if !(defined(NETWARE) && defined(CLIB_STAT_PATCH)) CWD_API int virtual_stat(const char *path, struct stat *buf TSRMLS_DC) { cwd_state new_state; @@ -697,21 +707,6 @@ CWD_API int virtual_stat(const char *path, struct stat *buf TSRMLS_DC) CWD_STATE_FREE(&new_state); return retval; } -#else -CWD_API int virtual_stat(const char *path, struct stat_libc *buf TSRMLS_DC) -{ - cwd_state new_state; - int retval; - - CWD_STATE_COPY(&new_state, &CWDG(cwd)); - virtual_file_ex(&new_state, path, NULL, 1); - - retval = stat(new_state.cwd, (struct stat*)buf); - - CWD_STATE_FREE(&new_state); - return retval; -} -#endif #if !defined(TSRM_WIN32) && !defined(NETWARE) CWD_API int virtual_lstat(const char *path, struct stat *buf TSRMLS_DC) diff --git a/TSRM/tsrm_virtual_cwd.h b/TSRM/tsrm_virtual_cwd.h index 0a05cf8016..1646042b03 100644 --- a/TSRM/tsrm_virtual_cwd.h +++ b/TSRM/tsrm_virtual_cwd.h @@ -74,10 +74,10 @@ typedef unsigned short mode_t; #define DEFAULT_SLASH '/' #define DEFAULT_DIR_SEPARATOR ';' #define IS_SLASH(c) ((c) == '/' || (c) == '\\') -#define COPY_WHEN_ABSOLUTE(path) \ - (strchr(path, ':') - path + 1) /* Take the volume name which ends with a colon */ +#define IS_SLASH_P(c) IS_SLASH(*(c)) +/* Colon indicates volume name, either first character should be forward slash or backward slash */ #define IS_ABSOLUTE_PATH(path, len) \ - (strchr(path, ':') != NULL) /* Colon indicates volume name */ + ((strchr(path, ':') != NULL) || ((len >= 1) && ((path[0] == '/') || (path[0] == '\\')))) #else #ifdef HAVE_DIRENT_H @@ -141,11 +141,7 @@ CWD_API FILE *virtual_fopen(const char *path, const char *mode TSRMLS_DC); CWD_API int virtual_open(const char *path TSRMLS_DC, int flags, ...); CWD_API int virtual_creat(const char *path, mode_t mode TSRMLS_DC); CWD_API int virtual_rename(char *oldname, char *newname TSRMLS_DC); -#if !(defined(NETWARE) && defined(CLIB_STAT_PATCH)) CWD_API int virtual_stat(const char *path, struct stat *buf TSRMLS_DC); -#else -CWD_API int virtual_stat(const char *path, struct stat_libc *buf TSRMLS_DC); -#endif #if !defined(TSRM_WIN32) && !defined(NETWARE) CWD_API int virtual_lstat(const char *path, struct stat *buf TSRMLS_DC); #endif -- 2.50.1