Skip to content

Commit

Permalink
adapted all loaders to latest TSynLibrary changes
Browse files Browse the repository at this point in the history
- including the new "prefix" parameter
  • Loading branch information
Arnaud Bouchez committed May 25, 2022
1 parent 96e1baf commit fb9f662
Show file tree
Hide file tree
Showing 9 changed files with 408 additions and 331 deletions.
32 changes: 21 additions & 11 deletions src/crypt/mormot.crypt.openssl.pas
Expand Up @@ -95,7 +95,7 @@ TAesPrngOsl = class(TAesPrngAbstract)
Ctx: array[boolean] of PEVP_CIPHER_CTX; // set and reused in CallEvp()
procedure Init(aOwner: TAesAbstract; aCipherName: PUtf8Char);
procedure Done;
procedure SetEvp(DoEncrypt: boolean; const method: string);
procedure SetEvp(DoEncrypt: boolean; const method: shortstring);
procedure UpdEvp(DoEncrypt: boolean; BufIn, BufOut: pointer; Count: cardinal);
procedure Clone(ToOwner: TAesAbstract; out ToAesOsl: TAesOsl);
end;
Expand Down Expand Up @@ -687,25 +687,35 @@ procedure TAesOsl.Done;
EVP_CIPHER_CTX_free(Ctx[true]);
end;

procedure TAesOsl.SetEvp(DoEncrypt: boolean; const method: string);
procedure TAesOsl.SetEvp(DoEncrypt: boolean; const method: shortstring);
var
c: PEVP_CIPHER_CTX;
begin
c := Ctx[DoEncrypt];
if c = nil then
if (c <> nil) and
(Owner.AlgoMode = mGcm) and
(OpenSslVersion >= $30000000) then
// on OpenSSL 3, GCM requires a full reinitialization of the context :(
EVP_CIPHER_CTX_reset(c)
else if c = nil then
begin
// setup encrypt/decrypt context, with the proper key and no padding
// setup encrypt/decrypt context, with the proper key/IV and no padding
c := EVP_CIPHER_CTX_new;
EOpenSslCrypto.Check(Owner, method,
EVP_CipherInit_ex(c, Cipher, nil,
@TAesAbstractOsl(Owner).fKey, nil, ord(DoEncrypt)));
EOpenSslCrypto.Check(Owner, method,
EVP_CIPHER_CTX_set_padding(c, 0));
Ctx[DoEncrypt] := c;
end
else
begin
// OpenSSL allows to reuse the previous Ctxt[], just setting the (new) IV
EOpenSslCrypto.Check(Owner, method, EVP_CipherInit_ex2(
c, nil, nil, @Owner.IV, ord(DoEncrypt), nil));
exit;
end;
// OpenSSL allows to reuse the previous Ctxt[], just setting the (new) IV
// full initialization of the context
EOpenSslCrypto.Check(Owner, method,
EVP_CipherInit_ex2(
c, Cipher, @TAesAbstractOsl(Owner).fKey, @Owner.IV, ord(DoEncrypt), nil));
EOpenSslCrypto.Check(Owner, method,
EVP_CipherInit_ex(c, nil, nil, nil, @Owner.IV, ord(DoEncrypt)));
EVP_CIPHER_CTX_set_padding(c, 0));
end;

