Index: configure.in
===================================================================
RCS file: /repository/php4/configure.in,v
retrieving revision 1.169
diff -u -r1.169 configure.in
--- configure.in	2000/08/25 08:15:08	1.169
+++ configure.in	2000/08/28 08:15:42
@@ -134,7 +134,7 @@
 dnl paths to the targets are relative to the build directory
 SAPI_PROGRAM=php
 SAPI_SHARED=libs/libphp4.$SHLIB_SUFFIX_NAME
-SAPI_STATIC=libs/libphp4.a
+SAPI_STATIC=libs/php4.a
 
 PHP_CONFIGURE_PART(Configuring SAPI modules)
 
@@ -227,7 +227,12 @@
 
 AC_CHECK_LIB(crypt, crypt, [
  AC_ADD_LIBRARY(crypt)
- AC_DEFINE(HAVE_LIBCRYPT,1,[ ]) ], [])
+ AC_DEFINE(HAVE_LIBCRYPT,1,[ ]) ], [
+   AC_CHECK_LIB(ufc, crypt, [
+     AC_ADD_LIBRARY(ufc)
+     AC_DEFINE(HAVE_LIBCRYPT,1,[ ]) 
+   ])
+ ])
 
 AC_CHECK_LIB(dl, dlopen,[AC_ADD_LIBRARY(dl)])
 
@@ -349,6 +354,7 @@
 localtime_r \
 lockf \
 lrand48 \
+lstat \
 memcpy \
 memmove \
 mmap \
Index: build/build.mk
===================================================================
RCS file: /repository/php4/build/build.mk,v
retrieving revision 1.5
diff -u -r1.5 build.mk
--- build/build.mk	2000/08/20 05:36:07	1.5
+++ build/build.mk	2000/08/28 08:15:44
@@ -20,6 +20,7 @@
 # Makefile to generate build tools
 #
 
+SHELL=sh
 SUBDIRS = Zend TSRM
 
 STAMP = buildmk.stamp
Index: build/build2.mk
===================================================================
RCS file: /repository/php4/build/build2.mk,v
retrieving revision 1.15
diff -u -r1.15 build2.mk
--- build/build2.mk	2000/08/20 05:36:07	1.15
+++ build/build2.mk	2000/08/28 08:15:44
@@ -17,6 +17,7 @@
 # $Id: build2.mk,v 1.15 2000/08/20 05:36:07 sas Exp $ 
 #
 
+SHELL=sh
 include generated_lists
 
 TOUCH_FILES = mkinstalldirs install-sh missing
Index: build/shtool
===================================================================
RCS file: /repository/php4/build/shtool,v
retrieving revision 1.2
diff -u -r1.2 shtool
--- build/shtool	2000/05/12 07:33:55	1.2
+++ build/shtool	2000/08/28 08:15:47
@@ -352,7 +352,7 @@
     if [ ".$opt_e" = .yes -a ".`echo $text | egrep '%[Bb]'`" != . ]; then
         case $TERM in
             #   for the most important terminal types we directly know the sequences
-            xterm|xterm*|vt220|vt220*)
+            xterm|xterm*|vt220|vt220*|ansi*)
                 term_bold=`awk 'BEGIN { printf("%c%c%c%c", 27, 91, 49, 109); }' </dev/null 2>/dev/null`
                 term_norm=`awk 'BEGIN { printf("%c%c%c", 27, 91, 109); }' </dev/null 2>/dev/null`
                 ;;
