Changes to build TSRM on NetWare

This commit is contained in:
Venkat Raghavan S 2002-05-29 08:41:21 +00:00
parent b049f9bf17
commit c61598f32b
9 changed files with 592 additions and 64 deletions

9
TSRM/tsrm_config.nw.h Normal file
View File

@ -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

View File

@ -5,11 +5,13 @@
# define TSRM_WIN32 # define TSRM_WIN32
#endif #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 "tsrm_config.h"
# include <sys/param.h> # include <sys/param.h>
#else
# include "tsrm_config.w32.h"
#endif #endif
#ifdef TSRM_WIN32 #ifdef TSRM_WIN32

260
TSRM/tsrm_nw.c Normal file
View File

@ -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

28
TSRM/tsrm_nw.h Normal file
View File

@ -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

View File

@ -36,12 +36,17 @@
#include "tsrm_win32.h" #include "tsrm_win32.h"
#endif #endif
#ifdef NETWARE
/*#include "pipe.h"*/
#include "tsrm_nw.h"
#endif
#define VIRTUAL_CWD_DEBUG 0 #define VIRTUAL_CWD_DEBUG 0
#include "TSRM.h" #include "TSRM.h"
/* Only need mutex for popen() in Windows because it doesn't chdir() on UNIX */ /* Only need mutex for popen() in Windows and NetWare, because it doesn't chdir() on UNIX */
#if defined(TSRM_WIN32) && defined(ZTS) #if (defined(TSRM_WIN32) || defined(NETWARE)) && defined(ZTS)
MUTEX_T cwd_mutex; MUTEX_T cwd_mutex;
#endif #endif
@ -85,6 +90,13 @@ static int php_check_dots(const char *element, int n)
#define IS_DIRECTORY_CURRENT(element, len) \ #define IS_DIRECTORY_CURRENT(element, len) \
(len == 1 && ptr[0] == '.') (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 #else
#define TOKENIZER_STRING "/" #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) static int php_is_dir_ok(const cwd_state *state)
{ {
#if !(defined(NETWARE) && defined(CLIB_STAT_PATCH))
struct stat buf; struct stat buf;
if (stat(state->cwd, &buf) == 0 && S_ISDIR(buf.st_mode)) 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 (0);
return (1); 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) static int php_is_file_ok(const cwd_state *state)
{ {
#if !(defined(NETWARE) && defined(CLIB_STAT_PATCH))
struct stat buf; struct stat buf;
if (stat(state->cwd, &buf) == 0 && S_ISREG(buf.st_mode)) 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 (0);
return (1); 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) if (path_length == 0)
return (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 (IS_ABSOLUTE_PATH(path, path_length)) {
if (realpath(path, resolved_path)) { if (realpath(path, resolved_path)) {
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); fprintf(stderr,"cwd = %s path = %s\n", state->cwd, path);
#endif #endif
if (IS_ABSOLUTE_PATH(path_copy, path_length)) { 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; copy_amount = COPY_WHEN_ABSOLUTE;
#else
copy_amount = COPY_WHEN_ABSOLUTE(path_copy);
#endif
is_absolute = 1; is_absolute = 1;
#ifdef TSRM_WIN32 #ifdef TSRM_WIN32
} else if (IS_UNC_PATH(path_copy, path_length)) { } 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])) { IsDBCSLeadByte(state->cwd[state->cwd_length-2])) {
state->cwd[state->cwd_length++] = DEFAULT_SLASH; 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 #else
state->cwd[state->cwd_length++] = DEFAULT_SLASH; state->cwd[state->cwd_length++] = DEFAULT_SLASH;
#endif #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); 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) { 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 = (char *) realloc(state->cwd, state->cwd_length+1+1);
state->cwd[state->cwd_length] = DEFAULT_SLASH; state->cwd[state->cwd_length] = DEFAULT_SLASH;
state->cwd[state->cwd_length+1] = '\0'; 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; 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 */ 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++; length++;
} }
temp = (char *) tsrm_do_alloca(length+1); 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; 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_API int virtual_chown(const char *filename, uid_t owner, gid_t group TSRMLS_DC)
{ {
cwd_state new_state; cwd_state new_state;
@ -602,6 +646,7 @@ CWD_API int virtual_rename(char *oldname, char *newname TSRMLS_DC)
return retval; return retval;
} }
#if !(defined(NETWARE) && defined(CLIB_STAT_PATCH))
CWD_API int virtual_stat(const char *path, struct stat *buf TSRMLS_DC) CWD_API int virtual_stat(const char *path, struct stat *buf TSRMLS_DC)
{ {
cwd_state new_state; 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); CWD_STATE_FREE(&new_state);
return retval; 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_API int virtual_lstat(const char *path, struct stat *buf TSRMLS_DC)
{ {
cwd_state new_state; 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); CWD_STATE_FREE(&new_state);
return retval; return retval;
} }
#endif #endif
CWD_API int virtual_unlink(const char *path TSRMLS_DC) CWD_API int virtual_unlink(const char *path TSRMLS_DC)
@ -697,7 +755,69 @@ CWD_API DIR *virtual_opendir(const char *pathname TSRMLS_DC)
return retval; 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)
{
char prev_cwd[MAXPATHLEN];
char *getcwd_result;
FILE *retval;
getcwd_result = getcwd(prev_cwd, MAXPATHLEN);
if (!getcwd_result) {
return NULL;
}
#ifdef ZTS
tsrm_mutex_lock(cwd_mutex);
#endif
chdir(CWDG(cwd).cwd);
retval = popen(command, type);
chdir(prev_cwd);
#ifdef ZTS
tsrm_mutex_unlock(cwd_mutex);
#endif
return retval;
}
#elif defined(NETWARE)
/* 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)
{
char prev_cwd[MAXPATHLEN];
char *getcwd_result;
FILE *retval;
getcwd_result = VCWD_GETCWD(prev_cwd, MAXPATHLEN);
if (!getcwd_result) {
return NULL;
}
#ifdef ZTS
tsrm_mutex_lock(cwd_mutex);
#endif
VCWD_CHDIR(CWDG(cwd).cwd);
retval = popen(command, type);
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) CWD_API FILE *virtual_popen(const char *command, const char *type TSRMLS_DC)
{ {
@ -733,37 +853,6 @@ CWD_API FILE *virtual_popen(const char *command, const char *type TSRMLS_DC)
return retval; return retval;
} }
#else
/* 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)
{
char prev_cwd[MAXPATHLEN];
char *getcwd_result;
FILE *retval;
getcwd_result = getcwd(prev_cwd, MAXPATHLEN);
if (!getcwd_result) {
return NULL;
}
#ifdef ZTS
tsrm_mutex_lock(cwd_mutex);
#endif
chdir(CWDG(cwd).cwd);
retval = popen(command, type);
chdir(prev_cwd);
#ifdef ZTS
tsrm_mutex_unlock(cwd_mutex);
#endif
return retval;
}
#endif #endif

View File

@ -58,6 +58,19 @@ typedef unsigned short mode_t;
#define IS_UNC_PATH(path, len) \ #define IS_UNC_PATH(path, len) \
(len >= 2 && IS_SLASH(path[0]) && IS_SLASH(path[1])) (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 #else
#ifdef HAVE_DIRENT_H #ifdef HAVE_DIRENT_H
#include <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_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_creat(const char *path, mode_t mode TSRMLS_DC);
CWD_API int virtual_rename(char *oldname, char *newname 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); 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); CWD_API int virtual_lstat(const char *path, struct stat *buf TSRMLS_DC);
#endif #endif
CWD_API int virtual_unlink(const char *path TSRMLS_DC); 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); CWD_API int virtual_utime(const char *filename, struct utimbuf *buf TSRMLS_DC);
#endif #endif
CWD_API int virtual_chmod(const char *filename, mode_t mode TSRMLS_DC); 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); CWD_API int virtual_chown(const char *filename, uid_t owner, gid_t group TSRMLS_DC);
#endif #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_REALPATH(path, real_path) virtual_realpath(path, real_path TSRMLS_CC)
#define VCWD_RENAME(oldname, newname) virtual_rename(oldname, newname TSRMLS_CC) #define VCWD_RENAME(oldname, newname) virtual_rename(oldname, newname TSRMLS_CC)
#define VCWD_STAT(path, buff) virtual_stat(path, buff 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) #define VCWD_LSTAT(path, buff) virtual_stat(path, buff TSRMLS_CC)
#else #else
#define VCWD_LSTAT(path, buff) virtual_lstat(path, buff TSRMLS_CC) #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) #define VCWD_UTIME(path, time) virtual_utime(path, time TSRMLS_CC)
#endif #endif
#define VCWD_CHMOD(path, mode) virtual_chmod(path, mode TSRMLS_CC) #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) #define VCWD_CHOWN(path, owner, group) virtual_chown(path, owner, group TSRMLS_CC)
#endif #endif
@ -205,7 +222,7 @@ typedef struct _virtual_cwd_globals {
#define VCWD_OPENDIR(pathname) opendir(pathname) #define VCWD_OPENDIR(pathname) opendir(pathname)
#define VCWD_POPEN(command, type) popen(command, type) #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) #define VCWD_REALPATH(path, real_path) realpath(path, real_path)
#else #else
#define VCWD_REALPATH(path, real_path) strcpy(real_path, path) #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) #define VCWD_UTIME(path, time) utime(path, time)
#endif #endif
#define VCWD_CHMOD(path, mode) chmod(path, mode) #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) #define VCWD_CHOWN(path, owner, group) chown(path, owner, group)
#endif #endif

1
netware/mktemp.h Normal file
View File

@ -0,0 +1 @@
char* mktemp(char* templateStr);

138
netware/sys/stat.h Normal file
View File

@ -0,0 +1,138 @@
#ifndef __sys_stat_h__
#define __sys_stat_h__
/*============================================================================
= Novell Software Development Kit
=
= Copyright (C) 1999-2002 Novell, Inc. All Rights Reserved.
=
= This work is subject to U.S. and international copyright laws and treaties.
= Use and redistribution of this work is subject to the license agreement
= accompanying the software development kit (SDK) that contains this work.
= However, no part of this work may be revised and/or modified without the
= prior written consent of Novell, Inc. Any use or exploitation of this work
= without authorization could subject the perpetrator to criminal and civil
= liability.
=
= Source(s): ISO/IEC (POSIX) 9845:1996
=
= sys/stat.h
==============================================================================
*/
#include <time.h>
#include <stddef.h>
#include <sys/mode.h>
#include <sys/time.h>
#include <pshpack1.h>
#ifdef CLIB_STAT_PATCH /* Venkat (7/2/02) */
/***************** stat structure taken from CLib and modified ***************/
struct stat
{
long st_dev; /* volume number */ /* dev_t replaced by long : Venkat (19/3/02) */
MACHINE_WORD st_ino; /* directory entry number of the st_name */ /* ino_t replaced by MACHINE_WORD : Venkat (19/3/02) */
unsigned short st_mode; /* emulated file mode */
unsigned short st_pad1; /* reserved for alignment */
unsigned long st_nlink; /* count of hard links (always 1) */
unsigned long st_uid; /* object id of owner */
unsigned long st_gid; /* group-id (always 0) */
long st_rdev; /* device type (always 0) */ /* dev_t replaced by long : Venkat (19/3/02) */
off_t st_size; /* total file size--files only */
time_t st_atime; /* last access date--files only */
time_t st_mtime; /* last modify date and time */
time_t st_ctime; /* POSIX: last status change time... */
/* ...NetWare: creation date/time */
time_t st_btime; /* last archived date and time */
unsigned long st_attr; /* file attributes */
unsigned long st_archivedID; /* user/object ID of last archive */
unsigned long st_updatedID; /* user/object ID of last update */
unsigned short st_inheritedRightsMask; /* inherited rights mask */
unsigned short st_pad2; /* reserved for alignment */
unsigned int st_originatingNameSpace; /* namespace of creation */
size_t st_blksize; /* block size for allocation--files only */
size_t st_blocks; /* count of blocks allocated to file */
unsigned int st_flags; /* user-defined flags */
unsigned long st_spare[4]; /* for future use */
unsigned char st_name[255+1];/* TARGET_NAMESPACE name */
};
/***************** stat structure taken from CLib and modified ***************/
struct stat_libc
{
uint32_t st_userspec; /* untouched by stat() */
uint32_t st_flags; /* flags for this entry */
mode_t st_mode; /* emulated file mode */
uint32_t st_spare1;
uint64_t st_gen; /* generation number of inode */
ino_t st_ino; /* directory entry number */
dev_t st_dev; /* volume number */
dev_t st_rdev; /* device type (always 0) */
off64_t st_size; /* total file size */
uint64_t st_spare2;
blkcnt_t st_blocks; /* count of blocks allocated to file */
blksize_t st_blksize; /* block size for allocation--files only */
nlink_t st_nlink; /* count of hard links (always 1) */
uint32_t st_spare3[3];
uid_t st_uid; /* owner (object) identity */
gid_t st_gid; /* group-id (always 0) */
uid_t st_bid; /* identity of last archiver */
uid_t st_mid; /* identity of last updator */
timespec_t st_atime; /* last access date--files only */
timespec_t st_mtime; /* last modify date and time */
timespec_t st_ctime; /* last file attributes modification */
timespec_t st_btime; /* last archived date and time */
uint64_t st_spare4[44];
}; /* sizeof(struct dirent) == 0x200 (512.) */
#else
struct stat
{
uint32_t st_userspec; /* untouched by stat() */
uint32_t st_flags; /* flags for this entry */
mode_t st_mode; /* emulated file mode */
uint32_t st_spare1;
uint64_t st_gen; /* generation number of inode */
ino_t st_ino; /* directory entry number */
dev_t st_dev; /* volume number */
dev_t st_rdev; /* device type (always 0) */
off64_t st_size; /* total file size */
uint64_t st_spare2;
blkcnt_t st_blocks; /* count of blocks allocated to file */
blksize_t st_blksize; /* block size for allocation--files only */
nlink_t st_nlink; /* count of hard links (always 1) */
uint32_t st_spare3[3];
uid_t st_uid; /* owner (object) identity */
gid_t st_gid; /* group-id (always 0) */
uid_t st_bid; /* identity of last archiver */
uid_t st_mid; /* identity of last updator */
timespec_t st_atime; /* last access date--files only */
timespec_t st_mtime; /* last modify date and time */
timespec_t st_ctime; /* last file attributes modification */
timespec_t st_btime; /* last archived date and time */
uint64_t st_spare4[44];
}; /* sizeof(struct dirent) == 0x200 (512.) */
#endif
#include <poppack.h>
#ifdef __cplusplus
extern "C"
{
#endif
int chmod ( const char *path, mode_t mode );
int fchmod( int fildes, mode_t mode );
int fstat ( int fildes, struct stat *buf );
int mkdir ( const char *pathname, mode_t mode );
int mkfifo( const char *pathname, mode_t mode );
int stat ( const char *path, struct stat *buf );
mode_t umask ( mode_t cmask );
#ifdef __cplusplus
}
#endif
#define stat64 stat /* same structure and function do both */
#define fstat64 fstat /* same function does both */
#endif

View File

@ -33,23 +33,15 @@ ifndef BINARY
endif endif
# Compile flags # Compile flags
#C_FLAGS = -c -maxerrors 25 -processor Pentium -align packed
#C_FLAGS += -w on -cpp_exceptions on -wchar_t off -bool on
#C_FLAGS += -msgstyle gcc -ext obj -ARM on -msext off -ansi off -nostdinc
C_FLAGS = -c -maxerrors 25 -msgstyle gcc C_FLAGS = -c -maxerrors 25 -msgstyle gcc
C_FLAGS += -wchar_t on -bool on C_FLAGS += -wchar_t on -bool on
C_FLAGS += -processor Pentium -align 1 C_FLAGS += -processor Pentium -align 1
#C_FLAGS += -r
C_FLAGS += -nostdinc C_FLAGS += -nostdinc
#C_FLAGS += -ext obj
#C_FLAGS += -DNLM_PLATFORM -D__GNUC__ -DTSRM_EXPORTS -D_LIB
C_FLAGS += -DZTS -DNETWARE -DHAVE_DIRENT_H C_FLAGS += -DZTS -DNETWARE -DHAVE_DIRENT_H
C_FLAGS += -DNEW_LIBC
#C_FLAGS += -DUSE_PIPE_OPEN #C_FLAGS += -DUSE_PIPE_OPEN
C_FLAGS += -DUSE_MKFIFO C_FLAGS += -DUSE_MKFIFO
C_FLAGS += -DCLIB_STAT_PATCH -DUSE_MPK C_FLAGS += -DCLIB_STAT_PATCH -DUSE_MPK
#C_FLAGS += -I. -I- -I../netware -I$(SDK_DIR)/sdk # ../netware added for special SYS/STAT.H : Venkat(6/2/02) C_FLAGS += -I. -I- -I../netware -I$(SDK_DIR)/include # ../netware added for special SYS/STAT.H
C_FLAGS += -I. -I- -I../netware -I$(SDK_DIR)/include # ../netware added for special SYS/STAT.H : Venkat(6/2/02)
C_FLAGS += -I$(MPK_DIR)/include1 C_FLAGS += -I$(MPK_DIR)/include1
C_FLAGS += -I$(MWCIncludes) C_FLAGS += -I$(MWCIncludes)
@ -88,14 +80,6 @@ $(OBJ_DIR)/%.d: %.c
@echo Building Dependencies for $(<F) @echo Building Dependencies for $(<F)
@$(CC) -M $< $(C_FLAGS) -o $@ @$(CC) -M $< $(C_FLAGS) -o $@
$(OBJ_DIR)/%.d: %.cpp
@echo Building Dependencies for $(<F)
@$(CC) -M $< $(C_FLAGS) -o $@
$(OBJ_DIR)/%.obj: %.cpp
@echo Compiling $?...
@$(CC) $< $(C_FLAGS) -o $@
$(OBJ_DIR)/%.obj: %.c $(OBJ_DIR)/%.obj: %.c
@echo Compiling $?... @echo Compiling $?...
@$(CC) $< $(C_FLAGS) -o $@ @$(CC) $< $(C_FLAGS) -o $@