101 |
|
isc_delete_user: Tisc_delete_user; |
102 |
|
isc_modify_user: Tisc_modify_user; |
103 |
|
|
104 |
+ |
FBLibraryName: string; |
105 |
+ |
|
106 |
|
|
107 |
|
{ Library Initialization } |
108 |
|
procedure LoadIBLibrary; |
110 |
|
function TryIBLoad: Boolean; |
111 |
|
procedure CheckIBLoaded; |
112 |
|
|
113 |
+ |
{Utility} |
114 |
+ |
function IsEmbeddedServer: boolean; |
115 |
+ |
|
116 |
|
{ Stubs for 6.0 only functions } |
117 |
|
function isc_rollback_retaining_stub(status_vector : PISC_STATUS; |
118 |
|
tran_handle : PISC_TR_HANDLE): |
182 |
|
|
183 |
|
uses Sysutils, IB, Dynlibs, Classes |
184 |
|
{$IFDEF WINDOWS} |
185 |
< |
, Registry |
185 |
> |
, Registry, WinDirs |
186 |
|
{$ENDIF} |
187 |
|
; |
188 |
|
|
211 |
|
for i := 0 to LibNames.Count - 1 do |
212 |
|
begin |
213 |
|
Result := LoadLibrary(LibNames[i]); |
214 |
< |
if Result <> NilHandle then Exit; |
214 |
> |
if Result <> NilHandle then |
215 |
> |
begin |
216 |
> |
FBLibraryName := LibNames[i]; |
217 |
> |
Exit; |
218 |
> |
end; |
219 |
|
end; |
220 |
|
finally |
221 |
|
LibNames.Free; |
243 |
|
|
244 |
|
LibName := '/Library/Frameworks/Firebird.framework/Firebird'; |
245 |
|
Result := LoadLibrary(LibName); |
246 |
+ |
if Result <> NilHandle then |
247 |
+ |
FBLibraryName := ExtractFileName(LibName); |
248 |
|
end |
249 |
|
{$ENDIF} |
250 |
|
end; |
251 |
|
{$ENDIF} |
252 |
|
{$IFDEF WINDOWS} |
253 |
+ |
function DoLoadLibrary(LibName: string): TLibHandle; |
254 |
+ |
begin |
255 |
+ |
Result := LoadLibrary(LibName); |
256 |
+ |
if Result <> NilHandle then |
257 |
+ |
FBLibraryName := ExtractFileName(LibName); |
258 |
+ |
end; |
259 |
+ |
|
260 |
|
function InternalLoadLibrary: TLibHandle; |
261 |
|
var InstallDir: string; |
262 |
|
dllPathName: string; |
263 |
|
begin |
264 |
+ |
Result := NilHandle; |
265 |
+ |
{If OnGetLibraryName given then use this} |
266 |
|
if assigned(OnGetLibraryName) then |
267 |
|
begin |
268 |
|
OnGetLibraryName(dllPathName); |
269 |
< |
Result := LoadLibrary(dllPathName); |
269 |
> |
Result := DoLoadLibrary(dllPathName); |
270 |
|
Exit |
271 |
|
end; |
272 |
|
|
273 |
+ |
{Then look in application installation directory} |
274 |
+ |
InstallDir := ExtractFilePath(Paramstr(0)); {Using ParamStr(0) assumes windows conventions} |
275 |
+ |
|
276 |
|
//First look for Firebird Embedded Server in installation dir |
254 |
– |
InstallDir := ExtractFilePath(Paramstr(0)); {Using ParamStr(0) assumes windows conventions} |
277 |
|
if FileExists(InstallDir + FIREBIRD_EMBEDDED) then |
278 |
|
begin |
279 |
|
dllPathName := InstallDir + FIREBIRD_EMBEDDED; |
280 |
< |
Result := LoadLibrary(dllPathName) |
280 |
> |
Result := DoLoadLibrary(dllPathName) |
281 |
|
end |
282 |
|
else |
283 |
|
//Otherwise look for Firebird Client in installation dir |
286 |
|
//assume firebird.conf and firebird.msg in same dir |
287 |
|
SetEnvironmentVariable('FIREBIRD',PChar(InstallDir)); |
288 |
|
dllPathName := InstallDir +FIREBIRD_CLIENT; |
289 |
< |
Result := LoadLibrary(dllPathName) |
290 |
< |
end |
291 |
< |
else |
292 |
< |
//Use Registry key if it exists to locate library |
289 |
> |
Result := DoLoadLibrary(dllPathName) |
290 |
> |
end; |
291 |
> |
|
292 |
> |
{If FIREBIRD environment variable available then try this} |
293 |
> |
if Result = NilHandle then |
294 |
> |
begin |
295 |
> |
InstallDir := GetEnvironmentVariable('FIREBIRD'); |
296 |
> |
if (InstallDir <> '') and FileExists(InstallDir + FIREBIRD_CLIENT) then |
297 |
> |
begin |
298 |
> |
//assume firebird.conf and firebird.msg in same dir |
299 |
> |
dllPathName := InstallDir + FIREBIRD_CLIENT; |
300 |
> |
Result := DoLoadLibrary(dllPathName) |
301 |
> |
end |
302 |
> |
else |
303 |
> |
if (InstallDir <> '') and FileExists(InstallDir + 'bin' + DirectorySeparator + FIREBIRD_CLIENT) then |
304 |
> |
begin |
305 |
> |
dllPathName := InstallDir + FIREBIRD_CLIENT; |
306 |
> |
Result := DoLoadLibrary(dllPathName) |
307 |
> |
end |
308 |
> |
end; |
309 |
> |
|
310 |
> |
if Result = NilHandle then |
311 |
> |
{Use Registry key if it exists to locate library} |
312 |
|
begin |
313 |
|
with TRegistry.Create do |
314 |
|
try |
317 |
|
begin |
318 |
|
if ValueExists('DefaultInstance') then |
319 |
|
begin |
320 |
< |
dllPathName := ReadString('DefaultInstance') + 'bin' + DirectorySeparator + FIREBIRD_CLIENT; |
321 |
< |
if FileExists(dllPathName) then |
322 |
< |
begin |
282 |
< |
Result := LoadLibrary(dllPathName); |
283 |
< |
Exit |
284 |
< |
end |
320 |
> |
InstallDir := ReadString('DefaultInstance') + 'bin' + DirectorySeparator ; |
321 |
> |
dllPathName := InstallDir + FIREBIRD_CLIENT; |
322 |
> |
Result := DoLoadLibrary(dllPathName) |
323 |
|
end |
324 |
|
end |
325 |
|
finally |
326 |
|
Free |
327 |
|
end; |
328 |
|
|
329 |
+ |
{Now try default install dir} |
330 |
+ |
if Result = NilHandle then |
331 |
+ |
begin |
332 |
+ |
InstallDir := GetWindowsSpecialDir(CSIDL_PROGRAM_FILES) + |
333 |
+ |
DirectorySeparator + 'Firebird' + |
334 |
+ |
DirectorySeparator + 'Firebird_2_5' + |
335 |
+ |
DirectorySeparator + 'bin' + DirectorySeparator; |
336 |
+ |
dllPathName := InstallDir + FIREBIRD_CLIENT; |
337 |
+ |
Result := DoLoadLibrary(dllPathName) |
338 |
+ |
end; |
339 |
+ |
|
340 |
|
//Otherwise see if Firebird client is in path |
341 |
|
//and rely on registry for location of firebird.conf and firebird.msg |
342 |
< |
Result := LoadLibrary(FIREBIRD_CLIENT); |
343 |
< |
if Result <= HINSTANCE_ERROR then |
342 |
> |
if Result = NilHandle then |
343 |
> |
begin |
344 |
> |
Result := DoLoadLibrary(FIREBIRD_CLIENT); |
345 |
> |
if Result <= HINSTANCE_ERROR then |
346 |
|
//well maybe InterBase is present... |
347 |
< |
Result := LoadLibrary(IBASE_DLL); |
347 |
> |
Result := DoLoadLibrary(IBASE_DLL); |
348 |
> |
end; |
349 |
|
end |
350 |
|
end; |
351 |
|
{$ENDIF} |
455 |
|
IBError(ibxeInterBaseMissing, [nil]); |
456 |
|
end; |
457 |
|
|
458 |
+ |
function IsEmbeddedServer: boolean; |
459 |
+ |
begin |
460 |
+ |
Result := false; |
461 |
+ |
{$IFDEF UNIX} |
462 |
+ |
Result := Pos('libfbembed',FBLibraryName) = 1; |
463 |
+ |
{$ENDIF} |
464 |
+ |
{$IFDEF WINDOWS} |
465 |
+ |
Result := CompareText(FBLibraryName,FIREBIRD_EMBEDDED) = 0 |
466 |
+ |
{$ENDIF} |
467 |
+ |
end; |
468 |
|
|
469 |
|
function isc_rollback_retaining_stub(status_vector : PISC_STATUS; |
470 |
|
tran_handle : PISC_TR_HANDLE): |