]> granicus.if.org Git - postgresql/blobdiff - src/interfaces/libpq/libpq-int.h
Avoid extra system calls to block SIGPIPE if the platform provides either
[postgresql] / src / interfaces / libpq / libpq-int.h
index b29057bde95257e2e638ad93200663972f6894ae..d93ba4d25e230657863770f23f0f7351827e0293 100644 (file)
@@ -9,10 +9,10 @@
  *       more likely to break across PostgreSQL releases than code that uses
  *       only the official API.
  *
- * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/interfaces/libpq/libpq-int.h,v 1.133 2008/09/19 16:40:40 tgl Exp $
+ * $PostgreSQL: pgsql/src/interfaces/libpq/libpq-int.h,v 1.144 2009/07/24 17:58:31 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -55,6 +55,9 @@
 
 #ifdef ENABLE_SSPI
 #define SECURITY_WIN32
+#if defined(WIN32) && !defined(WIN32_ONLY_COMPILER)
+#include <ntsecapi.h>
+#endif
 #include <security.h>
 #undef SECURITY_WIN32
 
@@ -66,15 +69,20 @@ typedef struct
 {
        void       *value;
        int                     length;
-}      gss_buffer_desc;
+} gss_buffer_desc;
 #endif
 #endif   /* ENABLE_SSPI */
 
 #ifdef USE_SSL
 #include <openssl/ssl.h>
 #include <openssl/err.h>
+
+#if (SSLEAY_VERSION_NUMBER >= 0x00907000L) && !defined(OPENSSL_NO_ENGINE)
+#define USE_SSL_ENGINE
 #endif
 
+#endif /* USE_SSL */
+
 /*
  * POSTGRES backend dependent Constants.
  */
@@ -152,11 +160,11 @@ typedef struct
 
 typedef struct PGEvent
 {
-       PGEventProc     proc;                   /* the function to call on events */
+       PGEventProc proc;                       /* the function to call on events */
        char       *name;                       /* used only for error messages */
        void       *passThrough;        /* pointer supplied at registration time */
        void       *data;                       /* optional state (instance) data */
-       bool            resultInitialized;      /* T if RESULTCREATE/COPY succeeded */
+       bool            resultInitialized;              /* T if RESULTCREATE/COPY succeeded */
 } PGEvent;
 
 struct pg_result
@@ -179,7 +187,7 @@ struct pg_result
         * on the PGresult don't have to reference the PGconn.
         */
        PGNoticeHooks noticeHooks;
-       PGEvent    *events;
+       PGEvent    *events;
        int                     nEvents;
        int                     client_encoding;        /* encoding id */
 
@@ -290,8 +298,12 @@ struct pg_conn
        char       *dbName;                     /* database name */
        char       *pguser;                     /* Postgres username and password, if any */
        char       *pgpass;
-       bool            pgpass_from_client;     /* did password come from connect args? */
        char       *sslmode;            /* SSL mode (require,prefer,allow,disable) */
+       char       *sslkey;                     /* client key filename */
+       char       *sslcert;            /* client certificate filename */
+       char       *sslrootcert;        /* root certificate filename */
+       char       *sslcrl;                     /* certificate revocation list filename */
+
 #if defined(KRB5) || defined(ENABLE_GSS) || defined(ENABLE_SSPI)
        char       *krbsrvname;         /* Kerberos service name */
 #endif
@@ -303,9 +315,9 @@ struct pg_conn
        PGNoticeHooks noticeHooks;
 
        /* Event procs registered via PQregisterEventProc */
-       PGEvent    *events;                     /* expandable array of event data */
+       PGEvent    *events;                     /* expandable array of event data */
        int                     nEvents;                /* number of active events */
-       int                     eventArraySize; /* allocated array size */
+       int                     eventArraySize; /* allocated array size */
 
        /* Status indicators */
        ConnStatusType status;
@@ -329,6 +341,8 @@ struct pg_conn
        ProtocolVersion pversion;       /* FE/BE protocol version in use */
        int                     sversion;               /* server version, e.g. 70401 for 7.4.1 */
        bool            password_needed;        /* true if server demanded a password */
+       bool            sigpipe_so;             /* have we masked SIGPIPE via SO_NOSIGPIPE? */
+       bool            sigpipe_flag;   /* can we mask SIGPIPE via MSG_NOSIGNAL? */
 
        /* Transient state needed while establishing connection */
        struct addrinfo *addrlist;      /* list of possible backend addresses */
@@ -341,7 +355,6 @@ struct pg_conn
        int                     be_pid;                 /* PID of backend --- needed for cancels */
        int                     be_key;                 /* key of backend --- needed for cancels */
        char            md5Salt[4];             /* password salt received from backend */
-       char            cryptSalt[2];   /* password salt received from backend */
        pgParameterStatus *pstatus; /* ParameterStatus data */
        int                     client_encoding;        /* encoding id */
        bool            std_strings;    /* standard_conforming_strings */
@@ -377,7 +390,13 @@ struct pg_conn
        X509       *peer;                       /* X509 cert of server */
        char            peer_dn[256 + 1];               /* peer distinguished name */
        char            peer_cn[SM_USER + 1];   /* peer common name */
+#ifdef USE_SSL_ENGINE
+       ENGINE     *engine;                     /* SSL engine, if any */
+#else
+       void       *engine;                     /* dummy field to keep struct the same
+                                                                  if OpenSSL version changes */
 #endif
+#endif /* USE_SSL */
 
 #ifdef ENABLE_GSS
        gss_ctx_id_t gctx;                      /* GSS context */
@@ -520,6 +539,7 @@ extern int  pqCheckInBufferSpace(size_t bytes_needed, PGconn *conn);
 extern int     pqGetc(char *result, PGconn *conn);
 extern int     pqPutc(char c, PGconn *conn);
 extern int     pqGets(PQExpBuffer buf, PGconn *conn);
+extern int     pqGets_append(PQExpBuffer buf, PGconn *conn);
 extern int     pqPuts(const char *s, PGconn *conn);
 extern int     pqGetnchar(char *s, size_t len, PGconn *conn);
 extern int     pqPutnchar(const char *s, size_t len, PGconn *conn);