1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-28 23:42:10 +03:00

Windows portability macros SOCK_ERRNO and SOCK_STRERROR should be in

libpq-int.h, not cluttering application namespace in libpq-fe.h.
This commit is contained in:
Tom Lane
2001-11-02 20:51:27 +00:00
parent 9685afb0b2
commit c42d3b3c24
2 changed files with 259 additions and 252 deletions

View File

@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Id: libpq-fe.h,v 1.77 2001/10/28 06:26:12 momjian Exp $ * $Id: libpq-fe.h,v 1.78 2001/11/02 20:51:27 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -22,20 +22,13 @@ extern "C"
#include <stdio.h> #include <stdio.h>
#ifdef WIN32 /*
#define SOCK_ERRNO (WSAGetLastError ()) * postgres_ext.h defines the backend's externally visible types,
#define SOCK_STRERROR winsock_strerror
#else
#define SOCK_ERRNO errno
#define SOCK_STRERROR strerror
#endif
/* postgres_ext.h defines the backend's externally visible types,
* such as Oid. * such as Oid.
*/ */
#include "postgres_ext.h" #include "postgres_ext.h"
/* SSL type is needed here only to declare PQgetssl() */
#ifdef USE_SSL #ifdef USE_SSL
#include <openssl/ssl.h> #include <openssl/ssl.h>
#endif #endif
@ -250,13 +243,16 @@ extern "C"
extern void PQuntrace(PGconn *conn); extern void PQuntrace(PGconn *conn);
/* Override default notice processor */ /* Override default notice processor */
extern PQnoticeProcessor PQsetNoticeProcessor(PGconn *conn, PQnoticeProcessor proc, void *arg); extern PQnoticeProcessor PQsetNoticeProcessor(PGconn *conn,
PQnoticeProcessor proc,
void *arg);
/* === in fe-exec.c === */ /* === in fe-exec.c === */
/* Quoting strings before inclusion in queries. */ /* Quoting strings before inclusion in queries. */
extern size_t PQescapeString(char *to, const char *from, size_t length); extern size_t PQescapeString(char *to, const char *from, size_t length);
extern unsigned char *PQescapeBytea(unsigned char *bintext, size_t binlen, size_t *bytealen); extern unsigned char *PQescapeBytea(unsigned char *bintext, size_t binlen,
size_t *bytealen);
/* Simple synchronous query */ /* Simple synchronous query */
extern PGresult *PQexec(PGconn *conn, const char *query); extern PGresult *PQexec(PGconn *conn, const char *query);
@ -337,8 +333,7 @@ extern "C"
* really old printing routines * really old printing routines
*/ */
extern void PQdisplayTuples(const PGresult *res, extern void PQdisplayTuples(const PGresult *res,
FILE *fp, /* where to send the FILE *fp, /* where to send the output */
* output */
int fillAlign, /* pad the fields with int fillAlign, /* pad the fields with
* spaces */ * spaces */
const char *fieldSep, /* field separator */ const char *fieldSep, /* field separator */

View File

@ -12,7 +12,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Id: libpq-int.h,v 1.42 2001/10/28 06:26:12 momjian Exp $ * $Id: libpq-int.h,v 1.43 2001/11/02 20:51:27 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -353,4 +353,16 @@ __attribute__((format_arg(1)));
#define libpq_gettext(x) (x) #define libpq_gettext(x) (x)
#endif #endif
/*
* These macros are needed to let error-handling code be portable between
* Unix and Windows. (ugh)
*/
#ifdef WIN32
#define SOCK_ERRNO (WSAGetLastError())
#define SOCK_STRERROR winsock_strerror
#else
#define SOCK_ERRNO errno
#define SOCK_STRERROR strerror
#endif
#endif /* LIBPQ_INT_H */ #endif /* LIBPQ_INT_H */