diff --git a/DerelictPQ/.gitignore b/DerelictPQ/.gitignore deleted file mode 100644 index fe764df0..00000000 --- a/DerelictPQ/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -lib -bin -.dub -update.txt \ No newline at end of file diff --git a/DerelictPQ/package.json b/DerelictPQ/package.json deleted file mode 100644 index 9079f8b9..00000000 --- a/DerelictPQ/package.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name": "derelict-pq", - "description": "A dynamic binding to the PostgreSQL pq library.", - "homepage": "https://github.com/DerelictOrg/DerelictPQ", - "license": "Boost", - "authors": [ - "Mike Parker" - ], - - "targetName": "DerelictPQ", - "targetPath": "lib", - - "dependencies": { - "derelict-util": "~master" - } -} diff --git a/DerelictPQ/source/derelict/pq/functions.d b/DerelictPQ/source/derelict/pq/functions.d deleted file mode 100644 index 64993834..00000000 --- a/DerelictPQ/source/derelict/pq/functions.d +++ /dev/null @@ -1,358 +0,0 @@ -/* - -Boost Software License - Version 1.0 - August 17th, 2003 - -Permission is hereby granted, free of charge, to any person or organization -obtaining a copy of the software and accompanying documentation covered by -this license (the "Software") to use, reproduce, display, distribute, -execute, and transmit the Software, and to prepare derivative works of the -Software, and to permit third-parties to whom the Software is furnished to -do so, all subject to the following: - -The copyright notices in the Software and this entire statement, including -the above license grant, this restriction and the following disclaimer, -must be included in all copies of the Software, in whole or in part, and -all derivative works of the Software, unless such copies or derivative -works are solely in the form of machine-executable object code generated by -a source language processor. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT -SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE -FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -DEALINGS IN THE SOFTWARE. - -*/ -module derelict.pq.functions; - -import derelict.pq.types; - -extern(C) nothrow -{ - /* Asynchronous (non-blocking) */ - alias PGconn* function(char* connInfo) da_PQconnectStart; - alias PGconn* function(char** keywords, char** values, int expand_dbname) da_PQconnectStartParams; - alias PostgresPollingStatusType function(PGconn* conn) da_PQconnectPoll; - /* Synchronous (blocking) */ - alias PGconn* function(immutable char* connInfo) da_PQconnectdb; - alias PGconn* function(char** keywords, char** values, int expand_dbname) da_PQconnectdbParams; - alias PGconn* function(char* pghost, char* pgport, char* pgoptions, char* pgtty, char* dbName, char* login, char* pwd) da_PQsetdbLogin; - - alias void function(PGconn* conn) da_PQfinish; - - alias PQconninfoOption* function() da_PQconndefaults; - alias PQconninfoOption* function(char* conninfo, char** errmsg) da_PQconninfoParse; - alias PQconninfoOption* function(PGconn* conn) da_PQconninfo; - alias void function(PQconninfoOption* connOptions) da_PQconninfoFree; - - alias int function(PGconn* conn) da_PQresetStart; - alias PostgresPollingStatusType function(PGconn*) da_PQresetPoll; - alias void function(PGconn* conn) da_PQreset; - - alias PGcancel* function(PGconn* conn) da_PQgetCancel; - alias void function(PGcancel* cancel) da_PQfreeCancel; - alias int function(PGcancel* cancel, char* errbuf, int errbufsize) da_PQcancel; - alias int function(PGconn* conn) da_PQrequestCancel; - - alias char* function(PGconn* conn) da_PQdb; - alias char* function(PGconn* conn) da_PQuser; - alias char* function(PGconn* conn) da_PQpass; - alias char* function(PGconn* conn) da_PQhost; - alias char* function(PGconn* conn) da_PQport; - alias char* function(PGconn* conn) da_PQtty; - alias char* function(PGconn* conn) da_PQoptions; - alias ConnStatusType function(PGconn* conn) da_PQstatus; - - alias PGTransactionStatusType function(PGconn* conn) da_PQtransactionStatus; - alias char* function(PGconn* conn, char* paramName) da_PQparameterStatus; - alias int function(PGconn* conn) da_PQprotocolVersion; - alias int function(PGconn* conn) da_PQserverVersion; - alias char* function(PGconn* conn) da_PQerrorMessage; - alias int function(PGconn* conn) da_PQsocket; - alias int function(PGconn* conn) da_PQbackendPID; - alias int function(PGconn* conn) da_PQconnectionNeedsPassword; - alias int function(PGconn* conn) da_PQconnectionUsedPassword; - alias int function(PGconn* conn) da_PQclientEncoding; - alias int function(PGconn* conn, char* encoding) da_PQsetClientEncoding; - - alias void* function(PGconn* conn) da_PQgetssl; - alias void function(int do_init) da_PQinitSSL; - alias void function(int do_ssl, int do_crypto) da_PQinitOpenSSL; - - alias PGVerbosity function(PGconn conn, PGVerbosity verbosity) da_PQsetErrorVerbosity; - alias void function(PGconn* conn, FILE* debug_port) da_PQtrace; - alias void function(PGconn* conn) da_PQuntrace; - - alias PQnoticeReceiver function(PGconn* conn, PQnoticeReceiver proc, void* arg) da_PQsetNoticeReceiver; - alias PQnotcieProcessor function(PGconn* conn, PQnotcieProcessor proc, void* arg) da_PQsetNoticeProcessor; - - alias pgthreadlock_t function(pgthreadlock_t newhandler) da_PQregisterThreadLock; - /* Simple synchronous query */ - alias PGresult* function(PGconn* conn, const(char)* query) da_PQexec; - alias PGresult* function(PGconn* conn, const(char)* command, int nParams, Oid* paramTypes, const(ubyte)** paramValues, int* paramLengths, int* paramFormats, int resultFormat) da_PQexecParams; - alias PGresult* function(PGconn* conn, char* stmtName, char* query, int nParams, Oid* paramTypes) da_PQprepare; - alias PGresult* function(PGconn* conn, char* stmtName, int nParams, char** paramValues, int* paramFormats, int resultFormat) da_PQexecPrepared; - alias int function(PGconn* conn, const(char)* query) da_PQsendQuery; - alias int function(PGconn* conn, const(char)* command, int nParams, Oid* paramTypes, const(ubyte)** paramValues, int* paramLengths, int* paramFormats, int resultFormat) da_PQsendQueryParams; - alias int function(PGconn* conn, char* stmtName, char* query, int nParams, Oid* paramTypes) da_PQsendPrepare; - alias int function(PGconn* conn, char* stmtName, int nParams, char** paramValues, int* paramLengths, int* paramFormats, int resultFormat) da_PQsendQueryPrepared; - alias int function(PGconn* conn) da_PQsetSingleRowMode; - alias PGresult* function(PGconn* conn) da_PQgetResult; - /* Routines for managing an asynchronous query */ - alias int function(PGconn* conn) da_PQisBusy; - alias int function(PGconn* conn) da_PQconsumeInput; - /* LISTEN/NOTIFY support */ - alias immutable (PGnotify)* function(PGconn* conn) da_PQnotifies; - /* Routines for copy in/out */ - alias int function(PGconn* conn, char* buffer, int nbytes) da_PQputCopyData; - alias int function(PGconn* conn, char* errormsg) da_PQputCopyEnd; - alias int function(PGconn* conn, char** buffer, int async) da_PQgetCopyData; - /* Deprecated routines for copy in/out */ - alias int function(PGconn* conn, char* string, int length) da_PQgetline; - alias int function(PGconn* conn, char* string) da_PQputline; - alias int function(PGconn* conn, char* buffer, int bufsize) da_PQgetlineAsync; - alias int function(PGconn* conn, char* buffer, int nbytes) da_PQputnbytes; - alias int function(PGconn* conn) da_PQendcopy; - /* Set blocking/nonblocking connection to the backend */ - alias int function(PGconn* conn, int arg) da_PQsetnonblocking; - alias int function(PGconn* conn) da_PQisnonblocking; - alias int function() da_PQisthreadsafe; - alias PGPing function(char* conninfo) da_PQping; - alias PGPing function(char** keywords, char** values, int expand_dbname) da_PQpingParams; - - alias int function(PGconn* conn) da_PQflush; - /* Accessor functions for PGresult objects */ - alias PGresult* function(PGconn* conn, int fnid, int* result_buf, int* result_len, int result_is_int, PQArgBlock* args, int nargs) da_PQfn; - alias ExecStatusType function(const(PGresult)* res) da_PQresultStatus; - alias char* function(ExecStatusType status) da_PQresStatus; - alias char* function(const(PGresult)* res) da_PQresultErrorMessage; - alias char* function(PGresult* res, int fieldcode) da_PQresultErrorField; - alias int function(const(PGresult)* res) da_PQntuples; - alias int function(const(PGresult)* res) da_PQnfields; - alias int function(PGresult* res) da_PQbinaryTuples; - alias char* function(PGresult* res, int field_num) da_PQfname; - alias int function(const(PGresult)* res, immutable char* field_name) da_PQfnumber; - alias Oid function(PGresult* res, int field_num) da_PQftable; - alias int function(PGresult* res, int field_num) da_PQftablecol; - alias valueFormat function(const(PGresult)* res, int field_num) da_PQfformat; - alias Oid function(const(PGresult)* res, int field_num) da_PQftype; - alias int function(PGresult* res, int field_num) da_PQfsize; - alias int function(PGresult* res, int field_num) da_PQfmod; - alias char* function(const(PGresult)* res) da_PQcmdStatus; - alias char* function(PGresult* res) da_PQoidStatus; - alias Oid function(PGresult* res) da_PQoidValue; - alias char* function(PGresult* res) da_PQcmdTuples; - alias immutable(ubyte)* function(const(PGresult)* res, int tup_num, int field_num) da_PQgetvalue; - alias int function(const(PGresult)* res, int tup_num, int field_num) da_PQgetlength; - alias int function(const(PGresult)* res, int tup_num, int field_num) da_PQgetisnull; - alias int function(PGresult* res) da_PQnparams; - alias Oid function(PGresult* res, int param_num) da_PQparamtype; - /* Describe prepared statements and portals */ - alias PGresult* function(PGconn* conn, char* stmt) da_PQdescribePrepared; - alias PGresult* function(PGconn* conn, char* portal) da_PQdescribePortal; - alias int function(PGconn* conn, char* stmt) da_PQsendDescribePrepared; - alias int function(PGconn* conn, char* portal) da_PQsendDescribePortal; - - alias void function(const(PGresult)* res) da_PQclear; - alias void function(void* ptr) da_PQfreemem; - /* Create and manipulate PGresults */ - alias PGresult* function(PGconn* conn, ExecStatusType status) da_PQmakeEmptyPGresult; - alias PGresult* function(const(PGresult)* src, int flags) da_PQcopyResult; - alias int function(PGresult* res, int numAttributes, PGresAttDesc* attDescs) da_PQsetResultAttrs; - alias void* function(PGresult* res, size_t nBytes) da_PQresultAlloc; - alias int function(PGresult* res, int tup_num, int field_num, char* value, int len) da_PQsetvalue; - /* Quoting strings before inclusion in queries. */ - alias size_t function(PGconn* conn, char* to, char* from, size_t length, int* error) da_PQescapeStringConn; - alias char* function(PGconn* conn, const(char)* str, size_t len) da_PQescapeLiteral; - alias char* function(PGconn* conn, const(char)* str, size_t length) da_PQescapeIdentifier; - alias ubyte* function(PGconn* conn, ubyte* from, size_t from_length, size_t* to_length) da_PQescapeByteaConn; - alias ubyte* function(ubyte* strtext, size_t* retbuflen) da_PQunescapeBytea; - /* These forms are deprecated! */ - alias size_t function(char* to, char* from, size_t length) da_PQescapeString; - alias ubyte* function(ubyte* from, size_t from_length, size_t* to_length) da_PQescapeBytea; - - alias void function(FILE* fout, PGresult* res, PQprintOpt* ps) da_PQprint; - alias void function(PGresult* res, FILE* fp, int fillAlign, char* fieldSep, int printHeader, int quiet) da_PQdisplayTuples; - alias void function(PGresult* res, FILE* fout, int printAttName, int terseOutput, int width) da_PQprintTuples; - /* Large-object access routines */ - alias int function(PGconn* conn, Oid lobjId, int mode) da_lo_open; - alias int function(PGconn* conn, int fd) da_lo_close; - alias int function(PGconn* conn, int fd, char* fuf, size_t len) da_lo_read; - alias int function(PGconn* conn, int fd, const(char)* buf, size_t len) da_lo_write; - alias int function(PGconn* conn, int fd, int offset, int whence) da_lo_lseek; - alias pg_int64 function(PGconn* conn, int fd, pg_int64 offset, int whence) da_lo_lseek64; - alias Oid function(PGconn* conn, int mode) da_lo_creat; - alias Oid function(PGconn* conn, Oid lobjId) da_lo_create; - alias int function(PGconn* conn, int fd) da_lo_tell; - alias pg_int64 function(PGconn* conn, int fd) da_lo_tell64; - alias int function(PGconn* conn, int fd, size_t len) da_lo_truncate; - alias int function(PGconn* conn, int fd, pg_int64 len) da_lo_truncate64; - alias int function(PGconn* conn, Oid lobjId) da_lo_unlink; - alias Oid function(PGconn* conn, const(char)* filename) da_lo_import; - alias Oid function(PGconn* conn, const(char)* filename, Oid lobjId) da_lo_import_with_oid; - alias int function(PGconn* conn, Oid lobjId, const(char)* filename) da_lo_export; - - alias int function() da_PQlibVersion; - alias int function(char* s, int encoding) da_PQmblen; - alias int function(char* s, int encoding) da_PQdsplen; - alias int function() da_PQenv2encoding; - alias char* function(char* passwd, char* user) da_PQencryptPassword; - - alias int function(const(char)* name) da_pg_char_to_encoding; - alias const(char)* function(int encoding) da_pg_encoding_to_char; - alias int function(int encoding) da_pg_valid_server_encoding_id; - - alias int function(PGconn* conn, PGEventProc proc, immutable char* name, void* passThrough) da_PQregisterEventProc; - alias int function(PGconn* conn, PGEventProc proc, void* data) da_PQsetInstanceData; -} - -__gshared -{ - da_PQconnectStart PQconnectStart; - da_PQconnectStartParams PQconnectStartParams; - da_PQconnectPoll PQconnectPoll; - da_PQconnectdb PQconnectdb; - da_PQconnectdbParams PQconnectdbParams; - da_PQsetdbLogin PQsetdbLogin; - da_PQfinish PQfinish; - da_PQconndefaults PQconndefaults; - da_PQconninfoParse PQconninfoParse; - da_PQconninfo PQconninfo; - da_PQconninfoFree PQconninfoFree; - da_PQresetStart PQresetStart; - da_PQresetPoll PQresetPoll; - da_PQreset PQreset; - da_PQgetCancel PQgetCancel; - da_PQfreeCancel PQfreeCancel; - da_PQcancel PQcancel; - da_PQrequestCancel PQrequestCancel; - da_PQdb PQdb; - da_PQuser PQuser; - da_PQpass PQpass; - da_PQhost PQhost; - da_PQport PQport; - da_PQtty PQtty; - da_PQoptions PQoptions; - da_PQstatus PQstatus; - da_PQtransactionStatus PQtransactionStatus; - da_PQparameterStatus PQparameterStatus; - da_PQprotocolVersion PQprotocolVersion; - da_PQserverVersion PQserverVersion; - da_PQerrorMessage PQerrorMessage; - da_PQsocket PQsocket; - da_PQbackendPID PQbackendPID; - da_PQconnectionNeedsPassword PQconnectionNeedsPassword; - da_PQconnectionUsedPassword PQconnectionUsedPassword; - da_PQclientEncoding PQclientEncoding; - da_PQsetClientEncoding PQsetClientEncoding; - da_PQgetssl PQgetssl; - da_PQinitSSL PQinitSSL; - da_PQinitOpenSSL PQinitOpenSSL; - da_PQsetErrorVerbosity PQsetErrorVerbosity; - da_PQtrace PQtrace; - da_PQuntrace PQuntrace; - da_PQsetNoticeReceiver PQsetNoticeReceiver; - da_PQsetNoticeProcessor PQsetNoticeProcessor; - da_PQregisterThreadLock PQregisterThreadLock; - da_PQexec PQexec; - da_PQexecParams PQexecParams; - da_PQprepare PQprepare; - da_PQexecPrepared PQexecPrepared; - da_PQsendQuery PQsendQuery; - da_PQsendQueryParams PQsendQueryParams; - da_PQsendPrepare PQsendPrepare; - da_PQsendQueryPrepared PQsendQueryPrepared; - da_PQsetSingleRowMode PQsetSingleRowMode; - da_PQgetResult PQgetResult; - da_PQisBusy PQisBusy; - da_PQconsumeInput PQconsumeInput; - da_PQnotifies PQnotifies; - da_PQputCopyData PQputCopyData; - da_PQputCopyEnd PQputCopyEnd; - da_PQgetCopyData PQgetCopyData; - da_PQgetline PQgetline; - da_PQputline PQputline; - da_PQgetlineAsync PQgetlineAsync; - da_PQputnbytes PQputnbytes; - da_PQendcopy PQendcopy; - da_PQsetnonblocking PQsetnonblocking; - da_PQisnonblocking PQisnonblocking; - da_PQisthreadsafe PQisthreadsafe; - da_PQping PQping; - da_PQpingParams PQpingParams; - da_PQflush PQflush; - da_PQfn PQfn; - da_PQresultStatus PQresultStatus; - da_PQresStatus PQresStatus; - da_PQresultErrorMessage PQresultErrorMessage; - da_PQresultErrorField PQresultErrorField; - da_PQntuples PQntuples; - da_PQnfields PQnfields; - da_PQbinaryTuples PQbinaryTuples; - da_PQfname PQfname; - da_PQfnumber PQfnumber; - da_PQftable PQftable; - da_PQftablecol PQftablecol; - da_PQfformat PQfformat; - da_PQftype PQftype; - da_PQfsize PQfsize; - da_PQfmod PQfmod; - da_PQcmdStatus PQcmdStatus; - da_PQoidStatus PQoidStatus; - da_PQoidValue PQoidValue; - da_PQcmdTuples PQcmdTuples; - da_PQgetvalue PQgetvalue; - da_PQgetlength PQgetlength; - da_PQgetisnull PQgetisnull; - da_PQnparams PQnparams; - da_PQparamtype PQparamtype; - da_PQdescribePrepared PQdescribePrepared; - da_PQdescribePortal PQdescribePortal; - da_PQsendDescribePrepared PQsendDescribePrepared; - da_PQsendDescribePortal PQsendDescribePortal; - da_PQclear PQclear; - da_PQfreemem PQfreemem; - da_PQmakeEmptyPGresult PQmakeEmptyPGresult; - da_PQcopyResult PQcopyResult; - da_PQsetResultAttrs PQsetResultAttrs; - da_PQresultAlloc PQresultAlloc; - da_PQsetvalue PQsetvalue; - da_PQescapeStringConn PQescapeStringConn; - da_PQescapeLiteral PQescapeLiteral; - da_PQescapeIdentifier PQescapeIdentifier; - da_PQescapeByteaConn PQescapeByteaConn; - da_PQunescapeBytea PQunescapeBytea; - da_PQescapeString PQescapeString; - da_PQescapeBytea PQescapeBytea; - da_PQprint PQprint; - da_PQdisplayTuples PQdisplayTuples; - da_PQprintTuples PQprintTuples; - da_lo_open lo_open; - da_lo_close lo_close; - da_lo_read lo_read; - da_lo_write lo_write; - da_lo_lseek lo_lseek; - da_lo_lseek64 lo_lseek64; - da_lo_creat lo_creat; - da_lo_create lo_create; - da_lo_tell lo_tell; - da_lo_tell64 lo_tell64; - da_lo_truncate lo_truncate; - da_lo_truncate64 lo_truncate64; - da_lo_unlink lo_unlink; - da_lo_import lo_import; - da_lo_import_with_oid lo_import_with_oid; - da_lo_export lo_export; - da_PQlibVersion PQlibVersion; - da_PQmblen PQmblen; - da_PQdsplen PQdsplen; - da_PQenv2encoding PQenv2encoding; - da_PQencryptPassword PQencryptPassword; - da_pg_char_to_encoding pg_char_to_encoding; - da_pg_encoding_to_char pg_encoding_to_char; - da_pg_valid_server_encoding_id pg_valid_server_encoding_id; - da_PQregisterEventProc PQregisterEventProc; - da_PQsetInstanceData PQsetInstanceData; -} diff --git a/DerelictPQ/source/derelict/pq/pq.d b/DerelictPQ/source/derelict/pq/pq.d deleted file mode 100644 index d294e619..00000000 --- a/DerelictPQ/source/derelict/pq/pq.d +++ /dev/null @@ -1,249 +0,0 @@ -/* - -Boost Software License - Version 1.0 - August 17th, 2003 - -Permission is hereby granted, free of charge, to any person or organization -obtaining a copy of the software and accompanying documentation covered by -this license (the "Software") to use, reproduce, display, distribute, -execute, and transmit the Software, and to prepare derivative works of the -Software, and to permit third-parties to whom the Software is furnished to -do so, all subject to the following: - -The copyright notices in the Software and this entire statement, including -the above license grant, this restriction and the following disclaimer, -must be included in all copies of the Software, in whole or in part, and -all derivative works of the Software, unless such copies or derivative -works are solely in the form of machine-executable object code generated by -a source language processor. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT -SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE -FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -DEALINGS IN THE SOFTWARE. - -*/ -module derelict.pq.pq; - -public -{ - import derelict.pq.types; - import derelict.pq.functions; -} - -private -{ - import derelict.util.loader; - import derelict.util.system; - import derelict.util.exception; - - static if(Derelict_OS_Windows) - enum libNames = "libpq.dll"; - else static if(Derelict_OS_Mac) - enum libNames = "libpq.dylib"; - else static if(Derelict_OS_Posix) - enum libNames = "libpq.so"; - else - static assert(0, "Need to implement PostgreSQL libNames for this operating system."); -} - -class DerelictPQLoader : SharedLibLoader -{ - PQVersion _loadedVersion; - - PQVersion loadedVersion() @property - { - return _loadedVersion; - } - - protected - { - override void loadSymbols() - { - // PQlibVersion appears first at 9.1 - try - { - bindFunc(cast(void**)&PQlibVersion, "PQlibVersion"); - } catch(SymbolLoadException e) - { - throw new DerelictException("DerelictPQ supports libpq since 9.1 version!"); - } - - _loadedVersion = cast(PQVersion)PQlibVersion(); - - bindFunc(cast(void**)&PQconnectStart, "PQconnectStart"); - bindFunc(cast(void**)&PQconnectStartParams, "PQconnectStartParams"); - bindFunc(cast(void**)&PQconnectPoll, "PQconnectPoll"); - bindFunc(cast(void**)&PQconnectdb, "PQconnectdb"); - bindFunc(cast(void**)&PQconnectdbParams, "PQconnectdbParams"); - bindFunc(cast(void**)&PQsetdbLogin, "PQsetdbLogin"); - bindFunc(cast(void**)&PQfinish, "PQfinish"); - bindFunc(cast(void**)&PQconndefaults, "PQconndefaults"); - bindFunc(cast(void**)&PQconninfoParse, "PQconninfoParse"); - bindFunc(cast(void**)&PQconninfoFree, "PQconninfoFree"); - bindFunc(cast(void**)&PQresetStart, "PQresetStart"); - bindFunc(cast(void**)&PQresetPoll, "PQresetPoll"); - bindFunc(cast(void**)&PQreset, "PQreset"); - bindFunc(cast(void**)&PQgetCancel, "PQgetCancel"); - bindFunc(cast(void**)&PQfreeCancel, "PQfreeCancel"); - bindFunc(cast(void**)&PQcancel, "PQcancel"); - bindFunc(cast(void**)&PQrequestCancel, "PQrequestCancel"); - bindFunc(cast(void**)&PQdb, "PQdb"); - bindFunc(cast(void**)&PQuser, "PQuser"); - bindFunc(cast(void**)&PQpass, "PQpass"); - bindFunc(cast(void**)&PQhost, "PQhost"); - bindFunc(cast(void**)&PQport, "PQport"); - bindFunc(cast(void**)&PQtty, "PQtty"); - bindFunc(cast(void**)&PQoptions, "PQoptions"); - bindFunc(cast(void**)&PQstatus, "PQstatus"); - bindFunc(cast(void**)&PQtransactionStatus, "PQtransactionStatus"); - bindFunc(cast(void**)&PQparameterStatus, "PQparameterStatus"); - bindFunc(cast(void**)&PQprotocolVersion, "PQprotocolVersion"); - bindFunc(cast(void**)&PQserverVersion, "PQserverVersion"); - bindFunc(cast(void**)&PQerrorMessage, "PQerrorMessage"); - bindFunc(cast(void**)&PQsocket, "PQsocket"); - bindFunc(cast(void**)&PQbackendPID, "PQbackendPID"); - bindFunc(cast(void**)&PQconnectionNeedsPassword, "PQconnectionNeedsPassword"); - bindFunc(cast(void**)&PQconnectionUsedPassword, "PQconnectionUsedPassword"); - bindFunc(cast(void**)&PQclientEncoding, "PQclientEncoding"); - bindFunc(cast(void**)&PQsetClientEncoding, "PQsetClientEncoding"); - bindFunc(cast(void**)&PQgetssl, "PQgetssl"); - bindFunc(cast(void**)&PQinitSSL, "PQinitSSL"); - bindFunc(cast(void**)&PQinitOpenSSL, "PQinitOpenSSL"); - bindFunc(cast(void**)&PQsetErrorVerbosity, "PQsetErrorVerbosity"); - bindFunc(cast(void**)&PQtrace, "PQtrace"); - bindFunc(cast(void**)&PQuntrace, "PQuntrace"); - bindFunc(cast(void**)&PQsetNoticeReceiver, "PQsetNoticeReceiver"); - bindFunc(cast(void**)&PQsetNoticeProcessor, "PQsetNoticeProcessor"); - bindFunc(cast(void**)&PQregisterThreadLock, "PQregisterThreadLock"); - bindFunc(cast(void**)&PQexec, "PQexec"); - bindFunc(cast(void**)&PQexecParams, "PQexecParams"); - bindFunc(cast(void**)&PQprepare, "PQprepare"); - bindFunc(cast(void**)&PQexecPrepared, "PQexecPrepared"); - bindFunc(cast(void**)&PQsendQuery, "PQsendQuery"); - bindFunc(cast(void**)&PQsendQueryParams, "PQsendQueryParams"); - bindFunc(cast(void**)&PQsendPrepare, "PQsendPrepare"); - bindFunc(cast(void**)&PQsendQueryPrepared, "PQsendQueryPrepared"); - bindFunc(cast(void**)&PQgetResult, "PQgetResult"); - bindFunc(cast(void**)&PQisBusy, "PQisBusy"); - bindFunc(cast(void**)&PQconsumeInput, "PQconsumeInput"); - bindFunc(cast(void**)&PQnotifies, "PQnotifies"); - bindFunc(cast(void**)&PQputCopyData, "PQputCopyData"); - bindFunc(cast(void**)&PQputCopyEnd, "PQputCopyEnd"); - bindFunc(cast(void**)&PQgetCopyData, "PQgetCopyData"); - bindFunc(cast(void**)&PQgetline, "PQgetline"); - bindFunc(cast(void**)&PQputline, "PQputline"); - bindFunc(cast(void**)&PQgetlineAsync, "PQgetlineAsync"); - bindFunc(cast(void**)&PQputnbytes, "PQputnbytes"); - bindFunc(cast(void**)&PQendcopy, "PQendcopy"); - bindFunc(cast(void**)&PQsetnonblocking, "PQsetnonblocking"); - bindFunc(cast(void**)&PQisnonblocking, "PQisnonblocking"); - bindFunc(cast(void**)&PQisthreadsafe, "PQisthreadsafe"); - bindFunc(cast(void**)&PQping, "PQping"); - bindFunc(cast(void**)&PQpingParams, "PQpingParams"); - bindFunc(cast(void**)&PQflush, "PQflush"); - bindFunc(cast(void**)&PQfn, "PQfn"); - bindFunc(cast(void**)&PQresultStatus, "PQresultStatus"); - bindFunc(cast(void**)&PQresStatus, "PQresStatus"); - bindFunc(cast(void**)&PQresultErrorMessage, "PQresultErrorMessage"); - bindFunc(cast(void**)&PQresultErrorField, "PQresultErrorField"); - bindFunc(cast(void**)&PQntuples, "PQntuples"); - bindFunc(cast(void**)&PQnfields, "PQnfields"); - bindFunc(cast(void**)&PQbinaryTuples, "PQbinaryTuples"); - bindFunc(cast(void**)&PQfname, "PQfname"); - bindFunc(cast(void**)&PQfnumber, "PQfnumber"); - bindFunc(cast(void**)&PQftable, "PQftable"); - bindFunc(cast(void**)&PQftablecol, "PQftablecol"); - bindFunc(cast(void**)&PQfformat, "PQfformat"); - bindFunc(cast(void**)&PQftype, "PQftype"); - bindFunc(cast(void**)&PQfsize, "PQfsize"); - bindFunc(cast(void**)&PQfmod, "PQfmod"); - bindFunc(cast(void**)&PQcmdStatus, "PQcmdStatus"); - bindFunc(cast(void**)&PQoidStatus, "PQoidStatus"); - bindFunc(cast(void**)&PQoidValue, "PQoidValue"); - bindFunc(cast(void**)&PQcmdTuples, "PQcmdTuples"); - bindFunc(cast(void**)&PQgetvalue, "PQgetvalue"); - bindFunc(cast(void**)&PQgetlength, "PQgetlength"); - bindFunc(cast(void**)&PQgetisnull, "PQgetisnull"); - bindFunc(cast(void**)&PQnparams, "PQnparams"); - bindFunc(cast(void**)&PQparamtype, "PQparamtype"); - bindFunc(cast(void**)&PQdescribePrepared, "PQdescribePrepared"); - bindFunc(cast(void**)&PQdescribePortal, "PQdescribePortal"); - bindFunc(cast(void**)&PQsendDescribePrepared, "PQsendDescribePrepared"); - bindFunc(cast(void**)&PQsendDescribePortal, "PQsendDescribePortal"); - bindFunc(cast(void**)&PQclear, "PQclear"); - bindFunc(cast(void**)&PQfreemem, "PQfreemem"); - bindFunc(cast(void**)&PQmakeEmptyPGresult, "PQmakeEmptyPGresult"); - bindFunc(cast(void**)&PQcopyResult, "PQcopyResult"); - bindFunc(cast(void**)&PQsetResultAttrs, "PQsetResultAttrs"); - bindFunc(cast(void**)&PQresultAlloc, "PQresultAlloc"); - bindFunc(cast(void**)&PQsetvalue, "PQsetvalue"); - bindFunc(cast(void**)&PQescapeStringConn, "PQescapeStringConn"); - bindFunc(cast(void**)&PQescapeLiteral, "PQescapeLiteral"); - bindFunc(cast(void**)&PQescapeIdentifier, "PQescapeIdentifier"); - bindFunc(cast(void**)&PQescapeByteaConn, "PQescapeByteaConn"); - bindFunc(cast(void**)&PQunescapeBytea, "PQunescapeBytea"); - bindFunc(cast(void**)&PQescapeString, "PQescapeString"); - bindFunc(cast(void**)&PQescapeBytea, "PQescapeBytea"); - bindFunc(cast(void**)&PQprint, "PQprint"); - bindFunc(cast(void**)&PQdisplayTuples, "PQdisplayTuples"); - bindFunc(cast(void**)&PQprintTuples, "PQprintTuples"); - bindFunc(cast(void**)&lo_open, "lo_open"); - bindFunc(cast(void**)&lo_close, "lo_close"); - bindFunc(cast(void**)&lo_read, "lo_read"); - bindFunc(cast(void**)&lo_write, "lo_write"); - bindFunc(cast(void**)&lo_lseek, "lo_lseek"); - bindFunc(cast(void**)&lo_creat, "lo_creat"); - bindFunc(cast(void**)&lo_create, "lo_create"); - bindFunc(cast(void**)&lo_tell, "lo_tell"); - bindFunc(cast(void**)&lo_truncate, "lo_truncate"); - bindFunc(cast(void**)&lo_unlink, "lo_unlink"); - bindFunc(cast(void**)&lo_import, "lo_import"); - bindFunc(cast(void**)&lo_import_with_oid, "lo_import_with_oid"); - bindFunc(cast(void**)&lo_export, "lo_export"); - bindFunc(cast(void**)&PQmblen, "PQmblen"); - bindFunc(cast(void**)&PQdsplen, "PQdsplen"); - bindFunc(cast(void**)&PQenv2encoding, "PQenv2encoding"); - bindFunc(cast(void**)&PQencryptPassword, "PQencryptPassword"); - bindFunc(cast(void**)&pg_char_to_encoding, "pg_char_to_encoding"); - bindFunc(cast(void**)&pg_encoding_to_char, "pg_encoding_to_char"); - bindFunc(cast(void**)&pg_valid_server_encoding_id, "pg_valid_server_encoding_id"); - bindFunc(cast(void**)&PQregisterEventProc, "PQregisterEventProc"); - bindFunc(cast(void**)&PQsetInstanceData, "PQsetInstanceData"); - - if(_loadedVersion >= PQVersion.PQ_920) - { - bindFunc(cast(void**)&PQsetSingleRowMode, "PQsetSingleRowMode"); - } - if(_loadedVersion >= PQVersion.PQ_930) - { - bindFunc(cast(void**)&PQconninfo, "PQconninfo"); - bindFunc(cast(void**)&lo_lseek64, "lo_lseek64"); - bindFunc(cast(void**)&lo_tell64, "lo_tell64"); - bindFunc(cast(void**)&lo_truncate64, "lo_truncate64"); - } - } - } - - public - { - this() - { - super(libNames); - } - } -} - -__gshared DerelictPQLoader DerelictPQ; - -shared static this() -{ - DerelictPQ = new DerelictPQLoader(); -} - -shared static ~this() -{ - DerelictPQ.unload(); -} diff --git a/DerelictPQ/source/derelict/pq/types.d b/DerelictPQ/source/derelict/pq/types.d deleted file mode 100644 index 4b8feff4..00000000 --- a/DerelictPQ/source/derelict/pq/types.d +++ /dev/null @@ -1,190 +0,0 @@ -/* - -Boost Software License - Version 1.0 - August 17th, 2003 - -Permission is hereby granted, free of charge, to any person or organization -obtaining a copy of the software and accompanying documentation covered by -this license (the "Software") to use, reproduce, display, distribute, -execute, and transmit the Software, and to prepare derivative works of the -Software, and to permit third-parties to whom the Software is furnished to -do so, all subject to the following: - -The copyright notices in the Software and this entire statement, including -the above license grant, this restriction and the following disclaimer, -must be included in all copies of the Software, in whole or in part, and -all derivative works of the Software, unless such copies or derivative -works are solely in the form of machine-executable object code generated by -a source language processor. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT -SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE -FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -DEALINGS IN THE SOFTWARE. - -*/ -module derelict.pq.types; - -enum PQVersion : int -{ - PQ_910 = 90100, - PQ_911 = 90101, - PQ_912 = 90102, - PQ_913 = 90103, - PQ_914 = 90104, - PQ_915 = 90105, - PQ_916 = 90106, - PQ_917 = 90107, - PQ_918 = 90108, - PQ_920 = 90200, - PQ_921 = 90201, - PQ_922 = 90202, - PQ_923 = 90203, - PQ_930 = 90300, -} - -extern(C) -{ - alias uint Oid; - alias char pqbool; - alias long pg_int64; - public import std.c.stdio : FILE; - - enum PG_COPYRES_ATTRS = 0x01; - enum PG_COPYRES_TUPLES = 0x02; - enum PG_COPYRES_EVENTS = 0x04; - enum PG_COPYRES_NOTICEHOOKS = 0x08; - enum valueFormat - { - TEXT, - BINARY - } - enum ConnStatusType - { - CONNECTION_OK, - CONNECTION_BAD, - CONNECTION_STARTED, - CONNECTION_MADE, - CONNECTION_AWAITIN_RESPONSE, - CONNECTION_AUTH_OK, - CONNECTION_SETENV, - CONNECTION_SSL_STARTUP, - CONNECTION_NEEDED - } - enum PostgresPollingStatusType - { - PGRES_POLLING_FAILED = 0, - PGRES_POLLING_READING, - PGRES_POLLING_WRITING, - PGRES_POLLING_OK, - PGRES_POLLING_ACTIVE - } - enum ExecStatusType - { - PGRES_EMPTY_QUERY = 0, - PGRES_COMMAND_OK, - PGRES_TUPLES_OK, - PGRES_COPY_OUT, - PGRES_COPY_IN, - PGRES_BAD_RESPONSE, - PGRES_NONFATAL_ERROR, - PGRES_FATAL_ERROR, - PGRES_COPY_BOTH, - PGRES_SINGLE_TUPLE - } - enum PGTransactionStatusType - { - PQTRANS_IDLE, - PQTRANS_ACTIVE, - PQTRANS_INTRANS, - PQTRANS_INERROR, - PQTRANS_UNKNOWN - } - enum PGVerbosity - { - PQERRORS_TERSE, - PQERRORS_DEFAULT, - PQERRORS_VERBOSE - } - enum PGPing - { - PQPING_OK, - PQPING_REJECT, - PQPING_NO_RESPONSE, - PQPING_NO_ATTEMTP - } - struct PGconn {} - struct PGresult {} - struct PGcancel {} - struct PGnotify - { - char* relname; - int be_pid; - char* extra; - private PGnotify* next; - } - struct PQprintOpt - { - pqbool header; - pqbool aligment; - pqbool standard; - pqbool html3; - pqbool expander; - pqbool pager; - char* fieldSep; - char* tableOpt; - char* caption; - char** fieldName; - } - struct PQconninfoOption - { - char* keyword; - char* envvar; - char* compiled; - char* val; - char* label; - char* dispchar; - int dispsize; - } - struct PQArgBlock - { - int len; - int ising; - union u - { - int* ptr; - int integer; - } - } - struct PGresAttDesc - { - char* name; - Oid tableid; - int columnid; - int format; - Oid typid; - int typlen; - int atttypmod; - } - enum PGEventId - { - PGEVT_REGISTER, - PGEVT_CONNRESET, - PGEVT_CONNDESTROY, - PGEVT_RESULTCREATE, - PGEVT_RESULTCOPY, - PGEVT_RESULTDESTROY - } - struct PGEventResultCreate - { - PGconn* conn; - PGresult* result; - } - - alias nothrow void function(void* arg, PGresult* res) PQnoticeReceiver; - alias nothrow void function(void* arg, char* message) PQnotcieProcessor; - alias nothrow void function(int acquire) pgthreadlock_t; - alias nothrow size_t function(PGEventId evtId, void* evtInfo, void* passThrough) PGEventProc; -} \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..127a5bc3 --- /dev/null +++ b/LICENSE @@ -0,0 +1,23 @@ +Boost Software License - Version 1.0 - August 17th, 2003 + +Permission is hereby granted, free of charge, to any person or organization +obtaining a copy of the software and accompanying documentation covered by +this license (the "Software") to use, reproduce, display, distribute, +execute, and transmit the Software, and to prepare derivative works of the +Software, and to permit third-parties to whom the Software is furnished to +do so, all subject to the following: + +The copyright notices in the Software and this entire statement, including +the above license grant, this restriction and the following disclaimer, +must be included in all copies of the Software, in whole or in part, and +all derivative works of the Software, unless such copies or derivative +works are solely in the form of machine-executable object code generated by +a source language processor. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT +SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE +FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md index fe9a9234..6fc3fcc7 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,7 @@ dependency to the `package.json` file in your project's directory: Invoking `dub` will then automatically download the latest dpq2 and compile and run the project. +If you want only to build your project run `dub build`. Similarly, you can run an example by invoking `dub` from any of the example project directories. @@ -55,6 +56,13 @@ If you want to install dpq2 explicitly, you can use: git clone https://github.com/denizzzka/dpq2.git cd dpq2 ``` + +The static bindings are generated by default. Add `--config=dynamic` +to the `dub` parameters to generate dynamic bindings. + +The debug version is generated by default. Add `--build=release` +to the `dub` parameters to generate release version. + ####Static bindings - debug version $ dub build @@ -69,17 +77,17 @@ cd dpq2 ####Unittest version (see below) $ cd unittests - $ dub build - $ dub --build=release build - $ dub --config=dynamic build - $ dub --config=dynamic --build=release build + $ dub + $ dub --build=release + $ dub --config=dynamic + $ dub --config=dynamic --build=release ####Example compilation $ cd example - $ dub build - $ dub --build=release build - $ dub --config=dynamic build - $ dub --config=dynamic --build=release build + $ dub + $ dub --build=release + $ dub --config=dynamic + $ dub --config=dynamic --build=release Example ------- diff --git a/example/package.json b/example/package.json index c38fa9db..84176dd1 100644 --- a/example/package.json +++ b/example/package.json @@ -2,9 +2,9 @@ "name": "dpq2-example", "description": "Example for usage high-level binding to the PostgreSQL database", "homepage": "https://github.com/denizzzka/dpq2", - "license": "", + "license": "Boost", "authors": [ - "denizzzka", "Anton Gushcha" + "Denis Feklushkin", "Anton Gushcha" ], "targetPath": "bin", "dependencies": { diff --git a/package.json b/package.json index b984985f..2d83d048 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "dpq2", "description": "High-level binding to the PostgreSQL database", "homepage": "https://github.com/denizzzka/dpq2", - "license": "", + "license": "Boost", "authors": [ "Denis Feklushkin", "Anton Gushcha" ], @@ -12,12 +12,11 @@ "configurations": [ { "name": "static", - "versions": ["BINDINGS_STATIC"], "libs": ["pq"] }, { "name": "dynamic", - "dependencies": {"derelict-pq": {"version": "~master", "path": "DerelictPQ"}}, + "dependencies": {"derelict:pq": "~master"}, "versions": ["BINDINGS_DYNAMIC"] } ] diff --git a/src/dpq2/all.d b/src/dpq2/all.d index 9a4ca161..14d9810f 100644 --- a/src/dpq2/all.d +++ b/src/dpq2/all.d @@ -17,15 +17,23 @@ version(BINDINGS_DYNAMIC) shared static ~this() { - import std.stdio; - write("DerelictPQ is unloading... "); + debug + { + import std.stdio; + write("DerelictPQ is unloading... "); + } + import core.memory; GC.collect(); DerelictPQ.unload(); - writeln("finished."); + + debug + { + writeln("finished."); + } } } -version(BINDINGS_STATIC) +else { public { diff --git a/src/dpq2/answer.d b/src/dpq2/answer.d index bd9d6ebc..0e111122 100644 --- a/src/dpq2/answer.d +++ b/src/dpq2/answer.d @@ -2,10 +2,14 @@ module dpq2.answer; @trusted: -version(BINDINGS_STATIC) - import dpq2.libpq; -version(BINDINGS_DYNAMIC) +version(BINDINGS_DYNAMIC) +{ import derelict.pq.pq; +} +else +{ + import dpq2.libpq; +} public import dpq2.query; diff --git a/src/dpq2/connection.d b/src/dpq2/connection.d index b1ad2f87..194af29c 100644 --- a/src/dpq2/connection.d +++ b/src/dpq2/connection.d @@ -2,10 +2,14 @@ module dpq2.connection; @trusted: -version(BINDINGS_STATIC) - import dpq2.libpq; -version(BINDINGS_DYNAMIC) +version(BINDINGS_DYNAMIC) +{ import derelict.pq.pq; +} +else +{ + import dpq2.libpq; +} import dpq2.answer; diff --git a/src/dpq2/query.d b/src/dpq2/query.d index a7a60f74..84adc4d9 100644 --- a/src/dpq2/query.d +++ b/src/dpq2/query.d @@ -1,10 +1,14 @@ module dpq2.query; @trusted: -version(BINDINGS_STATIC) - import dpq2.libpq; -version(BINDINGS_DYNAMIC) +version(BINDINGS_DYNAMIC) +{ import derelict.pq.pq; +} +else +{ + import dpq2.libpq; +} import dpq2.answer; public import dpq2.connection; diff --git a/unittests/package.json b/unittests/package.json index c51bb493..868fa3cd 100644 --- a/unittests/package.json +++ b/unittests/package.json @@ -2,9 +2,9 @@ "name": "dpq2-unittests", "description": "Unit tests for usage high-level binding to the PostgreSQL database", "homepage": "https://github.com/denizzzka/dpq2", - "license": "", + "license": "Boost", "authors": [ - "denizzzka", "Anton Gushcha" + "Denis Feklushkin", "Anton Gushcha" ], "targetPath": "bin", "dependencies": {