[php-i18n-commits] cvs commit: TSRM TSRM.c TSRM.h tsrm_config_common.h tsrm_virtual_cwd.c tsrm_virtual_cwd.h

Back to archive index

Yasuo Ohgaki yohga****@users*****
2002年 7月 9日 (火) 18:01:35 JST


yohgaki     02/07/09 18:01:35

  Modified:    .        Tag: ORIG TSRM.c TSRM.h tsrm_config_common.h
                        tsrm_virtual_cwd.c tsrm_virtual_cwd.h
  Log:
  Recent cvs.php.net changes
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.2.2.1   +15 -0     TSRM/TSRM.c
  
  Index: TSRM.c
  ===================================================================
  RCS file: /cvsroot/php-i18n/TSRM/TSRM.c,v
  retrieving revision 1.2
  retrieving revision 1.2.2.1
  diff -u -r1.2 -r1.2.2.1
  --- TSRM.c	29 Apr 2002 02:23:26 -0000	1.2
  +++ TSRM.c	9 Jul 2002 09:01:34 -0000	1.2.2.1
  @@ -412,6 +412,8 @@
   {
   #ifdef TSRM_WIN32
   	return GetCurrentThreadId();
  +#elif defined(NETWARE)
  +	return NXThreadGetId();
   #elif defined(GNUPTH)
   	return pth_self();
   #elif defined(PTHREADS)
  @@ -430,10 +432,17 @@
   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);
  @@ -460,6 +469,8 @@
       if (mutexp) {
   #ifdef TSRM_WIN32
   		DeleteCriticalSection(mutexp);
  +#elif defined(NETWARE)
  +		NXMutexFree(mutexp);
   #elif defined(GNUPTH)
   		free(mutexp);
   #elif defined(PTHREADS)
  @@ -486,6 +497,8 @@
   #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)
  @@ -507,6 +520,8 @@
   #ifdef TSRM_WIN32
   	LeaveCriticalSection(mutexp);
   	return 1;
  +#elif defined(NETWARE)
  +	return NXUnlock(mutexp);
   #elif defined(GNUPTH)
   	return pth_mutex_release(mutexp);
   #elif defined(PTHREADS)
  
  
  
  1.2.2.1   +8 -1      TSRM/TSRM.h
  
  Index: TSRM.h
  ===================================================================
  RCS file: /cvsroot/php-i18n/TSRM/TSRM.h,v
  retrieving revision 1.2
  retrieving revision 1.2.2.1
  diff -u -r1.2 -r1.2.2.1
  --- TSRM.h	29 Apr 2002 02:23:26 -0000	1.2
  +++ TSRM.h	9 Jul 2002 09:01:34 -0000	1.2.2.1
  @@ -13,7 +13,8 @@
   #ifndef TSRM_H
   #define TSRM_H
   
  -#ifndef WIN32
  +/* #ifndef WIN32 */
  +#if !defined(WIN32) && !defined(NETWARE)
   # include "tsrm_config.h"
   #endif
   
  @@ -36,6 +37,9 @@
   
   #ifdef TSRM_WIN32
   # include <windows.h>
  +#elif defined(NETWARE)
  +# include <nks/thread.h>
  +# include <nks/synch.h>
   #elif defined(GNUPTH)
   # include <pth.h>
   #elif defined(PTHREADS)
  @@ -50,6 +54,9 @@
   #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 *
  
  
  
  1.2.2.1   +5 -3      TSRM/tsrm_config_common.h
  
  Index: tsrm_config_common.h
  ===================================================================
  RCS file: /cvsroot/php-i18n/TSRM/tsrm_config_common.h,v
  retrieving revision 1.2
  retrieving revision 1.2.2.1
  diff -u -r1.2 -r1.2.2.1
  --- tsrm_config_common.h	29 Apr 2002 02:23:26 -0000	1.2
  +++ tsrm_config_common.h	9 Jul 2002 09:01:34 -0000	1.2.2.1
  @@ -5,11 +5,13 @@
   # define TSRM_WIN32
   #endif
   
  -#ifndef TSRM_WIN32
  +#ifdef TSRM_WIN32
  +# include "tsrm_config.w32.h"
  +#elif defined(NETWARE)
  +# include "tsrm_config.nw.h"
  +#else
   # include "tsrm_config.h"
   # include <sys/param.h>
  -#else
  -# include "tsrm_config.w32.h"
   #endif
   
   #ifdef TSRM_WIN32
  
  
  
  1.2.2.1   +125 -36   TSRM/tsrm_virtual_cwd.c
  
  Index: tsrm_virtual_cwd.c
  ===================================================================
  RCS file: /cvsroot/php-i18n/TSRM/tsrm_virtual_cwd.c,v
  retrieving revision 1.2
  retrieving revision 1.2.2.1
  diff -u -r1.2 -r1.2.2.1
  --- tsrm_virtual_cwd.c	29 Apr 2002 02:23:26 -0000	1.2
  +++ tsrm_virtual_cwd.c	9 Jul 2002 09:01:34 -0000	1.2.2.1
  @@ -17,7 +17,7 @@
      +----------------------------------------------------------------------+
   */
   
  -/* $Id: tsrm_virtual_cwd.c,v 1.29 2002/04/25 14:42:55 hirokawa Exp $ */
  +/* $Id: tsrm_virtual_cwd.c,v 1.30 2002/05/29 08:41:21 rvenkat Exp $ */
   
   #include <sys/types.h>
   #include <sys/stat.h>
  @@ -36,12 +36,17 @@
   #include "tsrm_win32.h"
   #endif
   
  +#ifdef NETWARE
  +/*#include "pipe.h"*/
  +#include "tsrm_nw.h"
  +#endif
  +
   #define VIRTUAL_CWD_DEBUG 0
   
   #include "TSRM.h"
   
  -/* Only need mutex for popen() in Windows because it doesn't chdir() on UNIX */
  -#if defined(TSRM_WIN32) && defined(ZTS)
  +/* Only need mutex for popen() in Windows and NetWare, because it doesn't chdir() on UNIX */
  +#if (defined(TSRM_WIN32) || defined(NETWARE)) && defined(ZTS)
   MUTEX_T cwd_mutex;
   #endif
   
  @@ -85,6 +90,13 @@
   #define IS_DIRECTORY_CURRENT(element, len) \
   	(len == 1 && ptr[0] == '.')
   
  +#elif defined(NETWARE)
  +/* NetWare has strtok() (in LibC) and allows both slashes in paths, like Windows --
  +   but rest of the stuff is like Unix */
  +/* strtok() call in LibC is abending when used in a different address space -- hence using
  +   PHP's version itself for now */
  +/*#define tsrm_strtok_r(a,b,c) strtok((a),(b))*/
  +#define TOKENIZER_STRING "/\\"
   
   #else
   #define TOKENIZER_STRING "/"
  @@ -121,9 +133,15 @@
   	
   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);
  @@ -131,9 +149,15 @@
   
   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);
  @@ -274,7 +298,7 @@
   	if (path_length == 0) 
   		return (0);
   
  -#if !defined(TSRM_WIN32) && !defined(__BEOS__)
  +#if !defined(TSRM_WIN32) && !defined(__BEOS__) && !defined(NETWARE)
   	if (IS_ABSOLUTE_PATH(path, path_length)) {
   		if (realpath(path, resolved_path)) {
   			path = resolved_path;
  @@ -309,7 +333,12 @@
   	fprintf(stderr,"cwd = %s path = %s\n", state->cwd, path);
   #endif
   	if (IS_ABSOLUTE_PATH(path_copy, path_length)) {
  +/* COPY_WHEN_ABSOLUTE needs to account for volume name that is unique to NetWare absolute paths */
  +#ifndef NETWARE
   		copy_amount = COPY_WHEN_ABSOLUTE;
  +#else
  +        copy_amount = COPY_WHEN_ABSOLUTE(path_copy);
  +#endif
   		is_absolute = 1;
   #ifdef TSRM_WIN32
   	} else if (IS_UNC_PATH(path_copy, path_length)) {
  @@ -368,6 +397,11 @@
   				IsDBCSLeadByte(state->cwd[state->cwd_length-2])) {
   				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] != ':') {
  +				state->cwd[state->cwd_length++] = DEFAULT_SLASH;
  +			}
   #else
   			state->cwd[state->cwd_length++] = DEFAULT_SLASH;
   #endif
  @@ -377,7 +411,12 @@
   		ptr = tsrm_strtok_r(NULL, TOKENIZER_STRING, &tok);
   	}
   
  +/* COPY_WHEN_ABSOLUTE needs to account for volume name that is unique to NetWare absolute paths */
  +#ifndef NETWARE
   	if (state->cwd_length == COPY_WHEN_ABSOLUTE) {
  +#else
  +	if (state->cwd_length == COPY_WHEN_ABSOLUTE(state->cwd)) {
  +#endif
   		state->cwd = (char *) realloc(state->cwd, state->cwd_length+1+1);
   		state->cwd[state->cwd_length] = DEFAULT_SLASH;
   		state->cwd[state->cwd_length+1] = '\0';
  @@ -427,7 +466,12 @@
   		return -1;
   	}
   
  +/* COPY_WHEN_ABSOLUTE needs to account for volume name that is unique to NetWare absolute paths */
  +#ifndef NETWARE
   	if (length == COPY_WHEN_ABSOLUTE && IS_ABSOLUTE_PATH(path, length+1)) { /* Also use trailing slash if this is absolute */
  +#else
  +	if (length == COPY_WHEN_ABSOLUTE(path) && IS_ABSOLUTE_PATH(path, length+1)) { /* Also use trailing slash if this is absolute */
  +#endif
   		length++;
   	}
   	temp = (char *) tsrm_do_alloca(length+1);
  @@ -526,7 +570,7 @@
   	return ret;
   }
   
  -#ifndef TSRM_WIN32
  +#if !defined(TSRM_WIN32) && !defined(NETWARE)
   CWD_API int virtual_chown(const char *filename, uid_t owner, gid_t group TSRMLS_DC)
   {
   	cwd_state new_state;
  @@ -602,6 +646,7 @@
   	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;
  @@ -615,9 +660,23 @@
   	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;
   
  -#ifndef TSRM_WIN32
  +	CWD_STATE_COPY(&new_state, &CWDG(cwd));
  +	virtual_file_ex(&new_state, path, NULL);
  +
  +	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)
   {
   	cwd_state new_state;
  @@ -631,7 +690,6 @@
   	CWD_STATE_FREE(&new_state);
   	return retval;
   }
  -
   #endif
   
   CWD_API int virtual_unlink(const char *path TSRMLS_DC)
  @@ -697,46 +755,41 @@
   	return retval;
   }
   
  -#ifndef TSRM_WIN32
  +#ifdef TSRM_WIN32
   
  +/* On Windows the trick of prepending "cd cwd; " doesn't work so we need to perform
  +   a real chdir() and mutex it
  + */
   CWD_API FILE *virtual_popen(const char *command, const char *type TSRMLS_DC)
   {
  -	int command_length;
  -	char *command_line;
  -	char *ptr;
  +	char prev_cwd[MAXPATHLEN];
  +	char *getcwd_result;
   	FILE *retval;
   
  -	command_length = strlen(command);
  -
  -	ptr = command_line = (char *) malloc(command_length + sizeof("cd  ; ") + CWDG(cwd).cwd_length+1);
  -	if (!command_line) {
  +	getcwd_result = getcwd(prev_cwd, MAXPATHLEN);
  +	if (!getcwd_result) {
   		return NULL;
   	}
  -	memcpy(ptr, "cd ", sizeof("cd ")-1);
  -	ptr += sizeof("cd ")-1;
   
  -	if (CWDG(cwd).cwd_length == 0) {
  -		*ptr++ = DEFAULT_SLASH;
  -	} else {
  -		memcpy(ptr, CWDG(cwd).cwd, CWDG(cwd).cwd_length);
  -		ptr += CWDG(cwd).cwd_length;
  -	}
  -	
  -	*ptr++ = ' ';
  -	*ptr++ = ';';
  -	*ptr++ = ' ';
  +#ifdef ZTS
  +	tsrm_mutex_lock(cwd_mutex);
  +#endif
   
  -	memcpy(ptr, command, command_length+1);
  -	retval = popen(command_line, type);
  +	chdir(CWDG(cwd).cwd);
  +	retval = popen(command, type);
  +	chdir(prev_cwd);
  +
  +#ifdef ZTS
  +	tsrm_mutex_unlock(cwd_mutex);
  +#endif
   
  -	free(command_line);
   	return retval;
   }
   
  -#else
  +#elif defined(NETWARE)
   
  -/* On Windows the trick of prepending "cd cwd; " doesn't work so we need to perform
  -   a real chdir() and mutex it
  +/* On NetWare, the trick of prepending "cd cwd; " doesn't work so we need to perform
  +   a VCWD_CHDIR() and mutex it
    */
   CWD_API FILE *virtual_popen(const char *command, const char *type TSRMLS_DC)
   {
  @@ -744,7 +797,7 @@
   	char *getcwd_result;
   	FILE *retval;
   
  -	getcwd_result = getcwd(prev_cwd, MAXPATHLEN);
  +	getcwd_result = VCWD_GETCWD(prev_cwd, MAXPATHLEN);
   	if (!getcwd_result) {
   		return NULL;
   	}
  @@ -753,14 +806,50 @@
   	tsrm_mutex_lock(cwd_mutex);
   #endif
   
  -	chdir(CWDG(cwd).cwd);
  +	VCWD_CHDIR(CWDG(cwd).cwd);
   	retval = popen(command, type);
  -	chdir(prev_cwd);
  +	VCWD_CHDIR(prev_cwd);
   
   #ifdef ZTS
   	tsrm_mutex_unlock(cwd_mutex);
   #endif
   
  +	return retval;
  +}
  +
  +#else /* Unix */
  +
  +CWD_API FILE *virtual_popen(const char *command, const char *type TSRMLS_DC)
  +{
  +	int command_length;
  +	char *command_line;
  +	char *ptr;
  +	FILE *retval;
  +
  +	command_length = strlen(command);
  +
  +	ptr = command_line = (char *) malloc(command_length + sizeof("cd  ; ") + CWDG(cwd).cwd_length+1);
  +	if (!command_line) {
  +		return NULL;
  +	}
  +	memcpy(ptr, "cd ", sizeof("cd ")-1);
  +	ptr += sizeof("cd ")-1;
  +
  +	if (CWDG(cwd).cwd_length == 0) {
  +		*ptr++ = DEFAULT_SLASH;
  +	} else {
  +		memcpy(ptr, CWDG(cwd).cwd, CWDG(cwd).cwd_length);
  +		ptr += CWDG(cwd).cwd_length;
  +	}
  +	
  +	*ptr++ = ' ';
  +	*ptr++ = ';';
  +	*ptr++ = ' ';
  +
  +	memcpy(ptr, command, command_length+1);
  +	retval = popen(command_line, type);
  +
  +	free(command_line);
   	return retval;
   }
   
  
  
  
  1.2.2.1   +24 -7     TSRM/tsrm_virtual_cwd.h
  
  Index: tsrm_virtual_cwd.h
  ===================================================================
  RCS file: /cvsroot/php-i18n/TSRM/tsrm_virtual_cwd.h,v
  retrieving revision 1.2
  retrieving revision 1.2.2.1
  diff -u -r1.2 -r1.2.2.1
  --- tsrm_virtual_cwd.h	29 Apr 2002 02:23:26 -0000	1.2
  +++ tsrm_virtual_cwd.h	9 Jul 2002 09:01:34 -0000	1.2.2.1
  @@ -17,7 +17,7 @@
      +----------------------------------------------------------------------+
   */
   
  -/* $Id: tsrm_virtual_cwd.h,v 1.18 2002/04/25 14:42:55 hirokawa Exp $ */
  +/* $Id: tsrm_virtual_cwd.h,v 1.19 2002/05/29 08:41:21 rvenkat Exp $ */
   
   #ifndef VIRTUAL_CWD_H
   #define VIRTUAL_CWD_H
  @@ -58,6 +58,19 @@
   #define IS_UNC_PATH(path, len) \
   	(len >= 2 && IS_SLASH(path[0]) && IS_SLASH(path[1]))
   
  +#elif defined(NETWARE)
  +#ifdef HAVE_DIRENT_H
  +#include <dirent.h>
  +#endif
  +
  +#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_ABSOLUTE_PATH(path, len) \
  +    (strchr(path, ':') != NULL) /* Colon indicates volume name */
  +
   #else
   #ifdef HAVE_DIRENT_H
   #include <dirent.h>
  @@ -120,8 +133,12 @@
   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);
  -#ifndef TSRM_WIN32
  +#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
   CWD_API int virtual_unlink(const char *path TSRMLS_DC);
  @@ -133,7 +150,7 @@
   CWD_API int virtual_utime(const char *filename, struct utimbuf *buf TSRMLS_DC);
   #endif
   CWD_API int virtual_chmod(const char *filename, mode_t mode TSRMLS_DC);
  -#ifndef TSRM_WIN32
  +#if !defined(TSRM_WIN32) && !defined(NETWARE)
   CWD_API int virtual_chown(const char *filename, uid_t owner, gid_t group TSRMLS_DC);
   #endif
   
  @@ -168,7 +185,7 @@
   #define VCWD_REALPATH(path, real_path) virtual_realpath(path, real_path TSRMLS_CC)
   #define VCWD_RENAME(oldname, newname) virtual_rename(oldname, newname TSRMLS_CC)
   #define VCWD_STAT(path, buff) virtual_stat(path, buff TSRMLS_CC)
  -#ifdef TSRM_WIN32
  +#if !defined(TSRM_WIN32) && !defined(NETWARE)
   #define VCWD_LSTAT(path, buff) virtual_stat(path, buff TSRMLS_CC)
   #else
   #define VCWD_LSTAT(path, buff) virtual_lstat(path, buff TSRMLS_CC)
  @@ -182,7 +199,7 @@
   #define VCWD_UTIME(path, time) virtual_utime(path, time TSRMLS_CC)
   #endif
   #define VCWD_CHMOD(path, mode) virtual_chmod(path, mode TSRMLS_CC)
  -#ifndef TSRM_WIN32
  +#if !defined(TSRM_WIN32) && !defined(NETWARE)
   #define VCWD_CHOWN(path, owner, group) virtual_chown(path, owner, group TSRMLS_CC)
   #endif
   
  @@ -205,7 +222,7 @@
   #define VCWD_OPENDIR(pathname) opendir(pathname)
   #define VCWD_POPEN(command, type) popen(command, type)
   
  -#ifndef TSRM_WIN32
  +#if !defined(TSRM_WIN32) && !defined(NETWARE)
   #define VCWD_REALPATH(path, real_path) realpath(path, real_path)
   #else
   #define VCWD_REALPATH(path, real_path) strcpy(real_path, path)
  @@ -215,7 +232,7 @@
   #define VCWD_UTIME(path, time) utime(path, time)
   #endif
   #define VCWD_CHMOD(path, mode) chmod(path, mode)
  -#ifndef TSRM_WIN32
  +#if !defined(TSRM_WIN32) && !defined(NETWARE)
   #define VCWD_CHOWN(path, owner, group) chown(path, owner, group)
   #endif
   
  
  
  



php-i18n-commits メーリングリストの案内
Back to archive index