Index: ext/mysql/php_mysql.c
===================================================================
RCS file: /repository/php4/ext/mysql/php_mysql.c,v
retrieving revision 1.51
diff -u -r1.51 php_mysql.c
--- ext/mysql/php_mysql.c	2000/07/05 20:41:06	1.51
+++ ext/mysql/php_mysql.c	2000/08/28 08:15:54
@@ -218,7 +218,7 @@
 		
 		MySG(default_port) = MYSQL_PORT;
 		if ((serv_ptr = getservbyname("mysql", "tcp"))) {
-			MySG(default_port) = (uint) ntohs((ushort) serv_ptr->s_port);
+			MySG(default_port) = (uint) ntohs((unsigned short) serv_ptr->s_port);
 		}
 		if ((env = getenv("MYSQL_TCP_PORT"))) {
 			MySG(default_port) = (uint) atoi(env);
Index: ext/mysql/libmysql/global.h
===================================================================
RCS file: /repository/php4/ext/mysql/libmysql/global.h,v
retrieving revision 1.5
diff -u -r1.5 global.h
--- ext/mysql/libmysql/global.h	2000/08/22 17:59:34	1.5
+++ ext/mysql/libmysql/global.h	2000/08/28 08:15:58
@@ -190,8 +190,11 @@
 #define min(a, b)	((a) < (b) ? (a) : (b))
 #endif
 
-#if defined(__EMX__) || !defined(HAVE_UINT)
+#if !defined(HAVE_UINT) && !defined(uint)
 typedef unsigned int uint;
+#endif
+
+#if !defined(HAVE_USHORT) && !defined(ushort)
 typedef unsigned short ushort;
 #endif
 
@@ -504,7 +507,7 @@
 error "Neither int or long is of 4 bytes width"
 #endif
 
-#if !defined(HAVE_ULONG) && !defined(HAVE_LINUXTHREADS) && !defined(__USE_MISC)
+#if !defined(HAVE_ULONG) && !defined(HAVE_LINUXTHREADS) && !defined(__USE_MISC) && !defined(ulong)
 typedef unsigned long	ulong;	/* Short for unsigned long */
 #endif
 #ifndef longlong_defined
Index: ext/mysql/libmysql/violite.c
===================================================================
RCS file: /repository/php4/ext/mysql/libmysql/violite.c,v
retrieving revision 1.3
diff -u -r1.3 violite.c
--- ext/mysql/libmysql/violite.c	2000/08/22 17:59:35	1.3
+++ ext/mysql/libmysql/violite.c	2000/08/28 08:15:59
@@ -21,7 +21,7 @@
 
 #if defined(__EMX__)
 #include <sys/ioctl.h>
-#define ioctlsocket(A,B,C) ioctl((A),(B),(void *)(C),sizeof(*(C)))
+#define ioctlsocket(A,B,C,D) ioctl((A),(B),(void *)(C),(D))
 #undef HAVE_FCNTL
 #endif				/* defined(__EMX__) */
 
@@ -93,7 +93,7 @@
     {
       /* set to blocking mode by default */
       ulong arg=0;
-      r = ioctlsocket(vio->sd,FIONBIO,(void*) &arg, sizeof(arg));
+      ioctlsocket(vio->sd,FIONBIO,(void*) &arg, sizeof(arg));
     }
 #endif
   }
Index: ext/standard/basic_functions.c
===================================================================
RCS file: /repository/php4/ext/standard/basic_functions.c,v
retrieving revision 1.243
diff -u -r1.243 basic_functions.c
--- ext/standard/basic_functions.c	2000/08/27 22:46:40	1.243
+++ ext/standard/basic_functions.c	2000/08/28 08:16:06
@@ -220,7 +220,7 @@
 	PHP_FE(gethostbyaddr,							NULL)
 	PHP_FE(gethostbyname,							NULL)
 	PHP_FE(gethostbynamel,							NULL)
-#if !defined(PHP_WIN32)||HAVE_BINDLIB
+#if (!defined(PHP_WIN32) && !defined(PHP_OS2))||HAVE_BINDLIB
 	PHP_FE(checkdnsrr,								NULL)
 	PHP_FE(getmxrr,									second_and_third_args_force_ref)
 #else
@@ -400,7 +400,7 @@
 	PHP_FALIAS(socket_set_timeout, warn_not_available,      NULL)                             
 #endif
 	PHP_FE(socket_get_status,	NULL)
-#if !PHP_WIN32 || defined(ZTS)
+#if (!PHP_WIN32 && !PHP_OS2) || defined(ZTS)
 	PHP_FE(realpath,			NULL)
 #else
 	PHP_FALIAS(realpath,		warn_not_available,		NULL)
