]> granicus.if.org Git - postgresql/blobdiff - src/interfaces/libpq/libpq-fe.h
From: Dan McGuirk <mcguirk@indirect.com>
[postgresql] / src / interfaces / libpq / libpq-fe.h
index 072039558c727c2b2b07ec2b0749a1660ca6f207..c765661e71770e288dc48d70a9ad99c68b6d29de 100644 (file)
@@ -6,7 +6,7 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- * $Id: libpq-fe.h,v 1.5 1996/07/31 18:40:12 scrappy Exp $
+ * $Id: libpq-fe.h,v 1.18 1997/03/12 21:23:16 scrappy Exp $
  *
  *-------------------------------------------------------------------------
  */
 extern "C" {
 #endif
 
+#include <stdio.h>
 /* ----------------
  *     include stuff common to fe and be
  * ----------------
  */
-/* #include "libpq/libpq.h" */
+#include "postgres_ext.h"
 #include "libpq/pqcomm.h"
 #include "lib/dllist.h"
 
@@ -45,7 +46,7 @@ typedef enum {
 } ExecStatusType;
 
 /* string descriptions of the ExecStatusTypes */
-extern char* pgresStatus[]; 
+extern const char* pgresStatus[]; 
 
 /* 
  * POSTGRES backend dependent Constants. 
@@ -75,7 +76,7 @@ typedef struct {
 typedef struct pgresAttDesc {
   char* name; /* type name */
   Oid adtid;  /* type id */
-  int2 adtsize; /* type size */
+  short adtsize; /* type size */
 } PGresAttDesc;
 
 /* use char* for Attribute values,
@@ -83,6 +84,9 @@ typedef struct pgresAttDesc {
    For binary tuples, the first four bytes of the value is the size,
    and the bytes afterwards are the value.  The binary value is 
    not guaranteed to be null-terminated.  In fact, it can have embedded nulls*/
