diff --git a/configure b/configure index c7709d20e5..f7947ebe72 100755 --- a/configure +++ b/configure @@ -15064,6 +15064,14 @@ case $LIBOBJS in *) LIBOBJS="$LIBOBJS rand.$ac_objext" ;; esac +case $LIBOBJS in + "win32error.$ac_objext" | \ + *" win32error.$ac_objext" | \ + "win32error.$ac_objext "* | \ + *" win32error.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS win32error.$ac_objext" ;; +esac + cat >>confdefs.h <<\_ACEOF #define HAVE_SYMLINK 1 diff --git a/configure.in b/configure.in index ae24a84b92..9075690fcc 100644 --- a/configure.in +++ b/configure.in @@ -1,5 +1,5 @@ dnl Process this file with autoconf to produce a configure script. -dnl $PostgreSQL: pgsql/configure.in,v 1.465 2006/05/30 13:52:24 momjian Exp $ +dnl $PostgreSQL: pgsql/configure.in,v 1.466 2006/06/07 22:24:43 momjian Exp $ dnl dnl Developers, please strive to achieve this order: dnl @@ -994,6 +994,7 @@ AC_LIBOBJ(gettimeofday) AC_LIBOBJ(kill) AC_LIBOBJ(open) AC_LIBOBJ(rand) +AC_LIBOBJ(win32error) AC_DEFINE([HAVE_SYMLINK], 1, [Define to 1 if you have the `symlink' function.]) fi diff --git a/src/backend/libpq/ip.c b/src/backend/libpq/ip.c index d1cd2b152a..595c99a81b 100644 --- a/src/backend/libpq/ip.c +++ b/src/backend/libpq/ip.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/libpq/ip.c,v 1.34 2006/03/05 15:58:27 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/libpq/ip.c,v 1.35 2006/06/07 22:24:43 momjian Exp $ * * This file and the IPV6 implementation were initially provided by * Nigel Kukard , Linux Based Systems Design @@ -20,7 +20,6 @@ /* This is intended to be used in both frontend and backend, so use c.h */ #include "c.h" -#ifndef WIN32_CLIENT_ONLY #include #include #include @@ -33,7 +32,6 @@ #endif #include #include -#endif #include "libpq/ip.h" diff --git a/src/backend/port/dynloader/win32.c b/src/backend/port/dynloader/win32.c index c2547f5a28..72d27fddcd 100644 --- a/src/backend/port/dynloader/win32.c +++ b/src/backend/port/dynloader/win32.c @@ -1,7 +1,6 @@ -/* $PostgreSQL: pgsql/src/backend/port/dynloader/win32.c,v 1.7 2005/10/15 02:49:23 momjian Exp $ */ +/* $PostgreSQL: pgsql/src/backend/port/dynloader/win32.c,v 1.8 2006/06/07 22:24:43 momjian Exp $ */ -#include -#include +#include "postgres.h" char *dlerror(void); int dlclose(void *handle); diff --git a/src/backend/port/win32/Makefile b/src/backend/port/win32/Makefile index 67d6df8f0e..365d4a577d 100644 --- a/src/backend/port/win32/Makefile +++ b/src/backend/port/win32/Makefile @@ -4,7 +4,7 @@ # Makefile for backend/port/win32 # # IDENTIFICATION -# $PostgreSQL: pgsql/src/backend/port/win32/Makefile,v 1.7 2006/04/29 20:52:56 tgl Exp $ +# $PostgreSQL: pgsql/src/backend/port/win32/Makefile,v 1.8 2006/06/07 22:24:43 momjian Exp $ # #------------------------------------------------------------------------- @@ -12,7 +12,7 @@ subdir = src/backend/port/win32 top_builddir = ../../../.. include $(top_builddir)/src/Makefile.global -OBJS = shmem.o timer.o socket.o signal.o security.o error.o +OBJS = shmem.o timer.o socket.o signal.o security.o all: SUBSYS.o diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c index 2ee450945f..0fa564a8f5 100644 --- a/src/backend/postmaster/postmaster.c +++ b/src/backend/postmaster/postmaster.c @@ -37,7 +37,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.484 2006/05/19 15:15:37 alvherre Exp $ + * $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.485 2006/06/07 22:24:44 momjian Exp $ * * NOTES * @@ -1121,7 +1121,7 @@ pmdaemonize(void) ExitPostmaster(1); } #endif - i = open(NULL_DEV, O_RDWR); + i = open(NULL_DEV, O_RDWR, 0); dup2(i, 0); dup2(i, 1); dup2(i, 2); diff --git a/src/backend/postmaster/syslogger.c b/src/backend/postmaster/syslogger.c index 4334024b84..339f4605af 100644 --- a/src/backend/postmaster/syslogger.c +++ b/src/backend/postmaster/syslogger.c @@ -18,7 +18,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/postmaster/syslogger.c,v 1.23 2006/03/05 15:58:36 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/postmaster/syslogger.c,v 1.24 2006/06/07 22:24:44 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -153,7 +153,7 @@ SysLoggerMain(int argc, char *argv[]) */ if (redirection_done) { - int fd = open(NULL_DEV, O_WRONLY); + int fd = open(NULL_DEV, O_WRONLY, 0); /* * The closes might look redundant, but they are not: we want to be diff --git a/src/backend/utils/adt/float.c b/src/backend/utils/adt/float.c index b5147c9aa4..132e6a11e4 100644 --- a/src/backend/utils/adt/float.c +++ b/src/backend/utils/adt/float.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/float.c,v 1.124 2006/04/24 20:36:32 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/float.c,v 1.125 2006/06/07 22:24:44 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -80,6 +80,14 @@ #define HAVE_FINITE 1 #endif +/* Visual C++ etc lacks NAN, and won't accept 0.0/0.0. NAN definition from + * http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclang/html/vclrfNotNumberNANItems.asp + */ +#if defined(WIN32) && !defined(NAN) +static const uint32 nan[2] = {0xffffffff, 0x7fffffff}; +#define NAN (*(const double *) nan) +#endif + /* not sure what the following should be, but better to make it over-sufficient */ #define MAXFLOATWIDTH 64 #define MAXDOUBLEWIDTH 128 diff --git a/src/backend/utils/fmgr/dfmgr.c b/src/backend/utils/fmgr/dfmgr.c index 0aacf2be99..4c50e421e5 100644 --- a/src/backend/utils/fmgr/dfmgr.c +++ b/src/backend/utils/fmgr/dfmgr.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/fmgr/dfmgr.c,v 1.85 2006/05/31 20:58:09 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/fmgr/dfmgr.c,v 1.86 2006/06/07 22:24:44 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -16,7 +16,11 @@ #include +#ifndef WIN32_ONLY_COMPILER #include "dynloader.h" +#else +#include "port/dynloader/win32.h" +#endif #include "miscadmin.h" #include "utils/dynamic_loader.h" diff --git a/src/backend/utils/mb/encnames.c b/src/backend/utils/mb/encnames.c index f628fcd679..3760bd78cf 100644 --- a/src/backend/utils/mb/encnames.c +++ b/src/backend/utils/mb/encnames.c @@ -2,7 +2,7 @@ * Encoding names and routines for work with it. All * in this file is shared bedween FE and BE. * - * $PostgreSQL: pgsql/src/backend/utils/mb/encnames.c,v 1.29 2006/02/18 16:15:22 petere Exp $ + * $PostgreSQL: pgsql/src/backend/utils/mb/encnames.c,v 1.30 2006/06/07 22:24:44 momjian Exp $ */ #ifdef FRONTEND #include "postgres_fe.h" @@ -13,9 +13,7 @@ #include "utils/builtins.h" #endif -#ifndef WIN32_CLIENT_ONLY #include -#endif #include "mb/pg_wchar.h" #include diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c index 82743bdb0a..343f428ddd 100644 --- a/src/bin/initdb/initdb.c +++ b/src/bin/initdb/initdb.c @@ -42,7 +42,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * Portions taken from FreeBSD. * - * $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.116 2006/05/27 18:07:06 tgl Exp $ + * $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.117 2006/06/07 22:24:44 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -2269,8 +2269,7 @@ setlocales(void) } #ifdef WIN32 -/* MingW headers are incomplete */ -typedef WINAPI BOOL (*__CreateRestrictedToken)(HANDLE, DWORD, DWORD, PSID_AND_ATTRIBUTES, DWORD, PLUID_AND_ATTRIBUTES, DWORD, PSID_AND_ATTRIBUTES, PHANDLE); +typedef BOOL (WINAPI *__CreateRestrictedToken)(HANDLE, DWORD, DWORD, PSID_AND_ATTRIBUTES, DWORD, PLUID_AND_ATTRIBUTES, DWORD, PSID_AND_ATTRIBUTES, PHANDLE); #define DISABLE_MAX_PRIVILEGE 0x1 /* diff --git a/src/bin/pg_controldata/pg_controldata.c b/src/bin/pg_controldata/pg_controldata.c index b2d0e01e02..dd56ea787e 100644 --- a/src/bin/pg_controldata/pg_controldata.c +++ b/src/bin/pg_controldata/pg_controldata.c @@ -6,7 +6,7 @@ * copyright (c) Oliver Elphick , 2001; * licence: BSD * - * $PostgreSQL: pgsql/src/bin/pg_controldata/pg_controldata.c,v 1.28 2006/04/03 23:35:04 tgl Exp $ + * $PostgreSQL: pgsql/src/bin/pg_controldata/pg_controldata.c,v 1.29 2006/06/07 22:24:44 momjian Exp $ */ #include "postgres.h" @@ -104,7 +104,7 @@ main(int argc, char *argv[]) snprintf(ControlFilePath, MAXPGPATH, "%s/global/pg_control", DataDir); - if ((fd = open(ControlFilePath, O_RDONLY)) == -1) + if ((fd = open(ControlFilePath, O_RDONLY, 0)) == -1) { fprintf(stderr, _("%s: could not open file \"%s\" for reading: %s\n"), progname, ControlFilePath, strerror(errno)); diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 57d7337e6b..c000a46f06 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -4,7 +4,7 @@ * * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.67 2006/03/05 15:58:50 momjian Exp $ + * $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.68 2006/06/07 22:24:44 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -1159,12 +1159,12 @@ pgwin32_doRunAsService(void) * also load the couple of functions that *do* exist in minwg headers but not * on NT4. That way, we don't break on NT4. */ -typedef WINAPI BOOL (*__CreateRestrictedToken)(HANDLE, DWORD, DWORD, PSID_AND_ATTRIBUTES, DWORD, PLUID_AND_ATTRIBUTES, DWORD, PSID_AND_ATTRIBUTES, PHANDLE); -typedef WINAPI BOOL (*__IsProcessInJob)(HANDLE, HANDLE, PBOOL); -typedef WINAPI HANDLE (*__CreateJobObject)(LPSECURITY_ATTRIBUTES, LPCTSTR); -typedef WINAPI BOOL (*__SetInformationJobObject)(HANDLE, JOBOBJECTINFOCLASS, LPVOID, DWORD); -typedef WINAPI BOOL (*__AssignProcessToJobObject)(HANDLE, HANDLE); -typedef WINAPI BOOL (*__QueryInformationJobObject)(HANDLE, JOBOBJECTINFOCLASS, LPVOID, DWORD, LPDWORD); +typedef BOOL (WINAPI *__CreateRestrictedToken)(HANDLE, DWORD, DWORD, PSID_AND_ATTRIBUTES, DWORD, PLUID_AND_ATTRIBUTES, DWORD, PSID_AND_ATTRIBUTES, PHANDLE); +typedef BOOL (WINAPI *__IsProcessInJob)(HANDLE, HANDLE, PBOOL); +typedef HANDLE (WINAPI *__CreateJobObject)(LPSECURITY_ATTRIBUTES, LPCTSTR); +typedef BOOL (WINAPI *__SetInformationJobObject)(HANDLE, JOBOBJECTINFOCLASS, LPVOID, DWORD); +typedef BOOL (WINAPI *__AssignProcessToJobObject)(HANDLE, HANDLE); +typedef BOOL (WINAPI *__QueryInformationJobObject)(HANDLE, JOBOBJECTINFOCLASS, LPVOID, DWORD, LPDWORD); /* Windows API define missing from MingW headers */ #define DISABLE_MAX_PRIVILEGE 0x1 diff --git a/src/bin/pg_dump/pg_backup_archiver.c b/src/bin/pg_dump/pg_backup_archiver.c index 904de34a7c..61e87ac28c 100644 --- a/src/bin/pg_dump/pg_backup_archiver.c +++ b/src/bin/pg_dump/pg_backup_archiver.c @@ -15,7 +15,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.131 2006/05/28 21:13:54 tgl Exp $ + * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.132 2006/06/07 22:24:44 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -28,9 +28,7 @@ #include -#ifndef WIN32_CLIENT_ONLY #include -#endif #ifdef WIN32 #include diff --git a/src/bin/pg_dump/pg_backup_db.c b/src/bin/pg_dump/pg_backup_db.c index 77c4086d3d..19d0d5bb05 100644 --- a/src/bin/pg_dump/pg_backup_db.c +++ b/src/bin/pg_dump/pg_backup_db.c @@ -5,7 +5,7 @@ * Implements the basic DB functions used by the archiver. * * IDENTIFICATION - * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_db.c,v 1.70 2006/03/03 23:38:29 tgl Exp $ + * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_db.c,v 1.71 2006/06/07 22:24:44 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -15,9 +15,7 @@ #include "pg_backup_db.h" #include "dumputils.h" -#ifndef WIN32_CLIENT_ONLY #include -#endif #include diff --git a/src/bin/pg_dump/pg_backup_null.c b/src/bin/pg_dump/pg_backup_null.c index 9dd373f252..deecf192b3 100644 --- a/src/bin/pg_dump/pg_backup_null.c +++ b/src/bin/pg_dump/pg_backup_null.c @@ -17,7 +17,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_null.c,v 1.17 2006/02/12 06:11:50 momjian Exp $ + * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_null.c,v 1.18 2006/06/07 22:24:44 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -25,9 +25,7 @@ #include "pg_backup.h" #include "pg_backup_archiver.h" -#ifndef WIN32_CLIENT_ONLY #include /* for dup */ -#endif #include "libpq/libpq-fs.h" diff --git a/src/bin/pg_dump/pg_backup_tar.c b/src/bin/pg_dump/pg_backup_tar.c index bb490e2aef..5fa080b06a 100644 --- a/src/bin/pg_dump/pg_backup_tar.c +++ b/src/bin/pg_dump/pg_backup_tar.c @@ -16,7 +16,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.51 2006/05/22 11:21:54 petere Exp $ + * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.52 2006/06/07 22:24:44 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -27,10 +27,7 @@ #include #include - -#ifndef WIN32_CLIENT_ONLY #include -#endif static void _ArchiveEntry(ArchiveHandle *AH, TocEntry *te); static void _StartData(ArchiveHandle *AH, TocEntry *te); diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index daf7829b51..2f30b17428 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -12,7 +12,7 @@ * by PostgreSQL * * IDENTIFICATION - * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.436 2006/05/28 21:13:54 tgl Exp $ + * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.437 2006/06/07 22:24:45 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -24,9 +24,7 @@ */ #include "postgres.h" -#ifndef WIN32_CLIENT_ONLY #include -#endif #include #ifdef ENABLE_NLS diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c index e57f9c5050..ecbd15f28c 100644 --- a/src/bin/pg_dump/pg_dumpall.c +++ b/src/bin/pg_dump/pg_dumpall.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * - * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.78 2006/05/31 11:02:42 momjian Exp $ + * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.79 2006/06/07 22:24:45 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -14,10 +14,7 @@ #include "postgres_fe.h" #include - -#ifndef WIN32_CLIENT_ONLY #include -#endif #ifdef ENABLE_NLS #include diff --git a/src/bin/pg_dump/pg_restore.c b/src/bin/pg_dump/pg_restore.c index f9799be68b..e34a475051 100644 --- a/src/bin/pg_dump/pg_restore.c +++ b/src/bin/pg_dump/pg_restore.c @@ -34,7 +34,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/bin/pg_dump/pg_restore.c,v 1.77 2006/04/12 22:18:48 tgl Exp $ + * $PostgreSQL: pgsql/src/bin/pg_dump/pg_restore.c,v 1.78 2006/06/07 22:24:45 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -53,9 +53,7 @@ #include #endif -#ifndef WIN32_CLIENT_ONLY #include -#endif #include "getopt_long.h" diff --git a/src/bin/pg_resetxlog/pg_resetxlog.c b/src/bin/pg_resetxlog/pg_resetxlog.c index 22232eddf5..7d2f295a01 100644 --- a/src/bin/pg_resetxlog/pg_resetxlog.c +++ b/src/bin/pg_resetxlog/pg_resetxlog.c @@ -23,7 +23,7 @@ * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/bin/pg_resetxlog/pg_resetxlog.c,v 1.47 2006/06/03 02:19:24 momjian Exp $ + * $PostgreSQL: pgsql/src/bin/pg_resetxlog/pg_resetxlog.c,v 1.48 2006/06/07 22:24:45 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -245,7 +245,7 @@ main(int argc, char *argv[]) */ snprintf(path, MAXPGPATH, "%s/postmaster.pid", DataDir); - if ((fd = open(path, O_RDONLY)) < 0) + if ((fd = open(path, O_RDONLY, 0)) < 0) { if (errno != ENOENT) { @@ -347,7 +347,7 @@ ReadControlFile(void) char *buffer; pg_crc32 crc; - if ((fd = open(XLOG_CONTROL_FILE, O_RDONLY)) < 0) + if ((fd = open(XLOG_CONTROL_FILE, O_RDONLY, 0)) < 0) { /* * If pg_control is not there at all, or we can't read it, the odds diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 63161edd45..3c5bd6740f 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -3,12 +3,12 @@ * * Copyright (c) 2000-2006, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.168 2006/06/01 00:15:36 tgl Exp $ + * $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.169 2006/06/07 22:24:45 momjian Exp $ */ #include "postgres_fe.h" #include "command.h" -#ifdef WIN32_CLIENT_ONLY /* needed for BCC */ +#ifdef __BORLANDC__ /* needed for BCC */ #undef mkdir #endif @@ -26,11 +26,9 @@ #include #include #include -#ifndef WIN32_CLIENT_ONLY #include /* for umask() */ #include /* for stat() */ #endif -#endif #include "libpq-fe.h" #include "pqexpbuffer.h" @@ -1261,10 +1259,8 @@ do_edit(const char *filename_arg, PQExpBuffer query_buf) bool error = false; int fd; -#ifndef WIN32_CLIENT_ONLY struct stat before, after; -#endif if (filename_arg) fname = filename_arg; @@ -1339,19 +1335,16 @@ do_edit(const char *filename_arg, PQExpBuffer query_buf) } } -#ifndef WIN32_CLIENT_ONLY if (!error && stat(fname, &before) != 0) { psql_error("%s: %s\n", fname, strerror(errno)); error = true; } -#endif /* call editor */ if (!error) error = !editFile(fname); -#ifndef WIN32_CLIENT_ONLY if (!error && stat(fname, &after) != 0) { psql_error("%s: %s\n", fname, strerror(errno)); @@ -1360,10 +1353,6 @@ do_edit(const char *filename_arg, PQExpBuffer query_buf) if (!error && before.st_mtime != after.st_mtime) { -#else - if (!error) - { -#endif stream = fopen(fname, PG_BINARY_R); if (!stream) { diff --git a/src/bin/psql/copy.c b/src/bin/psql/copy.c index ba89eb5b38..abf4b60342 100644 --- a/src/bin/psql/copy.c +++ b/src/bin/psql/copy.c @@ -3,7 +3,7 @@ * * Copyright (c) 2000-2006, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/bin/psql/copy.c,v 1.64 2006/06/01 01:28:00 tgl Exp $ + * $PostgreSQL: pgsql/src/bin/psql/copy.c,v 1.65 2006/06/07 22:24:45 momjian Exp $ */ #include "postgres_fe.h" #include "copy.h" @@ -26,7 +26,7 @@ #include "prompt.h" #include "stringutils.h" -#if defined(WIN32) && (!defined(__MINGW32__)) +#if defined(WIN32) && !defined(S_ISDIR) #define __S_ISTYPE(mode, mask) (((mode) & S_IFMT) == (mask)) #define S_ISDIR(mode) __S_ISTYPE((mode), S_IFDIR) #endif diff --git a/src/bin/psql/print.c b/src/bin/psql/print.c index d3b70896bf..1ad04783d0 100644 --- a/src/bin/psql/print.c +++ b/src/bin/psql/print.c @@ -3,7 +3,7 @@ * * Copyright (c) 2000-2006, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/bin/psql/print.c,v 1.85 2006/03/05 15:58:51 momjian Exp $ + * $PostgreSQL: pgsql/src/bin/psql/print.c,v 1.86 2006/06/07 22:24:45 momjian Exp $ */ #include "postgres_fe.h" #include "common.h" @@ -11,10 +11,7 @@ #include #include - -#ifndef WIN32_CLIENT_ONLY #include -#endif #ifndef WIN32 #include /* for ioctl() */ @@ -641,10 +638,10 @@ print_aligned_text(const char *title, const char *const * headers, for (ptr = footers; *ptr; ptr++) fprintf(fout, "%s\n", *ptr); -#ifndef __MINGW32__ +#ifndef WIN32 /* - * for some reason MinGW outputs an extra newline, so this supresses it + * for some reason MinGW (and MSVC) outputs an extra newline, so this supresses it */ fputc('\n', fout); #endif diff --git a/src/bin/psql/win32.mak b/src/bin/psql/win32.mak index e63004d95f..67b1b8e5b5 100644 --- a/src/bin/psql/win32.mak +++ b/src/bin/psql/win32.mak @@ -28,7 +28,7 @@ REFDOCDIR= ../../../doc/src/sgml/ref CPP_PROJ=/nologo $(OPT) /W3 /GX /D "WIN32" $(DEBUGDEF) /D "_CONSOLE" /D\ "_MBCS" /Fp"$(INTDIR)\psql.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c \ - /I ..\..\include /I ..\..\interfaces\libpq /I ..\..\include\port\win32 \ + /I ..\..\include /I ..\..\interfaces\libpq /I ..\..\include\port\win32 /I ..\..\include\port\win32_msvc \ /I ..\pg_dump /I ..\..\backend \ /D "HAVE_STRDUP" /D "FRONTEND" @@ -57,6 +57,7 @@ CLEAN : -@erase "$(INTDIR)\exec.obj" -@erase "$(INTDIR)\getopt.obj" -@erase "$(INTDIR)\getopt_long.obj" + -@erase "$(INTDIR)\snprintf.obj" -@erase "$(INTDIR)\path.obj" -@erase "$(INTDIR)\pgstrcasecmp.obj" -@erase "$(INTDIR)\sprompt.obj" @@ -91,6 +92,7 @@ LINK32_OBJS= \ "$(INTDIR)\exec.obj" \ "$(INTDIR)\getopt.obj" \ "$(INTDIR)\getopt_long.obj" \ + "$(INTDIR)\snprintf.obj" \ "$(INTDIR)\path.obj" \ "$(INTDIR)\pgstrcasecmp.obj" \ "$(INTDIR)\sprompt.obj" \ @@ -139,6 +141,11 @@ LINK32_OBJS = $(LINK32_OBJS) "..\..\interfaces\libpq\Release\libpqdll.lib" $(CPP_PROJ) ..\..\port\getopt_long.c << +"$(INTDIR)\snprintf.obj" : "$(INTDIR)" ..\..\port\snprintf.c + $(CPP) @<< + $(CPP_PROJ) ..\..\port\snprintf.c +<< + "$(INTDIR)\path.obj" : "$(INTDIR)" ..\..\port\path.c $(CPP) @<< $(CPP_PROJ) ..\..\port\path.c diff --git a/src/include/c.h b/src/include/c.h index 679981ea6c..acf5738e4a 100644 --- a/src/include/c.h +++ b/src/include/c.h @@ -12,7 +12,7 @@ * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/c.h,v 1.202 2006/05/28 21:13:54 tgl Exp $ + * $PostgreSQL: pgsql/src/include/c.h,v 1.203 2006/06/07 22:24:45 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -52,17 +52,15 @@ #include "pg_config.h" #include "pg_config_manual.h" /* must be after pg_config.h */ -#if !defined(WIN32) && !defined(__CYGWIN__) +#if !defined(WIN32) && !defined(__CYGWIN__) /* win32 will include further down */ #include "pg_config_os.h" /* must be before any system header files */ -#else -#if defined(_MSC_VER) || defined(__BORLANDC__) -#define WIN32_CLIENT_ONLY -/* Some use MinGW-generated pg_config.h but MSVC for extensions. */ -#undef HAVE_STRINGS_H -#endif #endif #include "postgres_ext.h" +#if defined(_MSC_VER) || defined(__BORLANDC__) +#define WIN32_ONLY_COMPILER +#endif + #include #include #include @@ -82,13 +80,11 @@ #endif #if defined(WIN32) || defined(__CYGWIN__) -#ifndef WIN32_CLIENT_ONLY -/* We have to redefine some system functions after they are included above */ -#include "pg_config_os.h" -#else -#include "port/win32.h" /* We didn't run configure, but this is our - * port file */ -#endif +/* We have to redefine some system functions after they are included above. + * + * use port/win32.h directly to work on both mingw and non-mingw. + */ +#include "port/win32.h" #endif /* Must be before gettext() games below */ diff --git a/src/include/getaddrinfo.h b/src/include/getaddrinfo.h index ec82583c97..6393ccfeae 100644 --- a/src/include/getaddrinfo.h +++ b/src/include/getaddrinfo.h @@ -15,17 +15,15 @@ * * Copyright (c) 2003-2006, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/include/getaddrinfo.h,v 1.19 2006/03/05 15:58:53 momjian Exp $ + * $PostgreSQL: pgsql/src/include/getaddrinfo.h,v 1.20 2006/06/07 22:24:45 momjian Exp $ * *------------------------------------------------------------------------- */ #ifndef GETADDRINFO_H #define GETADDRINFO_H -#ifndef WIN32_CLIENT_ONLY #include #include -#endif /* Various macros that ought to be in , but might not be */ @@ -42,7 +40,7 @@ #define EAI_MEMORY (-10) #define EAI_SYSTEM (-11) #else /* WIN32 */ -#if defined(WIN32_CLIENT_ONLY) +#ifdef WIN32_ONLY_COMPILER #define WSA_NOT_ENOUGH_MEMORY (WSAENOBUFS) #define WSATYPE_NOT_FOUND (WSABASEERR+109) #endif diff --git a/src/include/libpq/pqcomm.h b/src/include/libpq/pqcomm.h index 35c1d4bca7..02fa9132bf 100644 --- a/src/include/libpq/pqcomm.h +++ b/src/include/libpq/pqcomm.h @@ -9,28 +9,19 @@ * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/libpq/pqcomm.h,v 1.100 2006/05/17 01:44:24 momjian Exp $ + * $PostgreSQL: pgsql/src/include/libpq/pqcomm.h,v 1.101 2006/06/07 22:24:45 momjian Exp $ * *------------------------------------------------------------------------- */ #ifndef PQCOMM_H #define PQCOMM_H -#ifdef WIN32 -#include -/* workaround for clashing defines of "ERROR" */ -#ifdef ELOG_H -#undef ERROR -#define ERROR PGERROR -#endif -#else /* not WIN32 */ #include #include #ifdef HAVE_SYS_UN_H #include #endif #include -#endif /* not WIN32 */ #ifdef HAVE_STRUCT_SOCKADDR_STORAGE diff --git a/src/include/pg_config.h.win32 b/src/include/pg_config.h.win32 index d76b14a2da..430ab02a2f 100644 --- a/src/include/pg_config.h.win32 +++ b/src/include/pg_config.h.win32 @@ -1,72 +1,660 @@ -/* $PostgreSQL: pgsql/src/include/pg_config.h.win32,v 1.29 2006/05/30 12:43:28 momjian Exp $ */ +/* src/include/pg_config.h. Generated by configure. */ +/* src/include/pg_config.h.in. Generated from configure.in by autoheader. */ -#ifndef pg_config_h_win32__ -#define pg_config_h_win32__ -/* - * Parts of pg_config.h that you get with autoconf on other systems +/* This file is generated from MingW ./configure, and with the following + * changes to be valid for Visual C++ (and compatible): + * + * HAVE_CBRT, HAVE_FUNCNAME_FUNC, HAVE_FUNCNAME_FUNCTION, HAVE_GETOPT, + * HAVE_GETOPT_H, HAVE_GETOPT_LONG, HAVE_RINT, HAVE_STRINGS_H, + * HAVE_STRTOLL, HAVE_STRTOULL, HAVE_STRUCT_OPTION, ENABLE_THREAD_SAFETY + * + * For now, also HAVE_IPV6 */ -#define PG_VERSION "8.2devel" -#define PG_VERSION_STR "8.2devel (win32)" -#define DEF_PGPORT 5432 -#define DEF_PGPORT_STR "5432" +/* Define to the type of arg 1 of 'accept' */ +#define ACCEPT_TYPE_ARG1 unsigned int -#define MAXIMUM_ALIGNOF 4 +/* Define to the type of arg 2 of 'accept' */ +#define ACCEPT_TYPE_ARG2 struct sockaddr * + +/* Define to the type of arg 3 of 'accept' */ #define ACCEPT_TYPE_ARG3 int -#define MAXPGPATH 1024 +/* Define to the return type of 'accept' */ +#define ACCEPT_TYPE_RETURN unsigned int PASCAL + +/* The alignment requirement of a `double'. */ +#define ALIGNOF_DOUBLE 8 + +/* The alignment requirement of a `int'. */ +#define ALIGNOF_INT 4 + +/* The alignment requirement of a `long'. */ +#define ALIGNOF_LONG 4 + +/* The alignment requirement of a `long long int'. */ +#define ALIGNOF_LONG_LONG_INT 8 + +/* The alignment requirement of a `short'. */ +#define ALIGNOF_SHORT 2 + +/* Define to the default TCP port number on which the server listens and to + which clients will try to connect. This can be overridden at run-time, but + it's convenient if your clients have the right default compiled in. + (--with-pgport=PORTNUM) */ +#define DEF_PGPORT 5432 + +/* Define to the default TCP port number as a string constant. */ +#define DEF_PGPORT_STR "5432" + +/* Define to 1 if you want National Language Support. (--enable-nls) */ +/* #undef ENABLE_NLS */ + +/* Define to 1 to build client libraries as thread-safe code. + (--enable-thread-safety) */ +#define ENABLE_THREAD_SAFETY 1 + +/* Define to 1 if getpwuid_r() takes a 5th argument. */ +/* #undef GETPWUID_R_5ARG */ + +/* Define to 1 if gettimeofday() takes only 1 argument. */ +/* #undef GETTIMEOFDAY_1ARG */ + +#ifdef GETTIMEOFDAY_1ARG +# define gettimeofday(a,b) gettimeofday(a) +#endif + +/* Define to 1 if you have the `atexit' function. */ +#define HAVE_ATEXIT 1 + +/* Define to 1 if you have the `cbrt' function. */ +//#define HAVE_CBRT 1 + +/* Define to 1 if you have the `class' function. */ +/* #undef HAVE_CLASS */ + +/* Define to 1 if you have the `crypt' function. */ +/* #undef HAVE_CRYPT */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_CRYPT_H */ + +/* Define to 1 if you have the declaration of `fdatasync', and to 0 if you + don't. */ +#define HAVE_DECL_FDATASYNC 0 + +/* Define to 1 if you have the declaration of `F_FULLFSYNC', and to 0 if you + don't. */ +#define HAVE_DECL_F_FULLFSYNC 0 + +/* Define to 1 if you have the declaration of `snprintf', and to 0 if you + don't. */ +#define HAVE_DECL_SNPRINTF 1 + +/* Define to 1 if you have the declaration of `vsnprintf', and to 0 if you + don't. */ +#define HAVE_DECL_VSNPRINTF 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_DLD_H */ + +/* Define to 1 if you have the `dlopen' function. */ +/* #undef HAVE_DLOPEN */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_EDITLINE_HISTORY_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_EDITLINE_READLINE_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_ENDIAN_H */ + +/* Define to 1 if you have the `fcvt' function. */ +#define HAVE_FCVT 1 + +/* Define to 1 if you have the `fdatasync' function. */ +/* #undef HAVE_FDATASYNC */ + +/* Define to 1 if you have finite(). */ +#define HAVE_FINITE 1 + +/* Define to 1 if you have the `fpclass' function. */ +/* #undef HAVE_FPCLASS */ + +/* Define to 1 if you have the `fp_class' function. */ +/* #undef HAVE_FP_CLASS */ + +/* Define to 1 if you have the `fp_class_d' function. */ +/* #undef HAVE_FP_CLASS_D */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_FP_CLASS_H */ + +/* Define to 1 if fseeko (and presumably ftello) exists and is declared. */ +/* #undef HAVE_FSEEKO */ + +/* Define to 1 if your compiler understands __func__. */ +//#define HAVE_FUNCNAME__FUNC 1 + +/* Define to 1 if your compiler understands __FUNCTION__. */ +#undef HAVE_FUNCNAME__FUNCTION + +/* Define to 1 if you have getaddrinfo(). */ +/* #undef HAVE_GETADDRINFO */ + +/* Define to 1 if you have the `gethostbyname_r' function. */ +/* #undef HAVE_GETHOSTBYNAME_R */ + +/* Define to 1 if you have the `getopt' function. */ +//#define HAVE_GETOPT 1 + +/* Define to 1 if you have the header file. */ +//#define HAVE_GETOPT_H 1 + +/* Define to 1 if you have the `getopt_long' function. */ +//#define HAVE_GETOPT_LONG 1 + +/* Define to 1 if you have the `getpeereid' function. */ +/* #undef HAVE_GETPEEREID */ + +/* Define to 1 if you have the `getpwuid_r' function. */ +/* #undef HAVE_GETPWUID_R */ + +/* Define to 1 if you have the `getrusage' function. */ +/* #undef HAVE_GETRUSAGE */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_HISTORY_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_IEEEFP_H */ + +/* Define to 1 if you have the `inet_aton' function. */ +/* #undef HAVE_INET_ATON */ + +/* Define to 1 if the system has the type `int64'. */ +/* #undef HAVE_INT64 */ + +/* Define to 1 if the system has the type `int8'. */ +/* #undef HAVE_INT8 */ + +/* Define to 1 if you have the header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the global variable 'int optreset'. */ +#define HAVE_INT_OPTRESET 1 + +/* Define to 1 if you have the global variable 'int timezone'. */ +#define HAVE_INT_TIMEZONE + +/* Define to 1 if you have support for IPv6. */ +//#define HAVE_IPV6 1 + +/* Define to 1 if you have isinf(). */ +#define HAVE_ISINF 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_KERNEL_IMAGE_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_KERNEL_OS_H */ + +/* Define to 1 if `e_data' is member of `krb5_error'. */ +/* #undef HAVE_KRB5_ERROR_E_DATA */ + +/* Define to 1 if `text.data' is member of `krb5_error'. */ +/* #undef HAVE_KRB5_ERROR_TEXT_DATA */ + +/* Define to 1 if `client' is member of `krb5_ticket'. */ +/* #undef HAVE_KRB5_TICKET_CLIENT */ + +/* Define to 1 if `enc_part2' is member of `krb5_ticket'. */ +/* #undef HAVE_KRB5_TICKET_ENC_PART2 */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LANGINFO_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LDAP_H */ + +/* Define to 1 if you have the `crypto' library (-lcrypto). */ +/* #undef HAVE_LIBCRYPTO */ + +/* Define to 1 if you have the `eay32' library (-leay32). */ +/* #undef HAVE_LIBEAY32 */ + +/* Define to 1 if you have the `ldap' library (-lldap). */ +/* #undef HAVE_LIBLDAP */ + +/* Define to 1 if you have the `pam' library (-lpam). */ +/* #undef HAVE_LIBPAM */ + +/* Define if you have a function readline library */ +/* #undef HAVE_LIBREADLINE */ + +/* Define to 1 if you have the `ssl' library (-lssl). */ +/* #undef HAVE_LIBSSL */ + +/* Define to 1 if you have the `ssleay32' library (-lssleay32). */ +/* #undef HAVE_LIBSSLEAY32 */ + +/* Define to 1 if you have the `wldap32' library (-lwldap32). */ +/* #undef HAVE_LIBWLDAP32 */ + +/* Define to 1 if you have the `z' library (-lz). */ +/* #undef HAVE_LIBZ */ + +/* Define to 1 if constants of type 'long long int' should have the suffix LL. + */ +#define HAVE_LL_CONSTANTS 1 + +/* Define to 1 if `long int' works and is 64 bits. */ +/* #undef HAVE_LONG_INT_64 */ + +/* Define to 1 if `long long int' works and is 64 bits. */ +#define HAVE_LONG_LONG_INT_64 + +/* Define to 1 if you have the `memmove' function. */ +#define HAVE_MEMMOVE 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_NETINET_IN_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_NETINET_TCP_H */ + +/* Define to 1 if you have the `on_exit' function. */ +/* #undef HAVE_ON_EXIT */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_PAM_PAM_APPL_H */ + +/* Define to 1 if you have the `poll' function. */ +/* #undef HAVE_POLL */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_POLL_H */ + +/* Define to 1 if you have the POSIX signal interface. */ +/* #undef HAVE_POSIX_SIGNALS */ + +/* Define to 1 if you have the `pstat' function. */ +/* #undef HAVE_PSTAT */ + +/* Define to 1 if the PS_STRINGS thing exists. */ +/* #undef HAVE_PS_STRINGS */ + +/* Define if you have POSIX threads libraries and header files. */ +/* #undef HAVE_PTHREAD */ + +/* Define to 1 if you have the header file. */ +#define HAVE_PWD_H 1 + +/* Define to 1 if you have the `random' function. */ +/* #undef HAVE_RANDOM */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_READLINE_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_READLINE_HISTORY_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_READLINE_READLINE_H */ + +/* Define to 1 if you have the `readlink' function. */ +/* #undef HAVE_READLINK */ + +/* Define to 1 if you have the `replace_history_entry' function. */ +/* #undef HAVE_REPLACE_HISTORY_ENTRY */ + +/* Define to 1 if you have the `rint' function. */ +/*#define HAVE_RINT 1*/ + +/* Define to 1 if you have the global variable + 'rl_completion_append_character'. */ +/* #undef HAVE_RL_COMPLETION_APPEND_CHARACTER */ + +/* Define to 1 if you have the `rl_completion_matches' function. */ +/* #undef HAVE_RL_COMPLETION_MATCHES */ + +/* Define to 1 if you have the `rl_filename_completion_function' function. */ +/* #undef HAVE_RL_FILENAME_COMPLETION_FUNCTION */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SECURITY_PAM_APPL_H */ + +/* Define to 1 if you have the `setproctitle' function. */ +/* #undef HAVE_SETPROCTITLE */ + +/* Define to 1 if you have the `setsid' function. */ +/* #undef HAVE_SETSID */ + +/* Define to 1 if you have the `sigprocmask' function. */ +/* #undef HAVE_SIGPROCMASK */ + +/* Define to 1 if you have sigsetjmp(). */ +/* #undef HAVE_SIGSETJMP */ + +/* Define to 1 if the system has the type `sig_atomic_t'. */ +#define HAVE_SIG_ATOMIC_T 1 + +/* Define to 1 if you have the `snprintf' function. */ +/* #undef HAVE_SNPRINTF */ + +/* Define to 1 if you have spinlocks. */ +#define HAVE_SPINLOCKS 1 + +/* Define to 1 if you have the `srandom' function. */ +/* #undef HAVE_SRANDOM */ + +/* Define to 1 if you have the header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the `strdup' function. */ +#define HAVE_STRDUP 1 + +/* Define to 1 if you have the `strerror' function. */ +#define HAVE_STRERROR 1 + +/* Define to 1 if you have the `strerror_r' function. */ +/* #undef HAVE_STRERROR_R */ + +/* Define to 1 if cpp supports the ANSI # stringizing operator. */ +#define HAVE_STRINGIZE 1 + +/* Define to 1 if you have the header file. */ +/*#define HAVE_STRINGS_H 1 */ + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the `strtol' function. */ +#define HAVE_STRTOL 1 + +/* Define to 1 if you have the `strtoll' function. */ +//#define HAVE_STRTOLL 1 + +/* Define to 1 if you have the `strtoq' function. */ +/* #undef HAVE_STRTOQ */ + +/* Define to 1 if you have the `strtoul' function. */ +#define HAVE_STRTOUL 1 + +/* Define to 1 if you have the `strtoull' function. */ +//#define HAVE_STRTOULL 1 + +/* Define to 1 if you have the `strtouq' function. */ +/* #undef HAVE_STRTOUQ */ + +/* Define to 1 if the system has the type `struct addrinfo'. */ +#define HAVE_STRUCT_ADDRINFO 1 + +/* Define to 1 if the system has the type `struct cmsgcred'. */ +/* #undef HAVE_STRUCT_CMSGCRED */ + +/* Define to 1 if the system has the type `struct fcred'. */ +/* #undef HAVE_STRUCT_FCRED */ + +/* Define to 1 if the system has the type `struct option'. */ +//#define HAVE_STRUCT_OPTION 1 + +/* Define to 1 if `sa_len' is member of `struct sockaddr'. */ +/* #undef HAVE_STRUCT_SOCKADDR_SA_LEN */ + +/* Define to 1 if the system has the type `struct sockaddr_storage'. */ +#define HAVE_STRUCT_SOCKADDR_STORAGE 1 + +/* Define to 1 if `ss_family' is member of `struct sockaddr_storage'. */ +#define HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY 1 + +/* Define to 1 if `ss_len' is member of `struct sockaddr_storage'. */ +/* #undef HAVE_STRUCT_SOCKADDR_STORAGE_SS_LEN */ + +/* Define to 1 if `__ss_family' is member of `struct sockaddr_storage'. */ +/* #undef HAVE_STRUCT_SOCKADDR_STORAGE___SS_FAMILY */ + +/* Define to 1 if `__ss_len' is member of `struct sockaddr_storage'. */ +/* #undef HAVE_STRUCT_SOCKADDR_STORAGE___SS_LEN */ + +/* Define to 1 if the system has the type `struct sockaddr_un'. */ +/* #undef HAVE_STRUCT_SOCKADDR_UN */ + +/* Define to 1 if the system has the type `struct sockcred'. */ +/* #undef HAVE_STRUCT_SOCKCRED */ + +/* Define to 1 if `tm_zone' is member of `struct tm'. */ +/* #undef HAVE_STRUCT_TM_TM_ZONE */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SUPPORTDEFS_H */ + +/* Define to 1 if you have the `symlink' function. */ +#define HAVE_SYMLINK 1 + +/* Define to 1 if you have the `sysconf' function. */ +/* #undef HAVE_SYSCONF */ + +/* Define to 1 if you have the syslog interface. */ +/* #undef HAVE_SYSLOG */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_IPC_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_POLL_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_PSTAT_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_SELECT_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_SEM_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_SHM_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SOCKET_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TIME_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_UN_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_TERMIOS_H */ + +/* Define to 1 if your `struct tm' has `tm_zone'. Deprecated, use + `HAVE_STRUCT_TM_TM_ZONE' instead. */ +/* #undef HAVE_TM_ZONE */ + +/* Define to 1 if you have the `towlower' function. */ +#define HAVE_TOWLOWER 1 + +/* Define to 1 if you have the external array `tzname'. */ +/* #undef HAVE_TZNAME */ + +/* Define to 1 if the system has the type `uint64'. */ +/* #undef HAVE_UINT64 */ + +/* Define to 1 if the system has the type `uint8'. */ +/* #undef HAVE_UINT8 */ + +/* Define to 1 if the system has the type `union semun'. */ +/* #undef HAVE_UNION_SEMUN */ + +/* Define to 1 if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to 1 if you have unix sockets. */ +/* #undef HAVE_UNIX_SOCKETS */ + +/* Define to 1 if you have the `unsetenv' function. */ +/* #undef HAVE_UNSETENV */ + +/* Define to 1 if you have the `utime' function. */ +#define HAVE_UTIME 1 + +/* Define to 1 if you have the `utimes' function. */ +/* #undef HAVE_UTIMES */ + +/* Define to 1 if you have the header file. */ +#define HAVE_UTIME_H 1 + +/* Define to 1 if you have the `vsnprintf' function. */ +/* #undef HAVE_VSNPRINTF */ + +/* Define to 1 if you have the `waitpid' function. */ +/* #undef HAVE_WAITPID */ + +/* Define to 1 if you have the header file. */ +#define HAVE_WCHAR_H 1 + +/* Define to 1 if you have the `wcstombs' function. */ +#define HAVE_WCSTOMBS 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_WCTYPE_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_WINLDAP_H */ + +/* Define to the appropriate snprintf format for 64-bit ints, if any. */ +#define INT64_FORMAT "%lld" + +/* Define to build with Kerberos 5 support. (--with-krb5) */ +/* #undef KRB5 */ + +/* Define to the location of locale files. */ +/* #undef LOCALEDIR */ + +/* Define as the maximum alignment requirement of any C data type. */ +#define MAXIMUM_ALIGNOF 8 + +/* Define bytes to use libc memset(). */ #define MEMSET_LOOP_LIMIT 1024 -#define INDEX_MAX_KEYS 32 +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "pgsql-bugs@postgresql.org" -#define HAVE_ATEXIT -#define HAVE_MEMMOVE +/* Define to the full name of this package. */ +#define PACKAGE_NAME "PostgreSQL" -#ifdef __BORLANDC__ -#define HAVE_RANDOM -#endif +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "PostgreSQL 8.2devel" -#undef inline -#define inline __inline +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "postgresql" -#define INT64_FORMAT "%I64d" -#define HAVE_DECL_VSNPRINTF 1 +/* Define to the version of this package. */ +#define PACKAGE_VERSION "8.2devel" -/* use _snprintf and _vsnprintf */ -#define HAVE_DECL_SNPRINTF 1 -#define snprintf _snprintf -#define HAVE_DECL_VSNPRINTF 1 -#define vsnprintf _vsnprintf +/* Define to the name of the default PostgreSQL service principal in Kerberos. + (--with-krb-srvnam=NAME) */ +#define PG_KRB_SRVNAM "postgres" -/* defines for dynamic linking on Win32 platform */ -#ifdef __CYGWIN__ +/* PostgreSQL version as a string */ +#define PG_VERSION "8.2devel" -#if __GNUC__ && ! defined (__declspec) -#error You need egcs 1.1 or newer for compiling! -#endif +/* PostgreSQL version as a number */ +#define PG_VERSION_NUM 80200 -#ifdef BUILDING_DLL -#define DLLIMPORT __declspec (dllexport) -#else /* not BUILDING_DLL */ -#define DLLIMPORT __declspec (dllimport) -#endif +/* A string containing the version number, platform, and C compiler */ +#define PG_VERSION_STR "Uninitialized version string (win32)" -#elif defined(WIN32) && defined(_MSC_VER) /* not CYGWIN */ +/* Define to the necessary symbol if this constant uses a non-standard name on + your system. */ +/* #undef PTHREAD_CREATE_JOINABLE */ -#if defined(_DLL) -#define DLLIMPORT __declspec (dllexport) -#else /* not _DLL */ -#define DLLIMPORT __declspec (dllimport) -#endif +/* The size of a `size_t', as computed by sizeof. */ +#define SIZEOF_SIZE_T 4 -#else /* not CYGWIN, not MSVC */ +/* The size of a `unsigned long', as computed by sizeof. */ +#define SIZEOF_UNSIGNED_LONG 4 -#define DLLIMPORT +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 -#endif +/* Define to 1 if strerror_r() returns a int. */ +/* #undef STRERROR_R_INT */ -#ifndef __CYGWIN__ -#include -#endif +/* Define to 1 if your declares `struct tm'. */ +/* #undef TM_IN_SYS_TIME */ -#endif /* pg_config_h_win32__ */ +/* Define to the appropriate snprintf format for unsigned 64-bit ints, if any. + */ +#define UINT64_FORMAT "%llu" + +/* Define to 1 to build with assertion checks. (--enable-cassert) */ +/* #undef USE_ASSERT_CHECKING */ + +/* Define to 1 to build with Bonjour support. (--with-bonjour) */ +/* #undef USE_BONJOUR */ + +/* Define to 1 if you want 64-bit integer timestamp and interval support. + (--enable-integer-datetimes) */ +/* #undef USE_INTEGER_DATETIMES */ + +/* Define to 1 to build with LDAP support. (--with-ldap) */ +/* #undef USE_LDAP */ + +/* Define to select named POSIX semaphores. */ +/* #undef USE_NAMED_POSIX_SEMAPHORES */ + +/* Define to 1 to build with PAM support. (--with-pam) */ +/* #undef USE_PAM */ + +/* Use replacement snprintf() functions. */ +#define USE_REPL_SNPRINTF 1 + +/* Define to build with (Open)SSL support. (--with-openssl) */ +/* #undef USE_SSL */ + +/* Define to select SysV-style semaphores. */ +#define USE_SYSV_SEMAPHORES 1 + +/* Define to select SysV-style shared memory. */ +#define USE_SYSV_SHARED_MEMORY 1 + +/* Define to select unnamed POSIX semaphores. */ +/* #undef USE_UNNAMED_POSIX_SEMAPHORES */ + +/* Number of bits in a file offset, on hosts where this is settable. */ +/* #undef _FILE_OFFSET_BITS */ + +/* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */ +/* #undef _LARGEFILE_SOURCE */ + +/* Define for large files, on AIX-style hosts. */ +/* #undef _LARGE_FILES */ + +/* Define to empty if `const' does not conform to ANSI C. */ +/* #undef const */ + +/* Define as `__inline' if that's what the C compiler calls it, or to nothing + if it is not supported. */ +/* #undef inline */ + +/* Define to empty if the C compiler does not understand signed types. */ +/* #undef signed */ + +/* Define to empty if the keyword `volatile' does not work. Warning: valid + code using `volatile' can become incorrect without. Disable with care. */ +/* #undef volatile */ diff --git a/src/include/port.h b/src/include/port.h index a17ad800f0..b195e95c7c 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -6,16 +6,13 @@ * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/port.h,v 1.91 2006/04/24 04:03:24 momjian Exp $ + * $PostgreSQL: pgsql/src/include/port.h,v 1.92 2006/06/07 22:24:45 momjian Exp $ * *------------------------------------------------------------------------- */ -#ifndef WIN32_CLIENT_ONLY -/* for thread.c */ #include #include -#endif #include @@ -221,7 +218,7 @@ extern int pgrename(const char *from, const char *to); extern int pgunlink(const char *path); /* Include this first so later includes don't see these defines */ -#ifdef WIN32_CLIENT_ONLY +#ifdef WIN32_ONLY_COMPILER #include #endif @@ -249,10 +246,10 @@ extern bool rmtree(char *path, bool rmtopdir); /* open() replacement to allow delete of held files and passing * of special options. */ -#ifndef WIN32_CLIENT_ONLY extern int win32_open(const char *, int,...); -#define open(a,b,...) win32_open(a,b,##__VA_ARGS__) +#ifndef FRONTEND +#define open(a,b,c) win32_open(a,b,c) #endif #define popen(a,b) _popen(a,b) @@ -304,10 +301,8 @@ extern double rint(double x); #endif #ifndef HAVE_INET_ATON -#ifndef WIN32_CLIENT_ONLY #include #include -#endif extern int inet_aton(const char *cp, struct in_addr * addr); #endif diff --git a/src/include/port/win32.h b/src/include/port/win32.h index 40c1365198..60ac755a15 100644 --- a/src/include/port/win32.h +++ b/src/include/port/win32.h @@ -1,21 +1,24 @@ -/* $PostgreSQL: pgsql/src/include/port/win32.h,v 1.51 2006/03/03 20:52:36 momjian Exp $ */ +/* $PostgreSQL: pgsql/src/include/port/win32.h,v 1.52 2006/06/07 22:24:45 momjian Exp $ */ /* undefine and redefine after #include */ #undef mkdir #undef ERROR +#define _WINSOCKAPI_ #include -#include +#include +#include +#undef small #include #include #include - +#include +#include /* for non-unicode version */ #undef near /* Must be here to avoid conflicting with prototype in windows.h */ #define mkdir(a,b) mkdir(a) - #define HAVE_FSYNC_WRITETHROUGH #define HAVE_FSYNC_WRITETHROUGH_ONLY #define ftruncate(a,b) chsize(a,b) @@ -28,7 +31,7 @@ #define USES_WINSOCK /* defines for dynamic linking on Win32 platform */ -#if defined(__MINGW32__) || defined(__CYGWIN__) +#if defined(WIN32) || defined(__CYGWIN__) #if __GNUC__ && ! defined (__declspec) #error You need egcs 1.1 or newer for compiling! @@ -40,19 +43,12 @@ #define DLLIMPORT __declspec (dllimport) #endif -#elif defined(WIN32_CLIENT_ONLY) - -#if defined(_DLL) -#define DLLIMPORT __declspec (dllexport) -#else /* not _DLL */ -#define DLLIMPORT __declspec (dllimport) -#endif - #else /* not CYGWIN, not MSVC, not MingW */ #define DLLIMPORT #endif + /* * IPC defines */ @@ -175,7 +171,7 @@ typedef int gid_t; #endif typedef long key_t; -#ifdef WIN32_CLIENT_ONLY +#ifdef WIN32_ONLY_COMPILER typedef int pid_t; #endif @@ -254,5 +250,37 @@ extern int pgwin32_is_admin(void); extern int pgwin32_is_service(void); #endif -/* in backend/port/win32/error.c */ +/* in port/win32error.c */ extern void _dosmaperr(unsigned long); + + +/* Things that exist in MingW headers, but need to be added to MSVC */ +#ifdef WIN32_ONLY_COMPILER +typedef long ssize_t; +typedef unsigned short mode_t; + +#define inline __inline +#define __inline__ __inline + +#define _S_IRWXU (_S_IREAD | _S_IWRITE | _S_IEXEC) +#define _S_IXUSR _S_IEXEC +#define _S_IWUSR _S_IWRITE +#define _S_IRUSR _S_IREAD +#define S_IRUSR _S_IRUSR +#define S_IWUSR _S_IWUSR +#define S_IXUSR _S_IXUSR +#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) +#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) + +#define F_OK 0 +#define W_OK 2 +#define R_OK 4 + +#define isinf(x) ((_fpclass(x) == _FPCLASS_PINF) || (_fpclass(x) == _FPCLASS_NINF)) +#define isnan(x) _isnan(x) +#define finite(x) _finite(x) + + +/* Pulled from Makefile.port in mingw */ +#define DLSUFFIX ".dll" +#endif diff --git a/src/include/port/win32_msvc/dirent.h b/src/include/port/win32_msvc/dirent.h new file mode 100644 index 0000000000..42af9bd219 --- /dev/null +++ b/src/include/port/win32_msvc/dirent.h @@ -0,0 +1,21 @@ +/* + * Headers for port/dirent.c, win32 native implementation of dirent functions + * + * $PostgreSQL: pgsql/src/include/port/win32_msvc/dirent.h,v 1.1 2006/06/07 22:24:45 momjian Exp $ + */ + +#ifndef _WIN32VC_DIRENT_H +#define _WIN32VC_DIRENT_H +struct dirent { + long d_ino; + unsigned short d_reclen; + unsigned short d_namlen; + char d_name[MAX_PATH]; +}; + +typedef struct DIR DIR; + +DIR* opendir(const char *); +struct dirent* readdir(DIR *); +int closedir(DIR*); +#endif diff --git a/src/include/port/win32_msvc/sys/file.h b/src/include/port/win32_msvc/sys/file.h new file mode 100644 index 0000000000..b02d4ad950 --- /dev/null +++ b/src/include/port/win32_msvc/sys/file.h @@ -0,0 +1 @@ +/* $PostgreSQL: pgsql/src/include/port/win32_msvc/sys/file.h,v 1.1 2006/06/07 22:24:45 momjian Exp $ */ diff --git a/src/include/port/win32_msvc/sys/param.h b/src/include/port/win32_msvc/sys/param.h new file mode 100644 index 0000000000..8efec5a21d --- /dev/null +++ b/src/include/port/win32_msvc/sys/param.h @@ -0,0 +1 @@ +/* $PostgreSQL: pgsql/src/include/port/win32_msvc/sys/param.h,v 1.1 2006/06/07 22:24:45 momjian Exp $ */ diff --git a/src/include/port/win32_msvc/sys/time.h b/src/include/port/win32_msvc/sys/time.h new file mode 100644 index 0000000000..0295788ec4 --- /dev/null +++ b/src/include/port/win32_msvc/sys/time.h @@ -0,0 +1 @@ +/* $PostgreSQL: pgsql/src/include/port/win32_msvc/sys/time.h,v 1.1 2006/06/07 22:24:45 momjian Exp $ */ diff --git a/src/include/port/win32_msvc/unistd.h b/src/include/port/win32_msvc/unistd.h new file mode 100644 index 0000000000..b0072a0af6 --- /dev/null +++ b/src/include/port/win32_msvc/unistd.h @@ -0,0 +1 @@ +/* $PostgreSQL: pgsql/src/include/port/win32_msvc/unistd.h,v 1.1 2006/06/07 22:24:45 momjian Exp $ */ diff --git a/src/include/port/win32_msvc/utime.h b/src/include/port/win32_msvc/utime.h new file mode 100644 index 0000000000..2209604f3c --- /dev/null +++ b/src/include/port/win32_msvc/utime.h @@ -0,0 +1 @@ +/* $PostgreSQL: pgsql/src/include/port/win32_msvc/utime.h,v 1.1 2006/06/07 22:24:45 momjian Exp $ */ diff --git a/src/include/storage/s_lock.h b/src/include/storage/s_lock.h index dff5ffc8c2..23f4cc9cd4 100644 --- a/src/include/storage/s_lock.h +++ b/src/include/storage/s_lock.h @@ -66,7 +66,7 @@ * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/storage/s_lock.h,v 1.156 2006/05/19 13:10:11 momjian Exp $ + * $PostgreSQL: pgsql/src/include/storage/s_lock.h,v 1.157 2006/06/07 22:24:45 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -784,6 +784,24 @@ extern slock_t pg_atomic_cas(volatile slock_t *lock, slock_t with, #endif +#ifdef WIN32_ONLY_COMPILER +typedef LONG slock_t; + +#define HAS_TEST_AND_SET +#define TAS(lock) (InterlockedCompareExchange(lock, 1, 0)) + +#define SPIN_DELAY() spin_delay() + +static __forceinline void +spin_delay(void) +{ + /* See comment for gcc code. Same code, MASM syntax */ + __asm rep nop; +} + +#endif + + #endif /* !defined(HAS_TEST_AND_SET) */ diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c index 6634758948..74dfe3a9cf 100644 --- a/src/interfaces/libpq/fe-connect.c +++ b/src/interfaces/libpq/fe-connect.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.332 2006/05/21 20:19:23 tgl Exp $ + * $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.333 2006/06/07 22:24:46 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -20,9 +20,7 @@ #include #include #include -#ifndef WIN32_CLIENT_ONLY #include -#endif #ifndef HAVE_STRDUP #include "strdup.h" diff --git a/src/interfaces/libpq/fe-misc.c b/src/interfaces/libpq/fe-misc.c index 5c113ae988..011e57120c 100644 --- a/src/interfaces/libpq/fe-misc.c +++ b/src/interfaces/libpq/fe-misc.c @@ -23,7 +23,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/interfaces/libpq/fe-misc.c,v 1.127 2006/05/23 19:28:45 momjian Exp $ + * $PostgreSQL: pgsql/src/interfaces/libpq/fe-misc.c,v 1.128 2006/06/07 22:24:46 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -34,10 +34,8 @@ #include #include -#ifndef WIN32_CLIENT_ONLY #include #include -#endif #ifdef WIN32 #include "win32.h" diff --git a/src/interfaces/libpq/win32.c b/src/interfaces/libpq/win32.c index 28b6a1a5bd..2c5a58bef1 100644 --- a/src/interfaces/libpq/win32.c +++ b/src/interfaces/libpq/win32.c @@ -26,12 +26,18 @@ #define NOCRYPT #include -#include #include #include "win32.h" -#include "postgres_fe.h" -#include "libpq-fe.h" -#include "libpq-int.h" + +/* Declared here to avoid pulling in all includes, which causes name collissions */ +#ifdef ENABLE_NLS +extern char * +libpq_gettext(const char *msgid) +__attribute__((format_arg(1))); +#else +#define libpq_gettext(x) (x) +#endif + static struct WSErrorEntry { diff --git a/src/interfaces/libpq/win32.mak b/src/interfaces/libpq/win32.mak index 3af6966997..48bf70af0b 100644 --- a/src/interfaces/libpq/win32.mak +++ b/src/interfaces/libpq/win32.mak @@ -68,6 +68,7 @@ CLEAN : -@erase "$(INTDIR)\wchar.obj" -@erase "$(INTDIR)\encnames.obj" -@erase "$(INTDIR)\pthread-win32.obj" + -@erase "$(INTDIR)\snprintf.obj" -@erase "$(OUTDIR)\$(OUTFILENAME).lib" -@erase "$(OUTDIR)\$(OUTFILENAME)dll.lib" -@erase "$(OUTDIR)\libpq.res" @@ -103,6 +104,7 @@ LIB32_OBJS= \ "$(INTDIR)\pqsignal.obj" \ "$(INTDIR)\wchar.obj" \ "$(INTDIR)\encnames.obj" \ + "$(INTDIR)\snprintf.obj" \ "$(INTDIR)\pthread-win32.obj" @@ -117,7 +119,7 @@ pg_config_paths.h: win32.mak "$(OUTDIR)" : if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" -CPP_PROJ=/nologo /W3 /GX $(OPT) /I "..\..\include" /I. /D "FRONTEND" $(DEBUGDEF) /D\ +CPP_PROJ=/nologo /W3 /GX $(OPT) /I "..\..\include" /I "..\..\include\port\win32" /I "..\..\include\port\win32_msvc" /I. /D "FRONTEND" $(DEBUGDEF) /D\ "WIN32" /D "_WINDOWS" /Fp"$(INTDIR)\libpq.pch" /YX\ /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c /D "HAVE_VSNPRINTF" /D "HAVE_STRDUP" @@ -212,6 +214,11 @@ LINK32_OBJS= \ $(CPP_PROJ) /I"." ..\..\backend\utils\mb\encnames.c << +"$(INTDIR)\snprintf.obj" : ..\..\port\snprintf.c + $(CPP) @<< + $(CPP_PROJ) /I"." ..\..\port\snprintf.c +<< + .c{$(CPP_OBJS)}.obj: $(CPP) $(CPP_PROJ) $< diff --git a/src/port/dirent.c b/src/port/dirent.c new file mode 100644 index 0000000000..3722db862d --- /dev/null +++ b/src/port/dirent.c @@ -0,0 +1,108 @@ +/*------------------------------------------------------------------------- + * + * dirent.c + * opendir/readdir/closedir for win32/msvc + * + * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * + * IDENTIFICATION + * $PostgreSQL: pgsql/src/port/dirent.c,v 1.1 2006/06/07 22:24:46 momjian Exp $ + * + *------------------------------------------------------------------------- + */ + +#include "postgres.h" +#include + + +struct DIR { + char *dirname; + struct dirent ret; /* Used to return to caller */ + HANDLE handle; +}; + +DIR* opendir(const char *dirname) +{ + DWORD attr; + DIR *d; + + /* Make sure it is a directory */ + attr = GetFileAttributes(dirname); + if (attr == INVALID_FILE_ATTRIBUTES) + { + errno = ENOENT; + return NULL; + } + if ((attr & FILE_ATTRIBUTE_DIRECTORY) != FILE_ATTRIBUTE_DIRECTORY) + { + errno = ENOTDIR; + return NULL; + } + + d = malloc(sizeof(DIR)); + if (!d) + { + errno = ENOMEM; + return NULL; + } + d->dirname = malloc(strlen(dirname)+4); + if (!d->dirname) + { + errno = ENOMEM; + free(d); + return NULL; + } + strcpy(d->dirname, dirname); + if (d->dirname[strlen(d->dirname)-1] != '/' && + d->dirname[strlen(d->dirname)-1] != '\\') + strcat(d->dirname,"\\"); /* Append backslash if not already there */ + strcat(d->dirname,"*"); /* Search for entries named anything */ + d->handle = INVALID_HANDLE_VALUE; + d->ret.d_ino = 0; /* no inodes on win32 */ + d->ret.d_reclen = 0; /* not used on win32 */ + + return d; +} + +struct dirent* readdir(DIR * d) +{ + WIN32_FIND_DATA fd; + + if (d->handle == INVALID_HANDLE_VALUE) + { + d->handle = FindFirstFile(d->dirname, &fd); + if (d->handle == INVALID_HANDLE_VALUE) + { + errno = ENOENT; + return NULL; + } + } + else + { + if (!FindNextFile(d->handle, &fd)) + { + if (GetLastError() == ERROR_NO_MORE_FILES) + { + /* No more files, force errno=0 (unlike mingw) */ + errno = 0; + return NULL; + } + _dosmaperr(GetLastError()); + return NULL; + } + } + strcpy(d->ret.d_name, fd.cFileName); /* Both strings are MAX_PATH long */ + d->ret.d_namlen = strlen(d->ret.d_name); + return &d->ret; +} + +int closedir(DIR *d) +{ + if (d->handle != INVALID_HANDLE_VALUE) + FindClose(d->handle); + free(d->dirname); + free(d); + return 0; +} diff --git a/src/port/exec.c b/src/port/exec.c index 563d986ec6..7abc3d650b 100644 --- a/src/port/exec.c +++ b/src/port/exec.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/port/exec.c,v 1.41 2006/03/05 15:59:10 momjian Exp $ + * $PostgreSQL: pgsql/src/port/exec.c,v 1.42 2006/06/07 22:24:46 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -24,9 +24,7 @@ #include #include #include -#ifndef WIN32_CLIENT_ONLY #include -#endif #ifndef S_IRUSR /* XXX [TRH] should be in a header */ #define S_IRUSR S_IREAD @@ -48,7 +46,7 @@ #define log_error(str, param) (fprintf(stderr, str, param), fputc('\n', stderr)) #endif -#ifdef WIN32_CLIENT_ONLY +#ifdef WIN32_ONLY_COMPILER #define getcwd(cwd,len) GetCurrentDirectory(len, cwd) #endif diff --git a/src/port/getaddrinfo.c b/src/port/getaddrinfo.c index 3117db0527..51e31c18c0 100644 --- a/src/port/getaddrinfo.c +++ b/src/port/getaddrinfo.c @@ -16,7 +16,7 @@ * Copyright (c) 2003-2006, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/src/port/getaddrinfo.c,v 1.23 2006/03/05 15:59:10 momjian Exp $ + * $PostgreSQL: pgsql/src/port/getaddrinfo.c,v 1.24 2006/06/07 22:24:46 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -24,23 +24,15 @@ /* This is intended to be used in both frontend and backend, so use c.h */ #include "c.h" -#ifndef WIN32_CLIENT_ONLY #include #include #include #include -#endif #include "getaddrinfo.h" #ifdef WIN32 - -#define WIN32_LEAN_AND_MEAN - -#include - -#if !defined(WIN32_CLIENT_ONLY) /* * The native routines may or may not exist on the Windows platform we are on, * so we dynamically look up the routines, and call them via function pointers. @@ -130,7 +122,6 @@ haveNativeWindowsIPv6routines(void) return (getaddrinfo_ptr != NULL); } #endif -#endif /* @@ -151,7 +142,7 @@ getaddrinfo(const char *node, const char *service, *psin; struct addrinfo hints; -#if defined(WIN32) && !defined(WIN32_CLIENT_ONLY) +#ifdef WIN32 /* * If Windows has native IPv6 support, use the native Windows routine. @@ -274,7 +265,7 @@ freeaddrinfo(struct addrinfo * res) { if (res) { -#if defined(WIN32) && !defined(WIN32_CLIENT_ONLY) +#ifdef WIN32 /* * If Windows has native IPv6 support, use the native Windows routine. @@ -337,9 +328,11 @@ gai_strerror(int errcode) return "Not enough memory"; #endif #ifdef EAI_NODATA +#ifndef WIN32_ONLY_COMPILER /* MSVC complains because another case has the same value */ case EAI_NODATA: return "No host data of that type was found"; #endif +#endif #ifdef EAI_SERVICE case EAI_SERVICE: return "Class type not found"; @@ -366,7 +359,7 @@ getnameinfo(const struct sockaddr * sa, int salen, char *node, int nodelen, char *service, int servicelen, int flags) { -#if defined(WIN32) && !defined(WIN32_CLIENT_ONLY) +#ifdef WIN32 /* * If Windows has native IPv6 support, use the native Windows routine. diff --git a/src/port/inet_aton.c b/src/port/inet_aton.c index f5a64dbdbb..7ea3512a6d 100644 --- a/src/port/inet_aton.c +++ b/src/port/inet_aton.c @@ -1,4 +1,4 @@ -/* $PostgreSQL: pgsql/src/port/inet_aton.c,v 1.8 2005/10/15 02:49:51 momjian Exp $ +/* $PostgreSQL: pgsql/src/port/inet_aton.c,v 1.9 2006/06/07 22:24:46 momjian Exp $ * * This inet_aton() function was taken from the GNU C library and * incorporated into Postgres for those systems which do not have this @@ -44,10 +44,8 @@ #include "c.h" -#ifndef WIN32_CLIENT_ONLY #include #include -#endif /* * Check whether "cp" is a valid ascii representation diff --git a/src/port/thread.c b/src/port/thread.c index ed6e48a4e7..def2fcfa1d 100644 --- a/src/port/thread.c +++ b/src/port/thread.c @@ -7,19 +7,15 @@ * * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/port/thread.c,v 1.32 2006/03/05 15:59:10 momjian Exp $ + * $PostgreSQL: pgsql/src/port/thread.c,v 1.33 2006/06/07 22:24:46 momjian Exp $ * *------------------------------------------------------------------------- */ #include "c.h" -#ifdef WIN32_CLIENT_ONLY -#undef ERROR -#else #include -#endif -#if defined(ENABLE_THREAD_SAFETY) +#if defined(FRONTEND) && defined(ENABLE_THREAD_SAFETY) #include #endif diff --git a/src/port/win32error.c b/src/port/win32error.c new file mode 100644 index 0000000000..31127b683b --- /dev/null +++ b/src/port/win32error.c @@ -0,0 +1,200 @@ +/*------------------------------------------------------------------------- + * + * win32error.c + * Map win32 error codes to errno values + * + * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group + * + * IDENTIFICATION + * $PostgreSQL: pgsql/src/port/win32error.c,v 1.1 2006/06/07 22:24:46 momjian Exp $ + * + *------------------------------------------------------------------------- + */ + +#include "postgres.h" + +static const struct +{ + DWORD winerr; + int doserr; +} doserrors[] = + +{ + { + ERROR_INVALID_FUNCTION, EINVAL + }, + { + ERROR_FILE_NOT_FOUND, ENOENT + }, + { + ERROR_PATH_NOT_FOUND, ENOENT + }, + { + ERROR_TOO_MANY_OPEN_FILES, EMFILE + }, + { + ERROR_ACCESS_DENIED, EACCES + }, + { + ERROR_INVALID_HANDLE, EBADF + }, + { + ERROR_ARENA_TRASHED, ENOMEM + }, + { + ERROR_NOT_ENOUGH_MEMORY, ENOMEM + }, + { + ERROR_INVALID_BLOCK, ENOMEM + }, + { + ERROR_BAD_ENVIRONMENT, E2BIG + }, + { + ERROR_BAD_FORMAT, ENOEXEC + }, + { + ERROR_INVALID_ACCESS, EINVAL + }, + { + ERROR_INVALID_DATA, EINVAL + }, + { + ERROR_INVALID_DRIVE, ENOENT + }, + { + ERROR_CURRENT_DIRECTORY, EACCES + }, + { + ERROR_NOT_SAME_DEVICE, EXDEV + }, + { + ERROR_NO_MORE_FILES, ENOENT + }, + { + ERROR_LOCK_VIOLATION, EACCES + }, + { + ERROR_SHARING_VIOLATION, EACCES + }, + { + ERROR_BAD_NETPATH, ENOENT + }, + { + ERROR_NETWORK_ACCESS_DENIED, EACCES + }, + { + ERROR_BAD_NET_NAME, ENOENT + }, + { + ERROR_FILE_EXISTS, EEXIST + }, + { + ERROR_CANNOT_MAKE, EACCES + }, + { + ERROR_FAIL_I24, EACCES + }, + { + ERROR_INVALID_PARAMETER, EINVAL + }, + { + ERROR_NO_PROC_SLOTS, EAGAIN + }, + { + ERROR_DRIVE_LOCKED, EACCES + }, + { + ERROR_BROKEN_PIPE, EPIPE + }, + { + ERROR_DISK_FULL, ENOSPC + }, + { + ERROR_INVALID_TARGET_HANDLE, EBADF + }, + { + ERROR_INVALID_HANDLE, EINVAL + }, + { + ERROR_WAIT_NO_CHILDREN, ECHILD + }, + { + ERROR_CHILD_NOT_COMPLETE, ECHILD + }, + { + ERROR_DIRECT_ACCESS_HANDLE, EBADF + }, + { + ERROR_NEGATIVE_SEEK, EINVAL + }, + { + ERROR_SEEK_ON_DEVICE, EACCES + }, + { + ERROR_DIR_NOT_EMPTY, ENOTEMPTY + }, + { + ERROR_NOT_LOCKED, EACCES + }, + { + ERROR_BAD_PATHNAME, ENOENT + }, + { + ERROR_MAX_THRDS_REACHED, EAGAIN + }, + { + ERROR_LOCK_FAILED, EACCES + }, + { + ERROR_ALREADY_EXISTS, EEXIST + }, + { + ERROR_FILENAME_EXCED_RANGE, ENOENT + }, + { + ERROR_NESTING_NOT_ALLOWED, EAGAIN + }, + { + ERROR_NOT_ENOUGH_QUOTA, ENOMEM + } +}; + +void +_dosmaperr(unsigned long e) +{ + int i; + + if (e == 0) + { + errno = 0; + return; + } + + for (i = 0; i < lengthof(doserrors); i++) + { + if (doserrors[i].winerr == e) + { + errno = doserrors[i].doserr; +#ifndef FRONTEND + ereport(DEBUG5, + (errmsg_internal("mapped win32 error code %lu to %d", + e, errno))); +#else + fprintf(stderr, _("mapped win32 error code %lu to %d"), e, errno); +#endif + return; + } + } + +#ifndef FRONTEND + ereport(LOG, + (errmsg_internal("unrecognized win32 error code: %lu", + e))); +#else + fprintf(stderr, _("unrecognized win32 error code: %lu"), e); +#endif + + errno = EINVAL; + return; +} diff --git a/src/timezone/localtime.c b/src/timezone/localtime.c index fd609aba17..35fa21ef87 100644 --- a/src/timezone/localtime.c +++ b/src/timezone/localtime.c @@ -3,7 +3,7 @@ * 1996-06-05 by Arthur David Olson (arthur_david_olson@nih.gov). * * IDENTIFICATION - * $PostgreSQL: pgsql/src/timezone/localtime.c,v 1.13 2006/04/09 19:21:34 tgl Exp $ + * $PostgreSQL: pgsql/src/timezone/localtime.c,v 1.14 2006/06/07 22:24:46 momjian Exp $ */ /* @@ -157,7 +157,7 @@ tzload(const char *name, struct state * sp) } if (doaccess && access(name, R_OK) != 0) return -1; - if ((fid = open(name, O_RDONLY | PG_BINARY)) == -1) + if ((fid = open(name, O_RDONLY | PG_BINARY, 0)) == -1) return -1; } {