本文整理汇总了C++中cconfig::SubConfig::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ SubConfig::empty方法的具体用法?C++ SubConfig::empty怎么用?C++ SubConfig::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cconfig::SubConfig
的用法示例。
在下文中一共展示了SubConfig::empty方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ParseConfig
//.........这里部分代码省略.........
pConfig->FindStringEntry("pass", sValue);
// There are different formats for this available:
// Pass = <plain text>
// Pass = <md5 hash> -
// Pass = plain#<plain text>
// Pass = <hash name>#<hash>
// Pass = <hash name>#<salted hash>#<salt>#
// 'Salted hash' means hash of 'password' + 'salt'
// Possible hashes are md5 and sha256
if (sValue.Right(1) == "-") {
sValue.RightChomp();
sValue.Trim();
SetPass(sValue, CUser::HASH_MD5);
} else {
CString sMethod = sValue.Token(0, false, "#");
CString sPass = sValue.Token(1, true, "#");
if (sMethod == "md5" || sMethod == "sha256") {
CUser::eHashType type = CUser::HASH_MD5;
if (sMethod == "sha256")
type = CUser::HASH_SHA256;
CString sSalt = sPass.Token(1, false, "#");
sPass = sPass.Token(0, false, "#");
SetPass(sPass, type, sSalt);
} else if (sMethod == "plain") {
SetPass(sPass, CUser::HASH_NONE);
} else {
SetPass(sValue, CUser::HASH_NONE);
}
}
CConfig::SubConfig subConf;
CConfig::SubConfig::const_iterator subIt;
pConfig->FindSubConfig("pass", subConf);
if (!sValue.empty() && !subConf.empty()) {
sError = "Password defined more than once";
CUtils::PrintError(sError);
return false;
}
subIt = subConf.begin();
if (subIt != subConf.end()) {
CConfig* pSubConf = subIt->second.m_pSubConfig;
CString sHash;
CString sMethod;
CString sSalt;
CUser::eHashType method;
pSubConf->FindStringEntry("hash", sHash);
pSubConf->FindStringEntry("method", sMethod);
pSubConf->FindStringEntry("salt", sSalt);
if (sMethod.empty() || sMethod.Equals("plain"))
method = CUser::HASH_NONE;
else if (sMethod.Equals("md5"))
method = CUser::HASH_MD5;
else if (sMethod.Equals("sha256"))
method = CUser::HASH_SHA256;
else {
sError = "Invalid hash method";
CUtils::PrintError(sError);
return false;
}
SetPass(sHash, method, sSalt);
if (!pSubConf->empty()) {
sError = "Unhandled lines in config!";
CUtils::PrintError(sError);
CZNC::DumpConfig(pSubConf);
示例2: ParseConfig
//.........这里部分代码省略.........
}
}
}
pConfig->FindStringEntry("pass", sValue);
// There are different formats for this available:
// Pass = <plain text>
// Pass = <md5 hash> -
// Pass = plain#<plain text>
// Pass = <hash name>#<hash>
// Pass = <hash name>#<salted hash>#<salt>#
// 'Salted hash' means hash of 'password' + 'salt'
// Possible hashes are md5 and sha256
if (sValue.TrimSuffix("-")) {
SetPass(sValue.Trim_n(), CUser::HASH_MD5);
} else {
CString sMethod = sValue.Token(0, false, "#");
CString sPass = sValue.Token(1, true, "#");
if (sMethod == "md5" || sMethod == "sha256") {
CUser::eHashType type = CUser::HASH_MD5;
if (sMethod == "sha256") type = CUser::HASH_SHA256;
CString sSalt = sPass.Token(1, false, "#");
sPass = sPass.Token(0, false, "#");
SetPass(sPass, type, sSalt);
} else if (sMethod == "plain") {
SetPass(sPass, CUser::HASH_NONE);
} else {
SetPass(sValue, CUser::HASH_NONE);
}
}
CConfig::SubConfig subConf;
CConfig::SubConfig::const_iterator subIt;
pConfig->FindSubConfig("pass", subConf);
if (!sValue.empty() && !subConf.empty()) {
sError = "Password defined more than once";
CUtils::PrintError(sError);
return false;
}
subIt = subConf.begin();
if (subIt != subConf.end()) {
CConfig* pSubConf = subIt->second.m_pSubConfig;
CString sHash;
CString sMethod;
CString sSalt;
CUser::eHashType method;
pSubConf->FindStringEntry("hash", sHash);
pSubConf->FindStringEntry("method", sMethod);
pSubConf->FindStringEntry("salt", sSalt);
if (sMethod.empty() || sMethod.Equals("plain"))
method = CUser::HASH_NONE;
else if (sMethod.Equals("md5"))
method = CUser::HASH_MD5;
else if (sMethod.Equals("sha256"))
method = CUser::HASH_SHA256;
else {
sError = "Invalid hash method";
CUtils::PrintError(sError);
return false;
}
SetPass(sHash, method, sSalt);
if (!pSubConf->empty()) {
sError = "Unhandled lines in config!";
CUtils::PrintError(sError);
CZNC::DumpConfig(pSubConf);