Apply Win32 patch from Horak Daniel.

This commit is contained in:
Bruce Momjian 1999-01-17 06:20:06 +00:00
parent 298682d9e0
commit 7a6b562fdf
58 changed files with 484 additions and 86 deletions

View File

@ -6,7 +6,7 @@
# Copyright (c) 1998, Regents of the University of California
#
# IDENTIFICATION
# $Header: /cvsroot/pgsql/src/Makefile.shlib,v 1.5 1998/11/30 00:30:03 tgl Exp $
# $Header: /cvsroot/pgsql/src/Makefile.shlib,v 1.6 1999/01/17 06:18:08 momjian Exp $
#
#-------------------------------------------------------------------------
@ -156,6 +156,10 @@ ifeq ($(PORTNAME), unixware)
endif
endif
ifeq ($(PORTNAME), win)
install-shlib-dep := install-shlib
shlib := $(NAME)$(DLSUFFIX)
endif
# Default target definition. Note shlib is empty if not building a shlib.
@ -163,6 +167,7 @@ all: lib$(NAME).a $(shlib)
# Rules to build regular and shared libraries
ifneq ($(PORTNAME), win)
lib$(NAME).a: $(OBJS)
ifdef MK_NO_LORDER
$(AR) $(AROPT) $@ $(OBJS)
@ -170,10 +175,21 @@ else
$(AR) $(AROPT) $@ `lorder $(OBJS) | tsort`
endif
$(RANLIB) $@
endif
ifneq ($(shlib),)
ifneq ($(PORTNAME), win)
$(shlib): $(OBJS)
$(LD) $(LDFLAGS_SL) -o $@ $(OBJS) $(SHLIB_LINK)
else
$(shlib) lib$(NAME).a: $(OBJS) $(SRCDIR)/utils/dllinit.o
$(DLLTOOL) --export-all --output-def $(NAME).def $(OBJS)
$(DLLWRAP) -o $(shlib) --dllname $(shlib) --def $(NAME).def $(OBJS) $(SRCDIR)/utils/dllinit.o $(DLLINIT) $(SHLIB_LINK)
$(DLLTOOL) --dllname $(shlib) --def $(NAME).def --output-lib lib$(NAME).a
$(SRCDIR)/utils/dllinit.o: $(SRCDIR)/utils/dllinit.c
$(MAKE) -C $(SRCDIR)/utils dllinit.o
endif
endif
# Rules to install regular and shared libraries
@ -185,6 +201,7 @@ install-lib: lib$(NAME).a
install-shlib: $(shlib)
$(INSTALL) $(INSTL_SHLIB_OPTS) $(shlib) $(LIBDIR)/$(shlib)
ifneq ($(PORTNAME), win)
if [ "$(shlib)" != "lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)" ]; then \
cd $(LIBDIR); \
rm -f lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION); \
@ -195,3 +212,4 @@ install-shlib: $(shlib)
rm -f lib$(NAME)$(DLSUFFIX); \
$(LN_S) $(shlib) lib$(NAME)$(DLSUFFIX); \
fi
endif

View File

@ -34,7 +34,7 @@
#
#
# IDENTIFICATION
# $Header: /cvsroot/pgsql/src/backend/Makefile,v 1.34 1998/11/27 19:51:27 vadim Exp $
# $Header: /cvsroot/pgsql/src/backend/Makefile,v 1.35 1999/01/17 06:18:11 momjian Exp $
#
#-------------------------------------------------------------------------
@ -58,12 +58,34 @@ CFLAGS+= $(KRBFLAGS)
LDFLAGS+= $(KRBLIBS)
endif
ifeq ($(MAKE_DLL), true)
DLLOBJS=$(OBJS)
DLLOBJS+= ../utils/version.o
DLLLIBS= -L/usr/local/lib -lcygipc -lcrypt -lcygwin -lkernel32
postgres.def: $(DLLOBJS)
$(DLLTOOL) --export-all --output-def $@ $(DLLOBJS)
libpostgres.a: $(DLLOBJS) ../utils/dllinit.o postgres.def
$(DLLTOOL) --dllname postgres.exe --def postgres.def --output-lib $@
endif
all: postgres $(POSTGRES_IMP) global1.bki.source local1_template1.bki.source \
global1.description local1_template1.description
ifneq ($(PORTNAME), win)
postgres: fmgr.h $(OBJS) ../utils/version.o
$(CC) -o postgres $(OBJS) ../utils/version.o $(LDFLAGS)
else
postgres: $(DLLOBJS) ../utils/dllinit.o postgres.def libpostgres.a
dlltool --dllname $@$(X) --output-exp $@.exp --def postgres.def
gcc -g -o $@$(X) -Wl,--base-file,$@.base $@.exp $(DLLOBJS) $(DLLLIBS)
dlltool --dllname $@$(X) --base-file $@.base --output-exp $@.exp --def postgres.def
gcc -g -o $@$(X) $@.exp $(DLLOBJS) $(DLLLIBS)
rm $@.exp $@.base
endif
#.PHONY: postgres
$(OBJS): $(DIRS:%=%.dir)
@ -71,7 +93,10 @@ $(DIRS:%=%.dir):
$(MAKE) -C $(subst .dir,,$@) all
../utils/version.o:
$(MAKE) -C ../utils version.o
$(MAKE) -C ../utils version.o
../utils/dllinit.c:
$(MAKE) -C ../utils dllinit.o
global1.bki.source local1_template1.bki.source \
global1.description local1_template1.description: catalog/$@
@ -89,7 +114,6 @@ postgres.o: $(OBJS)
fast:
$(CC) -r -o postgres.o $(OBJS) $(LDFLAGS)
############################################################################
# The following targets are specified in make commands that appear in the
# make files in our subdirectories.
@ -104,9 +128,14 @@ fmgr.h:
#############################################################################
clean:
rm -f postgres $(POSTGRES_IMP) fmgr.h parse.h \
rm -f postgres$(X) $(POSTGRES_IMP) fmgr.h parse.h \
global1.bki.source local1_template1.bki.source \
global1.description local1_template1.description
ifeq ($(PORTNAME), win)
ifeq ($(MAKE_DLL), true)
rm -f postgres.dll postgres.def libpostgres.a
endif
endif
for i in $(DIRS); do $(MAKE) -C $$i clean; done
.DEFAULT:
@ -132,12 +161,18 @@ install: $(LIBDIR) $(BINDIR) $(HEADERDIR) postgres $(POSTGRES_IMP) fmgr.h\
global1.bki.source local1_template1.bki.source \
global1.description local1_template1.description \
libpq/pg_hba.conf.sample optimizer/geqo/pg_geqo.sample
$(INSTALL) $(INSTL_EXE_OPTS) postgres $(BINDIR)/postgres
$(INSTALL) $(INSTL_EXE_OPTS) postgres$(X) $(BINDIR)/postgres$(X)
ifeq ($(MAKE_EXPORTS), true)
$(INSTALL) $(INSTLOPTS) $(POSTGRES_IMP) $(LIBDIR)/$(POSTGRES_IMP)
endif
@rm -f $(BINDIR)/postmaster
ln -s postgres $(BINDIR)/postmaster
ln -s postgres$(X) $(BINDIR)/postmaster
ifeq ($(PORTNAME), win)
ifeq ($(MAKE_DLL), true)
# $(INSTALL) $(INSTLOPTS) postgres.dll $(BINDIR)/postgres.dll
$(INSTALL) $(INSTLOPTS) libpostgres.a $(LIBDIR)/libpostgres.a
endif
endif
$(INSTALL) $(INSTLOPTS) fmgr.h $(HEADERDIR)/fmgr.h
$(INSTALL) $(INSTLOPTS) global1.bki.source \
$(LIBDIR)/global1.bki.source
@ -152,7 +187,13 @@ endif
$(INSTALL) $(INSTLOPTS) optimizer/geqo/pg_geqo.sample \
$(LIBDIR)/pg_geqo.sample
$(BINDIR) $(LIBDIR) $(HEADERDIR):
#$(BINDIR) $(LIBDIR) $(HEADERDIR):
# mkdir $@
$(BINDIR):
mkdir $@
$(LIBDIR):
mkdir $@
$(HEADERDIR):
mkdir $@
#############################################################################

