]> granicus.if.org Git - postgresql/blob - src/interfaces/libpq/libpq-int.h
c338fa92332055c293372cf594fbc7e9a99c725e
[postgresql] / src / interfaces / libpq / libpq-int.h
1 /*-------------------------------------------------------------------------
2  *
3  * libpq-int.h--
4  *        This file contains internal definitions meant to be used only by
5  *        the frontend libpq library, not by applications that call it.
6  *
7  * Copyright (c) 1994, Regents of the University of California
8  *
9  * $Id: libpq-int.h,v 1.2 1998/09/01 04:40:12 momjian Exp $
10  *
11  *-------------------------------------------------------------------------
12  */
13
14 #ifndef LIBPQ_INT_H
15 #define LIBPQ_INT_H
16
17 /* We assume libpq-fe.h has already been included. */
18
19 /* ----------------
20  *              include stuff common to fe and be
21  * ----------------
22  */
23 #include "libpq/pqcomm.h"
24
25 /* libpq supports this version of the frontend/backend protocol.
26  *
27  * NB: we used to use PG_PROTOCOL_LATEST from the backend pqcomm.h file,
28  * but that's not really the right thing: just recompiling libpq
29  * against a more recent backend isn't going to magically update it
30  * for most sorts of protocol changes.  So, when you change libpq
31  * to support a different protocol revision, you have to change this
32  * constant too.  PG_PROTOCOL_EARLIEST and PG_PROTOCOL_LATEST in
33  * pqcomm.h describe what the backend knows, not what libpq knows.
34  */
35
36 #define PG_PROTOCOL_LIBPQ       PG_PROTOCOL(2,0)
37
38 /* ----------------
39  * Internal functions of libpq
40  * Functions declared here need to be visible across files of libpq,
41  * but are not intended to be called by applications.  We use the
42  * convention "pqXXX" for internal functions, vs. the "PQxxx" names
43  * used for application-visible routines.
44  * ----------------
45  */
46
47 /* === in fe-connect.c === */
48
49 extern int      pqPacketSend(PGconn *conn, const char *buf, size_t len);
50
51 /* === in fe-exec.c === */
52
53 extern void pqClearAsyncResult(PGconn *conn);
54
55 /* === in fe-misc.c === */
56
57  /*
58   * "Get" and "Put" routines return 0 if successful, EOF if not. Note that
59   * for Get, EOF merely means the buffer is exhausted, not that there is
60   * necessarily any error.
61   */
62 extern int      pqGetc(char *result, PGconn *conn);
63 extern int      pqGets(char *s, int maxlen, PGconn *conn);
64 extern int      pqPuts(const char *s, PGconn *conn);
65 extern int      pqGetnchar(char *s, int len, PGconn *conn);
66 extern int      pqPutnchar(const char *s, int len, PGconn *conn);
67 extern int      pqGetInt(int *result, int bytes, PGconn *conn);
68 extern int      pqPutInt(int value, int bytes, PGconn *conn);
69 extern int      pqReadData(PGconn *conn);
70 extern int      pqFlush(PGconn *conn);
71 extern int      pqWait(int forRead, int forWrite, PGconn *conn);
72
73 /* max length of message to send  */
74 #define MAX_MESSAGE_LEN 8193
75
76 /* maximum number of fields in a tuple */
77 #define MAX_FIELDS 512
78
79 /* bits in a byte */
80 #define BYTELEN 8
81
82 /* fall back options if they are not specified by arguments or defined
83    by environment variables */
84 #define DefaultHost             "localhost"
85 #define DefaultTty              ""
86 #define DefaultOption   ""
87 #define DefaultAuthtype           ""
88 #define DefaultPassword           ""
89
90 /* supply an implementation of strerror() macro if system doesn't have it */
91 #ifndef strerror
92 #if defined(sun) && defined(sparc) && !defined(__SVR4)
93 extern char *sys_errlist[];
94
95 #define strerror(A) (sys_errlist[(A)])
96 #endif   /* sunos4 */
97 #endif   /* !strerror */
98
99 #endif   /* LIBPQ_INT_H */