Fixing OS/2 build breaks OS2_BRANCH
authordanda
Mon, 20 Apr 1998 03:07:39 +0000
branchOS2_BRANCH
changeset 13 583856afdd7e22c76614015fa65613a7fd75e2ee
parent 6 d2219c504a7bdbdf02734b33e745d76f243408eb
child 32 2bc325efa3ce2264ace8e90c16caf8d801f89482
push idunknown
push userunknown
push dateunknown
Fixing OS/2 build breaks
dbm/include/mcom_db.h
dbm/src/h_bigkey.c
dbm/src/h_page.c
dbm/src/hash.c
dbm/src/hash_buf.c
dbm/src/mktemp.c
dbm/src/ndbm.c
dbm/src/snprintf.c
--- a/dbm/include/mcom_db.h
+++ b/dbm/include/mcom_db.h
@@ -119,17 +119,17 @@
 #ifdef macintosh
 #include <unix.h>
 #endif
 
 #ifndef macintosh
 #include <fcntl.h>
 #endif
 
-#ifdef _WINDOWS
+#if defined(_WINDOWS) || defined(XP_OS2)
 #include <stdio.h>
 #include <io.h>
 #include <limits.h>
 #define MAXPATHLEN 	1024              
 
 #define	EFTYPE		EINVAL		/* POSIX 1003.1 format errno. */
 
 #ifndef	STDERR_FILENO
--- a/dbm/src/h_bigkey.c
+++ b/dbm/src/h_bigkey.c
@@ -53,17 +53,17 @@ static char sccsid[] = "@(#)hash_bigkey.
  *	__big_return
  *	__big_delete
  *	__find_last_page
  * Internal
  *	collect_key
  *	collect_data
  */
 
-#if !defined(_WIN32) && !defined(_WINDOWS) && !defined(macintosh)
+#if !defined(_WIN32) && !defined(_WINDOWS) && !defined(macintosh) && !defined(XP_OS2_VACPP)
 #include <sys/param.h>
 #endif
 
 #include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
--- a/dbm/src/h_page.c
+++ b/dbm/src/h_page.c
@@ -70,17 +70,17 @@ static char sccsid[] = "@(#)hash_page.c	
 #ifndef macintosh
 #include <fcntl.h>
 #endif
 #include <signal.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
-#if !defined(_WIN32) && !defined(_WINDOWS) && !defined(macintosh)
+#if !defined(_WIN32) && !defined(_WINDOWS) && !defined(macintosh) && !defined(XP_OS2_VACPP)
 #include <unistd.h>
 #endif
 
 #include <assert.h>
 
 #include "mcom_db.h"
 #include "hash.h"
 #include "page.h"
@@ -1144,35 +1144,35 @@ extern void
 /*
  * Returns:
  *	 0 success
  *	-1 failure
  */
 static int
 open_temp(HTAB *hashp)
 {
-#if !defined(_WIN32) && !defined(_WINDOWS) && !defined(macintosh)
+#if !defined(_WIN32) && !defined(_WINDOWS) && !defined(macintosh) && !defined(XP_OS2)
 	sigset_t set, oset;
 #endif
 	static char namestr[] = "_hashXXXXXX";
 
-#if !defined(_WIN32) && !defined(_WINDOWS) && !defined(macintosh)
+#if !defined(_WIN32) && !defined(_WINDOWS) && !defined(macintosh) && !defined(XP_OS2)
 	/* Block signals; make sure file goes away at process exit. */
 	(void)sigfillset(&set);
 	(void)sigprocmask(SIG_BLOCK, &set, &oset);
 #endif
 
 	if ((hashp->fp = mkstemp(namestr)) != -1) {
 		(void)unlink(namestr);
-#if !defined(_WIN32) && !defined(_WINDOWS) && !defined(macintosh)
+#if !defined(_WIN32) && !defined(_WINDOWS) && !defined(macintosh) && !defined(XP_OS2)
 		(void)fcntl(hashp->fp, F_SETFD, 1);
 #endif									  
 	}
 
-#if !defined(_WIN32) && !defined(_WINDOWS) && !defined(macintosh) 
+#if !defined(_WIN32) && !defined(_WINDOWS) && !defined(macintosh) && !defined(XP_OS2)
 	(void)sigprocmask(SIG_SETMASK, &oset, (sigset_t *)NULL);
 #endif
 	return (hashp->fp != -1 ? 0 : -1);
 }
 
 /*
  * We have to know that the key will fit, but the last entry on the page is
  * an overflow pair, so we need to shift things.
--- a/dbm/src/hash.c
+++ b/dbm/src/hash.c
@@ -35,17 +35,17 @@
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
 static char sccsid[] = "@(#)hash.c	8.9 (Berkeley) 6/16/94";
 #endif /* LIBC_SCCS and not lint */
 
 #include "watcomfx.h"
 
