New config file token: LocationAlias.

This commit is contained in:
Stas Degteff
2005-10-02 12:17:28 +00:00
parent 694e568d82
commit 9f8c325884
11 changed files with 188 additions and 3 deletions

View File

@@ -238,6 +238,7 @@ const word CRC_KEYBSTACK = 0x5F23;
const word CRC_KLUDGE = 0xA600;
const word CRC_KLUDGECHRS = 0x0EEF;
const word CRC_LOADLANGUAGE = 0x9F1B;
const word CRC_LOCATIONALIAS = 0x1B5F;
const word CRC_LOGFILE = 0x8ACE;
const word CRC_LOGFORMAT = 0x9E51;
const word CRC_LOGLEVEL = 0xCF59;

View File

@@ -410,6 +410,7 @@ SwitchK:
SwitchL:
switch(crc) {
case CRC_LOADLANGUAGE : CfgLoadlanguage (); break;
case CRC_LOCATIONALIAS : CfgLocationalias (); break;
case CRC_LOGFILE : CfgLogfile (); break;
case CRC_LOGFORMAT : CfgLogformat (); break;
default : found = false;

View File

@@ -320,6 +320,17 @@ void CfgLoadlanguage() {
// ------------------------------------------------------------------
void CfgLocationalias()
{
char* key;
getkeyval(&key, &val);
StripQuotes(key);
StripQuotes(val);
CFG->locationalias.Add(key, val);
}
// ------------------------------------------------------------------
void CfgLogfile() {
strcpy(CFG->logfile, val);

View File

@@ -228,6 +228,7 @@ void CfgKeybstack ();
void CfgKludge ();
void CfgKludgechrs ();
void CfgLoadlanguage ();
void CfgLocationalias ();
void CfgLogfile ();
void CfgLogformat ();
void CfgLookupecho ();

View File

@@ -254,6 +254,7 @@ public:
char keybstack[80]; // keybuf[80];
gstrarray kludge;
Path loadlanguage;
GStrBag2 locationalias;
Path logfile; // goldedlog;
int logformat;
std::vector<MailList> mailinglist;

View File

@@ -1136,7 +1136,22 @@ void LookupNodeLocation(GMsg* msg, std::string &location, int what)
if (addr.invalid())
buf[0] = NUL;
item.loc = location = buf;
std::string city = buf;
GStrBag2 &strbag = CFG->locationalias;
if (strbag.First())
{
do
{
const char* str = strbag.Current1();
size_t pos = city.find(str);
if (pos != city.npos)
city.replace(pos, strlen(str), strbag.Current2());
}
while (strbag.Next());
}
item.loc = location = city;
cash.insert(it, item);
}