{
#ifdef TSRM_WIN32
return GetCurrentThreadId();
-#elif defined(NETWARE)
- return NXThreadGetId();
#elif defined(GNUPTH)
return pth_self();
#elif defined(PTHREADS)
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);
#ifdef TSRM_WIN32
DeleteCriticalSection(mutexp);
free(mutexp);
-#elif defined(NETWARE)
- NXMutexFree(mutexp);
#elif defined(GNUPTH)
free(mutexp);
#elif defined(PTHREADS)
#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)
#ifdef TSRM_WIN32
LeaveCriticalSection(mutexp);
return 1;
-#elif defined(NETWARE)
- return NXUnlock(mutexp);
#elif defined(GNUPTH)
return pth_mutex_release(mutexp);
#elif defined(PTHREADS)
#endif
#ifdef NETWARE
-/*#include "pipe.h"*/
-#include "tsrm_nw.h"
+#include <fsio.h>
#endif
#ifndef HAVE_REALPATH
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);
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);
{
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';
}
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
}
#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
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
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;
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)
#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
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