PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
libpq.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * libpq.h
4  * POSTGRES LIBPQ buffer structure definitions.
5  *
6  *
7  * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group
8  * Portions Copyright (c) 1994, Regents of the University of California
9  *
10  * src/include/libpq/libpq.h
11  *
12  *-------------------------------------------------------------------------
13  */
14 #ifndef LIBPQ_H
15 #define LIBPQ_H
16 
17 #include <sys/types.h>
18 #include <netinet/in.h>
19 
20 #include "lib/stringinfo.h"
21 #include "libpq/libpq-be.h"
22 #include "storage/latch.h"
23 
24 
25 typedef struct
26 {
27  void (*comm_reset) (void);
28  int (*flush) (void);
29  int (*flush_if_writable) (void);
30  bool (*is_send_pending) (void);
31  int (*putmessage) (char msgtype, const char *s, size_t len);
32  void (*putmessage_noblock) (char msgtype, const char *s, size_t len);
33  void (*startcopyout) (void);
34  void (*endcopyout) (bool errorAbort);
36 
38 
39 #define pq_comm_reset() (PqCommMethods->comm_reset())
40 #define pq_flush() (PqCommMethods->flush())
41 #define pq_flush_if_writable() (PqCommMethods->flush_if_writable())
42 #define pq_is_send_pending() (PqCommMethods->is_send_pending())
43 #define pq_putmessage(msgtype, s, len) \
44  (PqCommMethods->putmessage(msgtype, s, len))
45 #define pq_putmessage_noblock(msgtype, s, len) \
46  (PqCommMethods->putmessage_noblock(msgtype, s, len))
47 #define pq_startcopyout() (PqCommMethods->startcopyout())
48 #define pq_endcopyout(errorAbort) (PqCommMethods->endcopyout(errorAbort))
49 
50 /*
51  * External functions.
52  */
53 
54 /*
55  * prototypes for functions in pqcomm.c
56  */
57 extern int StreamServerPort(int family, char *hostName,
58  unsigned short portNumber, char *unixSocketDir,
59  pgsocket ListenSocket[], int MaxListen);
60 extern int StreamConnection(pgsocket server_fd, Port *port);
61 extern void StreamClose(pgsocket sock);
62 extern void TouchSocketFiles(void);
63 extern void RemoveSocketFiles(void);
64 extern void pq_init(void);
65 extern int pq_getbytes(char *s, size_t len);
66 extern int pq_getstring(StringInfo s);
67 extern void pq_startmsgread(void);
68 extern void pq_endmsgread(void);
69 extern bool pq_is_reading_msg(void);
70 extern int pq_getmessage(StringInfo s, int maxlen);
71 extern int pq_getbyte(void);
72 extern int pq_peekbyte(void);
73 extern int pq_getbyte_if_available(unsigned char *c);
74 extern int pq_putbytes(const char *s, size_t len);
75 
76 /*
77  * prototypes for functions in be-secure.c
78  */
79 extern char *ssl_cert_file;
80 extern char *ssl_key_file;
81 extern char *ssl_ca_file;
82 extern char *ssl_crl_file;
83 
84 extern int secure_initialize(bool isServerStart);
85 extern bool secure_loaded_verify_locations(void);
86 extern void secure_destroy(void);
87 extern int secure_open_server(Port *port);
88 extern void secure_close(Port *port);
89 extern ssize_t secure_read(Port *port, void *ptr, size_t len);
90 extern ssize_t secure_write(Port *port, void *ptr, size_t len);
91 extern ssize_t secure_raw_read(Port *port, void *ptr, size_t len);
92 extern ssize_t secure_raw_write(Port *port, const void *ptr, size_t len);
93 
94 extern bool ssl_loaded_verify_locations;
95 
97 
98 /* GUCs */
99 extern char *SSLCipherSuites;
100 extern char *SSLECDHCurve;
101 extern bool SSLPreferServerCiphers;
102 
103 #endif /* LIBPQ_H */
char * SSLCipherSuites
Definition: be-secure.c:53
void StreamClose(pgsocket sock)
Definition: pqcomm.c:791
ssize_t secure_raw_write(Port *port, const void *ptr, size_t len)
Definition: be-secure.c:302
char * ssl_ca_file
Definition: be-secure.c:45
WaitEventSet * FeBeWaitSet
Definition: pqcomm.c:167
bool pq_is_reading_msg(void)
Definition: pqcomm.c:1197
bool ssl_loaded_verify_locations
PGDLLIMPORT PQcommMethods * PqCommMethods
Definition: pqcomm.c:165
Definition: libpq-be.h:118
void pq_endmsgread(void)
Definition: pqcomm.c:1181
int secure_initialize(bool isServerStart)
Definition: be-secure.c:73
char * ssl_cert_file
Definition: be-secure.c:43
ssize_t secure_read(Port *port, void *ptr, size_t len)
Definition: be-secure.c:137
void pq_startmsgread(void)
Definition: pqcomm.c:1157
#define PGDLLIMPORT
Definition: c.h:1062
char bool
Definition: c.h:199
int pq_putbytes(const char *s, size_t len)
Definition: pqcomm.c:1300
bool SSLPreferServerCiphers
Definition: be-secure.c:59
char * c
bool secure_loaded_verify_locations(void)
Definition: be-secure.c:97
int pgsocket
Definition: port.h:22
int StreamConnection(pgsocket server_fd, Port *port)
Definition: pqcomm.c:663
static int port
Definition: pg_regress.c:87
int pq_getbyte_if_available(unsigned char *c)
Definition: pqcomm.c:987
static pgsocket ListenSocket[MAXLISTEN]
Definition: postmaster.c:215
int pq_peekbyte(void)
Definition: pqcomm.c:966
void secure_close(Port *port)
Definition: be-secure.c:125
char * ssl_key_file
Definition: be-secure.c:44
void RemoveSocketFiles(void)
Definition: pqcomm.c:836
ssize_t secure_write(Port *port, void *ptr, size_t len)
Definition: be-secure.c:240
void TouchSocketFiles(void)
Definition: pqcomm.c:806
void pq_init(void)
Definition: pqcomm.c:175
void secure_destroy(void)
Definition: be-secure.c:86
ssize_t secure_raw_read(Port *port, void *ptr, size_t len)
Definition: be-secure.c:216
int pq_getbyte(void)
Definition: pqcomm.c:947
int pq_getbytes(char *s, size_t len)
Definition: pqcomm.c:1041
int pq_getstring(StringInfo s)
Definition: pqcomm.c:1113
char * ssl_crl_file
Definition: be-secure.c:46
int pq_getmessage(StringInfo s, int maxlen)
Definition: pqcomm.c:1219
int StreamServerPort(int family, char *hostName, unsigned short portNumber, char *unixSocketDir, pgsocket ListenSocket[], int MaxListen)
Definition: pqcomm.c:311
char * SSLECDHCurve
Definition: be-secure.c:56
int secure_open_server(Port *port)
Definition: be-secure.c:110