summaryrefslogtreecommitdiff
path: root/TSRM
diff options
context:
space:
mode:
authorVenkat Raghavan S <rvenkat@php.net>2002-05-29 08:41:21 +0000
committerVenkat Raghavan S <rvenkat@php.net>2002-05-29 08:41:21 +0000
commitc61598f32babf080802a4c73d8eec1006f9fc0a2 (patch)
tree5f462c9c0ed53b50b118cc9bf0fd3be7f60f55be /TSRM
parentb049f9bf17d7f7efa2aa8608c00baee8cc5c34c3 (diff)
downloadphp-git-c61598f32babf080802a4c73d8eec1006f9fc0a2.tar.gz
Changes to build TSRM on NetWare
Diffstat (limited to 'TSRM')
-rw-r--r--TSRM/tsrm_config.nw.h9
-rw-r--r--TSRM/tsrm_config_common.h8
-rw-r--r--TSRM/tsrm_nw.c260
-rw-r--r--TSRM/tsrm_nw.h28
-rw-r--r--TSRM/tsrm_virtual_cwd.c159
-rw-r--r--TSRM/tsrm_virtual_cwd.h29
6 files changed, 449 insertions, 44 deletions
diff --git a/TSRM/tsrm_config.nw.h b/TSRM/tsrm_config.nw.h
new file mode 100644
index 0000000000..0681852c7d
--- /dev/null
+++ b/TSRM/tsrm_config.nw.h
@@ -0,0 +1,9 @@
+#ifndef TSRM_CONFIG_NW_H
+#define TSRM_CONFIG_NW_H
+
+#define HAVE_UTIME 1
+
+/* Though we have alloca(), this seems to be causing some problem with the stack pointer -- hence not using it */
+/* #define HAVE_ALLOCA 1 */
+
+#endif
diff --git a/TSRM/tsrm_config_common.h b/TSRM/tsrm_config_common.h
index add5a50fa5..6c220fa008 100644
--- a/TSRM/tsrm_config_common.h
+++ b/TSRM/tsrm_config_common.h
@@ -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
diff --git a/TSRM/tsrm_nw.c b/TSRM/tsrm_nw.c
new file mode 100644
index 0000000000..c0f69adb5d
--- /dev/null
+++ b/TSRM/tsrm_nw.c
@@ -0,0 +1,260 @@
+/*
+ +----------------------------------------------------------------------+
+ | PHP Version 4 |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 1997-2002 The PHP Group |
+ +----------------------------------------------------------------------+
+ | This source file is subject to version 2.02 of the PHP license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available at through the world-wide-web at |
+ | http://www.php.net/license/2_02.txt. |
+ | If you did not receive a copy of the PHP license and are unable to |
+ | obtain it through the world-wide-web, please send a note to |
+ | license@php.net so we can mail you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Authors: Venkat Raghavan S <rvenkat@novell.com> |
+ +----------------------------------------------------------------------+
+*/
+
+/* $Id$ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <fcntl.h>
+
+#include "TSRM.h"
+
+#ifdef NETWARE
+
+#ifdef USE_MKFIFO
+#include <sys/stat.h>
+#elif !defined(USE_PIPE_OPEN) /* NXFifoOpen */
+#include <nks/fsio.h>
+#endif
+
+#include <nks/vm.h>
+#include <nks/memory.h>
+
+#include <string.h>
+
+#include "mktemp.h"
+
+/* strtok() call in LibC is abending when used in a different address space -- hence using
+ PHP's version itself for now : Venkat (30/4/02) */
+#include "tsrm_strtok_r.h"
+#define tsrm_strtok_r(a,b,c) strtok((a),(b))
+
+#define WHITESPACE " \t"
+#define MAX_ARGS 10
+
+
+TSRM_API FILE* popen(const char *commandline, const char *type)
+{
+ char *command = NULL, *argv[MAX_ARGS] = {'\0'}, **env = NULL;
+ char *tempName = "sys:/php/temp/phpXXXXXX.tmp";
+ char *filePath = NULL;
+ char *ptr = NULL;
+ int ptrLen = 0, argc = 0, i = 0, envCount = 0, err = 0;
+ FILE *stream = NULL;
+#if defined(USE_PIPE_OPEN) || defined(USE_MKFIFO)
+ int pipe_handle;
+ int mode = O_RDONLY;
+#else
+ NXHandle_t pipe_handle;
+ NXMode_t mode = NX_O_RDONLY;
+#endif
+ NXExecEnvSpec_t envSpec;
+ NXNameSpec_t nameSpec;
+ NXVmId_t newVM = 0;
+
+ /* Check for validity of input parameters */
+ if (!commandline || !type)
+ return NULL;
+
+ /* Get temporary file name */
+ filePath = mktemp(tempName);
+/*consoleprintf ("PHP | popen: file path = %s, mode = %s\n", filePath, type);*/
+ if (!filePath)
+ return NULL;
+
+ /* Set pipe mode according to type -- for now allow only "r" or "w" */
+ if (strcmp(type, "r") == 0)
+#if defined(USE_PIPE_OPEN) || defined(USE_MKFIFO)
+ mode = O_RDONLY;
+#else
+ mode = NX_O_RDONLY;
+#endif
+ else if (strcmp(type, "w") == 0)
+#if defined(USE_PIPE_OPEN) || defined(USE_MKFIFO)
+ mode = O_WRONLY;
+#else
+ mode = NX_O_WRONLY;
+#endif
+ else
+ return NULL;
+
+#ifdef USE_PIPE_OPEN
+ pipe_handle = pipe_open(filePath, mode);
+/*consoleprintf ("PHP | popen: pipe_open() returned %d\n", pipe_handle);*/
+ if (pipe_handle == -1)
+ return NULL;
+#elif defined(USE_MKFIFO)
+ pipe_handle = mkfifo(filePath, mode);
+consoleprintf ("PHP | popen: mkfifo() returned %d\n", pipe_handle);
+ if (pipe_handle == -1)
+ return NULL;
+#else
+ /*
+ - NetWare doesn't require first parameter
+ - Allowing LibC to choose the buffer size for now
+ */
+ err = NXFifoOpen(0, filePath, mode, 0, &pipe_handle);
+/*consoleprintf ("PHP | popen: NXFifoOpen() returned %d\n", err);*/
+ if (err)
+ return NULL;
+#endif
+
+ /* Copy the environment variables in preparation for the spawn call */
+
+ envCount = NXGetEnvCount() + 1; /* add one for NULL */
+ env = (char**)NXMemAlloc(sizeof(char*) * envCount, 0);
+ if (!env)
+ return NULL;
+
+ err = NXCopyEnv(env, envCount);
+consoleprintf ("PHP | popen: NXCopyEnv() returned %d\n", err);
+ if (err)
+ {
+ NXMemFree (env);
+ return NULL;
+ }
+
+ /* Separate commandline string into words */
+consoleprintf ("PHP | popen: commandline = %s\n", commandline);
+ ptr = tsrm_strtok_r((char*)commandline, WHITESPACE, NULL);
+ ptrLen = strlen(ptr);
+
+ command = (char*)malloc(ptrLen + 1);
+ if (!command)
+ {
+ NXMemFree (env);
+ return NULL;
+ }
+
+ strcpy (command, ptr);
+
+ ptr = tsrm_strtok_r(NULL, WHITESPACE, NULL);
+ while (ptr && (argc < MAX_ARGS))
+ {
+ ptrLen = strlen(ptr);
+
+ argv[argc] = (char*)malloc(ptrLen + 1);
+ if (!argv[argc])
+ {
+ NXMemFree (env);
+
+ if (command)
+ free (command);
+
+ for (i = 0; i < argc; i++)
+ {
+ if (argv[i])
+ free (argv[i]);
+ }
+
+ return NULL;
+ }
+
+ strcpy (argv[argc], ptr);
+
+ argc++;
+
+ ptr = tsrm_strtok_r(NULL, WHITESPACE, NULL);
+ }
+consoleprintf ("PHP | popen: commandline string parsed into tokens\n");
+ /* Setup the execution environment and spawn new process */
+
+ envSpec.esFlags = 0; /* Not used */
+ envSpec.esArgc = argc;
+ envSpec.esArgv = (void**)argv;
+ envSpec.esEnv = (void**)env;
+
+ envSpec.esStdin.ssType =
+ envSpec.esStdout.ssType = NX_OBJ_FIFO;
+ envSpec.esStderr.ssType = NX_OBJ_FILE;
+/*
+ envSpec.esStdin.ssHandle =
+ envSpec.esStdout.ssHandle =
+ envSpec.esStderr.ssHandle = -1;
+*/
+ envSpec.esStdin.ssPathCtx =
+ envSpec.esStdout.ssPathCtx =
+ envSpec.esStderr.ssPathCtx = NULL;
+
+#if defined(USE_PIPE_OPEN) || defined(USE_MKFIFO)
+ if (mode == O_RDONLY)
+#else
+ if (mode == NX_O_RDONLY)
+#endif
+ {
+ envSpec.esStdin.ssPath = filePath;
+ envSpec.esStdout.ssPath = stdout;
+ }
+ else /* Write Only */
+ {
+ envSpec.esStdin.ssPath = stdin;
+ envSpec.esStdout.ssPath = filePath;
+ }
+
+ envSpec.esStderr.ssPath = stdout;
+
+ nameSpec.ssType = NX_OBJ_FIFO;
+/* nameSpec.ssHandle = 0; */ /* Not used */
+ nameSpec.ssPathCtx = NULL; /* Not used */
+ nameSpec.ssPath = argv[0];
+consoleprintf ("PHP | popen: environment setup\n");
+ err = NXVmSpawn(&nameSpec, &envSpec, 0, &newVM);
+consoleprintf ("PHP | popen: NXVmSpawn() returned %d\n", err);
+ if (!err)
+ /* Get file pointer corresponding to the pipe (file) opened */
+ stream = fdopen(pipe_handle, type);
+
+ /* Clean-up */
+
+ if (env)
+ NXMemFree (env);
+
+ if (pipe_handle)
+#if defined(USE_PIPE_OPEN) || defined(USE_MKFIFO)
+ close(pipe_handle);
+#else
+ NXClose(pipe_handle);
+#endif
+
+ if (command)
+ free (command);
+
+ for (i = 0; i < argc; i++)
+ {
+ if (argv[i])
+ free (argv[i]);
+ }
+consoleprintf ("PHP | popen: all clean-up done, returning...\n");
+ return stream;
+}
+
+TSRM_API int pclose(FILE* stream)
+{
+ int err = 0;
+ NXHandle_t fd = 0;
+
+ /* Get the process associated with this pipe (file) handle and terminate it */
+ fd = fileno(stream);
+ NXClose (fd);
+
+ err = fclose(stream);
+
+ return err;
+}
+
+#endif
diff --git a/TSRM/tsrm_nw.h b/TSRM/tsrm_nw.h
new file mode 100644
index 0000000000..3ced3f299b
--- /dev/null
+++ b/TSRM/tsrm_nw.h
@@ -0,0 +1,28 @@
+/*
+ +----------------------------------------------------------------------+
+ | PHP Version 4 |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 1997-2002 The PHP Group |
+ +----------------------------------------------------------------------+
+ | This source file is subject to version 2.02 of the PHP license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available at through the world-wide-web at |
+ | http://www.php.net/license/2_02.txt. |
+ | If you did not receive a copy of the PHP license and are unable to |
+ | obtain it through the world-wide-web, please send a note to |
+ | license@php.net so we can mail you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Authors: Venkat Raghavan S <rvenkat@novell.com> |
+ +----------------------------------------------------------------------+
+*/
+
+
+#ifndef TSRM_NW_H
+#define TSRM_NW_H
+
+#include "TSRM.h"
+
+TSRM_API FILE* popen(const char *command, const char *type);
+TSRM_API int pclose(FILE* stream);
+
+#endif
diff --git a/TSRM/tsrm_virtual_cwd.c b/TSRM/tsrm_virtual_cwd.c
index e0c305d05c..a2a65eda74 100644
--- a/TSRM/tsrm_virtual_cwd.c
+++ b/TSRM/tsrm_virtual_cwd.c
@@ -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 @@ static int php_check_dots(const char *element, int n)
#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_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);
@@ -131,9 +149,15 @@ 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);
@@ -274,7 +298,7 @@ CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func
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 @@ CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func
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 @@ CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func
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 @@ CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func
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 @@ CWD_API int virtual_chdir_file(const char *path, int (*p_chdir)(const char *path
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 @@ CWD_API int virtual_chmod(const char *filename, mode_t mode TSRMLS_DC)
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 @@ 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;
@@ -615,9 +660,23 @@ 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;
-#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_API int virtual_lstat(const char *path, struct stat *buf TSRMLS_DC)
CWD_STATE_FREE(&new_state);
return retval;
}
-
#endif
CWD_API int virtual_unlink(const char *path TSRMLS_DC)
@@ -697,46 +755,41 @@ CWD_API DIR *virtual_opendir(const char *pathname TSRMLS_DC)
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 @@ CWD_API FILE *virtual_popen(const char *command, const char *type TSRMLS_DC)
char *getcwd_result;
FILE *retval;
- getcwd_result = getcwd(prev_cwd, MAXPATHLEN);
+ getcwd_result = VCWD_GETCWD(prev_cwd, MAXPATHLEN);
if (!getcwd_result) {
return NULL;
}
@@ -753,9 +806,9 @@ CWD_API FILE *virtual_popen(const char *command, const char *type TSRMLS_DC)
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);
@@ -764,6 +817,42 @@ CWD_API FILE *virtual_popen(const char *command, const char *type TSRMLS_DC)
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;
+}
+
#endif
diff --git a/TSRM/tsrm_virtual_cwd.h b/TSRM/tsrm_virtual_cwd.h
index 98efaa1432..d77539d1ef 100644
--- a/TSRM/tsrm_virtual_cwd.h
+++ b/TSRM/tsrm_virtual_cwd.h
@@ -58,6 +58,19 @@ typedef unsigned short mode_t;
#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 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);
-#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 FILE *virtual_popen(const char *command, const char *type TSRMLS_DC);
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 @@ typedef struct _virtual_cwd_globals {
#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 @@ typedef struct _virtual_cwd_globals {
#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 @@ typedef struct _virtual_cwd_globals {
#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 @@ typedef struct _virtual_cwd_globals {
#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