* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/libpq/md5.c,v 1.18 2002/09/04 20:31:19 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/libpq/md5.c,v 1.19 2002/10/03 17:09:41 momjian Exp $
*/
* can be compiled stand-alone.
*/
-#ifndef MD5_ODBC
+#if ! defined(MD5_ODBC) && ! defined(FRONTEND)
#include "postgres.h"
#include "libpq/crypt.h"
-#else
+#endif
+
+#ifdef FRONTEND
+#include "postgres_fe.h"
+#ifndef WIN32
+#include "libpq/crypt.h"
+#endif /* WIN32 */
+#endif /* FRONTEND */
+
+#ifdef MD5_ODBC
#include "md5.h"
#endif
*
* Copyright 2000-2002 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/command.c,v 1.81 2002/09/22 20:57:21 petere Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/command.c,v 1.82 2002/10/03 17:09:41 momjian Exp $
*/
#include "postgres_fe.h"
#include "command.h"
#include
#include
#include
+#include
#endif
#include "libpq-fe.h"
return NULL;
}
- if (i < token_len - 1)
+ if (i < (int) token_len - 1)
return_val[i + 1] = '\0';
}
exit(EXIT_FAILURE);
}
- for (p = source; p - source < len && *p; p += PQmblen(p, pset.encoding))
+ for (p = source; p - source < (int) len && *p; p += PQmblen(p, pset.encoding))
{
if (esc)
{
char *end;
l = strtol(p, &end, 0);
- c = l;
+ c = (char) l;
p = end - 1;
break;
}
*
* Copyright 2000 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/common.c,v 1.45 2002/09/14 19:46:01 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/common.c,v 1.46 2002/10/03 17:09:41 momjian Exp $
*/
#include "postgres_fe.h"
#include
#include
-#include
#ifndef HAVE_STRDUP
#include
#endif
#include
#ifndef WIN32
+#include
#include /* for write() */
#include
#else
#include /* for _write() */
#include
+#include /* for _ftime() */
#endif
#include "libpq-fe.h"
bool success = false;
PGresult *results;
PGnotify *notify;
+#ifndef WIN32
struct timeval before,
after;
- struct timezone tz;
+#else
+ struct _timeb before,
+ after;
+#endif
if (!pset.db)
{
}
cancelConn = pset.db;
+
+#ifndef WIN32
+ if (pset.timing)
+ gettimeofday(&before, NULL);
+ results = PQexec(pset.db, query);
+ if (pset.timing)
+ gettimeofday(&after, NULL);
+#else
if (pset.timing)
- gettimeofday(&before, &tz);
+ _ftime(&before);
results = PQexec(pset.db, query);
if (pset.timing)
- gettimeofday(&after, &tz);
+ _ftime(&after);
+#endif
+
if (PQresultStatus(results) == PGRES_COPY_IN)
copy_in_state = true;
/* keep cancel connection for copy out state */
/* Possible microtiming output */
if (pset.timing && success)
+#ifndef WIN32
printf(gettext("Time: %.2f ms\n"),
((after.tv_sec - before.tv_sec) * 1000000.0 + after.tv_usec - before.tv_usec) / 1000.0);
+#else
+ printf(gettext("Time: %.2f ms\n"),
+ ((after.time - before.time) * 1000.0 + after.millitm - before.millitm));
+#endif
return success;
}
*
* Copyright 2000 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/copy.c,v 1.25 2002/09/22 20:57:21 petere Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/copy.c,v 1.26 2002/10/03 17:09:41 momjian Exp $
*/
#include "postgres_fe.h"
#include "copy.h"
#ifdef WIN32
#define strcasecmp(x,y) stricmp(x,y)
+#define __S_ISTYPE(mode, mask) (((mode) & S_IFMT) == (mask))
+#define S_ISDIR(mode) __S_ISTYPE((mode), S_IFDIR)
#endif
bool copy_in_state;
*
* Copyright 2000-2002 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/large_obj.c,v 1.21 2002/09/04 20:31:36 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/large_obj.c,v 1.22 2002/10/03 17:09:41 momjian Exp $
*/
#include "postgres_fe.h"
#include "large_obj.h"
{
char *cmdbuf;
char *bufptr;
- int slen = strlen(comment_arg);
+ size_t slen = strlen(comment_arg);
cmdbuf = malloc(slen * 2 + 256);
if (!cmdbuf)
*
* Copyright 2000 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/mbprint.c,v 1.4 2002/08/27 20:16:48 petere Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/mbprint.c,v 1.5 2002/10/03 17:09:42 momjian Exp $
*/
#include "postgres_fe.h"
for (; *pwcs && len > 0; pwcs += l)
{
l = pg_utf_mblen(pwcs);
- if ((len < l) || ((w = ucs_wcwidth(utf2ucs(pwcs))) < 0))
+ if ((len < (size_t) l) || ((w = ucs_wcwidth(utf2ucs(pwcs))) < 0))
return width;
len -= l;
width += w;
*
* Copyright 2000 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/print.c,v 1.31 2002/09/01 23:30:46 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/print.c,v 1.32 2002/10/03 17:09:42 momjian Exp $
*/
#include "postgres_fe.h"
#include "print.h"
{
int tlen;
- if ((tlen = pg_wcswidth((unsigned char *) title, strlen(title))) >= total_w)
+ if ((unsigned int) (tlen = pg_wcswidth((unsigned char *) title, strlen(title))) >= total_w)
fprintf(fout, "%s\n", title);
else
fprintf(fout, "%-*s%s\n", (int) (total_w - tlen) / 2, "", title);
footers ? (const char *const *) footers : (const char *const *) (opt->footers),
align, &opt->topt, fout);
- free(headers);
- free(cells);
+ free((void *) headers);
+ free((void *) cells);
if (footers)
{
free(footers[0]);
#define MAXPGPATH 1024
+#define INDEX_MAX_KEYS 32
+
#define HAVE_ATEXIT
#define HAVE_MEMMOVE
#endif
+#ifndef __CYGWIN__
+#include
+#endif
+
#endif /* pg_config_h_win32__ */
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.205 2002/09/22 20:57:21 petere Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.206 2002/10/03 17:09:42 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#include
#include
#include
-#include
#include "libpq-fe.h"
#include "libpq-int.h"
{
PostgresPollingStatusType flag = PGRES_POLLING_WRITING;
- struct timeval remains,
- *rp = NULL,
- finish_time,
- start_time;
+ time_t finish_time = 0,
+ current_time;
+ struct timeval remains,
+ *rp = NULL;
if (conn == NULL || conn->status == CONNECTION_BAD)
return 0;
}
remains.tv_usec = 0;
rp = &remains;
+
+ /* calculate the finish time based on start + timeout */
+ finish_time = time((time_t *) NULL) + remains.tv_sec;
}
while (rp == NULL || remains.tv_sec > 0 || remains.tv_usec > 0)
{
- /*
- * If connecting timeout is set, get current time.
- */
- if (rp != NULL && gettimeofday(&start_time, NULL) == -1)
- {
- conn->status = CONNECTION_BAD;
- return 0;
- }
-
/*
* Wait, if necessary. Note that the initial state (just after
* PQconnectStart) is to wait for the socket to select for
flag = PQconnectPoll(conn);
/*
- * If connecting timeout is set, calculate remain time.
+ * If connecting timeout is set, calculate remaining time.
*/
if (rp != NULL)
{
- if (gettimeofday(&finish_time, NULL) == -1)
+ if (time(¤t_time) == -1)
{
conn->status = CONNECTION_BAD;
return 0;
}
- if ((finish_time.tv_usec -= start_time.tv_usec) < 0)
- {
- remains.tv_sec++;
- finish_time.tv_usec += 1000000;
- }
- if ((remains.tv_usec -= finish_time.tv_usec) < 0)
- {
- remains.tv_sec--;
- remains.tv_usec += 1000000;
- }
- remains.tv_sec -= finish_time.tv_sec - start_time.tv_sec;
+
+ remains.tv_sec = finish_time - current_time;
+ remains.tv_usec = 0;
}
}
conn->status = CONNECTION_BAD;
return NULL;
}
+#ifndef WIN32
/* If password file is insecure, alert the user and ignore it. */
if (stat_buf.st_mode & (S_IRWXG | S_IRWXO))
{
free(pgpassfile);
return NULL;
}
+#endif
fp = fopen(pgpassfile, "r");
free(pgpassfile);
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-misc.c,v 1.79 2002/09/04 20:31:47 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-misc.c,v 1.80 2002/10/03 17:09:42 momjian Exp $
*
*-------------------------------------------------------------------------
*/
* try to grow the buffer. FIXME: The new size could be
* chosen more intelligently.
*/
- size_t buflen = conn->outCount + nbytes;
+ size_t buflen = (size_t) conn->outCount + nbytes;
- if (buflen > conn->outBufSize)
+ if (buflen > (size_t) conn->outBufSize)
{
char *newbuf = realloc(conn->outBuffer, buflen);
int
pqGetnchar(char *s, size_t len, PGconn *conn)
{
- if (len < 0 || len > conn->inEnd - conn->inCursor)
+ if (len < 0 || len > (size_t) (conn->inEnd - conn->inCursor))
return EOF;
memcpy(s, conn->inBuffer + conn->inCursor, len);
* didn't really belong there.
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-print.c,v 1.46 2002/08/29 07:22:30 ishii Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-print.c,v 1.47 2002/10/03 17:09:42 momjian Exp $
*
*-------------------------------------------------------------------------
*/
(PQntuples(res) == 1) ? "" : "s");
free(fieldMax);
free(fieldNotNum);
- free(fieldNames);
+ free((void *) fieldNames);
if (usePipe)
{
#ifdef WIN32
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: libpq-int.h,v 1.57 2002/09/04 20:31:47 momjian Exp $
+ * $Id: libpq-int.h,v 1.58 2002/10/03 17:09:42 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#define LIBPQ_INT_H
#include
-#include
#include
+#ifndef WIN32
+#include
+#endif
#if defined(WIN32) && (!defined(ssize_t))
typedef int ssize_t; /* ssize_t doesn't exist in VC (atleast
LIBRARY LIBPQ
-DESCRIPTION "Postgres Client Access Library"
EXPORTS
PQconnectdb @ 1
PQsetdbLogin @ 2
PQfreeNotify @ 87
PQescapeString @ 88
PQescapeBytea @ 89
+ printfPQExpBuffer @ 90
+ appendPQExpBuffer @ 91
+ pg_encoding_to_char @ 92
+ pg_utf_mblen @ 93
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Header: /cvsroot/pgsql/src/interfaces/libpq/pqexpbuffer.c,v 1.13 2002/06/20 20:29:54 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/libpq/pqexpbuffer.c,v 1.14 2002/10/03 17:09:42 momjian Exp $
*
*-------------------------------------------------------------------------
*/
* actually stored, but at least one returns -1 on failure. Be
* conservative about believing whether the print worked.
*/
- if (nprinted >= 0 && nprinted < avail - 1)
+ if (nprinted >= 0 && nprinted < (int) avail - 1)
{
/* Success. Note nprinted does not include trailing null. */
str->len += nprinted;
* actually stored, but at least one returns -1 on failure. Be
* conservative about believing whether the print worked.
*/
- if (nprinted >= 0 && nprinted < avail - 1)
+ if (nprinted >= 0 && nprinted < (int) avail - 1)
{
/* Success. Note nprinted does not include trailing null. */
str->len += nprinted;
/*
* crypt not available (yet)
*/
-#define crypt(a,b) (a)
+#define crypt(a,b) ((char *) a)
#undef EAGAIN /* doesn't apply on sockets */
#undef EINTR
#
# Makefile for utils
#
-# $Header: /cvsroot/pgsql/src/utils/Attic/Makefile,v 1.14 2002/07/27 20:10:05 petere Exp $
+# $Header: /cvsroot/pgsql/src/utils/Attic/Makefile,v 1.15 2002/10/03 17:09:42 momjian Exp $
#
# dllinit.o is only built on Win32 platform.
#
all:
clean distclean maintainer-clean:
- rm -f dllinit.o
+ rm -f dllinit.o getopt.o