mirror of https://github.com/postgres/postgres
Win32 port is now called 'win32' rather than 'win'
add -lwsock32 on Win32
make gethostname() be only used when kerberos4 is enabled
use /port/getopt.c
new /port/opendir.c routines
disable GUC unix_socket_group on Win32
convert some keywords.c symbols to KEYWORD_P to prevent conflict
create new FCNTL_NONBLOCK macro to turn off socket blocking
create new /include/port.h file that has /port prototypes, move
out of c.h
new /include/port/win32_include dir to hold missing include files
work around ERROR being defined in Win32 includes
WIN32_DEV
parent
2c0556068f
commit
12c9423832
@ -1,4 +1,4 @@ |
||||
/* $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> |
||||
|
||||
@ -0,0 +1,93 @@ |
||||
/*-------------------------------------------------------------------------
|
||||
* |
||||
* 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 |
||||
|
||||
@ -1,15 +0,0 @@ |
||||
/* $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 |
||||
@ -0,0 +1,2 @@ |
||||
#include <sys/socket.h> |
||||
|
||||
@ -0,0 +1,15 @@ |
||||
/*
|
||||
* 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 |
||||
@ -1,4 +1,8 @@ |
||||
# $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
|
||||
@ -1,122 +0,0 @@ |
||||
/*
|
||||
* $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; |
||||
} |
||||
@ -0,0 +1,3 @@ |
||||
if test "$GCC" = yes; then |
||||
CFLAGS="-O2" |
||||
fi |
||||
Loading…
Reference in new issue