-#if !defined(_WIN32) && !defined(_WINDOWS) && !defined(macintosh)
+#if !defined(_WIN32) && !defined(_WINDOWS) && !defined(macintosh) && !defined(XP_OS2_VACPP)
 #include <sys/param.h>
 #endif
 
 #if !defined(macintosh)
 #include <sys/stat.h>
 #endif
 
 #include <errno.h>
@@ -53,20 +53,24 @@ static char sccsid[] = "@(#)hash.c	8.9 (
 #include <unix.h>
 #else
 #include <fcntl.h>
 #endif
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
-#if !defined(_WIN32) && !defined(_WINDOWS) && !defined(macintosh)
+#if !defined(_WIN32) && !defined(_WINDOWS) && !defined(macintosh) && !defined(XP_OS2_VACPP)
 #include <unistd.h>
 #endif
 
+#ifdef XP_OS2_VACPP
+#define EPERM SOCEPERM
+#endif
+
 #ifdef DEBUG
 #include <assert.h>
 #endif
 
 #include "mcom_db.h"
 #include "hash.h"
 #include "page.h"
 
@@ -184,17 +188,17 @@ extern DB *
 		/* check for a zero length file and delete it
 	 	 * if it exists
 	 	 */
 		new_table = 1;
 	}
 
 	if (file) {				 
 
-#if defined(_WIN32) || defined(_WINDOWS) || defined (macintosh)
+#if defined(_WIN32) || defined(_WINDOWS) || defined (macintosh)  || defined(XP_OS2_VACPP)
 		if ((hashp->fp = DBFILE_OPEN(file, flags | O_BINARY, mode)) == -1)
 			RETURN_ERROR(errno, error0);
 #else
  	if ((hashp->fp = open(file, flags, mode)) == -1)
 		RETURN_ERROR(errno, error0);
 	(void)fcntl(hashp->fp, F_SETFD, 1);
 /* We can't use fcntl because of NFS bugs. SIGH */
 #if 0
@@ -412,17 +416,17 @@ init_hash(HTAB *hashp, const char *file,
 	memset(hashp->SPARES, 0, sizeof(hashp->SPARES));
 	memset(hashp->BITMAPS, 0, sizeof (hashp->BITMAPS));
 
 	/* Fix bucket size to be optimal for file system */
 	if (file != NULL) {
 		if (stat(file, &statbuf))
 			return (NULL);
 
-#if !defined(_WIN32) && !defined(_WINDOWS) && !defined(macintosh)
+#if !defined(_WIN32) && !defined(_WINDOWS) && !defined(macintosh) && !defined(XP_OS2)
 		hashp->BSIZE = statbuf.st_blksize;
 
        	/* new code added by Lou to reduce block
        	 * size down below MAX_BSIZE
        	 */
        	if (hashp->BSIZE > MAX_BSIZE)
        		hashp->BSIZE = MAX_BSIZE;
 #endif
--- a/dbm/src/hash_buf.c
+++ b/dbm/src/hash_buf.c
@@ -50,17 +50,17 @@ static char sccsid[] = "@(#)hash_buf.c	8
  * External
  *	__buf_init
  *	__get_buf
  *	__buf_free
  *	__reclaim_buf
  * Internal
  *	newbuf
  */
-#if !defined(_WIN32) && !defined(_WINDOWS) && !defined(macintosh)
+#if !defined(_WIN32) && !defined(_WINDOWS) && !defined(macintosh) && !defined(XP_OS2_VACPP)
 #include <sys/param.h>
 #endif
 
 #include <errno.h>
 #include <stddef.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
--- a/dbm/src/mktemp.c
+++ b/dbm/src/mktemp.c
@@ -44,20 +44,26 @@ static char sccsid[] = "@(#)mktemp.c	8.1
 #include <sys/stat.h>
 #endif
 #include <fcntl.h>
 #include <errno.h>
 #include <stdio.h>
 #include <ctype.h>
 #include "mcom_db.h"
 
-#if !defined(_WINDOWS)
+#if !defined(_WINDOWS) && !defined(XP_OS2_VACPP)
 #include <unistd.h>
 #endif
 
+#ifdef XP_OS2_VACPP
+#define ENOTDIR EBADPOS
+#include <process.h>
+#include <dirent.h>
+#endif
+
 #ifdef _WINDOWS
 #include <process.h>
 #include "winfile.h"
 #endif
 
 static int _gettemp(char *path, register int *doopen);
 
 int
--- a/dbm/src/ndbm.c
+++ b/dbm/src/ndbm.c
@@ -39,17 +39,17 @@ static char sccsid[] = "@(#)ndbm.c	8.4 (
 #endif /* LIBC_SCCS and not lint */
 
 #include "watcomfx.h"
 
 /*
  * This package provides a dbm compatible interface to the new hashing
  * package described in db(3).
  */
-#if !defined(_WIN32) && !defined(_WINDOWS)
+#if !defined(_WIN32) && !defined(_WINDOWS) && !defined(XP_OS2_VACPP)
 #include <sys/param.h>
 #endif
 
 #if defined(__linux)
 #include <linux/limits.h>
 #endif
 
 #include <stdio.h>
--- a/dbm/src/snprintf.c
+++ b/dbm/src/snprintf.c
@@ -1,46 +1,47 @@
 #include "watcomfx.h"
 #include <sys/types.h>
 #include <stddef.h>
 #include <stdio.h>
-#if defined(_WINDOWS) || defined(SOLARIS) || defined(AIXV3) || defined(AIX) || defined(OSF1) || defined(NEC)
+#if defined(_WINDOWS) || defined(SOLARIS) || defined(AIXV3) || defined(AIX) || defined(OSF1) || defined(NEC) || defined(XP_OS2_VACPP)
 #include "cdefs.h"
 #elif !defined(HPUX) && !defined(UNIXWARE) && !defined(SNI)
 #include <sys/cdefs.h>
 #endif
 
 #include "prtypes.h"
 
 #include <ncompat.h>
 
-#ifdef __STDC__
+/* The OS/2 VAC compiler doesn't appear to define __STDC__ and won't let us define it either */
+#if defined(__STDC__) || defined(XP_OS2_VACPP)
 #include <stdarg.h>
 #else
 #include <varargs.h>
 #endif
 
 int
-#ifdef __STDC__
+#if defined(__STDC__) || defined(XP_OS2_VACPP)
 snprintf(char *str, size_t n, const char *fmt, ...)
 #else
 snprintf(str, n, fmt, va_alist)
 	char *str;
 	size_t n;
 	const char *fmt;
 	va_dcl
 #endif
 {
 	va_list ap;
 #ifdef VSPRINTF_CHARSTAR
 	char *rp;
 #else
 	int rval;
 #endif
-#ifdef __STDC__
+#if defined(__STDC__) || defined(XP_OS2_VACPP)
 	va_start(ap, fmt);
 #else
 	va_start(ap);
 #endif
 #ifdef VSPRINTF_CHARSTAR
 	rp = vsprintf(str, fmt, ap);
 	va_end(ap);
 	return (strlen(rp));