本文整理汇总了C++中Hdf::getName方法的典型用法代码示例。如果您正苦于以下问题:C++ Hdf::getName方法的具体用法?C++ Hdf::getName怎么用?C++ Hdf::getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Hdf
的用法示例。
在下文中一共展示了Hdf::getName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: configGet
void Hdf::configGet(std::map<std::string, std::string,
stdltistr> &values) const {
values.clear();
for (Hdf hdf = firstChild(); hdf.exists(); hdf = hdf.next()) {
values[hdf.getName()] = hdf.configGetString("");
}
}
示例2: if
SatelliteServerInfo::SatelliteServerInfo(Hdf hdf) {
m_name = hdf.getName();
m_port = hdf["Port"].getUInt16(0);
m_threadCount = hdf["ThreadCount"].getInt32(5);
m_maxRequest = hdf["MaxRequest"].getInt32(500);
m_maxDuration = hdf["MaxDuration"].getInt32(120);
m_timeoutSeconds = std::chrono::seconds
(hdf["TimeoutSeconds"].getInt32(RuntimeOption::RequestTimeoutSeconds));
m_reqInitFunc = hdf["RequestInitFunction"].getString("");
m_reqInitDoc = hdf["RequestInitDocument"].getString("");
m_password = hdf["Password"].getString("");
hdf["Passwords"].get(m_passwords);
m_alwaysReset = hdf["AlwaysReset"].getBool(false);
std::string type = hdf["Type"].getString();
if (type == "InternalPageServer") {
m_type = SatelliteServer::Type::KindOfInternalPageServer;
std::vector<std::string> urls;
hdf["URLs"].get(urls);
for (unsigned int i = 0; i < urls.size(); i++) {
m_urls.insert(format_pattern(urls[i], true));
}
if (hdf["BlockMainServer"].getBool(true)) {
InternalURLs.insert(m_urls.begin(), m_urls.end());
}
} else if (type == "DanglingPageServer") {
m_type = SatelliteServer::Type::KindOfDanglingPageServer;
DanglingServerPort = m_port;
} else if (type == "RPCServer") {
m_type = SatelliteServer::Type::KindOfRPCServer;
} else {
m_type = SatelliteServer::Type::Unknown;
}
}
示例3: if
SatelliteServerInfo::SatelliteServerInfo(const IniSetting::Map& ini, Hdf hdf) {
// Since this could be activated when calling fb_gen_user_func() or similar.
// Those type of calls spawn async, and after extensions have
// been loaded.
// So, pretend extensions haven't been loaded for this PHP_INI_SYSTEM
// setting and then stop pretending after these binds.
// Something similar is being done in virtual-host.cpp as well.
IniSetting::s_pretendExtensionsHaveNotBeenLoaded = true;
m_name = hdf.getName();
Config::Bind(m_port, ini, hdf["Port"], 0);
Config::Bind(m_threadCount, ini, hdf["ThreadCount"], 5);
Config::Bind(m_maxRequest, ini, hdf["MaxRequest"], 500);
Config::Bind(m_maxDuration, ini, hdf["MaxDuration"], 120);
m_timeoutSeconds = std::chrono::seconds(
Config::GetInt32(ini, hdf["TimeoutSeconds"],
RuntimeOption::RequestTimeoutSeconds));
Config::Bind(m_reqInitFunc, ini, hdf["RequestInitFunction"], "");
Config::Bind(m_reqInitDoc, ini, hdf["RequestInitDocument"], "");
Config::Bind(m_password, ini, hdf["Password"], "");
Config::Get(ini, hdf["Passwords"], m_passwords);
Config::Bind(m_alwaysReset, ini, hdf["AlwaysReset"], false);
std::string type = Config::GetString(ini, hdf["Type"]);
if (type == "InternalPageServer") {
m_type = SatelliteServer::Type::KindOfInternalPageServer;
std::vector<std::string> urls;
Config::Get(ini, hdf["URLs"], urls);
for (unsigned int i = 0; i < urls.size(); i++) {
m_urls.insert(format_pattern(urls[i], true));
}
if (Config::GetBool(ini, hdf["BlockMainServer"], true)) {
InternalURLs.insert(m_urls.begin(), m_urls.end());
}
} else if (type == "DanglingPageServer") {
m_type = SatelliteServer::Type::KindOfDanglingPageServer;
DanglingServerPort = m_port;
} else if (type == "RPCServer") {
m_type = SatelliteServer::Type::KindOfRPCServer;
} else {
m_type = SatelliteServer::Type::Unknown;
}
IniSetting::s_pretendExtensionsHaveNotBeenLoaded = false;
}
示例4: FromHdf
Variant ArrayUtil::FromHdf(const Hdf &hdf) {
if (hdf.firstChild().exists()) {
Array ret = Array::Create();
const char *value = hdf.get();
if (value) {
ret.set(s_default, String(value, CopyString));
}
for (Hdf child = hdf.firstChild(); child.exists(); child = child.next()) {
ret.set(String(child.getName()), FromHdf(child));
}
return ret;
}
const char *value = hdf.get("");
if (strcasecmp(value, "false") == 0 ||
strcasecmp(value, "no") == 0 ||
strcasecmp(value, "off") == 0) {
return false;
}
if (strcasecmp(value, "true") == 0 ||
strcasecmp(value, "yes") == 0 ||
strcasecmp(value, "on") == 0) {
return true;
}
int64_t lval; double dval;
int len = strlen(value);
DataType ret = is_numeric_string(value, len, &lval, &dval, 0);
switch (ret) {
case KindOfInt64: return lval;
case KindOfDouble: return dval;
default: break;
}
return String(value, len, CopyString);
}
示例5: Load
void Option::Load(const IniSetting::Map& ini, Hdf &config) {
LoadRootHdf(ini, config["IncludeRoots"], IncludeRoots);
LoadRootHdf(ini, config["AutoloadRoots"], AutoloadRoots);
Config::Get(ini, config["PackageFiles"], PackageFiles);
Config::Get(ini, config["IncludeSearchPaths"], IncludeSearchPaths);
Config::Get(ini, config["PackageDirectories"], PackageDirectories);
Config::Get(ini, config["PackageExcludeDirs"], PackageExcludeDirs);
Config::Get(ini, config["PackageExcludeFiles"], PackageExcludeFiles);
Config::Get(ini, config["PackageExcludePatterns"], PackageExcludePatterns);
Config::Get(ini, config["PackageExcludeStaticDirs"], PackageExcludeStaticDirs);
Config::Get(ini, config["PackageExcludeStaticFiles"], PackageExcludeStaticFiles);
Config::Get(ini, config["PackageExcludeStaticPatterns"], PackageExcludeStaticPatterns);
CachePHPFile = Config::GetBool(ini, config["CachePHPFile"]);
Config::Get(ini, config["ParseOnDemandDirs"], ParseOnDemandDirs);
{
Hdf cg = config["CodeGeneration"];
string tmp;
#define READ_CG_OPTION(name) \
tmp = Config::GetString(ini, cg[#name]); \
if (!tmp.empty()) { \
name = OptionStrings.add(tmp.c_str()); \
}
READ_CG_OPTION(IdPrefix);
READ_CG_OPTION(LambdaPrefix);
}
Config::Get(ini, config["DynamicFunctionPrefix"], DynamicFunctionPrefixes);
Config::Get(ini, config["DynamicFunctionPostfix"], DynamicFunctionPostfixes);
Config::Get(ini, config["DynamicMethodPrefix"], DynamicMethodPrefixes);
Config::Get(ini, config["DynamicInvokeFunctions"], DynamicInvokeFunctions);
Config::Get(ini, config["VolatileClasses"], VolatileClasses);
// build map from function names to sections
for (Hdf hdf = config["FunctionSections"].firstChild(); hdf.exists();
hdf = hdf.next()) {
for (Hdf hdfFunc = hdf.firstChild(); hdfFunc.exists();
hdfFunc = hdfFunc.next()) {
FunctionSections[Config::GetString(ini, hdfFunc)] = hdf.getName();
}
}
{
Hdf repo = config["Repo"];
{
Hdf repoCentral = repo["Central"];
RepoCentralPath = Config::GetString(ini, repoCentral["Path"]);
}
RepoDebugInfo = Config::GetBool(ini, repo["DebugInfo"], false);
}
{
Hdf autoloadMap = config["AutoloadMap"];
Config::Get(ini, autoloadMap["class"], AutoloadClassMap);
Config::Get(ini, autoloadMap["function"], AutoloadFuncMap);
Config::Get(ini, autoloadMap["constant"], AutoloadConstMap);
AutoloadRoot = Config::GetString(ini, autoloadMap["root"]);
}
HardTypeHints = Config::GetBool(ini, config["HardTypeHints"], true);
HardConstProp = Config::GetBool(ini, config["HardConstProp"], true);
EnableHipHopSyntax = Config::GetBool(ini, config["EnableHipHopSyntax"]);
EnableZendCompat = Config::GetBool(ini, config["EnableZendCompat"]);
JitEnableRenameFunction = Config::GetBool(ini, config["JitEnableRenameFunction"]);
EnableHipHopExperimentalSyntax =
Config::GetBool(ini, config["EnableHipHopExperimentalSyntax"]);
EnableShortTags = Config::GetBool(ini, config["EnableShortTags"], true);
{
const Hdf& lang = config["Hack"]["Lang"];
IntsOverflowToInts =
Config::GetBool(ini, lang["IntsOverflowToInts"], EnableHipHopSyntax);
StrictArrayFillKeys =
Config::GetHackStrictOption(ini,
lang["StrictArrayFillKeys"],
EnableHipHopSyntax);
}
EnableAspTags = Config::GetBool(ini, config["EnableAspTags"]);
EnableXHP = Config::GetBool(ini, config["EnableXHP"], false);
if (EnableHipHopSyntax) {
// If EnableHipHopSyntax is true, it forces EnableXHP to true
// regardless of how it was set in the config
EnableXHP = true;
}
ParserThreadCount = Config::GetInt32(ini, config["ParserThreadCount"], 0);
if (ParserThreadCount <= 0) {
ParserThreadCount = Process::GetCPUCount();
}
EnableEval = (EvalLevel) Config::GetByte(ini, config["EnableEval"], 0);
AllDynamic = Config::GetBool(ini, config["AllDynamic"], true);
//.........这里部分代码省略.........
示例6: Load
void Option::Load(Hdf &config) {
LoadRootHdf(config["IncludeRoots"], IncludeRoots);
LoadRootHdf(config["AutoloadRoots"], AutoloadRoots);
config["PackageFiles"].get(PackageFiles);
config["IncludeSearchPaths"].get(IncludeSearchPaths);
config["PackageDirectories"].get(PackageDirectories);
config["PackageExcludeDirs"].get(PackageExcludeDirs);
config["PackageExcludeFiles"].get(PackageExcludeFiles);
config["PackageExcludePatterns"].get(PackageExcludePatterns);
config["PackageExcludeStaticDirs"].get(PackageExcludeStaticDirs);
config["PackageExcludeStaticFiles"].get(PackageExcludeStaticFiles);
config["PackageExcludeStaticPatterns"].get(PackageExcludeStaticPatterns);
CachePHPFile = config["CachePHPFile"].getBool();
config["ParseOnDemandDirs"].get(ParseOnDemandDirs);
{
Hdf cg = config["CodeGeneration"];
string tmp;
#define READ_CG_OPTION(name) \
tmp = cg[#name].getString(); \
if (!tmp.empty()) { \
name = OptionStrings.add(tmp.c_str()); \
}
READ_CG_OPTION(IdPrefix);
READ_CG_OPTION(LabelEscape);
READ_CG_OPTION(LambdaPrefix);
}
int count = 0;
for (Hdf hdf = config["SepExtensions"].firstChild(); hdf.exists();
hdf = hdf.next()) {
++count;
}
SepExtensions.resize(count);
count = 0;
for (Hdf hdf = config["SepExtensions"].firstChild(); hdf.exists();
hdf = hdf.next()) {
SepExtensionOptions &options = SepExtensions[count++];
options.name = hdf.getName();
options.soname = hdf["soname"].getString();
options.include_path = hdf["include"].getString();
options.lib_path = hdf["libpath"].getString();
options.shared = hdf["shared"].getBool();
}
config["DynamicFunctionPrefix"].get(DynamicFunctionPrefixes);
config["DynamicFunctionPostfix"].get(DynamicFunctionPostfixes);
config["DynamicMethodPrefix"].get(DynamicMethodPrefixes);
config["DynamicInvokeFunctions"].get(DynamicInvokeFunctions);
config["VolatileClasses"].get(VolatileClasses);
// build map from function names to sections
for (Hdf hdf = config["FunctionSections"].firstChild(); hdf.exists();
hdf = hdf.next()) {
for (Hdf hdfFunc = hdf.firstChild(); hdfFunc.exists();
hdfFunc = hdfFunc.next()) {
FunctionSections[hdfFunc.getString()] = hdf.getName();
}
}
{
Hdf repo = config["Repo"];
{
Hdf repoCentral = repo["Central"];
RepoCentralPath = repoCentral["Path"].getString();
}
RepoDebugInfo = repo["DebugInfo"].getBool(false);
}
{
Hdf autoloadMap = config["AutoloadMap"];
autoloadMap["class"].get(AutoloadClassMap);
autoloadMap["function"].get(AutoloadFuncMap);
autoloadMap["constant"].get(AutoloadConstMap);
AutoloadRoot = autoloadMap["root"].getString();
}
HardTypeHints = config["HardTypeHints"].getBool(true);
EnableHipHopSyntax = config["EnableHipHopSyntax"].getBool();
JitEnableRenameFunction = config["JitEnableRenameFunction"].getBool();
EnableHipHopExperimentalSyntax =
config["EnableHipHopExperimentalSyntax"].getBool();
EnableShortTags = config["EnableShortTags"].getBool(true);
EnableAspTags = config["EnableAspTags"].getBool();
EnableXHP = config["EnableXHP"].getBool(true);
ParserThreadCount = config["ParserThreadCount"].getInt32(0);
if (ParserThreadCount <= 0) {
ParserThreadCount = Process::GetCPUCount();
}
EnableFinallyStatement = config["EnableFinallyStatement"].getBool();
//.........这里部分代码省略.........
示例7: init
void VirtualHost::init(Hdf vh) {
m_name = vh.getName();
const char *prefix = vh["Prefix"].get("");
const char *pattern = vh["Pattern"].get("");
const char *pathTranslation = vh["PathTranslation"].get("");
Hdf overwrite = vh["overwrite"];
initRuntimeOption(overwrite);
if (prefix) m_prefix = prefix;
if (pattern) {
m_pattern = Util::format_pattern(pattern, true);
if (!m_pattern.empty()) {
m_pattern += "i"; // case-insensitive
}
}
if (pathTranslation) {
m_pathTranslation = pathTranslation;
if (!m_pathTranslation.empty() &&
m_pathTranslation[m_pathTranslation.length() - 1] != '/') {
m_pathTranslation += '/';
}
}
m_disabled = vh["Disabled"].getBool(false);
m_documentRoot = RuntimeOption::SourceRoot + m_pathTranslation;
if (!m_documentRoot.empty() &&
m_documentRoot[m_documentRoot.length() - 1] == '/') {
m_documentRoot = m_documentRoot.substr(0, m_documentRoot.length() - 1);
}
Hdf rewriteRules = vh["RewriteRules"];
for (Hdf hdf = rewriteRules.firstChild(); hdf.exists(); hdf = hdf.next()) {
RewriteRule dummy;
m_rewriteRules.push_back(dummy);
RewriteRule &rule = m_rewriteRules.back();
rule.pattern = Util::format_pattern(hdf["pattern"].getString(""), true);
rule.to = hdf["to"].getString("");
rule.qsa = hdf["qsa"].getBool(false);
rule.redirect = hdf["redirect"].getInt16(0);
if (rule.pattern.empty() || rule.to.empty()) {
throw InvalidArgumentException("rewrite rule", "(empty pattern or to)");
}
Hdf rewriteConds = hdf["conditions"];
for (Hdf chdf = rewriteConds.firstChild(); chdf.exists();
chdf = chdf.next()) {
RewriteCond dummy;
rule.rewriteConds.push_back(dummy);
RewriteCond &cond = rule.rewriteConds.back();
cond.pattern = Util::format_pattern(chdf["pattern"].getString(""), true);
if (cond.pattern.empty()) {
throw InvalidArgumentException("rewrite rule", "(empty cond pattern)");
}
const char *type = chdf["type"].get();
if (type) {
if (strcasecmp(type, "host") == 0) {
cond.type = RewriteCond::Host;
} else if (strcasecmp(type, "request") == 0) {
cond.type = RewriteCond::Request;
} else {
throw InvalidArgumentException("rewrite rule",
"(invalid cond type)");
}
} else {
cond.type = RewriteCond::Request;
}
cond.negate = chdf["negate"].getBool(false);
}
}
if (vh["IpBlockMap"].firstChild().exists()) {
Hdf ipblocks = vh["IpBlockMap"];
m_ipBlocks = IpBlockMapPtr(new IpBlockMap(ipblocks));
}
Hdf logFilters = vh["LogFilters"];
for (Hdf hdf = logFilters.firstChild(); hdf.exists(); hdf = hdf.next()) {
QueryStringFilter filter;
filter.urlPattern = Util::format_pattern(hdf["url"].getString(""), true);
filter.replaceWith = hdf["value"].getString("");
filter.replaceWith = "\\1=" + filter.replaceWith;
string pattern = hdf["pattern"].getString("");
vector<string> names;
hdf["params"].get(names);
if (pattern.empty()) {
for (unsigned int i = 0; i < names.size(); i++) {
if (pattern.empty()) {
pattern = "(?<=[&\?])(";
} else {
pattern += "|";
}
pattern += names[i];
}
if (!pattern.empty()) {
pattern += ")=.*?(?=(&|$))";
pattern = Util::format_pattern(pattern, false);
//.........这里部分代码省略.........
示例8: get
void Hdf::get(hphp_string_imap<std::string> &values) const {
values.clear();
for (Hdf hdf = firstChild(); hdf.exists(); hdf = hdf.next()) {
values[hdf.getName()] = hdf.getString("");
}
}
示例9: Load
void RuntimeOption::Load(Hdf &config, StringVec *overwrites /* = NULL */) {
// Machine metrics
string hostname, tier, cpu;
{
Hdf machine = config["Machine"];
hostname = machine["name"].getString();
if (hostname.empty()) {
hostname = Process::GetHostName();
}
tier = machine["tier"].getString();
cpu = machine["cpu"].getString();
if (cpu.empty()) {
cpu = Process::GetCPUModel();
}
}
// Tier overwrites
{
Hdf tiers = config["Tiers"];
for (Hdf hdf = tiers.firstChild(); hdf.exists(); hdf = hdf.next()) {
if (matchHdfPattern(hostname, hdf["machine"]) &&
matchHdfPattern(tier, hdf["tier"]) &&
matchHdfPattern(cpu, hdf["cpu"])) {
Tier = hdf.getName();
config.copy(hdf["overwrite"]);
// no break here, so we can continue to match more overwrites
}
hdf["overwrite"].setVisited(); // avoid lint complaining
}
}
// More overwrites
if (overwrites) {
for (unsigned int i = 0; i < overwrites->size(); i++) {
config.fromString(overwrites->at(i).c_str());
}
}
PidFile = config["PidFile"].getString("www.pid");
{
Hdf logger = config["Log"];
if (logger["Level"] == "None") {
Logger::LogLevel = Logger::LogNone;
} else if (logger["Level"] == "Error") {
Logger::LogLevel = Logger::LogError;
} else if (logger["Level"] == "Warning") {
Logger::LogLevel = Logger::LogWarning;
} else if (logger["Level"] == "Info") {
Logger::LogLevel = Logger::LogInfo;
} else if (logger["Level"] == "Verbose") {
Logger::LogLevel = Logger::LogVerbose;
}
Logger::LogHeader = logger["Header"].getBool();
bool logInjectedStackTrace = logger["InjectedStackTrace"].getBool();
if (logInjectedStackTrace) {
Logger::SetTheLogger(new ExtendedLogger());
ExtendedLogger::EnabledByDefault = true;
}
Logger::LogNativeStackTrace = logger["NativeStackTrace"].getBool(true);
Logger::MaxMessagesPerRequest =
logger["MaxMessagesPerRequest"].getInt32(-1);
Logger::UseLogFile = logger["UseLogFile"].getBool(true);
Logger::UseCronolog = logger["UseCronolog"].getBool(false);
if (Logger::UseLogFile) {
LogFile = logger["File"].getString();
LogFileSymLink = logger["SymLink"].getString();
}
Logger::DropCacheChunkSize =
logger["DropCacheChunkSize"].getInt32(1 << 20);
AlwaysEscapeLog = logger["AlwaysEscapeLog"].getBool(false);
Hdf aggregator = logger["Aggregator"];
Logger::UseLogAggregator = aggregator.getBool();
LogAggregatorFile = aggregator["File"].getString();
LogAggregatorDatabase = aggregator["Database"].getString();
LogAggregatorSleepSeconds = aggregator["SleepSeconds"].getInt16(10);
AlwaysLogUnhandledExceptions =
logger["AlwaysLogUnhandledExceptions"].getBool(true);
NoSilencer = logger["NoSilencer"].getBool();
EnableApplicationLog = logger["ApplicationLog"].getBool(true);
RuntimeErrorReportingLevel =
logger["RuntimeErrorReportingLevel"].getInt32(ErrorConstants::HPHP_ALL);
AccessLogDefaultFormat = logger["AccessLogDefaultFormat"].
getString("%h %l %u %t \"%r\" %>s %b");
{
Hdf access = logger["Access"];
for (Hdf hdf = access.firstChild(); hdf.exists();
hdf = hdf.next()) {
string fname = hdf["File"].getString();
if (fname.empty()) {
continue;
}
string symLink = hdf["SymLink"].getString();
//.........这里部分代码省略.........
示例10: createFromUserConfig
void SourceRootInfo::createFromUserConfig() {
String homePath = String(RuntimeOption::SandboxHome) + "/" + m_user + "/";
{
struct stat hstat;
if (stat(homePath.c_str(), &hstat) != 0) {
if (!RuntimeOption::SandboxFallback.empty()) {
homePath = String(RuntimeOption::SandboxFallback) + "/" + m_user + "/";
if (stat(homePath.c_str(), &hstat) != 0) {
m_sandboxCond = SandboxOff;
return;
}
}
}
}
string confpath = string(homePath.c_str()) +
RuntimeOption::SandboxConfFile;
Hdf config, serverVars;
String sp, lp, alp, userOverride;
try {
config.open(confpath);
userOverride = config["user_override"].get();
Hdf sboxConf = config[m_sandbox.c_str()];
if (sboxConf.exists()) {
sp = sboxConf["path"].get();
lp = sboxConf["log"].get();
alp = sboxConf["accesslog"].get();
serverVars = sboxConf["ServerVars"];
}
} catch (HdfException &e) {
Logger::Error("%s ignored: %s", confpath.c_str(),
e.getMessage().c_str());
}
if (serverVars.exists()) {
for (Hdf hdf = serverVars.firstChild(); hdf.exists(); hdf = hdf.next()) {
m_serverVars.set(String(hdf.getName()), String(hdf.getString()));
}
}
if (!userOverride.empty()) {
m_user = std::move(userOverride);
}
if (m_sandbox == "default") {
if (sp.isNull()) {
sp = "www/";
}
}
if (sp.isNull()) {
m_sandboxCond = SandboxError;
return;
}
if (sp.charAt(0) == '/') {
m_path = std::move(sp);
} else {
m_path = homePath + sp;
}
if (m_path.charAt(m_path.size() - 1) != '/') {
m_path += "/";
}
if (!lp.isNull()) {
if (lp.charAt(0) != '/') {
lp = homePath + lp;
}
if (!Logger::SetThreadLog(lp.c_str())) {
Logger::Warning("Sandbox error log %s could not be opened",
lp.c_str());
}
}
if (!alp.isNull()) {
if (alp.charAt(0) != '/') {
alp = homePath + alp;
}
if (!HttpRequestHandler::GetAccessLog().setThreadLog(alp.c_str())) {
Logger::Warning("Sandbox access log %s could not be opened",
alp.c_str());
}
}
}
示例11: Load
void Option::Load(Hdf &config) {
LoadRootHdf(config["IncludeRoots"], IncludeRoots);
LoadRootHdf(config["AutoloadRoots"], AutoloadRoots);
config["PackageFiles"].get(PackageFiles);
config["IncludeSearchPaths"].get(IncludeSearchPaths);
config["PackageDirectories"].get(PackageDirectories);
config["PackageExcludeDirs"].get(PackageExcludeDirs);
config["PackageExcludeFiles"].get(PackageExcludeFiles);
config["PackageExcludePatterns"].get(PackageExcludePatterns);
config["PackageExcludeStaticDirs"].get(PackageExcludeStaticDirs);
config["PackageExcludeStaticFiles"].get(PackageExcludeStaticFiles);
config["PackageExcludeStaticPatterns"].get(PackageExcludeStaticPatterns);
CachePHPFile = config["CachePHPFile"].getBool();
config["ParseOnDemandDirs"].get(ParseOnDemandDirs);
{
Hdf cg = config["CodeGeneration"];
string tmp;
#define READ_CG_OPTION(name) \
tmp = cg[#name].getString(); \
if (!tmp.empty()) { \
name = OptionStrings.add(tmp.c_str()); \
}
READ_CG_OPTION(IdPrefix);
READ_CG_OPTION(LabelEscape);
READ_CG_OPTION(LambdaPrefix);
READ_CG_OPTION(FunctionPrefix);
READ_CG_OPTION(BuiltinFunctionPrefix);
READ_CG_OPTION(InvokePrefix);
READ_CG_OPTION(CreateObjectPrefix);
READ_CG_OPTION(PseudoMainPrefix);
READ_CG_OPTION(VariablePrefix);
READ_CG_OPTION(GlobalVariablePrefix);
READ_CG_OPTION(StaticVariablePrefix);
READ_CG_OPTION(ScalarArrayName);
READ_CG_OPTION(SystemScalarArrayName);
READ_CG_OPTION(ClassPrefix);
READ_CG_OPTION(ClassStaticsPrefix);
READ_CG_OPTION(ClassStaticsObjectPrefix);
READ_CG_OPTION(ClassStaticsCallbackPrefix);
READ_CG_OPTION(ClassStaticsIdGetterPrefix);
READ_CG_OPTION(ClassStaticInitializerPrefix);
READ_CG_OPTION(ClassStaticInitializerFlagPrefix);
READ_CG_OPTION(ClassWrapperFunctionPrefix);
READ_CG_OPTION(ObjectPrefix);
READ_CG_OPTION(ObjectStaticPrefix);
READ_CG_OPTION(SmartPtrPrefix);
READ_CG_OPTION(MethodPrefix);
READ_CG_OPTION(MethodWrapperPrefix);
READ_CG_OPTION(MethodImplPrefix);
READ_CG_OPTION(PropertyPrefix);
READ_CG_OPTION(StaticPropertyPrefix);
READ_CG_OPTION(ConstantPrefix);
READ_CG_OPTION(ClassConstantPrefix);
READ_CG_OPTION(ExceptionPrefix);
READ_CG_OPTION(TempVariablePrefix);
READ_CG_OPTION(EvalOrderTempPrefix);
READ_CG_OPTION(SilencerPrefix);
READ_CG_OPTION(EvalInvokePrefix);
READ_CG_OPTION(TempPrefix);
READ_CG_OPTION(MapPrefix);
READ_CG_OPTION(IterPrefix);
READ_CG_OPTION(InitPrefix);
READ_CG_OPTION(FFIFnPrefix);
READ_CG_OPTION(SystemFilePrefix);
READ_CG_OPTION(UserFilePrefix);
READ_CG_OPTION(ClassHeaderPrefix);
READ_CG_OPTION(ClusterPrefix);
READ_CG_OPTION(FFIFilePrefix);
}
int count = 0;
for (Hdf hdf = config["SepExtensions"].firstChild(); hdf.exists();
hdf = hdf.next()) {
++count;
}
SepExtensions.resize(count);
count = 0;
for (Hdf hdf = config["SepExtensions"].firstChild(); hdf.exists();
hdf = hdf.next()) {
SepExtensionOptions &options = SepExtensions[count++];
options.name = hdf.getName();
options.soname = hdf["soname"].getString();
options.include_path = hdf["include"].getString();
options.lib_path = hdf["libpath"].getString();
options.shared = hdf["shared"].getBool();
}
config["DynamicFunctionPrefix"].get(DynamicFunctionPrefixes);
config["DynamicFunctionPostfix"].get(DynamicFunctionPostfixes);
config["DynamicMethodPrefix"].get(DynamicMethodPrefixes);
config["DynamicInvokeFunctions"].get(DynamicInvokeFunctions);
config["VolatileClasses"].get(VolatileClasses);
// build map from function names to sections
for (Hdf hdf = config["FunctionSections"].firstChild(); hdf.exists();
//.........这里部分代码省略.........
示例12: Load
void Option::Load(Hdf &config) {
LoadRootHdf(config["IncludeRoots"], IncludeRoots);
LoadRootHdf(config["AutoloadRoots"], AutoloadRoots);
config["IncludeSearchPaths"].get(IncludeSearchPaths);
config["PackageDirectories"].get(PackageDirectories);
config["PackageExcludeDirs"].get(PackageExcludeDirs);
config["PackageExcludeFiles"].get(PackageExcludeFiles);
config["PackageExcludeStaticFiles"].get(PackageExcludeStaticFiles);
CachePHPFile = config["CachePHPFile"].getBool();
{
Hdf cg = config["CodeGeneration"];
string tmp;
#define READ_CG_OPTION(name) \
tmp = cg[#name].getString(); \
if (!tmp.empty()) { \
name = OptionStrings.add(tmp.c_str()); \
}
READ_CG_OPTION(IdPrefix);
READ_CG_OPTION(LambdaPrefix);
READ_CG_OPTION(FunctionPrefix);
READ_CG_OPTION(BuiltinFunctionPrefix);
READ_CG_OPTION(InvokePrefix);
READ_CG_OPTION(CreateObjectPrefix);
READ_CG_OPTION(PseudoMainPrefix);
READ_CG_OPTION(VariablePrefix);
READ_CG_OPTION(GlobalVariablePrefix);
READ_CG_OPTION(StaticVariablePrefix);
READ_CG_OPTION(ScalarArrayName);
READ_CG_OPTION(SystemScalarArrayName);
READ_CG_OPTION(ClassPrefix);
READ_CG_OPTION(ClassStaticsPrefix);
READ_CG_OPTION(ClassStaticsObjectPrefix);
READ_CG_OPTION(ClassStaticsIdGetterPrefix);
READ_CG_OPTION(ClassStaticInitializerPrefix);
READ_CG_OPTION(ClassStaticInitializerFlagPrefix);
READ_CG_OPTION(ClassWrapperFunctionPrefix);
READ_CG_OPTION(ObjectPrefix);
READ_CG_OPTION(ObjectStaticPrefix);
READ_CG_OPTION(SmartPtrPrefix);
READ_CG_OPTION(MethodPrefix);
READ_CG_OPTION(MethodImplPrefix);
READ_CG_OPTION(PropertyPrefix);
READ_CG_OPTION(StaticPropertyPrefix);
READ_CG_OPTION(ConstantPrefix);
READ_CG_OPTION(ClassConstantPrefix);
READ_CG_OPTION(ExceptionPrefix);
READ_CG_OPTION(TempVariablePrefix);
READ_CG_OPTION(EvalOrderTempPrefix);
READ_CG_OPTION(SilencerPrefix);
READ_CG_OPTION(EvalInvokePrefix);
READ_CG_OPTION(TempPrefix);
READ_CG_OPTION(MapPrefix);
READ_CG_OPTION(IterPrefix);
READ_CG_OPTION(InitPrefix);
READ_CG_OPTION(FFIFnPrefix);
READ_CG_OPTION(SystemFilePrefix);
READ_CG_OPTION(UserFilePrefix);
READ_CG_OPTION(ClassHeaderPrefix);
READ_CG_OPTION(ClusterPrefix);
READ_CG_OPTION(FFIFilePrefix);
}
int count = 0;
for (Hdf hdf = config["SepExtensions"].firstChild(); hdf.exists();
hdf = hdf.next()) {
++count;
}
SepExtensions.resize(count);
count = 0;
for (Hdf hdf = config["SepExtensions"].firstChild(); hdf.exists();
hdf = hdf.next()) {
SepExtensionOptions &options = SepExtensions[count++];
options.name = hdf.getName();
options.soname = hdf["soname"].getString();
options.include_path = hdf["include"].getString();
options.lib_path = hdf["libpath"].getString();
options.shared = hdf["shared"].getBool();
}
config["DynamicFunctionPrefix"].get(DynamicFunctionPrefixes);
config["DynamicFunctionPostfix"].get(DynamicFunctionPostfixes);
config["DynamicMethodPrefix"].get(DynamicMethodPrefixes);
config["DynamicInvokeFunctions"].get(DynamicInvokeFunctions);
config["VolatileClasses"].get(VolatileClasses);
ScalarArrayFileCount = config["ScalarArrayFileCount"].getByte(1);
if (ScalarArrayFileCount <= 0) ScalarArrayFileCount = 1;
LiteralStringFileCount = config["LiteralStringFileCount"].getInt32(1);
if (LiteralStringFileCount <= 0) LiteralStringFileCount = 1;
ScalarArrayOverflowLimit = config["ScalarArrayOverflowLimit"].getInt32(2000);
if (ScalarArrayOverflowLimit <= 0) ScalarArrayOverflowLimit = 2000;
FlibDirectory = config["FlibDirectory"].getString();
EnableXHP = config["EnableXHP"].getBool();
RTTIOutputFile = config["RTTIOutputFile"].getString();
EnableEval = (EvalLevel)config["EnableEval"].getByte(0);
//.........这里部分代码省略.........
示例13: createFromUserConfig
void SourceRootInfo::createFromUserConfig() {
String homePath = String(RuntimeOption::SandboxHome) + "/" + m_user + "/";
{
struct stat hstat;
if (stat(homePath.c_str(), &hstat) != 0) {
if (!RuntimeOption::SandboxFallback.empty()) {
homePath = String(RuntimeOption::SandboxFallback) + "/" + m_user + "/";
if (stat(homePath.c_str(), &hstat) != 0) {
m_sandboxCond = SandboxCondition::Off;
return;
}
}
}
}
std::string confFileName = std::string(homePath.c_str()) +
RuntimeOption::SandboxConfFile;
IniSetting::Map ini = IniSetting::Map::object;
Hdf config;
String sp, lp, alp, userOverride;
try {
Config::ParseConfigFile(confFileName, ini, config);
userOverride = Config::Get(ini, config, "user_override");
sp = Config::Get(ini, config, (m_sandbox + ".path").c_str());
lp = Config::Get(ini, config, (m_sandbox + ".log").c_str());
alp = Config::Get(ini, config, (m_sandbox + ".accesslog").c_str());
} catch (HdfException &e) {
Logger::Error("%s ignored: %s", confFileName.c_str(),
e.getMessage().c_str());
}
if (config[(m_sandbox + ".ServerVars").c_str()]. exists()) {
for (Hdf hdf = config[(m_sandbox + ".ServerVars").c_str()].firstChild();
hdf.exists(); hdf = hdf.next()) {
m_serverVars.set(String(hdf.getName()),
String(Config::GetString(ini, hdf)));
}
}
if (!userOverride.empty()) {
m_user = std::move(userOverride);
}
if (m_sandbox == s_default) {
if (sp.isNull()) {
sp = "www/";
}
}
if (sp.isNull()) {
m_sandboxCond = SandboxCondition::Error;
return;
}
if (sp.charAt(0) == '/') {
m_path = std::move(sp);
} else {
m_path = homePath + sp;
}
if (m_path.charAt(m_path.size() - 1) != '/') {
m_path += "/";
}
if (!lp.isNull()) {
if (lp.charAt(0) != '/') {
lp = homePath + lp;
}
if (!Logger::SetThreadLog(lp.c_str())) {
Logger::Warning("Sandbox error log %s could not be opened",
lp.c_str());
}
}
if (!alp.isNull()) {
if (alp.charAt(0) != '/') {
alp = homePath + alp;
}
if (!HttpRequestHandler::GetAccessLog().setThreadLog(alp.c_str())) {
Logger::Warning("Sandbox access log %s could not be opened",
alp.c_str());
}
}
}
示例14: Load
void Option::Load(const IniSetting::Map& ini, Hdf &config) {
LoadRootHdf(ini, config, "IncludeRoots", IncludeRoots);
LoadRootHdf(ini, config, "AutoloadRoots", AutoloadRoots);
Config::Bind(PackageFiles, ini, config, "PackageFiles", PackageFiles);
Config::Bind(IncludeSearchPaths, ini, config, "IncludeSearchPaths");
Config::Bind(PackageDirectories, ini, config, "PackageDirectories");
Config::Bind(PackageExcludeDirs, ini, config, "PackageExcludeDirs");
Config::Bind(PackageExcludeFiles, ini, config, "PackageExcludeFiles");
Config::Bind(PackageExcludePatterns, ini, config, "PackageExcludePatterns");
Config::Bind(PackageExcludeStaticDirs, ini,
config, "PackageExcludeStaticDirs");
Config::Bind(PackageExcludeStaticFiles, ini,
config, "PackageExcludeStaticFiles");
Config::Bind(PackageExcludeStaticFiles, ini,
config, "PackageExcludeStaticPatterns");
Config::Bind(CachePHPFile, ini, config, "CachePHPFile");
Config::Bind(ParseOnDemandDirs, ini, config, "ParseOnDemandDirs");
{
std::string tmp;
#define READ_CG_OPTION(name) \
tmp = Config::GetString(ini, config, "CodeGeneration."#name); \
if (!tmp.empty()) { \
name = OptionStrings.add(tmp.c_str()); \
}
READ_CG_OPTION(IdPrefix);
READ_CG_OPTION(LambdaPrefix);
}
Config::Bind(DynamicInvokeFunctions, ini, config, "DynamicInvokeFunctions");
Config::Bind(VolatileClasses, ini, config, "VolatileClasses");
// build map from function names to sections
for (Hdf hdf = config["FunctionSections"].firstChild(); hdf.exists();
hdf = hdf.next()) {
for (Hdf hdfFunc = hdf.firstChild(); hdfFunc.exists();
hdfFunc = hdfFunc.next()) {
FunctionSections[Config::GetString(ini, hdfFunc, "", "", false)]
= hdf.getName();
}
}
{
// Repo
{
// Repo Central
Config::Bind(RepoCentralPath, ini, config, "Repo.Central.Path");
}
Config::Bind(RepoDebugInfo, ini, config, "Repo.DebugInfo", false);
}
{
// AutoloadMap
Config::Bind(AutoloadClassMap, ini, config, "AutoloadMap.class");
Config::Bind(AutoloadFuncMap, ini, config, "AutoloadMap.function");
Config::Bind(AutoloadConstMap, ini, config, "AutoloadMap.constant");
Config::Bind(AutoloadRoot, ini, config, "AutoloadMap.root");
}
Config::Bind(HardTypeHints, ini, config, "HardTypeHints", true);
Config::Bind(HardReturnTypeHints, ini, config, "HardReturnTypeHints", false);
Config::Bind(HardConstProp, ini, config, "HardConstProp", true);
Config::Bind(EnableHipHopSyntax, ini, config, "EnableHipHopSyntax");
Config::Bind(EnableZendCompat, ini, config, "EnableZendCompat");
Config::Bind(JitEnableRenameFunction, ini, config, "JitEnableRenameFunction");
Config::Bind(EnableHipHopExperimentalSyntax, ini,
config, "EnableHipHopExperimentalSyntax");
Config::Bind(EnableShortTags, ini, config, "EnableShortTags", true);
{
// Hack
Config::Bind(IntsOverflowToInts, ini, config,
"Hack.Lang.IntsOverflowToInts", EnableHipHopSyntax);
Config::Bind(StrictArrayFillKeys, ini, config,
"Hack.Lang.StrictArrayFillKeys");
Config::Bind(DisallowDynamicVarEnvFuncs, ini, config,
"Hack.Lang.DisallowDynamicVarEnvFuncs");
}
Config::Bind(EnableAspTags, ini, config, "EnableAspTags");
Config::Bind(EnableXHP, ini, config, "EnableXHP", false);
if (EnableHipHopSyntax) {
// If EnableHipHopSyntax is true, it forces EnableXHP to true
// regardless of how it was set in the config
EnableXHP = true;
}
Config::Bind(ParserThreadCount, ini, config, "ParserThreadCount", 0);
if (ParserThreadCount <= 0) {
ParserThreadCount = Process::GetCPUCount();
}
// Just to silence warnings until we remove them from various config files
//.........这里部分代码省略.........
示例15: init
void VirtualHost::init(const IniSetting::Map& ini, Hdf vh) {
m_name = vh.getName();
const char *prefix = Config::Get(ini, vh, "Prefix", "", false);
const char *pattern = Config::Get(ini, vh, "Pattern", "", false);
const char *pathTranslation = Config::Get(ini, vh, "PathTranslation", "",
false);
if (prefix) m_prefix = prefix;
if (pattern) {
m_pattern = format_pattern(pattern, false);
if (!m_pattern.empty()) {
m_pattern += "i"; // case-insensitive
}
}
if (pathTranslation) {
m_pathTranslation = pathTranslation;
if (!m_pathTranslation.empty() &&
m_pathTranslation[m_pathTranslation.length() - 1] != '/') {
m_pathTranslation += '/';
}
}
initRuntimeOption(ini, vh); // overwrites
m_disabled = Config::GetBool(ini, vh, "Disabled", false, false);
m_checkExistenceBeforeRewrite =
Config::GetBool(ini, vh, "CheckExistenceBeforeRewrite", true, false);
for (Hdf hdf = vh["RewriteRules"].firstChild(); hdf.exists();
hdf = hdf.next()) {
RewriteRule dummy;
m_rewriteRules.push_back(dummy);
RewriteRule &rule = m_rewriteRules.back();
rule.pattern = format_pattern(Config::GetString(ini, hdf, "pattern", "",
false),
true);
rule.to = Config::GetString(ini, hdf, "to", "", false);
rule.qsa = Config::GetBool(ini, hdf, "qsa", false, false);
rule.redirect = Config::GetInt16(ini, hdf, "redirect", 0, false);
rule.encode_backrefs = Config::GetBool(ini, hdf, "encode_backrefs", false,
false);
if (rule.pattern.empty() || rule.to.empty()) {
throw std::runtime_error("Invalid rewrite rule: (empty pattern or to)");
}
for (Hdf chdf = hdf["conditions"].firstChild(); chdf.exists();
chdf = chdf.next()) {
RewriteCond dummy;
rule.rewriteConds.push_back(dummy);
RewriteCond &cond = rule.rewriteConds.back();
cond.pattern = format_pattern(Config::GetString(ini, chdf, "pattern", "",
false),
true);
if (cond.pattern.empty()) {
throw std::runtime_error("Invalid rewrite rule: (empty cond pattern)");
}
const char *type = Config::Get(ini, chdf, "type", "", false);
if (type) {
if (strcasecmp(type, "host") == 0) {
cond.type = RewriteCond::Type::Host;
} else if (strcasecmp(type, "request") == 0) {
cond.type = RewriteCond::Type::Request;
} else {
throw std::runtime_error("Invalid rewrite rule: (invalid "
"cond type)");
}
} else {
cond.type = RewriteCond::Type::Request;
}
cond.negate = Config::GetBool(ini, chdf, "negate", false, false);
}
}
if (vh["IpBlockMap"].firstChild().exists()) {
m_ipBlocks = std::make_shared<IpBlockMap>(ini, vh["IpBlockMap"]);
}
for (Hdf hdf = vh["LogFilters"].firstChild(); hdf.exists();
hdf = hdf.next()) {
QueryStringFilter filter;
filter.urlPattern = format_pattern(Config::GetString(ini, hdf, "url", "",
false),
true);
filter.replaceWith = Config::GetString(ini, hdf, "value", "", false);
filter.replaceWith = "\\1=" + filter.replaceWith;
std::string pattern = Config::GetString(ini, hdf, "pattern", "", false);
std::vector<std::string> names;
names = Config::GetVector(ini, hdf, "params", names, false);
if (pattern.empty()) {
for (unsigned int i = 0; i < names.size(); i++) {
if (pattern.empty()) {
pattern = "(?<=[&\?])(";
} else {
pattern += "|";
//.........这里部分代码省略.........