procedure TAesOsl.UpdEvp(DoEncrypt: boolean; BufIn, BufOut: pointer; Count: cardinal);
Expand Down
138 changes: 69 additions & 69 deletions src/db/mormot.db.raw.odbc.pas
Expand Up @@ -888,74 +888,74 @@ function SQL_TIMESTAMP_STRUCT.ToIso8601(Dest: PUtf8Char; DataType: SqlSmallint;
ODBC_LIB = 'libodbc.so.1';
{$endif OSWINDOWS}

ODBC_ENTRIES: array[0..66] of PAnsiChar = (
'SQLAllocEnv',
'SQLAllocHandle',
'SQLAllocStmt',
'SQLBindCol',
'SQLBindParameter',
'SQLCancel',
'SQLCloseCursor',
'SQLColAttribute',
'SQLColAttributeW',
'SQLColumns',
'SQLColumnsW',
'SQLStatistics',
'SQLStatisticsW',
'SQLConnect',
'SQLConnectW',
'SQLCopyDesc',
'SQLDataSources',
'SQLDataSourcesW',
'SQLDescribeCol',
'SQLDescribeColW',
'SQLDisconnect',
'SQLEndTran',
'SQLError',
'SQLErrorW',
'SQLExecDirect',
'SQLExecDirectW',
'SQLExecute',
'SQLFetch',
'SQLFetchScroll',
'SQLFreeConnect',
'SQLFreeEnv',
'SQLFreeHandle',
'SQLFreeStmt',
'SQLGetConnectAttr',
'SQLGetConnectAttrW',
'SQLGetCursorName',
'SQLGetCursorNameW',
'SQLGetData',
'SQLGetDescField',
'SQLGetDescFieldW',
'SQLGetDescRec',
'SQLGetDescRecW',
'SQLGetDiagField',
'SQLGetDiagFieldW',
'SQLGetDiagRec',
'SQLGetDiagRecW',
'SQLMoreResults',
'SQLPrepare',
'SQLPrepareW',
'SQLRowCount',
'SQLNumResultCols',
'SQLGetInfo',
'SQLGetInfoW',
'SQLSetStmtAttr',
'SQLSetStmtAttrW',
'SQLSetEnvAttr',
'SQLSetConnectAttr',
'SQLSetConnectAttrW',
'SQLTables',
'SQLTablesW',
'SQLForeignKeys',
'SQLForeignKeysW',
'SQLDriverConnect',
'SQLDriverConnectW',
'SQLProcedureColumnsA',
'SQLProcedureColumnsW',
'SQLProcedures');
ODBC_ENTRIES: array[0..66] of RawUtf8 = (
'AllocEnv',
'AllocHandle',
'AllocStmt',
'BindCol',
'BindParameter',
'Cancel',
'CloseCursor',
'ColAttribute',
'ColAttributeW',
'Columns',
'ColumnsW',
'Statistics',
'StatisticsW',
'Connect',
'ConnectW',
'CopyDesc',
'DataSources',
'DataSourcesW',
'DescribeCol',
'DescribeColW',
'Disconnect',
'EndTran',
'Error',
'ErrorW',
'ExecDirect',
'ExecDirectW',
'Execute',
'Fetch',
'FetchScroll',
'FreeConnect',
'FreeEnv',
'FreeHandle',
'FreeStmt',
'GetConnectAttr',
'GetConnectAttrW',
'GetCursorName',
'GetCursorNameW',
'GetData',
'GetDescField',
'GetDescFieldW',
'GetDescRec',
'GetDescRecW',
'GetDiagField',
'GetDiagFieldW',
'GetDiagRec',
'GetDiagRecW',
'MoreResults',
'Prepare',
'PrepareW',
'RowCount',
'NumResultCols',
'GetInfo',
'GetInfoW',
'SetStmtAttr',
'SetStmtAttrW',
'SetEnvAttr',
'SetConnectAttr',
'SetConnectAttrW',
'Tables',
'TablesW',
'ForeignKeys',
'ForeignKeysW',
'DriverConnect',
'DriverConnectW',
'ProcedureColumnsA',
'ProcedureColumnsW',
'Procedures');


{$ifdef OSWINDOWS}
Expand Down Expand Up @@ -1031,7 +1031,7 @@ constructor TOdbcLib.Create;
TryLoadLibrary([ODBC_LIB], EOdbcException);
P := @@AllocEnv;
for i := 0 to High(ODBC_ENTRIES) do
Resolve(ODBC_ENTRIES[i], @P[i], {raiseonfailure=}EOdbcException);
Resolve('SQL', ODBC_ENTRIES[i], @P[i], {raiseonfailure=}EOdbcException);
end;

function TOdbcLib.GetDiagField(StatementHandle: SqlHStmt): RawUtf8;
Expand Down
57 changes: 43 additions & 14 deletions src/db/mormot.db.raw.oracle.pas
Expand Up @@ -1276,19 +1276,48 @@ procedure TOracleDate.From(aIso8601: PUtf8Char; Length: integer);
Text: 'WE8ISO8859P1'
));

