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

Make all configuration files case-sensitive

This commit is contained in:
alexpeshkoff 2010-03-04 12:52:01 +00:00
parent d8938efea2
commit e344287aa0
11 changed files with 41 additions and 40 deletions

View File

@ -32,9 +32,6 @@
#include <stdlib.h>
#endif
// config_file works with OS case-sensitivity
typedef Firebird::PathName String;
namespace {
/******************************************************************************
@ -222,7 +219,7 @@ void Config::loadValues(const ConfigFile& file)
for (int i = 0; i < MAX_CONFIG_KEY; i++)
{
const ConfigEntry& entry = entries[i];
const String value = getValue(file, entry.key);
const ConfigFile::String value = getValue(file, entry.key);
if (value.length())
{
@ -274,23 +271,23 @@ Config::~Config()
}
}
String Config::getValue(const ConfigFile& file, ConfigName key)
ConfigFile::String Config::getValue(const ConfigFile& file, ConfigName key)
{
const ConfigFile::Parameter* p = file.findParameter(key);
return p ? p->value : "";
}
int Config::asInteger(const String &value)
int Config::asInteger(const ConfigFile::String &value)
{
return atoi(value.data());
}
bool Config::asBoolean(const String &value)
bool Config::asBoolean(const ConfigFile::String &value)
{
return (atoi(value.data()) != 0);
}
const char* Config::asString(const String &value)
const char* Config::asString(const ConfigFile::String &value)
{
return value.c_str();
}

View File

@ -26,6 +26,7 @@
#include "../common/classes/alloc.h"
#include "../common/classes/fb_string.h"
#include "../common/classes/RefCounted.h"
#include "../common/config/config_file.h"
/**
Since the original (isc.cpp) code wasn't able to provide powerful and
@ -74,8 +75,6 @@ extern const char* AmMixed;
enum AmCache {AM_UNKNOWN, AM_DISABLED, AM_ENABLED};
class ConfigFile;
class Config : public Firebird::RefCounted, public Firebird::GlobalStorage
{
public:
@ -150,11 +149,11 @@ private:
ConfigValue default_value;
};
static Firebird::PathName getValue(const ConfigFile&, ConfigName);
static ConfigFile::String getValue(const ConfigFile&, ConfigName);
static int asInteger(const Firebird::PathName&);
static bool asBoolean(const Firebird::PathName&);
static const char* asString(const Firebird::PathName&);
static int asInteger(const ConfigFile::String&);
static bool asBoolean(const ConfigFile::String&);
static const char* asString(const ConfigFile::String&);
void loadValues(const ConfigFile& file);

View File

@ -166,7 +166,7 @@ private:
} // anonymous namespace
ConfigFile::ConfigFile(const ConfigFile::String& file, USHORT fl)
ConfigFile::ConfigFile(const Firebird::PathName& file, USHORT fl)
: AutoStorage(), configFile(getPool(), file), parameters(getPool()), flags(fl)
{
MainStream s(configFile.c_str(), flags & EXCEPTION_ON_ERROR);
@ -334,8 +334,9 @@ bool ConfigFile::translate(const String& from, String& to)
{
return false;
}
PathName file;
PathUtils::splitLastComponent(to, file, configFile);
PathName path, file;
PathUtils::splitLastComponent(path, file, configFile.ToPathName());
to = path.ToString();
}
/* else if (!substituteOneOfStandardFirebirdDirs(from, to))
{

View File

@ -57,8 +57,8 @@ public:
// enum to distinguish ctors
enum UseText {USE_TEXT};
// config_file works with OS case-sensitivity
typedef Firebird::PathName String;
// config_file is always OS case sensitive
typedef Firebird::string String;
class Stream
{
@ -91,7 +91,7 @@ public:
typedef Firebird::SortedObjectsArray<Parameter, Firebird::InlineStorage<Parameter*, 100>,
String, Parameter> Parameters;
ConfigFile(const String& file, USHORT fl);
ConfigFile(const Firebird::PathName& file, USHORT fl);
ConfigFile(const char* file, USHORT fl);
ConfigFile(UseText, const char* configText, USHORT fl);

View File

@ -363,7 +363,7 @@ void* FB_CALL ExtEngineManager::ExternalContextImpl::setInfo(int code, void* val
//---------------------
static InitInstance<GenericMap<Pair<Full<MetaName, PathName> > > > enginesModules;
static InitInstance<GenericMap<Pair<Full<MetaName, ConfigFile::String> > > > enginesModules;
//---------------------
@ -888,7 +888,7 @@ ExternalEngine* ExtEngineManager::getEngine(thread_db* tdbb, const MetaName& nam
if (!engines.get(name, engine))
{
PathName pluginName;
ConfigFile::String pluginName;
if (enginesModules().get(name, pluginName))
{
PluginImpl* plugin = PluginManager::getPlugin(pluginName);

View File

@ -468,7 +468,7 @@ bool IntlManager::initialize()
{
fatal_exception::raiseFmt("Missing parameter 'filename' for intl_module %s\n", module->value.c_str());
}
filename = fname->value;
filename = fname->value.ToPathName();
configInfo = getConfigInfo(objModule);
if (!modules->exist(filename))

View File

@ -43,11 +43,11 @@ namespace Jrd {
namespace
{
class PluginsMap : public GenericMap<Pair<Left<PathName, PluginImpl*> > >
class PluginsMap : public GenericMap<Pair<Left<ConfigFile::String, PluginImpl*> > >
{
public:
explicit PluginsMap(MemoryPool& p)
: GenericMap<Pair<Left<PathName, PluginImpl*> > >(p)
: GenericMap<Pair<Left<ConfigFile::String, PluginImpl*> > >(p)
{
}
@ -127,7 +127,7 @@ void PluginManager::initialize()
plugin->name.c_str());
}
plugin->filename = par->value;
plugin->filename = par->value.ToPathName();
par = pm->sub->findParameter("plugin_config");
if (par)
@ -172,7 +172,7 @@ PathName PluginManager::getPluginsDirectory()
}
PluginImpl* PluginManager::getPlugin(const PathName& name)
PluginImpl* PluginManager::getPlugin(const ConfigFile::String& name)
{
PluginImpl* plugin;

View File

@ -33,11 +33,12 @@
#include "../common/classes/MetaName.h"
#include "../common/classes/objects_array.h"
#include "../common/classes/rwlock.h"
#include "../common/config/config_file.h"
namespace Jrd {
typedef Firebird::Pair<Firebird::Full<Firebird::PathName, Firebird::PathName> > ConfigEntry;
typedef Firebird::Pair<Firebird::Full<ConfigFile::String, ConfigFile::String> > ConfigEntry;
class PluginImpl : public Firebird::Plugin, public Firebird::GlobalStorage
{
@ -66,12 +67,12 @@ public:
Firebird::ExternalEngineFactory* getExternalEngineFactory();
private:
Firebird::PathName name;
ConfigFile::String name;
Firebird::PathName filename;
Firebird::SortedObjectsArray<
ConfigEntry,
Firebird::EmptyStorage<ConfigEntry*>,
Firebird::PathName, Firebird::FirstPointerKey<ConfigEntry>
ConfigFile::String, Firebird::FirstPointerKey<ConfigEntry>
> configInfo;
Firebird::AutoPtr<ModuleLoader::Module> module;
Firebird::ExternalEngineFactory* externalEngineFactory;
@ -83,7 +84,7 @@ class PluginManager
public:
static void initialize();
static Firebird::PathName getPluginsDirectory();
static PluginImpl* getPlugin(const Firebird::PathName& name);
static PluginImpl* getPlugin(const ConfigFile::String& name);
};

View File

@ -84,7 +84,8 @@ namespace
static void upcpy(size_t* toPar, const char* from, size_t length)
{
char* to = reinterpret_cast<char*>(toPar);
memcpy(toPar, from, length);
/* char* to = reinterpret_cast<char*>(toPar);
while (length--)
{
if (CASE_SENSITIVITY)
@ -96,6 +97,7 @@ namespace
*to++ = toupper(*from++);
}
}
*/
}
static size_t hash(const char* value, size_t length, size_t hashSize)
@ -205,7 +207,7 @@ namespace
{
const ConfigFile::Parameter* par = &params[n];
PathName file(par->value);
PathName file(par->value.ToPathName());
replace_dir_sep(file);
if (PathUtils::isRelative(file))
{
@ -236,7 +238,7 @@ namespace
db->config = new Config(*par->sub, *Config::getDefaultConfig());
}
PathName correctedAlias(par->name);
PathName correctedAlias(par->name.ToPathName());
AliasName* alias = aliasHash.lookup(correctedAlias);
if (alias)
{

View File

@ -47,7 +47,7 @@ void TraceCfgReader::readTraceConfiguration(const char* text,
#define PATH_PARAMETER(NAME, VALUE) \
if (!found && el->name == #NAME) { \
ConfigFile::String temp; \
Firebird::PathName temp; \
expandPattern(el, temp); \
m_config.NAME = temp.c_str(); \
found = true; \
@ -273,10 +273,10 @@ ULONG TraceCfgReader::parseUInteger(const ConfigFile::Parameter* el) const
return result;
}
void TraceCfgReader::expandPattern(const ConfigFile::Parameter* el, ConfigFile::String& valueToExpand)
void TraceCfgReader::expandPattern(const ConfigFile::Parameter* el, PathName& valueToExpand)
{
valueToExpand = el->value;
string::size_type pos = 0;
valueToExpand = el->value.ToPathName();
PathName::size_type pos = 0;
while (pos < valueToExpand.length())
{
string::char_type c = valueToExpand[pos];

View File

@ -28,7 +28,8 @@
#ifndef TRACEPLUGINCONFIG_H
#define TRACEPLUGINCONFIG_H
#include "../../common/classes/fb_string.h"
#include "../common/classes/fb_string.h"
#include "../common/config/config_file.h"
//enum LogFormat { lfText = 0, lfBinary = 1 };
@ -38,7 +39,7 @@ struct TracePluginConfig
#define SERVICE_PARAMS
#define PATH_PARAMETER(NAME, VALUE) Firebird::PathName NAME;
#define STR_PARAMETER(NAME, VALUE) Firebird::PathName NAME;
#define STR_PARAMETER(NAME, VALUE) ConfigFile::String NAME;
#define BOOL_PARAMETER(NAME, VALUE) bool NAME;
#define UINT_PARAMETER(NAME, VALUE) ULONG NAME;
#include "paramtable.h"