Use AC_PROG_INSTALL & ./install-sh
[pgbouncer.git] / include / proto.h
blob82a2c61129d089be3984440585ae3f538183b58c
1 /*
2 * PgBouncer - Lightweight connection pooler for PostgreSQL.
3 *
4 * Copyright (c) 2007-2009 Marko Kreen, Skype Technologies OÜ
5 *
6 * Permission to use, copy, modify, and/or distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20 * parsed packet header, plus whatever data is
21 * available in SBuf for this packet.
23 * if (pkt->len == mbuf_avail(&pkt->data))
24 * packet is fully in buffer
26 * get_header() points pkt->data.pos after header.
27 * to packet body.
29 struct PktHdr {
30 unsigned type;
31 unsigned len;
32 MBuf data;
35 bool get_header(MBuf *data, PktHdr *pkt) _MUSTCHECK;
37 bool send_pooler_error(PgSocket *client, bool send_ready, const char *msg) /*_MUSTCHECK*/;
38 void log_server_error(const char *note, PktHdr *pkt);
39 void parse_server_error(PktHdr *pkt, const char **level_p, const char **msg_p);
41 void add_welcome_parameter(PgPool *pool, const char *key, const char *val);
42 void finish_welcome_msg(PgSocket *server);
43 bool welcome_client(PgSocket *client) _MUSTCHECK;
45 bool answer_authreq(PgSocket *server, PktHdr *pkt) _MUSTCHECK;
47 bool send_startup_packet(PgSocket *server) _MUSTCHECK;
49 int scan_text_result(MBuf *pkt, const char *tupdesc, ...) _MUSTCHECK;
51 /* is packet completely in our buffer */
52 static inline bool incomplete_pkt(const PktHdr *pkt)
54 return mbuf_size(&pkt->data) != pkt->len;
57 /* one char desc */
58 static inline char pkt_desc(const PktHdr *pkt)
60 return pkt->type > 256 ? '!' : pkt->type;