1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-15 19:21:59 +03:00

Remove NT-specific file open defines by defining our own open macros for

"rb" and "wb".
This commit is contained in:
Bruce Momjian
2000-06-02 15:57:44 +00:00
parent bf1c8f2b3b
commit cc2b5e5815
28 changed files with 590 additions and 348 deletions

View File

@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.15 2000/06/02 10:20:25 vadim Exp $
* $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.16 2000/06/02 15:57:16 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -746,11 +746,7 @@ XLogFileInit(uint32 log, uint32 seg)
XLogFileName(path, log, seg);
unlink(path);
#ifndef __CYGWIN__
fd = BasicOpenFile(path, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
#else
fd = BasicOpenFile(path, O_RDWR | O_CREAT | O_EXCL | O_BINARY, S_IRUSR | S_IWUSR);
#endif
fd = BasicOpenFile(path, O_RDWR | O_CREAT | O_EXCL | PG_BINARY, S_IRUSR | S_IWUSR);
if (fd < 0)
elog(STOP, "Open(logfile %u seg %u) failed: %d",
logId, logSeg, errno);
@ -782,11 +778,7 @@ XLogFileOpen(uint32 log, uint32 seg, bool econt)
XLogFileName(path, log, seg);
#ifndef __CYGWIN__
fd = BasicOpenFile(path, O_RDWR, S_IRUSR | S_IWUSR);
#else
fd = BasicOpenFile(path, O_RDWR | O_BINARY, S_IRUSR | S_IWUSR);
#endif
fd = BasicOpenFile(path, O_RDWR | PG_BINARY, S_IRUSR | S_IWUSR);
if (fd < 0)
{
if (econt && errno == ENOENT)
@ -1096,11 +1088,7 @@ UpdateControlFile()
{
int fd;
#ifndef __CYGWIN__
fd = BasicOpenFile(ControlFilePath, O_RDWR, S_IRUSR | S_IWUSR);
#else
fd = BasicOpenFile(ControlFilePath, O_RDWR | O_BINARY, S_IRUSR | S_IWUSR);
#endif
fd = BasicOpenFile(ControlFilePath, O_RDWR | PG_BINARY, S_IRUSR | S_IWUSR);
if (fd < 0)
elog(STOP, "Open(cntlfile) failed: %d", errno);
@ -1158,11 +1146,7 @@ BootStrapXLOG()
#endif
#ifndef __CYGWIN__
fd = BasicOpenFile(ControlFilePath, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
#else
fd = BasicOpenFile(ControlFilePath, O_RDWR | O_CREAT | O_EXCL | O_BINARY, S_IRUSR | S_IWUSR);
#endif
fd = BasicOpenFile(ControlFilePath, O_RDWR | O_CREAT | O_EXCL | PG_BINARY, S_IRUSR | S_IWUSR);
if (fd < 0)
elog(STOP, "BootStrapXLOG failed to create control file (%s): %d",
ControlFilePath, errno);
@ -1273,11 +1257,7 @@ StartupXLOG()
/*
* Open/read Control file
*/
#ifndef __CYGWIN__
fd = BasicOpenFile(ControlFilePath, O_RDWR, S_IRUSR | S_IWUSR);
#else
fd = BasicOpenFile(ControlFilePath, O_RDWR | O_BINARY, S_IRUSR | S_IWUSR);
#endif
fd = BasicOpenFile(ControlFilePath, O_RDWR | PG_BINARY, S_IRUSR | S_IWUSR);
if (fd < 0)
elog(STOP, "Open(\"%s\") failed: %d", ControlFilePath, errno);

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.109 2000/05/30 04:25:00 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.110 2000/06/02 15:57:18 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -320,11 +320,7 @@ DoCopy(char *relname, bool binary, bool oids, bool from, bool pipe,
}
else
{
#ifndef __CYGWIN32__
fp = AllocateFile(filename, "r");
#else
fp = AllocateFile(filename, "rb");
#endif
fp = AllocateFile(filename, PG_BINARY_R);
if (fp == NULL)
elog(ERROR, "COPY command, running in backend with "
"effective uid %d, could not open file '%s' for "
@ -355,12 +351,7 @@ DoCopy(char *relname, bool binary, bool oids, bool from, bool pipe,
" COPY command.");
oumask = umask((mode_t) 022);
#ifndef __CYGWIN32__
fp = AllocateFile(filename, "w");
#else
fp = AllocateFile(filename, "wb");
#endif
fp = AllocateFile(filename, PG_BINARY_W);
umask(oumask);
if (fp == NULL)

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/libpq/be-fsstubs.c,v 1.44 2000/04/12 17:15:14 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/libpq/be-fsstubs.c,v 1.45 2000/06/02 15:57:20 momjian Exp $
*
* NOTES
* This should be moved to a more appropriate place. It is here
@ -342,11 +342,7 @@ lo_import(text *filename)
if (nbytes > FNAME_BUFSIZE)
nbytes = FNAME_BUFSIZE;
StrNCpy(fnamebuf, VARDATA(filename), nbytes);
#ifndef __CYGWIN32__
fd = PathNameOpenFile(fnamebuf, O_RDONLY, 0666);
#else
fd = PathNameOpenFile(fnamebuf, O_RDONLY | O_BINARY, 0666);
#endif
fd = PathNameOpenFile(fnamebuf, O_RDONLY | PG_BINARY, 0666);
if (fd < 0)
{ /* error */
elog(ERROR, "lo_import: can't open unix file \"%s\": %m",
@ -427,11 +423,7 @@ lo_export(Oid lobjId, text *filename)
nbytes = FNAME_BUFSIZE;
StrNCpy(fnamebuf, VARDATA(filename), nbytes);
oumask = umask((mode_t) 0022);
#ifndef __CYGWIN32__
fd = PathNameOpenFile(fnamebuf, O_CREAT | O_WRONLY | O_TRUNC, 0666);
#else
fd = PathNameOpenFile(fnamebuf, O_CREAT | O_WRONLY | O_TRUNC | O_BINARY, 0666);
#endif
fd = PathNameOpenFile(fnamebuf, O_CREAT | O_WRONLY | O_TRUNC | PG_BINARY, 0666);
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.23 1999/07/17 20:17:01 momjian Exp $
* $Id: crypt.c,v 1.24 2000/06/02 15:57:20 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -73,11 +73,7 @@ crypt_openpwdfile()
FILE *pwdfile;
filename = crypt_getpwdfilename();
#ifndef __CYGWIN32__
pwdfile = AllocateFile(filename, "r");
#else
pwdfile = AllocateFile(filename, "rb");
#endif
pwdfile = AllocateFile(filename, PG_BINARY_R);
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.51 2000/04/12 17:15:14 momjian Exp $
* $Id: hba.c,v 1.52 2000/06/02 15:57:20 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -397,11 +397,7 @@ find_hba_entry(hbaPort *port, bool *hba_ok_p)
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
if ((fd = open(old_conf_file, O_RDONLY | PG_BINARY, 0)) != -1)
{
/* Old config file exists. Tell this guy he needs to upgrade. */
close(fd);
@ -810,11 +806,7 @@ verify_against_usermap(const char *pguser,
map_file = (char *) palloc(bufsize);
snprintf(map_file, bufsize, "%s/%s", DataDir, USERMAP_FILE);
#ifndef __CYGWIN32__
file = AllocateFile(map_file, "r");
#else
file = AllocateFile(map_file, "rb");
#endif
file = AllocateFile(map_file, PG_BINARY_R);
if (file == NULL)
{
/* The open of the map file failed. */
@ -986,11 +978,7 @@ 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 = AllocateFile(map_file, "r");
#else
file = AllocateFile(map_file, "rb");
#endif
file = AllocateFile(map_file, PG_BINARY_R);
if (file == NULL)
return;
while (!eof)

View File

@ -2,7 +2,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: password.c,v 1.28 2000/01/26 05:56:29 momjian Exp $
* $Id: password.c,v 1.29 2000/06/02 15:57:21 momjian Exp $
*
*/
@ -28,11 +28,7 @@ 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
pw_file = AllocateFile(pw_file_fullname, PG_BINARY_R);
if (!pw_file)
{
snprintf(PQerrormsg, PQERRORMSG_LENGTH,

View File

@ -29,7 +29,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: pqcomm.c,v 1.93 2000/05/31 00:28:18 petere Exp $
* $Id: pqcomm.c,v 1.94 2000/06/02 15:57:21 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -234,11 +234,7 @@ StreamServerPort(char *hostName, unsigned 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
if ((lock_fd = open(sock_path, O_WRONLY | O_NONBLOCK | PG_BINARY, 0666)) >= 0)
{
struct flock lck;
@ -287,11 +283,7 @@ StreamServerPort(char *hostName, unsigned 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
if ((lock_fd = open(sock_path, O_WRONLY | O_NONBLOCK | PG_BINARY, 0666)) >= 0)
{
struct flock lck;

View File

@ -11,7 +11,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.144 2000/05/31 00:28:25 petere Exp $
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.145 2000/06/02 15:57:22 momjian Exp $
*
* NOTES
*
@ -327,11 +327,7 @@ checkDataDir(const char *DataDir, bool *DataDirOK)
snprintf(path, sizeof(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
fp = AllocateFile(path, PG_BINARY_R);
if (fp == NULL)
{
fprintf(stderr, "%s does not find the database system. "
@ -433,7 +429,7 @@ PostmasterMain(int argc, char *argv[])
*/
umask((mode_t) 0077);
ResetAllOptions();
ResetAllOptions();
if (!(hostName = getenv("PGHOST")))
{
@ -445,10 +441,10 @@ PostmasterMain(int argc, char *argv[])
MyProcPid = getpid();
DataDir = getenv("PGDATA"); /* default value */
/*
* First we must scan for a -D argument to get the data dir. Then
* read the config file. Finally, scan all the other arguments.
* (Command line switches override config file.)
/*
* First we must scan for a -D argument to get the data dir. Then
* read the config file. Finally, scan all the other arguments.
* (Command line switches override config file.)
*
* Note: The two lists of options must be exactly the same, even
* though perhaps the first one would only have to be "D:" with
@ -457,15 +453,15 @@ PostmasterMain(int argc, char *argv[])
* to the local world view) which will result in some switches
* being associated with the wrong argument. Death and destruction
* will occur.
*/
*/
opterr = 1;
while ((opt = getopt(nonblank_argc, argv, "A:a:B:b:D:d:Film:MN:no:p:Ss-:")) != EOF)
{
if (opt == 'D')
DataDir = optarg;
}
{
if (opt == 'D')
DataDir = optarg;
}
optind = 1; /* start over */
optind = 1; /* start over */
checkDataDir(DataDir, &DataDirOK); /* issues error messages */
if (!DataDirOK)
{
@ -473,7 +469,7 @@ PostmasterMain(int argc, char *argv[])
exit(2);
}
ProcessConfigFile(PGC_POSTMASTER);
ProcessConfigFile(PGC_POSTMASTER);
IgnoreSystemIndexes(false);
while ((opt = getopt(nonblank_argc, argv, "A:a:B:b:D:d:Film:MN:no:p:Ss-:")) != EOF)
@ -511,7 +507,7 @@ PostmasterMain(int argc, char *argv[])
}
break;
case 'D':
/* already done above */
/* already done above */
break;
case 'd':
@ -521,9 +517,9 @@ PostmasterMain(int argc, char *argv[])
*/
DebugLvl = atoi(optarg);
break;
case 'F':
enableFsync = false;
break;
case 'F':
enableFsync = false;
break;
case 'i':
NetServer = true;
break;
@ -593,21 +589,21 @@ PostmasterMain(int argc, char *argv[])
*/
SendStop = true;
break;
case '-':
{
/* A little 'long argument' simulation */
size_t equal_pos = strcspn(optarg, "=");
char *cp;
case '-':
{
/* A little 'long argument' simulation */
size_t equal_pos = strcspn(optarg, "=");
char *cp;
if (optarg[equal_pos] != '=')
elog(ERROR, "--%s requires argument", optarg);
optarg[equal_pos] = '\0';
for(cp = optarg; *cp; cp++)
if (*cp == '-')
*cp = '_';
SetConfigOption(optarg, optarg + equal_pos + 1, PGC_POSTMASTER);
break;
}
if (optarg[equal_pos] != '=')
elog(ERROR, "--%s requires argument", optarg);
optarg[equal_pos] = '\0';
for(cp = optarg; *cp; cp++)
if (*cp == '-')
*cp = '_';
SetConfigOption(optarg, optarg + equal_pos + 1, PGC_POSTMASTER);
break;
}
default:
/* usage() never returns */
usage(progname);
@ -839,11 +835,7 @@ pmdaemonize(char *extraoptions)
exit(1);
}
#endif
#ifndef __CYGWIN32__
i = open(NULL_DEV, O_RDWR);
#else
i = open(NULL_DEV, O_RDWR | O_BINARY);
#endif
i = open(NULL_DEV, O_RDWR | PG_BINARY);
dup2(i, 0);
dup2(i, 1);
dup2(i, 2);

View File

@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/file/fd.c,v 1.58 2000/06/02 03:58:32 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/file/fd.c,v 1.59 2000/06/02 15:57:24 momjian Exp $
*
* NOTES:
*
@ -701,14 +701,8 @@ OpenTemporaryFile(void)
"pg_sorttemp%d.%ld", MyProcPid, tempFileCounter++);
/* Open the file */
#ifndef __CYGWIN32__
file = FileNameOpenFile(tempfilename,
O_RDWR | O_CREAT | O_TRUNC, 0600);
#else
file = FileNameOpenFile(tempfilename,
O_RDWR | O_CREAT | O_TRUNC | O_BINARY, 0600);
#endif
O_RDWR | O_CREAT | O_TRUNC | PG_BINARY, 0600);
if (file <= 0)
elog(ERROR, "Failed to create temporary file %s", tempfilename);

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/smgr/md.c,v 1.69 2000/06/02 03:58:33 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/smgr/md.c,v 1.70 2000/06/02 15:57:26 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -131,11 +131,7 @@ mdcreate(Relation reln)
Assert(reln->rd_unlinked && reln->rd_fd < 0);
path = relpath(RelationGetPhysicalRelationName(reln));
#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
fd = FileNameOpenFile(path, O_RDWR | O_CREAT | O_EXCL | PG_BINARY, 0600);
/*
* During bootstrap processing, we skip that check, because pg_time,
@ -155,11 +151,7 @@ mdcreate(Relation reln)
reln->rd_rel->relkind == RELKIND_UNCATALOGED)
return -1;
#ifndef __CYGWIN32__
fd = FileNameOpenFile(path, O_RDWR, 0600);
#else
fd = FileNameOpenFile(path, O_RDWR | O_BINARY, 0600);
#endif
fd = FileNameOpenFile(path, O_RDWR | PG_BINARY, 0600);
if (fd < 0)
return -1;
if (!IsBootstrapProcessingMode())
@ -332,23 +324,12 @@ mdopen(Relation reln)
Assert(reln->rd_fd < 0);
path = relpath(RelationGetPhysicalRelationName(reln));
#ifndef __CYGWIN32__
fd = FileNameOpenFile(path, O_RDWR, 0600);
#else
fd = FileNameOpenFile(path, O_RDWR | O_BINARY, 0600);
#endif
fd = FileNameOpenFile(path, O_RDWR | PG_BINARY, 0600);
if (fd < 0)
{
/* in bootstrap mode, accept mdopen as substitute for mdcreate */
if (IsBootstrapProcessingMode())
{
#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
}
fd = FileNameOpenFile(path, O_RDWR | O_CREAT | O_EXCL | PG_BINARY, 0600);
if (fd < 0)
{
elog(NOTICE, "mdopen: couldn't open %s: %m", path);
@ -1004,11 +985,7 @@ _mdfd_openseg(Relation reln, int segno, int oflags)
fullpath = path;
/* open the file */
#ifndef __CYGWIN32__
fd = FileNameOpenFile(fullpath, O_RDWR | oflags, 0600);
#else
fd = FileNameOpenFile(fullpath, O_RDWR | O_BINARY | oflags, 0600);
#endif
fd = FileNameOpenFile(fullpath, O_RDWR | PG_BINARY | oflags, 0600);
pfree(fullpath);
@ -1130,12 +1107,7 @@ _mdfd_blind_getseg(char *dbname, char *relname, Oid dbid, Oid relid,
#endif
/* call fd.c to allow other FDs to be closed if needed */
#ifndef __CYGWIN32__
fd = BasicOpenFile(path, O_RDWR, 0600);
#else
fd = BasicOpenFile(path, O_RDWR | O_BINARY, 0600);
#endif
fd = BasicOpenFile(path, O_RDWR | PG_BINARY, 0600);
if (fd < 0)
elog(DEBUG, "_mdfd_blind_getseg: couldn't open %s: %m", path);

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.54 2000/05/30 04:24:50 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.55 2000/06/02 15:57:28 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -549,11 +549,7 @@ _ReadLOArray(char *str,
{
FILE *afd;
#ifndef __CYGWIN32__
if ((afd = AllocateFile(accessfile, "r")) == NULL)
#else
if ((afd = AllocateFile(accessfile, "r")) == NULL)
#endif
if ((afd = AllocateFile(accessfile, PG_BINARY_R)) == NULL)
elog(ERROR, "unable to open access pattern file");
*chunkFlag = true;
retStr = _ChunkArray(*fd, afd, ndim, dim, baseSize, nbytes,

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.98 2000/05/30 00:49:54 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.99 2000/06/02 15:57:30 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -2122,11 +2122,7 @@ init_irels(void)
int i;
int relno;
#ifndef __CYGWIN32__
if ((fd = FileNameOpenFile(RELCACHE_INIT_FILENAME, O_RDONLY, 0600)) < 0)
#else
if ((fd = FileNameOpenFile(RELCACHE_INIT_FILENAME, O_RDONLY | O_BINARY, 0600)) < 0)
#endif
if ((fd = FileNameOpenFile(RELCACHE_INIT_FILENAME, O_RDONLY | PG_BINARY, 0600)) < 0)
{
write_irels();
return;
@ -2292,11 +2288,7 @@ write_irels(void)
snprintf(finalfilename, sizeof(finalfilename), "%s%c%s",
DatabasePath, SEP_CHAR, RELCACHE_INIT_FILENAME);
#ifndef __CYGWIN32__
fd = PathNameOpenFile(tempfilename, O_WRONLY | O_CREAT | O_TRUNC, 0600);
#else
fd = PathNameOpenFile(tempfilename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0600);
#endif
fd = PathNameOpenFile(tempfilename, O_WRONLY | O_CREAT | O_TRUNC | PG_BINARY, 0600);
if (fd < 0)
elog(FATAL, "cannot create init file %s", tempfilename);

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.46 2000/05/02 08:13:08 ishii Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.47 2000/06/02 15:57:32 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -207,11 +207,7 @@ SetCharSet()
map_file = (char *) malloc((strlen(DataDir) +
strlen(p) + 2) * sizeof(char));
sprintf(map_file, "%s/%s", DataDir, p);
#ifndef __CYGWIN32__
file = AllocateFile(map_file, "r");
#else
file = AllocateFile(map_file, "rb");
#endif
file = AllocateFile(map_file, PG_BINARY_R);
if (file == NULL)
return;
eof = false;

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/misc/Attic/database.c,v 1.37 2000/04/12 17:16:07 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/misc/Attic/database.c,v 1.38 2000/06/02 15:57:34 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -146,11 +146,7 @@ GetRawDatabaseInfo(const char *name, Oid *db_id, char *path)
dbfname = (char *) palloc(strlen(DataDir) + strlen(DatabaseRelationName) + 2);
sprintf(dbfname, "%s%c%s", DataDir, SEP_CHAR, DatabaseRelationName);
#ifndef __CYGWIN32__
if ((dbfd = open(dbfname, O_RDONLY, 0)) < 0)
#else
if ((dbfd = open(dbfname, O_RDONLY | O_BINARY, 0)) < 0)
#endif
if ((dbfd = open(dbfname, O_RDONLY | PG_BINARY, 0)) < 0)
elog(FATAL, "cannot open %s: %s", dbfname, strerror(errno));
pfree(dbfname);

View File

@ -22,7 +22,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.148 2000/05/28 20:34:52 tgl Exp $
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.149 2000/06/02 15:57:38 momjian Exp $
*
* Modifications - 6/10/96 - dave@bensoft.com - version 1.13.dhb
*
@ -760,11 +760,7 @@ main(int argc, char **argv)
g_fout = stdout;
else
{
#ifndef __CYGWIN32__
g_fout = fopen(filename, "w");
#else
g_fout = fopen(filename, "wb");
#endif
g_fout = fopen(filename, PG_BINARY_W);
if (g_fout == NULL)
{
fprintf(stderr,

View File

@ -54,11 +54,7 @@ read_pwd_file(char *filename)
int i;
try_again:
#ifndef __CYGWIN32__
fp = fopen(filename, "r");
#else
fp = fopen(filename, "rb");
#endif
fp = fopen(filename, PG_BINARY_R);
if (fp == NULL)
{
if (errno == ENOENT)
@ -70,11 +66,7 @@ try_again:
{
case 'y':
case 'Y':
#ifndef __CYGWIN32__
fp = fopen(filename, "w");
#else
fp = fopen(filename, "wb");
#endif
fp = fopen(filename, PG_BINARY_W);
if (fp == NULL)
{
perror(filename);
@ -192,11 +184,7 @@ link_again:
}
/* open file */
#ifndef __CYGWIN32__
if ((fp = fopen(filename, "w")) == NULL)
#else
if ((fp = fopen(filename, "wb")) == NULL)
#endif
if ((fp = fopen(filename, PG_BINARY_W)) == NULL)
{
perror(filename);
exit(1);

View File

@ -8,7 +8,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: c.h,v 1.70 2000/05/28 17:56:09 tgl Exp $
* $Id: c.h,v 1.71 2000/06/02 15:57:40 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -50,6 +50,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/fcntl.h>
#ifdef STDC_HEADERS
#include <stddef.h>
#include <stdarg.h>
@ -895,6 +896,16 @@ extern char *vararg_format(const char *fmt,...);
* ----------------------------------------------------------------
*/
#ifndef __CYGWIN32__
#define PG_BINARY 0
#define PG_BINARY_R "rb"
#define PG_BINARY_W "wb"
#else
#define PG_BINARY O_BINARY
#define PG_BINARY_R "r"
#define PG_BINARY_W "w"
#endif
#ifdef FIXADE
#if defined(hpux)
#include "port/hpux/fixade.h" /* for unaligned access fixup */

View File

@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1995, Regents of the University of California
*
* $Id: postgres.h,v 1.39 2000/05/28 17:56:12 tgl Exp $
* $Id: postgres.h,v 1.40 2000/06/02 15:57:40 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -229,7 +229,6 @@ typedef uint32 CommandId;
*/
#ifdef CYR_RECODE
extern void SetCharSet();
#endif /* CYR_RECODE */
#endif /* POSTGRES_H */

View File

@ -66,11 +66,7 @@ main(int argc, char *const argv[])
switch (c)
{
case 'o':
#ifndef __CYGWIN32__
yyout = fopen(optarg, "w");
#else
yyout = fopen(optarg, "wb");
#endif
yyout = fopen(optarg, PG_BINARY_W);
if (yyout == NULL)
perror(optarg);
else
@ -147,11 +143,7 @@ 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
yyout = fopen(output_filename, PG_BINARY_W);
if (yyout == NULL)
{
perror(output_filename);
@ -161,11 +153,7 @@ main(int argc, char *const argv[])
}
}
#ifndef __CYGWIN32__
yyin = fopen(input_filename, "r");
#else
yyin = fopen(input_filename, "rb");
#endif
yyin = fopen(input_filename, PG_BINARY_R);
if (yyin == NULL)
perror(argv[fnr]);
else

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-lobj.c,v 1.29 2000/04/12 17:17:15 momjian Exp $
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-lobj.c,v 1.30 2000/06/02 15:57:42 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -391,11 +391,7 @@ lo_import(PGconn *conn, const 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
fd = open(filename, O_RDONLY | PG_BINARY, 0666);
if (fd < 0)
{ /* error */
printfPQExpBuffer(&conn->errorMessage,
@ -474,11 +470,7 @@ lo_export(PGconn *conn, Oid lobjId, const 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
fd = open(filename, O_CREAT | O_WRONLY | O_TRUNC | PG_BINARY, 0666);
if (fd < 0)
{ /* error */
printfPQExpBuffer(&conn->errorMessage,
@ -544,7 +536,7 @@ lo_initialize(PGconn *conn)
* ----------------
*/
res = PQexec(conn, "select proname, oid from pg_proc \
where proname = 'lo_open' \
where proname = 'lo_open' \
or proname = 'lo_close' \
or proname = 'lo_creat' \
or proname = 'lo_unlink' \

View File

@ -59,7 +59,7 @@ GetPrivateProfileString(char *theSection, /* section name */
BOOL aSectionFound = FALSE;
BOOL aKeyFound = FALSE;
int j = 0;
j = strlen(theIniFileName) + 1;
ptr = (char*)getpwuid(getuid()); /* get user info */
@ -92,21 +92,13 @@ 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
aFile = (FILE*)(buf ? fopen(buf, PG_BINARY_R) : NULL);
if(!aFile) {
sprintf(buf,"%s",theIniFileName);
#ifndef __CYGWIN32__
aFile = (FILE*)(buf ? fopen(buf, "r") : NULL);
#else
aFile = (FILE*)(buf ? fopen(buf, "rb") : NULL);
#endif
aFile = (FILE*)(buf ? fopen(buf, PG_BINARY_R) : NULL);
}
aLength = (theDefault == NULL) ? 0 : strlen(theDefault);
if(theReturnBufferLength == 0 || theReturnBuffer == NULL)
@ -145,7 +137,7 @@ GetPrivateProfileString(char *theSection, /* section name */
case ';': /* comment line */
continue;
break;
case '[': /* section marker */
if( (aString = strchr(aLine, ']')) )
@ -173,7 +165,7 @@ GetPrivateProfileString(char *theSection, /* section name */
if(aSectionFound)
{
/* try to match requested key */
if( (aString = aValue = strchr(aLine, '=')) )
{
*aValue = '\0';
@ -220,7 +212,7 @@ GetPrivateProfileString(char *theSection, /* section name */
/* remove trailing blanks from aValue if any */
aString = aValue + aLength - 1;
while(--aString > aValue && *aString == ' ')
{
*aString = '\0';
@ -333,9 +325,9 @@ WritePrivateProfileString(char *theSection, /* section name */
BOOL aSectionFound = FALSE;
BOOL keyFound = FALSE;
int j = 0;
/* If this isn't correct processing we'll change it later */
if(theSection == NULL || theKey == NULL || theBuffer == NULL ||
if(theSection == NULL || theKey == NULL || theBuffer == NULL ||
theIniFileName == NULL) return 0;
aLength = strlen(theBuffer);
@ -380,7 +372,7 @@ WritePrivateProfileString(char *theSection, /* section name */
if(!aFile) return 0;
}
aLength = strlen(theBuffer);
/* We have to search for theKey, because if it already */
@ -401,7 +393,7 @@ WritePrivateProfileString(char *theSection, /* section name */
case ';': /* comment line */
continue;
break;
case '[': /* section marker */
if( (aString = strchr(aLine, ']')) )
@ -425,7 +417,7 @@ WritePrivateProfileString(char *theSection, /* section name */
if(aSectionFound)
{
/* try to match requested key */
if( (aString = aValue = strchr(aLine, '=')) )
{
*aValue = '\0';

View File

@ -68,11 +68,7 @@ mylog(char * fmt, ...)
if (! LOGFP) {
generate_filename(MYLOGDIR,MYLOGFILE,filebuf);
#ifndef __CYGWIN32__
LOGFP = fopen(filebuf, "w");
#else
LOGFP = fopen(filebuf, "wb");
#endif
LOGFP = fopen(filebuf, PG_BINARY_W);
globals.mylogFP = LOGFP;
setbuf(LOGFP, NULL);
}
@ -100,11 +96,7 @@ qlog(char * fmt, ...)
if (! LOGFP) {
generate_filename(QLOGDIR,QLOGFILE,filebuf);
#ifndef __CYGWIN32__
LOGFP = fopen(filebuf, "w");
#else
LOGFP = fopen(filebuf, "wb");
#endif
LOGFP = fopen(filebuf, PG_BINARY_W);
globals.qlogFP = LOGFP;
setbuf(LOGFP, NULL);
}
@ -136,9 +128,9 @@ qlog(char * fmt, ...)
#include <sql.h>
#endif
/* returns STRCPY_FAIL, STRCPY_TRUNCATED, or #bytes copied (not including null term) */
int
int
my_strcpy(char *dst, int dst_len, char *src, int src_len)
{
if (dst_len <= 0)
@ -146,7 +138,7 @@ my_strcpy(char *dst, int dst_len, char *src, int src_len)
if (src_len == SQL_NULL_DATA) {
dst[0] = '\0';
return STRCPY_NULL;
return STRCPY_NULL;
}
else if (src_len == SQL_NTS)
src_len = strlen(src);
@ -154,12 +146,12 @@ my_strcpy(char *dst, int dst_len, char *src, int src_len)
if (src_len <= 0)
return STRCPY_FAIL;
else {
else {
if (src_len < dst_len) {
memcpy(dst, src, src_len);
dst[src_len] = '\0';
}
else {
else {
memcpy(dst, src, dst_len-1);
dst[dst_len-1] = '\0'; /* truncated */
return STRCPY_TRUNCATED;
@ -184,7 +176,7 @@ int i;
if (len == SQL_NULL_DATA) {
dst[0] = '\0';
return NULL;
}
}
else if (len == SQL_NTS)
len = strlen(src) + 1;
@ -208,7 +200,7 @@ make_string(char *s, int len, char *buf)
int length;
char *str;
if(s && (len > 0 || (len == SQL_NTS && strlen(s) > 0))) {
if(s && (len > 0 || (len == SQL_NTS && strlen(s) > 0))) {
length = (len > 0) ? len : strlen(s);
if (buf) {
@ -216,11 +208,11 @@ char *str;
return buf;
}
str = malloc(length + 1);
str = malloc(length + 1);
if ( ! str)
return NULL;
strncpy_null(str, s, length+1);
strncpy_null(str, s, length+1);
return str;
}
@ -235,7 +227,7 @@ char *
my_strcat(char *buf, char *fmt, char *s, int len)
{
if (s && (len > 0 || (len == SQL_NTS && strlen(s) > 0))) {
if (s && (len > 0 || (len == SQL_NTS && strlen(s) > 0))) {
int length = (len > 0) ? len : strlen(s);
int pos = strlen(buf);
@ -248,14 +240,14 @@ my_strcat(char *buf, char *fmt, char *s, int len)
void remove_newlines(char *string)
{
unsigned int i;
unsigned int i;
for(i=0; i < strlen(string); i++) {
if((string[i] == '\n') ||
(string[i] == '\r')) {
string[i] = ' ';
}
}
for(i=0; i < strlen(string); i++) {
if((string[i] == '\n') ||
(string[i] == '\r')) {
string[i] = ' ';
}
}
}
char *

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/utils/Attic/version.c,v 1.15 2000/04/12 17:17:22 momjian Exp $
* $Header: /cvsroot/pgsql/src/utils/Attic/version.c,v 1.16 2000/06/02 15:57:44 momjian Exp $
*
* STANDALONE CODE - do not use error routines as this code is not linked
* with any...
@ -67,11 +67,7 @@ ValidatePgVersion(const char *path, char **reason_p)
sprintf(myversion, "%s.%s\n", PG_RELEASE, PG_VERSION);
#ifndef __CYGWIN32__
if ((fd = open(full_path, O_RDONLY, 0)) == -1)
#else
if ((fd = open(full_path, O_RDONLY | O_BINARY, 0)) == -1)
#endif
if ((fd = open(full_path, O_RDONLY | PG_BINARY, 0)) == -1)
{
*reason_p = malloc(100 + strlen(full_path));
sprintf(*reason_p, "File '%s' does not exist or no read permission.", full_path);
@ -125,11 +121,7 @@ SetPgVersion(const char *path, char **reason_p)
sprintf(version, "%s.%s\n", PG_RELEASE, PG_VERSION);
#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
fd = open(full_path, O_WRONLY | O_CREAT | O_EXCL | PG_BINARY, 0666);
if (fd < 0)
{
*reason_p = malloc(100 + strlen(full_path));