本文整理汇总了C++中ConfigReader::ReadValue方法的典型用法代码示例。如果您正苦于以下问题:C++ ConfigReader::ReadValue方法的具体用法?C++ ConfigReader::ReadValue怎么用?C++ ConfigReader::ReadValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConfigReader
的用法示例。
在下文中一共展示了ConfigReader::ReadValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnKill
virtual int OnKill(userrec* source, userrec* dest, const std::string &reason)
{
long dest_level = 0,source_level = 0;
// oper killing an oper?
if (IS_OPER(dest) && IS_OPER(source))
{
for (int j =0; j < conf->Enumerate("type"); j++)
{
std::string typen = conf->ReadValue("type","name",j);
if (!strcmp(typen.c_str(),dest->oper))
{
dest_level = conf->ReadInteger("type","level",j,true);
break;
}
}
for (int k =0; k < conf->Enumerate("type"); k++)
{
std::string typen = conf->ReadValue("type","name",k);
if (!strcmp(typen.c_str(),source->oper))
{
source_level = conf->ReadInteger("type","level",k,true);
break;
}
}
if (dest_level > source_level)
{
ServerInstance->WriteOpers("Oper %s (level %d) attempted to /kill a higher oper: %s (level %d): Reason: %s",source->nick,source_level,dest->nick,dest_level,reason.c_str());
dest->WriteServ("NOTICE %s :Oper %s attempted to /kill you!",dest->nick,source->nick);
source->WriteServ("481 %s :Permission Denied - Oper %s is a higher level than you",source->nick,dest->nick);
return 1;
}
}
return 0;
}
示例2: OnRehash
virtual void OnRehash(const std::string ¶meter)
{
// reload our config file on rehash - we must destroy and re-allocate the classes
// to call the constructor again and re-read our data.
ConfigReader* Conf = new ConfigReader(ServerInstance);
std::string filterfile = Conf->ReadValue("filter","file",0);
// this automatically re-reads the configuration file into the class
ConfigReader* MyConf = new ConfigReader(ServerInstance, filterfile);
if ((filterfile == "") || (!MyConf->Verify()))
{
// bail if the user forgot to create a config file
FilterException e;
throw(e);
}
for (filter_t::iterator n = filters.begin(); n != filters.end(); n++)
{
DELETE(n->second);
}
filters.clear();
for (int index = 0; index < MyConf->Enumerate("keyword"); index++)
{
std::string pattern = MyConf->ReadValue("keyword","pattern",index);
std::string reason = MyConf->ReadValue("keyword","reason",index);
std::string do_action = MyConf->ReadValue("keyword","action",index);
if (do_action == "")
do_action = "none";
Filter* x = new Filter;
x->reason = reason;
x->action = do_action;
filters[pattern] = x;
}
ServerInstance->Log(DEFAULT,"m_filter: read configuration from "+filterfile);
DELETE(Conf);
DELETE(MyConf);
}
示例3: ReadConfig
virtual void ReadConfig()
{
ConfigReader *MyConf = new ConfigReader(ServerInstance);
helpop_map.clear();
for (int i = 0; i < MyConf->Enumerate("helpop"); i++)
{
irc::string key = assign(MyConf->ReadValue("helpop", "key", i));
std::string value = MyConf->ReadValue("helpop", "value", i, true); /* Linefeeds allowed! */
if (key == "index")
{
throw ModuleException("m_helpop: The key 'index' is reserved for internal purposes. Please remove it.");
}
helpop_map[key] = value;
}
if (helpop_map.find("start") == helpop_map.end())
{
// error!
throw ModuleException("m_helpop: Helpop file is missing important entries. Please check the example conf.");
}
else if (helpop_map.find("nohelp") == helpop_map.end())
{
// error!
throw ModuleException("m_helpop: Helpop file is missing important entries. Please check the example conf.");
}
}
示例4: Handle
CmdResult Handle (const std::vector<std::string> ¶meters, User *user)
{
ConfigReader *Conf = new ConfigReader(ServerInstance);
for (int index = 0; index < Conf->Enumerate("vhost"); index++)
{
std::string mask = Conf->ReadValue("vhost","host",index);
std::string username = Conf->ReadValue("vhost","user",index);
std::string pass = Conf->ReadValue("vhost","pass",index);
std::string hash = Conf->ReadValue("vhost","hash",index);
if ((!strcmp(parameters[0].c_str(),username.c_str())) && !ServerInstance->PassCompare(user, pass.c_str(), parameters[1].c_str(), hash.c_str()))
{
if (!mask.empty())
{
user->WriteServ("NOTICE "+std::string(user->nick)+" :Setting your VHost: " + mask);
user->ChangeDisplayedHost(mask.c_str());
delete Conf;
return CMD_LOCALONLY;
}
}
}
user->WriteServ("NOTICE "+std::string(user->nick)+" :Invalid username or password.");
delete Conf;
return CMD_FAILURE;
}
示例5: e
ModuleRandQuote(InspIRCd* Me)
: Module(Me)
{
conf = new ConfigReader(ServerInstance);
// Sort the Randomizer thingie..
srand(time(NULL));
q_file = conf->ReadValue("randquote","file",0);
prefix = conf->ReadValue("randquote","prefix",0);
suffix = conf->ReadValue("randquote","suffix",0);
mycommand = NULL;
if (q_file.empty())
{
RandquoteException e("m_randquote: Quotefile not specified - Please check your config.");
throw(e);
}
quotes = new FileReader(ServerInstance, q_file);
if(!quotes->Exists())
{
RandquoteException e("m_randquote: QuoteFile not Found!! Please check your config - module will not function.");
throw(e);
}
else
{
/* Hidden Command -- Mode clients assume /quote sends raw data to an IRCd >:D */
mycommand = new cmd_randquote(ServerInstance);
ServerInstance->AddCommand(mycommand);
}
}
示例6: OnReload
void OnReload()
{
ConfigReader config;
this->binddn = config.ReadValue("m_ldap_oper", "binddn", "", 0);
this->password = config.ReadValue("m_ldap_oper", "password", "", 0);
this->basedn = config.ReadValue("m_ldap_oper", "basedn", "", 0);
this->filter = config.ReadValue("m_ldap_oper", "filter", "", 0);
opertype_attribute = config.ReadValue("m_ldap_oper", "opertype_attribute", "", 0);
for (std::set<Oper *>::iterator it = my_opers.begin(), it_end = my_opers.end(); it != it_end; ++it)
delete *it;
my_opers.clear();
}
示例7: ReadSettings
void ReadSettings()
{
Conf = new ConfigReader(ServerInstance);
IdentTimeout = Conf->ReadInteger("ident", "timeout", 0, true);
PortBind = Conf->ReadValue("ident", "bind", 0);
if (!IdentTimeout)
IdentTimeout = 1;
DELETE(Conf);
}
示例8: OnReload
void OnReload()
{
ConfigReader config;
this->rewrites.clear();
for (int i = 0; i < config.Enumerate("rewrite"); ++i)
{
Rewrite rw;
rw.client = config.ReadValue("rewrite", "client", "", i);
rw.source_message = config.ReadValue("rewrite", "source_message", "", i),
rw.target_message = config.ReadValue("rewrite", "target_message", "", i);
if (rw.client.empty() || rw.source_message.empty() || rw.target_message.empty())
continue;
this->rewrites.push_back(rw);
}
}
示例9: OnRehash
virtual void OnRehash(userrec* user, const std::string ¶meter)
{
ConfigReader* conf = new ConfigReader(ServerInstance);
operChan = conf->ReadValue("operjoin", "channel", 0);
operChans.clear();
if (!operChan.empty())
tokenize(operChan,operChans);
DELETE(conf);
}
示例10: OnRehash
virtual void OnRehash(const std::string ¶meter)
{
DELETE(Conf);
Conf = new ConfigReader(ServerInstance);
MySuffix = Conf->ReadValue("host","suffix",0);
for (hostchanges_t::iterator i = hostchanges.begin(); i != hostchanges.end(); i++)
{
DELETE(i->second);
}
hostchanges.clear();
for (int index = 0; index < Conf->Enumerate("hostchange"); index++)
{
std::string mask = Conf->ReadValue("hostchange","mask",index);
std::string action = Conf->ReadValue("hostchange","action",index);
std::string newhost = Conf->ReadValue("hostchange","value",index);
Host* x = new Host;
x->action = action;
x->newhost = newhost;
hostchanges[mask] = x;
}
}
示例11: LoadOperMOTD
void LoadOperMOTD()
{
ConfigReader* conf = new ConfigReader(ServerInstance);
std::string filename;
filename = conf->ReadValue("opermotd","file",0);
if (opermotd)
{
delete opermotd;
opermotd = NULL;
}
opermotd = new FileReader(ServerInstance, filename);
DELETE(conf);
}
示例12: ReadConfig
void ReadConfig()
{
ConfigReader* MyConf = new ConfigReader(ServerInstance);
allowchans.clear();
for (int i = 0; i < MyConf->Enumerate("allowchannel"); i++)
{
std::string txt;
txt = MyConf->ReadValue("allowchannel", "name", i);
irc::string channel = txt.c_str();
allowchans[channel] = 1;
}
DELETE(MyConf);
}
示例13: OnPreCommand
virtual int OnPreCommand(std::string &command, std::vector<std::string>& parameters, User* user, bool validated, const std::string &original_line)
{
if (!validated)
return 0;
if (command != "OPER")
return 0;
std::string *account, currentaccount=user->nick.c_str();
user->GetExt("accountname", account);
if (account)
currentaccount=account->c_str();
else if (!user->IsModeSet('r') && !account)
{
user->WriteServ("491 %s :Invalid oper credentials",user->nick.c_str());
return 1;
}
for (int j = 0; j < Conf->Enumerate("oper"); j++)
{
std::string opername = Conf->ReadValue("oper", "name", j);
if (opername==parameters[0])
{
std::string registerednick = Conf->ReadValue("oper", "registerednick", "", j);
if (registerednick.empty() || InspIRCd::Match(registerednick,currentaccount))
break;
else
{
user->WriteServ("491 %s :Invalid oper credentials",user->nick.c_str());
return 1;
}
}
}
return 0;
}
示例14: OnOperCompare
virtual int OnOperCompare(const std::string &data, const std::string &input, int tagnumber)
{
/* First, lets see what hash theyre using on this oper */
std::string hashtype = Conf->ReadValue("oper", "hash", tagnumber);
hashymodules::iterator x = hashers.find(hashtype.c_str());
/* Is this a valid hash name? (case insensitive) */
if (x != hashers.end())
{
/* Reset the hashing module */
HashResetRequest(this, x->second).Send();
/* Compare the hash in the config to the generated hash */
if (!strcasecmp(data.c_str(), HashSumRequest(this, x->second, input.c_str()).Send()))
return 1;
/* No match, and must be hashed, forbid */
else return -1;
}
/* Not a hash, fall through to strcmp in core */
return 0;
}
示例15: OnRehash
virtual void OnRehash(const std::string ¶m)
{
if(param != "ssl")
return;
Conf = new ConfigReader(ServerInstance);
for(unsigned int i = 0; i < listenports.size(); i++)
{
ServerInstance->Config->DelIOHook(listenports[i]);
}
listenports.clear();
for(int i = 0; i < Conf->Enumerate("bind"); i++)
{
// For each <bind> tag
if(((Conf->ReadValue("bind", "type", i) == "") || (Conf->ReadValue("bind", "type", i) == "clients")) && (Conf->ReadValue("bind", "ssl", i) == "openssl"))
{
// Get the port we're meant to be listening on with SSL
unsigned int port = Conf->ReadInteger("bind", "port", i, true);
if (ServerInstance->Config->AddIOHook(port, this))
{
// We keep a record of which ports we're listening on with SSL
listenports.push_back(port);
ServerInstance->Log(DEFAULT, "m_ssl_openssl.so: Enabling SSL for port %d", port);
}
else
{
ServerInstance->Log(DEFAULT, "m_ssl_openssl.so: FAILED to enable SSL on port %d, maybe you have another ssl or similar module loaded?", port);
}
}
}
std::string confdir(CONFIG_FILE);
// +1 so we the path ends with a /
confdir = confdir.substr(0, confdir.find_last_of('/') + 1);
cafile = Conf->ReadValue("openssl", "cafile", 0);
// crlfile = Conf->ReadValue("openssl", "crlfile", 0);
certfile = Conf->ReadValue("openssl", "certfile", 0);
keyfile = Conf->ReadValue("openssl", "keyfile", 0);
dhfile = Conf->ReadValue("openssl", "dhfile", 0);
// Set all the default values needed.
if(cafile == "")
cafile = "ca.pem";
//if(crlfile == "")
// crlfile = "crl.pem";
if(certfile == "")
certfile = "cert.pem";
if(keyfile == "")
keyfile = "key.pem";
if(dhfile == "")
dhfile = "dhparams.pem";
// Prepend relative paths with the path to the config directory.
if(cafile[0] != '/')
cafile = confdir + cafile;
//if(crlfile[0] != '/')
// crlfile = confdir + crlfile;
if(certfile[0] != '/')
certfile = confdir + certfile;
if(keyfile[0] != '/')
keyfile = confdir + keyfile;
if(dhfile[0] != '/')
dhfile = confdir + dhfile;
/* Load our keys and certificates*/
if(!SSL_CTX_use_certificate_chain_file(ctx, certfile.c_str()))
{
ServerInstance->Log(DEFAULT, "m_ssl_openssl.so: Can't read certificate file %s", certfile.c_str());
}
if(!SSL_CTX_use_PrivateKey_file(ctx, keyfile.c_str(), SSL_FILETYPE_PEM))
{
ServerInstance->Log(DEFAULT, "m_ssl_openssl.so: Can't read key file %s", keyfile.c_str());
}
/* Load the CAs we trust*/
if(!SSL_CTX_load_verify_locations(ctx, cafile.c_str(), 0))
{
ServerInstance->Log(DEFAULT, "m_ssl_openssl.so: Can't read CA list from ", cafile.c_str());
}
FILE* dhpfile = fopen(dhfile.c_str(), "r");
DH* ret;
if(dhpfile == NULL)
{
ServerInstance->Log(DEFAULT, "m_ssl_openssl.so Couldn't open DH file %s: %s", dhfile.c_str(), strerror(errno));
//.........这里部分代码省略.........