+
+#define NULL_LEN       (-1)    /* pg_result len for NULL value */
+
 typedef struct pgresAttValue {
   int len; /* length in bytes of the value */
   char *value; /* actual value */
@@ -93,6 +97,17 @@ typedef struct pgNotify {
     int be_pid;                        /* process id of backend */
 } PGnotify;
 
+typedef struct pgLobjfuncs {
+    Oid fn_lo_open;            /* OID of backend function lo_open      */
+    Oid fn_lo_close;           /* OID of backend function lo_close     */
+    Oid fn_lo_creat;           /* OID of backend function lo_creat     */
+    Oid fn_lo_unlink;          /* OID of backend function lo_unlink    */
+    Oid fn_lo_lseek;           /* OID of backend function lo_lseek     */
+    Oid fn_lo_tell;            /* OID of backend function lo_tell      */
+    Oid fn_lo_read;            /* OID of backend function LOread       */
+    Oid fn_lo_write;           /* OID of backend function LOwrite      */
+} PGlobjfuncs;
+
 /* PGconn encapsulates a connection to the backend */
 typedef struct pg_conn{
   char *pghost; /* the machine on which the server is running */
@@ -109,6 +124,10 @@ typedef struct pg_conn{
   void *port; /* really a Port* */
   int asyncNotifyWaiting;
   Dllist* notifyList;
+  char *pguser;  /* Postgres username of user who is connected */
+  char *pgpass;
+  char *pgauth;
+  PGlobjfuncs *lobjfuncs; /* Backend function OID's for large object access */
 } PGconn;
 
 #define CMDSTATUS_LEN 40
@@ -127,13 +146,19 @@ typedef struct pg_result{
   PGconn* conn;
 } PGresult;
 
+typedef char pqbool;
+  /* We can't use the conventional "bool", because we are designed to be
+     included in a user's program, and user may already have that type
+     defined.  Pqbool, on the other hand, is unlikely to be used.
+     */
+
 struct _PQprintOpt {
-    bool header;         /* print output field headings and row count */
-    bool align;          /* fill align the fields */
-    bool standard;       /* old brain dead format */
-    bool html3;          /* output html tables */
-    bool expanded;       /* expand tables */
-    bool pager;          /* use pager for output if needed */
+    pqbool header;         /* print output field headings and row count */
+    pqbool align;          /* fill align the fields */
+    pqbool standard;       /* old brain dead format */
+    pqbool html3;          /* output html tables */
+    pqbool expanded;       /* expand tables */
+    pqbool pager;          /* use pager for output if needed */
     char *fieldSep;      /* field separator */
     char *tableOpt;     /* insert to HTML <table ...> */
     char *caption;       /* HTML <caption> */
@@ -142,10 +167,33 @@ struct _PQprintOpt {
 
 typedef struct _PQprintOpt PQprintOpt;
 
+/* ----------------
+ * Structure for the conninfo parameter definitions of PQconnectdb()
+ * ----------------
+ */
+struct _PQconninfoOption {
+    char       *keyword;       /* The keyword of the option            */
+    char       *environ;       /* Fallback environment variable name   */
+    char       *compiled;      /* Fallback compiled in default value   */
+    char       *val;           /* Options value                        */
+    char       *label;         /* Label for field in connect dialog    */
+    char       *dispchar;      /* Character to display for this field  */
+                               /* in a connect dialog. Values are:     */
+                               /*    ""   Display entered value as is  */
+                               /*    "*"  Password field - hide value  */
+                               /*    "D"  Debug options - don't        */
+                               /*         create a field by default    */
+    int                dispsize;       /* Field size in characters for dialog  */
+};
+
+typedef struct _PQconninfoOption PQconninfoOption;
+
 /* ===  in fe-connect.c === */
   /* make a new client connection to the backend */
-extern PGconn* PQsetdb(char* pghost, char* pgport, char* pgoptions, 
-                      char* pgtty, char* dbName);
+extern PGconn* PQconnectdb(const char* conninfo);
+extern PQconninfoOption *PQconndefaults(void);
+extern PGconn* PQsetdb(const char* pghost, const char* pgport, const char* pgoptions, 
+                      const char* pgtty, const char* dbName);
   /* close the current connection and free the PGconn data structure */
 extern void PQfinish(PGconn* conn);
   /* close the current connection and restablish a new one with the same 
@@ -153,6 +201,7 @@ extern void PQfinish(PGconn* conn);
 extern void PQreset(PGconn* conn);
 
 extern char* PQdb(PGconn* conn);
+extern char* PQuser(PGconn* conn);
 extern char* PQhost(PGconn* conn);
 extern char* PQoptions(PGconn* conn);
 extern char* PQport(PGconn* conn);
@@ -163,27 +212,28 @@ extern void PQtrace(PGconn *conn, FILE* debug_port);
 extern void PQuntrace(PGconn *conn);
 
 /* === in fe-exec.c === */
-extern PGresult* PQexec(PGconn* conn, char* query);
+extern PGresult* PQexec(PGconn* conn, const char* query);
 extern int PQgetline(PGconn *conn, char* string, int length);
 extern int PQendcopy(PGconn *conn);
-extern void PQputline(PGconn *conn, char* string);
+extern void PQputline(PGconn *conn, const char* string);
 extern ExecStatusType PQresultStatus(PGresult* res);
 extern int PQntuples(PGresult *res);
 extern int PQnfields(PGresult *res);
 extern char* PQfname(PGresult *res, int field_num);
-extern int PQfnumber(PGresult *res, char* field_name);
+extern int PQfnumber(PGresult *res, const char* field_name);
 extern Oid PQftype(PGresult *res, int field_num);
-extern int2 PQfsize(PGresult *res, int field_num);
+extern short PQfsize(PGresult *res, int field_num);
 extern char* PQcmdStatus(PGresult *res);
-extern char* PQoidStatus(PGresult *res);
+extern const char* PQoidStatus(PGresult *res);
 extern char* PQgetvalue(PGresult *res, int tup_num, int field_num);
 extern int PQgetlength(PGresult *res, int tup_num, int field_num);
+extern int PQgetisnull(PGresult *res, int tup_num, int field_num);
 extern void PQclear(PGresult* res);
 /* PQdisplayTuples() is a better version of PQprintTuples() */
 extern void PQdisplayTuples(PGresult *res,
                            FILE *fp,      /* where to send the output */
                            int fillAlign, /* pad the fields with spaces */
-                           char *fieldSep,  /* field separator */
+                           const char *fieldSep,  /* field separator */
                            int printHeader, /* display headers? */
                            int quiet);
 extern void PQprintTuples(PGresult* res, 
@@ -207,7 +257,7 @@ extern PGresult* PQfn(PGconn* conn,
                      int nargs);
 /* === in fe-auth.c === */
 extern MsgType fe_getauthsvc(char* PQerrormsg);
-extern void fe_setauthsvc(char *name, char* PQerrormsg);
+extern void fe_setauthsvc(const char *name, char* PQerrormsg);
 extern char *fe_getauthname(char* PQerrormsg);
 
 /* === in fe-misc.c === */
@@ -217,15 +267,15 @@ extern char *fe_getauthname(char* PQerrormsg);
 */
 extern int pqGets(char* s, int maxlen, FILE* stream, FILE* debug);
 extern int pqGetnchar(char* s, int maxlen, FILE* stream, FILE* debug);
-extern int pqPutnchar(char* s, int maxlen, FILE* stream, FILE* debug);
-extern int pqPuts(char* s, FILE* stream, FILE* debug );
+extern int pqPutnchar(const char* s, int maxlen, FILE* stream, FILE* debug);
+extern int pqPuts(const char* s, FILE* stream, FILE* debug );
 extern int pqGetc(FILE* stream, FILE *debug);
 /* get a n-byte integer from the stream into result */
 /* returns 0 if successful */
 extern int pqGetInt(int* result, int bytes, FILE* stream, FILE *debug );
 /* put a n-byte integer into the stream */
 /* returns 0 if successful */
-extern int pqPutInt(int n, int bytes, FILE* stream, FILE *debug );
+extern int pqPutInt(const int n, int bytes, FILE* stream, FILE *debug );
 extern void pqFlush(FILE* stream, FILE* debug);
 
 /* === in fe-lobj.c === */
@@ -256,10 +306,10 @@ typedef void *TUPLE;
 #define palloc malloc
 #define pfree free
 
-#if defined(PORTNAME_sparc)
+#if defined(sunos4)
 extern char *sys_errlist[];
 #define strerror(A) (sys_errlist[(A)])
-#endif /* PORTNAME_sparc */
+#endif /* sunos4 */
 
 #ifdef __cplusplus
 };