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 ZPlainFirebird15;
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 ZPlainFirebirdDriver;
00069
00070 { ***************** Plain API Constants definition **************** }
00071
00072 const
00073 WINDOWS1_DLL_LOCATION = 'fbclient15.dll';
00074 WINDOWS1_DLL_LOCATION_EMBEDDED = 'fbclientd15.dll';
00075 LINUX1_DLL_LOCATION = 'libfbclient.so.15';
00076 LINUX1_IB_CRYPT_LOCATION = 'libcrypt.so.15';
00077 LINUX1_DLL_LOCATION_EMBEDDED = 'libfbembed.so.15';
00078
00079 type
00080
00081 { ************** Plain API Function types definition ************* }
00082
00083 { General database routines }
00084
00085 Tisc_attach_database = function(status_vector: PISC_STATUS;
00086 db_name_length: Short; db_name: PChar; db_handle: PISC_DB_HANDLE;
00087 parm_buffer_length: Short; parm_buffer: PChar): ISC_STATUS;
00088 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00089
00090 Tisc_detach_database = function(status_vector: PISC_STATUS;
00091 db_handle: PISC_DB_HANDLE): ISC_STATUS;
00092 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00093
00094 Tisc_drop_database = function(status_vector: PISC_STATUS;
00095 db_handle: PISC_DB_HANDLE): ISC_STATUS;
00096 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00097
00098 Tisc_database_info = function(status_vector: PISC_STATUS;
00099 db_handle: PISC_DB_HANDLE; item_list_buffer_length: Short;
00100 item_list_buffer: PChar; result_buffer_length: Short;
00101 result_buffer: PChar): ISC_STATUS;
00102 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00103
00104 { Array processing routines }
00105 Tisc_array_gen_sdl = function(status_vector: PISC_STATUS;
00106 isc_array_desc: PISC_ARRAY_DESC; isc_arg3: PShort;
00107 isc_arg4: PChar; isc_arg5: PShort): ISC_STATUS;
00108 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00109
00110 Tisc_array_get_slice = function(status_vector: PISC_STATUS;
00111 db_handle: PISC_DB_HANDLE; trans_handle: PISC_TR_HANDLE;
00112 array_id: PISC_QUAD; descriptor: PISC_ARRAY_DESC;
00113 dest_array: PVoid; slice_length: ISC_LONG): ISC_STATUS;
00114 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00115
00116 Tisc_array_lookup_bounds = function(status_vector: PISC_STATUS;
00117 db_handle: PISC_DB_HANDLE; trans_handle: PISC_TR_HANDLE;
00118 table_name, column_name: PChar;
00119 descriptor: PISC_ARRAY_DESC): ISC_STATUS;
00120 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00121
00122 Tisc_array_lookup_desc = function(status_vector: PISC_STATUS;
00123 db_handle: PISC_DB_HANDLE; trans_handle: PISC_TR_HANDLE;
00124 table_name, column_name: PChar;
00125 descriptor: PISC_ARRAY_DESC): ISC_STATUS;
00126 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00127
00128 Tisc_array_set_desc = function(status_vector: PISC_STATUS;
00129 table_name: PChar; column_name: PChar;
00130 sql_dtype, sql_length, sql_dimensions: PShort;
00131 descriptor: PISC_ARRAY_DESC): ISC_STATUS;
00132 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00133
00134 Tisc_array_put_slice = function(status_vector: PISC_STATUS;
00135 db_handle: PISC_DB_HANDLE; trans_handle: PISC_TR_HANDLE;
00136 array_id: PISC_QUAD; descriptor: PISC_ARRAY_DESC;
00137 source_array: PVoid; slice_length: PISC_LONG): ISC_STATUS;
00138 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00139
00140 Tisc_free = function(isc_arg1: PChar): ISC_LONG;
00141 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00142
00143 Tisc_sqlcode = function(status_vector: PISC_STATUS): ISC_LONG;
00144 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00145
00146 Tisc_sql_interprete = procedure(sqlcode: Short; buffer: PChar;
00147 buffer_length: Short); {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00148
00149 Tisc_interprete = function(buffer: PChar; status_vector: PPISC_STATUS):
00150 ISC_STATUS; {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00151
00152 { Transaction support routines }
00153
00154 Tisc_start_transaction = function(status_vector: PISC_STATUS;
00155 tran_handle: PISC_TR_HANDLE; db_handle_count: Short;
00156 db_handle: PISC_DB_HANDLE; tpb_length: Word; tpb_address: PChar):
00157 ISC_STATUS; {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00158
00159 Tisc_start_multiple = function(status_vector: PISC_STATUS;
00160 tran_handle: PISC_TR_HANDLE; db_handle_count: Short;
00161 teb_vector_address: PISC_TEB): ISC_STATUS;
00162 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00163
00164 Tisc_rollback_transaction = function(status_vector: PISC_STATUS;
00165 tran_handle: PISC_TR_HANDLE): ISC_STATUS;
00166 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00167
00168 Tisc_rollback_retaining = function(status_vector: PISC_STATUS;
00169 tran_handle: PISC_TR_HANDLE): ISC_STATUS;
00170 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00171
00172 Tisc_commit_retaining = function(status_vector: PISC_STATUS;
00173 tran_handle: PISC_TR_HANDLE): ISC_STATUS;
00174 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00175
00176 Tisc_commit_transaction = function(status_vector: PISC_STATUS;
00177 tran_handle: PISC_TR_HANDLE): ISC_STATUS;
00178 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00179
00180 Tisc_transaction_info = function(status_vector: PISC_STATUS;
00181 tr_handle: PISC_TR_HANDLE; item_list_buffer_length: Short;
00182 item_list_buffer: PChar; result_buffer_length: Short;
00183 result_buffer: PChar): ISC_STATUS;
00184 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00185
00186 { Dynamic SQL routines }
00187
00188 Tisc_dsql_allocate_statement = function(status_vector: PISC_STATUS;
00189 db_handle: PISC_DB_HANDLE; stmt_handle: PISC_STMT_HANDLE): ISC_STATUS;
00190 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00191
00192 Tisc_dsql_alloc_statement2 = function(status_vector: PISC_STATUS;
00193 db_handle: PISC_DB_HANDLE; stmt_handle: PISC_STMT_HANDLE): ISC_STATUS;
00194 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00195
00196 Tisc_dsql_describe = function(status_vector: PISC_STATUS;
00197 stmt_handle: PISC_STMT_HANDLE; dialect: Word; xsqlda: PXSQLDA): ISC_STATUS;
00198 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00199
00200 Tisc_dsql_describe_bind = function(status_vector: PISC_STATUS;
00201 stmt_handle: PISC_STMT_HANDLE; dialect: Word; xsqlda: PXSQLDA): ISC_STATUS;
00202 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00203
00204 Tisc_dsql_execute = function(status_vector: PISC_STATUS;
00205 tran_handle: PISC_TR_HANDLE; stmt_handle: PISC_STMT_HANDLE; dialect: Word;
00206 xsqlda: PXSQLDA): ISC_STATUS;
00207 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00208
00209 Tisc_dsql_execute2 = function(status_vector: PISC_STATUS;
00210 tran_handle: PISC_TR_HANDLE; stmt_handle: PISC_STMT_HANDLE; dialect: Word;
00211 in_xsqlda, out_xsqlda: PXSQLDA): ISC_STATUS;
00212 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00213
00214 Tisc_dsql_execute_immediate = function(status_vector: PISC_STATUS;
00215 db_handle: PISC_DB_HANDLE; tran_handle: PISC_TR_HANDLE; length: Word;
00216 statement: PChar; dialect: Word; xsqlda: PXSQLDA): ISC_STATUS;
00217 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00218
00219 Tisc_dsql_fetch = function(status_vector: PISC_STATUS;
00220 stmt_handle: PISC_STMT_HANDLE; dialect: Word; xsqlda: PXSQLDA): ISC_STATUS;
00221 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00222
00223 Tisc_dsql_free_statement = function(status_vector: PISC_STATUS;
00224 stmt_handle: PISC_STMT_HANDLE; options: Word): ISC_STATUS;
00225 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00226
00227 Tisc_dsql_prepare = function(status_vector: PISC_STATUS;
00228 tran_handle: PISC_TR_HANDLE; stmt_handle: PISC_STMT_HANDLE;
00229 length: Word; statement: PChar; dialect: Word; xsqlda: PXSQLDA):
00230 ISC_STATUS; {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00231
00232 Tisc_dsql_set_cursor_name = function(status_vector: PISC_STATUS;
00233 stmt_handle: PISC_STMT_HANDLE; cursor_name: PChar; _type: Word): ISC_STATUS;
00234 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00235
00236 Tisc_dsql_sql_info = function(status_vector: PISC_STATUS;
00237 stmt_handle: PISC_STMT_HANDLE; item_length: Short; items: PChar;
00238 buffer_length: Short; buffer: PChar): ISC_STATUS;
00239 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00240
00241 { Blob processing routines }
00242
00243 Tisc_open_blob2 = function(status_vector: PISC_STATUS;
00244 db_handle: PISC_DB_HANDLE; tran_handle: PISC_TR_HANDLE;
00245 blob_handle: PISC_BLOB_HANDLE; blob_id: PISC_QUAD; bpb_length: Short;
00246 bpb_buffer: PChar): ISC_STATUS;
00247 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00248
00249 Tisc_create_blob2 = function(status_vector: PISC_STATUS;
00250 db_handle: PISC_DB_HANDLE; tran_handle: PISC_TR_HANDLE;
00251 blob_handle: PISC_BLOB_HANDLE; blob_id: PISC_QUAD; bpb_length: Short;
00252 bpb_address: PChar): ISC_STATUS;
00253 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00254
00255 Tisc_blob_info = function(status_vector: PISC_STATUS;
00256 blob_handle: PISC_BLOB_HANDLE; item_list_buffer_length: Short;
00257 item_list_buffer: PChar; result_buffer_length: Short; result_buffer: PChar):
00258 ISC_STATUS; {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00259
00260 Tisc_close_blob = function(status_vector: PISC_STATUS;
00261 blob_handle: PISC_BLOB_HANDLE): ISC_STATUS;
00262 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00263
00264 Tisc_cancel_blob = function(status_vector: PISC_STATUS;
00265 blob_handle: PISC_BLOB_HANDLE): ISC_STATUS;
00266 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00267
00268 Tisc_get_segment = function(status_vector: PISC_STATUS;
00269 blob_handle: PISC_BLOB_HANDLE; actual_seg_length: PWord;
00270 seg_buffer_length: Word; seg_buffer: PChar): ISC_STATUS;
00271 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00272
00273 Tisc_put_segment = function(status_vector: PISC_STATUS;
00274 blob_handle: PISC_BLOB_HANDLE; seg_buffer_len: Word; seg_buffer: PChar):
00275 ISC_STATUS; {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00276
00277 { Event processing routines }
00278
00279 Tisc_event_block = function(event_buffer: PPChar; result_buffer: PPChar;
00280 id_count: Word; event_list: array of PChar): ISC_LONG;
00281 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00282
00283 Tisc_event_counts = procedure(status_vector: PISC_STATUS;
00284 buffer_length: Short; event_buffer: PChar; result_buffer: PChar);
00285 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00286
00287 Tisc_cancel_events = function(status_vector: PISC_STATUS;
00288 db_handle: PISC_DB_HANDLE; event_id: PISC_LONG): ISC_STATUS;
00289 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00290
00291 Tisc_que_events = function(status_vector: PISC_STATUS;
00292 db_handle: PISC_DB_HANDLE; event_id: PISC_LONG; length: Short;
00293 event_buffer: PChar; event_function: TISC_CALLBACK;
00294 event_function_arg: PVoid): ISC_STATUS;
00295 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00296
00297 { Types convertion routines }
00298
00299 Tisc_decode_date = procedure(ib_date: PISC_QUAD; tm_date: PCTimeStructure);
00300 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00301
00302 Tisc_encode_date = procedure(tm_date: PCTimeStructure; ib_date: PISC_QUAD);
00303 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00304
00305 { Interbase Version 6 routines }
00306 Tisc_decode_sql_date = procedure(ib_date: PISC_DATE;
00307 tm_date: PCTimeStructure); {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00308
00309 Tisc_decode_sql_time = procedure(ib_time: PISC_TIME;
00310 tm_date: PCTimeStructure); {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00311
00312 Tisc_decode_timestamp = procedure(ib_timestamp: PISC_TIMESTAMP;
00313 tm_date: PCTimeStructure); {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00314
00315 Tisc_encode_sql_date = procedure(tm_date: PCTimeStructure;
00316 ib_date: PISC_DATE); {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00317
00318 Tisc_encode_sql_time = procedure(tm_date: PCTimeStructure;
00319 ib_time: PISC_TIME); {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00320
00321 Tisc_encode_timestamp = procedure(tm_date: PCTimeStructure;
00322 ib_timestamp: PISC_TIMESTAMP);
00323 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00324
00325 Tisc_vax_integer = function(buffer: PChar; length: Short): ISC_LONG;
00326 {$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF};
00327
00328 { ************* Plain API Function variables definition ************ }
00329
00330 var
00331 { General database routines }
00332 isc_attach_database: Tisc_attach_database;
00333 isc_detach_database: Tisc_detach_database;
00334 isc_drop_database: Tisc_drop_database;
00335 isc_database_info: Tisc_database_info;
00336 isc_free: Tisc_free;
00337 isc_sqlcode: Tisc_sqlcode;
00338 isc_sql_interprete: Tisc_sql_interprete;
00339 isc_interprete: Tisc_interprete;
00340
00341 { Transaction support routines }
00342 isc_start_transaction: Tisc_start_transaction;
00343 isc_start_multiple: Tisc_start_multiple;
00344 isc_rollback_transaction: Tisc_rollback_transaction;
00345 isc_rollback_retaining: Tisc_rollback_retaining;
00346 isc_commit_transaction: Tisc_commit_transaction;
00347 isc_commit_retaining: Tisc_commit_retaining;
00348 isc_transaction_info: Tisc_transaction_info;
00349
00350 { Dynamic SQL routines }
00351 isc_dsql_allocate_statement: Tisc_dsql_allocate_statement;
00352 isc_dsql_alloc_statement2: Tisc_dsql_alloc_statement2;
00353 isc_dsql_describe: Tisc_dsql_describe;
00354 isc_dsql_describe_bind: Tisc_dsql_describe_bind;
00355 isc_dsql_execute: Tisc_dsql_execute;
00356 isc_dsql_execute2: Tisc_dsql_execute2;
00357 isc_dsql_execute_immediate: Tisc_dsql_execute_immediate;
00358 isc_dsql_fetch: Tisc_dsql_fetch;
00359 isc_dsql_free_statement: Tisc_dsql_free_statement;
00360 isc_dsql_prepare: Tisc_dsql_prepare;
00361 isc_dsql_set_cursor_name: Tisc_dsql_set_cursor_name;
00362 isc_dsql_sql_info: Tisc_dsql_sql_info;
00363
00364 { Array processing routines }
00365 isc_array_gen_sdl: Tisc_array_gen_sdl;
00366 isc_array_get_slice: Tisc_array_get_slice;
00367 isc_array_lookup_bounds: Tisc_array_lookup_bounds;
00368 isc_array_lookup_desc: Tisc_array_lookup_desc;
00369 isc_array_set_desc: Tisc_array_set_desc;
00370 isc_array_put_slice: Tisc_array_put_slice;
00371
00372 { Blob processing routines }
00373 isc_open_blob2: Tisc_open_blob2;
00374 isc_create_blob2: Tisc_create_blob2;
00375 isc_blob_info: Tisc_blob_info;
00376 isc_close_blob: Tisc_close_blob;
00377 isc_cancel_blob: Tisc_cancel_blob;
00378 isc_get_segment: Tisc_get_segment;
00379 isc_put_segment: Tisc_put_segment;
00380
00381 { Event processing routines }
00382 isc_que_events: Tisc_que_events;
00383 isc_event_counts: Tisc_event_counts;
00384 isc_event_block: Tisc_event_block;
00385 isc_cancel_events: Tisc_cancel_events;
00386
00387 { Types convertion routines }
00388 isc_encode_date: Tisc_encode_date;
00389 isc_decode_date: Tisc_decode_date;
00390 isc_vax_integer: Tisc_vax_integer;
00391
00392 isc_encode_sql_date: Tisc_encode_sql_date;
00393 isc_decode_sql_date: Tisc_decode_sql_date;
00394
00395 isc_encode_sql_time: Tisc_encode_sql_time;
00396 isc_decode_sql_time: Tisc_decode_sql_time;
00397
00398 isc_encode_timestamp: Tisc_encode_timestamp;
00399 isc_decode_timestamp: Tisc_decode_timestamp;
00400
00401 var
00402 LibraryLoader: TZNativeLibraryLoader;
00403 LibraryLoaderEmbedded: TZNativeLibraryLoader;
00404
00405 implementation
00406
00407 uses SysUtils,
00408 {$IFNDEF UNIX}
00409 Windows,
00410 {$ELSE}
00411 {$IFNDEF FPC}
00412 libc,
00413 {$ENDIF}
00414 {$ENDIF}
00415 ZMessages;
00416
00417 {$IFDEF UNIX}
00418 {$IFDEF INTERBASE_CRYPT}
00419 {$DEFINE ENABLE_INTERBASE_CRYPT}
00420 {$ENDIF}
00421 {$ENDIF}
00422
00423 type
00424 {** Implements a loader for Firebird native library. }
00425 TZFirebirdNativeLibraryLoader = class (TZNativeLibraryLoader)
00426 {$IFDEF ENABLE_INTERBASE_CRYPT}
00427 private
00428 FPreLocations: TStringDynArray;
00429 FPreHandle: LongWord;
00430 FPreLoaded: Boolean;
00431 FPreRequared: boolean;
00432 protected
00433 function LoadNativeLibrary: Boolean; override;
00434 procedure FreeNativeLibrary; override;
00435
00436 public
00437 constructor Create(PreLocations, Locations: array of string;
00438 PreRequared: boolean = False); overload;
00439
00440 property PreHandle: LongWord read FPreHandle write FPreHandle;
00441 property PreLoaded: Boolean read FPreLoaded write FPreLoaded;
00442 {$ENDIF}
00443 public
00444 function Load: Boolean; override;
00445 end;
00446
00447 { TZFirebirdNativeLibraryLoader }
00448
00449 {**
00450 Creates this loader class and assignes main properties.
00451 @param Locations locations of native library on windows platform.
00452 }
00453 {$IFDEF ENABLE_INTERBASE_CRYPT}
00454 constructor TZFirebirdNativeLibraryLoader.Create(PreLocations,
00455 Locations: array of string; PreRequared: boolean);
00456 var
00457 I: Integer;
00458 begin
00459 inherited Create(Locations);
00460 SetLength(FPreLocations, Length(PreLocations));
00461 for I := 0 to High(PreLocations) do
00462 FPreLocations[I] := PreLocations[I];
00463 FPreRequared := PreRequared;
00464 end;
00465 {$ENDIF}
00466
00467 {**
00468 Frees a previously loaded library.
00469 }
00470 {$IFDEF ENABLE_INTERBASE_CRYPT}
00471 procedure TZFirebirdNativeLibraryLoader.FreeNativeLibrary;
00472 begin
00473 inherited FreeNativeLibrary;
00474 if (PreHandle <> 0) and Loaded then
00475 FreeLibrary(PreHandle);
00476 PreHandle := 0;
00477 PreLoaded := False;
00478 end;
00479 {$ENDIF}
00480
00481 {**
00482 Loads a library module.
00483 @return <code>True</code> if library was successfully loaded.
00484 }
00485 function TZFirebirdNativeLibraryLoader.Load: Boolean;
00486 begin
00487 Result := inherited Load;
00488
00489 isc_sqlcode := GetAddress('isc_sqlcode');
00490 isc_sql_interprete := GetAddress('isc_sql_interprete');
00491 isc_interprete := GetAddress('isc_interprete');
00492 isc_vax_integer := GetAddress('isc_vax_integer');
00493
00494 isc_array_gen_sdl := GetAddress( 'isc_array_gen_sdl');
00495 isc_array_get_slice := GetAddress( 'isc_array_get_slice');
00496 isc_array_lookup_bounds := GetAddress( 'isc_array_lookup_bounds');
00497 isc_array_lookup_desc := GetAddress( 'isc_array_lookup_desc');
00498 isc_array_set_desc := GetAddress( 'isc_array_set_desc');
00499 isc_array_put_slice := GetAddress( 'isc_array_put_slice');
00500
00501 isc_blob_info := GetAddress('isc_blob_info');
00502 isc_open_blob2 := GetAddress('isc_open_blob2');
00503 isc_close_blob := GetAddress('isc_close_blob');
00504 isc_cancel_blob := GetAddress('isc_cancel_blob');
00505 isc_get_segment := GetAddress('isc_get_segment');
00506 isc_put_segment := GetAddress('isc_put_segment');
00507 isc_create_blob2 := GetAddress('isc_create_blob2');
00508 isc_decode_date := GetAddress('isc_decode_date');
00509 isc_encode_date := GetAddress('isc_encode_date');
00510 isc_dsql_free_statement := GetAddress('isc_dsql_free_statement');
00511 isc_dsql_execute2 := GetAddress('isc_dsql_execute2');
00512 isc_dsql_execute := GetAddress('isc_dsql_execute');
00513 isc_dsql_set_cursor_name := GetAddress('isc_dsql_set_cursor_name');
00514 isc_dsql_fetch := GetAddress('isc_dsql_fetch');
00515 isc_dsql_sql_info := GetAddress('isc_dsql_sql_info');
00516 isc_dsql_allocate_statement := GetAddress('isc_dsql_allocate_statement');
00517 isc_dsql_alloc_statement2 := GetAddress('isc_dsql_alloc_statement2');
00518 isc_dsql_prepare := GetAddress('isc_dsql_prepare');
00519 isc_dsql_describe_bind := GetAddress('isc_dsql_describe_bind');
00520 isc_dsql_describe := GetAddress('isc_dsql_describe');
00521 isc_dsql_execute_immediate := GetAddress('isc_dsql_execute_immediate');
00522 isc_drop_database := GetAddress('isc_drop_database');
00523 isc_detach_database := GetAddress('isc_detach_database');
00524 isc_attach_database := GetAddress('isc_attach_database');
00525 isc_database_info := GetAddress('isc_database_info');
00526 isc_transaction_info := GetAddress('isc_transaction_info');
00527 isc_start_multiple := GetAddress('isc_start_multiple');
00528 isc_start_transaction := GetAddress('isc_start_transaction');
00529 isc_commit_transaction := GetAddress('isc_commit_transaction');
00530
00531 isc_commit_retaining := GetAddress('isc_commit_retaining');
00532 isc_rollback_transaction := GetAddress('isc_rollback_transaction');
00533 isc_cancel_events := GetAddress('isc_cancel_events');
00534 isc_que_events := GetAddress('isc_que_events');
00535 isc_event_counts := GetAddress('isc_event_counts');
00536 isc_event_block := GetAddress('isc_event_block');
00537 isc_free := GetAddress('isc_free');
00538
00539 isc_rollback_retaining := GetAddress( 'isc_rollback_retaining');
00540 isc_decode_sql_date := GetAddress('isc_decode_sql_date');
00541 isc_decode_sql_time := GetAddress('isc_decode_sql_time');
00542 isc_decode_timestamp := GetAddress('isc_decode_timestamp');
00543 isc_encode_sql_date := GetAddress('isc_encode_sql_date');
00544 isc_encode_sql_time := GetAddress('isc_encode_sql_time');
00545 isc_encode_timestamp := GetAddress('isc_encode_timestamp');
00546 end;
00547
00548 {**
00549 Loads a library module and initializes the handle.
00550 @return <code>True</code> is library was successfully loaded.
00551 }
00552 {$IFDEF ENABLE_INTERBASE_CRYPT}
00553 function TZFirebirdNativeLibraryLoader.LoadNativeLibrary: Boolean;
00554 var
00555 I: Integer;
00556 Location: string;
00557 TriedLocations: string;
00558 begin
00559 if Length(FPreLocations) <> 0 then
00560 begin
00561 PreLoaded := False;
00562 Location := '';
00563 TriedLocations := '';
00564 if PreHandle = 0 then
00565 begin
00566 for I := 0 to High(FPreLocations) do
00567 begin
00568 Location := FPreLocations[I];
00569
00570
00571
00572 {$IFDEF UNIX}
00573 {$IFDEF FPC}
00574 PreHandle := ZCompatibility.LoadLibrary(PChar(Location));
00575 {$ELSE}
00576 PreHandle := HMODULE(dlopen(PChar(Location), RTLD_GLOBAL));
00577 {$ENDIF}
00578 {$ELSE}
00579 PreHandle := LoadLibrary(PChar(Location));
00580 {$ENDIF}
00581
00582 if PreHandle <> 0 then
00583 begin
00584 PreLoaded := True;
00585 Break;
00586 end;
00587 if TriedLocations <> '' then
00588 TriedLocations := TriedLocations + ', ';
00589 TriedLocations := TriedLocations + Location;
00590 end;
00591 end;
00592
00593 if (not PreLoaded) and (FPreRequared) then
00594 raise Exception.Create(Format(SLibraryNotFound, [TriedLocations]));
00595 end;
00596
00597 Result := inherited LoadNativeLibrary;
00598 end;
00599 {$ENDIF}
00600
00601 initialization
00602 {$IFNDEF UNIX}
00603 LibraryLoader := TZFirebirdNativeLibraryLoader.Create(
00604 [WINDOWS1_DLL_LOCATION
00605 {$IFNDEF FIREBIRD_STRICT_DLL_LOADING}
00606 ,WINDOWS2_DLL_LOCATION
00607 {$ENDIF}
00608 ]);
00609 LibraryLoaderEmbedded := TZFirebirdNativeLibraryLoader.Create(
00610 [WINDOWS1_DLL_LOCATION_EMBEDDED
00611 {$IFNDEF FIREBIRD_STRICT_DLL_LOADING}
00612 ,WINDOWS2_DLL_LOCATION_EMBEDDED
00613 {$ENDIF}
00614 ]);
00615
00616 {$ELSE}
00617 {$IFDEF ENABLE_INTERBASE_CRYPT}
00618 LibraryLoader := TZFirebirdNativeLibraryLoader.Create(
00619 [LINUX1_IB_CRYPT_LOCATION
00620 {$IFNDEF FIREBIRD_STRICT_DLL_LOADING}
00621 , LINUX2_IB_CRYPT_LOCATION
00622 {$ENDIF}
00623 ],[LINUX1_DLL_LOCATION
00624
00625 {$IFNDEF FIREBIRD_STRICT_DLL_LOADING}
00626 ,LINUX2_DLL_LOCATION
00627 {$ENDIF}
00628 ]);
00629
00630 LibraryLoaderEmbedded := TZFirebirdNativeLibraryLoader.Create(
00631 [LINUX1_IB_CRYPT_LOCATION
00632 {$IFNDEF FIREBIRD_STRICT_DLL_LOADING}
00633 ,LINUX2_IB_CRYPT_LOCATION
00634 {$ENDIF}
00635 ], [LINUX1_DLL_LOCATION_EMBEDDED
00636 {$IFNDEF FIREBIRD_STRICT_DLL_LOADING}
00637 ,LINUX2_DLL_LOCATION_EMBEDDED
00638 {$ENDIF}
00639 ]);
00640 {$ELSE}
00641 LibraryLoader := TZFirebirdNativeLibraryLoader.Create(
00642 [LINUX1_DLL_LOCATION
00643 {$IFNDEF FIREBIRD_STRICT_DLL_LOADING}
00644 ,LINUX2_DLL_LOCATION
00645 {$ENDIF}
00646 ]);
00647 LibraryLoaderEmbedded := TZFirebirdNativeLibraryLoader.Create(
00648 [LINUX1_DLL_LOCATION_EMBEDDED
00649 {$IFNDEF FIREBIRD_STRICT_DLL_LOADING}
00650 ,LINUX2_DLL_LOCATION_EMBEDDED
00651 {$ENDIF}
00652 ]);
00653 {$ENDIF}
00654 {$ENDIF}
00655 finalization
00656 if Assigned(LibraryLoader) then
00657 LibraryLoader.Free;
00658 if Assigned(LibraryLoaderEmbedded) then
00659 LibraryLoaderEmbedded.Free;
00660
00661 end.