8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-22 16:03:03 +01:00

Partial change to load RootDirectory from /etc/firebird.conf file

plus some more install/compile things
This commit is contained in:
skywalker 2001-08-20 08:15:33 +00:00
parent 115a8cd074
commit 83f8c38cf0
13 changed files with 342 additions and 214 deletions

View File

@ -1,74 +1,21 @@
#include "firebird.h"
#include "FirebirdConfig.h"
#include "FirebirdConfigFile.h"
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
//-----------------------------------------------------------------------------
//
// The instance of the static class variable.
//
FirebirdConfig FirebirdConfig::sysConfig;
//-----------------------------------------------------------------------------
//
//
//
void stripLeadingWhiteSpace(string& s)
{
if (!s.size()) {
return;
}
const string::size_type startPos = s.find_first_not_of(" \t");
if (startPos == string::npos) {
s.erase(); // nothing but air
} else if (startPos) {
s = s.substr(startPos);
}
}
//-----------------------------------------------------------------------------
//
//
//
void stripTrailingWhiteSpace(string& s)
{
if (!s.size()) {
return;
}
string::size_type endPos = s.find_last_not_of(" \t");
if (endPos != string::npos) {
// Note that endPos is the index to the last non-ws char
// why we have to inc. it
++endPos;
s = s.substr(0, endPos);
}
}
//-----------------------------------------------------------------------------
//
//
//
void stripComments(string& s)
{
// Note that this is only a hack. It won't work in case inputLine
// contains hash-marks embedded in quotes! Not that I know if we
// should care about that case.
const string::size_type commentPos = s.find('#');
if (commentPos != string::npos) {
s = s.substr(0, commentPos);
}
}
static FirebirdConfigFile sysConfig;
//static FirebirdConfigReg sysConfig; // I would expect win32 to have this one.
//-----------------------------------------------------------------------------
//
@ -93,123 +40,23 @@ int FirebirdConfig::getSysInt(const string& key) {
//
//
//
string FirebirdConfig::getString(const string& key) {
mymap_t::iterator lookup;
lookup = parameters.find(key);
if (lookup != parameters.end()) {
return lookup->second;
}
return string();
}
//-----------------------------------------------------------------------------
//
//
//
int FirebirdConfig::getInt(const string& key) {
string data = getString(key);
if (data.empty()) {
return 0;
}
return atoi(data.data());
}
//-----------------------------------------------------------------------------
//
//
//
string parseKeyFrom(const string& inputLine, string::size_type& endPos) {
endPos = inputLine.find_first_of("= \t");
if (endPos == string::npos) {
return inputLine;
}
return inputLine.substr(0, endPos);
}
//-----------------------------------------------------------------------------
//
//
//
string parseValueFrom(string inputLine, string::size_type initialPos) {
if (initialPos == string::npos) {
return string();
}
// skip leading white spaces
int startPos = inputLine.find_first_not_of("= \t", initialPos);
if (startPos == string::npos) {
return string();
}
stripTrailingWhiteSpace(inputLine);
return inputLine.substr(startPos);
}
//-----------------------------------------------------------------------------
//
//
//
void FirebirdConfig::loadSysConfig() {
sysConfig.loadConfig();
sysConfig.loadConfig();
}
//-----------------------------------------------------------------------------
//
//
//
void FirebirdConfig::loadConfig() {
ifstream configFile("/etc/firebird.conf");
string inputLine;
while (!configFile.eof()) {
getline(configFile, inputLine);
stripComments(inputLine);
stripLeadingWhiteSpace(inputLine);
if (!inputLine.size()) {
continue; // comment-line or empty line
}
// cout << "read \"" << inputLine << "\"\n";
if (inputLine.find('=') == string::npos) {
cerr << "illegal line \"" << inputLine << "\"" << endl;
continue;
}
string::size_type endPos;
string key = parseKeyFrom(inputLine, endPos);
string value = parseValueFrom(inputLine, endPos);
cout << "adding \"" << key << "\" \"" << value << "\"" << endl;
// parameters.insert(pair<string, string>(key, value));
// Just to display yet another template function
parameters.insert(make_pair(key, value));
}
const string FirebirdConfig::getSysConfigFile() {
return sysConfig.getConfigFile();
}
//-----------------------------------------------------------------------------
//
//
//
void FirebirdConfig::setSysConfigFile(const string& newFile) {
sysConfig.setConfigFile(newFile);
}

View File

@ -4,27 +4,32 @@
#include <iostream>
#include <fstream>
#include <map>
#include <string>
class FirebirdConfig {
public:
static string getSysString(const string& key);
static int getSysInt(const string& key);
static void loadSysConfig();
void loadConfig();
string getString(const string& key);
int getInt(const string& key);
static string getSysString(const string& key);
static int getSysInt(const string& key);
static void loadSysConfig();
static const string getSysConfigFile();
static void setSysConfigFile(const string& newFile);
private:
typedef pair<string, string> mypair;
typedef map<string, string> mymap_t;
mymap_t parameters;
static FirebirdConfig sysConfig;
FirebirdConfig() {}
virtual const string getConfigFile()= 0;
virtual void setConfigFile(const string& newFile)= 0;
virtual bool getIsLoadedFlg()= 0;
virtual void setIsLoadedFlg(bool newFlg)= 0;
virtual void loadConfig()= 0;
virtual void checkLoadConfig()= 0;
virtual string getString(const string& key) = 0;
virtual int getInt(const string& key) = 0;
virtual ~FirebirdConfig() {}
};

View File

@ -0,0 +1,208 @@
#include "firebird.h"
#include "FirebirdConfigFile.h"
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
//-----------------------------------------------------------------------------
//
//
//
FirebirdConfigFile::FirebirdConfigFile()
{
isLoadedFlg = false;
configFile = "/etc/firebird.conf";
}
//-----------------------------------------------------------------------------
//
//
//
void stripLeadingWhiteSpace(string& s)
{
if (!s.size()) {
return;
}
const string::size_type startPos = s.find_first_not_of(" \t");
if (startPos == string::npos) {
s.erase(); // nothing but air
} else if (startPos) {
s = s.substr(startPos);
}
}
//-----------------------------------------------------------------------------
//
//
//
void stripTrailingWhiteSpace(string& s)
{
if (!s.size()) {
return;
}
string::size_type endPos = s.find_last_not_of(" \t");
if (endPos != string::npos) {
// Note that endPos is the index to the last non-ws char
// why we have to inc. it
++endPos;
s = s.substr(0, endPos);
}
}
//-----------------------------------------------------------------------------
//
//
//
void stripComments(string& s)
{
// Note that this is only a hack. It won't work in case inputLine
// contains hash-marks embedded in quotes! Not that I know if we
// should care about that case.
const string::size_type commentPos = s.find('#');
if (commentPos != string::npos) {
s = s.substr(0, commentPos);
}
}
//-----------------------------------------------------------------------------
//
//
//
string FirebirdConfigFile::getString(const string& key) {
checkLoadConfig();
mymap_t::iterator lookup;
lookup = parameters.find(key);
if (lookup != parameters.end()) {
return lookup->second;
}
return string();
}
//-----------------------------------------------------------------------------
//
//
//
int FirebirdConfigFile::getInt(const string& key) {
checkLoadConfig();
string data = getString(key);
if (data.empty()) {
return 0;
}
return atoi(data.data());
}
//-----------------------------------------------------------------------------
//
//
//
string parseKeyFrom(const string& inputLine, string::size_type& endPos) {
endPos = inputLine.find_first_of("= \t");
if (endPos == string::npos) {
return inputLine;
}
return inputLine.substr(0, endPos);
}
//-----------------------------------------------------------------------------
//
//
//
string parseValueFrom(string inputLine, string::size_type initialPos) {
if (initialPos == string::npos) {
return string();
}
// skip leading white spaces
unsigned int startPos = inputLine.find_first_not_of("= \t", initialPos);
if (startPos == string::npos) {
return string();
}
stripTrailingWhiteSpace(inputLine);
return inputLine.substr(startPos);
}
//-----------------------------------------------------------------------------
//
//
//
void FirebirdConfigFile::checkLoadConfig() {
if (!isLoadedFlg) {
loadConfig();
}
}
//-----------------------------------------------------------------------------
//
//
//
void FirebirdConfigFile::loadConfig() {
ifstream configFile(configFile.c_str());
string inputLine;
while (!configFile.eof()) {
getline(configFile, inputLine);
stripComments(inputLine);
stripLeadingWhiteSpace(inputLine);
if (!inputLine.size()) {
continue; // comment-line or empty line
}
// cout << "read \"" << inputLine << "\"\n";
if (inputLine.find('=') == string::npos) {
cerr << "illegal line \"" << inputLine << "\"" << endl;
continue;
}
string::size_type endPos;
string key = parseKeyFrom(inputLine, endPos);
string value = parseValueFrom(inputLine, endPos);
cout << "adding \"" << key << "\" \"" << value << "\"" << endl;
// parameters.insert(pair<string, string>(key, value));
// Just to display yet another template function
parameters.insert(make_pair(key, value));
}
}

View File

@ -0,0 +1,38 @@
#ifndef _FirebirdConfigFile_H
#define _FirebirdConfigFile_H
#include <iostream>
#include <fstream>
#include <map>
#include <string>
#include "FirebirdConfig.h"
class FirebirdConfigFile : FirebirdConfig {
public:
FirebirdConfigFile();
const string getConfigFile() { return configFile; }
void setConfigFile(const string& newFile) { configFile = newFile; }
bool getIsLoadedFlg() { return isLoadedFlg; }
void setIsLoadedFlg(bool newFlg) { isLoadedFlg = newFlg; }
void loadConfig();
void checkLoadConfig();
string getString(const string& key);
int getInt(const string& key);
private:
string configFile;
bool isLoadedFlg;
typedef pair<string, string> mypair;
typedef map<string, string> mymap_t;
mymap_t parameters;
};
#endif

View File

@ -26,7 +26,7 @@
# Contributor(s):
#
#
# $Id: Makefile.in,v 1.5 2001-08-15 18:10:35 skywalker Exp $
# $Id: Makefile.in,v 1.6 2001-08-20 08:15:32 skywalker Exp $
#
ROOT=../..
@ -38,11 +38,15 @@ include $(ROOT)/src/make.defaults
include $(ROOT)/src/make.platform
include $(ROOT)/src/make.shared.variables
FirebirdInstallPrefix=@prefix@
@SET_MAKE@
FIREBIRD=$(FirebirdInstallPrefix)/firebird
export -n FIREBIRD
export -n INTERBASE
.PHONY: all CSrpmscript SSrpmscript ssinstall runclassicinstall \
classicpackages

View File

@ -87,26 +87,25 @@
cp -f $BuildDir/include/ibase.h /usr/include/ibase.h
cp -f $BuildDir/include/ib_util.h /usr/include/ib_util.h
cp $BuildDir/include/gds.f $DestDir/include
cp $BuildDir/include/gds.hxx $DestDir/include
# cp $BuildDir/include/gds.f $DestDir/include
# cp $BuildDir/include/gds.hxx $DestDir/include
cp $BuildDir/include/*.h $DestDir/include
cp -f $BuildDir/lib/gds.so /usr/lib/libgds.so.0
cp -f $BuildDir/lib/libgds.so /usr/lib/libgds.so.0
if [ -L /usr/lib/libgds.so ]
then
rm -f /usr/lib/libgds.so
fi
ln -s libgds.so.0 /usr/lib/libgds.so
cp -f $BuildDir/lib/gds.a /usr/lib/libgds.a
# cp -f $BuildDir/lib/gds.a /usr/lib/libgds.a
cp -f $BuildDir/lib/ib_util.so /usr/lib/libib_util.so
cp $BuildDir/intl/libgdsintl.so $DestDir/intl/
cp $BuildDir/UDF/ib_udf $DestDir/UDF/ib_udf
cp $BuildDir/UDF/ib_udf.so $DestDir/UDF/
cp $BuildDir/services.isc $DestDir/services.isc
cp $BuildDir/README $DestDir/README
# cp $BuildDir/README $DestDir/README
cp $BuildDir/misc/firebird.xinetd $DestDir/misc/firebird.xinetd

View File

@ -124,14 +124,14 @@
#ifdef UNIX
#define WORKFILE "/tmp/"
#ifdef LINUX
#define ISC_PREFIX "/usr/local/interbase/"
#define ISC_PREFIX "/usr/local/firebird/"
#else
#ifdef DARWIN
#define ISC_PREFIX "/all/files/are/in/framework/resources"
#define DARWIN_GEN_DIR "var"
#define DARWIN_FRAMEWORK_ID "com.firebird.Firebird2"
#else
#define ISC_PREFIX "/usr/interbase/"
#define ISC_PREFIX "/usr/local/firebird/"
#endif
#endif
#endif

View File

@ -97,6 +97,9 @@
#endif /* VMS */
#include "fbutil/FirebirdConfig.h"
/* Turn on V4 mutex protection for gds__alloc/free */
#ifdef WIN_NT
@ -608,7 +611,7 @@ static const UCHAR
rid[] = { op_word, op_byte, op_line, 0},
rid2[] = { op_word, op_byte, op_literal, op_pad, op_byte, op_line, 0},
union_ops[] = { op_byte, op_byte, op_line, op_union, 0},
map[] = { op_word, op_line, op_map, 0},
map[] = { op_word, op_line, op_map, 0},
function[] = { op_byte, op_literal, op_byte, op_line, op_args, 0},
gen_id[] = { op_byte, op_literal, op_line, op_verb, 0},
declare[] = { op_word, op_dtype, op_line, 0},
@ -2368,7 +2371,7 @@ SLONG API_ROUTINE gds__get_prefix(SSHORT arg_type, TEXT * passed_string)
#ifndef VMS
void API_ROUTINE gds__prefix(TEXT * string, TEXT * root)
void API_ROUTINE gds__prefix(TEXT * resultString, TEXT * root)
{
/**************************************
*
@ -2388,15 +2391,13 @@ void API_ROUTINE gds__prefix(TEXT * string, TEXT * root)
CFStringRef msgFilePath;
#endif
string[0] = 0;
resultString[0] = 0;
if (ib_prefix == NULL) {
if ( !(ib_prefix = getenv(ISC_ENV)) || ib_prefix[0] == 0)
{
if ( !(ib_prefix = getenv(ISC_ENV)) || ib_prefix[0] == 0) {
#if defined(WIN_NT)
ib_prefix = ib_prefix_val;
if (ISC_get_registry_var("RootDirectory", ib_prefix, MAXPATHLEN, 0) != -1)
{
if (ISC_get_registry_var("RootDirectory", ib_prefix, MAXPATHLEN, 0) != -1) {
TEXT *p = ib_prefix + strlen(ib_prefix);
if (p != ib_prefix)
if (p[-1] == '\\')
@ -2436,19 +2437,33 @@ void API_ROUTINE gds__prefix(TEXT * string, TEXT * root)
else
#endif
{
ib_prefix = ISC_PREFIX;
strcat(ib_prefix_val, ib_prefix);
}
// Try and get value from config file.
const string regPrefix = FirebirdConfig::getSysString("RootDirectory");
int len = regPrefix.length();
if ( len > 0) {
if (len > sizeof(ib_prefix_val)) {
ib_perror("ib_prefix path size too large - truncated");
}
strncpy(ib_prefix_val, regPrefix.c_str(), sizeof(ib_prefix_val) -1);
ib_prefix_val[sizeof(ib_prefix_val) -1] = 0;
ib_prefix = ib_prefix_val;
}
else {
ib_prefix = ISC_PREFIX;
strcat(ib_prefix_val, ib_prefix);
}
}
#endif
ib_prefix = ib_prefix_val;
}
}
strcat(string, ib_prefix);
strcat(resultString, ib_prefix);
#ifndef NETWARE_386
if (string[strlen(string) - 1] != '/')
strcat(string, "/");
if (resultString[strlen(resultString) - 1] != '/')
strcat(resultString, "/");
#endif
strcat(string, root);
strcat(resultString, root);
}
#endif /* !defined(VMS) */

View File

@ -24,7 +24,7 @@
* Solaris x86 changes - Konstantin Kuznetsov, Neil McCalden
*/
/*
$Id: isc.cpp,v 1.3 2001-07-29 17:42:22 skywalker Exp $
$Id: isc.cpp,v 1.4 2001-08-20 08:15:33 skywalker Exp $
*/
#include "firebird.h"
@ -782,6 +782,7 @@ TEXT *INTERNAL_API_ROUTINE ISC_get_host(TEXT * string, USHORT length)
#if !defined(WIN_NT) // implemented in isc_win32.cpp
#ifdef PC_PLATFORM
#ifndef NETWARE_386
int INTERNAL_API_ROUTINE ISC_get_user(TEXT* name,
int* id,
int* group,
@ -897,6 +898,8 @@ int INTERNAL_API_ROUTINE ISC_get_user(TEXT* name,
return (euid == 0);
}
#endif

View File

@ -26,7 +26,7 @@
# Contributor(s):
#
#
# $Id: Makefile.in.firebird,v 1.7 2001-08-15 18:10:36 skywalker Exp $
# $Id: Makefile.in.firebird,v 1.8 2001-08-20 08:15:33 skywalker Exp $
#
ROOT=..
@ -40,6 +40,7 @@ include $(ROOT)/src/make.shared.variables
ISC_USER= sysdba
ISC_PASSWORD= masterkey
LD_LIBRARY_PATH=/home/odonohue/src/firebird2/gen/firebird/lib
export ISC_USER
export ISC_PASSWORD
@ -187,7 +188,7 @@ isc4.gdb: gdef isql # build the security database
phase3: build_alt_use_main jrdlib_main sysdba_user \
gfix gbak gdef msgs isql $(INTL) locks qli inet_server \
gsplit gstat gds_relay gsec gds_drop gpre \
extlib msgs_intl includes examples
extlib msgs_intl includes examples otherfiles
build_alt_use_main: # alter header file so jrd/alt.cpp DOES use security.
$(MAKE) -C jrd $@ # alter utilities to build the security objects
@ -234,6 +235,7 @@ examples: includes
$(MAKE) -C v5_examples v5_examples
otherfiles: misc_files script_files
@ -367,6 +369,11 @@ $(BIN)/% :: $(SRC_ROOT)/install/misc/%
install:
$(MAKE) -C install $@
packages:
$(MAKE) -C install $@
installclassic:
$(SRC_ROOT)/install/classic/CSpreinstall.sh
# $(SRC_ROOT)/install/classic/CSinstall.sh

View File

@ -26,7 +26,7 @@
# Contributor(s):
#
#
# $Id: make.defaults,v 1.7 2001-08-13 08:14:38 skywalker Exp $
# $Id: make.defaults,v 1.8 2001-08-20 08:15:33 skywalker Exp $
#
@ -89,7 +89,9 @@ LIBGDS_A = $(LIB)/libgds.a
ifdef UseSharedLibraries
LIBGDS_LA = $(LIBGDS_SO)
LIBGDS_DEP =
LIBGDS_LINK = $(LIBGDS_SO)
# LIBGDS_LINK = $(LIBGDS_SO)
LIBGDS_LINK =
LINK_LIBS := -L$(LIB) -lgds $(LINK_LIBS)
else
LIBGDS_LA = $(LIBGDS_A)
LIBGDS_DEP = $(LIBGDS_LA)

View File

@ -26,7 +26,7 @@
# Contributor(s):
#
#
# $Id: make.rules,v 1.7 2001-08-14 17:41:39 skywalker Exp $
# $Id: make.rules,v 1.8 2001-08-20 08:15:33 skywalker Exp $
#
#____________________________________________________________________________
@ -121,8 +121,8 @@ else
LIB_LINK= ld -shared
STATICLIB_LINK= ar cruvs
# LIB_LINK_OPTIONS = -soname libgds.so -rpath /usr/lib
LIB_LINK_OPTIONS =
LIB_LINK_OPTIONS = -soname libgds.so.2 -rpath /usr/lib
# LIB_LINK_OPTIONS =
EXE_LINK = @CC@
STATICEXE_LINK = @CXX@

View File

@ -133,7 +133,7 @@ SECURITY_SharedObjects = $(SECURITY_Objects:.o=.lo)
#
# fbutil
FBUTIL_Sources=FirebirdConfig.cpp
FBUTIL_Sources=FirebirdConfig.cpp FirebirdConfigFile.cpp
FBUTIL_Objects = $(FBUTIL_Sources:%.cpp=$(GEN_ROOT)/fbutil/%.o)
FBUTIL_SharedObjects = $(FBUTIL_Objects:.o=.lo)