mirror of https://github.com/Icinga/icinga2.git
parent
383d2369b1
commit
a88d9b5646
|
@ -1618,7 +1618,7 @@ yyreduce:
|
|||
/* Line 1806 of yacc.c */
|
||||
#line 118 "config_parser.yy"
|
||||
{
|
||||
context->HandleInclude((yyvsp[(2) - (2)].text), false);
|
||||
context->HandleInclude((yyvsp[(2) - (2)].text), false, yylloc);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -1627,7 +1627,7 @@ yyreduce:
|
|||
/* Line 1806 of yacc.c */
|
||||
#line 122 "config_parser.yy"
|
||||
{
|
||||
context->HandleInclude((yyvsp[(2) - (2)].text), true);
|
||||
context->HandleInclude((yyvsp[(2) - (2)].text), true, yylloc);
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
@ -116,11 +116,11 @@ statement: object | type | include | library
|
|||
|
||||
include: T_INCLUDE T_STRING
|
||||
{
|
||||
context->HandleInclude($2, false);
|
||||
context->HandleInclude($2, false, yylloc);
|
||||
}
|
||||
| T_INCLUDE T_STRING_ANGLE
|
||||
{
|
||||
context->HandleInclude($2, true);
|
||||
context->HandleInclude($2, true, yylloc);
|
||||
}
|
||||
|
||||
library: T_LIBRARY T_STRING
|
||||
|
|
|
@ -114,13 +114,14 @@ String ConfigCompiler::GetPath(void) const
|
|||
*
|
||||
* @param include The path from the include directive.
|
||||
* @param search Whether to search global include dirs.
|
||||
* @param debuginfo Debug information.
|
||||
*/
|
||||
void ConfigCompiler::HandleInclude(const String& include, bool search)
|
||||
void ConfigCompiler::HandleInclude(const String& include, bool search, const DebugInfo& debuginfo)
|
||||
{
|
||||
String path = Utility::DirName(GetPath()) + "/" + include;
|
||||
|
||||
vector<ConfigType::Ptr> types;
|
||||
m_HandleInclude(path, search, &m_ResultObjects, &types);
|
||||
m_HandleInclude(path, search, &m_ResultObjects, &types, debuginfo);
|
||||
|
||||
BOOST_FOREACH(const ConfigType::Ptr& type, types) {
|
||||
AddType(type);
|
||||
|
@ -202,9 +203,13 @@ void ConfigCompiler::CompileText(const String& path, const String& text,
|
|||
* configuration items.
|
||||
*
|
||||
* @param include The path from the include directive.
|
||||
* @param search Whether to search include dirs.
|
||||
* @param resultItems The resulting items.
|
||||
* @param resultTypes The resulting types.
|
||||
* @param debuginfo Debug information.
|
||||
*/
|
||||
void ConfigCompiler::HandleFileInclude(const String& include, bool search,
|
||||
vector<ConfigItem::Ptr> *resultItems, vector<ConfigType::Ptr> *resultTypes)
|
||||
vector<ConfigItem::Ptr> *resultItems, vector<ConfigType::Ptr> *resultTypes, const DebugInfo& debuginfo)
|
||||
{
|
||||
String includePath = include;
|
||||
|
||||
|
@ -229,8 +234,11 @@ void ConfigCompiler::HandleFileInclude(const String& include, bool search,
|
|||
|
||||
vector<ConfigItem::Ptr> items;
|
||||
|
||||
if (!Utility::Glob(includePath, boost::bind(&ConfigCompiler::CompileFile, _1, resultItems, resultTypes)))
|
||||
throw_exception(invalid_argument("Include file '" + include + "' does not exist (or no files found for pattern)."));
|
||||
if (!Utility::Glob(includePath, boost::bind(&ConfigCompiler::CompileFile, _1, resultItems, resultTypes))) {
|
||||
stringstream msgbuf;
|
||||
msgbuf << "Include file '" + include + "' does not exist (or no files found for pattern): " << debuginfo;
|
||||
throw_exception(invalid_argument(msgbuf.str()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -32,7 +32,8 @@ namespace icinga
|
|||
class I2_CONFIG_API ConfigCompiler
|
||||
{
|
||||
public:
|
||||
typedef function<void (const String&, bool, vector<ConfigItem::Ptr> *, vector<ConfigType::Ptr> *)> HandleIncludeFunc;
|
||||
typedef function<void (const String&, bool, vector<ConfigItem::Ptr> *,
|
||||
vector<ConfigType::Ptr> *, const DebugInfo&)> HandleIncludeFunc;
|
||||
|
||||
ConfigCompiler(const String& path, istream *input = &cin,
|
||||
HandleIncludeFunc includeHandler = &ConfigCompiler::HandleFileInclude);
|
||||
|
@ -54,10 +55,11 @@ public:
|
|||
String GetPath(void) const;
|
||||
|
||||
static void HandleFileInclude(const String& include, bool search,
|
||||
vector<ConfigItem::Ptr> *resultItems, vector<ConfigType::Ptr> *resultTypes);
|
||||
vector<ConfigItem::Ptr> *resultItems, vector<ConfigType::Ptr> *resultTypes,
|
||||
const DebugInfo& debuginfo);
|
||||
|
||||
/* internally used methods */
|
||||
void HandleInclude(const String& include, bool search);
|
||||
void HandleInclude(const String& include, bool search, const DebugInfo& debuginfo);
|
||||
void HandleLibrary(const String& library);
|
||||
|
||||
void AddObject(const ConfigItem::Ptr& object);
|
||||
|
|
Loading…
Reference in New Issue