View File

@ -5,7 +5,7 @@
*
*
* IDENTIFICATION
* $Id: nbtsort.c,v 1.33 1998/09/01 04:27:07 momjian Exp $
* $Id: nbtsort.c,v 1.34 1999/01/17 06:18:12 momjian Exp $
*
* NOTES
*
@ -420,7 +420,11 @@ _bt_tapecreate(char *fname)
tape->bttb_magic = BTTAPEMAGIC;
#ifndef __CYGWIN32__
tape->bttb_fd = FileNameOpenFile(fname, O_RDWR | O_CREAT | O_TRUNC, 0600);
#else
tape->bttb_fd = FileNameOpenFile(fname, O_RDWR | O_CREAT | O_TRUNC | O_BINARY, 0600);
#endif
Assert(tape->bttb_fd >= 0);
/* initialize the buffer */

View File

@ -7,7 +7,7 @@
* Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.52 1998/11/27 19:51:45 vadim Exp $
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.53 1999/01/17 06:18:14 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -17,6 +17,9 @@
#include <signal.h>
#include <setjmp.h>
#include <string.h>
#ifdef __CYGWIN32__
#include <getopt.h>
#endif
#define BOOTSTRAP_INCLUDE /* mask out stuff in tcop/tcopprot.h */

View File

@ -4,7 +4,7 @@
# Makefile for catalog
#
# IDENTIFICATION
# $Header: /cvsroot/pgsql/src/backend/catalog/Makefile,v 1.14 1998/10/08 18:29:19 momjian Exp $
# $Header: /cvsroot/pgsql/src/backend/catalog/Makefile,v 1.15 1999/01/17 06:18:14 momjian Exp $
#
#-------------------------------------------------------------------------
@ -39,17 +39,26 @@ LOCALBKI_SRCS= $(addprefix ../../include/catalog/, \
)
global1.bki.source: $(GENBKI) $(GLOBALBKI_SRCS)
ifneq ($(PORTNAME), win)
sh $(SHOPTS) $(GENBKI) $(BKIOPTS) $(GLOBALBKI_SRCS) > $@ 2>global1.description
else
$(GENBKI) $(BKIOPTS) $(GLOBALBKI_SRCS) > $@ 2>global1.description
endif
local1_template1.bki.source: $(GENBKI) $(LOCALBKI_SRCS)
ifneq ($(PORTNAME), win)
sh $(SHOPTS) $(GENBKI) $(BKIOPTS) $(LOCALBKI_SRCS) > $@ 2>local1_template1.description
else
$(GENBKI) $(BKIOPTS) $(LOCALBKI_SRCS) > $@ 2>local1_template1.description
endif
depend dep:
$(CC) -MM $(CFLAGS) *.c >depend
clean:
rm -f SUBSYS.o $(OBJS) global1.bki.source local1_template1.bki.source \
global1.description local1_template1.description
global1.description local1_template1.description \
$(GENBKI)
ifeq (depend,$(wildcard depend))
include depend

View File