@@ -465,10 +465,12 @@
 	PHP_FE(ezmlm_hash,				NULL)
 
 	/* functions from syslog.c */
+#ifdef HAVE_SYSLOG_H
 	PHP_FE(openlog,					NULL)
 	PHP_FE(syslog,					NULL)
 	PHP_FE(closelog,				NULL)
 	PHP_FE(define_syslog_variables,	NULL)
+#endif
 
 	/* functions from lcg.c */
 	PHP_FE(lcg_value, NULL)
@@ -687,7 +689,9 @@
 #endif
 
 	PHP_MINIT(dir)(INIT_FUNC_ARGS_PASSTHRU);
+#ifdef HAVE_SYSLOG_H
 	PHP_MINIT(syslog)(INIT_FUNC_ARGS_PASSTHRU);
+#endif
 	PHP_MINIT(array)(INIT_FUNC_ARGS_PASSTHRU);
 	PHP_MINIT(assert)(INIT_FUNC_ARGS_PASSTHRU);
 
@@ -738,7 +742,9 @@
 
 	PHP_RINIT(head)(INIT_FUNC_ARGS_PASSTHRU);
 	PHP_RINIT(filestat)(INIT_FUNC_ARGS_PASSTHRU);
+#ifdef HAVE_SYSLOG_H
 	PHP_RINIT(syslog)(INIT_FUNC_ARGS_PASSTHRU);
+#endif
 	PHP_RINIT(assert)(INIT_FUNC_ARGS_PASSTHRU);
 	PHP_RINIT(dir)(INIT_FUNC_ARGS_PASSTHRU);
 
@@ -768,7 +774,9 @@
 
 	PHP_RSHUTDOWN(fsock)(SHUTDOWN_FUNC_ARGS_PASSTHRU);
 	PHP_RSHUTDOWN(filestat)(SHUTDOWN_FUNC_ARGS_PASSTHRU);
+#ifdef HAVE_SYSLOG_H
 	PHP_RSHUTDOWN(syslog)(SHUTDOWN_FUNC_ARGS_PASSTHRU);
+#endif
 	PHP_RSHUTDOWN(assert)(SHUTDOWN_FUNC_ARGS_PASSTHRU);
 
 #ifdef TRANS_SID
@@ -791,7 +799,9 @@
 {
 	php_info_print_table_start();
 	PHP_MINFO(regex)(ZEND_MODULE_INFO_FUNC_ARGS_PASSTHRU);
+#ifdef HAVE_LIBDL
 	PHP_MINFO(dl)(ZEND_MODULE_INFO_FUNC_ARGS_PASSTHRU);
+#endif
 	PHP_MINFO(mail)(ZEND_MODULE_INFO_FUNC_ARGS_PASSTHRU);
 	php_info_print_table_end();
 	PHP_MINFO(assert)(ZEND_MODULE_INFO_FUNC_ARGS_PASSTHRU);
Index: ext/standard/dns.c
===================================================================
RCS file: /repository/php4/ext/standard/dns.c,v
retrieving revision 1.22
diff -u -r1.22 dns.c
--- ext/standard/dns.c	2000/06/05 19:47:44	1.22
+++ ext/standard/dns.c	2000/08/28 08:16:06
@@ -159,7 +159,7 @@
 	return estrdup(inet_ntoa(in));
 }
 
-#if !defined(PHP_WIN32)||HAVE_BINDLIB
+#if (!defined(PHP_WIN32) && !defined(PHP_OS2))||HAVE_BINDLIB
 
 /* {{{ proto int checkdnsrr(string host [, string type])
    Check DNS records corresponding to a given Internet host name or IP address */
Index: ext/standard/file.c
===================================================================
RCS file: /repository/php4/ext/standard/file.c,v
retrieving revision 1.108
diff -u -r1.108 file.c
--- ext/standard/file.c	2000/08/21 19:24:44	1.108
+++ ext/standard/file.c	2000/08/28 08:16:12
@@ -30,6 +30,9 @@
 #include "ext/standard/php_filestat.h"
 
 #include <stdio.h>
