mirror of
https://github.com/postgres/postgres.git
synced 2025-09-02 04:21:28 +03:00
pgindent run.
This commit is contained in:
@@ -6,13 +6,14 @@
|
||||
|
||||
#include "postgres.h"
|
||||
|
||||
#undef mkdir /* no reason to use that macro because we ignore the 2nd arg */
|
||||
#undef mkdir /* no reason to use that macro because we
|
||||
* ignore the 2nd arg */
|
||||
|
||||
#include <dirent.h>
|
||||
|
||||
|
||||
int
|
||||
copydir(char *fromdir,char *todir)
|
||||
copydir(char *fromdir, char *todir)
|
||||
{
|
||||
DIR *xldir;
|
||||
struct dirent *xlde;
|
||||
@@ -37,19 +38,19 @@ copydir(char *fromdir,char *todir)
|
||||
|
||||
while ((xlde = readdir(xldir)) != NULL)
|
||||
{
|
||||
snprintf(fromfl, MAXPGPATH, "%s/%s", fromdir, xlde->d_name);
|
||||
snprintf(tofl, MAXPGPATH, "%s/%s", todir, xlde->d_name);
|
||||
if (CopyFile(fromfl,tofl,TRUE) < 0)
|
||||
{
|
||||
int save_errno = errno;
|
||||
snprintf(fromfl, MAXPGPATH, "%s/%s", fromdir, xlde->d_name);
|
||||
snprintf(tofl, MAXPGPATH, "%s/%s", todir, xlde->d_name);
|
||||
if (CopyFile(fromfl, tofl, TRUE) < 0)
|
||||
{
|
||||
int save_errno = errno;
|
||||
|
||||
closedir(xldir);
|
||||
errno = save_errno;
|
||||
ereport(ERROR,
|
||||
(errcode_for_file_access(),
|
||||
errmsg("could not copy file \"%s\": %m", fromfl)));
|
||||
return 1;
|
||||
}
|
||||
closedir(xldir);
|
||||
errno = save_errno;
|
||||
ereport(ERROR,
|
||||
(errcode_for_file_access(),
|
||||
errmsg("could not copy file \"%s\": %m", fromfl)));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
closedir(xldir);
|
||||
|
853
src/port/crypt.c
853
src/port/crypt.c
File diff suppressed because it is too large
Load Diff
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* These are replacement versions of unlink and rename that work on
|
||||
* Win32 (NT, Win2k, XP). replace() doesn't work on Win95/98/Me.
|
||||
* Win32 (NT, Win2k, XP). replace() doesn't work on Win95/98/Me.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef TEST_VERSION
|
||||
|
||||
#include "postgres.h"
|
||||
@@ -13,14 +13,14 @@
|
||||
int
|
||||
pgrename(const char *from, const char *to)
|
||||
{
|
||||
int loops = 0;
|
||||
int loops = 0;
|
||||
|
||||
while (!MoveFileEx(from, to, MOVEFILE_REPLACE_EXISTING))
|
||||
{
|
||||
if (GetLastError() != ERROR_ACCESS_DENIED)
|
||||
/* set errno? */
|
||||
return -1;
|
||||
Sleep(100); /* ms */
|
||||
Sleep(100); /* ms */
|
||||
if (loops == 10)
|
||||
#ifndef FRONTEND
|
||||
elog(LOG, "could not rename \"%s\" to \"%s\", continuing to try",
|
||||
@@ -45,14 +45,14 @@ pgrename(const char *from, const char *to)
|
||||
int
|
||||
pgunlink(const char *path)
|
||||
{
|
||||
int loops = 0;
|
||||
int loops = 0;
|
||||
|
||||
while (unlink(path))
|
||||
{
|
||||
if (errno != EACCES)
|
||||
/* set errno? */
|
||||
return -1;
|
||||
Sleep(100); /* ms */
|
||||
Sleep(100); /* ms */
|
||||
if (loops == 10)
|
||||
#ifndef FRONTEND
|
||||
elog(LOG, "could not unlink \"%s\", continuing to try",
|
||||
@@ -78,13 +78,13 @@ pgunlink(const char *path)
|
||||
|
||||
|
||||
/*
|
||||
* Illustrates problem with Win32 rename() and unlink()
|
||||
* Illustrates problem with Win32 rename() and unlink()
|
||||
* under concurrent access.
|
||||
*
|
||||
* Run with arg '1', then less than 5 seconds later, run with
|
||||
* arg '2' (rename) or '3'(unlink) to see the problem.
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
@@ -97,9 +97,9 @@ do { \
|
||||
} while (0)
|
||||
|
||||
int
|
||||
main(int argc, char* argv[])
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
FILE *fd;
|
||||
FILE *fd;
|
||||
|
||||
if (argc != 2)
|
||||
halt("Arg must be '1' (test), '2' (rename), or '3' (unlink)\n"
|
||||
@@ -143,7 +143,7 @@ main(int argc, char* argv[])
|
||||
}
|
||||
halt("unlink successful\n");
|
||||
}
|
||||
else
|
||||
else
|
||||
halt("invalid arg\n");
|
||||
|
||||
return 0;
|
||||
|
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/port/fseeko.c,v 1.10 2003/01/11 19:38:23 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/port/fseeko.c,v 1.11 2003/08/04 00:43:33 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -40,7 +40,7 @@
|
||||
int
|
||||
fseeko(FILE *stream, off_t offset, int whence)
|
||||
{
|
||||
off_t floc;
|
||||
off_t floc;
|
||||
struct stat filestat;
|
||||
|
||||
switch (whence)
|
||||
@@ -79,7 +79,7 @@ fseeko(FILE *stream, off_t offset, int whence)
|
||||
return 0;
|
||||
break;
|
||||
default:
|
||||
errno = EINVAL;
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -94,10 +94,11 @@ failure:
|
||||
off_t
|
||||
ftello(FILE *stream)
|
||||
{
|
||||
off_t floc;
|
||||
off_t floc;
|
||||
|
||||
if (fgetpos(stream, &floc) != 0)
|
||||
return -1;
|
||||
return floc;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -4,7 +4,7 @@
|
||||
* Support getaddrinfo() on platforms that don't have it.
|
||||
*
|
||||
* We also supply getnameinfo() here, assuming that the platform will have
|
||||
* it if and only if it has getaddrinfo(). If this proves false on some
|
||||
* it if and only if it has getaddrinfo(). If this proves false on some
|
||||
* platform, we'll need to split this file and provide a separate configure
|
||||
* test for getnameinfo().
|
||||
*
|
||||
@@ -12,7 +12,7 @@
|
||||
* Copyright (c) 2003, PostgreSQL Global Development Group
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/port/getaddrinfo.c,v 1.10 2003/07/23 23:30:41 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/port/getaddrinfo.c,v 1.11 2003/08/04 00:43:33 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -40,23 +40,22 @@
|
||||
*/
|
||||
int
|
||||
getaddrinfo(const char *node, const char *service,
|
||||
const struct addrinfo *hintp,
|
||||
struct addrinfo **res)
|
||||
const struct addrinfo * hintp,
|
||||
struct addrinfo ** res)
|
||||
{
|
||||
struct addrinfo *ai;
|
||||
struct sockaddr_in sin, *psin;
|
||||
struct addrinfo hints;
|
||||
struct addrinfo *ai;
|
||||
struct sockaddr_in sin,
|
||||
*psin;
|
||||
struct addrinfo hints;
|
||||
|
||||
if (hintp == NULL)
|
||||
if (hintp == NULL)
|
||||
{
|
||||
memset(&hints, 0, sizeof(hints));
|
||||
hints.ai_family = AF_INET;
|
||||
hints.ai_socktype = SOCK_STREAM;
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy(&hints, hintp, sizeof(hints));
|
||||
}
|
||||
|
||||
if (hints.ai_family != AF_INET && hints.ai_family != AF_UNSPEC)
|
||||
return EAI_FAMILY;
|
||||
@@ -78,20 +77,19 @@ getaddrinfo(const char *node, const char *service,
|
||||
else if (hints.ai_flags & AI_NUMERICHOST)
|
||||
{
|
||||
if (!inet_aton(node, &sin.sin_addr))
|
||||
{
|
||||
return EAI_FAIL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
struct hostent *hp;
|
||||
|
||||
#ifdef FRONTEND
|
||||
struct hostent hpstr;
|
||||
char buf[BUFSIZ];
|
||||
int herrno = 0;
|
||||
char buf[BUFSIZ];
|
||||
int herrno = 0;
|
||||
|
||||
pqGethostbyname(node, &hpstr, buf, sizeof(buf),
|
||||
&hp, &herrno);
|
||||
&hp, &herrno);
|
||||
#else
|
||||
hp = gethostbyname(node);
|
||||
#endif
|
||||
@@ -132,9 +130,7 @@ getaddrinfo(const char *node, const char *service,
|
||||
|
||||
ai = malloc(sizeof(*ai));
|
||||
if (!ai)
|
||||
{
|
||||
return EAI_MEMORY;
|
||||
}
|
||||
|
||||
psin = malloc(sizeof(*psin));
|
||||
if (!psin)
|
||||
@@ -161,7 +157,7 @@ getaddrinfo(const char *node, const char *service,
|
||||
|
||||
|
||||
void
|
||||
freeaddrinfo(struct addrinfo *res)
|
||||
freeaddrinfo(struct addrinfo * res)
|
||||
{
|
||||
if (res)
|
||||
{
|
||||
@@ -176,7 +172,7 @@ const char *
|
||||
gai_strerror(int errcode)
|
||||
{
|
||||
#ifdef HAVE_HSTRERROR
|
||||
int hcode;
|
||||
int hcode;
|
||||
|
||||
switch (errcode)
|
||||
{
|
||||
@@ -194,7 +190,7 @@ gai_strerror(int errcode)
|
||||
|
||||
return hstrerror(hcode);
|
||||
|
||||
#else /* !HAVE_HSTRERROR */
|
||||
#else /* !HAVE_HSTRERROR */
|
||||
|
||||
switch (errcode)
|
||||
{
|
||||
@@ -206,71 +202,61 @@ gai_strerror(int errcode)
|
||||
default:
|
||||
return "Unknown server error";
|
||||
}
|
||||
|
||||
#endif /* HAVE_HSTRERROR */
|
||||
#endif /* HAVE_HSTRERROR */
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert an ipv4 address to a hostname.
|
||||
*
|
||||
*
|
||||
* Bugs: - Only supports NI_NUMERICHOST and NI_NUMERICSERV
|
||||
* It will never resolv a hostname.
|
||||
* - No IPv6 support.
|
||||
*/
|
||||
int
|
||||
getnameinfo(const struct sockaddr *sa, int salen,
|
||||
getnameinfo(const struct sockaddr * sa, int salen,
|
||||
char *node, int nodelen,
|
||||
char *service, int servicelen, int flags)
|
||||
{
|
||||
/* Invalid arguments. */
|
||||
if (sa == NULL || (node == NULL && service == NULL))
|
||||
{
|
||||
return EAI_FAIL;
|
||||
}
|
||||
|
||||
/* We don't support those. */
|
||||
if ((node && !(flags & NI_NUMERICHOST))
|
||||
|| (service && !(flags & NI_NUMERICSERV)))
|
||||
{
|
||||
return EAI_FAIL;
|
||||
}
|
||||
|
||||
#ifdef HAVE_IPV6
|
||||
if (sa->sa_family == AF_INET6)
|
||||
{
|
||||
return EAI_FAMILY;
|
||||
}
|
||||
return EAI_FAMILY;
|
||||
#endif
|
||||
|
||||
if (node)
|
||||
{
|
||||
int ret = -1;
|
||||
int ret = -1;
|
||||
|
||||
if (sa->sa_family == AF_INET)
|
||||
{
|
||||
char *p;
|
||||
p = inet_ntoa(((struct sockaddr_in *)sa)->sin_addr);
|
||||
char *p;
|
||||
|
||||
p = inet_ntoa(((struct sockaddr_in *) sa)->sin_addr);
|
||||
ret = snprintf(node, nodelen, "%s", p);
|
||||
}
|
||||
if (ret == -1 || ret > nodelen)
|
||||
{
|
||||
return EAI_MEMORY;
|
||||
}
|
||||
}
|
||||
|
||||
if (service)
|
||||
{
|
||||
int ret = -1;
|
||||
int ret = -1;
|
||||
|
||||
if (sa->sa_family == AF_INET)
|
||||
{
|
||||
ret = snprintf(service, servicelen, "%d",
|
||||
ntohs(((struct sockaddr_in *)sa)->sin_port));
|
||||
ntohs(((struct sockaddr_in *) sa)->sin_port));
|
||||
}
|
||||
if (ret == -1 || ret > servicelen)
|
||||
{
|
||||
return EAI_MEMORY;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@@ -94,7 +94,7 @@ const char *ostr;
|
||||
++optind;
|
||||
if (opterr && *ostr != ':')
|
||||
(void) fprintf(stderr,
|
||||
"illegal option -- %c\n", optopt);
|
||||
"illegal option -- %c\n", optopt);
|
||||
return BADCH;
|
||||
}
|
||||
if (*++oli != ':')
|
||||
|
@@ -35,7 +35,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Header: /cvsroot/pgsql/src/port/getopt_long.c,v 1.1 2003/01/06 18:53:25 petere Exp $
|
||||
* $Header: /cvsroot/pgsql/src/port/getopt_long.c,v 1.2 2003/08/04 00:43:33 momjian Exp $
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
@@ -49,9 +49,9 @@
|
||||
#define EMSG ""
|
||||
|
||||
int
|
||||
getopt_long(int argc, char * const argv[],
|
||||
getopt_long(int argc, char *const argv[],
|
||||
const char *optstring,
|
||||
const struct option *longopts, int *longindex)
|
||||
const struct option * longopts, int *longindex)
|
||||
{
|
||||
static char *place = EMSG; /* option letter processing */
|
||||
char *oli; /* option letter list index */
|
||||
@@ -86,8 +86,8 @@ getopt_long(int argc, char * const argv[],
|
||||
if (place[0] && place[0] == '-' && place[1])
|
||||
{
|
||||
/* long option */
|
||||
size_t namelen;
|
||||
int i;
|
||||
size_t namelen;
|
||||
int i;
|
||||
|
||||
place++;
|
||||
|
||||
@@ -101,7 +101,7 @@ getopt_long(int argc, char * const argv[],
|
||||
{
|
||||
if (place[namelen] == '=')
|
||||
optarg = place + namelen + 1;
|
||||
else if (optind < argc-1)
|
||||
else if (optind < argc - 1)
|
||||
{
|
||||
optind++;
|
||||
optarg = argv[optind];
|
||||
@@ -112,7 +112,7 @@ getopt_long(int argc, char * const argv[],
|
||||
return BADARG;
|
||||
if (opterr)
|
||||
fprintf(stderr,
|
||||
"%s: option requires an argument -- %s\n",
|
||||
"%s: option requires an argument -- %s\n",
|
||||
argv[0], place);
|
||||
place = EMSG;
|
||||
optind++;
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Header: /cvsroot/pgsql/src/port/gettimeofday.c,v 1.1 2003/05/16 04:59:24 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/port/gettimeofday.c,v 1.2 2003/08/04 00:43:33 momjian Exp $
|
||||
*
|
||||
* Copyright (c) 2003 SRA, Inc.
|
||||
* Copyright (c) 2003 SKC, Inc.
|
||||
@@ -34,20 +34,19 @@ static const unsigned __int64 epoch = 116444736000000000L;
|
||||
* timezone information is stored outside the kernel so tzp isn't used anymore.
|
||||
*/
|
||||
int
|
||||
gettimeofday(struct timeval *tp, struct timezone *tzp)
|
||||
gettimeofday(struct timeval * tp, struct timezone * tzp)
|
||||
{
|
||||
FILETIME file_time;
|
||||
SYSTEMTIME system_time;
|
||||
ULARGE_INTEGER ularge;
|
||||
FILETIME file_time;
|
||||
SYSTEMTIME system_time;
|
||||
ULARGE_INTEGER ularge;
|
||||
|
||||
GetSystemTime(&system_time);
|
||||
SystemTimeToFileTime(&system_time, &file_time);
|
||||
ularge.LowPart = file_time.dwLowDateTime;
|
||||
ularge.HighPart = file_time.dwHighDateTime;
|
||||
|
||||
tp->tv_sec = (long)((ularge.QuadPart - epoch) / 10000000L);
|
||||
tp->tv_usec = (long)(system_time.wMilliseconds * 1000);
|
||||
tp->tv_sec = (long) ((ularge.QuadPart - epoch) / 10000000L);
|
||||
tp->tv_usec = (long) (system_time.wMilliseconds * 1000);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/* $Id: path.c,v 1.1 2003/04/04 20:42:13 momjian Exp $ */
|
||||
/* $Id: path.c,v 1.2 2003/08/04 00:43:33 momjian Exp $ */
|
||||
|
||||
#include "c.h"
|
||||
#include <ctype.h>
|
||||
@@ -6,28 +6,32 @@
|
||||
/*
|
||||
* is_absolute_path
|
||||
*/
|
||||
bool is_absolute_path(const char *filename)
|
||||
bool
|
||||
is_absolute_path(const char *filename)
|
||||
{
|
||||
return filename[0] == '/'
|
||||
#ifdef WIN32 /* WIN32 paths can either have forward or backward slashes */
|
||||
#ifdef WIN32 /* WIN32 paths can either have forward or
|
||||
* backward slashes */
|
||||
|| filename[0] == '\\'
|
||||
|| (isalpha(filename[0]) && filename[1] == ':'
|
||||
&& (filename[2] == '\\' || filename[2] == '/'))
|
||||
&& (filename[2] == '\\' || filename[2] == '/'))
|
||||
#endif
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* first_path_separator
|
||||
*/
|
||||
char *first_path_separator(const char *filename)
|
||||
char *
|
||||
first_path_separator(const char *filename)
|
||||
{
|
||||
#ifndef WIN32
|
||||
return strchr(filename, '/');
|
||||
#else
|
||||
char *slash, *bslash;
|
||||
char *slash,
|
||||
*bslash;
|
||||
|
||||
/* How should we handle "C:file.c"? */
|
||||
slash = strchr(filename, '/');
|
||||
@@ -45,12 +49,14 @@ char *first_path_separator(const char *filename)
|
||||
/*
|
||||
* last_path_separator
|
||||
*/
|
||||
char *last_path_separator(const char *filename)
|
||||
char *
|
||||
last_path_separator(const char *filename)
|
||||
{
|
||||
#ifndef WIN32
|
||||
return strrchr(filename, '/');
|
||||
#else
|
||||
char *slash, *bslash;
|
||||
char *slash,
|
||||
*bslash;
|
||||
|
||||
/* How should we handle "C:file.c"? */
|
||||
slash = strrchr(filename, '/');
|
||||
|
@@ -7,7 +7,7 @@
|
||||
*
|
||||
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
|
||||
*
|
||||
* $Id: threads.c,v 1.1 2003/06/14 14:35:42 momjian Exp $
|
||||
* $Id: threads.c,v 1.2 2003/08/04 00:43:33 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -41,6 +41,7 @@ pqGetpwuid(uid_t uid, struct passwd * resultbuf, char *buffer,
|
||||
size_t buflen, struct passwd ** result)
|
||||
{
|
||||
#if defined(USE_THREADS) && defined(HAVE_GETPWUID_R)
|
||||
|
||||
/*
|
||||
* broken (well early POSIX draft) getpwuid_r() which returns 'struct
|
||||
* passwd *'
|
||||
@@ -65,6 +66,7 @@ pqGethostbyname(const char *name,
|
||||
int *herrno)
|
||||
{
|
||||
#if defined(USE_THREADS) && defined(HAVE_GETHOSTBYNAME_R)
|
||||
|
||||
/*
|
||||
* broken (well early POSIX draft) gethostbyname_r() which returns
|
||||
* 'struct hostent *'
|
||||
|
Reference in New Issue
Block a user