25 changed files with 1668 additions and 167 deletions
-
8netware/ZendEngine2.mak
-
31netware/grp.h
-
93netware/libpq.imp
-
87netware/mktemp.c
-
20netware/param.h
-
5netware/php-nw.bat
-
30netware/php4apache.mak
-
166netware/php4apache2filter.mak
-
163netware/php4cli.mak
-
38netware/phplib.imp
-
118netware/phplib.mak
-
1netware/phptest.ncf
-
329netware/pipe.c
-
11netware/pipe.h
-
45netware/postgres_ext.h
-
86netware/pwd.c
-
15netware/pwd.h
-
73netware/start.c
-
114netware/sysexits.h
-
246netware/time_nw.c
-
57netware/time_nw.h
-
21netware/tsrm.mak
-
17netware/wfile.c
-
16netware/wfile.h
-
45netware/zend.mak
@ -0,0 +1,31 @@ |
|||
/* pwd.h - Try to approximate UN*X's getuser...() functions under MS-DOS. |
|||
Copyright (C) 1990 by Thorsten Ohl, td12@ddagsi3.bitnet |
|||
|
|||
This program is free software; you can redistribute it and/or modify |
|||
it under the terms of the GNU General Public License as published by |
|||
the Free Software Foundation; either version 1, or (at your option) |
|||
any later version. |
|||
|
|||
This program is distributed in the hope that it will be useful, |
|||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
GNU General Public License for more details. |
|||
|
|||
You should have received a copy of the GNU General Public License |
|||
along with this program; if not, write to the Free Software |
|||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
|||
|
|||
$Header$ |
|||
*/ |
|||
|
|||
/* This 'implementation' is conjectured from the use of this functions in |
|||
the RCS and BASH distributions. Of course these functions don't do too |
|||
much useful things under MS-DOS, but using them avoids many "#ifdef |
|||
MSDOS" in ported UN*X code ... */ |
|||
|
|||
struct group { |
|||
char *gr_name; /* group name */ |
|||
char *gr_passwd; /* group password */ |
|||
int gr_gid; /* group id */ |
|||
char **gr_mem; /* group members */ |
|||
}; |
|||
@ -0,0 +1,93 @@ |
|||
lo_open, |
|||
lo_close, |
|||
lo_read, |
|||
lo_write, |
|||
lo_lseek, |
|||
lo_creat, |
|||
lo_tell, |
|||
lo_unlink, |
|||
lo_import, |
|||
lo_export, |
|||
PQconnectdb, |
|||
PQconnectStart, |
|||
PQconndefaults, |
|||
PQsetdbLogin, |
|||
PQconnectPoll, |
|||
PQfinish, |
|||
PQreset, |
|||
PQresetStart, |
|||
PQresetPoll, |
|||
PQrequestCancel, |
|||
PQconninfoFree, |
|||
PQdb, |
|||
PQuser, |
|||
PQpass, |
|||
PQhost, |
|||
PQport, |
|||
PQtty, |
|||
PQoptions, |
|||
PQstatus, |
|||
PQerrorMessage, |
|||
PQsocket, |
|||
PQbackendPID, |
|||
PQclientEncoding, |
|||
PQsetClientEncoding, |
|||
PQtrace, |
|||
PQuntrace, |
|||
PQsetNoticeProcessor, |
|||
PQmakeEmptyPGresult, |
|||
PQclear, |
|||
PQsendQuery, |
|||
PQconsumeInput, |
|||
PQisBusy, |
|||
PQgetResult, |
|||
PQexec, |
|||
PQnotifies, |
|||
PQgetline, |
|||
PQgetlineAsync, |
|||
PQputline, |
|||
PQputnbytes, |
|||
PQendcopy, |
|||
PQfn, |
|||
PQresultStatus, |
|||
PQresStatus, |
|||
PQresultErrorMessage, |
|||
PQntuples, |
|||
PQnfields, |
|||
PQbinaryTuples, |
|||
PQfname, |
|||
PQfnumber, |
|||
PQftype, |
|||
PQfsize, |
|||
PQfmod, |
|||
PQcmdStatus, |
|||
PQoidStatus, |
|||
PQoidValue, |
|||
PQcmdTuples, |
|||
PQgetvalue, |
|||
PQgetlength, |
|||
PQgetisnull, |
|||
PQsetnonblocking, |
|||
PQisnonblocking, |
|||
PQflush, |
|||
PQmblen, |
|||
PQenv2encoding, |
|||
PQprint, |
|||
PQdisplayTuples, |
|||
PQprintTuples, |
|||
pg_valid_client_encoding, |
|||
pg_valid_server_encoding, |
|||
pg_char_to_encname_struct, |
|||
pg_char_to_encoding, |
|||
pg_encoding_to_char, |
|||
createPQExpBuffer, |
|||
initPQExpBuffer, |
|||
destroyPQExpBuffer, |
|||
termPQExpBuffer, |
|||
resetPQExpBuffer, |
|||
enlargePQExpBuffer, |
|||
printfPQExpBuffer, |
|||
appendPQExpBuffer, |
|||
appendPQExpBufferStr, |
|||
appendPQExpBufferChar, |
|||
appendBinaryPQExpBuffer |
|||
@ -0,0 +1,87 @@ |
|||
|
|||
#include <string.h> |
|||
#include <errno.h> |
|||
#include <unistd.h> |
|||
|
|||
|
|||
/* Based on standard ANSI C mktemp() for NetWare */ |
|||
char* mktemp(char* templateStr) |
|||
{ |
|||
char* pXs = NULL; |
|||
char numBuf[50] = {'\0'}; |
|||
int count = 0; |
|||
char* pPid = NULL; |
|||
|
|||
char termChar = '\0'; |
|||
char letter = 'a'; |
|||
char letter1 = 'a'; |
|||
|
|||
if (templateStr && (pXs = strstr(templateStr, "XXXXXX"))) |
|||
{ |
|||
/* Generate temp name */ |
|||
termChar = pXs[6]; |
|||
ltoa(NXThreadGetId(), numBuf, 16); |
|||
numBuf[strlen(numBuf)-1] = '\0'; |
|||
|
|||
/* |
|||
Beware! thread IDs are 8 hex digits on NW 4.11 and only the |
|||
lower digits seem to change, whereas on NW 5 they are in the |
|||
range of < 1000 hex or 3 hex digits in length. So the following |
|||
logic ensures we use the least significant portion of the number.\ |
|||
*/ |
|||
if (strlen(numBuf) > 5) |
|||
pPid = &numBuf[strlen(numBuf)-5]; |
|||
else |
|||
pPid = numBuf; |
|||
|
|||
/* |
|||
Temporary files, as the name suggests, are temporarily used and then |
|||
cleaned up after usage. In the case of complex scripts, new temp files |
|||
may be created before the old ones are deleted. So, we need to have |
|||
a provision to create many temp files. It is found that provision for |
|||
26 files may not be enough in such cases. Hence the logic below. |
|||
|
|||
The logic below allows 26 files (like, pla00015.tmp through plz00015.tmp) |
|||
plus 6x26=676 (like, plaa0015.tmp through plzz0015.tmp) |
|||
*/ |
|||
letter = 'a'; |
|||
do |
|||
{ |
|||
sprintf(pXs, (char *)"%c%05.5s", letter, pPid); |
|||
pXs[6] = termChar; |
|||
|
|||
if (access(templateStr, 0) != 0) |
|||
return templateStr; /* File does not exist */ |
|||
|
|||
letter++; |
|||
} while (letter <= 'z'); |
|||
|
|||
letter1 = 'a'; |
|||
do |
|||
{ |
|||
letter = 'a'; |
|||
|
|||
do |
|||
{ |
|||
sprintf(pXs, (char *)"%c%c%04.5s", letter1, letter, pPid); |
|||
pXs[6] = termChar; |
|||
|
|||
if (access(templateStr, 0) != 0) |
|||
return templateStr; /* File does not exist */ |
|||
|
|||
letter++; |
|||
} while (letter <= 'z'); |
|||
|
|||
letter1++; |
|||
} while (letter1 <= 'z'); |
|||
|
|||
errno = ENOENT; |
|||
return NULL; |
|||
} |
|||
else |
|||
{ |
|||
errno = EINVAL; |
|||
return NULL; |
|||
} |
|||
} |
|||
|
|||
@ -0,0 +1,20 @@ |
|||
|
|||
/***************************************************************************** |
|||
* * |
|||
* sys/param.c * |
|||
* * |
|||
* Freely redistributable and modifiable. Use at your own risk. * |
|||
* * |
|||
* Copyright 1994 The Downhill Project * |
|||
* * |
|||
*****************************************************************************/ |
|||
#ifndef MAXPATHLEN |
|||
/*#define MAXPATHLEN _MAX_PATH*/ |
|||
#define MAXPATHLEN 260 /* _MAX_PATH defined in STDLIB.H for Windows; picked up the value from there */ |
|||
#define _MAX_PATH 260 /* Defined since it is used in os.c while compiling apache */ |
|||
#endif |
|||
#define MAXHOSTNAMELEN 64 |
|||
#define howmany(x,y) (((x)+((y)-1))/(y)) |
|||
#define roundup(x,y) ((((x)+((y)-1))/(y))*(y)) |
|||
|
|||
#define _MAX_VOLUME 31 /* Defined since it is used in os.c while compiling apache. The value picked up from LibC */ |
|||
@ -0,0 +1,166 @@ |
|||
# Temporarily here -- later may go into some batch file
|
|||
# which will set this as an environment variable
|
|||
PROJECT_ROOT = ../.. |
|||
|
|||
# Module details
|
|||
MODULE_NAME = mod_php |
|||
MODULE_DESC = "PHP 4.3 - Apache 2.0 Module" |
|||
VMAJ = 3 |
|||
VMIN = 0 |
|||
VREV = 0 |
|||
|
|||
#include the common settings
|
|||
include $(PROJECT_ROOT)/netware/common.mif |
|||
|
|||
# Extensions of all input and output files
|
|||
.SUFFIXES: |
|||
.SUFFIXES: .nlm .lib .obj .cpp .c .msg .mlc .mdb .xdc .d |
|||
|
|||
# Source files
|
|||
C_SRC = apache_config.c \
|
|||
php_functions.c \
|
|||
sapi_apache2.c |
|||
|
|||
# Destination directories and files
|
|||
OBJ_DIR = $(BUILD) |
|||
FINAL_DIR = $(BUILD) |
|||
MAP_FILE = $(FINAL_DIR)\$(MODULE_NAME).map |
|||
OBJECTS = $(addprefix $(OBJ_DIR)/,$(CPP_SRC:.cpp=.obj) $(C_SRC:.c=.obj)) |
|||
DEPDS = $(addprefix $(OBJ_DIR)/,$(CPP_SRC:.cpp=.d) $(C_SRC:.c=.d)) |
|||
|
|||
# Binary file
|
|||
ifndef BINARY |
|||
BINARY=$(FINAL_DIR)\$(MODULE_NAME).nlm |
|||
endif |
|||
|
|||
|
|||
# Compile flags
|
|||
C_FLAGS += -c -maxerrors 25 -msgstyle gcc |
|||
C_FLAGS += -wchar_t on -bool on |
|||
C_FLAGS += -processor Pentium |
|||
C_FLAGS += -w nounusedarg -msext on |
|||
C_FLAGS += -nostdinc |
|||
C_FLAGS += -relax_pointers # To remove type-casting errors |
|||
C_FLAGS += -DNETWARE |
|||
C_FLAGS += -DZTS |
|||
C_FLAGS += -DNLM_PLATFORM |
|||
C_FLAGS += -DN_PLAT_NLM -DNLM=1 -D__NO_MATH_OPS |
|||
C_FLAGS += -D__C9X_CMATH_INLINES_DEFINED -DAPACHE_OS_H -DNO_USE_SIGACTION -DMULTITHREAD |
|||
C_FLAGS += -DCLIB_STAT_PATCH |
|||
C_FLAGS += -DNEW_LIBC |
|||
C_FLAGS += -I. -I- -I. -I../../netware -I$(SDK_DIR)/include # ../../netware added for special SYS/STAT.H |
|||
C_FLAGS += -I$(SDK_DIR)/include/winsock # For Apache 2.0 headers |
|||
C_FLAGS += -I$(MWCIncludes) |
|||
C_FLAGS += -I$(APACHE_DIR)/include |
|||
C_FLAGS += -I- -I../../main -I../../Zend -I../../TSRM -I../../ext/standard |
|||
C_FLAGS += -I../../ -I../../netware -I$(PROJECT_ROOT)/regex |
|||
C_FLAGS += -I$(WINSOCK_DIR)/include/nlm -I$(WINSOCK_DIR)/include |
|||
|
|||
|
|||
# Extra stuff based on debug / release builds
|
|||
ifeq '$(BUILD)' 'debug' |
|||
SYM_FILE = $(FINAL_DIR)\$(MODULE_NAME).sym |
|||
C_FLAGS += -inline smart -sym on -sym codeview4 -opt off -opt intrinsics -sym internal -DDEBUGGING -DDKFBPON |
|||
C_FLAGS += -r -DZEND_DEBUG=1 |
|||
C_FLAGS += -exc cw |
|||
LD_FLAGS += -sym on -sym codeview4 -sym internal -osym $(SYM_FILE) |
|||
LD_FLAGS += -msgstyle std |
|||
export MWLibraryFiles=$(SDK_DIR)/imports/libcpre.o;mwcrtld.lib |
|||
else |
|||
C_FLAGS += -opt speed -inline on -inline smart -inline auto -sym off -DZEND_DEBUG=0 |
|||
C_FLAGS += -opt intrinsics |
|||
C_FLAGS += -opt level=4 |
|||
LD_FLAGS += -sym off |
|||
export MWLibraryFiles=$(SDK_DIR)/imports/libcpre.o;mwcrtl.lib |
|||
endif |
|||
|
|||
# Dependencies
|
|||
MODULE = LibC \
|
|||
phplib |
|||
IMPORT = @$(SDK_DIR)/imports/libc.imp \
|
|||
@$(APACHE_DIR)/lib/httpd.imp \
|
|||
@$(APACHE_DIR)/lib/aprlib.imp \
|
|||
@$(PROJECT_ROOT)/netware/phplib.imp |
|||
EXPORT = php4_module |
|||
|
|||
|
|||
# Virtual paths
|
|||
vpath %.cpp . |
|||
vpath %.c . |
|||
vpath %.obj $(OBJ_DIR) |
|||
|
|||
|
|||
all: prebuild project |
|||
|
|||
.PHONY: all |
|||
|
|||
prebuild: |
|||
@if not exist $(OBJ_DIR) md $(OBJ_DIR) |
|||
|
|||
project: $(BINARY) $(MESSAGE) |
|||
@echo Build complete. |
|||
|
|||
|
|||
$(OBJ_DIR)/%.d: %.c |
|||
@echo Building Dependencies for $(<F) |
|||
@$(CC) -M $< $(C_FLAGS) -o $@ |
|||
|
|||
$(OBJ_DIR)/%.obj: %.c |
|||
@echo Compiling $?... |
|||
@$(CC) $< $(C_FLAGS) -o $@ |
|||
|
|||
|
|||
$(BINARY): $(OBJECTS) |
|||
@echo Import $(IMPORT) > $(basename $@).def |
|||
ifdef API |
|||
@echo Import $(API) >> $(basename $@).def |
|||
endif |
|||
@echo Module $(MODULE) >> $(basename $@).def |
|||
ifdef EXPORT |
|||
@echo Export $(EXPORT) >> $(basename $@).def |
|||
endif |
|||
@echo AutoUnload >> $(basename $@).def |
|||
ifeq '$(BUILD)' 'debug' |
|||
@echo Debug >> $(basename $@).def |
|||
endif |
|||
@echo Flag_On 0x00000008 >> $(basename $@).def |
|||
@echo Start _lib_start >> $(basename $@).def |
|||
@echo Exit _lib_stop >> $(basename $@).def |
|||
|
|||
$(MPKTOOL) $(XDCFLAGS) $(basename $@).xdc |
|||
@echo xdcdata $(basename $@).xdc >> $(basename $@).def |
|||
|
|||
@echo Linking $@... |
|||
@echo $(LD_FLAGS) -commandfile $(basename $@).def > $(basename $@).link |
|||
ifdef LIBRARY |
|||
@echo $(LIBRARY) >> $(basename $@).link |
|||
endif |
|||
@echo $(OBJECTS) $(APACHE_DIR)/lib/libpre.obj >> $(basename $@).link |
|||
|
|||
@$(LINK) @$(basename $@).link |
|||
|
|||
|
|||
.PHONY: clean |
|||
clean: cleanobj cleanbin |
|||
|
|||
.PHONY: cleand |
|||
cleand: |
|||
@echo Deleting all dependency files... |
|||
-@del "$(OBJ_DIR)\*.d" |
|||
|
|||
.PHONY: cleanobj |
|||
cleanobj: |
|||
@echo Deleting all object files... |
|||
-@del "$(OBJ_DIR)\*.obj" |
|||
|
|||
.PHONY: cleanbin |
|||
cleanbin: |
|||
@echo Deleting binary files... |
|||
-@del "$(FINAL_DIR)\$(MODULE_NAME).nlm" |
|||
@echo Deleting MAP, DEF files, etc.... |
|||
-@del "$(FINAL_DIR)\$(MODULE_NAME).map" |
|||
-@del "$(FINAL_DIR)\$(MODULE_NAME).def" |
|||
-@del "$(FINAL_DIR)\$(MODULE_NAME).link" |
|||
ifeq '$(BUILD)' 'debug' |
|||
-@del $(FINAL_DIR)\$(MODULE_NAME).sym |
|||
endif |
|||
@ -0,0 +1,163 @@ |
|||
# Temporarily here -- later may go into some batch file
|
|||
# which will set this as an environment variable
|
|||
PROJECT_ROOT = ../.. |
|||
|
|||
# Module details
|
|||
MODULE_NAME = php |
|||
MODULE_DESC = "PHP 4.2.3 - Command Line Interface" |
|||
VMAJ = 2 |
|||
VMIN = 0 |
|||
VREV = 0 |
|||
|
|||
#include the common settings
|
|||
include $(PROJECT_ROOT)/netware/common.mif |
|||
|
|||
# Extensions of all input and output files
|
|||
.SUFFIXES: |
|||
.SUFFIXES: .nlm .lib .obj .cpp .c .msg .mlc .mdb .xdc .d |
|||
|
|||
# Source files
|
|||
C_SRC = getopt.c \
|
|||
php_cli.c |
|||
|
|||
# Library files
|
|||
LIBRARY = |
|||
|
|||
# Destination directories and files
|
|||
OBJ_DIR = $(BUILD) |
|||
FINAL_DIR = $(BUILD) |
|||
MAP_FILE = $(FINAL_DIR)\$(MODULE_NAME).map |
|||
OBJECTS = $(addprefix $(OBJ_DIR)/,$(CPP_SRC:.cpp=.obj) $(C_SRC:.c=.obj)) |
|||
DEPDS = $(addprefix $(OBJ_DIR)/,$(CPP_SRC:.cpp=.d) $(C_SRC:.c=.d)) |
|||
|
|||
# Binary file
|
|||
ifndef BINARY |
|||
BINARY=$(FINAL_DIR)\$(MODULE_NAME).nlm |
|||
endif |
|||
|
|||
|
|||
# Compile flags
|
|||
C_FLAGS += -c -maxerrors 25 -msgstyle gcc |
|||
C_FLAGS += -wchar_t on -bool on |
|||
C_FLAGS += -processor Pentium |
|||
C_FLAGS += -w nounusedarg -msext on |
|||
C_FLAGS += -nostdinc |
|||
C_FLAGS += -relax_pointers # To remove type-casting errors |
|||
C_FLAGS += -DNETWARE -DTHREAD_SWITCH |
|||
C_FLAGS += -DZTS |
|||
C_FLAGS += -DNLM_PLATFORM |
|||
C_FLAGS += -DN_PLAT_NLM -DNLM=1 -D__NO_MATH_OPS |
|||
C_FLAGS += -D__C9X_CMATH_INLINES_DEFINED -DAPACHE_OS_H -DNO_USE_SIGACTION -DMULTITHREAD |
|||
C_FLAGS += -DNEW_LIBC |
|||
C_FLAGS += -I. -I- -I. -I../../netware -I$(SDK_DIR)/include # ../../netware added for special SYS/STAT.H |
|||
C_FLAGS += -I$(MWCIncludes) |
|||
C_FLAGS += -I- -I../../main -I../../Zend -I../../TSRM -I../../ext/standard |
|||
C_FLAGS += -I../../ -I../../netware -I$(PROJECT_ROOT)/regex |
|||
C_FLAGS += -I$(WINSOCK_DIR)/include/nlm -I$(WINSOCK_DIR)/include |
|||
|
|||
# Extra stuff based on debug / release builds
|
|||
ifeq '$(BUILD)' 'debug' |
|||
SYM_FILE = $(FINAL_DIR)\$(MODULE_NAME).sym |
|||
C_FLAGS += -inline smart -sym on -sym codeview4 -opt off -opt intrinsics -sym internal -DDEBUGGING -DDKFBPON |
|||
C_FLAGS += -r -DZEND_DEBUG=1 |
|||
C_FLAGS += -exc cw |
|||
LD_FLAGS += -sym on -sym codeview4 -sym internal -osym $(SYM_FILE) |
|||
export MWLibraryFiles=$(SDK_DIR)/imports/libcpre.o;mwcrtld.lib |
|||
else |
|||
C_FLAGS += -opt speed -inline on -inline smart -inline auto -sym off -DZEND_DEBUG=0 |
|||
C_FLAGS += -opt intrinsics |
|||
C_FLAGS += -opt level=4 |
|||
LD_FLAGS += -sym off |
|||
export MWLibraryFiles=$(SDK_DIR)/imports/libcpre.o;mwcrtl.lib |
|||
endif |
|||
|
|||
|
|||
# Dependencies
|
|||
MODULE = LibC \
|
|||
phplib |
|||
IMPORT = @$(SDK_DIR)/imports/libc.imp \
|
|||
@$(PROJECT_ROOT)/netware/phplib.imp |
|||
EXPORT = |
|||
API = |
|||
|
|||
|
|||
# Virtual paths
|
|||
vpath %.cpp . |
|||
vpath %.c . |
|||
vpath %.obj $(OBJ_DIR) |
|||
|
|||
|
|||
all: prebuild project |
|||
|
|||
.PHONY: all |
|||
|
|||
prebuild: |
|||
@if not exist $(OBJ_DIR) md $(OBJ_DIR) |
|||
|
|||
project: $(BINARY) $(MESSAGE) |
|||
@echo Build complete. |
|||
|
|||
|
|||
$(OBJ_DIR)/%.d: %.c |
|||
@echo Building Dependencies for $(<F) |
|||
@$(CC) -M $< $(C_FLAGS) -o $@ |
|||
|
|||
$(OBJ_DIR)/%.obj: %.c |
|||
@echo Compiling $?... |
|||
@$(CC) $< $(C_FLAGS) -o $@ |
|||
|
|||
|
|||
$(BINARY): $(OBJECTS) |
|||
@echo Import $(IMPORT) > $(basename $@).def |
|||
ifdef API |
|||
@echo Import $(API) >> $(basename $@).def |
|||
endif |
|||
@echo Module $(MODULE) >> $(basename $@).def |
|||
ifdef EXPORT |
|||
@echo Export $(EXPORT) >> $(basename $@).def |
|||
endif |
|||
@echo AutoUnload >> $(basename $@).def |
|||
ifeq '$(BUILD)' 'debug' |
|||
@echo Debug >> $(basename $@).def |
|||
endif |
|||
@echo Flag_On 0x00000008 >> $(basename $@).def |
|||
@echo Start _LibCPrelude >> $(basename $@).def |
|||
@echo Exit _LibCPostlude >> $(basename $@).def |
|||
|
|||
$(MPKTOOL) $(XDCFLAGS) $(basename $@).xdc |
|||
@echo xdcdata $(basename $@).xdc >> $(basename $@).def |
|||
|
|||
@echo Linking $@... |
|||
@echo $(LD_FLAGS) -commandfile $(basename $@).def > $(basename $@).link |
|||
ifdef LIBRARY |
|||
@echo $(LIBRARY) >> $(basename $@).link |
|||
endif |
|||
@echo $(OBJECTS) >> $(basename $@).link |
|||
|
|||
@$(LINK) @$(basename $@).link |
|||
|
|||
|
|||
.PHONY: clean |
|||
clean: cleanobj cleanbin |
|||
|
|||
.PHONY: cleand |
|||
cleand: |
|||
@echo Deleting all dependency files... |
|||
-@del "$(OBJ_DIR)\*.d" |
|||
|
|||
.PHONY: cleanobj |
|||
cleanobj: |
|||
@echo Deleting all object files... |
|||
-@del "$(OBJ_DIR)\*.obj" |
|||
|
|||
.PHONY: cleanbin |
|||
cleanbin: |
|||
@echo Deleting binary files... |
|||
-@del "$(FINAL_DIR)\$(MODULE_NAME).nlm" |
|||
@echo Deleting MAP, DEF files, etc.... |
|||
-@del "$(FINAL_DIR)\$(MODULE_NAME).map" |
|||
-@del "$(FINAL_DIR)\$(MODULE_NAME).def" |
|||
-@del "$(FINAL_DIR)\$(MODULE_NAME).link" |
|||
ifeq '$(BUILD)' 'debug' |
|||
-@del $(FINAL_DIR)\$(MODULE_NAME).sym |
|||
endif |
|||
@ -0,0 +1 @@ |
|||
php -q run-tests.php > results.txt |
|||
@ -0,0 +1,329 @@ |
|||
/* |
|||
* FILENAME : pipe.c |
|||
* DESCRIPTION : Functions to implement pipes on NetWare. |
|||
* Author : Anantha Kesari H Y, Venkat Raghavan S, Srivathsa M |
|||
* |
|||
*/ |
|||
|
|||
#include <stdio.h> |
|||
#include <stdlib.h> |
|||
#include <string.h> |
|||
|
|||
#include "netware/pipe.h" |
|||
#include "netware/mktemp.h" |
|||
|
|||
|
|||
/* Following definitions unavailable in LibC, hence borrowed from CLib */ |
|||
#define P_WAIT 0 |
|||
#define P_NOWAIT 1 |
|||
|
|||
#define WHITESPACE " \t" |
|||
#define MAX_ARGS 10 |
|||
|
|||
|
|||
FILE* popen(const char* commandline, const char* mode) |
|||
{ |
|||
int err, count; |
|||
char pszPipestr[32] = {'\0'}; |
|||
char *command = NULL, *argv[MAX_ARGS] = {'\0'}; |
|||
int fd = -1; |
|||
fd_set myfds; |
|||
wiring_t wiring; |
|||
pid_t pid=0; |
|||
FILE *fp=NULL; |
|||
char *ptr = NULL; |
|||
int ptrLen = 0, argc = 0, i = 0; |
|||
|
|||
|
|||
/* Get a temporary name */ |
|||
(void) tmpnam(strecpy(pszPipestr, "PHP/php$pipe/")); |
|||
|
|||
wiring.infd=FD_UNUSED; |
|||
wiring.outfd=FD_UNUSED; |
|||
wiring.errfd=FD_UNUSED; |
|||
|
|||
/* Open a pipe */ |
|||
if ( *mode=='r') { |
|||
fd = pipe_open (pszPipestr, O_RDONLY); |
|||
if (fd == -1) |
|||
return NULL; |
|||
|
|||
wiring.outfd=fd; |
|||
} else if (*mode=='w') { |
|||
fd = pipe_open (pszPipestr, O_WRONLY); |
|||
if (fd == -1) |
|||
return NULL; |
|||
|
|||
wiring.infd=fd; |
|||
} else { |
|||
consoleprintf ("Unsupported pipe open mode \n"); |
|||
return NULL; |
|||
} |
|||
|
|||
/* Get the file pointer */ |
|||
fp = fdopen(fd, mode); |
|||
if (fp == NULL) { |
|||
consoleprintf ("Failure in fdopen \n"); |
|||
close (fd); |
|||
return NULL; |
|||
} |
|||
|
|||
/* Separate commandline string into words */ |
|||
ptr = strtok((char*)commandline, WHITESPACE); |
|||
ptrLen = strlen(ptr); |
|||
|
|||
/* Get the command */ |
|||
command = (char*)malloc(ptrLen + 1); |
|||
if(command == NULL) { |
|||
consoleprintf ("Failure in memory allocation \n"); |
|||
close (fd); |
|||
fclose (fp); |
|||
return NULL; |
|||
} |
|||
strcpy (command, ptr); |
|||
|
|||
/* Command as the first argument into prcessve */ |
|||
argv[argc] = (char*)malloc(ptrLen + 1); |
|||
if(argv[argc] == NULL) { |
|||
consoleprintf ("Failure in memory allocation \n"); |
|||
close (fd); |
|||
fclose (fp); |
|||
if(command) { |
|||
free(command); |
|||
command = NULL; |
|||
} |
|||
return NULL; |
|||
} |
|||
strcpy (argv[argc], ptr); |
|||
argc++; |
|||
|
|||
/* Get more arguments if any to be passed to prcessve */ |
|||
ptr = strtok(NULL, WHITESPACE); |
|||
while (ptr && (argc < MAX_ARGS)) |
|||
{ |
|||
ptrLen = strlen(ptr); |
|||
|
|||
argv[argc] = (char*)malloc(ptrLen + 1); |
|||
if(argv[argc] == NULL) { |
|||
consoleprintf ("Failure in memory allocation \n"); |
|||
close (fd); |
|||
fclose (fp); |
|||
if(command) { |
|||
free(command); |
|||
command = NULL; |
|||
} |
|||
return NULL; |
|||
} |
|||
strcpy (argv[argc], ptr); |
|||
argc++; |
|||
|
|||
ptr = strtok(NULL, WHITESPACE); |
|||
} |
|||
argv[argc] = NULL; |
|||
|
|||
FD_ZERO(&myfds); |
|||
FD_SET(fd, &myfds); |
|||
|
|||
pid = processve(command, PROC_CURRENT_SPACE, NULL, &wiring, |
|||
&myfds, NULL, (const char **)argv ); |
|||
if (pid == -1) { |
|||
consoleprintf ("Failure in processve call \n"); |
|||
close (fd); |
|||
fclose(fp); |
|||
if(command) { |
|||
free(command); |
|||
command = NULL; |
|||
} |
|||
for(i=0; i<argc; i++) { |
|||
if(argv[i]) { |
|||
free(argv[i]); |
|||
argv[i] = NULL; |
|||
} |
|||
} |
|||
return NULL; |
|||
} |
|||
|
|||
close (fd); |
|||
if(command) { |
|||
free(command); |
|||
command = NULL; |
|||
} |
|||
for(i=0; i<argc; i++) { |
|||
if(argv[i]) { |
|||
free(argv[i]); |
|||
argv[i] = NULL; |
|||
} |
|||
} |
|||
|
|||
return fp; |
|||
} |
|||
|
|||
|
|||
int pclose(FILE* stream) |
|||
{ |
|||
fclose(stream); |
|||
return 0; |
|||
} |
|||
|
|||
|
|||
|
|||
#if 0 |
|||
|
|||
FILE* popen2(const char* commandline, const char* mode) |
|||
{ |
|||
int err, count, var, replaced; |
|||
char **env, pszPipestr[32]; |
|||
NXVmId_t newVM; |
|||
NXExecEnvSpec_t envSpec; |
|||
char *command = NULL, *argv[MAX_ARGS] = {"\0"}; |
|||
NXHandle_t fd; |
|||
|
|||
fd = (NXHandle_t) -1; |
|||
|
|||
count = NXGetEnvCount() + 1; // (add one for NULL) |
|||
env = (char **) NXMemAlloc(sizeof(char *) * count, 0); |
|||
|
|||
if (!env) |
|||
return 0; |
|||
|
|||
err = NXCopyEnv(env, count); // ensure NULL added at end |
|||
if ( *mode='r'){ |
|||
(void) tmpnam(strecpy(pszPipestr, "PHPPIPE/stdin/")); |
|||
err = NXFifoOpen(0, pszPipestr, NX_O_RDONLY, 0, &fd); |
|||
if (err) |
|||
return 0; |
|||
|
|||
envSpec.esStdin.ssType = NX_OBJ_CONSOLE; |
|||
envSpec.esStdout.ssType = NX_OBJ_FIFO; |
|||
envSpec.esStdout.ssPath = pszPipestr; |
|||
} |
|||
else if (*mode='w') then{ |
|||
(void) tmpnam(strecpy(pszPipestr, "PHPPIPE/stdout/")); |
|||
err = NXFifoOpen(0, instr, NX_O_WRONLY, 0, &fd); |
|||
if (err) |
|||
return 0; |
|||
envSpec.esStdin.ssType = NX_OBJ_FIFO; |
|||
envSpec.esStdout.ssType = NX_OBJ_CONSOLE; |
|||
envSpec.esStdin.ssPath = pszPipestr; |
|||
} |
|||
else |
|||
consoleprintf ("Unsupported pipe open mode \n"); |
|||
|
|||
|
|||
/* Separate commandline string into words */ |
|||
|
|||
ptr = strtok((char*)commandline, WHITESPACE); |
|||
ptrLen = strlen(ptr); |
|||
|
|||
command = (char*)malloc(ptrLen + 1); |
|||
strcpy (command, ptr); |
|||
|
|||
ptr = strtok(NULL, WHITESPACE); |
|||
while (ptr && (argc < MAX_ARGS)) |
|||
{ |
|||
ptrLen = strlen(ptr); |
|||
|
|||
argv[argc] = (char*)malloc(ptrLen + 1); |
|||
strcpy (argv[argc], ptr); |
|||
|
|||
argc++; |
|||
|
|||
ptr = strtok(NULL, WHITESPACE); |
|||
} |
|||
/* consoleprintf ("PHP | popen: command = %s\n", command); */ |
|||
|
|||
// |
|||
|
|||
envSpec.esArgc = argc; |
|||
envSpec.esArgv = argv; |
|||
envSpec.esEnv = env; |
|||
|
|||
envSpec.esStderr.ssType = NX_OBJ_CONSOLE; |
|||
|
|||
envSpec.esStdin.ssHandle = |
|||
envSpec.esStdout.ssHandle = |
|||
envSpec.esStderr.ssHandle = -1; |
|||
|
|||
envSpec.esStdin.ssPathCtx = |
|||
envSpec.esStdout.ssPathCtx = |
|||
envSpec.esStderr.ssPathCtx = NULL; |
|||
|
|||
envSpec.esStderr.ssPath = NULL; |
|||
|
|||
err = NXVmSpawn(NULL, command, &envSpec, NX_VM_CREATE_DETACHED, &newVM); |
|||
return fd; |
|||
|
|||
} |
|||
|
|||
int pclose2(FILE* stream) |
|||
{ |
|||
NXClose(*(NXHandle_t *)stream); |
|||
return 0; |
|||
} |
|||
|
|||
FILE* popen1(const char* commandline, const char* mode) |
|||
{ |
|||
char *command = NULL, *argv[MAX_ARGS] = {"\0"}; |
|||
char *tempName = "phpXXXXXX.tmp"; |
|||
char *filePath = NULL; |
|||
FILE *fp = NULL; |
|||
char *ptr = NULL; |
|||
int ptrLen = 0, argc = 0, i = 0; |
|||
|
|||
/* Check for validity of input parameters */ |
|||
if (!commandline || !mode) |
|||
return NULL; |
|||
|
|||
/* Get temporary file name */ |
|||
filePath = mktemp(tempName); |
|||
if (!filePath) |
|||
return NULL; |
|||
|
|||
/* Separate commandline string into words */ |
|||
|
|||
ptr = strtok((char*)commandline, WHITESPACE); |
|||
ptrLen = strlen(ptr); |
|||
|
|||
command = (char*)malloc(ptrLen + 1); |
|||
strcpy (command, ptr); |
|||
|
|||
ptr = strtok(NULL, WHITESPACE); |
|||
while (ptr && (argc < MAX_ARGS)) |
|||
{ |
|||
ptrLen = strlen(ptr); |
|||
|
|||
argv[argc] = (char*)malloc(ptrLen + 1); |
|||
strcpy (argv[argc], ptr); |
|||
|
|||
argc++; |
|||
|
|||
ptr = strtok(NULL, WHITESPACE); |
|||
} |
|||
/*consoleprintf ("PHP | popen: command = %s\n", command);*/ |
|||
if(strchr(mode,'r') != 0) |
|||
{ |
|||
/*spawnvp(P_WAIT, command, argv);*/ |
|||
|
|||
fp = fopen(filePath, "r"); /* Get the file handle of the pipe */ |
|||
} |
|||
else if(strchr(mode,'w') != 0) |
|||
fp = fopen(filePath, "w"); /* Get the file handle of the pipe */ |
|||
|
|||
/* Free resources */ |
|||
free (command); |
|||
for (i = 0; i < argc; i++) |
|||
{ |
|||
/*consoleprintf ("%s\t", argv[i]);*/ |
|||
free (argv[i]); |
|||
} |
|||
/*consoleprintf ("\n");*/ |
|||
|
|||
return fp; /* Return the file handle.*/ |
|||
} |
|||
|
|||
int pclose1(FILE* stream) |
|||
{ |
|||
return (fclose(stream)); |
|||
} |
|||
|
|||
# endif |
|||
@ -0,0 +1,11 @@ |
|||
|
|||
/* pipe related function declarations */ |
|||
|
|||
/*#include <unistd.h>*/ |
|||
#include <proc.h> |
|||
#include <fcntl.h> |
|||
#include <sys/select.h> |
|||
|
|||
|
|||
FILE* popen(const char* command, const char* mode); |
|||
int pclose(FILE* stream); |
|||
@ -0,0 +1,45 @@ |
|||
/*------------------------------------------------------------------------- |
|||
* |
|||
* postgres_ext.h |
|||
* |
|||
* This file contains declarations of things that are visible everywhere |
|||
* in PostgreSQL *and* are visible to clients of frontend interface libraries. |
|||
* For example, the Oid type is part of the API of libpq and other libraries. |
|||
* |
|||
* Declarations which are specific to a particular interface should |
|||
* go in the header file for that interface (such as libpq-fe.h). This |
|||
* file is only for fundamental Postgres declarations. |
|||
* |
|||
* User-written C functions don't count as "external to Postgres." |
|||
* Those function much as local modifications to the backend itself, and |
|||
* use header files that are otherwise internal to Postgres to interface |
|||
* with the backend. |
|||
* |
|||
* $Id$ |
|||
* |
|||
*------------------------------------------------------------------------- |
|||
*/ |
|||
|
|||
#ifndef POSTGRES_EXT_H |
|||
#define POSTGRES_EXT_H |
|||
|
|||
/* |
|||
* Object ID is a fundamental type in Postgres. |
|||
*/ |
|||
typedef unsigned int Oid; |
|||
|
|||
#define InvalidOid ((Oid) 0) |
|||
|
|||
#define OID_MAX UINT_MAX |
|||
/* you will need to include <limits.h> to use the above #define */ |
|||
|
|||
|
|||
/* |
|||
* NAMEDATALEN is the max length for system identifiers (e.g. table names, |
|||
* attribute names, function names, etc.) |
|||
* |
|||
* NOTE that databases with different NAMEDATALEN's cannot interoperate! |
|||
*/ |
|||
#define NAMEDATALEN 32 |
|||
|
|||
#endif |
|||
@ -0,0 +1,86 @@ |
|||
/* pwd.c - Try to approximate UN*X's getuser...() functions under MS-DOS. |
|||
Copyright (C) 1990 by Thorsten Ohl, td12@ddagsi3.bitnet |
|||
|
|||
This program is free software; you can redistribute it and/or modify |
|||
it under the terms of the GNU General Public License as published by |
|||
the Free Software Foundation; either version 1, or (at your option) |
|||
any later version. |
|||
|
|||
This program is distributed in the hope that it will be useful, |
|||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
GNU General Public License for more details. |
|||
|
|||
You should have received a copy of the GNU General Public License |
|||
along with this program; if not, write to the Free Software |
|||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
|||
|
|||
$Header$ |
|||
*/ |
|||
|
|||
/* This 'implementation' is conjectured from the use of this functions in |
|||
the RCS and BASH distributions. Of course these functions don't do too |
|||
much useful things under MS-DOS, but using them avoids many "#ifdef |
|||
MSDOS" in ported UN*X code ... */ |
|||
|
|||
#include "php.h" /*php specific */ |
|||
/* Need to take care of all the commented stuff later for NetWare */ |
|||
/* |
|||
#define WIN32_LEAN_AND_MEAN |
|||
#include <windows.h> |
|||
#include <lmaccess.h> |
|||
*/ |
|||
#include <stdio.h> |
|||
#include <stdlib.h> |
|||
#include <string.h> |
|||
/*#include <lmapibuf.h>*/ |
|||
#include "pwd.h" |
|||
#include "grp.h" |
|||
|
|||
#ifndef THREAD_SAFE |
|||
static struct passwd pw; /* should we return a malloc()'d structure */ |
|||
#endif |
|||
static char *home_dir = "."; /* we feel (no|every)where at home */ |
|||
static char *login_shell = "not command.com!"; |
|||
|
|||
struct passwd *getpwnam(char *name) |
|||
{ |
|||
return (struct passwd *) 0; |
|||
} |
|||
|
|||
|
|||
char *getlogin() |
|||
{ |
|||
/* |
|||
static char name[256]; |
|||
DWORD dw = 256; |
|||
GetUserName(name, &dw); |
|||
return name; |
|||
*/ |
|||
return NULL; /* For now */ |
|||
} |
|||
|
|||
struct passwd * |
|||
getpwuid(int uid) |
|||
{ |
|||
pw.pw_name = getlogin(); |
|||
pw.pw_dir = home_dir; |
|||
pw.pw_shell = login_shell; |
|||
pw.pw_uid = 0; |
|||
|
|||
return &pw; |
|||
} |
|||
|
|||
/* Implementation for now */ |
|||
int getpid() |
|||
{ |
|||
return -1; |
|||
} |
|||
|
|||
/* |
|||
* Local Variables: |
|||
* mode:C |
|||
* ChangeLog:ChangeLog |
|||
* compile-command:make |
|||
* End: |
|||
*/ |
|||
@ -0,0 +1,114 @@ |
|||
/* |
|||
* Copyright (c) 1987, 1993 |
|||
* The Regents of the University of California. All rights reserved. |
|||
* |
|||
* Redistribution and use in source and binary forms, with or without |
|||
* modification, are permitted provided that the following conditions |
|||
* are met: |
|||
* 1. Redistributions of source code must retain the above copyright |
|||
* notice, this list of conditions and the following disclaimer. |
|||
* 2. Redistributions in binary form must reproduce the above copyright |
|||
* notice, this list of conditions and the following disclaimer in the |
|||
* documentation and/or other materials provided with the distribution. |
|||
* 4. Neither the name of the University nor the names of its contributors |
|||
* may be used to endorse or promote products derived from this software |
|||
* without specific prior written permission. |
|||
* |
|||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
|||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
|||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
|||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
|||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
|||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
|||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
|||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
|||
* SUCH DAMAGE. |
|||
* |
|||
* @(#)sysexits.h 8.1 (Berkeley) 6/2/93 |
|||
*/ |
|||
|
|||
#ifndef _SYSEXITS_H |
|||
#define _SYSEXITS_H 1 |
|||
|
|||
/* |
|||
* SYSEXITS.H -- Exit status codes for system programs. |
|||
* |
|||
* This include file attempts to categorize possible error |
|||
* exit statuses for system programs, notably delivermail |
|||
* and the Berkeley network. |
|||
* |
|||
* Error numbers begin at EX__BASE to reduce the possibility of |
|||
* clashing with other exit statuses that random programs may |
|||
* already return. The meaning of the codes is approximately |
|||
* as follows: |
|||
* |
|||
* EX_USAGE -- The command was used incorrectly, e.g., with |
|||
* the wrong number of arguments, a bad flag, a bad |
|||
* syntax in a parameter, or whatever. |
|||
* EX_DATAERR -- The input data was incorrect in some way. |
|||
* This should only be used for user's data & not |
|||
* system files. |
|||
* EX_NOINPUT -- An input file (not a system file) did not |
|||
* exist or was not readable. This could also include |
|||
* errors like "No message" to a mailer (if it cared |
|||
* to catch it). |
|||
* EX_NOUSER -- The user specified did not exist. This might |
|||
* be used for mail addresses or remote logins. |
|||
* EX_NOHOST -- The host specified did not exist. This is used |
|||
* in mail addresses or network requests. |
|||
* EX_UNAVAILABLE -- A service is unavailable. This can occur |
|||
* if a support program or file does not exist. This |
|||
* can also be used as a catchall message when something |
|||
* you wanted to do doesn't work, but you don't know |
|||
* why. |
|||
* EX_SOFTWARE -- An internal software error has been detected. |
|||
* This should be limited to non-operating system related |
|||
* errors as possible. |
|||
* EX_OSERR -- An operating system error has been detected. |
|||
* This is intended to be used for such things as "cannot |
|||
* fork", "cannot create pipe", or the like. It includes |
|||
* things like getuid returning a user that does not |
|||
* exist in the passwd file. |
|||
* EX_OSFILE -- Some system file (e.g., /etc/passwd, /etc/utmp, |
|||
* etc.) does not exist, cannot be opened, or has some |
|||
* sort of error (e.g., syntax error). |
|||
* EX_CANTCREAT -- A (user specified) output file cannot be |
|||
* created. |
|||
* EX_IOERR -- An error occurred while doing I/O on some file. |
|||
* EX_TEMPFAIL -- temporary failure, indicating something that |
|||
* is not really an error. In sendmail, this means |
|||
* that a mailer (e.g.) could not create a connection, |
|||
* and the request should be reattempted later. |
|||
* EX_PROTOCOL -- the remote system returned something that |
|||
* was "not possible" during a protocol exchange. |
|||
* EX_NOPERM -- You did not have sufficient permission to |
|||
* perform the operation. This is not intended for |
|||
* file system problems, which should use NOINPUT or |
|||
* CANTCREAT, but rather for higher level permissions. |
|||
*/ |
|||
|
|||
#define EX_OK 0 /* successful termination */ |
|||
|
|||
#define EX__BASE 64 /* base value for error messages */ |
|||
|
|||
#define EX_USAGE 64 /* command line usage error */ |
|||
#define EX_DATAERR 65 /* data format error */ |
|||
#define EX_NOINPUT 66 /* cannot open input */ |
|||
#define EX_NOUSER 67 /* addressee unknown */ |
|||
#define EX_NOHOST 68 /* host name unknown */ |
|||
#define EX_UNAVAILABLE 69 /* service unavailable */ |
|||
#define EX_SOFTWARE 70 /* internal software error */ |
|||
#define EX_OSERR 71 /* system error (e.g., can't fork) */ |
|||
#define EX_OSFILE 72 /* critical OS file missing */ |
|||
#define EX_CANTCREAT 73 /* can't create (user) output file */ |
|||
#define EX_IOERR 74 /* input/output error */ |
|||
#define EX_TEMPFAIL 75 /* temp failure; user is invited to retry */ |
|||
#define EX_PROTOCOL 76 /* remote error in protocol */ |
|||
#define EX_NOPERM 77 /* permission denied */ |
|||
#define EX_CONFIG 78 /* configuration error */ |
|||
|
|||
#define EX__MAX 78 /* maximum listed value */ |
|||
|
|||
#endif /* sysexits.h */ |
|||
@ -0,0 +1,246 @@ |
|||
|
|||
/***************************************************************************** |
|||
* * |
|||
* DH_TIME.C * |
|||
* * |
|||
* Freely redistributable and modifiable. Use at your own risk. * |
|||
* * |
|||
* Copyright 1994 The Downhill Project * |
|||
* |
|||
* Modified by Shane Caraveo for use with PHP |
|||
* |
|||
*****************************************************************************/ |
|||
|
|||
/* $Id$ */ |
|||
|
|||
/** |
|||
* |
|||
* 04-Feb-2001 |
|||
* - Added patch by "Vanhanen, Reijo" <Reijo.Vanhanen@helsoft.fi> |
|||
* Improves accuracy of msec |
|||
*/ |
|||
|
|||
/* Include stuff ************************************************************ */ |
|||
|
|||
#include "time_nw.h" |
|||
#include "unistd.h" |
|||
#include "signal.h" |
|||
/*#include <winbase.h> |
|||
#include <mmsystem.h>*/ |
|||
#include <errno.h> |
|||
/* |
|||
int getfilesystemtime(struct timeval *time_Info) |
|||
{ |
|||
FILETIME ft; |
|||
__int64 ff; |
|||
|
|||
GetSystemTimeAsFileTime(&ft); *//* 100 ns blocks since 01-Jan-1641 *//* |
|||
*//* resolution seems to be 0.01 sec *//* |
|||
ff = *(__int64*)(&ft); |
|||
time_Info->tv_sec = (int)(ff/(__int64)10000000-(__int64)11644473600); |
|||
time_Info->tv_usec = (int)(ff % 10000000)/10; |
|||
return 0; |
|||
} |
|||
*/ |
|||
|
|||
|
|||
int gettimeofday(struct timeval *time_Info, struct timezone *timezone_Info) |
|||
{ |
|||
#ifdef NETWARE |
|||
return 0; |
|||
#else |
|||
static struct timeval starttime = {0, 0}; |
|||
static __int64 lasttime = 0; |
|||
static __int64 freq = 0; |
|||
__int64 timer; |
|||
LARGE_INTEGER li; |
|||
BOOL b; |
|||
double dt; |
|||
|
|||
/* Get the time, if they want it */ |
|||
if (time_Info != NULL) { |
|||
if (starttime.tv_sec == 0) { |
|||
b = QueryPerformanceFrequency(&li); |
|||
if (!b) { |
|||
starttime.tv_sec = -1; |
|||
} |
|||
else { |
|||
freq = li.QuadPart; |
|||
b = QueryPerformanceCounter(&li); |
|||
if (!b) { |
|||
starttime.tv_sec = -1; |
|||
} |
|||
else { |
|||
getfilesystemtime(&starttime); |
|||
timer = li.QuadPart; |
|||
dt = (double)timer/freq; |
|||
starttime.tv_usec -= (int)((dt-(int)dt)*1000000); |
|||
if (starttime.tv_usec < 0) { |
|||
starttime.tv_usec += 1000000; |
|||
--starttime.tv_sec; |
|||
} |
|||
starttime.tv_sec -= (int)dt; |
|||
} |
|||
} |
|||
} |
|||
if (starttime.tv_sec > 0) { |
|||
b = QueryPerformanceCounter(&li); |
|||
if (!b) { |
|||
starttime.tv_sec = -1; |
|||
} |
|||
else { |
|||
timer = li.QuadPart; |
|||
if (timer < lasttime) { |
|||
getfilesystemtime(time_Info); |
|||
dt = (double)timer/freq; |
|||
starttime = *time_Info; |
|||
starttime.tv_usec -= (int)((dt-(int)dt)*1000000); |
|||
if (starttime.tv_usec < 0) { |
|||
starttime.tv_usec += 1000000; |
|||
--starttime.tv_sec; |
|||
} |
|||
starttime.tv_sec -= (int)dt; |
|||
} |
|||
else { |
|||
lasttime = timer; |
|||
dt = (double)timer/freq; |
|||
time_Info->tv_sec = starttime.tv_sec + (int)dt; |
|||
time_Info->tv_usec = starttime.tv_usec + (int)((dt-(int)dt)*1000000); |
|||
if (time_Info->tv_usec > 1000000) { |
|||
time_Info->tv_usec -= 1000000; |
|||
++time_Info->tv_sec; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
if (starttime.tv_sec < 0) { |
|||
getfilesystemtime(time_Info); |
|||
} |
|||
|
|||
} |
|||
/* Get the timezone, if they want it */ |
|||
if (timezone_Info != NULL) { |
|||
_tzset(); |
|||
timezone_Info->tz_minuteswest = _timezone; |
|||
timezone_Info->tz_dsttime = _daylight; |
|||
} |
|||
/* And return */ |
|||
return 0; |
|||
#endif |
|||
} |
|||
|
|||
|
|||
/* this usleep isnt exactly accurate but should do ok */ |
|||
/* |
|||
void usleep(unsigned int useconds) |
|||
{ |
|||
struct timeval tnow, tthen, t0; |
|||
|
|||
gettimeofday(&tthen, NULL); |
|||
t0 = tthen; |
|||
tthen.tv_usec += useconds; |
|||
while (tthen.tv_usec > 1000000) { |
|||
tthen.tv_usec -= 1000000; |
|||
tthen.tv_sec++; |
|||
} |
|||
|
|||
if (useconds > 10000) { |
|||
useconds -= 10000; |
|||
Sleep(useconds/1000); |
|||
} |
|||
|
|||
while (1) { |
|||
gettimeofday(&tnow, NULL); |
|||
if (tnow.tv_sec > tthen.tv_sec) { |
|||
break; |
|||
} |
|||
if (tnow.tv_sec == tthen.tv_sec) { |
|||
if (tnow.tv_usec > tthen.tv_usec) { |
|||
break; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
*/ |
|||
|
|||
#ifdef HAVE_SETITIMER |
|||
|
|||
/* |
|||
#ifndef THREAD_SAFE |
|||
unsigned int proftimer, virttimer, realtimer; |
|||
extern LPMSG phpmsg; |
|||
#endif |
|||
|
|||
struct timer_msg { |
|||
int signal; |
|||
unsigned int threadid; |
|||
}; |
|||
|
|||
|
|||
LPTIMECALLBACK setitimer_timeout(UINT uTimerID, UINT info, DWORD dwUser, DWORD dw1, DWORD dw2) |
|||
{ |
|||
struct timer_msg *msg = (struct timer_msg *) info; |
|||
|
|||
if (msg) { |
|||
raise((int) msg->signal); |
|||
PostThreadMessage(msg->threadid, |
|||
WM_NOTIFY, msg->signal, 0); |
|||
free(msg); |
|||
} |
|||
return 0; |
|||
} |
|||
|
|||
int setitimer(int which, const struct itimerval *value, struct itimerval *ovalue) |
|||
{ |
|||
int timeout = value->it_value.tv_sec * 1000 + value->it_value.tv_usec; |
|||
int repeat = TIME_ONESHOT; |
|||
*/ |
|||
/*make sure the message queue is initialized *//* |
|||
PeekMessage(phpmsg, NULL, WM_USER, WM_USER, PM_NOREMOVE); |
|||
if (timeout > 0) { |
|||
struct timer_msg *msg = malloc(sizeof(struct timer_msg)); |
|||
msg->threadid = GetCurrentThreadId(); |
|||
if (!ovalue) { |
|||
repeat = TIME_PERIODIC; |
|||
} |
|||
switch (which) { |
|||
case ITIMER_REAL: |
|||
msg->signal = SIGALRM; |
|||
realtimer = timeSetEvent(timeout, 100, (LPTIMECALLBACK) setitimer_timeout, (UINT) msg, repeat); |
|||
break; |
|||
case ITIMER_VIRT: |
|||
msg->signal = SIGVTALRM; |
|||
virttimer = timeSetEvent(timeout, 100, (LPTIMECALLBACK) setitimer_timeout, (UINT) msg, repeat); |
|||
break; |
|||
case ITIMER_PROF: |
|||
msg->signal = SIGPROF; |
|||
proftimer = timeSetEvent(timeout, 100, (LPTIMECALLBACK) setitimer_timeout, (UINT) msg, repeat); |
|||
break; |
|||
default: |
|||
errno = EINVAL; |
|||
return -1; |
|||
break; |
|||
} |
|||
} else { |
|||
switch (which) { |
|||
case ITIMER_REAL: |
|||
timeKillEvent(realtimer); |
|||
break; |
|||
case ITIMER_VIRT: |
|||
timeKillEvent(virttimer); |
|||
break; |
|||
case ITIMER_PROF: |
|||
timeKillEvent(proftimer); |
|||
break; |
|||
default: |
|||
errno = EINVAL; |
|||
return -1; |
|||
break; |
|||
} |
|||
} |
|||
|
|||
|
|||
return 0; |
|||
} |
|||
*/ |
|||
#endif |
|||
@ -0,0 +1,57 @@ |
|||
/***************************************************************************** |
|||
* * |
|||
* sys/time.h * |
|||
* * |
|||
* Freely redistributable and modifiable. Use at your own risk. * |
|||
* * |
|||
* Copyright 1994 The Downhill Project * |
|||
* |
|||
* Modified by Shane Caraveo for PHP |
|||
* |
|||
*****************************************************************************/ |
|||
#ifndef TIME_H |
|||
#define TIME_H |
|||
|
|||
/* Include stuff ************************************************************ */ |
|||
#ifdef USE_WINSOCK |
|||
/*#include <ws2nlm.h>*/ |
|||
#include <novsock2.h> |
|||
#else |
|||
#include <sys/socket.h> |
|||
#endif |
|||
#include <time.h> |
|||
|
|||
/* |
|||
Commented out most of the stuff for now, since we dunno the utility right now |
|||
*/ |
|||
|
|||
/* Struct stuff ************************************************************* */ |
|||
/* |
|||
struct { |
|||
int tz_minuteswest; |
|||
int tz_dsttime; |
|||
} timezone; |
|||
*/ |
|||
/* |
|||
struct { |
|||
struct timeval it_interval; *//* next value *//* |
|||
struct timeval it_value; *//* current value *//* |
|||
} itimerval; |
|||
*/ |
|||
#define ITIMER_REAL 0 /*generates sigalrm */ |
|||
#define ITIMER_VIRTUAL 1 /*generates sigvtalrm */ |
|||
#define ITIMER_VIRT 1 /*generates sigvtalrm */ |
|||
#define ITIMER_PROF 2 /*generates sigprof */ |
|||
|
|||
/* Prototype stuff ********************************************************** */ |
|||
/* |
|||
extern int gettimeofday(struct timeval *time_Info, struct timezone *timezone_Info); |
|||
*/ |
|||
|
|||
/* setitimer operates at 100 millisecond resolution */ |
|||
/* |
|||
extern int setitimer(int which, const struct itimerval *value, |
|||
struct itimerval *ovalue); |
|||
*/ |
|||
|
|||
#endif |
|||
@ -0,0 +1,17 @@ |
|||
|
|||
/* Function borrowed from the Downhill Project */ |
|||
#include "wfile.h" |
|||
/*#include "direct.h"*/ /* Can't find this file */ |
|||
|
|||
int readlink(char *file_Name, char *buf_Mem, int buf_Size) |
|||
{ |
|||
/* See if the file exists */ |
|||
if (access(file_Name, X_OK) == -1) { |
|||
errno = ENOENT; |
|||
} else { |
|||
errno = EINVAL; |
|||
} |
|||
|
|||
/* Either way, it's not a link */ |
|||
return -1; |
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
/*#include <io.h> */ |
|||
#include <stdio.h> |
|||
#include <stdlib.h> |
|||
#include <errno.h> |
|||
|
|||
#define access _access |
|||
#define X_OK 0 |
|||
#ifndef ENOENT |
|||
#define ENOENT 136 |
|||
#endif |
|||
#ifndef EINVAL |
|||
#define EINVAL 131 |
|||
#endif |
|||
|
|||
int readlink(char *, char *, int); |
|||
int checkroot(char *path); |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue