codekingpro/portable-devtools
114k
1/*-------------------------------------------------------------------------2 *3 * libpq-fe.h4 * This file contains definitions for structures and5 * externs for functions used by frontend postgres applications.6 *7 * Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group8 * Portions Copyright (c) 1994, Regents of the University of California9 *10 * src/interfaces/libpq/libpq-fe.h11 *12 *-------------------------------------------------------------------------13 */14 15#ifndef LIBPQ_FE_H16#define LIBPQ_FE_H17 18#ifdef __cplusplus19extern "C"20{21#endif22 23#include <stdio.h>24 25/*26 * postgres_ext.h defines the backend's externally visible types,27 * such as Oid.28 */29#include "postgres_ext.h"30 31/*32 * These symbols may be used in compile-time #ifdef tests for the availability33 * of newer libpq features.34 */35/* Indicates presence of PQenterPipelineMode and friends */36#define LIBPQ_HAS_PIPELINING 137/* Indicates presence of PQsetTraceFlags; also new PQtrace output format */38#define LIBPQ_HAS_TRACE_FLAGS 139/* Indicates that PQsslAttribute(NULL, "library") is useful */40#define LIBPQ_HAS_SSL_LIBRARY_DETECTION 141 42/*43 * Option flags for PQcopyResult44 */45#define PG_COPYRES_ATTRS 0x0146#define PG_COPYRES_TUPLES 0x02 /* Implies PG_COPYRES_ATTRS */47#define PG_COPYRES_EVENTS 0x0448#define PG_COPYRES_NOTICEHOOKS 0x0849 50/* Application-visible enum types */51 52/*53 * Although it is okay to add to these lists, values which become unused54 * should never be removed, nor should constants be redefined - that would55 * break compatibility with existing code.56 */57 58typedef enum59{60 CONNECTION_OK,61 CONNECTION_BAD,62 /* Non-blocking mode only below here */63 64 /*65 * The existence of these should never be relied upon - they should only66 * be used for user feedback or similar purposes.67 */68 CONNECTION_STARTED, /* Waiting for connection to be made. */69 CONNECTION_MADE, /* Connection OK; waiting to send. */70 CONNECTION_AWAITING_RESPONSE, /* Waiting for a response from the71 * postmaster. */72 CONNECTION_AUTH_OK, /* Received authentication; waiting for73 * backend startup. */74 CONNECTION_SETENV, /* This state is no longer used. */75 CONNECTION_SSL_STARTUP, /* Negotiating SSL. */76 CONNECTION_NEEDED, /* Internal state: connect() needed */77 CONNECTION_CHECK_WRITABLE, /* Checking if session is read-write. */78 CONNECTION_CONSUME, /* Consuming any extra messages. */79 CONNECTION_GSS_STARTUP, /* Negotiating GSSAPI. */80 CONNECTION_CHECK_TARGET, /* Checking target server properties. */81 CONNECTION_CHECK_STANDBY /* Checking if server is in standby mode. */82} ConnStatusType;83 84typedef enum85{86 PGRES_POLLING_FAILED = 0,87 PGRES_POLLING_READING, /* These two indicate that one may */88 PGRES_POLLING_WRITING, /* use select before polling again. */89 PGRES_POLLING_OK,90 PGRES_POLLING_ACTIVE /* unused; keep for awhile for backwards91 * compatibility */92} PostgresPollingStatusType;93 94typedef enum95{96 PGRES_EMPTY_QUERY = 0, /* empty query string was executed */97 PGRES_COMMAND_OK, /* a query command that doesn't return98 * anything was executed properly by the99 * backend */100 PGRES_TUPLES_OK, /* a query command that returns tuples was101 * executed properly by the backend, PGresult102 * contains the result tuples */103 PGRES_COPY_OUT, /* Copy Out data transfer in progress */104 PGRES_COPY_IN, /* Copy In data transfer in progress */105 PGRES_BAD_RESPONSE, /* an unexpected response was recv'd from the106 * backend */107 PGRES_NONFATAL_ERROR, /* notice or warning message */108 PGRES_FATAL_ERROR, /* query failed */109 PGRES_COPY_BOTH, /* Copy In/Out data transfer in progress */110 PGRES_SINGLE_TUPLE, /* single tuple from larger resultset */111 PGRES_PIPELINE_SYNC, /* pipeline synchronization point */112 PGRES_PIPELINE_ABORTED /* Command didn't run because of an abort113 * earlier in a pipeline */114} ExecStatusType;115 116typedef enum117{118 PQTRANS_IDLE, /* connection idle */119 PQTRANS_ACTIVE, /* command in progress */120 PQTRANS_INTRANS, /* idle, within transaction block */121 PQTRANS_INERROR, /* idle, within failed transaction */122 PQTRANS_UNKNOWN /* cannot determine status */123} PGTransactionStatusType;124 125typedef enum126{127 PQERRORS_TERSE, /* single-line error messages */128 PQERRORS_DEFAULT, /* recommended style */129 PQERRORS_VERBOSE, /* all the facts, ma'am */130 PQERRORS_SQLSTATE /* only error severity and SQLSTATE code */131} PGVerbosity;132 133typedef enum134{135 PQSHOW_CONTEXT_NEVER, /* never show CONTEXT field */136 PQSHOW_CONTEXT_ERRORS, /* show CONTEXT for errors only (default) */137 PQSHOW_CONTEXT_ALWAYS /* always show CONTEXT field */138} PGContextVisibility;139 140/*141 * PGPing - The ordering of this enum should not be altered because the142 * values are exposed externally via pg_isready.143 */144 145typedef enum146{147 PQPING_OK, /* server is accepting connections */148 PQPING_REJECT, /* server is alive but rejecting connections */149 PQPING_NO_RESPONSE, /* could not establish connection */150 PQPING_NO_ATTEMPT /* connection not attempted (bad params) */151} PGPing;152 153/*154 * PGpipelineStatus - Current status of pipeline mode155 */156typedef enum157{158 PQ_PIPELINE_OFF,159 PQ_PIPELINE_ON,160 PQ_PIPELINE_ABORTED161} PGpipelineStatus;162 163/* PGconn encapsulates a connection to the backend.164 * The contents of this struct are not supposed to be known to applications.165 */166typedef struct pg_conn PGconn;167 168/* PGresult encapsulates the result of a query (or more precisely, of a single169 * SQL command --- a query string given to PQsendQuery can contain multiple170 * commands and thus return multiple PGresult objects).171 * The contents of this struct are not supposed to be known to applications.172 */173typedef struct pg_result PGresult;174 175/* PGcancel encapsulates the information needed to cancel a running176 * query on an existing connection.177 * The contents of this struct are not supposed to be known to applications.178 */179typedef struct pg_cancel PGcancel;180 181/* PGnotify represents the occurrence of a NOTIFY message.182 * Ideally this would be an opaque typedef, but it's so simple that it's183 * unlikely to change.184 * NOTE: in Postgres 6.4 and later, the be_pid is the notifying backend's,185 * whereas in earlier versions it was always your own backend's PID.186 */187typedef struct pgNotify188{189 char *relname; /* notification condition name */190 int be_pid; /* process ID of notifying server process */191 char *extra; /* notification parameter */192 /* Fields below here are private to libpq; apps should not use 'em */193 struct pgNotify *next; /* list link */194} PGnotify;195 196/* Function types for notice-handling callbacks */197typedef void (*PQnoticeReceiver) (void *arg, const PGresult *res);198typedef void (*PQnoticeProcessor) (void *arg, const char *message);199 200/* Print options for PQprint() */201typedef char pqbool;202 203typedef struct _PQprintOpt204{205 pqbool header; /* print output field headings and row count */206 pqbool align; /* fill align the fields */207 pqbool standard; /* old brain dead format */208 pqbool html3; /* output html tables */209 pqbool expanded; /* expand tables */210 pqbool pager; /* use pager for output if needed */211 char *fieldSep; /* field separator */212 char *tableOpt; /* insert to HTML <table ...> */213 char *caption; /* HTML <caption> */214 char **fieldName; /* null terminated array of replacement field215 * names */216} PQprintOpt;217 218/* ----------------219 * Structure for the conninfo parameter definitions returned by PQconndefaults220 * or PQconninfoParse.221 *222 * All fields except "val" point at static strings which must not be altered.223 * "val" is either NULL or a malloc'd current-value string. PQconninfoFree()224 * will release both the val strings and the PQconninfoOption array itself.225 * ----------------226 */227typedef struct _PQconninfoOption228{229 char *keyword; /* The keyword of the option */230 char *envvar; /* Fallback environment variable name */231 char *compiled; /* Fallback compiled in default value */232 char *val; /* Option's current value, or NULL */233 char *label; /* Label for field in connect dialog */234 char *dispchar; /* Indicates how to display this field in a235 * connect dialog. Values are: "" Display236 * entered value as is "*" Password field -237 * hide value "D" Debug option - don't show238 * by default */239 int dispsize; /* Field size in characters for dialog */240} PQconninfoOption;241 242/* ----------------243 * PQArgBlock -- structure for PQfn() arguments244 * ----------------245 */246typedef struct247{248 int len;249 int isint;250 union251 {252 int *ptr; /* can't use void (dec compiler barfs) */253 int integer;254 } u;255} PQArgBlock;256 257/* ----------------258 * PGresAttDesc -- Data about a single attribute (column) of a query result259 * ----------------260 */261typedef struct pgresAttDesc262{263 char *name; /* column name */264 Oid tableid; /* source table, if known */265 int columnid; /* source column, if known */266 int format; /* format code for value (text/binary) */267 Oid typid; /* type id */268 int typlen; /* type size */269 int atttypmod; /* type-specific modifier info */270} PGresAttDesc;271 272/* ----------------273 * Exported functions of libpq274 * ----------------275 */276 277/* === in fe-connect.c === */278 279/* make a new client connection to the backend */280/* Asynchronous (non-blocking) */281extern PGconn *PQconnectStart(const char *conninfo);282extern PGconn *PQconnectStartParams(const char *const *keywords,283 const char *const *values, int expand_dbname);284extern PostgresPollingStatusType PQconnectPoll(PGconn *conn);285 286/* Synchronous (blocking) */287extern PGconn *PQconnectdb(const char *conninfo);288extern PGconn *PQconnectdbParams(const char *const *keywords,289 const char *const *values, int expand_dbname);290extern PGconn *PQsetdbLogin(const char *pghost, const char *pgport,291 const char *pgoptions, const char *pgtty,292 const char *dbName,293 const char *login, const char *pwd);294 295#define PQsetdb(M_PGHOST,M_PGPORT,M_PGOPT,M_PGTTY,M_DBNAME) \296 PQsetdbLogin(M_PGHOST, M_PGPORT, M_PGOPT, M_PGTTY, M_DBNAME, NULL, NULL)297 298/* close the current connection and free the PGconn data structure */299extern void PQfinish(PGconn *conn);300 301/* get info about connection options known to PQconnectdb */302extern PQconninfoOption *PQconndefaults(void);303 304/* parse connection options in same way as PQconnectdb */305extern PQconninfoOption *PQconninfoParse(const char *conninfo, char **errmsg);306 307/* return the connection options used by a live connection */308extern PQconninfoOption *PQconninfo(PGconn *conn);309 310/* free the data structure returned by PQconndefaults() or PQconninfoParse() */311extern void PQconninfoFree(PQconninfoOption *connOptions);312 313/*314 * close the current connection and reestablish a new one with the same315 * parameters316 */317/* Asynchronous (non-blocking) */318extern int PQresetStart(PGconn *conn);319extern PostgresPollingStatusType PQresetPoll(PGconn *conn);320 321/* Synchronous (blocking) */322extern void PQreset(PGconn *conn);323 324/* request a cancel structure */325extern PGcancel *PQgetCancel(PGconn *conn);326 327/* free a cancel structure */328extern void PQfreeCancel(PGcancel *cancel);329 330/* issue a cancel request */331extern int PQcancel(PGcancel *cancel, char *errbuf, int errbufsize);332 333/* backwards compatible version of PQcancel; not thread-safe */334extern int PQrequestCancel(PGconn *conn);335 336/* Accessor functions for PGconn objects */337extern char *PQdb(const PGconn *conn);338extern char *PQuser(const PGconn *conn);339extern char *PQpass(const PGconn *conn);340extern char *PQhost(const PGconn *conn);341extern char *PQhostaddr(const PGconn *conn);342extern char *PQport(const PGconn *conn);343extern char *PQtty(const PGconn *conn);344extern char *PQoptions(const PGconn *conn);345extern ConnStatusType PQstatus(const PGconn *conn);346extern PGTransactionStatusType PQtransactionStatus(const PGconn *conn);347extern const char *PQparameterStatus(const PGconn *conn,348 const char *paramName);349extern int PQprotocolVersion(const PGconn *conn);350extern int PQserverVersion(const PGconn *conn);351extern char *PQerrorMessage(const PGconn *conn);352extern int PQsocket(const PGconn *conn);353extern int PQbackendPID(const PGconn *conn);354extern PGpipelineStatus PQpipelineStatus(const PGconn *conn);355extern int PQconnectionNeedsPassword(const PGconn *conn);356extern int PQconnectionUsedPassword(const PGconn *conn);357extern int PQconnectionUsedGSSAPI(const PGconn *conn);358extern int PQclientEncoding(const PGconn *conn);359extern int PQsetClientEncoding(PGconn *conn, const char *encoding);360 361/* SSL information functions */362extern int PQsslInUse(PGconn *conn);363extern void *PQsslStruct(PGconn *conn, const char *struct_name);364extern const char *PQsslAttribute(PGconn *conn, const char *attribute_name);365extern const char *const *PQsslAttributeNames(PGconn *conn);366 367/* Get the OpenSSL structure associated with a connection. Returns NULL for368 * unencrypted connections or if any other TLS library is in use. */369extern void *PQgetssl(PGconn *conn);370 371/* Tell libpq whether it needs to initialize OpenSSL */372extern void PQinitSSL(int do_init);373 374/* More detailed way to tell libpq whether it needs to initialize OpenSSL */375extern void PQinitOpenSSL(int do_ssl, int do_crypto);376 377/* Return true if GSSAPI encryption is in use */378extern int PQgssEncInUse(PGconn *conn);379 380/* Returns GSSAPI context if GSSAPI is in use */381extern void *PQgetgssctx(PGconn *conn);382 383/* Set verbosity for PQerrorMessage and PQresultErrorMessage */384extern PGVerbosity PQsetErrorVerbosity(PGconn *conn, PGVerbosity verbosity);385 386/* Set CONTEXT visibility for PQerrorMessage and PQresultErrorMessage */387extern PGContextVisibility PQsetErrorContextVisibility(PGconn *conn,388 PGContextVisibility show_context);389 390/* Override default notice handling routines */391extern PQnoticeReceiver PQsetNoticeReceiver(PGconn *conn,392 PQnoticeReceiver proc,393 void *arg);394extern PQnoticeProcessor PQsetNoticeProcessor(PGconn *conn,395 PQnoticeProcessor proc,396 void *arg);397 398/*399 * Used to set callback that prevents concurrent access to400 * non-thread safe functions that libpq needs.401 * The default implementation uses a libpq internal mutex.402 * Only required for multithreaded apps that use kerberos403 * both within their app and for postgresql connections.404 */405typedef void (*pgthreadlock_t) (int acquire);406 407extern pgthreadlock_t PQregisterThreadLock(pgthreadlock_t newhandler);408 409/* === in fe-trace.c === */410extern void PQtrace(PGconn *conn, FILE *debug_port);411extern void PQuntrace(PGconn *conn);412 413/* flags controlling trace output: */414/* omit timestamps from each line */415#define PQTRACE_SUPPRESS_TIMESTAMPS (1<<0)416/* redact portions of some messages, for testing frameworks */417#define PQTRACE_REGRESS_MODE (1<<1)418extern void PQsetTraceFlags(PGconn *conn, int flags);419 420/* === in fe-exec.c === */421 422/* Simple synchronous query */423extern PGresult *PQexec(PGconn *conn, const char *query);424extern PGresult *PQexecParams(PGconn *conn,425 const char *command,426 int nParams,427 const Oid *paramTypes,428 const char *const *paramValues,429 const int *paramLengths,430 const int *paramFormats,431 int resultFormat);432extern PGresult *PQprepare(PGconn *conn, const char *stmtName,433 const char *query, int nParams,434 const Oid *paramTypes);435extern PGresult *PQexecPrepared(PGconn *conn,436 const char *stmtName,437 int nParams,438 const char *const *paramValues,439 const int *paramLengths,440 const int *paramFormats,441 int resultFormat);442 443/* Interface for multiple-result or asynchronous queries */444#define PQ_QUERY_PARAM_MAX_LIMIT 65535445 446extern int PQsendQuery(PGconn *conn, const char *query);447extern int PQsendQueryParams(PGconn *conn,448 const char *command,449 int nParams,450 const Oid *paramTypes,451 const char *const *paramValues,452 const int *paramLengths,453 const int *paramFormats,454 int resultFormat);455extern int PQsendPrepare(PGconn *conn, const char *stmtName,456 const char *query, int nParams,457 const Oid *paramTypes);458extern int PQsendQueryPrepared(PGconn *conn,459 const char *stmtName,460 int nParams,461 const char *const *paramValues,462 const int *paramLengths,463 const int *paramFormats,464 int resultFormat);465extern int PQsetSingleRowMode(PGconn *conn);466extern PGresult *PQgetResult(PGconn *conn);467 468/* Routines for managing an asynchronous query */469extern int PQisBusy(PGconn *conn);470extern int PQconsumeInput(PGconn *conn);471 472/* Routines for pipeline mode management */473extern int PQenterPipelineMode(PGconn *conn);474extern int PQexitPipelineMode(PGconn *conn);475extern int PQpipelineSync(PGconn *conn);476extern int PQsendFlushRequest(PGconn *conn);477 478/* LISTEN/NOTIFY support */479extern PGnotify *PQnotifies(PGconn *conn);480 481/* Routines for copy in/out */482extern int PQputCopyData(PGconn *conn, const char *buffer, int nbytes);483extern int PQputCopyEnd(PGconn *conn, const char *errormsg);484extern int PQgetCopyData(PGconn *conn, char **buffer, int async);485 486/* Deprecated routines for copy in/out */487extern int PQgetline(PGconn *conn, char *buffer, int length);488extern int PQputline(PGconn *conn, const char *string);489extern int PQgetlineAsync(PGconn *conn, char *buffer, int bufsize);490extern int PQputnbytes(PGconn *conn, const char *buffer, int nbytes);491extern int PQendcopy(PGconn *conn);492 493/* Set blocking/nonblocking connection to the backend */494extern int PQsetnonblocking(PGconn *conn, int arg);495extern int PQisnonblocking(const PGconn *conn);496extern int PQisthreadsafe(void);497extern PGPing PQping(const char *conninfo);498extern PGPing PQpingParams(const char *const *keywords,499 const char *const *values, int expand_dbname);500 501/* Force the write buffer to be written (or at least try) */502extern int PQflush(PGconn *conn);503 504/*505 * "Fast path" interface --- not really recommended for application506 * use507 */508extern PGresult *PQfn(PGconn *conn,509 int fnid,510 int *result_buf,511 int *result_len,512 int result_is_int,513 const PQArgBlock *args,514 int nargs);515 516/* Accessor functions for PGresult objects */517extern ExecStatusType PQresultStatus(const PGresult *res);518extern char *PQresStatus(ExecStatusType status);519extern char *PQresultErrorMessage(const PGresult *res);520extern char *PQresultVerboseErrorMessage(const PGresult *res,521 PGVerbosity verbosity,522 PGContextVisibility show_context);523extern char *PQresultErrorField(const PGresult *res, int fieldcode);524extern int PQntuples(const PGresult *res);525extern int PQnfields(const PGresult *res);526extern int PQbinaryTuples(const PGresult *res);527extern char *PQfname(const PGresult *res, int field_num);528extern int PQfnumber(const PGresult *res, const char *field_name);529extern Oid PQftable(const PGresult *res, int field_num);530extern int PQftablecol(const PGresult *res, int field_num);531extern int PQfformat(const PGresult *res, int field_num);532extern Oid PQftype(const PGresult *res, int field_num);533extern int PQfsize(const PGresult *res, int field_num);534extern int PQfmod(const PGresult *res, int field_num);535extern char *PQcmdStatus(PGresult *res);536extern char *PQoidStatus(const PGresult *res); /* old and ugly */537extern Oid PQoidValue(const PGresult *res); /* new and improved */538extern char *PQcmdTuples(PGresult *res);539extern char *PQgetvalue(const PGresult *res, int tup_num, int field_num);540extern int PQgetlength(const PGresult *res, int tup_num, int field_num);541extern int PQgetisnull(const PGresult *res, int tup_num, int field_num);542extern int PQnparams(const PGresult *res);543extern Oid PQparamtype(const PGresult *res, int param_num);544 545/* Describe prepared statements and portals */546extern PGresult *PQdescribePrepared(PGconn *conn, const char *stmt);547extern PGresult *PQdescribePortal(PGconn *conn, const char *portal);548extern int PQsendDescribePrepared(PGconn *conn, const char *stmt);549extern int PQsendDescribePortal(PGconn *conn, const char *portal);550 551/* Delete a PGresult */552extern void PQclear(PGresult *res);553 554/* For freeing other alloc'd results, such as PGnotify structs */555extern void PQfreemem(void *ptr);556 557/* Exists for backward compatibility. bjm 2003-03-24 */558#define PQfreeNotify(ptr) PQfreemem(ptr)559 560/* Error when no password was given. */561/* Note: depending on this is deprecated; use PQconnectionNeedsPassword(). */562#define PQnoPasswordSupplied "fe_sendauth: no password supplied\n"563 564/* Create and manipulate PGresults */565extern PGresult *PQmakeEmptyPGresult(PGconn *conn, ExecStatusType status);566extern PGresult *PQcopyResult(const PGresult *src, int flags);567extern int PQsetResultAttrs(PGresult *res, int numAttributes, PGresAttDesc *attDescs);568extern void *PQresultAlloc(PGresult *res, size_t nBytes);569extern size_t PQresultMemorySize(const PGresult *res);570extern int PQsetvalue(PGresult *res, int tup_num, int field_num, char *value, int len);571 572/* Quoting strings before inclusion in queries. */573extern size_t PQescapeStringConn(PGconn *conn,574 char *to, const char *from, size_t length,575 int *error);576extern char *PQescapeLiteral(PGconn *conn, const char *str, size_t len);577extern char *PQescapeIdentifier(PGconn *conn, const char *str, size_t len);578extern unsigned char *PQescapeByteaConn(PGconn *conn,579 const unsigned char *from, size_t from_length,580 size_t *to_length);581extern unsigned char *PQunescapeBytea(const unsigned char *strtext,582 size_t *retbuflen);583 584/* These forms are deprecated! */585extern size_t PQescapeString(char *to, const char *from, size_t length);586extern unsigned char *PQescapeBytea(const unsigned char *from, size_t from_length,587 size_t *to_length);588 589 590 591/* === in fe-print.c === */592 593extern void PQprint(FILE *fout, /* output stream */594 const PGresult *res,595 const PQprintOpt *po); /* option structure */596 597/*598 * really old printing routines599 */600extern void PQdisplayTuples(const PGresult *res,601 FILE *fp, /* where to send the output */602 int fillAlign, /* pad the fields with spaces */603 const char *fieldSep, /* field separator */604 int printHeader, /* display headers? */605 int quiet);606 607extern void PQprintTuples(const PGresult *res,608 FILE *fout, /* output stream */609 int PrintAttNames, /* print attribute names */610 int TerseOutput, /* delimiter bars */611 int colWidth); /* width of column, if 0, use612 * variable width */613 614 615/* === in fe-lobj.c === */616 617/* Large-object access routines */618extern int lo_open(PGconn *conn, Oid lobjId, int mode);619extern int lo_close(PGconn *conn, int fd);620extern int lo_read(PGconn *conn, int fd, char *buf, size_t len);621extern int lo_write(PGconn *conn, int fd, const char *buf, size_t len);622extern int lo_lseek(PGconn *conn, int fd, int offset, int whence);623extern pg_int64 lo_lseek64(PGconn *conn, int fd, pg_int64 offset, int whence);624extern Oid lo_creat(PGconn *conn, int mode);625extern Oid lo_create(PGconn *conn, Oid lobjId);626extern int lo_tell(PGconn *conn, int fd);627extern pg_int64 lo_tell64(PGconn *conn, int fd);628extern int lo_truncate(PGconn *conn, int fd, size_t len);629extern int lo_truncate64(PGconn *conn, int fd, pg_int64 len);630extern int lo_unlink(PGconn *conn, Oid lobjId);631extern Oid lo_import(PGconn *conn, const char *filename);632extern Oid lo_import_with_oid(PGconn *conn, const char *filename, Oid lobjId);633extern int lo_export(PGconn *conn, Oid lobjId, const char *filename);634 635/* === in fe-misc.c === */636 637/* Get the version of the libpq library in use */638extern int PQlibVersion(void);639 640/* Determine length of multibyte encoded char at *s */641extern int PQmblen(const char *s, int encoding);642 643/* Same, but not more than the distance to the end of string s */644extern int PQmblenBounded(const char *s, int encoding);645 646/* Determine display length of multibyte encoded char at *s */647extern int PQdsplen(const char *s, int encoding);648 649/* Get encoding id from environment variable PGCLIENTENCODING */650extern int PQenv2encoding(void);651 652/* === in fe-auth.c === */653 654extern char *PQencryptPassword(const char *passwd, const char *user);655extern char *PQencryptPasswordConn(PGconn *conn, const char *passwd, const char *user, const char *algorithm);656 657/* === in encnames.c === */658 659extern int pg_char_to_encoding(const char *name);660extern const char *pg_encoding_to_char(int encoding);661extern int pg_valid_server_encoding_id(int encoding);662 663/* === in fe-secure-openssl.c === */664 665/* Support for overriding sslpassword handling with a callback */666typedef int (*PQsslKeyPassHook_OpenSSL_type) (char *buf, int size, PGconn *conn);667extern PQsslKeyPassHook_OpenSSL_type PQgetSSLKeyPassHook_OpenSSL(void);668extern void PQsetSSLKeyPassHook_OpenSSL(PQsslKeyPassHook_OpenSSL_type hook);669extern int PQdefaultSSLKeyPassHook_OpenSSL(char *buf, int size, PGconn *conn);670 671#ifdef __cplusplus672}673#endif674 675#endif /* LIBPQ_FE_H */676 