1 /*
2 
3 Boost Software License - Version 1.0 - August 17th,2003
4 
5 Permission is hereby granted,free of charge,to any person or organization
6 obtaining a copy of the software and accompanying documentation covered by
7 this license (the "Software") to use,reproduce,display,distribute,
8 execute,and transmit the Software,and to prepare derivative works of the
9 Software,and to permit third-parties to whom the Software is furnished to
10 do so,all subject to the following:
11 
12 The copyright notices in the Software and this entire statement,including
13 the above license grant,this restriction and the following disclaimer,
14 must be included in all copies of the Software,in whole or in part,and
15 all derivative works of the Software,unless such copies or derivative
16 works are solely in the form of machine-executable object code generated by
17 a source language processor.
18 
19 THE SOFTWARE IS PROVIDED "AS IS",WITHOUT WARRANTY OF ANY KIND,EXPRESS OR
20 IMPLIED,INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE,TITLE AND NON-INFRINGEMENT. IN NO EVENT
22 SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
23 FOR ANY DAMAGES OR OTHER LIABILITY,WHETHER IN CONTRACT,TORT OR OTHERWISE,
24 ARISING FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25 DEALINGS IN THE SOFTWARE.
26 
27 */
28 module derelict.pq.dynload;
29 
30 version (Derelict_Static)
31 {
32 }
33 else version (DerelictPQ_Static)
34 {
35 }
36 else
37 {
38     version = DerelictPQ_Dynamic;
39 }
40 
41 version (DerelictPQ_Dynamic)  : public import derelict.pq.types;
42 import derelict.util.exception, derelict.util.loader, derelict.util.system;
43 
44 extern (C) @nogc nothrow
45 {
46     alias da_PQconnectStart = PGconn* function(const(char)*);
47     alias da_PQconnectStartParams = PGconn* function(const(char*)*, const(char*)*, int);
48     alias da_PQconnectPoll = PostgresPollingStatusType function(PGconn*);
49 
50     alias da_PQconnectdb = PGconn* function(const(char)*);
51     alias da_PQconnectdbParams = PGconn* function(const(char*)*, const(char*)*, int);
52     alias da_PQsetdbLogin = PGconn* function(const(char)*, const(char)*,
53             const(char)*, const(char)*, const(char)*, const(char)*, const(char)*);
54 
55     alias da_PQfinish = void function(PGconn*);
56 
57     alias da_PQconndefaults = PQconninfoOption* function();
58     alias da_PQconninfoParse = PQconninfoOption* function(const(char)*, char**);
59     alias da_PQconninfo = PQconninfoOption* function(PGconn*);
60     alias da_PQconninfoFree = void function(PQconninfoOption*);
61 
62     alias da_PQresetStart = int function(PGconn*);
63     alias da_PQresetPoll = PostgresPollingStatusType function(PGconn*);
64     alias da_PQreset = void function(PGconn*);
65 
66     alias da_PQgetCancel = PGcancel* function(PGconn*);
67     alias da_PQfreeCancel = void function(PGcancel*);
68     alias da_PQcancel = int function(PGcancel*, char*, int);
69     alias da_PQrequestCancel = int function(PGconn*);
70 
71     alias da_PQdb = char* function(const(PGconn)*);
72     alias da_PQuser = char* function(const(PGconn)*);
73     alias da_PQpass = char* function(const(PGconn)*);
74     alias da_PQhost = char* function(const(PGconn)*);
75     alias da_PQport = char* function(const(PGconn)*);
76     alias da_PQtty = char* function(const(PGconn)*);
77     alias da_PQoptions = char* function(const(PGconn)*);
78     alias da_PQstatus = ConnStatusType function(const(PGconn)*);
79     alias da_PQtransactionStatus = PGTransactionStatusType function(const(PGconn)*);
80     alias da_PQparameterStatus = char* function(const(PGconn)*, const(char)*);
81     alias da_PQprotocolVersion = int function(const(PGconn)*);
82     alias da_PQserverVersion = int function(const(PGconn)*);
83     alias da_PQerrorMessage = char* function(const(PGconn)*);
84     alias da_PQsocket = int function(const(PGconn)*);
85     alias da_PQbackendPID = int function(const(PGconn)*);
86     alias da_PQconnectionNeedsPassword = int function(const(PGconn)*);
87     alias da_PQconnectionUsedPassword = int function(const(PGconn)*);
88     alias da_PQclientEncoding = int function(const(PGconn)*);
89     alias da_PQsetClientEncoding = int function(PGconn*, const(char)*);
90 
91     // The next four are new in 9.5
92     alias da_PQsslInUse = int function(PGconn*);
93     alias da_PQsslStruct = void* function(PGconn*, const(char)*);
94     alias da_PQsslAttribute = const(char)* function(PGconn*, const(char)*);
95     alias da_PQsslAttributeNames = const(char*)* function(PGconn*);
96 
97     alias da_PQgetssl = void* function(PGconn*);
98     alias da_PQinitSSL = void function(int);
99     alias da_PQinitOpenSSL = void function(int, int);
100 
101     alias da_PQsetErrorVerbosity = PGVerbosity function(PGconn*, PGVerbosity);
102     // The next one is new in 9.6
103     alias da_PQsetErrorContextVisibility = PGContextVisibility function(PGconn*,
104             PGContextVisibility);
105     alias da_PQtrace = void function(PGconn*, FILE*);
106     alias da_PQuntrace = void function(PGconn*);
107 
108     alias da_PQsetNoticeReceiver = PQnoticeReceiver function(PGconn*, PQnoticeReceiver, void*);
109     alias da_PQsetNoticeProcessor = PQnoticeProcessor function(PGconn*, PQnoticeProcessor, void*);
110 
111     alias da_PQregisterThreadLock = pgthreadlock_t function(pgthreadlock_t);
112 
113     alias da_PQexec = PGresult* function(PGconn*, const(char)*);
114     alias da_PQexecParams = PGresult* function(PGconn*, const(char)*, int,
115             const(Oid)*, const(ubyte*)*, const(int)*, const int*, int);
116     alias da_PQprepare = PGresult* function(PGconn*, const(char)*,
117             const(char)*, int, const(Oid)*);
118     alias da_PQexecPrepared = PGresult* function(PGconn*, const(char)*, int,
119             const(char*)*, const(int)*, const(int)*, int);
120     alias da_PQsendQuery = int function(PGconn*, const(char)*);
121     alias da_PQsendQueryParams = int function(PGconn*, const(char)*, int,
122             const(Oid)*, const(ubyte*)*, const(int)*, const(int)*, int);
123     alias da_PQsendPrepare = int function(PGconn*, const(char)*,
124             const(char)*, int, const(Oid)*);
125     alias da_PQsendQueryPrepared = int function(PGconn*, const(char)*, int,
126             const(ubyte*)*, const(int)*, const(int)*, int);
127     alias da_PQsetSingleRowMode = int function(PGconn*);
128     alias da_PQgetResult = PGresult* function(PGconn*);
129 
130     alias da_PQisBusy = int function(PGconn*);
131     alias da_PQconsumeInput = int function(PGconn*);
132 
133     alias da_PQnotifies = immutable(PGnotify)* function(PGconn*);
134 
135     alias da_PQputCopyData = int function(PGconn*, const(char)*, int);
136     alias da_PQputCopyEnd = int function(PGconn*, const(char)*);
137     alias da_PQgetCopyData = int function(PGconn*, char**, int);
138 
139     alias da_PQgetline = int function(PGconn*, char*, int);
140     alias da_PQputline = int function(PGconn*, const(char)*);
141     alias da_PQgetlineAsync = int function(PGconn*, char*, int);
142     alias da_PQputnbytes = int function(PGconn*, const(char)*, int);
143     alias da_PQendcopy = int function(PGconn*);
144 
145     alias da_PQsetnonblocking = int function(PGconn*, int);
146     alias da_PQisnonblocking = int function(PGconn*);
147     alias da_PQisthreadsafe = int function();
148     alias da_PQping = PGPing function(const(char)*);
149     alias da_PQpingParams = PGPing function(const(char*)*, const(char*)*, int);
150 
151     alias da_PQflush = int function(PGconn*);
152 
153     alias da_PQfn = PGresult* function(PGconn*, int, int*, int*, int, PQArgBlock*, int);
154     alias da_PQresultStatus = ExecStatusType function(const(PGresult)*);
155     alias da_PQresStatus = char* function(ExecStatusType);
156     alias da_PQresultErrorMessage = char* function(const(PGresult)*);
157     // The next one is new in 9.6
158     alias da_PQresultVerboseErrorMessage = char* function(const(PGresult)*,
159             PGVerbosity, PGContextVisibility);
160     alias da_PQresultErrorField = char* function(const(PGresult)*, int);
161     alias da_PQntuples = int function(const(PGresult)*);
162     alias da_PQnfields = int function(const(PGresult)*);
163     alias da_PQbinaryTuples = int function(const(PGresult)*);
164     alias da_PQfname = char* function(const(PGresult)*, int);
165     alias da_PQfnumber = int function(const(PGresult)*, const(char)*);
166     alias da_PQftable = Oid function(PGresult*, int);
167     alias da_PQftablecol = int function(const(PGresult)*, int);
168     alias da_PQfformat = int function(const(PGresult)*, int);
169     alias da_PQftype = Oid function(const(PGresult)*, int);
170     alias da_PQfsize = int function(const(PGresult)*, int);
171     alias da_PQfmod = int function(const(PGresult)*, int);
172     alias da_PQcmdStatus = char* function(PGresult*);
173     alias da_PQoidStatus = char* function(PGresult*);
174     alias da_PQoidValue = Oid function(const(PGresult)*);
175     alias da_PQcmdTuples = char* function(PGresult*);
176     alias da_PQgetvalue = const(ubyte)* function(const(PGresult)*, int, int);
177     alias da_PQgetlength = int function(const(PGresult)*, int, int);
178     alias da_PQgetisnull = int function(const(PGresult)*, int, int);
179     alias da_PQnparams = int function(const(PGresult)*);
180     alias da_PQparamtype = Oid function(const(PGresult)*, int);
181 
182     alias da_PQdescribePrepared = PGresult* function(PGconn*, const(char)*);
183     alias da_PQdescribePortal = PGresult* function(PGconn*, const(char)*);
184     alias da_PQsendDescribePrepared = int function(PGconn*, const(char)*);
185     alias da_PQsendDescribePortal = int function(PGconn*, const(char)*);
186 
187     alias da_PQclear = void function(const(PGresult)*);
188     alias da_PQfreemem = void function(void*);
189 
190     alias da_PQmakeEmptyPGresult = PGresult* function(PGconn*, ExecStatusType);
191     alias da_PQcopyResult = PGresult* function(const(PGresult)*, int);
192     alias da_PQsetResultAttrs = int function(PGresult*, int, PGresAttDesc*);
193     alias da_PQresultAlloc = void* function(PGresult*, size_t);
194     alias da_PQsetvalue = int function(PGresult*, int, int, char*, int);
195 
196     alias da_PQescapeStringConn = size_t function(PGconn*, char*, char*, size_t, int*);
197     alias da_PQescapeLiteral = char* function(PGconn*, const(char)*, size_t);
198     alias da_PQescapeIdentifier = char* function(PGconn*, const(char)*, size_t);
199     alias da_PQescapeByteaConn = ubyte* function(PGconn*, ubyte*, size_t, size_t*);
200     alias da_PQunescapeBytea = ubyte* function(ubyte*, size_t*);
201 
202     alias da_PQescapeString = size_t function(char*, char*, size_t);
203     alias da_PQescapeBytea = ubyte* function(ubyte*, size_t, size_t*);
204 
205     alias da_PQprint = void function(FILE*, PGresult*, PQprintOpt*);
206     alias da_PQdisplayTuples = void function(PGresult*, FILE*, int, char*, int, int);
207     alias da_PQprintTuples = void function(PGresult*, FILE*, int, int, int);
208 
209     alias da_lo_open = int function(PGconn*, Oid, int);
210     alias da_lo_close = int function(PGconn*, int);
211     alias da_lo_read = int function(PGconn*, int, char*, size_t);
212     alias da_lo_write = int function(PGconn*, int, const(char)*, size_t);
213     alias da_lo_lseek = int function(PGconn*, int, int, int);
214     alias da_lo_lseek64 = pg_int64 function(PGconn*, int, pg_int64, int);
215     alias da_lo_creat = Oid function(PGconn*, int);
216     alias da_lo_create = Oid function(PGconn*, Oid);
217     alias da_lo_tell = int function(PGconn*, int);
218     alias da_lo_tell64 = pg_int64 function(PGconn*, int);
219     alias da_lo_truncate = int function(PGconn*, int, size_t);
220     alias da_lo_truncate64 = int function(PGconn*, int, pg_int64);
221     alias da_lo_unlink = int function(PGconn*, Oid);
222     alias da_lo_import = Oid function(PGconn*, const(char)*);
223     alias da_lo_import_with_oid = Oid function(PGconn*, const(char)*, Oid);
224     alias da_lo_export = int function(PGconn*, Oid, const(char)*);
225 
226     alias da_PQlibVersion = int function();
227     alias da_PQmblen = int function(char*, int);
228     alias da_PQdsplen = int function(char*, int);
229     alias da_PQenv2encoding = int function();
230     alias da_PQencryptPassword = char* function(char*, char*);
231 
232     alias da_pg_char_to_encoding = int function(const(char)*);
233     alias da_pg_encoding_to_char = const(char)* function(int);
234     alias da_pg_valid_server_encoding_id = int function(int);
235 
236     alias da_PQregisterEventProc = int function(PGconn*, PGEventProc, const(char)*, void*);
237     alias da_PQsetInstanceData = int function(PGconn*, PGEventProc, void*);
238 }
239 
240 __gshared
241 {
242     da_PQconnectStart PQconnectStart;
243     da_PQconnectStartParams PQconnectStartParams;
244     da_PQconnectPoll PQconnectPoll;
245     da_PQconnectdb PQconnectdb;
246     da_PQconnectdbParams PQconnectdbParams;
247     da_PQsetdbLogin PQsetdbLogin;
248     da_PQfinish PQfinish;
249     da_PQconndefaults PQconndefaults;
250     da_PQconninfoParse PQconninfoParse;
251     da_PQconninfo PQconninfo;
252     da_PQconninfoFree PQconninfoFree;
253     da_PQresetStart PQresetStart;
254     da_PQresetPoll PQresetPoll;
255     da_PQreset PQreset;
256     da_PQgetCancel PQgetCancel;
257     da_PQfreeCancel PQfreeCancel;
258     da_PQcancel PQcancel;
259     da_PQrequestCancel PQrequestCancel;
260     da_PQdb PQdb;
261     da_PQuser PQuser;
262     da_PQpass PQpass;
263     da_PQhost PQhost;
264     da_PQport PQport;
265     da_PQtty PQtty;
266     da_PQoptions PQoptions;
267     da_PQstatus PQstatus;
268     da_PQtransactionStatus PQtransactionStatus;
269     da_PQparameterStatus PQparameterStatus;
270     da_PQprotocolVersion PQprotocolVersion;
271     da_PQserverVersion PQserverVersion;
272     da_PQerrorMessage PQerrorMessage;
273     da_PQsocket PQsocket;
274     da_PQbackendPID PQbackendPID;
275     da_PQconnectionNeedsPassword PQconnectionNeedsPassword;
276     da_PQconnectionUsedPassword PQconnectionUsedPassword;
277     da_PQclientEncoding PQclientEncoding;
278     da_PQsetClientEncoding PQsetClientEncoding;
279     da_PQsslInUse PQsslInUse;
280     da_PQsslStruct PQsslStruct;
281     da_PQsslAttribute PQsslAttribute;
282     da_PQsslAttributeNames PQsslAttributeNames;
283     da_PQgetssl PQgetssl;
284     da_PQinitSSL PQinitSSL;
285     da_PQinitOpenSSL PQinitOpenSSL;
286     da_PQsetErrorVerbosity PQsetErrorVerbosity;
287     da_PQsetErrorContextVisibility PQsetErrorContextVisibility;
288     da_PQtrace PQtrace;
289     da_PQuntrace PQuntrace;
290     da_PQsetNoticeReceiver PQsetNoticeReceiver;
291     da_PQsetNoticeProcessor PQsetNoticeProcessor;
292     da_PQregisterThreadLock PQregisterThreadLock;
293     da_PQexec PQexec;
294     da_PQexecParams PQexecParams;
295     da_PQprepare PQprepare;
296     da_PQexecPrepared PQexecPrepared;
297     da_PQsendQuery PQsendQuery;
298     da_PQsendQueryParams PQsendQueryParams;
299     da_PQsendPrepare PQsendPrepare;
300     da_PQsendQueryPrepared PQsendQueryPrepared;
301     da_PQsetSingleRowMode PQsetSingleRowMode;
302     da_PQgetResult PQgetResult;
303     da_PQisBusy PQisBusy;
304     da_PQconsumeInput PQconsumeInput;
305     da_PQnotifies PQnotifies;
306     da_PQputCopyData PQputCopyData;
307     da_PQputCopyEnd PQputCopyEnd;
308     da_PQgetCopyData PQgetCopyData;
309     da_PQgetline PQgetline;
310     da_PQputline PQputline;
311     da_PQgetlineAsync PQgetlineAsync;
312     da_PQputnbytes PQputnbytes;
313     da_PQendcopy PQendcopy;
314     da_PQsetnonblocking PQsetnonblocking;
315     da_PQisnonblocking PQisnonblocking;
316     da_PQisthreadsafe PQisthreadsafe;
317     da_PQping PQping;
318     da_PQpingParams PQpingParams;
319     da_PQflush PQflush;
320     da_PQfn PQfn;
321     da_PQresultStatus PQresultStatus;
322     da_PQresStatus PQresStatus;
323     da_PQresultErrorMessage PQresultErrorMessage;
324     da_PQresultVerboseErrorMessage PQresultVerboseErrorMessage;
325     da_PQresultErrorField PQresultErrorField;
326     da_PQntuples PQntuples;
327     da_PQnfields PQnfields;
328     da_PQbinaryTuples PQbinaryTuples;
329     da_PQfname PQfname;
330     da_PQfnumber PQfnumber;
331     da_PQftable PQftable;
332     da_PQftablecol PQftablecol;
333     da_PQfformat PQfformat;
334     da_PQftype PQftype;
335     da_PQfsize PQfsize;
336     da_PQfmod PQfmod;
337     da_PQcmdStatus PQcmdStatus;
338     da_PQoidStatus PQoidStatus;
339     da_PQoidValue PQoidValue;
340     da_PQcmdTuples PQcmdTuples;
341     da_PQgetvalue PQgetvalue;
342     da_PQgetlength PQgetlength;
343     da_PQgetisnull PQgetisnull;
344     da_PQnparams PQnparams;
345     da_PQparamtype PQparamtype;
346     da_PQdescribePrepared PQdescribePrepared;
347     da_PQdescribePortal PQdescribePortal;
348     da_PQsendDescribePrepared PQsendDescribePrepared;
349     da_PQsendDescribePortal PQsendDescribePortal;
350     da_PQclear PQclear;
351     da_PQfreemem PQfreemem;
352     da_PQmakeEmptyPGresult PQmakeEmptyPGresult;
353     da_PQcopyResult PQcopyResult;
354     da_PQsetResultAttrs PQsetResultAttrs;
355     da_PQresultAlloc PQresultAlloc;
356     da_PQsetvalue PQsetvalue;
357     da_PQescapeStringConn PQescapeStringConn;
358     da_PQescapeLiteral PQescapeLiteral;
359     da_PQescapeIdentifier PQescapeIdentifier;
360     da_PQescapeByteaConn PQescapeByteaConn;
361     da_PQunescapeBytea PQunescapeBytea;
362     da_PQescapeString PQescapeString;
363     da_PQescapeBytea PQescapeBytea;
364     da_PQprint PQprint;
365     da_PQdisplayTuples PQdisplayTuples;
366     da_PQprintTuples PQprintTuples;
367     da_lo_open lo_open;
368     da_lo_close lo_close;
369     da_lo_read lo_read;
370     da_lo_write lo_write;
371     da_lo_lseek lo_lseek;
372     da_lo_lseek64 lo_lseek64;
373     da_lo_creat lo_creat;
374     da_lo_create lo_create;
375     da_lo_tell lo_tell;
376     da_lo_tell64 lo_tell64;
377     da_lo_truncate lo_truncate;
378     da_lo_truncate64 lo_truncate64;
379     da_lo_unlink lo_unlink;
380     da_lo_import lo_import;
381     da_lo_import_with_oid lo_import_with_oid;
382     da_lo_export lo_export;
383     da_PQlibVersion PQlibVersion;
384     da_PQmblen PQmblen;
385     da_PQdsplen PQdsplen;
386     da_PQenv2encoding PQenv2encoding;
387     da_PQencryptPassword PQencryptPassword;
388     da_pg_char_to_encoding pg_char_to_encoding;
389     da_pg_encoding_to_char pg_encoding_to_char;
390     da_pg_valid_server_encoding_id pg_valid_server_encoding_id;
391     da_PQregisterEventProc PQregisterEventProc;
392     da_PQsetInstanceData PQsetInstanceData;
393 }
394 
395 class DerelictPQLoader : SharedLibLoader
396 {
397     this()
398     {
399         super(libNames);
400     }
401 
402     protected override void loadSymbols()
403     {
404         bindFunc(cast(void**)&PQconnectStart, "PQconnectStart");
405         bindFunc(cast(void**)&PQconnectStartParams, "PQconnectStartParams");
406         bindFunc(cast(void**)&PQconnectPoll, "PQconnectPoll");
407         bindFunc(cast(void**)&PQconnectdb, "PQconnectdb");
408         bindFunc(cast(void**)&PQconnectdbParams, "PQconnectdbParams");
409         bindFunc(cast(void**)&PQsetdbLogin, "PQsetdbLogin");
410         bindFunc(cast(void**)&PQfinish, "PQfinish");
411         bindFunc(cast(void**)&PQconndefaults, "PQconndefaults");
412         bindFunc(cast(void**)&PQconninfoParse, "PQconninfoParse");
413         bindFunc(cast(void**)&PQconninfoFree, "PQconninfoFree");
414         bindFunc(cast(void**)&PQresetStart, "PQresetStart");
415         bindFunc(cast(void**)&PQresetPoll, "PQresetPoll");
416         bindFunc(cast(void**)&PQreset, "PQreset");
417         bindFunc(cast(void**)&PQgetCancel, "PQgetCancel");
418         bindFunc(cast(void**)&PQfreeCancel, "PQfreeCancel");
419         bindFunc(cast(void**)&PQcancel, "PQcancel");
420         bindFunc(cast(void**)&PQrequestCancel, "PQrequestCancel");
421         bindFunc(cast(void**)&PQdb, "PQdb");
422         bindFunc(cast(void**)&PQuser, "PQuser");
423         bindFunc(cast(void**)&PQpass, "PQpass");
424         bindFunc(cast(void**)&PQhost, "PQhost");
425         bindFunc(cast(void**)&PQport, "PQport");
426         bindFunc(cast(void**)&PQtty, "PQtty");
427         bindFunc(cast(void**)&PQoptions, "PQoptions");
428         bindFunc(cast(void**)&PQstatus, "PQstatus");
429         bindFunc(cast(void**)&PQtransactionStatus, "PQtransactionStatus");
430         bindFunc(cast(void**)&PQparameterStatus, "PQparameterStatus");
431         bindFunc(cast(void**)&PQprotocolVersion, "PQprotocolVersion");
432         bindFunc(cast(void**)&PQserverVersion, "PQserverVersion");
433         bindFunc(cast(void**)&PQerrorMessage, "PQerrorMessage");
434         bindFunc(cast(void**)&PQsocket, "PQsocket");
435         bindFunc(cast(void**)&PQbackendPID, "PQbackendPID");
436         bindFunc(cast(void**)&PQconnectionNeedsPassword, "PQconnectionNeedsPassword");
437         bindFunc(cast(void**)&PQconnectionUsedPassword, "PQconnectionUsedPassword");
438         bindFunc(cast(void**)&PQclientEncoding, "PQclientEncoding");
439         bindFunc(cast(void**)&PQsetClientEncoding, "PQsetClientEncoding");
440         bindFunc(cast(void**)&PQsslInUse, "PQsslInUse");
441         bindFunc(cast(void**)&PQsslStruct, "PQsslStruct");
442         bindFunc(cast(void**)&PQsslAttribute, "PQsslAttribute");
443         bindFunc(cast(void**)&PQsslAttributeNames, "PQsslAttributeNames");
444         bindFunc(cast(void**)&PQgetssl, "PQgetssl");
445         bindFunc(cast(void**)&PQinitSSL, "PQinitSSL");
446         bindFunc(cast(void**)&PQinitOpenSSL, "PQinitOpenSSL");
447         bindFunc(cast(void**)&PQsetErrorVerbosity, "PQsetErrorVerbosity");
448         bindFunc(cast(void**)&PQsetErrorContextVisibility, "PQsetErrorContextVisibility");
449         bindFunc(cast(void**)&PQtrace, "PQtrace");
450         bindFunc(cast(void**)&PQuntrace, "PQuntrace");
451         bindFunc(cast(void**)&PQsetNoticeReceiver, "PQsetNoticeReceiver");
452         bindFunc(cast(void**)&PQsetNoticeProcessor, "PQsetNoticeProcessor");
453         bindFunc(cast(void**)&PQregisterThreadLock, "PQregisterThreadLock");
454         bindFunc(cast(void**)&PQexec, "PQexec");
455         bindFunc(cast(void**)&PQexecParams, "PQexecParams");
456         bindFunc(cast(void**)&PQprepare, "PQprepare");
457         bindFunc(cast(void**)&PQexecPrepared, "PQexecPrepared");
458         bindFunc(cast(void**)&PQsendQuery, "PQsendQuery");
459         bindFunc(cast(void**)&PQsendQueryParams, "PQsendQueryParams");
460         bindFunc(cast(void**)&PQsendPrepare, "PQsendPrepare");
461         bindFunc(cast(void**)&PQsendQueryPrepared, "PQsendQueryPrepared");
462         bindFunc(cast(void**)&PQgetResult, "PQgetResult");
463         bindFunc(cast(void**)&PQisBusy, "PQisBusy");
464         bindFunc(cast(void**)&PQconsumeInput, "PQconsumeInput");
465         bindFunc(cast(void**)&PQnotifies, "PQnotifies");
466         bindFunc(cast(void**)&PQputCopyData, "PQputCopyData");
467         bindFunc(cast(void**)&PQputCopyEnd, "PQputCopyEnd");
468         bindFunc(cast(void**)&PQgetCopyData, "PQgetCopyData");
469         bindFunc(cast(void**)&PQgetline, "PQgetline");
470         bindFunc(cast(void**)&PQputline, "PQputline");
471         bindFunc(cast(void**)&PQgetlineAsync, "PQgetlineAsync");
472         bindFunc(cast(void**)&PQputnbytes, "PQputnbytes");
473         bindFunc(cast(void**)&PQendcopy, "PQendcopy");
474         bindFunc(cast(void**)&PQsetnonblocking, "PQsetnonblocking");
475         bindFunc(cast(void**)&PQisnonblocking, "PQisnonblocking");
476         bindFunc(cast(void**)&PQisthreadsafe, "PQisthreadsafe");
477         bindFunc(cast(void**)&PQping, "PQping");
478         bindFunc(cast(void**)&PQpingParams, "PQpingParams");
479         bindFunc(cast(void**)&PQflush, "PQflush");
480         bindFunc(cast(void**)&PQfn, "PQfn");
481         bindFunc(cast(void**)&PQresultStatus, "PQresultStatus");
482         bindFunc(cast(void**)&PQresStatus, "PQresStatus");
483         bindFunc(cast(void**)&PQresultErrorMessage, "PQresultErrorMessage");
484         bindFunc(cast(void**)&PQresultVerboseErrorMessage, "PQresultVerboseErrorMessage");
485         bindFunc(cast(void**)&PQresultErrorField, "PQresultErrorField");
486         bindFunc(cast(void**)&PQntuples, "PQntuples");
487         bindFunc(cast(void**)&PQnfields, "PQnfields");
488         bindFunc(cast(void**)&PQbinaryTuples, "PQbinaryTuples");
489         bindFunc(cast(void**)&PQfname, "PQfname");
490         bindFunc(cast(void**)&PQfnumber, "PQfnumber");
491         bindFunc(cast(void**)&PQftable, "PQftable");
492         bindFunc(cast(void**)&PQftablecol, "PQftablecol");
493         bindFunc(cast(void**)&PQfformat, "PQfformat");
494         bindFunc(cast(void**)&PQftype, "PQftype");
495         bindFunc(cast(void**)&PQfsize, "PQfsize");
496         bindFunc(cast(void**)&PQfmod, "PQfmod");
497         bindFunc(cast(void**)&PQcmdStatus, "PQcmdStatus");
498         bindFunc(cast(void**)&PQoidStatus, "PQoidStatus");
499         bindFunc(cast(void**)&PQoidValue, "PQoidValue");
500         bindFunc(cast(void**)&PQcmdTuples, "PQcmdTuples");
501         bindFunc(cast(void**)&PQgetvalue, "PQgetvalue");
502         bindFunc(cast(void**)&PQgetlength, "PQgetlength");
503         bindFunc(cast(void**)&PQgetisnull, "PQgetisnull");
504         bindFunc(cast(void**)&PQnparams, "PQnparams");
505         bindFunc(cast(void**)&PQparamtype, "PQparamtype");
506         bindFunc(cast(void**)&PQdescribePrepared, "PQdescribePrepared");
507         bindFunc(cast(void**)&PQdescribePortal, "PQdescribePortal");
508         bindFunc(cast(void**)&PQsendDescribePrepared, "PQsendDescribePrepared");
509         bindFunc(cast(void**)&PQsendDescribePortal, "PQsendDescribePortal");
510         bindFunc(cast(void**)&PQclear, "PQclear");
511         bindFunc(cast(void**)&PQfreemem, "PQfreemem");
512         bindFunc(cast(void**)&PQmakeEmptyPGresult, "PQmakeEmptyPGresult");
513         bindFunc(cast(void**)&PQcopyResult, "PQcopyResult");
514         bindFunc(cast(void**)&PQsetResultAttrs, "PQsetResultAttrs");
515         bindFunc(cast(void**)&PQresultAlloc, "PQresultAlloc");
516         bindFunc(cast(void**)&PQsetvalue, "PQsetvalue");
517         bindFunc(cast(void**)&PQescapeStringConn, "PQescapeStringConn");
518         bindFunc(cast(void**)&PQescapeLiteral, "PQescapeLiteral");
519         bindFunc(cast(void**)&PQescapeIdentifier, "PQescapeIdentifier");
520         bindFunc(cast(void**)&PQescapeByteaConn, "PQescapeByteaConn");
521         bindFunc(cast(void**)&PQunescapeBytea, "PQunescapeBytea");
522         bindFunc(cast(void**)&PQescapeString, "PQescapeString");
523         bindFunc(cast(void**)&PQescapeBytea, "PQescapeBytea");
524         bindFunc(cast(void**)&PQprint, "PQprint");
525         bindFunc(cast(void**)&PQdisplayTuples, "PQdisplayTuples");
526         bindFunc(cast(void**)&PQprintTuples, "PQprintTuples");
527         bindFunc(cast(void**)&lo_open, "lo_open");
528         bindFunc(cast(void**)&lo_close, "lo_close");
529         bindFunc(cast(void**)&lo_read, "lo_read");
530         bindFunc(cast(void**)&lo_write, "lo_write");
531         bindFunc(cast(void**)&lo_lseek, "lo_lseek");
532         bindFunc(cast(void**)&lo_creat, "lo_creat");
533         bindFunc(cast(void**)&lo_create, "lo_create");
534         bindFunc(cast(void**)&lo_tell, "lo_tell");
535         bindFunc(cast(void**)&lo_truncate, "lo_truncate");
536         bindFunc(cast(void**)&lo_unlink, "lo_unlink");
537         bindFunc(cast(void**)&lo_import, "lo_import");
538         bindFunc(cast(void**)&lo_import_with_oid, "lo_import_with_oid");
539         bindFunc(cast(void**)&lo_export, "lo_export");
540         bindFunc(cast(void**)&PQlibVersion, "PQlibVersion");
541         bindFunc(cast(void**)&PQmblen, "PQmblen");
542         bindFunc(cast(void**)&PQdsplen, "PQdsplen");
543         bindFunc(cast(void**)&PQenv2encoding, "PQenv2encoding");
544         bindFunc(cast(void**)&PQencryptPassword, "PQencryptPassword");
545         bindFunc(cast(void**)&pg_char_to_encoding, "pg_char_to_encoding");
546         bindFunc(cast(void**)&pg_encoding_to_char, "pg_encoding_to_char");
547         bindFunc(cast(void**)&pg_valid_server_encoding_id, "pg_valid_server_encoding_id");
548         bindFunc(cast(void**)&PQregisterEventProc, "PQregisterEventProc");
549         bindFunc(cast(void**)&PQsetInstanceData, "PQsetInstanceData");
550         bindFunc(cast(void**)&PQsetSingleRowMode, "PQsetSingleRowMode");
551         bindFunc(cast(void**)&PQconninfo, "PQconninfo");
552         bindFunc(cast(void**)&lo_lseek64, "lo_lseek64");
553         bindFunc(cast(void**)&lo_tell64, "lo_tell64");
554         bindFunc(cast(void**)&lo_truncate64, "lo_truncate64");
555     }
556 }
557 
558 __gshared DerelictPQLoader DerelictPQ;
559 
560 shared static this()
561 {
562     DerelictPQ = new DerelictPQLoader();
563 }
564 
565 private:
566 
567 static if (Derelict_OS_Windows)
568 {
569     enum libNames = "libpq.dll";
570 }
571 else static if (Derelict_OS_Mac)
572 {
573     enum libNames = "libpq.dylib";
574 }
575 else static if (Derelict_OS_Posix)
576 {
577     enum libNames = "libpq.so";
578 }
579 else
580 {
581     static assert(0, "Need to implement PostgreSQL libNames for this operating system.");
582 }