| 1 |
/* |
| 2 |
* The contents of this file are subject to the Initial |
| 3 |
* Developer's Public License Version 1.0 (the "License"); |
| 4 |
* you may not use this file except in compliance with the |
| 5 |
* License. You may obtain a copy of the License at |
| 6 |
* http://www.ibphoenix.com/main.nfs?a=ibphoenix&page=ibp_idpl. |
| 7 |
* |
| 8 |
* Software distributed under the License is distributed AS IS, |
| 9 |
* WITHOUT WARRANTY OF ANY KIND, either express or implied. |
| 10 |
* See the License for the specific language governing rights |
| 11 |
* and limitations under the License. |
| 12 |
* |
| 13 |
* The Original Code was created by Mark O'Donohue |
| 14 |
* for the Firebird Open Source RDBMS project. |
| 15 |
* |
| 16 |
* Copyright (c) 2002 Mark O'Donohue <[email protected]> |
| 17 |
* and all contributors signed below. |
| 18 |
* |
| 19 |
* All Rights Reserved. |
| 20 |
* Contributor(s): ______________________________________. |
| 21 |
* 25 May 2003 - Nickolay Samofatov: Fix several bugs that prevented |
| 22 |
* compatibility with Kylix |
| 23 |
* |
| 24 |
*/ |
| 25 |
|
| 26 |
#include "firebird.h" |
| 27 |
|
| 28 |
#ifdef HAVE_UNISTD_H |
| 29 |
#include <unistd.h> |
| 30 |
#endif |
| 31 |
|
| 32 |
#include "fb_types.h" |
| 33 |
#include "../common/classes/fb_string.h" |
| 34 |
#include "../yvalve/config/os/config_root.h" |
| 35 |
#include "../common/os/path_utils.h" |
| 36 |
#include "binreloc.h" |
| 37 |
|
| 38 |
typedef Firebird::PathName string; |
| 39 |
|
| 40 |
/****************************************************************************** |
| 41 |
* |
| 42 |
* Platform-specific root locator |
| 43 |
*/ |
| 44 |
|
| 45 |
void ConfigRoot::osConfigRoot() |
| 46 |
{ |
| 47 |
// Try to use value set at configure time |
| 48 |
if (FB_CONFDIR[0]) |
| 49 |
{ |
| 50 |
root_dir = FB_CONFDIR; |
| 51 |
if (root_dir[root_dir.length() - 1] != PathUtils::dir_sep) |
| 52 |
{ |
| 53 |
root_dir += PathUtils::dir_sep; |
| 54 |
} |
| 55 |
return; |
| 56 |
} |
| 57 |
|
| 58 |
// As a last resort get it from the default install directory |
| 59 |
root_dir = install_dir + PathUtils::dir_sep; |
| 60 |
} |
| 61 |
|
| 62 |
|
| 63 |
void ConfigRoot::osConfigInstallDir() |
| 64 |
{ |
| 65 |
#ifdef ENABLE_BINRELOC |
| 66 |
BrInitError brError; |
| 67 |
if (br_init_lib(&brError)) |
| 68 |
{ |
| 69 |
char* temp = br_find_exe_dir(NULL); |
| 70 |
if (temp) |
| 71 |
{ |
| 72 |
string dummy; |
| 73 |
PathUtils::splitLastComponent(install_dir, dummy, temp); |
| 74 |
free(temp); |
| 75 |
return; |
| 76 |
} |
| 77 |
} |
| 78 |
#endif |
| 79 |
|
| 80 |
// As a last resort get it from the default install directory |
| 81 |
install_dir = string(FB_PREFIX); |
| 82 |
} |