00001 {*********************************************************}
00002 { }
00003 { Zeos Database Objects }
00004 { Delphi interface to gds32.dll }
00005 { from Firebird }
00006 { }
00007 { Originally written by Sergey Seroukhov }
00008 { }
00009 {*********************************************************}
00010
00011 {@********************************************************}
00012 { Copyright (c) 1999-2006 Zeos Development Group }
00013 { }
00014 { License Agreement: }
00015 { }
00016 { This library is distributed in the hope that it will be }
00017 { useful, but WITHOUT ANY WARRANTY; without even the }
00018 { implied warranty of MERCHANTABILITY or FITNESS FOR }
00019 { A PARTICULAR PURPOSE. See the GNU Lesser General }
00020 { Public License for more details. }
00021 { }
00022 { The source code of the ZEOS Libraries and packages are }
00023 { distributed under the Library GNU General Public }
00024 { License (see the file COPYING / COPYING.ZEOS) }
00025 { with the following modification: }
00026 { As a special exception, the copyright holders of this }
00027 { library give you permission to link this library with }
00028 { independent modules to produce an executable, }
00029 { regardless of the license terms of these independent }
00030 { modules, and to copy and distribute the resulting }
00031 { executable under terms of your choice, provided that }
00032 { you also meet, for each linked independent module, }
00033 { the terms and conditions of the license of that module. }
00034 { An independent module is a module which is not derived }
00035 { from or based on this library. If you modify this }
00036 { library, you may extend this exception to your version }
00037 { of the library, but you are not obligated to do so. }
00038 { If you do not wish to do so, delete this exception }
00039 { statement from your version. }
00040 { }
00041 { }
00042 { The project web site is located on: }
00043 { http:
00044 { http:
00045 { svn:
00046 { }
00047 { http:
00048 { http:
00049 { }
00050 { }
00051 { }
00052 { Zeos Development Group. }
00053 {********************************************************@}
00054
00055 unit ZPlainFirebird10;
00056
00057 interface
00058
00059 {$I ZPlain.inc}
00060
00061 {$J+}
00062
00063 uses
00064 {$IFNDEF VER130BELOW}
00065 Types,
00066 {$ENDIF}
00067 ZCompatibility, ZPlainLoader, ZPlainFirebirdInterbaseConstants;
00068
00069 { ***************** Plain API Constants definition **************** }
00070
00071 const
00072 WINDOWS_DLL_LOCATION = 'gds32.dll';
00073 LINUX_DLL_LOCATION = 'libgds32.so';
00074 LINUX_IB_CRYPT_LOCATION = 'libcrypt.so';
00075
00076 type
00077
00078 { ************** Plain API Function types definition ************* }
00079
00080 { General database routines }
00081
00082 Tisc_attach_database = function(status_vector: PISC_STATUS;
00083 db_name_length: Short; db_name: PChar; db_handle: PISC_DB_HANDLE;
00084 parm_buffer_length: Short; parm_buffer: PChar): ISC_STATUS;
00085 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00086
00087 Tisc_detach_database = function(status_vector: PISC_STATUS;
00088 db_handle: PISC_DB_HANDLE): ISC_STATUS;
00089 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00090
00091 Tisc_drop_database = function(status_vector: PISC_STATUS;
00092 db_handle: PISC_DB_HANDLE): ISC_STATUS;
00093 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00094
00095 Tisc_database_info = function(status_vector: PISC_STATUS;
00096 db_handle: PISC_DB_HANDLE; item_list_buffer_length: Short;
00097 item_list_buffer: PChar; result_buffer_length: Short;
00098 result_buffer: PChar): ISC_STATUS;
00099 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00100
00101 { Array processing routines }
00102 Tisc_array_gen_sdl = function(status_vector: PISC_STATUS;
00103 isc_array_desc: PISC_ARRAY_DESC; isc_arg3: PShort;
00104 isc_arg4: PChar; isc_arg5: PShort): ISC_STATUS;
00105 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00106
00107 Tisc_array_get_slice = function(status_vector: PISC_STATUS;
00108 db_handle: PISC_DB_HANDLE; trans_handle: PISC_TR_HANDLE;
00109 array_id: PISC_QUAD; descriptor: PISC_ARRAY_DESC;
00110 dest_array: PVoid; slice_length: ISC_LONG): ISC_STATUS;
00111 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00112
00113 Tisc_array_lookup_bounds = function(status_vector: PISC_STATUS;
00114 db_handle: PISC_DB_HANDLE; trans_handle: PISC_TR_HANDLE;
00115 table_name, column_name: PChar;
00116 descriptor: PISC_ARRAY_DESC): ISC_STATUS;
00117 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00118
00119 Tisc_array_lookup_desc = function(status_vector: PISC_STATUS;
00120 db_handle: PISC_DB_HANDLE; trans_handle: PISC_TR_HANDLE;
00121 table_name, column_name: PChar;
00122 descriptor: PISC_ARRAY_DESC): ISC_STATUS;
00123 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00124
00125 Tisc_array_set_desc = function(status_vector: PISC_STATUS;
00126 table_name: PChar; column_name: PChar;
00127 sql_dtype, sql_length, sql_dimensions: PShort;
00128 descriptor: PISC_ARRAY_DESC): ISC_STATUS;
00129 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00130
00131 Tisc_array_put_slice = function(status_vector: PISC_STATUS;
00132 db_handle: PISC_DB_HANDLE; trans_handle: PISC_TR_HANDLE;
00133 array_id: PISC_QUAD; descriptor: PISC_ARRAY_DESC;
00134 source_array: PVoid; slice_length: PISC_LONG): ISC_STATUS;
00135 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00136
00137 Tisc_free = function(isc_arg1: PChar): ISC_LONG;
00138 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00139
00140 Tisc_sqlcode = function(status_vector: PISC_STATUS): ISC_LONG;
00141 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00142
00143 Tisc_sql_interprete = procedure(sqlcode: Short; buffer: PChar;
00144 buffer_length: Short); {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00145
00146 Tisc_interprete = function(buffer: PChar; status_vector: PPISC_STATUS):
00147 ISC_STATUS; {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00148
00149 { Transaction support routines }
00150
00151 Tisc_start_transaction = function(status_vector: PISC_STATUS;
00152 tran_handle: PISC_TR_HANDLE; db_handle_count: Short;
00153 db_handle: PISC_DB_HANDLE; tpb_length: Word; tpb_address: PChar):
00154 ISC_STATUS; {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00155
00156 Tisc_start_multiple = function(status_vector: PISC_STATUS;
00157 tran_handle: PISC_TR_HANDLE; db_handle_count: Short;
00158 teb_vector_address: PISC_TEB): ISC_STATUS;
00159 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00160
00161 Tisc_rollback_transaction = function(status_vector: PISC_STATUS;
00162 tran_handle: PISC_TR_HANDLE): ISC_STATUS;
00163 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00164
00165 Tisc_rollback_retaining = function(status_vector: PISC_STATUS;
00166 tran_handle: PISC_TR_HANDLE): ISC_STATUS;
00167 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00168
00169 Tisc_commit_retaining = function(status_vector: PISC_STATUS;
00170 tran_handle: PISC_TR_HANDLE): ISC_STATUS;
00171 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00172
00173 Tisc_commit_transaction = function(status_vector: PISC_STATUS;
00174 tran_handle: PISC_TR_HANDLE): ISC_STATUS;
00175 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00176
00177 Tisc_transaction_info = function(status_vector: PISC_STATUS;
00178 tr_handle: PISC_TR_HANDLE; item_list_buffer_length: Short;
00179 item_list_buffer: PChar; result_buffer_length: Short;
00180 result_buffer: PChar): ISC_STATUS;
00181 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00182
00183 { Dynamic SQL routines }
00184
00185 Tisc_dsql_allocate_statement = function(status_vector: PISC_STATUS;
00186 db_handle: PISC_DB_HANDLE; stmt_handle: PISC_STMT_HANDLE): ISC_STATUS;
00187 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00188
00189 Tisc_dsql_alloc_statement2 = function(status_vector: PISC_STATUS;
00190 db_handle: PISC_DB_HANDLE; stmt_handle: PISC_STMT_HANDLE): ISC_STATUS;
00191 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00192
00193 Tisc_dsql_describe = function(status_vector: PISC_STATUS;
00194 stmt_handle: PISC_STMT_HANDLE; dialect: Word; xsqlda: PXSQLDA): ISC_STATUS;
00195 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00196
00197 Tisc_dsql_describe_bind = function(status_vector: PISC_STATUS;
00198 stmt_handle: PISC_STMT_HANDLE; dialect: Word; xsqlda: PXSQLDA): ISC_STATUS;
00199 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00200
00201 Tisc_dsql_execute = function(status_vector: PISC_STATUS;
00202 tran_handle: PISC_TR_HANDLE; stmt_handle: PISC_STMT_HANDLE; dialect: Word;
00203 xsqlda: PXSQLDA): ISC_STATUS;
00204 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00205
00206 Tisc_dsql_execute2 = function(status_vector: PISC_STATUS;
00207 tran_handle: PISC_TR_HANDLE; stmt_handle: PISC_STMT_HANDLE; dialect: Word;
00208 in_xsqlda, out_xsqlda: PXSQLDA): ISC_STATUS;
00209 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00210
00211 Tisc_dsql_execute_immediate = function(status_vector: PISC_STATUS;
00212 db_handle: PISC_DB_HANDLE; tran_handle: PISC_TR_HANDLE; length: Word;
00213 statement: PChar; dialect: Word; xsqlda: PXSQLDA): ISC_STATUS;
00214 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00215
00216 Tisc_dsql_fetch = function(status_vector: PISC_STATUS;
00217 stmt_handle: PISC_STMT_HANDLE; dialect: Word; xsqlda: PXSQLDA): ISC_STATUS;
00218 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00219
00220 Tisc_dsql_free_statement = function(status_vector: PISC_STATUS;
00221 stmt_handle: PISC_STMT_HANDLE; options: Word): ISC_STATUS;
00222 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00223
00224 Tisc_dsql_prepare = function(status_vector: PISC_STATUS;
00225 tran_handle: PISC_TR_HANDLE; stmt_handle: PISC_STMT_HANDLE;
00226 length: Word; statement: PChar; dialect: Word; xsqlda: PXSQLDA):
00227 ISC_STATUS; {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00228
00229 Tisc_dsql_set_cursor_name = function(status_vector: PISC_STATUS;
00230 stmt_handle: PISC_STMT_HANDLE; cursor_name: PChar; _type: Word): ISC_STATUS;
00231 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00232
00233 Tisc_dsql_sql_info = function(status_vector: PISC_STATUS;
00234 stmt_handle: PISC_STMT_HANDLE; item_length: Short; items: PChar;
00235 buffer_length: Short; buffer: PChar): ISC_STATUS;
00236 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00237
00238 { Blob processing routines }
00239
00240 Tisc_open_blob2 = function(status_vector: PISC_STATUS;
00241 db_handle: PISC_DB_HANDLE; tran_handle: PISC_TR_HANDLE;
00242 blob_handle: PISC_BLOB_HANDLE; blob_id: PISC_QUAD; bpb_length: Short;
00243 bpb_buffer: PChar): ISC_STATUS;
00244 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00245
00246 Tisc_create_blob2 = function(status_vector: PISC_STATUS;
00247 db_handle: PISC_DB_HANDLE; tran_handle: PISC_TR_HANDLE;
00248 blob_handle: PISC_BLOB_HANDLE; blob_id: PISC_QUAD; bpb_length: Short;
00249 bpb_address: PChar): ISC_STATUS;
00250 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00251
00252 Tisc_blob_info = function(status_vector: PISC_STATUS;
00253 blob_handle: PISC_BLOB_HANDLE; item_list_buffer_length: Short;
00254 item_list_buffer: PChar; result_buffer_length: Short; result_buffer: PChar):
00255 ISC_STATUS; {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00256
00257 Tisc_close_blob = function(status_vector: PISC_STATUS;
00258 blob_handle: PISC_BLOB_HANDLE): ISC_STATUS;
00259 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00260
00261 Tisc_cancel_blob = function(status_vector: PISC_STATUS;
00262 blob_handle: PISC_BLOB_HANDLE): ISC_STATUS;
00263 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00264
00265 Tisc_get_segment = function(status_vector: PISC_STATUS;
00266 blob_handle: PISC_BLOB_HANDLE; actual_seg_length: PWord;
00267 seg_buffer_length: Word; seg_buffer: PChar): ISC_STATUS;
00268 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00269
00270 Tisc_put_segment = function(status_vector: PISC_STATUS;
00271 blob_handle: PISC_BLOB_HANDLE; seg_buffer_len: Word; seg_buffer: PChar):
00272 ISC_STATUS; {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00273
00274 { Event processing routines }
00275
00276 Tisc_event_block = function(event_buffer: PPChar; result_buffer: PPChar;
00277 id_count: Word; event_list: array of PChar): ISC_LONG;
00278 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00279
00280 Tisc_event_counts = procedure(status_vector: PISC_STATUS;
00281 buffer_length: Short; event_buffer: PChar; result_buffer: PChar);
00282 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00283
00284 Tisc_cancel_events = function(status_vector: PISC_STATUS;
00285 db_handle: PISC_DB_HANDLE; event_id: PISC_LONG): ISC_STATUS;
00286 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00287
00288 Tisc_que_events = function(status_vector: PISC_STATUS;
00289 db_handle: PISC_DB_HANDLE; event_id: PISC_LONG; length: Short;
00290 event_buffer: PChar; event_function: TISC_CALLBACK;
00291 event_function_arg: PVoid): ISC_STATUS;
00292 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00293
00294 { Types convertion routines }
00295
00296 Tisc_decode_date = procedure(ib_date: PISC_QUAD; tm_date: PCTimeStructure);
00297 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00298
00299 Tisc_encode_date = procedure(tm_date: PCTimeStructure; ib_date: PISC_QUAD);
00300 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00301
00302 { Interbase Version 6 routines }
00303 Tisc_decode_sql_date = procedure(ib_date: PISC_DATE;
00304 tm_date: PCTimeStructure); {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00305
00306 Tisc_decode_sql_time = procedure(ib_time: PISC_TIME;
00307 tm_date: PCTimeStructure); {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00308
00309 Tisc_decode_timestamp = procedure(ib_timestamp: PISC_TIMESTAMP;
00310 tm_date: PCTimeStructure); {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00311
00312 Tisc_encode_sql_date = procedure(tm_date: PCTimeStructure;
00313 ib_date: PISC_DATE); {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00314
00315 Tisc_encode_sql_time = procedure(tm_date: PCTimeStructure;
00316 ib_time: PISC_TIME); {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00317
00318 Tisc_encode_timestamp = procedure(tm_date: PCTimeStructure;
00319 ib_timestamp: PISC_TIMESTAMP);
00320 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00321
00322 Tisc_vax_integer = function(buffer: PChar; length: Short): ISC_LONG;
00323 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00324
00325 { ************* Plain API Function variables definition ************ }
00326
00327 var
00328 { General database routines }
00329 isc_attach_database: Tisc_attach_database;
00330 isc_detach_database: Tisc_detach_database;
00331 isc_drop_database: Tisc_drop_database;
00332 isc_database_info: Tisc_database_info;
00333 isc_free: Tisc_free;
00334 isc_sqlcode: Tisc_sqlcode;
00335 isc_sql_interprete: Tisc_sql_interprete;
00336 isc_interprete: Tisc_interprete;
00337
00338 { Transaction support routines }
00339 isc_start_transaction: Tisc_start_transaction;
00340 isc_start_multiple: Tisc_start_multiple;
00341 isc_rollback_transaction: Tisc_rollback_transaction;
00342 isc_rollback_retaining: Tisc_rollback_retaining;
00343 isc_commit_transaction: Tisc_commit_transaction;
00344 isc_commit_retaining: Tisc_commit_retaining;
00345 isc_transaction_info: Tisc_transaction_info;
00346
00347 { Dynamic SQL routines }
00348 isc_dsql_allocate_statement: Tisc_dsql_allocate_statement;
00349 isc_dsql_alloc_statement2: Tisc_dsql_alloc_statement2;
00350 isc_dsql_describe: Tisc_dsql_describe;
00351 isc_dsql_describe_bind: Tisc_dsql_describe_bind;
00352 isc_dsql_execute: Tisc_dsql_execute;
00353 isc_dsql_execute2: Tisc_dsql_execute2;
00354 isc_dsql_execute_immediate: Tisc_dsql_execute_immediate;
00355 isc_dsql_fetch: Tisc_dsql_fetch;
00356 isc_dsql_free_statement: Tisc_dsql_free_statement;
00357 isc_dsql_prepare: Tisc_dsql_prepare;
00358 isc_dsql_set_cursor_name: Tisc_dsql_set_cursor_name;
00359 isc_dsql_sql_info: Tisc_dsql_sql_info;
00360
00361 { Array processing routines }
00362 isc_array_gen_sdl: Tisc_array_gen_sdl;
00363 isc_array_get_slice: Tisc_array_get_slice;
00364 isc_array_lookup_bounds: Tisc_array_lookup_bounds;
00365 isc_array_lookup_desc: Tisc_array_lookup_desc;
00366 isc_array_set_desc: Tisc_array_set_desc;
00367 isc_array_put_slice: Tisc_array_put_slice;
00368
00369 { Blob processing routines }
00370 isc_open_blob2: Tisc_open_blob2;
00371 isc_create_blob2: Tisc_create_blob2;
00372 isc_blob_info: Tisc_blob_info;
00373 isc_close_blob: Tisc_close_blob;
00374 isc_cancel_blob: Tisc_cancel_blob;
00375 isc_get_segment: Tisc_get_segment;
00376 isc_put_segment: Tisc_put_segment;
00377
00378 { Event processing routines }
00379 isc_que_events: Tisc_que_events;
00380 isc_event_counts: Tisc_event_counts;
00381 isc_event_block: Tisc_event_block;
00382 isc_cancel_events: Tisc_cancel_events;
00383
00384 { Types convertion routines }
00385 isc_encode_date: Tisc_encode_date;
00386 isc_decode_date: Tisc_decode_date;
00387 isc_vax_integer: Tisc_vax_integer;
00388
00389 isc_encode_sql_date: Tisc_encode_sql_date;
00390 isc_decode_sql_date: Tisc_decode_sql_date;
00391
00392 isc_encode_sql_time: Tisc_encode_sql_time;
00393 isc_decode_sql_time: Tisc_decode_sql_time;
00394
00395 isc_encode_timestamp: Tisc_encode_timestamp;
00396 isc_decode_timestamp: Tisc_decode_timestamp;
00397
00398 var
00399 LibraryLoader: TZNativeLibraryLoader;
00400
00401 implementation
00402
00403 uses SysUtils,
00404 {$IFNDEF UNIX}
00405 Windows,
00406 {$ELSE}
00407 {$IFNDEF FPC}
00408 libc,
00409 {$ENDIF}
00410 {$ENDIF}
00411 ZMessages;
00412
00413 {$IFDEF UNIX}
00414 {$IFDEF INTERBASE_CRYPT}
00415 {$DEFINE ENABLE_INTERBASE_CRYPT}
00416 {$ENDIF}
00417 {$ENDIF}
00418
00419 type
00420 {** Implements a loader for Firebird native library. }
00421 TZFirebirdNativeLibraryLoader = class (TZNativeLibraryLoader)
00422 {$IFDEF ENABLE_INTERBASE_CRYPT}
00423 private
00424 FPreLocations: TStringDynArray;
00425 FPreHandle: LongWord;
00426 FPreLoaded: Boolean;
00427 FPreRequared: boolean;
00428 protected
00429 function LoadNativeLibrary: Boolean; override;
00430 procedure FreeNativeLibrary; override;
00431
00432 public
00433 constructor Create(PreLocations, Locations: array of string;
00434 PreRequared: boolean = False); overload;
00435
00436 property PreHandle: LongWord read FPreHandle write FPreHandle;
00437 property PreLoaded: Boolean read FPreLoaded write FPreLoaded;
00438 {$ENDIF}
00439 public
00440 function Load: Boolean; override;
00441 end;
00442
00443 { TZFirebirdNativeLibraryLoader }
00444
00445 {**
00446 Creates this loader class and assignes main properties.
00447 @param Locations locations of native library on windows platform.
00448 }
00449 {$IFDEF ENABLE_INTERBASE_CRYPT}
00450 constructor TZFirebirdNativeLibraryLoader.Create(PreLocations,
00451 Locations: array of string; PreRequared: boolean);
00452 var
00453 I: Integer;
00454 begin
00455 inherited Create(Locations);
00456 SetLength(FPreLocations, Length(PreLocations));
00457 for I := 0 to High(PreLocations) do
00458 FPreLocations[I] := PreLocations[I];
00459 FPreRequared := PreRequared;
00460 end;
00461 {$ENDIF}
00462
00463 {**
00464 Frees a previously loaded library.
00465 }
00466 {$IFDEF ENABLE_INTERBASE_CRYPT}
00467 procedure TZFirebirdNativeLibraryLoader.FreeNativeLibrary;
00468 begin
00469 inherited FreeNativeLibrary;
00470 if (PreHandle <> 0) and Loaded then
00471 FreeLibrary(PreHandle);
00472 PreHandle := 0;
00473 PreLoaded := False;
00474 end;
00475 {$ENDIF}
00476
00477 {**
00478 Loads a library module.
00479 @return <code>True</code> if library was successfully loaded.
00480 }
00481 function TZFirebirdNativeLibraryLoader.Load: Boolean;
00482 begin
00483 Result := inherited Load;
00484
00485 isc_sqlcode := GetAddress('isc_sqlcode');
00486 isc_sql_interprete := GetAddress('isc_sql_interprete');
00487 isc_interprete := GetAddress('isc_interprete');
00488 isc_vax_integer := GetAddress('isc_vax_integer');
00489
00490 isc_array_gen_sdl := GetAddress( 'isc_array_gen_sdl');
00491 isc_array_get_slice := GetAddress( 'isc_array_get_slice');
00492 isc_array_lookup_bounds := GetAddress( 'isc_array_lookup_bounds');
00493 isc_array_lookup_desc := GetAddress( 'isc_array_lookup_desc');
00494 isc_array_set_desc := GetAddress( 'isc_array_set_desc');
00495 isc_array_put_slice := GetAddress( 'isc_array_put_slice');
00496
00497 isc_blob_info := GetAddress('isc_blob_info');
00498 isc_open_blob2 := GetAddress('isc_open_blob2');
00499 isc_close_blob := GetAddress('isc_close_blob');
00500 isc_cancel_blob := GetAddress('isc_cancel_blob');
00501 isc_get_segment := GetAddress('isc_get_segment');
00502 isc_put_segment := GetAddress('isc_put_segment');
00503 isc_create_blob2 := GetAddress('isc_create_blob2');
00504 isc_decode_date := GetAddress('isc_decode_date');
00505 isc_encode_date := GetAddress('isc_encode_date');
00506 isc_dsql_free_statement := GetAddress('isc_dsql_free_statement');
00507 isc_dsql_execute2 := GetAddress('isc_dsql_execute2');
00508 isc_dsql_execute := GetAddress('isc_dsql_execute');
00509 isc_dsql_set_cursor_name := GetAddress('isc_dsql_set_cursor_name');
00510 isc_dsql_fetch := GetAddress('isc_dsql_fetch');
00511 isc_dsql_sql_info := GetAddress('isc_dsql_sql_info');
00512 isc_dsql_allocate_statement := GetAddress('isc_dsql_allocate_statement');
00513 isc_dsql_alloc_statement2 := GetAddress('isc_dsql_alloc_statement2');
00514 isc_dsql_prepare := GetAddress('isc_dsql_prepare');
00515 isc_dsql_describe_bind := GetAddress('isc_dsql_describe_bind');
00516 isc_dsql_describe := GetAddress('isc_dsql_describe');
00517 isc_dsql_execute_immediate := GetAddress('isc_dsql_execute_immediate');
00518 isc_drop_database := GetAddress('isc_drop_database');
00519 isc_detach_database := GetAddress('isc_detach_database');
00520 isc_attach_database := GetAddress('isc_attach_database');
00521 isc_database_info := GetAddress('isc_database_info');
00522 isc_transaction_info := GetAddress('isc_transaction_info');
00523 isc_start_multiple := GetAddress('isc_start_multiple');
00524 isc_start_transaction := GetAddress('isc_start_transaction');
00525 isc_commit_transaction := GetAddress('isc_commit_transaction');
00526
00527 isc_commit_retaining := GetAddress('isc_commit_retaining');
00528 isc_rollback_transaction := GetAddress('isc_rollback_transaction');
00529 isc_cancel_events := GetAddress('isc_cancel_events');
00530 isc_que_events := GetAddress('isc_que_events');
00531 isc_event_counts := GetAddress('isc_event_counts');
00532 isc_event_block := GetAddress('isc_event_block');
00533 isc_free := GetAddress('isc_free');
00534
00535 isc_rollback_retaining := GetAddress( 'isc_rollback_retaining');
00536 isc_decode_sql_date := GetAddress('isc_decode_sql_date');
00537 isc_decode_sql_time := GetAddress('isc_decode_sql_time');
00538 isc_decode_timestamp := GetAddress('isc_decode_timestamp');
00539 isc_encode_sql_date := GetAddress('isc_encode_sql_date');
00540 isc_encode_sql_time := GetAddress('isc_encode_sql_time');
00541 isc_encode_timestamp := GetAddress('isc_encode_timestamp');
00542 end;
00543
00544 {**
00545 Loads a library module and initializes the handle.
00546 @return <code>True</code> is library was successfully loaded.
00547 }
00548 {$IFDEF ENABLE_INTERBASE_CRYPT}
00549 function TZFirebirdNativeLibraryLoader.LoadNativeLibrary: Boolean;
00550 var
00551 I: Integer;
00552 Location: string;
00553 TriedLocations: string;
00554 begin
00555 if Length(FPreLocations) <> 0 then
00556 begin
00557 PreLoaded := False;
00558 Location := '';
00559 TriedLocations := '';
00560 if PreHandle = 0 then
00561 begin
00562 for I := 0 to High(FPreLocations) do
00563 begin
00564 Location := FPreLocations[I];
00565
00566
00567
00568 {$IFDEF UNIX}
00569 {$IFDEF FPC}
00570 PreHandle := LoadLibrary(PChar(Location));
00571 {$ELSE}
00572 PreHandle := HMODULE(dlopen(PChar(Location), RTLD_GLOBAL));
00573 {$ENDIF}
00574 {$ELSE}
00575 PreHandle := LoadLibrary(PChar(Location));
00576 {$ENDIF}
00577
00578 if PreHandle <> 0 then
00579 begin
00580 PreLoaded := True;
00581 Break;
00582 end;
00583 if TriedLocations <> '' then
00584 TriedLocations := TriedLocations + ', ';
00585 TriedLocations := TriedLocations + Location;
00586 end;
00587 end;
00588
00589 if (not PreLoaded) and (FPreRequared) then
00590 raise Exception.Create(Format(SLibraryNotFound, [TriedLocations]));
00591 end;
00592
00593 Result := inherited LoadNativeLibrary;
00594 end;
00595 {$ENDIF}
00596
00597 initialization
00598 {$IFNDEF UNIX}
00599 LibraryLoader := TZFirebirdNativeLibraryLoader.Create(
00600 [WINDOWS_DLL_LOCATION]);
00601 {$ELSE}
00602 {$IFDEF ENABLE_INTERBASE_CRYPT}
00603 LibraryLoader := TZFirebirdNativeLibraryLoader.Create(
00604 [LINUX_IB_CRYPT_LOCATION], [LINUX_DLL_LOCATION]);
00605 {$ELSE}
00606 LibraryLoader := TZFirebirdNativeLibraryLoader.Create(
00607 [LINUX_DLL_LOCATION]);
00608 {$ENDIF}
00609 {$ENDIF}
00610 finalization
00611 if Assigned(LibraryLoader) then
00612 LibraryLoader.Free;
00613 end.