hpux*) template=hpux ;;
irix*) template=irix5 ;;
linux*) template=linux ;;
- mingw*) template=win ;;
+ mingw*) template=win32 ;;
netbsd*) template=netbsd ;;
nextstep*) template=nextstep ;;
openbsd*) template=openbsd ;;
done
IFS=$ac_save_IFS
-
#
# Tcl/Tk
#
fi
+
+echo "$as_me:$LINENO: checking for main in -lwsock32" >&5
+echo $ECHO_N "checking for main in -lwsock32... $ECHO_C" >&6
+if test "${ac_cv_lib_wsock32_main+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-lwsock32 $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+#include "confdefs.h"
+
+
+#ifdef F77_DUMMY_MAIN
+# ifdef __cplusplus
+ extern "C"
+# endif
+ int F77_DUMMY_MAIN() { return 1; }
+#endif
+int
+main ()
+{
+main ();
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_lib_wsock32_main=yes
+else
+ echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_lib_wsock32_main=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_lib_wsock32_main" >&5
+echo "${ECHO_T}$ac_cv_lib_wsock32_main" >&6
+if test $ac_cv_lib_wsock32_main = yes; then
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBWSOCK32 1
+_ACEOF
+
+ LIBS="-lwsock32 $LIBS"
+
+fi
+
echo "$as_me:$LINENO: checking for library containing getopt_long" >&5
echo $ECHO_N "checking for library containing getopt_long... $ECHO_C" >&6
if test "${ac_cv_search_getopt_long+set}" = set; then
{ (exit 1); exit 1; }; }
fi
+
+for ac_func in gethostname
+do
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+echo "$as_me:$LINENO: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
+if eval "test \"\${$as_ac_var+set}\" = set"; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $ac_func (); below. */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char $ac_func ();
+char (*f) ();
+
+#ifdef F77_DUMMY_MAIN
+# ifdef __cplusplus
+ extern "C"
+# endif
+ int F77_DUMMY_MAIN() { return 1; }
+#endif
+int
+main ()
+{
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+f = $ac_func;
+#endif
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ eval "$as_ac_var=yes"
+else
+ echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+eval "$as_ac_var=no"
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
+if test `eval echo '${'$as_ac_var'}'` = yes; then
+ cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+else
+ LIBOBJS="$LIBOBJS $ac_func.$ac_objext"
+fi
+done
+
+
fi
if test "$with_krb5" = yes ; then
-for ac_func in crypt fseeko gethostname getopt_long getrusage inet_aton random rint srandom strcasecmp strdup strerror strtol strtoul
+for ac_func in crypt fseeko getopt getopt_long getrusage inet_aton random rint srandom strcasecmp strdup strerror strtol strtoul
do
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
echo "$as_me:$LINENO: checking for $ac_func" >&5
esac
# Win32 can't to rename or unlink on an open file
-case $host_os in win32*)
-LIBOBJS="$LIBOBJS dirmod.$ac_objext"
-LIBOBJS="$LIBOBJS opendir.$ac_objext" ;;
+case $host_os in win32*|mingw*)
+LIBOBJS="$LIBOBJS dirmod.$ac_objext" ;;
esac
if test "$with_readline" = yes; then
dnl Process this file with autoconf to produce a configure script.
-dnl $Header: /cvsroot/pgsql/configure.in,v 1.249 2003/05/10 04:03:37 momjian Exp $
+dnl $Header: /cvsroot/pgsql/configure.in,v 1.250 2003/05/15 16:35:27 momjian Exp $
dnl
dnl Developers, please strive to achieve this order:
dnl
hpux*) template=hpux ;;
irix*) template=irix5 ;;
linux*) template=linux ;;
- mingw*) template=win ;;
+ mingw*) template=win32 ;;
netbsd*) template=netbsd ;;
nextstep*) template=nextstep ;;
openbsd*) template=openbsd ;;
done
IFS=$ac_save_IFS
-
#
# Tcl/Tk
#
AC_CHECK_LIB(gen, main)
AC_CHECK_LIB(PW, main)
AC_CHECK_LIB(resolv, main)
+AC_CHECK_LIB(wsock32, main)
AC_SEARCH_LIBS(getopt_long, [getopt gnugetopt])
# QNX:
AC_CHECK_LIB(unix, main)
if test "$with_krb4" = yes ; then
AC_CHECK_LIB(des, des_encrypt, [], [AC_MSG_ERROR([library 'des' is required for Kerberos 4])])
AC_CHECK_LIB(krb, krb_sendauth, [], [AC_MSG_ERROR([library 'krb' is required for Kerberos 4])])
+ AC_REPLACE_FUNCS([gethostname])
fi
if test "$with_krb5" = yes ; then
AC_CHECK_FUNCS([fpclass fp_class fp_class_d class], [break])
fi
-AC_REPLACE_FUNCS([crypt fseeko gethostname getopt_long getrusage inet_aton random rint srandom strcasecmp strdup strerror strtol strtoul])
+AC_REPLACE_FUNCS([crypt fseeko getopt getopt_long getrusage inet_aton random rint srandom strcasecmp strdup strerror strtol strtoul])
# system's version of getaddrinfo(), if any, may be used only if we found
# a definition for struct addrinfo; see notes in src/include/getaddrinfo.h
esac
# Win32 can't to rename or unlink on an open file
-case $host_os in win32*)
-AC_LIBOBJ(dirmod)
-AC_LIBOBJ(opendir) ;;
+case $host_os in win32*|mingw*)
+AC_LIBOBJ(dirmod) ;;
esac
if test "$with_readline" = yes; then
TODO list for PostgreSQL
========================
-Last updated: Wed Apr 2 17:44:34 EST 2003
+Last updated: Thu May 15 12:10:39 EDT 2003
Current maintainer: Bruce Momjian (pgman@candle.pha.pa.us)
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/libpq/be-secure.c,v 1.31 2003/04/25 04:37:23 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/libpq/be-secure.c,v 1.32 2003/05/15 16:35:28 momjian Exp $
*
* Since the server static private key ($DataDir/server.key)
* will normally be stored unencrypted so that the database
#include "libpq/libpq.h"
#include "miscadmin.h"
-#ifdef WIN32
-#include "win32.h"
-#else
#include <sys/socket.h>
#include <unistd.h>
#include <netdb.h>
#include <netinet/in.h>
#ifdef HAVE_NETINET_TCP_H
#include <netinet/tcp.h>
-#endif
#include <arpa/inet.h>
#endif
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Header: /cvsroot/pgsql/src/backend/libpq/pqcomm.c,v 1.152 2003/04/25 01:24:00 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/libpq/pqcomm.c,v 1.153 2003/05/15 16:35:28 momjian Exp $
*
*-------------------------------------------------------------------------
*/
Assert(Unix_socket_group);
if (Unix_socket_group[0] != '\0')
{
+#ifdef WIN32
+ elog(FATAL, "Config value 'unix_socket_group' not supported on this platform");
+#else
char *endptr;
unsigned long int val;
gid_t gid;
sock_path, strerror(errno));
return STATUS_ERROR;
}
+#endif
}
if (chmod(sock_path, Unix_socket_permissions) == -1)
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/main/main.c,v 1.56 2002/11/08 20:23:56 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/main/main.c,v 1.57 2003/05/15 16:35:28 momjian Exp $
*
*-------------------------------------------------------------------------
*/
strcmp(argv[1], "--version") == 0 ||
strcmp(argv[1], "-V") == 0)))
{
+#ifndef WIN32
+#ifndef __BEOS__
/*
* Make sure we are not running as root.
*
* BeOS currently runs everything as root :-(, so this check must be
* temporarily disabled there...
*/
-#ifndef __BEOS__
if (geteuid() == 0)
{
fprintf(stderr, gettext(
));
exit(1);
}
-#endif /* __BEOS__ */
+#endif /* !__BEOS__ */
/*
* Also make sure that real and effective uids are the same.
argv[0]);
exit(1);
}
+#endif /* !WIN32 */
}
/*
* specifying current userid as the "authenticated" Postgres user
* name.
*/
+#ifndef WIN32
pw = getpwuid(geteuid());
if (pw == NULL)
{
}
/* Allocate new memory because later getpwuid() calls can overwrite it */
pw_name_persist = strdup(pw->pw_name);
+#else
+ {
+ long namesize = 256 /* UNLEN */ + 1;
+
+ pw_name_persist = malloc(namesize);
+ if (!GetUserName(pw_name_persist, &namesize))
+ {
+ fprintf(stderr, "%s: GetUserName failed\n", argv[0]);
+ exit(1);
+ }
+ }
+#endif
exit(PostgresMain(argc, new_argv, pw_name_persist));
}
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.413 2003/05/04 00:03:55 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.414 2003/05/15 16:35:28 momjian Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
*/
/* ordinary key words in alphabetical order */
-%token <keyword> ABORT_P ABSOLUTE ACCESS ACTION ADD AFTER
+%token <keyword> ABORT_P ABSOLUTE_P ACCESS ACTION ADD AFTER
AGGREGATE ALL ALTER ANALYSE ANALYZE AND ANY ARRAY AS ASC
ASSERTION ASSIGNMENT AT AUTHORIZATION
BACKWARD BEFORE BEGIN_P BETWEEN BIGINT BINARY BIT
- BOOLEAN BOTH BY
+ BOOLEAN_P BOTH BY
CACHE CALLED CASCADE CASE CAST CHAIN CHAR_P
CHARACTER CHARACTERISTICS CHECK CHECKPOINT CLASS CLOSE
CREATEUSER CROSS CURRENT_DATE CURRENT_TIME
CURRENT_TIMESTAMP CURRENT_USER CURSOR CYCLE
- DATABASE DAY_P DEALLOCATE DEC DECIMAL DECLARE DEFAULT
+ DATABASE DAY_P DEALLOCATE DEC DECIMAL_P DECLARE DEFAULT
DEFERRABLE DEFERRED DEFINER DELETE_P DELIMITER DELIMITERS
- DESC DISTINCT DO DOMAIN_P DOUBLE DROP
+ DESC DISTINCT DO DOMAIN_P DOUBLE_P DROP
EACH ELSE ENCODING ENCRYPTED END_P ESCAPE EXCEPT
EXCLUSIVE EXECUTE EXISTS EXPLAIN EXTERNAL EXTRACT
HANDLER HAVING HOLD HOUR_P
ILIKE IMMEDIATE IMMUTABLE IMPLICIT_P IN_P INCREMENT
- INDEX INHERITS INITIALLY INNER_P INOUT INPUT
- INSENSITIVE INSERT INSTEAD INT INTEGER INTERSECT
+ INDEX INHERITS INITIALLY INNER_P INOUT INPUT_P
+ INSENSITIVE INSERT INSTEAD INT_P INTEGER INTERSECT
INTERVAL INTO INVOKER IS ISNULL ISOLATION
JOIN
ORDER OUT_P OUTER_P OVERLAPS OVERLAY OWNER
PARTIAL PASSWORD PATH_P PENDANT PLACING POSITION
- PRECISION PRESERVE PREPARE PRIMARY PRIOR PRIVILEGES PROCEDURAL
- PROCEDURE
+ PRECISION PRESERVE PREPARE PRIMARY
+ PRIOR PRIVILEGES PROCEDURAL PROCEDURE
- READ REAL RECHECK REFERENCES REINDEX RELATIVE RENAME REPLACE
+ READ REAL RECHECK REFERENCES REINDEX RELATIVE_P RENAME REPLACE
RESET RESTART RESTRICT RETURNS REVOKE RIGHT ROLLBACK ROW ROWS
RULE
SCHEMA SCROLL SECOND_P SECURITY SELECT SEQUENCE
SERIALIZABLE SESSION SESSION_USER SET SETOF SHARE
SHOW SIMILAR SIMPLE SMALLINT SOME STABLE START STATEMENT
- STATISTICS STDIN STDOUT STORAGE STRICT SUBSTRING
- SYSID
+ STATISTICS STDIN STDOUT STORAGE STRICT_P SUBSTRING SYSID
TABLE TEMP TEMPLATE TEMPORARY THEN TIME TIMESTAMP
TO TOAST TRAILING TRANSACTION TREAT TRIGGER TRIM TRUE_P
n->howMany = -1;
$$ = (Node *)n;
}
- | ABSOLUTE fetch_count
+ | ABSOLUTE_P fetch_count
{
FetchStmt *n = makeNode(FetchStmt);
n->direction = FETCH_ABSOLUTE;
n->howMany = $2;
$$ = (Node *)n;
}
- | RELATIVE fetch_count
+ | RELATIVE_P fetch_count
{
FetchStmt *n = makeNode(FetchStmt);
n->direction = FETCH_RELATIVE;
{
$$ = makeDefElem("volatility", (Node *)makeString("volatile"));
}
- | CALLED ON NULL_P INPUT
+ | CALLED ON NULL_P INPUT_P
{
$$ = makeDefElem("strict", (Node *)makeInteger(FALSE));
}
- | RETURNS NULL_P ON NULL_P INPUT
+ | RETURNS NULL_P ON NULL_P INPUT_P
{
$$ = makeDefElem("strict", (Node *)makeInteger(TRUE));
}
- | STRICT
+ | STRICT_P
{
$$ = makeDefElem("strict", (Node *)makeInteger(TRUE));
}
* Provide real DECIMAL() and NUMERIC() implementations now - Jan 1998-12-30
* - thomas 1997-09-18
*/
-Numeric: INT
+Numeric: INT_P
{
$$ = SystemTypeName("int4");
}
{
$$ = $2;
}
- | DOUBLE PRECISION
+ | DOUBLE_P PRECISION
{
$$ = SystemTypeName("float8");
}
- | DECIMAL opt_decimal
+ | DECIMAL_P opt_decimal
{
$$ = SystemTypeName("numeric");
$$->typmod = $2;
$$ = SystemTypeName("numeric");
$$->typmod = $2;
}
- | BOOLEAN
+ | BOOLEAN_P
{
$$ = SystemTypeName("bool");
}
*/
unreserved_keyword:
ABORT_P
- | ABSOLUTE
+ | ABSOLUTE_P
| ACCESS
| ACTION
| ADD
| DELIMITER
| DELIMITERS
| DOMAIN_P
- | DOUBLE
+ | DOUBLE_P
| DROP
| EACH
| ENCODING
| INDEX
| INHERITS
| INOUT
- | INPUT
+ | INPUT_P
| INSENSITIVE
| INSERT
| INSTEAD
| READ
| RECHECK
| REINDEX
- | RELATIVE
+ | RELATIVE_P
| RENAME
| REPLACE
| RESET
| STDIN
| STDOUT
| STORAGE
- | STRICT
| SYSID
+ | STRICT_P
| TEMP
| TEMPLATE
| TEMPORARY
col_name_keyword:
BIGINT
| BIT
- | BOOLEAN
+ | BOOLEAN_P
| CHAR_P
| CHARACTER
| COALESCE
| CONVERT
| DEC
- | DECIMAL
+ | DECIMAL_P
| EXISTS
| EXTRACT
| FLOAT_P
- | INT
+ | INT_P
| INTEGER
| INTERVAL
| NCHAR
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.138 2003/04/08 23:20:02 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.139 2003/05/15 16:35:28 momjian Exp $
*
*-------------------------------------------------------------------------
*/
static const ScanKeyword ScanKeywords[] = {
/* name, value */
{"abort", ABORT_P},
- {"absolute", ABSOLUTE},
+ {"absolute", ABSOLUTE_P},
{"access", ACCESS},
{"action", ACTION},
{"add", ADD},
{"bigint", BIGINT},
{"binary", BINARY},
{"bit", BIT},
- {"boolean", BOOLEAN},
+ {"boolean", BOOLEAN_P},
{"both", BOTH},
{"by", BY},
{"cache", CACHE},
{"day", DAY_P},
{"deallocate", DEALLOCATE},
{"dec", DEC},
- {"decimal", DECIMAL},
+ {"decimal", DECIMAL_P},
{"declare", DECLARE},
{"default", DEFAULT},
{"deferrable", DEFERRABLE},
{"distinct", DISTINCT},
{"do", DO},
{"domain", DOMAIN_P},
- {"double", DOUBLE},
+ {"double", DOUBLE_P},
{"drop", DROP},
{"each", EACH},
{"else", ELSE},
{"initially", INITIALLY},
{"inner", INNER_P},
{"inout", INOUT},
- {"input", INPUT},
+ {"input", INPUT_P},
{"insensitive", INSENSITIVE},
{"insert", INSERT},
{"instead", INSTEAD},
- {"int", INT},
+ {"int", INT_P},
{"integer", INTEGER},
{"intersect", INTERSECT},
{"interval", INTERVAL},
{"recheck", RECHECK},
{"references", REFERENCES},
{"reindex", REINDEX},
- {"relative", RELATIVE},
+ {"relative", RELATIVE_P},
{"rename", RENAME},
{"replace", REPLACE},
{"reset", RESET},
{"stdin", STDIN},
{"stdout", STDOUT},
{"storage", STORAGE},
- {"strict", STRICT},
+ {"strict", STRICT_P},
{"substring", SUBSTRING},
{"sysid", SYSID},
{"table", TABLE},
# be converted to Method 2.
#
# IDENTIFICATION
-# $Header: /cvsroot/pgsql/src/backend/port/Makefile,v 1.18 2002/07/27 20:10:05 petere Exp $
+# $Header: /cvsroot/pgsql/src/backend/port/Makefile,v 1.19 2003/05/15 16:35:29 momjian Exp $
#
#-------------------------------------------------------------------------
OBJS+=$(TAS)
ifeq ($(PORTNAME), qnx4)
-OBJS+=getrusage.o qnx4/SUBSYS.o
+OBJS+=qnx4/SUBSYS.o
endif
ifeq ($(PORTNAME), beos)
OBJS+=beos/SUBSYS.o
ifeq ($(PORTNAME), darwin)
OBJS+=darwin/SUBSYS.o
endif
+ifeq ($(PORTNAME), win32)
+OBJS+=win32/SUBSYS.o
+endif
all: SUBSYS.o
darwin.dir:
$(MAKE) -C darwin all
+win32/SUBSYS.o: win32.dir
+
+win32.dir:
+ $(MAKE) -C win32 all
+
tas.o: tas.s
$(CC) $(CFLAGS) -c $<
$(MAKE) -C beos clean
$(MAKE) -C darwin clean
$(MAKE) -C qnx4 clean
+ $(MAKE) -C win32 clean
+
-/* $Header: /cvsroot/pgsql/src/backend/port/dynloader/Attic/win.c,v 1.2 2003/03/21 17:18:34 petere Exp $ */
+/* $Header: /cvsroot/pgsql/src/backend/port/dynloader/win32.c,v 1.1 2003/05/15 16:35:29 momjian Exp $ */
#include <windows.h>
#include "postgres.h"
#include "storage/shmem.h"
-#include "sema.h"
#include <errno.h>
Size sem_set_size = sizeof(win32_sem_set_hdr) + semNum * (sizeof(HANDLE) + sizeof(int));
HANDLE *sem_handles = NULL;
int *sem_counts = NULL;
-
+ int i;
+
sec_attrs.nLength = sizeof(sec_attrs);
sec_attrs.lpSecurityDescriptor = NULL;
sec_attrs.bInheritHandle = TRUE;
sem_handles = (HANDLE *) ((off_t) new_set + new_set->m_semaphoreHandles);
sem_counts = (int *) ((off_t) new_set + new_set->m_semaphoreCounts);
- for (int i = 0; i < semNum && ans; ++i)
+ for (i = 0; i < semNum && ans; ++i)
{
strcpy(num_part, _itoa(i, cur_num, 10));
return MAKE_OFFSET(new_set);
else
{
+ int i;
/* Blow away what we've got right now... */
- for (int i = 0; i < semNum; ++i)
+ for (i = 0; i < semNum; ++i)
{
if (sem_handles[i])
CloseHandle(sem_handles[i]);
*
* Copyright (c) 2001-2003, PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/backend/postmaster/pgstat.c,v 1.35 2003/04/27 20:09:44 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/postmaster/pgstat.c,v 1.36 2003/05/15 16:35:29 momjian Exp $
* ----------
*/
#include "postgres.h"
* messages will be discarded; backends won't block waiting to send
* messages to the collector.
*/
- if (fcntl(pgStatSock, F_SETFL, O_NONBLOCK) < 0)
+ if (FCNTL_NONBLOCK(pgStatSock) < 0)
{
elog(LOG, "PGSTAT: fcntl() failed: %m");
goto startup_failed;
* Set the write pipe to nonblock mode, so that we cannot block when
* the collector falls behind.
*/
- if (fcntl(writePipe, F_SETFL, O_NONBLOCK) < 0)
+ if (FCNTL_NONBLOCK(writePipe) < 0)
{
elog(LOG, "PGSTATBUFF: fcntl() failed: %m");
exit(1);
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.327 2003/05/10 18:15:42 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.328 2003/05/15 16:35:29 momjian Exp $
*
* NOTES
*
bool Log_connections = false;
bool Db_user_namespace = false;
+/* For FNCTL_NONBLOCK */
+#if defined(WIN32) || defined(__BEOS__)
+long ioctlsocket_ret;
+#endif
+
/* list of library:init-function to be preloaded */
char *preload_libraries_string = NULL;
{
int save_errno = errno;
+#ifdef WIN32
+#warning fix waidpid for Win32
+#else
#ifdef HAVE_WAITPID
int status; /* backend exit status */
CleanupProc(pid, exitstatus);
} /* loop over pending child-death reports */
+#endif
if (FatalError)
{
{
char buffer[1000];
-#ifdef __BEOS__
- int on = 1;
-#endif
-
/* Format the error message packet */
snprintf(buffer, sizeof(buffer), "E%s%s\n",
gettext("Server process fork() failed: "),
strerror(errnum));
/* Set port to non-blocking. Don't do send() if this fails */
-#ifdef __BEOS__
- if (ioctl(port->sock, FIONBIO, &on) != 0)
+ if (FCNTL_NONBLOCK(port->sock) < 0)
return;
-#else
- if (fcntl(port->sock, F_SETFL, O_NONBLOCK) < 0)
- return;
-#endif
send(port->sock, buffer, strlen(buffer) + 1, 0);
}
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.129 2003/02/18 02:13:24 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.130 2003/05/15 16:35:29 momjian Exp $
*
*-------------------------------------------------------------------------
*/
bool
enable_sig_alarm(int delayms, bool is_statement_timeout)
{
+#ifdef WIN32
+# warning add Win32 timer
+#else
struct timeval fin_time;
#ifndef __BEOS__
struct itimerval timeval;
if (set_alarm(time_interval, B_ONE_SHOT_RELATIVE_ALARM) < 0)
return false;
#endif
-
+#endif
return true;
}
bool
disable_sig_alarm(bool is_statement_timeout)
{
+#ifdef WIN32
+#warning add Win32 timer
+#else
/*
* Always disable the interrupt if it is active; this avoids being
* interrupted by the signal handler and thereby possibly getting
if (!CheckStatementTimeout())
return false;
}
-
+#endif
return true;
}
else
{
/* Not time yet, so (re)schedule the interrupt */
+#ifdef WIN32
+#warning add win32 timer
+#else
#ifndef __BEOS__
struct itimerval timeval;
if (set_alarm(time_interval, B_ONE_SHOT_RELATIVE_ALARM) < 0)
return false;
#endif
+#endif
}
return true;
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/init/Attic/findbe.c,v 1.32 2003/04/04 20:42:12 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/init/Attic/findbe.c,v 1.33 2003/05/15 16:35:29 momjian Exp $
*
*-------------------------------------------------------------------------
*/
ValidateBinary(char *path)
{
struct stat buf;
+#ifndef WIN32
uid_t euid;
struct group *gp;
struct passwd *pwp;
+#endif
int i;
int is_r = 0;
int is_x = 0;
* Ensure that the file is both executable and readable (required for
* dynamic loading).
*/
+#ifdef WIN32
+ is_r = buf.st_mode & S_IRUSR;
+ is_x = buf.st_mode & S_IXUSR;
+ return is_x ? (is_r ? 0 : -2) : -1;
+#else
euid = geteuid();
if (euid == buf.st_uid)
{
elog(DEBUG2, "ValidateBinary: \"%s\" is not other read/execute",
path);
return is_x ? (is_r ? 0 : -2) : -1;
+#endif
}
/*
* Encoding names and routines for work with it. All
* in this file is shared bedween FE and BE.
*
- * $Id: encnames.c,v 1.12 2003/03/10 22:28:18 tgl Exp $
+ * $Id: encnames.c,v 1.13 2003/05/15 16:35:29 momjian Exp $
*/
#ifdef FRONTEND
#include "postgres_fe.h"
#include "utils/builtins.h"
#endif
-#ifdef WIN32
-#include "win32.h"
-#else
#include <unistd.h>
-#endif
#include "mb/pg_wchar.h"
#include <ctype.h>
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: c.h,v 1.144 2003/05/09 16:59:43 momjian Exp $
+ * $Id: c.h,v 1.145 2003/05/15 16:35:29 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#include "pg_config.h"
#include "pg_config_manual.h" /* must be after pg_config.h */
-#include "pg_config_os.h"
#include "postgres_ext.h"
#include <stdio.h>
#include <sys/types.h>
#include <errno.h>
-#include <sys/fcntl.h> /* ensure O_BINARY is available */
+#include <fcntl.h> /* ensure O_BINARY is available */
#ifdef HAVE_SUPPORTDEFS_H
#include <SupportDefs.h>
#endif
+/* Must be here so we can redefine some functions on Win32 */
+#include "pg_config_os.h"
+
/* Must be before gettext() games below */
#include <locale.h>
#define PG_BINARY_W "w"
#endif
-#if defined(sun) && defined(__sparc__) && !defined(__SVR4)
-#include <unistd.h>
+#if !defined(WIN32) && !defined(__BEOS__)
+#define FCNTL_NONBLOCK(sock) fcntl(sock, F_SETFL, O_NONBLOCK)
+#else
+extern long ioctlsocket_ret;
+/* Returns non-0 on failure, while fcntl() returns -1 on failure */
+#ifdef WIN32
+#define FCNTL_NONBLOCK(sock) ((ioctlsocket(sock, FIONBIO, &ioctlsocket_ret) == 0) ? 0 : -1)
#endif
-
-/* Portable path handling for Unix/Win32 */
-bool is_absolute_path(const char *filename);
-char *first_path_separator(const char *filename);
-char *last_path_separator(const char *filename);
-char *get_progname(char *argv0);
-
-#if defined(bsdi) || defined(netbsd)
-int fseeko(FILE *stream, off_t offset, int whence);
-off_t ftello(FILE *stream);
+#ifdef __BEOS__
+#define FCNTL_NONBLOCK(sock) ((ioctl(sock, FIONBIO, &ioctlsocket_ret) == 0) ? 0 : -1)
#endif
-
-/*
- * Win32 doesn't have reliable rename/unlink during concurrent access
- */
-#if defined(WIN32) && !defined(FRONTEND)
-int pgrename(const char *from, const char *to);
-int pgunlink(const char *path);
-#define rename(path) pgrename(path)
-#define unlink(from, to) pgunlink(from, to)
#endif
-/*
- * Win32 doesn't have opendir/readdir/closedir()
- */
-#ifdef WIN32
-struct dirent {
- ino_t d_ino; /* inode (always 1 on WIN32) */
- char d_name[MAX_PATH + 1]; /* filename (null terminated) */
-};
-
-typedef struct {
- HANDLE handle; /* handle for FindFirstFile or
- * FindNextFile */
- long offset; /* offset into directory */
- int finished; /* 1 if there are not more files */
- WIN32_FIND_DATA finddata; /* file data FindFirstFile or FindNextFile
- * returns */
- char *dir; /* the directory path we are reading */
- struct dirent ent; /* the dirent to return */
-} DIR;
-
-extern DIR *opendir(const char *);
-extern struct dirent *readdir(DIR *);
-extern int closedir(DIR *);
+#if defined(sun) && defined(__sparc__) && !defined(__SVR4)
+#include <unistd.h>
#endif
-/*
- * Win32 requires a special close for sockets and pipes, while on Unix
- * close() does them all.
- */
-#ifndef WIN32
-#define closesocket close
-#endif
-
/* These are for things that are one way on Unix and another on NT */
#define NULL_DEV "/dev/null"
#endif
/*
- * Default "extern" declarations or macro substitutes for library routines.
- * When necessary, these routines are provided by files in src/port/.
- */
-#ifndef HAVE_CRYPT
-char *crypt(const char *key, const char *setting);
-#endif
-
-#ifndef HAVE_FSEEKO
-#define fseeko(a, b, c) fseek((a), (b), (c))
-#define ftello(a) ftell((a))
-#endif
-
-#ifndef HAVE_ISINF
-extern int isinf(double x);
-#endif
-
-#ifndef HAVE_GETHOSTNAME
-extern int gethostname(char *name, int namelen);
-#endif
-
-#ifndef HAVE_RINT
-extern double rint(double x);
-#endif
-
-#ifndef HAVE_INET_ATON
-# include <netinet/in.h>
-# include <arpa/inet.h>
-extern int inet_aton(const char *cp, struct in_addr * addr);
-#endif
-
-/*
* When there is no sigsetjmp, its functionality is provided by plain
* setjmp. Incidentally, nothing provides setjmp's functionality in
* that case.
# define siglongjmp longjmp
#endif
-#ifndef HAVE_STRCASECMP
-extern int strcasecmp(char *s1, char *s2);
-#endif
-
-#ifndef HAVE_STRDUP
-extern char *strdup(char const *);
-#endif
-
-#ifndef HAVE_RANDOM
-extern long random(void);
-#endif
-
-#ifndef HAVE_SRANDOM
-extern void srandom(unsigned int seed);
-#endif
-
#if defined(HAVE_FDATASYNC) && !HAVE_DECL_FDATASYNC
extern int fdatasync(int fildes);
#endif
# define HAVE_STRTOULL 1
#endif
+/* /port compatibility functions */
+#include "port.h"
+
#endif /* C_H */
* for developers. If you edit any of these, be sure to do a *full*
* rebuild (and an initdb if noted).
*
- * $Id: pg_config_manual.h,v 1.2 2003/04/18 01:03:42 momjian Exp $
+ * $Id: pg_config_manual.h,v 1.3 2003/05/15 16:35:29 momjian Exp $
*------------------------------------------------------------------------
*/
* Define this if your operating system supports AF_UNIX family
* sockets.
*/
-#if !defined(__QNX__) && !defined(__BEOS__)
+#if !defined(__QNX__) && !defined(__BEOS__) && !defined(WIN32)
# define HAVE_UNIX_SOCKETS 1
#endif
--- /dev/null
+/*-------------------------------------------------------------------------
+ *
+ * port.h
+ * Header for /port compatibility functions.
+ *
+ * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1994, Regents of the University of California
+ *
+ * $Id: port.h,v 1.1 2003/05/15 16:35:29 momjian Exp $
+ *
+ *-------------------------------------------------------------------------
+ */
+
+/* Portable path handling for Unix/Win32 */
+bool is_absolute_path(const char *filename);
+char *first_path_separator(const char *filename);
+char *last_path_separator(const char *filename);
+char *get_progname(char *argv0);
+
+#if defined(bsdi) || defined(netbsd)
+int fseeko(FILE *stream, off_t offset, int whence);
+off_t ftello(FILE *stream);
+#endif
+
+/*
+ * Win32 doesn't have reliable rename/unlink during concurrent access
+ */
+#if defined(WIN32) && !defined(FRONTEND)
+int pgrename(const char *from, const char *to);
+int pgunlink(const char *path);
+#define rename(from, to) pgrename(from, to)
+#define unlink(path) pgunlink(path)
+#endif
+
+/*
+ * Win32 requires a special close for sockets and pipes, while on Unix
+ * close() does them all.
+ */
+#ifndef WIN32
+#define closesocket close
+#endif
+
+/*
+ * Default "extern" declarations or macro substitutes for library routines.
+ * When necessary, these routines are provided by files in src/port/.
+ */
+#ifndef HAVE_CRYPT
+char *crypt(const char *key, const char *setting);
+#endif
+
+#ifndef HAVE_FSEEKO
+#define fseeko(a, b, c) fseek((a), (b), (c))
+#define ftello(a) ftell((a))
+#endif
+
+#ifndef HAVE_GETOPT
+extern int getopt(int nargc, char *const *nargv, const char *ostr);
+#endif
+
+#ifndef HAVE_ISINF
+extern int isinf(double x);
+#endif
+
+#if !defined(HAVE_GETHOSTNAME) && defined(KRB4)
+extern int gethostname(char *name, int namelen);
+#endif
+
+#ifndef HAVE_RINT
+extern double rint(double x);
+#endif
+
+#ifndef HAVE_INET_ATON
+# include <netinet/in.h>
+# include <arpa/inet.h>
+extern int inet_aton(const char *cp, struct in_addr * addr);
+#endif
+
+#ifndef HAVE_STRCASECMP
+extern int strcasecmp(char *s1, char *s2);
+#endif
+
+#ifndef HAVE_STRDUP
+extern char *strdup(char const *);
+#endif
+
+#ifndef HAVE_RANDOM
+extern long random(void);
+#endif
+
+#ifndef HAVE_SRANDOM
+extern void srandom(unsigned int seed);
+#endif
+
+++ /dev/null
-/* $Header: /cvsroot/pgsql/src/include/port/Attic/win.h,v 1.15 2003/03/21 17:18:34 petere Exp $ */
-
-#define HAS_TEST_AND_SET
-
-#ifdef BUILDING_DLL
-#define DLLIMPORT __declspec (dllexport)
-#else
-#define DLLIMPORT __declspec (dllimport)
-#endif
-
-#if defined(_DLL)
-#define DLLIMPORT __declspec (dllexport)
-#else
-#define DLLIMPORT __declspec (dllimport)
-#endif
-/* $Header: /cvsroot/pgsql/src/include/port/win32.h,v 1.9 2003/04/29 18:25:54 momjian Exp $ */
+/* $Header: /cvsroot/pgsql/src/include/port/win32.h,v 1.10 2003/05/15 16:35:29 momjian Exp $ */
+
+/* undefine and redefine after #include */
+#undef mkdir
+
+#undef ERROR
+#include <windows.h>
+#undef near
+
+/* Must be here to avoid conflicting with prototype in windows.h */
+#define mkdir(a,b) mkdir(a)
+
#define USES_WINSOCK
#define NOFILE 100
/*
* IPC defines
*/
+#undef HAVE_UNION_SEMUN
+#define HAVE_UNION_SEMUN 1
+
#define IPC_RMID 256
#define IPC_CREAT 512
#define IPC_EXCL 1024
#define IPC_NOWAIT 2048
#define IPC_STAT 4096
+#define EACCESS 2048
+#define EIDRM 4096
+
+#define SETALL 8192
+#define GETNCNT 16384
+#define GETVAL 65536
+#define SETVAL 131072
+#define GETPID 262144
/*
* Shared memory
int semget(int semKey, int semNum, int flags);
int semop(int semId, struct sembuf * sops, int flag);
+#define sleep(sec) (Sleep(sec * 1000), /* no return value */ 0)
+
+/* Some extra signals */
+#define SIGHUP 1
+#define SIGQUIT 3
+#define SIGTRAP 5
+#define SIGABRT 22 /* Set to match W32 value -- not UNIX value */
+#define SIGKILL 9
+#define SIGPIPE 13
+#define SIGALRM 14
+#define SIGSTOP 17
+#define SIGCONT 19
+#define SIGCHLD 20
+#define SIGTTIN 21
+#define SIGTTOU 22 /* Same as SIGABRT -- no problem, I hope */
+#define SIGWINCH 28
+#define SIGUSR1 30
+#define SIGUSR2 31
+
+struct timezone
+{
+ int tz_minuteswest; /* Minutes west of GMT. */
+ int tz_dsttime; /* Nonzero if DST is ever in effect. */
+};
/* FROM SRA */
*/
#define snprintf _snprintf
#define vsnprintf _vsnprintf
-
-
--- /dev/null
+#include <sys/socket.h>
+
--- /dev/null
+/*
+ * Unfortunately, <wingdi.h> of VC++ also defines ERROR.
+ * To avoid the conflict, we include <windows.h> here and undefine ERROR
+ * immediately.
+ *
+ * Note: Don't include <wingdi.h> directly. It causes compile errors.
+ */
+#include <winsock2.h>
+#undef ERROR
+#undef small
+
+/* Restore old ERROR value */
+#ifdef PGERROR
+#define ERROR PGERROR
+#endif
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: rusagestub.h,v 1.10 2002/06/20 20:29:42 momjian Exp $
+ * $Id: rusagestub.h,v 1.11 2003/05/15 16:35:29 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#define RUSAGESTUB_H
#include <sys/time.h> /* for struct timeval */
+#ifndef WIN32
#include <sys/times.h> /* for struct tms */
+#endif
#include <limits.h> /* for CLK_TCK */
#define RUSAGE_SELF 0
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: elog.h,v 1.41 2003/04/24 21:16:44 tgl Exp $
+ * $Id: elog.h,v 1.42 2003/05/15 16:35:29 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#define WARNING 19 /* Warnings */
#define ERROR 20 /* user error - abort transaction; return
* to known state */
+#define ERROR 20 /* user error - abort transaction; return
+ * to known state */
+/* Save ERROR value in PGERROR so it can bve restored when Win32 includes
+ * modify it. We have to use a constant rather than ERROR because macros
+ * are expanded only when referenced outside macros.
+ */
+#ifdef WIN32
+#define PGERROR 20
+#endif
#define FATAL 21 /* fatal error - abort process */
#define PANIC 22 /* take down the other backends with me */
* exceed INITIAL_EXPBUFFER_SIZE (currently 256 bytes).
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-auth.c,v 1.76 2003/04/19 00:02:30 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-auth.c,v 1.77 2003/05/15 16:35:30 momjian Exp $
*
*-------------------------------------------------------------------------
*/
/*
* libpq uses a non-blocking socket. But kerberos needs a blocking
* socket, and we have to block somehow to do mutual authentication
- * anyway. So we temporarily make it blocking.
+ * anyway. So we temporarily make it blocking. Win32 doesn't support this.
*/
flags = fcntl(sock, F_GETFL);
- if (flags < 0 || fcntl(sock, F_SETFL, (long) (flags & ~O_NONBLOCK)))
+ if (flags < 0 || fcntl(sock, F_SETFL, flags & ~O_NONBLOCK)))
{
snprintf(PQerrormsg, PQERRORMSG_LENGTH,
libpq_gettext("could not set socket to blocking mode: %s\n"), strerror(errno));
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.240 2003/05/05 00:44:56 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.241 2003/05/15 16:35:30 momjian Exp $
*
*-------------------------------------------------------------------------
*/
static int
connectMakeNonblocking(PGconn *conn)
{
-#if defined(WIN32) || defined(__BEOS__)
- int on = 1;
-#endif
-
-#if defined(WIN32)
- if (ioctlsocket(conn->sock, FIONBIO, &on) != 0)
-#elif defined(__BEOS__)
- if (ioctl(conn->sock, FIONBIO, &on) != 0)
-#else
- if (fcntl(conn->sock, F_SETFL, O_NONBLOCK) < 0)
-#endif
+ if (FCNTL_NONBLOCK(conn->sock) < 0)
{
printfPQExpBuffer(&conn->errorMessage,
libpq_gettext("could not set socket to non-blocking mode: %s\n"),
-# $Header: /cvsroot/pgsql/src/makefiles/Attic/Makefile.win,v 1.19 2003/03/21 17:18:34 petere Exp $
+# $Header: /cvsroot/pgsql/src/makefiles/Makefile.win32,v 1.1 2003/05/15 16:35:30 momjian Exp $
+
+# Use replacement include files for those missing on Win32
+override CPPFLAGS+="-I$(top_srcdir)/src/include/port/win32_include"
+
DLLTOOL= dlltool
DLLWRAP= dllwrap
BE_DLLLIBS= -L$(top_builddir)/src/backend -lpostgres
#ifndef TEST_VERSION
+#include "postgres.h"
+
#undef rename
#undef unlink
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
*/
+#include "postgres.h"
+
+
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)getopt.c 8.3 (Berkeley) 4/27/95";
#endif /* LIBC_SCCS and not lint */
++optind;
if (opterr && *ostr != ':')
(void) fprintf(stderr,
- "%s: illegal option -- %c\n", argv[0], optopt);
+ "illegal option -- %c\n", optopt);
return BADCH;
}
if (*++oli != ':')
return BADARG;
if (opterr)
(void) fprintf(stderr,
- "%s: option requires an argument -- %c\n",
- argv[0], optopt);
+ "option requires an argument -- %c\n",
+ optopt);
return BADCH;
}
else
-/* $Id: getrusage.c,v 1.1 2002/07/18 04:13:59 momjian Exp $ */
+/* $Id: getrusage.c,v 1.2 2003/05/15 16:35:30 momjian Exp $ */
#include <stdio.h>
#include <errno.h>
+
+#include "postgres.h"
#include "rusagestub.h"
/* This code works on:
int
getrusage(int who, struct rusage * rusage)
{
+#ifdef WIN32
+ if (rusage)
+ memset(rusage, 0, sizeof(rusage));
+#else
struct tms tms;
int tick_rate = CLK_TCK; /* ticks per second */
clock_t u,
rusage->ru_utime.tv_usec = TICK_TO_USEC(u, tick_rate);
rusage->ru_stime.tv_sec = TICK_TO_SEC(s, tick_rate);
rusage->ru_stime.tv_usec = TICK_TO_USEC(u, tick_rate);
+#endif
return 0;
}
+++ /dev/null
-/*
- * $Header: /cvsroot/pgsql/src/port/Attic/opendir.c,v 1.1 2003/05/09 01:16:29 momjian Exp $
- *
- * Copyright (c) 2003 SRA, Inc.
- * Copyright (c) 2003 SKC, Inc.
- *
- * Permission to use, copy, modify, and distribute this software and
- * its documentation for any purpose, without fee, and without a
- * written agreement is hereby granted, provided that the above
- * copyright notice and this paragraph and the following two
- * paragraphs appear in all copies.
- *
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE TO ANY PARTY FOR DIRECT,
- * INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING
- * LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS
- * DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED
- * OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * THE AUTHOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS
- * IS" BASIS, AND THE AUTHOR HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE,
- * SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
- */
-
-#include "postgres.h"
-
-#include <stddef.h>
-#include <sys/types.h>
-#include <windows.h>
-
-#include "dirent.h"
-
-DIR *
-opendir(const char *dir)
-{
- DIR *dp;
- char *findspec;
- HANDLE handle;
- size_t dirlen;
-
- dirlen = strlen(dir);
- findspec = palloc(dirlen + 2 + 1);
- if (findspec == NULL)
- return NULL;
-
- if (dirlen == 0)
- strcpy(findspec, "*");
- else if (isalpha(dir[0]) && dir[1] == ':' && dir[2] == '\0')
- sprintf(findspec, "%s*", dir);
- else if (dir[dirlen - 1] == '/' || dir[dirlen - 1] == '\\')
- sprintf(findspec, "%s*", dir);
- else
- sprintf(findspec, "%s\\*", dir);
-
- dp = (DIR *)palloc(sizeof(DIR));
- if (dp == NULL)
- {
- pfree(findspec);
- errno = ENOMEM;
- return NULL;
- }
-
- dp->offset = 0;
- dp->finished = 0;
- dp->dir = pstrdup(dir);
- if (dp->dir == NULL)
- {
- pfree(dp);
- pfree(findspec);
- errno = ENOMEM;
- return NULL;
- }
-
- handle = FindFirstFile(findspec, &(dp->finddata));
- if (handle == INVALID_HANDLE_VALUE)
- {
- pfree(dp->dir);
- pfree(dp);
- pfree(findspec);
- errno = ENOENT;
- return NULL;
- }
- dp->handle = handle;
-
- pfree(findspec);
- return dp;
-}
-
-
-struct dirent *
-readdir(DIR *dp)
-{
- if (dp == NULL || dp->finished)
- return NULL;
-
- if (dp->offset != 0)
- {
- if (FindNextFile(dp->handle, &(dp->finddata)) == 0)
- {
- dp->finished = 1;
- return NULL;
- }
- }
- dp->offset++;
-
- strncpy(dp->ent.d_name, dp->finddata.cFileName, MAX_PATH);
- dp->ent.d_ino = 1;
-
- return &(dp->ent);
-}
-
-
-int
-closedir(DIR *dp)
-{
- FindClose(dp->handle);
- pfree(dp->dir);
- pfree(dp);
-
- return 0;
-}
--- /dev/null
+if test "$GCC" = yes; then
+ CFLAGS="-O2"
+fi