PostgreSQL Source Code  git master
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-2018, 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 <netinet/in.h>
18 
19 #include "lib/stringinfo.h"
20 #include "libpq/libpq-be.h"
21 #include "storage/latch.h"
22 
23 
24 typedef struct
25 {
26  void (*comm_reset) (void);
27  int (*flush) (void);
28  int (*flush_if_writable) (void);
29  bool (*is_send_pending) (void);
30  int (*putmessage) (char msgtype, const char *s, size_t len);
31  void (*putmessage_noblock) (char msgtype, const char *s, size_t len);
32  void (*startcopyout) (void);
33  void (*endcopyout) (bool errorAbort);
35 
37 
38 #define pq_comm_reset() (PqCommMethods->comm_reset())
39 #define pq_flush() (PqCommMethods->flush())
40 #define pq_flush_if_writable() (PqCommMethods->flush_if_writable())
41 #define pq_is_send_pending() (PqCommMethods->is_send_pending())
42 #define pq_putmessage(msgtype, s, len) \
43  (PqCommMethods->putmessage(msgtype, s, len))
44 #define pq_putmessage_noblock(msgtype, s, len) \
45  (PqCommMethods->putmessage_noblock(msgtype, s, len))
46 #define pq_startcopyout() (PqCommMethods->startcopyout())
47 #define pq_endcopyout(errorAbort) (PqCommMethods->endcopyout(errorAbort))
48 
49 /*
50  * External functions.
51  */
52 
53 /*
54  * prototypes for functions in pqcomm.c
55  */
56 extern int StreamServerPort(int family, char *hostName,
57  unsigned short portNumber, char *unixSocketDir,
58  pgsocket ListenSocket[], int MaxListen);
59 extern int StreamConnection(pgsocket server_fd, Port *port);
60 extern void StreamClose(pgsocket sock);
61 extern void TouchSocketFiles(void);
62 extern void RemoveSocketFiles(void);
63 extern void pq_init(void);
64 extern int pq_getbytes(char *s, size_t len);
65 extern int pq_getstring(StringInfo s);
66 extern void pq_startmsgread(void);
67 extern void pq_endmsgread(void);
68 extern bool pq_is_reading_msg(void);
69 extern int pq_getmessage(StringInfo s, int maxlen);
70 extern int pq_getbyte(void);
71 extern int pq_peekbyte(void);
72 extern int pq_getbyte_if_available(unsigned char *c);
73 extern int pq_putbytes(const char *s, size_t len);
74 
75 /*
76  * prototypes for functions in be-secure.c
77  */
78 extern char *ssl_cert_file;
79 extern char *ssl_key_file;
80 extern char *ssl_ca_file;
81 extern char *ssl_crl_file;
82 extern char *ssl_dh_params_file;
83 extern char *ssl_passphrase_command;
85 
86 extern int secure_initialize(bool isServerStart);
87 extern bool secure_loaded_verify_locations(void);
88 extern void secure_destroy(void);
89 extern int secure_open_server(Port *port);
90 extern void secure_close(Port *port);
91 extern ssize_t secure_read(Port *port, void *ptr, size_t len);
92 extern ssize_t secure_write(Port *port, void *ptr, size_t len);
93 extern ssize_t secure_raw_read(Port *port, void *ptr, size_t len);
94 extern ssize_t secure_raw_write(Port *port, const void *ptr, size_t len);
95 
96 extern bool ssl_loaded_verify_locations;
97 
99 
100 /* GUCs */
101 extern char *SSLCipherSuites;
102 extern char *SSLECDHCurve;
103 extern bool SSLPreferServerCiphers;
104 
105 /*
106  * prototypes for functions in be-secure-common.c
107  */
108 extern int run_ssl_passphrase_command(const char *prompt, bool is_server_start,
109  char *buf, int size);
110 extern bool check_ssl_key_file_permissions(const char *ssl_key_file,
111  bool isServerStart);
112 
113 #endif /* LIBPQ_H */
char * SSLCipherSuites
Definition: be-secure.c:54
char * ssl_passphrase_command
Definition: be-secure.c:46
void StreamClose(pgsocket sock)
Definition: pqcomm.c:844
ssize_t secure_raw_write(Port *port, const void *ptr, size_t len)
Definition: be-secure.c:307
char * ssl_ca_file
Definition: be-secure.c:43
WaitEventSet * FeBeWaitSet
Definition: pqcomm.c:186
bool pq_is_reading_msg(void)
Definition: pqcomm.c:1250
bool ssl_loaded_verify_locations
PGDLLIMPORT PQcommMethods * PqCommMethods
Definition: pqcomm.c:184
Definition: libpq-be.h:116
void pq_endmsgread(void)
Definition: pqcomm.c:1234
int secure_initialize(bool isServerStart)
Definition: be-secure.c:74
char * ssl_cert_file
Definition: be-secure.c:41
ssize_t secure_read(Port *port, void *ptr, size_t len)
Definition: be-secure.c:142
void pq_startmsgread(void)
Definition: pqcomm.c:1210
#define PGDLLIMPORT
Definition: c.h:1105
char bool
Definition: c.h:275
int pq_putbytes(const char *s, size_t len)
Definition: pqcomm.c:1353
bool SSLPreferServerCiphers
Definition: be-secure.c:60
char * c
static char * buf
Definition: pg_test_fsync.c:67
bool secure_loaded_verify_locations(void)
Definition: be-secure.c:98
int pgsocket
Definition: port.h:31
int StreamConnection(pgsocket server_fd, Port *port)
Definition: pqcomm.c:716
static int port
Definition: pg_regress.c:90
int pq_getbyte_if_available(unsigned char *c)
Definition: pqcomm.c:1040
bool ssl_passphrase_command_supports_reload
Definition: be-secure.c:47
int run_ssl_passphrase_command(const char *prompt, bool is_server_start, char *buf, int size)
static pgsocket ListenSocket[MAXLISTEN]
Definition: postmaster.c:217
int pq_peekbyte(void)
Definition: pqcomm.c:1019
void secure_close(Port *port)
Definition: be-secure.c:130
char * ssl_dh_params_file
Definition: be-secure.c:45
char * ssl_key_file
Definition: be-secure.c:42
void RemoveSocketFiles(void)
Definition: pqcomm.c:889
bool check_ssl_key_file_permissions(const char *ssl_key_file, bool isServerStart)
ssize_t secure_write(Port *port, void *ptr, size_t len)
Definition: be-secure.c:245
void TouchSocketFiles(void)
Definition: pqcomm.c:859
void pq_init(void)
Definition: pqcomm.c:194
void secure_destroy(void)
Definition: be-secure.c:87
ssize_t secure_raw_read(Port *port, void *ptr, size_t len)
Definition: be-secure.c:221
int pq_getbyte(void)
Definition: pqcomm.c:1000
int pq_getbytes(char *s, size_t len)
Definition: pqcomm.c:1094
int pq_getstring(StringInfo s)
Definition: pqcomm.c:1166
char * ssl_crl_file
Definition: be-secure.c:44
int pq_getmessage(StringInfo s, int maxlen)
Definition: pqcomm.c:1272
int StreamServerPort(int family, char *hostName, unsigned short portNumber, char *unixSocketDir, pgsocket ListenSocket[], int MaxListen)
Definition: pqcomm.c:330
char * SSLECDHCurve
Definition: be-secure.c:57
int secure_open_server(Port *port)
Definition: be-secure.c:111