@ -6,7 +6,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.66 1999/01/11 03:56:05 scrappy Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.67 1999/01/17 06:18:15 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -250,7 +250,11 @@ DoCopy(char *relname, bool binary, bool oids, bool from, bool pipe,
}
else
{
#ifndef __CYGWIN32__
fp = AllocateFile(filename, "r");
#else
fp = AllocateFile(filename, "rb");
#endif
if (fp == NULL)
elog(ERROR, "COPY command, running in backend with "
"effective uid %d, could not open file '%s' for "
@ -277,7 +281,11 @@ DoCopy(char *relname, bool binary, bool oids, bool from, bool pipe,
mode_t oumask; /* Pre-existing umask value */
oumask = umask((mode_t) 0);
#ifndef __CYGWIN32__
fp = AllocateFile(filename, "w");
#else
fp = AllocateFile(filename, "wb");
#endif
umask(oumask);
if (fp == NULL)
elog(ERROR, "COPY command, running in backend with "

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.28 1998/12/15 12:45:55 vadim Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.29 1999/01/17 06:18:17 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -305,7 +305,11 @@ stop_vacuum(char *dbpath, char *dbname)
else
snprintf(filename, 256, "%s%c%s.vacuum", dbpath, SEP_CHAR, dbname);
#ifndef __CYGWIN32__
if ((fp = AllocateFile(filename, "r")) != NULL)
#else
if ((fp = AllocateFile(filename, "rb")) != NULL)
#endif
{
fscanf(fp, "%d", &pid);
FreeFile(fp);

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.92 1998/12/15 12:46:01 vadim Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.93 1999/01/17 06:18:18 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -187,7 +187,11 @@ vc_init()
{
int fd;
#ifndef __CYGWIN32__
if ((fd = open("pg_vlock", O_CREAT | O_EXCL, 0600)) < 0)
#else
if ((fd = open("pg_vlock", O_CREAT | O_EXCL | O_BINARY, 0600)) < 0)
#endif
{
elog(ERROR, "Can't create lock file. Is another vacuum cleaner running?\n\
\tIf not, you may remove the pg_vlock file in the %s\n\

View File

@ -6,7 +6,7 @@
* Copyright (c) 1994, Regents of the University of California
*
*
* $Id: nodeHash.c,v 1.28 1998/12/15 12:46:06 vadim Exp $
* $Id: nodeHash.c,v 1.29 1999/01/17 06:18:19 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -100,8 +100,13 @@ ExecHash(Hash *node)
batches = (File *) palloc(nbatch * sizeof(File));
for (i = 0; i < nbatch; i++)
{
#ifndef __CYGWIN32__
batches[i] = FileNameOpenFile(ABSADDR(innerbatchNames[i]),
O_CREAT | O_RDWR, 0600);
#else
batches[i] = FileNameOpenFile(ABSADDR(innerbatchNames[i]),
O_CREAT | O_RDWR | O_BINARY, 0600);
#endif
}
hashstate->hashBatches = batches;
batchPos = (RelativeAddr *) ABSADDR(hashtable->innerbatchPos);

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/nodeHashjoin.c,v 1.14 1998/11/27 19:52:02 vadim Exp $
* $Header: /cvsroot/pgsql/src/backend/executor/nodeHashjoin.c,v 1.15 1999/01/17 06:18:21 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -172,9 +172,15 @@ ExecHashJoin(HashJoin *node)
palloc(nbatch * sizeof(File));
for (i = 0; i < nbatch; i++)
{
#ifndef __CYGWIN32__
outerbatches[i] = FileNameOpenFile(
ABSADDR(outerbatchNames[i]),
O_CREAT | O_RDWR, 0600);
ABSADDR(outerbatchNames[i]),
O_CREAT | O_RDWR, 0600);
#else
outerbatches[i] = FileNameOpenFile(
ABSADDR(outerbatchNames[i]),
O_CREAT | O_RDWR | O_BINARY, 0600);
#endif
}
hjstate->hj_OuterBatches = outerbatches;

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/libpq/be-fsstubs.c,v 1.26 1998/09/01 04:28:46 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/libpq/be-fsstubs.c,v 1.27 1999/01/17 06:18:24 momjian Exp $
*
* NOTES
* This should be moved to a more appropriate place. It is here
@ -267,7 +267,11 @@ lo_import(text *filename)
* open the file to be read in
*/
StrNCpy(fnamebuf, VARDATA(filename), VARSIZE(filename) - VARHDRSZ + 1);
#ifndef __CYGWIN32__
fd = open(fnamebuf, O_RDONLY, 0666);
#else
fd = open(fnamebuf, O_RDONLY | O_BINARY, 0666);
#endif
if (fd < 0)
{ /* error */
elog(ERROR, "be_lo_import: can't open unix file\"%s\"\n",
@ -341,7 +345,11 @@ lo_export(Oid lobjId, text *filename)
*/
oumask = umask((mode_t) 0);
StrNCpy(fnamebuf, VARDATA(filename), VARSIZE(filename) - VARHDRSZ + 1);
#ifndef __CYGWIN32__
fd = open(fnamebuf, O_CREAT | O_WRONLY | O_TRUNC, 0666);
#else
fd = open(fnamebuf, O_CREAT | O_WRONLY | O_TRUNC | O_BINARY, 0666);
#endif
umask(oumask);
if (fd < 0)
{ /* error */

View File

@ -9,7 +9,7 @@
* Dec 17, 1997 - Todd A. Brandys
* Orignal Version Completed.
*
* $Id: crypt.c,v 1.13 1998/12/14 06:50:24 scrappy Exp $
* $Id: crypt.c,v 1.14 1999/01/17 06:18:25 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -76,7 +76,11 @@ crypt_openpwdfile()
FILE *pwdfile;
filename = crypt_getpwdfilename();
#ifndef __CYGWIN32__
pwdfile = AllocateFile(filename, "r");
#else
pwdfile = AllocateFile(filename, "rb");
#endif
return pwdfile;
}

View File

@ -5,7 +5,7 @@
* wherein you authenticate a user by seeing what IP address the system
* says he comes from and possibly using ident).
*
* $Id: hba.c,v 1.37 1998/12/14 06:50:25 scrappy Exp $
* $Id: hba.c,v 1.38 1999/01/17 06:18:25 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -390,7 +390,11 @@ find_hba_entry(SockAddr *raddr, const char *user, const char *database,
old_conf_file = (char *) palloc(bufsize);
snprintf(old_conf_file, bufsize, "%s/%s", DataDir, OLD_CONF_FILE);
#ifndef __CYGWIN32__
if ((fd = open(old_conf_file, O_RDONLY, 0)) != -1)
#else
if ((fd = open(old_conf_file, O_RDONLY | O_BINARY, 0)) != -1)
#endif
{
/* Old config file exists. Tell this guy he needs to upgrade. */
close(fd);
@ -801,7 +805,11 @@ verify_against_usermap(const char *pguser,
map_file = (char *) palloc(bufsize);
snprintf(map_file, bufsize, "%s/%s", DataDir, MAP_FILE);
#ifndef __CYGWIN32__
file = AllocateFile(map_file, "r");
#else
file = AllocateFile(map_file, "rb");
#endif
if (file == NULL)
{
/* The open of the map file failed. */
@ -973,7 +981,11 @@ GetCharSetByHost(char *TableName, int host, const char *DataDir)
bufsize = (strlen(DataDir) + strlen(CHARSET_FILE) + 2) * sizeof(char);
map_file = (char *) palloc(bufsize);
snprintf(map_file, bufsize, "%s/%s", DataDir, CHARSET_FILE);
#ifndef __CYGWIN32__
file = fopen(map_file, "r");
#else
file = fopen(map_file, "rb");
#endif
if (file == NULL)
{
return;

View File

@ -1,7 +1,7 @@
/*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: password.c,v 1.19 1998/12/14 06:50:26 scrappy Exp $
* $Id: password.c,v 1.20 1999/01/17 06:18:26 momjian Exp $
*
*/
@ -27,7 +27,11 @@ verify_password(char *auth_arg, char *user, char *password)
strcat(pw_file_fullname, "/");
strcat(pw_file_fullname, auth_arg);
#ifndef __CYGWIN32__
pw_file = AllocateFile(pw_file_fullname, "r");
#else
pw_file = AllocateFile(pw_file_fullname, "rb");
#endif
if (!pw_file)
{
snprintf(PQerrormsg, ERROR_MSG_LENGTH,

View File

@ -5,7 +5,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: pqcomm.c,v 1.62 1999/01/17 03:10:23 tgl Exp $
* $Id: pqcomm.c,v 1.63 1999/01/17 06:18:26 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -466,7 +466,11 @@ StreamServerPort(char *hostName, short portName, int *fdP)
* can safely delete the file.
*/
#ifdef HAVE_FCNTL_SETLK
#ifndef __CYGWIN32__
if ((lock_fd = open(sock_path, O_WRONLY | O_NONBLOCK, 0666)) >= 0)
#else
if ((lock_fd = open(sock_path, O_WRONLY | O_NONBLOCK | O_BINARY, 0666)) >= 0)
#endif
{
struct flock lck;
@ -519,7 +523,11 @@ StreamServerPort(char *hostName, short portName, int *fdP)
* lock_fd is left open to keep the lock.
*/
#ifdef HAVE_FCNTL_SETLK
#ifndef __CYGWIN32__
if ((lock_fd = open(sock_path, O_WRONLY | O_NONBLOCK, 0666)) >= 0)
#else
if ((lock_fd = open(sock_path, O_WRONLY | O_NONBLOCK | O_BINARY, 0666)) >= 0)
#endif
{
struct flock lck;

View File

@ -5,7 +5,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: geqo_params.c,v 1.10 1998/09/01 03:23:11 momjian Exp $
* $Id: geqo_params.c,v 1.11 1999/01/17 06:18:27 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -91,7 +91,11 @@ geqo_params(int string_length)
sprintf(conf_file, "%s/%s", DataDir, GEQO_FILE);
/* open the config file */
#ifndef __CYGWIN32__
file = AllocateFile(conf_file, "r");
#else
file = AllocateFile(conf_file, "rb");
#endif
if (file)
{

View File

@ -36,6 +36,7 @@
#include "pathnames.h"
#endif
#include <features.h>
#include "postgres.h"
#include "regex/cdefs.h"
@ -73,7 +74,7 @@ typedef unsigned long long ulong_long;
* causing nast effects.
**************************************************************/
/*static char _id[] = "$Id: snprintf.c,v 1.16 1999/01/17 03:22:49 tgl Exp $";*/
/*static char _id[] = "$Id: snprintf.c,v 1.17 1999/01/17 06:18:33 momjian Exp $";*/
static char *end;
static int SnprfOverflow;

View File

@ -10,7 +10,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.98 1998/11/29 01:51:56 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.99 1999/01/17 06:18:34 momjian Exp $
*
* NOTES
*
@ -73,6 +73,10 @@
#include <sys/select.h>
#endif
#ifdef __CYGWIN32__
#include <getopt.h>
#endif
#include "storage/ipc.h"
#include "libpq/libpq.h"
#include "libpq/auth.h"
@ -170,7 +174,9 @@ static int real_argc;
static char Execfile[MAXPATHLEN] = "";
static int ServerSock_INET = INVALID_SOCK; /* stream socket server */
#ifndef __CYGWIN32__
static int ServerSock_UNIX = INVALID_SOCK; /* stream socket server */
#endif
/*
* Set by the -o option
@ -268,7 +274,11 @@ checkDataDir(const char *DataDir, bool *DataDirOK)
sprintf(path, "%s%cbase%ctemplate1%cpg_class",
DataDir, SEP_CHAR, SEP_CHAR, SEP_CHAR);
#ifndef __CYGWIN32__
fp = AllocateFile(path, "r");
#else
fp = AllocateFile(path, "rb");
#endif
if (fp == NULL)
{
fprintf(stderr, "%s does not find the database system. "
@ -522,6 +532,7 @@ PostmasterMain(int argc, char *argv[])
exit(1);
}
}
#ifndef __CYGWIN32__
status = StreamServerPort(NULL, PostPortName, &ServerSock_UNIX);
if (status != STATUS_OK)
{
@ -529,7 +540,7 @@ PostmasterMain(int argc, char *argv[])
progname);
exit(1);
}
#endif
/* set up shared memory and semaphores */
EnableMemoryContext(TRUE);
reset_shared(PostPortName);
@ -584,7 +595,11 @@ pmdaemonize(void)
exit(1);
}
#endif
#ifndef __CYGWIN32__
i = open(NULL_DEV, O_RDWR);
#else
i = open(NULL_DEV, O_RDWR | O_BINARY);
#endif
dup2(i, 0);
dup2(i, 1);
dup2(i, 2);
@ -688,12 +703,14 @@ ServerLoop(void)
/* new connection pending on our well-known port's socket */
#ifndef __CYGWIN32__
if (ServerSock_UNIX != INVALID_SOCK &&
FD_ISSET(ServerSock_UNIX, &rmask) &&
(port = ConnCreate(ServerSock_UNIX)) != NULL)
PacketReceiveSetup(&port->pktInfo,
readStartupPacket,
(void *) port);
#endif
if (ServerSock_INET != INVALID_SOCK &&
FD_ISSET(ServerSock_INET, &rmask) &&
@ -802,6 +819,7 @@ initMasks(fd_set *rmask, fd_set *wmask)
FD_ZERO(rmask);
FD_ZERO(wmask);
#ifndef __CYGWIN32__
if (ServerSock_UNIX != INVALID_SOCK)
{
FD_SET(ServerSock_UNIX, rmask);
@ -809,6 +827,7 @@ initMasks(fd_set *rmask, fd_set *wmask)
if (ServerSock_UNIX > nsocks)
nsocks = ServerSock_UNIX;
}
#endif
if (ServerSock_INET != INVALID_SOCK)
{
@ -1437,7 +1456,9 @@ DoBackend(Port *port)
/* Close the postmater sockets */
if (NetServer)
StreamClose(ServerSock_INET);
#ifndef __CYGWIN32__
StreamClose(ServerSock_UNIX);
#endif
/* Save port for ps status */
MyProcPort = port;
@ -1546,8 +1567,10 @@ ExitPostmaster(int status)
*/
if (ServerSock_INET != INVALID_SOCK)
StreamClose(ServerSock_INET);
#ifndef __CYGWIN32__
if (ServerSock_UNIX != INVALID_SOCK)
StreamClose(ServerSock_UNIX);
#endif
proc_exit(status);
}

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/smgr/md.c,v 1.39 1998/09/01 04:32:06 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/smgr/md.c,v 1.40 1999/01/17 06:18:40 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -140,7 +140,11 @@ mdcreate(Relation reln)
char *path;
path = relpath(reln->rd_rel->relname.data);
#ifndef __CYGWIN32__
fd = FileNameOpenFile(path, O_RDWR | O_CREAT | O_EXCL, 0600);
#else
fd = FileNameOpenFile(path, O_RDWR | O_CREAT | O_EXCL | O_BINARY, 0600);
#endif
/*
* If the file already exists and is empty, we pretend that the create
@ -157,7 +161,11 @@ mdcreate(Relation reln)
{
if (!IsBootstrapProcessingMode())
return -1;
#ifndef __CYGWIN32__
fd = FileNameOpenFile(path, O_RDWR, 0600); /* Bootstrap */
#else
fd = FileNameOpenFile(path, O_RDWR | O_BINARY, 0600); /* Bootstrap */
#endif
if (fd < 0)
return -1;
}
@ -290,11 +298,19 @@ mdopen(Relation reln)
path = relpath(reln->rd_rel->relname.data);
#ifndef __CYGWIN32__
fd = FileNameOpenFile(path, O_RDWR, 0600);
#else
fd = FileNameOpenFile(path, O_RDWR | O_BINARY, 0600);
#endif
/* this should only happen during bootstrap processing */
if (fd < 0)
#ifndef __CYGWIN32__
fd = FileNameOpenFile(path, O_RDWR | O_CREAT | O_EXCL, 0600);
#else
fd = FileNameOpenFile(path, O_RDWR | O_CREAT | O_EXCL | O_BINARY, 0600);
#endif
vfd = _fdvec_alloc();
if (vfd < 0)
@ -622,7 +638,11 @@ mdblindwrt(char *dbstr,
}
#endif
#ifndef __CYGWIN32__
if ((fd = open(path, O_RDWR, 0600)) < 0)
#else
if ((fd = open(path, O_RDWR | O_BINARY, 0600)) < 0)
#endif
return SM_FAIL;
/* seek to the right spot */
@ -900,7 +920,11 @@ _mdfd_openseg(Relation reln, int segno, int oflags)
fullpath = path;
/* open the file */
#ifndef __CYGWIN32__
fd = PathNameOpenFile(fullpath, O_RDWR | oflags, 0600);
#else
fd = PathNameOpenFile(fullpath, O_RDWR | O_BINARY | oflags, 0600);
#endif
if (dofree)
pfree(fullpath);

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.95 1998/12/16 11:53:52 vadim Exp $
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.96 1999/01/17 06:18:42 momjian Exp $
*
* NOTES
* this is the "main" module of the postgres backend and
@ -39,6 +39,9 @@
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#ifdef __CYGWIN32__
#include <getopt.h>
#endif
#include "postgres.h"
#include "miscadmin.h"
@ -1451,7 +1454,11 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
{
fprintf(stderr,
"Postmaster flag set: no port number specified, use /dev/null\n");
#ifndef __CYGWIN32__
Portfd = open(NULL_DEV, O_RDWR, 0666);
#else
Portfd = open(NULL_DEV, O_RDWR | O_BINARY, 0666);
#endif
}
pq_init(Portfd);
whereToSendOutput = Remote;
@ -1520,7 +1527,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
if (!IsUnderPostmaster)
{
puts("\nPOSTGRES backend interactive interface ");
puts("$Revision: 1.95 $ $Date: 1998/12/16 11:53:52 $\n");
puts("$Revision: 1.96 $ $Date: 1999/01/17 06:18:42 $\n");
}
/* ----------------

View File

@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.51 1998/12/18 09:10:36 vadim Exp $
* $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.52 1999/01/17 06:18:44 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -620,7 +620,11 @@ ProcessUtility(Node *parsetree,
filename = stmt->filename;
closeAllVfds();
#ifndef __CYGWIN32__
if ((fp = AllocateFile(filename, "r")) == NULL)
#else
if ((fp = AllocateFile(filename, "rb")) == NULL)
#endif
elog(ERROR, "LOAD: could not open file '%s'", filename);
FreeFile(fp);
load_file(filename);

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.34 1998/09/01 04:32:24 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.35 1999/01/17 06:18:45 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -550,7 +550,11 @@ _ReadLOArray(char *str,
{
FILE *afd;
#ifndef __CYGWIN32__
if ((afd = AllocateFile(accessfile, "r")) == NULL)
#else
if ((afd = AllocateFile(accessfile, "r")) == NULL)
#endif
elog(ERROR, "unable to open access pattern file");
*chunkFlag = true;
retStr = _ChunkArray(*fd, afd, ndim, dim, baseSize, nbytes,

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.52 1998/12/15 12:46:37 vadim Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.53 1999/01/17 06:18:51 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -1861,7 +1861,11 @@ init_irels(void)
int i;
int relno;
#ifndef __CYGWIN32__
if ((fd = FileNameOpenFile(INIT_FILENAME, O_RDONLY, 0600)) < 0)
#else
if ((fd = FileNameOpenFile(INIT_FILENAME, O_RDONLY | O_BINARY, 0600)) < 0)
#endif
{
write_irels();
return;
@ -2022,7 +2026,11 @@ write_irels(void)
int relno;
RelationBuildDescInfo bi;
#ifndef __CYGWIN32__
fd = FileNameOpenFile(INIT_FILENAME, O_WRONLY | O_CREAT | O_TRUNC, 0600);
#else
fd = FileNameOpenFile(INIT_FILENAME, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0600);
#endif
if (fd < 0)
elog(FATAL, "cannot create init file %s", INIT_FILENAME);

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.24 1998/10/08 18:30:16 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.25 1999/01/17 06:18:54 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -338,7 +338,11 @@ SetCharSet()
map_file = (char *) malloc((strlen(DataDir) +
strlen(p) + 2) * sizeof(char));
sprintf(map_file, "%s/%s", DataDir, p);
#ifndef __CYGWIN32__
file = fopen(map_file, "r");
#else
file = fopen(map_file, "rb");
#endif
if (file == NULL)
return;
eof = false;

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/init/postinit.c,v 1.35 1998/09/01 04:33:17 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/init/postinit.c,v 1.36 1999/01/17 06:18:55 momjian Exp $
*
* NOTES
* InitPostgres() is the function called from PostgresMain
@ -176,7 +176,11 @@ VerifySystemDatabase()
errormsg[0] = '\0';
#ifndef __CYGWIN32__
if ((fd = open(DataDir, O_RDONLY, 0)) == -1)
#else
if ((fd = open(DataDir, O_RDONLY | O_DIROPEN, 0)) == -1)
#endif
sprintf(errormsg, "Database system does not exist. "
"PGDATA directory '%s' not found.\n\tNormally, you "
"create a database system by running initdb.",
@ -212,7 +216,11 @@ VerifyMyDatabase()
name = DatabaseName;
myPath = DatabasePath;
#ifndef __CYGWIN32__
if ((fd = open(myPath, O_RDONLY, 0)) == -1)
#else
if ((fd = open(myPath, O_RDONLY | O_DIROPEN, 0)) == -1)
#endif
sprintf(errormsg,
"Database '%s' does not exist."
"\n\tWe know this because the directory '%s' does not exist."

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/misc/Attic/database.c,v 1.21 1998/11/27 19:52:29 vadim Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/misc/Attic/database.c,v 1.22 1999/01/17 06:18:58 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -198,7 +198,11 @@ GetRawDatabaseInfo(char *name, int4 *owner, Oid *db_id, char *path, int *encodin
sprintf(dbfname, "%s%cpg_database", DataDir, SEP_CHAR);
fileflags = O_RDONLY;
#ifndef __CYGWIN32__
if ((dbfd = open(dbfname, O_RDONLY, 0)) < 0)
#else
if ((dbfd = open(dbfname, O_RDONLY | O_BINARY, 0)) < 0)
#endif
elog(FATAL, "Cannot open %s", dbfname);
pfree(dbfname);

View File

@ -345,7 +345,11 @@ read_pg_options(SIGNAL_ARGS)
}
snprintf(buffer, BUF_SIZE - 1, "%s/%s", DataDir, "pg_options");
#ifndef __CYGWIN32__
if ((fd = open(buffer, O_RDONLY)) < 0)
#else
if ((fd = open(buffer, O_RDONLY | O_BINARY)) < 0)
#endif
return;
if ((n = read(fd, buffer, BUF_SIZE - 1)) > 0)

View File

@ -4,7 +4,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: psort.c,v 1.46 1999/01/01 04:48:49 momjian Exp $
* $Id: psort.c,v 1.47 1999/01/17 06:19:02 momjian Exp $
*
* NOTES
* Sorts the first relation into the second relation.
@ -1033,8 +1033,11 @@ gettape()
StrNCpy(tp->tl_name, uniqueName, MAXPGPATH);
#ifndef __CYGWIN32__
file = AllocateFile(tp->tl_name, "w+");
#else
file = AllocateFile(tp->tl_name, "w+b");
#endif
if (file == NULL)
elog(ERROR, "Open: %s in %s line %d, %s", tp->tl_name,
__FILE__, __LINE__, strerror(errno));

View File

@ -7,7 +7,7 @@
#
#
# IDENTIFICATION
# $Header: /cvsroot/pgsql/src/bin/pg_dump/Attic/Makefile.in,v 1.10 1998/08/30 05:06:53 momjian Exp $
# $Header: /cvsroot/pgsql/src/bin/pg_dump/Attic/Makefile.in,v 1.11 1999/01/17 06:19:05 momjian Exp $
#
#-------------------------------------------------------------------------
@ -39,7 +39,7 @@ submake:
$(MAKE) -C $(LIBPQDIR) libpq.a
install: pg_dump
$(INSTALL) $(INSTL_EXE_OPTS) pg_dump $(BINDIR)/pg_dump
$(INSTALL) $(INSTL_EXE_OPTS) pg_dump$(X) $(BINDIR)/pg_dump$(X)
$(INSTALL) $(INSTL_EXE_OPTS) pg_dumpall $(BINDIR)/pg_dumpall
$(INSTALL) $(INSTL_EXE_OPTS) pg_upgrade $(BINDIR)/pg_upgrade
@ -47,7 +47,7 @@ depend dep:
$(CC) -MM $(CFLAGS) *.c >depend
clean:
rm -f pg_dump $(OBJS)
rm -f pg_dump$(X) $(OBJS)
ifeq (depend,$(wildcard depend))
include depend

View File

@ -21,7 +21,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.97 1998/12/13 23:41:32 thomas Exp $
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.98 1999/01/17 06:19:05 momjian Exp $
*
* Modifications - 6/10/96 - dave@bensoft.com - version 1.13.dhb
*
@ -76,6 +76,10 @@
#include <termios.h>
#endif
#ifdef __CYGWIN32__
#include <getopt.h>
#endif
#include "pg_dump.h"
static void dumpSequence(FILE *fout, TableInfo tbinfo);
@ -629,7 +633,11 @@ main(int argc, char **argv)
g_fout = stdout;
else
{
#ifndef __CYGWIN32__
g_fout = fopen(filename, "w");
#else
g_fout = fopen(filename, "wb");
#endif
if (g_fout == NULL)
{
fprintf(stderr,

View File

@ -7,7 +7,7 @@
#
#
# IDENTIFICATION
# $Header: /cvsroot/pgsql/src/bin/pg_id/Attic/Makefile,v 1.11 1998/04/06 16:51:04 momjian Exp $
# $Header: /cvsroot/pgsql/src/bin/pg_id/Attic/Makefile,v 1.12 1999/01/17 06:19:10 momjian Exp $
#
#-------------------------------------------------------------------------
@ -33,13 +33,13 @@ $(LIBPQDIR)/libpq.a:
$(MAKE) -C $(LIBPQDIR) libpq.a
install: pg_id
$(INSTALL) $(INSTL_EXE_OPTS) pg_id $(BINDIR)/pg_id
$(INSTALL) $(INSTL_EXE_OPTS) pg_id$(X) $(BINDIR)/pg_id$(X)
depend dep:
$(CC) -MM $(CFLAGS) *.c >depend
clean:
rm -f pg_id $(OBJS)
rm -f pg_id$(X) $(OBJS)
ifeq (depend,$(wildcard depend))
include depend

View File

@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_id/Attic/pg_id.c,v 1.6 1998/06/15 19:30:03 momjian Exp $
* $Header: /cvsroot/pgsql/src/bin/pg_id/Attic/pg_id.c,v 1.7 1999/01/17 06:19:10 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -18,7 +18,9 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#ifdef __CYGWIN32__
#include <getopt.h>
#endif
int
main(int argc, char **argv)

View File

@ -15,7 +15,7 @@ pg_passwd: $(OBJS)
$(CC) -o pg_passwd $(OBJS) $(LDFLAGS)
install: pg_passwd
$(INSTALL) $(INSTL_EXE_OPTS) pg_passwd $(BINDIR)/pg_passwd
$(INSTALL) $(INSTL_EXE_OPTS) pg_passwd$(X) $(BINDIR)/pg_passwd$(X)
.PHONY: submake
submake:
@ -25,7 +25,7 @@ depend dep:
$(CC) -MM $(CFLAGS) *.c >depend
clean:
rm -f pg_passwd $(OBJS)
rm -f pg_passwd$(X) $(OBJS)
ifeq (depend,$(wildcard depend))
include depend

View File

@ -63,7 +63,11 @@ read_pwd_file(char *filename)
int i;
try_again:
#ifndef __CYGWIN32__
fp = fopen(filename, "r");
#else
fp = fopen(filename, "rb");
#endif
if (fp == NULL)
{
if (errno == ENOENT)
@ -75,7 +79,11 @@ try_again:
{
case 'y':
case 'Y':
#ifndef __CYGWIN32__
fp = fopen(filename, "w");
#else
fp = fopen(filename, "wb");
#endif
if (fp == NULL)
{
perror(filename);
@ -193,7 +201,11 @@ link_again:
}
/* open file */
#ifndef __CYGWIN32__
if ((fp = fopen(filename, "w")) == NULL)
#else
if ((fp = fopen(filename, "wb")) == NULL)
#endif
{
perror(filename);
exit(1);

View File

@ -7,7 +7,7 @@
#
#
# IDENTIFICATION
# $Header: /cvsroot/pgsql/src/bin/pg_version/Attic/Makefile.in,v 1.5 1998/04/06 16:51:27 momjian Exp $
# $Header: /cvsroot/pgsql/src/bin/pg_version/Attic/Makefile.in,v 1.6 1999/01/17 06:19:14 momjian Exp $
#
#-------------------------------------------------------------------------
@ -28,13 +28,13 @@ submake:
$(MAKE) -C ../../utils version.o
install: pg_version
$(INSTALL) $(INSTL_EXE_OPTS) pg_version $(BINDIR)/pg_version
$(INSTALL) $(INSTL_EXE_OPTS) pg_version$(X) $(BINDIR)/pg_version$(X)
depend dep:
$(CC) -MM $(CFLAGS) *.c >depend
clean:
rm -f pg_version pg_version.o
rm -f pg_version$(X) pg_version.o
ifeq (depend,$(wildcard depend))
include depend

View File

@ -7,7 +7,7 @@
#
#
# IDENTIFICATION
# $Header: /cvsroot/pgsql/src/bin/psql/Attic/Makefile.in,v 1.14 1998/11/30 00:30:05 tgl Exp $
# $Header: /cvsroot/pgsql/src/bin/psql/Attic/Makefile.in,v 1.15 1999/01/17 06:19:19 momjian Exp $
#
#-------------------------------------------------------------------------
@ -43,13 +43,13 @@ submake:
$(MAKE) -C $(LIBPQDIR) libpq.a
install: psql
$(INSTALL) $(INSTL_EXE_OPTS) psql $(BINDIR)/psql
$(INSTALL) $(INSTL_EXE_OPTS) psql$(X) $(BINDIR)/psql$(X)
depend dep:
$(CC) -MM $(CFLAGS) *.c >depend
clean:
rm -f psql $(OBJS)
rm -f psql$(X) $(OBJS)
ifeq (depend,$(wildcard depend))
include depend

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.165 1998/12/14 04:59:58 momjian Exp $
* $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.166 1999/01/17 06:19:19 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -40,6 +40,9 @@
#ifdef HAVE_TERMIOS_H
#include <termios.h>
#endif
#ifdef __CYGWIN32__
#include <getopt.h>
#endif
#ifdef HAVE_LIBREADLINE
#ifdef HAVE_READLINE_H
@ -1436,9 +1439,17 @@ do_copy(const char *args, PsqlSettings *pset)
strcat(query, " TO stdout");
if (from)
#ifndef __CYGWIN32__
copystream = fopen(file, "r");
#else
copystream = fopen(file, "rb");
#endif
else
#ifndef __CYGWIN32__
copystream = fopen(file, "w");
#else
copystream = fopen(file, "wb");
#endif
if (copystream == NULL)
fprintf(stderr,
"Unable to open file %s which to copy, errno = %s (%d).",
@ -2139,7 +2150,11 @@ HandleSlashCmds(PsqlSettings *pset,
}
stat(lastfile, &st);
editFile(lastfile);
#ifndef __CYGWIN32__
if ((stat(lastfile, &st2) == -1) || ((fd = fopen(lastfile, "r")) == NULL))
#else
if ((stat(lastfile, &st2) == -1) || ((fd = fopen(lastfile, "rb")) == NULL))
#endif
{
perror(lastfile);
break;
@ -2209,7 +2224,11 @@ HandleSlashCmds(PsqlSettings *pset,
fprintf(stderr, "\\i must be followed by a file name\n");
break;
}
#ifndef __CYGWIN32__
if ((fd = fopen(optarg, "r")) == NULL)
#else
if ((fd = fopen(optarg, "rb")) == NULL)
#endif
{
fprintf(stderr, "file named %s could not be opened\n", optarg);
break;
@ -2305,7 +2324,11 @@ HandleSlashCmds(PsqlSettings *pset,
fprintf(stderr, "\\w must be followed by a file name\n");
break;
}
#ifndef __CYGWIN32__
if ((fd = fopen(optarg, "w")) == NULL)
#else
if ((fd = fopen(optarg, "w")) == NULL)
#endif
{
fprintf(stderr, "file named %s could not be opened\n", optarg);
break;
@ -3086,7 +3109,11 @@ setFout(PsqlSettings *pset, char *fname)
if (*fname == '|')
{
pqsignal(SIGPIPE, SIG_IGN);
#ifndef __CYGWIN32__
pset->queryFout = popen(fname + 1, "w");
#else
pset->queryFout = popen(fname + 1, "wb");
#endif
pset->pipe = 1;
}
else

10
src/configure vendored
View File

@ -668,8 +668,6 @@ PORTNAME=${os}
echo "checking echo setting..."
if echo '\c' | grep -s c >/dev/null 2>&1
then
@ -760,7 +758,7 @@ fi
if test "$INCLUDE_DIRS"; then
for dir in $INCLUDE_DIRS; do
for dir in $INCLUDE_DIRS $SRCH_INC; do
if test -d "$dir"; then
PGSQL_CPPFLAGS="$PGSQL_CPPFLAGS -I$dir"
else
@ -798,7 +796,7 @@ fi
if test "$LIBRARY_DIRS"; then
for dir in $LIBRARY_DIRS; do
for dir in $LIBRARY_DIRS $SRCH_LIB; do
if test -d "$dir"; then
PGSQL_LDFLAGS="$PGSQL_LDFLAGS -L$dir"
else
@ -1549,11 +1547,11 @@ esac
ECHO_N_OUT=`echo -n "" | wc -c`
ECHO_C_OUT=`echo "\c" | wc -c`
if test "$ECHO_N_OUT" -eq 0; then
if test $ECHO_N_OUT -eq 0; then
DASH_N='-n'
BACKSLASH_C=
else
if test "ECHO_C_OUT" -eq 0; then
if test $ECHO_C_OUT -eq 0; then
DASH_N=
BACKSLASH_C='\\\\c'
else

View File

@ -164,7 +164,7 @@ AC_ARG_WITH(includes,
])
if test "$INCLUDE_DIRS"; then
for dir in $INCLUDE_DIRS; do
for dir in $INCLUDE_DIRS $SRCH_INC; do
if test -d "$dir"; then
PGSQL_CPPFLAGS="$PGSQL_CPPFLAGS -I$dir"
else
@ -196,7 +196,7 @@ AC_ARG_WITH(libraries,
])
if test "$LIBRARY_DIRS"; then
for dir in $LIBRARY_DIRS; do
for dir in $LIBRARY_DIRS $SRCH_LIB; do
if test -d "$dir"; then
PGSQL_LDFLAGS="$PGSQL_LDFLAGS -L$dir"
else

View File

@ -7,7 +7,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: c.h,v 1.48 1999/01/17 03:22:51 tgl Exp $
* $Id: c.h,v 1.49 1999/01/17 06:19:22 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -53,6 +53,10 @@
#include <stdarg.h>
#endif
#ifdef __CYGWIN32__
#include <errno.h>
#endif
/* ----------------------------------------------------------------
* Section 1: bool, true, false, TRUE, FALSE
* ----------------------------------------------------------------

View File

@ -6,7 +6,7 @@
# Copyright (c) 1994, Regents of the University of California
#
# IDENTIFICATION
# $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/Makefile.in,v 1.38 1998/10/19 00:00:40 tgl Exp $
# $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/Makefile.in,v 1.39 1999/01/17 06:19:24 momjian Exp $
#
#-------------------------------------------------------------------------
@ -43,6 +43,9 @@ typename.o : typename.c ../include/ecpgtype.h
.PHONY: clean
clean:
rm -f lib$(NAME).a $(shlib) $(OBJS)
ifeq ($(PORTNAME), win)
rm -f $(NAME).def
endif
depend dep:
$(CC) -MM $(CFLAGS) *.c >depend

View File

@ -15,10 +15,10 @@ OBJ=y.tab.o pgc.o type.o ecpg.o ecpg_keywords.o ../../../backend/parser/scansup.
all:: ecpg
clean:
rm -f *.o core a.out ecpg y.tab.h y.tab.c pgc.c *~
rm -f *.o core a.out ecpg$(X) y.tab.h y.tab.c pgc.c *~
install: all
$(INSTALL) $(INSTL_EXE_OPTS) ecpg $(DESTDIR)$(BINDIR)
$(INSTALL) $(INSTL_EXE_OPTS) ecpg$(X) $(DESTDIR)$(BINDIR)
uninstall:
rm -f $(DESTDIR)$(BINDIR)/ecpg

View File

@ -61,7 +61,11 @@ main(int argc, char *const argv[])
switch (c)
{
case 'o':
#ifndef __CYGWIN32__
yyout = fopen(optarg, "w");
#else
yyout = fopen(optarg, "wb");
#endif
if (yyout == NULL)
perror(optarg);
else
@ -126,7 +130,11 @@ main(int argc, char *const argv[])
ptr2ext[1] = 'c';
ptr2ext[2] = '\0';
#ifndef __CYGWIN32__
yyout = fopen(output_filename, "w");
#else
yyout = fopen(output_filename, "wb");
#endif
if (yyout == NULL)
{
perror(output_filename);
@ -136,7 +144,11 @@ main(int argc, char *const argv[])
}
}
#ifndef __CYGWIN32__
yyin = fopen(input_filename, "r");
#else
yyin = fopen(input_filename, "rb");
#endif
if (yyin == NULL)
perror(argv[fnr]);
else

View File

@ -6,7 +6,7 @@
# Copyright (c) 1994, Regents of the University of California
#
# IDENTIFICATION
# $Header: /cvsroot/pgsql/src/interfaces/libpq++/Attic/Makefile.in,v 1.10 1998/10/19 00:00:46 tgl Exp $
# $Header: /cvsroot/pgsql/src/interfaces/libpq++/Attic/Makefile.in,v 1.11 1999/01/17 06:19:39 momjian Exp $
#
#-------------------------------------------------------------------------
@ -44,7 +44,11 @@ endif
OBJS = pgenv.o pgconnection.o pgtransdb.o pgcursordb.o pglobject.o
ifeq ($(PORTNAME), win)
SHLIB_LINK+= -L../libpq -lpq -lstdc++
else
SHLIB_LINK= -L../libpq -lpq
endif
# Shared library stuff, also default 'all' target
include $(SRCDIR)/Makefile.shlib
@ -87,6 +91,9 @@ beforeinstall-headers:
clean:
rm -f libpq++.a $(shlib) $(OBJS)
$(MAKE) -C examples clean
ifeq ($(PORTNAME), win)
rm -f pq++.def
endif
dep depend:
$(CXX) -MM $(CXXFLAGS) *.cc >depend

View File

@ -6,7 +6,7 @@
# Copyright (c) 1994, Regents of the University of California
#
# IDENTIFICATION
# $Header: /cvsroot/pgsql/src/interfaces/libpq/Attic/Makefile.in,v 1.41 1998/11/12 05:27:01 tgl Exp $
# $Header: /cvsroot/pgsql/src/interfaces/libpq/Attic/Makefile.in,v 1.42 1999/01/17 06:19:34 momjian Exp $
#
#-------------------------------------------------------------------------
@ -36,7 +36,11 @@ endif
# If crypt is a separate library, rather than part of libc,
# make sure it gets included in shared libpq.
ifeq ($(PORTNAME), win)
SHLIB_LINK+= $(findstring -lcrypt,$(LIBS))
else
SHLIB_LINK= $(findstring -lcrypt,$(LIBS))
endif
# Shared library stuff, also default 'all' target
include $(SRCDIR)/Makefile.shlib
@ -139,6 +143,9 @@ beforeinstall-headers:
clean:
rm -f libpq.a $(shlib) $(OBJS)
rm -f dllist.c common.c wchar.c conv.c
ifeq ($(PORTNAME), win)
rm -f pq.def
endif
depend dep:
$(CC) -MM $(CFLAGS) *.c >depend

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.87 1999/01/17 03:37:19 tgl Exp $
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.88 1999/01/17 06:19:35 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -567,7 +567,7 @@ connectDB(PGconn *conn)
conn->raddr.in.sin_port = htons((unsigned short) (portno));
conn->raddr_len = sizeof(struct sockaddr_in);
}
#ifndef WIN32
#if !defined(WIN32) && !defined(__CYGWIN32__)
else
conn->raddr_len = UNIXSOCK_PATH(conn->raddr.un, portno);
#endif

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-lobj.c,v 1.17 1998/10/01 01:40:22 tgl Exp $
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-lobj.c,v 1.18 1999/01/17 06:19:36 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -392,7 +392,11 @@ lo_import(PGconn *conn, char *filename)
/*
* open the file to be read in
*/
#ifndef __CYGWIN32__
fd = open(filename, O_RDONLY, 0666);
#else
fd = open(filename, O_RDONLY | O_BINARY, 0666);
#endif
if (fd < 0)
{ /* error */
sprintf(conn->errorMessage,
@ -467,7 +471,11 @@ lo_export(PGconn *conn, Oid lobjId, char *filename)
/*
* open the file to be written to
*/
#ifndef __CYGWIN32__
fd = open(filename, O_CREAT | O_WRONLY | O_TRUNC, 0666);
#else
fd = open(filename, O_CREAT | O_WRONLY | O_TRUNC | O_BINARY, 0666);
#endif
if (fd < 0)
{ /* error */
sprintf(conn->errorMessage,

View File

@ -7,7 +7,7 @@
#
#
# IDENTIFICATION
# $Header: /cvsroot/pgsql/src/interfaces/odbc/Attic/GNUmakefile.in,v 1.9 1998/10/28 06:49:10 thomas Exp $
# $Header: /cvsroot/pgsql/src/interfaces/odbc/Attic/GNUmakefile.in,v 1.10 1999/01/17 06:19:43 momjian Exp $
#
#-------------------------------------------------------------------------
@SET_MAKE@
@ -73,7 +73,11 @@ clean:
distclean: clean
-rm -f config.h GNUmakefile Makefile.global
-rm -f config.cache config.log config.status
ifeq ($(PORTNAME), win)
@if [ $SRCDIR != $ODBCSRCDIR ]; then rm -f template makefiles port; fi
else
@if [ $SRCDIR ne $ODBCSRCDIR ]; then rm -f template makefiles port
endif
.PHONY: standalone

View File

@ -97,10 +97,18 @@ GetPrivateProfileString(char *theSection, // section name
/* This code makes it so that a file in the users home dir
* overrides a the "default" file as passed in
*/
#ifndef __CYGWIN32__
aFile = (FILE*)(buf ? fopen(buf, "r") : NULL);
#else
aFile = (FILE*)(buf ? fopen(buf, "rb") : NULL);
#endif
if(!aFile) {
sprintf(buf,"%s",theIniFileName);
#ifndef __CYGWIN32__
aFile = (FILE*)(buf ? fopen(buf, "r") : NULL);
#else
aFile = (FILE*)(buf ? fopen(buf, "rb") : NULL);
#endif
}

View File

@ -71,7 +71,11 @@ char filebuf[80];
if (! LOGFP) {
generate_filename(MYLOGDIR,MYLOGFILE,filebuf);
#ifndef __CYGWIN32__
LOGFP = fopen(filebuf, "w");
#else
LOGFP = fopen(filebuf, "wb");
#endif
globals.mylogFP = LOGFP;
setbuf(LOGFP, NULL);
}
@ -102,7 +106,11 @@ FILE* LOGFP = globals.qlogFP;
if (! LOGFP) {
generate_filename(QLOGDIR,QLOGFILE,filebuf);
#ifndef __CYGWIN32__
LOGFP = fopen(filebuf, "w");
#else
LOGFP = fopen(filebuf, "wb");
#endif
globals.qlogFP = LOGFP;
setbuf(LOGFP, NULL);
}

View File

@ -19,6 +19,6 @@ lextest: lextest.c scan.l
@echo "If this fails, flex is broken" | ./lextest || rm -f lextest
clean:
rm -f lextest lex.yy.c lex.yy.o lextest.o
rm -f lextest$(X) lex.yy.c lex.yy.o lextest.o
dep:

View File

@ -4,7 +4,7 @@
# Makefile for the plpgsql shared object
#
# IDENTIFICATION
# $Header: /cvsroot/pgsql/src/pl/plpgsql/src/Attic/Makefile.in,v 1.12 1998/10/30 15:05:23 tgl Exp $
# $Header: /cvsroot/pgsql/src/pl/plpgsql/src/Attic/Makefile.in,v 1.13 1999/01/17 06:19:53 momjian Exp $
#
#-------------------------------------------------------------------------
@ -24,7 +24,11 @@ LFLAGS+= -i -l
OBJS= pl_parse.o pl_handler.o pl_comp.o pl_exec.o pl_funcs.o
ifeq ($(PORTNAME), win)
SHLIB_LINK+= -L$(LIBPQDIR) -lpq
else
SHLIB_LINK= -L$(LIBPQDIR) -lpq
endif
# Shared library stuff, also default 'all' target
include $(SRCDIR)/Makefile.shlib
@ -74,3 +78,6 @@ pl.tab.h: pl_gram.c
clean:
rm -f lib$(NAME).a $(shlib)
rm -f *.o pl.tab.h pl_gram.c pl_scan.c
ifeq ($(PORTNAME), win)
rm -f $(NAME).def
endif

View File

@ -12,6 +12,7 @@ i386-pc-solaris=solaris_i386_gcc
i386-pc-sunos5=solaris_i386_gcc
i386-unknown-freebsd=freebsd
i386-unknown-netbsd=netbsd
i386-pc-cygwin32=cygwin32
i486-pc-linux-gnu=linux_i386
i586-pc-linux-gnu=linux_i386
i586-pc-sco3.2v=sco

View File

@ -7,7 +7,7 @@
#
#
# IDENTIFICATION
# $Header: /cvsroot/pgsql/src/test/regress/GNUmakefile,v 1.16 1998/07/26 04:31:41 scrappy Exp $
# $Header: /cvsroot/pgsql/src/test/regress/GNUmakefile,v 1.17 1999/01/17 06:19:57 momjian Exp $
#
#-------------------------------------------------------------------------
@ -43,19 +43,37 @@ endif
all: $(INFILES)
cd input; $(MAKE) all; cd ..
cd output; $(MAKE) all; cd ..
#ifneq ($(PORTNAME), win)
$(MAKE) -C ../../../contrib/spi REFINT_VERBOSE=1 refint$(DLSUFFIX) \
autoinc$(DLSUFFIX)
#else
# cat /dev/null > ../../../contrib/spi/refint$(DLSUFFIX)
# cat /dev/null > ../../../contrib/spi/autoinc$(DLSUFFIX)
#endif
#ifeq ($(PORTNAME), win)
#regress.dll: regress.c
# cat /dev/null > $@
#endif
#
# run the test
#
runtest: $(INFILES)
ifneq ($(PORTNAME), win)
MULTIBYTE=$(MULTIBYTE);export MULTIBYTE; \
$(SHELL) ./regress.sh 2>&1 | tee regress.out
$(SHELL) ./regress.sh $(PORTNAME) 2>&1 | tee regress.out
else
MULTIBYTE=$(MULTIBYTE);export MULTIBYTE; \
./regress.sh $(PORTNAME) 2>&1 | tee regress.out
endif
@echo "ACTUAL RESULTS OF REGRESSION TEST ARE NOW IN FILE regress.out"
clean:
rm -f $(INFILES) regress.out
rm -f $(INFILES) regress.out regress.o regression.diffs
ifeq ($(PORTNAME), win)
rm -f regress.def
endif
$(MAKE) -C sql clean
$(MAKE) -C expected clean
$(MAKE) -C results clean

View File

@ -1,6 +1,19 @@
#!/bin/sh
# $Header: /cvsroot/pgsql/src/test/regress/Attic/regress.sh,v 1.21 1998/08/28 14:17:57 momjian Exp $
# $Header: /cvsroot/pgsql/src/test/regress/Attic/regress.sh,v 1.22 1999/01/17 06:19:58 momjian Exp $
#
if [ $# -eq 0 ];
then
echo "Syntaxe: $0 <portname>"
exit 1
fi
if [ $1 == "win" ];
then
HOST="-h localhost"
else
HOST=""
fi
if echo '\c' | grep -s c >/dev/null 2>&1
then
ECHO_N="echo -n"
@ -18,7 +31,7 @@ PGTZ="PST8PDT"; export PGTZ
PGDATESTYLE="Postgres,US"; export PGDATESTYLE
#FRONTEND=monitor
FRONTEND="psql -n -e -q"
FRONTEND="psql $HOST -n -e -q"
SYSTEM=`uname -s`
@ -31,10 +44,10 @@ echo "See regress/README for more information."
echo ""
echo "=============== destroying old regression database... ================="
destroydb regression
destroydb $HOST regression
echo "=============== creating new regression database... ================="
createdb regression
createdb $HOST regression
if [ $? -ne 0 ]; then
echo createdb failed
exit 1

View File

@ -94,7 +94,11 @@ char **argv;
in_file = stdin;
else
{
#ifndef __CYGWIN32__
if ((in_file = fopen(*argv, "r")) == NULL)
#else
if ((in_file = fopen(*argv, "rb")) == NULL)
#endif
halt("PERROR: Can not open file %s\n", argv[0]);
argv++;
}

View File

@ -4,7 +4,7 @@
# Makefile for utils
#
# IDENTIFICATION
# $Header: /cvsroot/pgsql/src/utils/Attic/Makefile,v 1.5 1998/04/06 00:32:26 momjian Exp $
# $Header: /cvsroot/pgsql/src/utils/Attic/Makefile,v 1.6 1999/01/17 06:20:03 momjian Exp $
#
# About strdup: Some systems have strdup in their standard library, others
# don't. Ones that don't will use this make file to compile the strdup.c
@ -27,6 +27,9 @@ depend dep:
clean:
rm -f version.o
ifeq ($(PORTNAME), win)
rm -f dllinit.o
endif
ifeq (depend,$(wildcard depend))
include depend

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/utils/Attic/version.c,v 1.9 1998/04/29 12:41:29 scrappy Exp $
* $Header: /cvsroot/pgsql/src/utils/Attic/version.c,v 1.10 1999/01/17 06:20:06 momjian Exp $
*
* NOTES
* XXX eventually, should be able to handle version identifiers
@ -68,7 +68,11 @@ ValidatePgVersion(const char *path, char **reason_p)
PathSetVersionFilePath(path, full_path);
#ifndef __CYGWIN32__
if ((fd = open(full_path, O_RDONLY, 0)) == -1)
#else
if ((fd = open(full_path, O_RDONLY | O_BINARY, 0)) == -1)
#endif
{
*reason_p = malloc(200);
sprintf(*reason_p, "File '%s' does not exist or no read permission.", full_path);
@ -123,7 +127,11 @@ SetPgVersion(const char *path, char **reason_p)
PathSetVersionFilePath(path, full_path);
#ifndef __CYGWIN32__
fd = open(full_path, O_WRONLY | O_CREAT | O_EXCL, 0666);
#else
fd = open(full_path, O_WRONLY | O_CREAT | O_EXCL | O_BINARY, 0666);
#endif
if (fd < 0)
{
*reason_p = malloc(100 + strlen(full_path));