OCI_ENTRIES: array[0..40] of PAnsiChar = (
'OCIClientVersion', 'OCIEnvNlsCreate',
'OCIHandleAlloc', 'OCIHandleFree', 'OCIServerAttach', 'OCIServerDetach',
'OCIAttrGet', 'OCIAttrSet', 'OCISessionBegin', 'OCISessionEnd',
'OCIErrorGet', 'OCIStmtPrepare', 'OCIStmtExecute', 'OCIStmtFetch',
'OCIBindByPos', 'OCIParamGet', 'OCITransStart', 'OCITransRollback',
'OCITransCommit', 'OCIDescriptorAlloc', 'OCIDescriptorFree',
'OCIDateTimeConstruct', 'OCIDateTimeGetDate', 'OCIDefineByPos',
'OCILobGetLength', 'OCILobGetChunkSize', 'OCILobOpen', 'OCILobRead',
'OCILobClose', 'OCILobWrite', 'OCINlsCharSetNameToId', 'OCIStmtPrepare2',
'OCIStmtRelease', 'OCITypeByName', 'OCIObjectNew', 'OCIObjectFree',
'OCINumberFromInt', 'OCIStringAssignText', 'OCICollAppend', 'OCIBindObject',
'OCIPasswordChange');
OCI_ENTRIES: array[0..40] of RawUtf8 = (
'ClientVersion',
'EnvNlsCreate',
'HandleAlloc',
'HandleFree',
'ServerAttach',
'ServerDetach',
'AttrGet',
'AttrSet',
'SessionBegin',
'SessionEnd',
'ErrorGet',
'StmtPrepare',
'StmtExecute',
'StmtFetch',
'BindByPos',
'ParamGet',
'TransStart',
'TransRollback',
'TransCommit',
'DescriptorAlloc',
'DescriptorFree',
'DateTimeConstruct',
'DateTimeGetDate',
'DefineByPos',
'LobGetLength',
'LobGetChunkSize',
'LobOpen',
'LobRead',
'LobClose',
'LobWrite',
'NlsCharSetNameToId',
'StmtPrepare2',
'StmtRelease',
'TypeByName',
'ObjectNew',
'ObjectFree',
'NumberFromInt',
'StringAssignText',
'CollAppend',
'BindObject',
'PasswordChange');


{ TSqlDBOracleLib }
Expand Down Expand Up @@ -1657,7 +1686,7 @@ constructor TSqlDBOracleLib.Create(LibraryFileName: TFileName);
TryLoadLibrary([{%H-}l1, l2, l3, LibraryFileName, LIBNAME], ESqlDBOracle);
P := @@ClientVersion;
for i := 0 to High(OCI_ENTRIES) do
Resolve(OCI_ENTRIES[i], @P[i], {raiseonfailure=}ESqlDBOracle);
Resolve('OCI', OCI_ENTRIES[i], @P[i], {raiseonfailure=}ESqlDBOracle);
ClientVersion(
major_version, minor_version, update_num, patch_num, port_update_num);
SupportsInt64Params := (major_version > 11) or
Expand Down
50 changes: 25 additions & 25 deletions src/db/mormot.db.raw.postgres.pas
Expand Up @@ -212,30 +212,30 @@ implementation
{ ************ PostgreSQL Client Library Loading }

const
PQ_ENTRIES: array[0..22] of PAnsiChar = (
'PQlibVersion',
'PQisthreadsafe',
'PQsetdbLogin',
'PQstatus',
'PQfinish',
'PQresultStatus',
'PQresultErrorField',
'PQerrorMessage',
'PQsetNoticeProcessor',
'PQclear',
'PQfreemem',
'PQexec',
'PQprepare',
'PQexecPrepared',
'PQexecParams',
'PQnfields',
'PQntuples',
'PQcmdTuples',
'PQfname',
'PQftype',
'PQgetvalue',
'PQgetlength',
'PQgetisnull');
PQ_ENTRIES: array[0..22] of RawUtf8 = (
'libVersion',
'isthreadsafe',
'setdbLogin',
'status',
'finish',
'resultStatus',
'resultErrorField',
'errorMessage',
'setNoticeProcessor',
'clear',
'freemem',
'exec',
'prepare',
'execPrepared',
'execParams',
'nfields',
'ntuples',
'cmdTuples',
'fname',
'ftype',
'getvalue',
'getlength',
'getisnull');


{ TSqlDBPostgresLib }
Expand Down Expand Up @@ -267,7 +267,7 @@ constructor TSqlDBPostgresLib.Create;
{%H-}l2, LIBNAME, LIBNAME2], ESqlDBPostgres);
P := @@LibVersion;
for i := 0 to High(PQ_ENTRIES) do
Resolve(PQ_ENTRIES[i], @P[I], {raiseonfailure=}ESqlDBPostgres);
Resolve('PQ', PQ_ENTRIES[i], @P[I], {raiseonfailure=}ESqlDBPostgres);
end;

procedure TSqlDBPostgresLib.GetRawUtf8(res: PPGresult;
Expand Down

0 comments on commit fb9f662

Please sign in to comment.