+#ifdef PHP_OS2
+#include <io.h>
+#endif
 #include <stdlib.h>
 #include <errno.h>
 #include <sys/types.h>
@@ -1991,7 +1994,7 @@
 
 /* }}} */
 
-#if !PHP_WIN32 || defined(ZTS)
+#if (!PHP_WIN32 && !PHP_OS2) || defined(ZTS)
 /* {{{ proto string realpath(string path)
    Return the resolved path */
 PHP_FUNCTION(realpath)
Index: ext/standard/filestat.c
===================================================================
RCS file: /repository/php4/ext/standard/filestat.c,v
retrieving revision 1.44
diff -u -r1.44 filestat.c
--- ext/standard/filestat.c	2000/08/06 16:22:07	1.44
+++ ext/standard/filestat.c	2000/08/28 08:16:15
@@ -34,7 +34,7 @@
 # include <unistd.h>
 #endif
 
-#ifdef OS2
+#ifdef PHP_OS2
 #  define INCL_DOS
 #  include <os2.h>
 #endif
@@ -198,7 +198,7 @@
 		RETURN_FALSE;
 	}
 
-#elif defined(OS2)
+#elif defined(PHP_OS2)
 	{
 		FSALLOCATE fsinfo;
   		char drive = (*path)->value.str.val[0] & 95;
@@ -228,7 +228,7 @@
    Change file owner */
 PHP_FUNCTION(chgrp)
 {
-#ifndef WINDOWS
+#if !defined(WINDOWS) && !defined(PHP_OS2)
 	pval **filename, **group;
 	gid_t gid;
 	struct group *gr=NULL;
@@ -276,7 +276,7 @@
    Change file group */
 PHP_FUNCTION(chown)
 {
-#ifndef WINDOWS
+#if !defined(WINDOWS) && !defined(PHP_OS2)
 	pval **filename, **user;
 	int ret;
 	uid_t uid;
@@ -547,8 +547,10 @@
 		switch(BG(sb).st_mode&S_IFMT) {
 		case S_IFIFO: RETURN_STRING("fifo",1);
 		case S_IFCHR: RETURN_STRING("char",1);
-		case S_IFDIR: RETURN_STRING("dir",1);
-		case S_IFBLK: RETURN_STRING("block",1);
+                case S_IFDIR: RETURN_STRING("dir",1);
+#ifdef S_IFBLK
+                case S_IFBLK: RETURN_STRING("block",1);
+#endif
 		case S_IFREG: RETURN_STRING("file",1);
 		}
 		php_error(E_WARNING,"Unknown file type (%d)",BG(sb).st_mode&S_IFMT);
Index: ext/standard/mail.c
===================================================================
RCS file: /repository/php4/ext/standard/mail.c,v
retrieving revision 1.28
diff -u -r1.28 mail.c
--- ext/standard/mail.c	2000/08/03 19:26:19	1.28
+++ ext/standard/mail.c	2000/08/28 08:16:16
@@ -25,7 +25,14 @@
 #include "ext/standard/info.h"
 #if !defined(PHP_WIN32)
 #include "build-defs.h"
+
+#ifdef PHP_OS2
+#define EX_OK 0
+#define EX_TEMPFAIL 75 /* Not sure if this is right for OS/2's sendmail */
+#else
 #include <sysexits.h>
+#endif
+
 #endif
 #include "php_mail.h"
 #include "php_ini.h"
Index: ext/standard/microtime.c
===================================================================
RCS file: /repository/php4/ext/standard/microtime.c,v
retrieving revision 1.27
diff -u -r1.27 microtime.c
--- ext/standard/microtime.c	2000/06/05 19:47:44	1.27
+++ ext/standard/microtime.c	2000/08/28 08:16:18
@@ -39,6 +39,11 @@
 #include <stdio.h>
 #include <errno.h>
 
+#if PHP_OS2
+#define INCL_DOSPROFILE
+#include <os2.h>
+#endif
+
 #include "microtime.h"
 
 #define NUL  '\0'
@@ -50,10 +55,32 @@
 {
 #ifdef HAVE_GETTIMEOFDAY
 	struct timeval tp;
-	long sec = 0L;
-	double msec = 0.0;
 	char ret[100];
 	
+#if PHP_OS2
+    static ULONG hrtimerHz = 0;
+    /* Number of hrtimerHz between 1 Jan 1970 & base of DosTmrQueryTime() */
+    static unsigned long long hradjust; 
+    QWORD qwNow;
+    unsigned long long llNow;
+
+    if (hrtimerHz == 0) {
+        DosTmrQueryFreq(&hrtimerHz);
+        gettimeofday(&tp, NULL);
+        DosTmrQueryTime(&qwNow);
+        llNow = ((unsigned long long)qwNow.ulHi << 32) | qwNow.ulLo;
+        hradjust = (unsigned long long)tp.tv_sec * hrtimerHz + (tp.tv_usec * hrtimerHz / MICRO_IN_SEC) - llNow;
+    }
+
+    DosTmrQueryTime(&qwNow);
+    llNow = ((unsigned long long)qwNow.ulHi << 32) | qwNow.ulLo;
+    llNow += hradjust;
+    snprintf(ret, 100, "%.8f %ld", (double)(llNow % hrtimerHz)/hrtimerHz, llNow / hrtimerHz);
+    RETVAL_STRING(ret,1);
+#else
+	long sec = 0L;
+	double msec = 0.0;
+
 	if (gettimeofday((struct timeval *) &tp, (NUL)) == 0) {
 		msec = (double) (tp.tv_usec / MICRO_IN_SEC);
 		sec = tp.tv_sec;
@@ -61,6 +88,7 @@
 	if (msec >= 1.0) msec -= (long) msec;
 	snprintf(ret, 100, "%.8f %ld", msec, sec);
 	RETVAL_STRING(ret,1);
+#endif
 #endif
 }
 /* }}} */
Index: ext/standard/php_math.h
===================================================================
RCS file: /repository/php4/ext/standard/php_math.h,v
retrieving revision 1.5
diff -u -r1.5 php_math.h
--- ext/standard/php_math.h	2000/08/19 22:01:37	1.5
+++ ext/standard/php_math.h	2000/08/28 08:16:19
@@ -56,6 +56,9 @@
 PHP_FUNCTION(rad2deg);
 
 #include <math.h>
+#ifdef HAVE_FLOAT_H
+#include <float.h>
+#endif
 
 #ifndef M_E
 #define M_E            2.7182818284590452354   /* e */
Index: ext/standard/syslog.c
===================================================================
RCS file: /repository/php4/ext/standard/syslog.c,v
retrieving revision 1.22
diff -u -r1.22 syslog.c
--- ext/standard/syslog.c	2000/06/05 19:47:44	1.22
+++ ext/standard/syslog.c	2000/08/28 08:16:20
@@ -34,6 +34,7 @@
 #include "basic_functions.h"
 #include "php_ext_syslog.h"
 
+#ifdef HAVE_SYSLOG_H
 static void start_syslog(BLS_D);
 
 PHP_MINIT_FUNCTION(syslog)
@@ -256,6 +257,7 @@
 	RETURN_TRUE;
 }
 /* }}} */
+#endif /* HAVE_SYSLOG_H */
 
 /*
  * Local variables:
Index: main/SAPI.c
===================================================================
RCS file: /repository/php4/main/SAPI.c,v
retrieving revision 1.85
diff -u -r1.85 SAPI.c
--- main/SAPI.c	2000/08/27 09:48:03	1.85
+++ main/SAPI.c	2000/08/28 08:16:24
@@ -18,10 +18,10 @@
    +----------------------------------------------------------------------+
 */
 
+#include "php.h"
 #include <ctype.h>
 #include <sys/stat.h>
 
-#include "php.h"
 #include "SAPI.h"
 #ifdef ZTS
 #include "TSRM.h"
Index: main/configuration-parser.y
===================================================================
RCS file: /repository/php4/main/configuration-parser.y,v
retrieving revision 1.53
diff -u -r1.53 configuration-parser.y
--- main/configuration-parser.y	2000/07/25 18:50:50	1.53
+++ main/configuration-parser.y	2000/08/28 08:16:25
@@ -186,7 +186,13 @@
 			}
 		}
 #else
+#if PHP_OS2
 		if (!php_ini_path) {
+			php_ini_path = getenv("ETC");
+		}
+#endif
+
+		if (!php_ini_path) {
 			default_location = CONFIGURATION_FILE_PATH;
 		} else {
 			default_location = php_ini_path;
@@ -197,7 +203,7 @@
 		php_ini_search_path = (char *) malloc(sizeof(".")+strlen(env_location)+strlen(default_location)+2+1);
 
 		if (!php_ini_path) {
-#ifdef PHP_WIN32
+#if defined(PHP_WIN32) || defined(PHP_OS2)
 			sprintf(php_ini_search_path,".;%s;%s",env_location,default_location);
 #else
 			sprintf(php_ini_search_path,".:%s:%s",env_location,default_location);
Index: main/fopen-wrappers.c
===================================================================
RCS file: /repository/php4/main/fopen-wrappers.c,v
retrieving revision 1.82
diff -u -r1.82 fopen-wrappers.c
--- main/fopen-wrappers.c	2000/08/21 09:50:52	1.82
+++ main/fopen-wrappers.c	2000/08/28 08:16:28
@@ -217,7 +217,7 @@
 		ptr = pathbuf;
 
 		while (ptr && *ptr) {
-#ifdef PHP_WIN32
+#if defined(PHP_WIN32) || defined(PHP_OS2)
 			end = strchr(ptr, ';');
 #else
 			end = strchr(ptr, ':');
@@ -408,7 +408,7 @@
 		return php_fopen_and_set_opened_path(filename, mode, opened_path);
 	}
 	/* Absolute path open - prepend document_root in safe mode */
-#ifdef PHP_WIN32
+#if defined(PHP_WIN32) || defined(PHP_OS2)
 	if (IS_SLASH(*filename) || (filename[1] == ':')) {
 #else
 	if (IS_SLASH(*filename)) {
@@ -438,7 +438,7 @@
 	ptr = pathbuf;
 
 	while (ptr && *ptr) {
-#ifdef PHP_WIN32
+#if defined(PHP_WIN32) || defined(PHP_OS2)
 		end = strchr(ptr, ';');
 #else
 		end = strchr(ptr, ':');
Index: main/php.h
===================================================================
RCS file: /repository/php4/main/php.h,v
retrieving revision 1.122
diff -u -r1.122 php.h
--- main/php.h	2000/08/27 18:27:37	1.122
+++ main/php.h	2000/08/28 08:16:30
@@ -64,6 +64,16 @@
 #define PHP_DIR_SEPARATOR '/'
 #endif
 
+#ifdef __EMX__
+#define PHP_OS2 1
+#define TCPIPV4 1
+#define MAXSOCKETS 2048
+#if !HAVE_AP_CONFIG_H
+#define strcasecmp(s1, s2) stricmp(s1, s2)
+#define strncasecmp(s1, s2, n) strnicmp(s1, s2, n)
+#endif
+#endif
+
 #include "php_regex.h"
 
 /* PHP's DEBUG value must match Zend's ZEND_DEBUG value */
@@ -305,7 +315,7 @@
 #define V_GETWD(buf)
 #define V_REALPATH(path,real_path) virtual_realpath(path,real_path)
 #define V_STAT(path, buff) virtual_stat(path, buff)
-#ifdef PHP_WIN32
+#if defined(PHP_WIN32) || defined(PHP_OS2)
 #define V_LSTAT(path, buff) virtual_stat(path, buff)
 #else
 #define V_LSTAT(path, buff) virtual_lstat(path, buff)
Index: main/php_syslog.h
===================================================================
RCS file: /repository/php4/main/php_syslog.h,v
retrieving revision 1.4
diff -u -r1.4 php_syslog.h
--- main/php_syslog.h	2000/06/09 17:21:40	1.4
+++ main/php_syslog.h	2000/08/28 08:16:30
@@ -4,7 +4,9 @@
 #ifdef PHP_WIN32
 #include "win32/syslog.h"
 #else
+#ifdef HAVE_SYSLOG_H
 #include <syslog.h>
+#endif
 #endif
 
 /* 
Index: main/php_virtual_cwd.c
===================================================================
RCS file: /repository/php4/main/php_virtual_cwd.c,v
retrieving revision 1.73
diff -u -r1.73 php_virtual_cwd.c
--- main/php_virtual_cwd.c	2000/08/27 19:36:35	1.73
+++ main/php_virtual_cwd.c	2000/08/28 08:16:32
@@ -35,6 +35,7 @@
 
 #include "php_virtual_cwd.h"
 #include "php_reentrancy.h" /* for php_strtok_r */
+#include "php_config.h"
 
 #define VIRTUAL_CWD_DEBUG 0
 
@@ -65,7 +66,7 @@
 #define S_ISREG(mode) ((mode) & _S_IFREG)
 #endif
 
-#ifdef ZEND_WIN32
+#if defined(ZEND_WIN32) || defined(PHP_OS2)
 #define php_strtok_r(a,b,c) strtok((a),(b))
 #define DEFAULT_SLASH '\\'
 #define TOKENIZER_STRING "/\\"
@@ -201,7 +202,7 @@
 		return retval;
 	}
 
-#ifdef ZEND_WIN32
+#if defined(ZEND_WIN32)||defined(PHP_OS2)
 	/* If we have something like C: */
 	if (state->cwd_length == 2 && state->cwd[state->cwd_length-1] == ':') {
 		char *retval;
@@ -260,7 +261,7 @@
 	if (path_length == 0) 
 		return (0);
 
-#ifndef ZEND_WIN32
+#if !defined(ZEND_WIN32) && HAVE_REALPATH
 	if (IS_ABSOLUTE_PATH(path, path_length)) {
 		if (realpath(path, resolved_path)) {
 			path = resolved_path;
@@ -297,7 +298,7 @@
 	if (IS_ABSOLUTE_PATH(path_copy, path_length)) {
 		copy_amount = COPY_WHEN_ABSOLUTE;
 		is_absolute = 1;
-#ifdef ZEND_WIN32
+#if defined(ZEND_WIN32) || defined(PHP_OS2)
 	} else if(IS_SLASH(path_copy[0])) {
 		copy_amount = 2;
 #endif
@@ -500,7 +501,7 @@
 	return ret;
 }
 
-#ifndef PHP_WIN32
+#if !defined(PHP_WIN32) && !defined(PHP_OS2) 
 CWD_API int virtual_chown(const char *filename, uid_t owner, gid_t group)
 {
 	cwd_state new_state;
@@ -573,7 +574,7 @@
 	return retval;
 }
 
-#ifndef ZEND_WIN32
+#ifdef HAVE_LSTAT
 
 CWD_API int virtual_lstat(const char *path, struct stat *buf)
 {
Index: sapi/cgi/cgi_main.c
===================================================================
RCS file: /repository/php4/sapi/cgi/cgi_main.c,v
retrieving revision 1.68
diff -u -r1.68 cgi_main.c
--- sapi/cgi/cgi_main.c	2000/08/27 19:46:03	1.68
+++ sapi/cgi/cgi_main.c	2000/08/28 08:16:34
@@ -59,8 +59,10 @@
 #include "win32/syslog.h"
 #include "win32/php_registry.h"
 #else
+#ifdef HAVE_SYSLOG_H
 #include <syslog.h>
 #endif
+#endif
 
 #if HAVE_SIGNAL_H
 #include <signal.h>
@@ -419,6 +421,12 @@
 	setmode(_fileno(stdin), O_BINARY);		/* make the stdio mode be binary */
 	setmode(_fileno(stdout), O_BINARY);		/* make the stdio mode be binary */
 	setmode(_fileno(stderr), O_BINARY);		/* make the stdio mode be binary */
+#endif
+
+#ifdef PHP_OS2
+	_fsetmode(stdin,  "b");
+	_fsetmode(stdout, "b");
+	_fsetmode(stderr, "b");
 #endif
 
 
