Implement script variables IcingaPrefixDir, IcingaLocalStateDir, IcingaPkgLibDir, IcingaPkgDataDir and IcingaStatePath.

This commit is contained in:
Gunnar Beutner 2013-08-30 12:04:24 +02:00
parent ecc583fba0
commit 519ce78727
7 changed files with 203 additions and 181 deletions

View File

@ -172,20 +172,30 @@ int main(int argc, char **argv)
#ifdef ICINGA_PREFIX #ifdef ICINGA_PREFIX
Application::SetPrefixDir(ICINGA_PREFIX); Application::SetPrefixDir(ICINGA_PREFIX);
#else /* ICINGA_PREFIX */
Application::SetPrefixDir(".");
#endif /* ICINGA_PREFIX */ #endif /* ICINGA_PREFIX */
#ifdef ICINGA_LOCALSTATEDIR #ifdef ICINGA_LOCALSTATEDIR
Application::SetLocalStateDir(ICINGA_LOCALSTATEDIR); Application::SetLocalStateDir(ICINGA_LOCALSTATEDIR);
#else /* ICINGA_LOCALSTATEDIR */
Application::SetLocalStateDir("./var");
#endif /* ICINGA_LOCALSTATEDIR */ #endif /* ICINGA_LOCALSTATEDIR */
#ifdef ICINGA_PKGLIBDIR #ifdef ICINGA_PKGLIBDIR
Application::SetPkgLibDir(ICINGA_PKGLIBDIR); Application::SetPkgLibDir(ICINGA_PKGLIBDIR);
#else /* ICINGA_PKGLIBDIR */
Application::SetPkgLibDir(".");
#endif /* ICINGA_PKGLIBDIR */ #endif /* ICINGA_PKGLIBDIR */
#ifdef ICINGA_PKGDATADIR #ifdef ICINGA_PKGDATADIR
Application::SetPkgDataDir(ICINGA_PKGDATADIR); Application::SetPkgDataDir(ICINGA_PKGDATADIR);
#else /* ICINGA_PKGDATADIR */
Application::SetPkgDataDir(".");
#endif /* ICINGA_PKGDATADIR */ #endif /* ICINGA_PKGDATADIR */
Application::SetStatePath(Application::GetLocalStateDir() + "/lib/icinga2/icinga2.state");
po::options_description desc("Supported options"); po::options_description desc("Supported options");
desc.add_options() desc.add_options()
("help", "show this help message") ("help", "show this help message")

View File

@ -44,10 +44,6 @@ using namespace icinga;
Application *Application::m_Instance = NULL; Application *Application::m_Instance = NULL;
bool Application::m_ShuttingDown = false; bool Application::m_ShuttingDown = false;
bool Application::m_Debugging = false; bool Application::m_Debugging = false;
String Application::m_PrefixDir;
String Application::m_LocalStateDir;
String Application::m_PkgLibDir;
String Application::m_PkgDataDir;
int Application::m_ArgC; int Application::m_ArgC;
char **Application::m_ArgV; char **Application::m_ArgV;
@ -538,10 +534,7 @@ void Application::ClosePidFile(void)
*/ */
String Application::GetPrefixDir(void) String Application::GetPrefixDir(void)
{ {
if (m_PrefixDir.IsEmpty()) return ScriptVariable::Get("IcingaPrefixDir");
return ".";
else
return m_PrefixDir;
} }
/** /**
@ -551,7 +544,7 @@ String Application::GetPrefixDir(void)
*/ */
void Application::SetPrefixDir(const String& path) void Application::SetPrefixDir(const String& path)
{ {
m_PrefixDir = path; ScriptVariable::Set("IcingaPrefixDir", path);
} }
/** /**
@ -561,10 +554,7 @@ void Application::SetPrefixDir(const String& path)
*/ */
String Application::GetLocalStateDir(void) String Application::GetLocalStateDir(void)
{ {
if (m_LocalStateDir.IsEmpty()) return ScriptVariable::Get("IcingaLocalStateDir");
return "./var";
else
return m_LocalStateDir;
} }
/** /**
@ -574,7 +564,7 @@ String Application::GetLocalStateDir(void)
*/ */
void Application::SetLocalStateDir(const String& path) void Application::SetLocalStateDir(const String& path)
{ {
m_LocalStateDir = path; ScriptVariable::Set("IcingaLocalStateDir", path);
} }
/** /**
@ -584,10 +574,7 @@ void Application::SetLocalStateDir(const String& path)
*/ */
String Application::GetPkgLibDir(void) String Application::GetPkgLibDir(void)
{ {
if (m_PkgLibDir.IsEmpty()) return ScriptVariable::Get("IcingaPkgLibDir");
return ".";
else
return m_PkgLibDir;
} }
/** /**
@ -597,7 +584,7 @@ String Application::GetPkgLibDir(void)
*/ */
void Application::SetPkgLibDir(const String& path) void Application::SetPkgLibDir(const String& path)
{ {
m_PkgLibDir = path; ScriptVariable::Set("IcingaPkgLibDir", path);
} }
/** /**
@ -607,10 +594,7 @@ void Application::SetPkgLibDir(const String& path)
*/ */
String Application::GetPkgDataDir(void) String Application::GetPkgDataDir(void)
{ {
if (m_PkgDataDir.IsEmpty()) return ScriptVariable::Get("IcingaPkgDataDir");
return ".";
else
return m_PkgDataDir;
} }
/** /**
@ -620,7 +604,7 @@ String Application::GetPkgDataDir(void)
*/ */
void Application::SetPkgDataDir(const String& path) void Application::SetPkgDataDir(const String& path)
{ {
m_PkgDataDir = path; ScriptVariable::Set("IcingaPkgDataDir", path);
} }
/** /**
@ -630,13 +614,17 @@ void Application::SetPkgDataDir(const String& path)
*/ */
String Application::GetStatePath(void) String Application::GetStatePath(void)
{ {
String statePath = ScriptVariable::Get("IcingaStatePath"); return ScriptVariable::Get("IcingaStatePath");
}
/**
if (statePath.IsEmpty()) * Sets the path for the package data dir.
return GetLocalStateDir() + "/lib/icinga2/icinga2.state"; *
else * @param path The new path.
return statePath; */
void Application::SetStatePath(const String& path)
{
ScriptVariable::Set("IcingaStatePath", path);
} }
/** /**

View File

@ -81,6 +81,7 @@ public:
static void SetPkgDataDir(const String& path); static void SetPkgDataDir(const String& path);
static String GetStatePath(void); static String GetStatePath(void);
static void SetStatePath(const String& path);
static ThreadPool& GetTP(void); static ThreadPool& GetTP(void);
@ -101,10 +102,6 @@ private:
static char **m_ArgV; /**< Command-line arguments. */ static char **m_ArgV; /**< Command-line arguments. */
FILE *m_PidFile; /**< The PID file */ FILE *m_PidFile; /**< The PID file */
static bool m_Debugging; /**< Whether debugging is enabled. */ static bool m_Debugging; /**< Whether debugging is enabled. */
static String m_PrefixDir; /**< The installation prefix. */
static String m_LocalStateDir; /**< The local state dir. */
static String m_PkgLibDir; /**< The package lib dir. */
static String m_PkgDataDir; /**< The package data dir. */
#ifndef _WIN32 #ifndef _WIN32
static void SigIntHandler(int signum); static void SigIntHandler(int signum);

View File

@ -513,16 +513,16 @@ union yyalloc
/* YYFINAL -- State number of the termination state. */ /* YYFINAL -- State number of the termination state. */
#define YYFINAL 2 #define YYFINAL 2
/* YYLAST -- Last index in YYTABLE. */ /* YYLAST -- Last index in YYTABLE. */
#define YYLAST 149 #define YYLAST 152
/* YYNTOKENS -- Number of terminals. */ /* YYNTOKENS -- Number of terminals. */
#define YYNTOKENS 47 #define YYNTOKENS 47
/* YYNNTS -- Number of nonterminals. */ /* YYNNTS -- Number of nonterminals. */
#define YYNNTS 35 #define YYNNTS 35
/* YYNRULES -- Number of rules. */ /* YYNRULES -- Number of rules. */
#define YYNRULES 89 #define YYNRULES 90
/* YYNRULES -- Number of states. */ /* YYNRULES -- Number of states. */
#define YYNSTATES 131 #define YYNSTATES 132
/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
#define YYUNDEFTOK 2 #define YYUNDEFTOK 2
@ -577,15 +577,16 @@ static const yytype_uint8 yyprhs[] =
104, 105, 112, 115, 117, 118, 121, 123, 124, 126, 104, 105, 112, 115, 117, 118, 121, 123, 124, 126,
130, 131, 134, 138, 140, 143, 144, 146, 150, 154, 130, 131, 134, 138, 140, 143, 144, 146, 150, 154,
161, 163, 165, 167, 169, 171, 175, 177, 180, 181, 161, 163, 165, 167, 169, 171, 175, 177, 180, 181,
183, 187, 189, 191, 193, 195, 199, 201, 203, 207, 183, 187, 189, 191, 193, 195, 199, 201, 203, 205,
211, 215, 219, 223, 227, 231, 235, 239, 241, 243 209, 213, 217, 221, 225, 229, 233, 237, 241, 243,
245
}; };
/* YYRHS -- A `-1'-separated list of the rules' RHS. */ /* YYRHS -- A `-1'-separated list of the rules' RHS. */
static const yytype_int8 yyrhs[] = static const yytype_int8 yyrhs[] =
{ {
48, 0, -1, -1, 48, 49, -1, 63, -1, 54, 48, 0, -1, -1, 48, 49, -1, 63, -1, 54,
-1, 50, -1, 51, -1, 52, -1, 30, 3, -1, -1, 50, -1, 51, -1, 52, -1, 30, 81, -1,
30, 4, -1, 31, 3, -1, 13, 53, 8, 81, 30, 4, -1, 31, 3, -1, 13, 53, 8, 81,
-1, 7, -1, 3, -1, -1, 56, 26, 53, 55, -1, 7, -1, 3, -1, -1, 56, 26, 53, 55,
62, 57, -1, -1, 33, -1, -1, 40, 58, 59, 62, 57, -1, -1, 33, -1, -1, 40, 58, 59,
@ -603,12 +604,12 @@ static const yytype_int8 yyrhs[] =
-1, 8, -1, 9, -1, 10, -1, 11, -1, 12, -1, 8, -1, 9, -1, 10, -1, 11, -1, 12,
-1, 45, 76, 46, -1, 77, -1, 77, 42, -1, -1, 45, 76, 46, -1, 77, -1, 77, 42, -1,
-1, 81, -1, 77, 42, 81, -1, 3, -1, 5, -1, 81, -1, 77, 42, 81, -1, 3, -1, 5,
-1, 6, -1, 75, -1, 43, 80, 44, -1, 5, -1, 6, -1, 75, -1, 43, 80, 44, -1, 3,
-1, 53, -1, 80, 34, 80, -1, 80, 35, 80, -1, 5, -1, 7, -1, 80, 34, 80, -1, 80,
-1, 80, 36, 80, -1, 80, 37, 80, -1, 80, 35, 80, -1, 80, 36, 80, -1, 80, 37, 80,
38, 80, -1, 80, 39, 80, -1, 80, 14, 80, -1, 80, 38, 80, -1, 80, 39, 80, -1, 80,
-1, 80, 15, 80, -1, 43, 80, 44, -1, 78, 14, 80, -1, 80, 15, 80, -1, 43, 80, 44,
-1, 70, -1, 79, -1 -1, 78, -1, 70, -1, 79, -1
}; };
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
@ -621,8 +622,9 @@ static const yytype_uint16 yyrline[] =
304, 304, 345, 346, 351, 352, 355, 362, 365, 371, 304, 304, 345, 346, 351, 352, 355, 362, 365, 371,
384, 387, 393, 399, 403, 409, 412, 418, 430, 436, 384, 387, 393, 399, 403, 409, 412, 418, 430, 436,
450, 451, 452, 453, 454, 460, 466, 470, 476, 479, 450, 451, 452, 453, 454, 460, 466, 470, 476, 479,
494, 514, 519, 523, 527, 537, 542, 546, 551, 555, 494, 514, 519, 523, 527, 537, 542, 547, 551, 556,
559, 563, 567, 571, 575, 579, 583, 589, 590, 595 563, 567, 571, 575, 579, 583, 587, 591, 597, 598,
603
}; };
#endif #endif
@ -681,7 +683,8 @@ static const yytype_uint8 yyr1[] =
69, 69, 70, 71, 71, 72, 72, 72, 73, 73, 69, 69, 70, 71, 71, 72, 72, 72, 73, 73,
74, 74, 74, 74, 74, 75, 76, 76, 77, 77, 74, 74, 74, 74, 74, 75, 76, 76, 77, 77,
77, 78, 78, 78, 78, 79, 80, 80, 80, 80, 77, 78, 78, 78, 78, 79, 80, 80, 80, 80,
80, 80, 80, 80, 80, 80, 80, 81, 81, 81 80, 80, 80, 80, 80, 80, 80, 80, 81, 81,
81
}; };
/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
@ -694,8 +697,9 @@ static const yytype_uint8 yyr2[] =
0, 6, 2, 1, 0, 2, 1, 0, 1, 3, 0, 6, 2, 1, 0, 2, 1, 0, 1, 3,
0, 2, 3, 1, 2, 0, 1, 3, 3, 6, 0, 2, 3, 1, 2, 0, 1, 3, 3, 6,
1, 1, 1, 1, 1, 3, 1, 2, 0, 1, 1, 1, 1, 1, 1, 3, 1, 2, 0, 1,
3, 1, 1, 1, 1, 3, 1, 1, 3, 3, 3, 1, 1, 1, 1, 3, 1, 1, 1, 3,
3, 3, 3, 3, 3, 3, 3, 1, 1, 1 3, 3, 3, 3, 3, 3, 3, 3, 1, 1,
1
}; };
/* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM. /* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM.
@ -705,57 +709,57 @@ static const yytype_uint8 yydefact[] =
{ {
2, 40, 1, 0, 33, 34, 35, 36, 37, 38, 2, 40, 1, 0, 33, 34, 35, 36, 37, 38,
39, 0, 0, 18, 3, 6, 7, 8, 5, 0, 39, 0, 0, 18, 3, 6, 7, 8, 5, 0,
4, 44, 14, 13, 0, 9, 10, 11, 0, 43, 4, 44, 14, 13, 0, 71, 10, 72, 73, 55,
0, 0, 0, 15, 0, 46, 42, 45, 71, 72, 0, 68, 89, 74, 88, 90, 9, 11, 0, 43,
73, 55, 0, 68, 88, 74, 87, 89, 12, 31, 0, 0, 0, 0, 0, 53, 56, 76, 77, 78,
50, 0, 0, 53, 56, 76, 0, 77, 0, 0, 0, 0, 0, 66, 69, 15, 0, 46, 42, 45,
66, 69, 0, 0, 47, 0, 60, 61, 62, 63, 12, 60, 61, 62, 63, 64, 0, 0, 52, 54,
64, 0, 0, 52, 54, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 75,
0, 0, 0, 0, 75, 65, 67, 32, 19, 16, 65, 67, 31, 50, 0, 58, 57, 87, 85, 86,
48, 51, 41, 0, 58, 57, 86, 84, 85, 78, 79, 80, 81, 82, 83, 84, 70, 0, 0, 47,
79, 80, 81, 82, 83, 70, 23, 0, 0, 0, 0, 0, 32, 19, 16, 48, 51, 41, 0, 23,
0, 17, 0, 21, 24, 49, 0, 27, 26, 39, 0, 59, 0, 0, 17, 0, 21, 24, 49, 27,
0, 20, 22, 59, 0, 28, 25, 0, 30, 0, 26, 39, 0, 20, 22, 0, 28, 25, 0, 30,
29 0, 29
}; };
/* YYDEFGOTO[NTERM-NUM]. */ /* YYDEFGOTO[NTERM-NUM]. */
static const yytype_int8 yydefgoto[] = static const yytype_int8 yydefgoto[] =
{ {
-1, 1, 14, 15, 16, 17, 57, 18, 49, 19, -1, 1, 14, 15, 16, 17, 43, 18, 82, 19,
89, 106, 112, 113, 114, 63, 20, 21, 30, 31, 104, 109, 115, 116, 117, 98, 20, 21, 40, 41,
37, 91, 65, 44, 52, 53, 54, 72, 45, 59, 59, 106, 100, 32, 44, 45, 46, 67, 33, 52,
60, 46, 47, 58, 48 53, 34, 35, 51, 36
}; };
/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
STATE-NUM. */ STATE-NUM. */
#define YYPACT_NINF -43 #define YYPACT_NINF -30
static const yytype_int8 yypact[] = static const yytype_int8 yypact[] =
{ {
-43, 35, -43, 1, -43, -43, -43, -43, -43, -43, -30, 42, -30, 5, -30, -30, -30, -30, -30, -30,
-43, 20, -1, -43, -43, -43, -43, -43, -43, -16, -30, 0, -2, -30, -30, -30, -30, -30, -30, -15,
-43, -17, -43, -43, 18, -43, -43, -43, 1, -43, -30, -14, -30, -30, 9, -30, -30, -30, -30, 5,
1, 6, 0, -43, 28, -43, -43, -43, -43, -43, 11, 4, -30, -30, -30, -30, -30, -30, 5, -30,
-43, 1, 4, 0, -43, -43, -43, -43, -43, 9, 5, 23, 4, 12, -22, -6, -30, -30, -30, -30,
10, 5, -9, -6, -43, -43, 4, -43, 48, -7, 11, 51, -7, -1, -30, -30, 43, -30, -30, -30,
16, -43, 1, 24, 34, 27, -43, -43, -43, -43, -30, -30, -30, -30, -30, -30, 45, 4, -30, 5,
-43, 46, 0, -43, 1, 61, 4, 4, 4, 4, 62, 11, 11, 11, 11, 11, 11, 11, 11, -30,
4, 4, 4, 4, -43, -43, 0, -43, -43, -43, -30, 4, 24, 35, 25, -30, -30, -30, 89, 89,
-43, 30, -43, 43, -43, -43, -43, 88, 88, 92, 93, 93, 95, 95, 14, 55, -30, 5, 34, 75,
92, 55, 55, 7, 14, -43, -5, 57, 69, 70, 40, 22, -30, -30, -30, -30, 39, -30, 4, 2,
87, 116, 50, 59, -43, -43, 0, -43, -43, 73, 79, -30, 80, 81, 119, 52, 50, -30, -30, -30,
101, -43, -5, -43, 1, 24, -43, 74, -43, 114, -30, 59, 102, -30, 2, 5, 34, -30, 67, -30,
-43 117, -30
}; };
/* YYPGOTO[NTERM-NUM]. */ /* YYPGOTO[NTERM-NUM]. */
static const yytype_int8 yypgoto[] = static const yytype_int8 yypgoto[] =
{ {
-43, -43, -43, -43, -43, -43, -3, 8, -43, -43, -30, -30, -30, -30, -30, -30, -3, 7, -30, -30,
15, -43, -43, -43, -2, -43, -43, -43, -43, -43, 16, -30, -30, -30, 19, -30, -30, -30, -30, -30,
-43, -43, -43, 76, -43, -43, 65, 36, -43, -43, -30, -30, -30, 44, -30, -30, 76, 46, -30, -30,
-43, -43, -43, 32, -42 -30, -30, -30, 41, -29
}; };
/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
@ -764,46 +768,48 @@ static const yytype_int8 yypgoto[] =
#define YYTABLE_NINF -18 #define YYTABLE_NINF -18
static const yytype_int16 yytable[] = static const yytype_int16 yytable[] =
{ {
24, 61, 27, 38, 22, 39, 40, 22, 23, 55, 24, 37, 54, 25, 26, 27, 28, 25, 22, 27,
28, 23, 29, 66, 67, 68, 69, 70, 109, 110, 28, 38, 23, 60, 47, 39, 48, 42, 49, 68,
111, 76, 77, 25, 26, 33, 32, 34, 76, 77, 61, 62, 63, 64, 65, 112, 113, 114, 71, 72,
94, 50, 73, 35, 36, 2, 74, 90, 51, 85, 61, 62, 63, 64, 65, 55, 69, 56, 85, 80,
41, 62, 64, 42, 105, 43, 83, 56, 3, 93, 29, 81, 2, 30, 29, 31, 83, 30, 84, 31,
71, 4, 5, 6, 7, 8, 9, 10, 86, 87, 57, 58, 96, 78, 50, 3, 97, 66, 4, 5,
115, -17, 76, 77, 88, 11, 12, 41, 13, 76, 6, 7, 8, 9, 10, 71, 72, 99, -17, 71,
77, 51, 107, 117, 123, 76, 77, 66, 67, 68, 72, 101, 11, 12, 103, 13, 71, 72, 105, 111,
69, 70, 78, 79, 80, 81, 82, 83, 75, 108, 29, 110, 118, 119, 120, 73, 74, 75, 76, 77,
118, 121, 84, 82, 83, 78, 79, 80, 81, 82, 78, 70, 124, 123, 102, 79, 73, 74, 75, 76,
83, 122, 76, 77, 125, 96, 76, 77, 97, 98, 77, 78, 125, 71, 72, 126, 87, 71, 72, 71,
99, 100, 101, 102, 103, 104, 124, 130, 129, 120, 72, 130, 88, 89, 90, 91, 92, 93, 94, 95,
126, 127, 78, 79, 80, 81, 82, 83, 80, 81, 131, 122, 128, 73, 74, 75, 76, 77, 78, 75,
82, 83, 4, 5, 6, 7, 8, 9, 119, 95, 76, 77, 78, 77, 78, 4, 5, 6, 7, 8,
128, 92, 0, 0, 116, 0, 0, 0, 0, 13 9, 121, 129, 127, 107, 86, 0, 108, 0, 0,
0, 0, 13
}; };
#define yypact_value_is_default(yystate) \ #define yypact_value_is_default(yystate) \
((yystate) == (-43)) ((yystate) == (-30))
#define yytable_value_is_error(yytable_value) \ #define yytable_value_is_error(yytable_value) \
YYID (0) YYID (0)
static const yytype_int8 yycheck[] = static const yytype_int8 yycheck[] =
{ {
3, 43, 3, 3, 3, 5, 6, 3, 7, 5, 3, 3, 31, 3, 4, 5, 6, 3, 3, 5,
26, 7, 29, 8, 9, 10, 11, 12, 23, 24, 6, 26, 7, 42, 3, 29, 5, 8, 7, 41,
25, 14, 15, 3, 4, 28, 8, 30, 14, 15, 8, 9, 10, 11, 12, 23, 24, 25, 14, 15,
72, 3, 41, 27, 28, 0, 42, 3, 41, 46, 8, 9, 10, 11, 12, 38, 42, 40, 67, 46,
40, 32, 32, 43, 86, 45, 39, 43, 13, 3, 40, 42, 0, 43, 40, 45, 3, 43, 3, 45,
45, 16, 17, 18, 19, 20, 21, 22, 42, 62, 27, 28, 81, 39, 43, 13, 32, 45, 16, 17,
3, 26, 14, 15, 40, 30, 31, 40, 33, 14, 18, 19, 20, 21, 22, 14, 15, 32, 26, 14,
15, 74, 42, 3, 116, 14, 15, 8, 9, 10, 15, 46, 30, 31, 40, 33, 14, 15, 3, 108,
11, 12, 34, 35, 36, 37, 38, 39, 56, 46, 40, 42, 3, 3, 3, 34, 35, 36, 37, 38,
3, 41, 44, 38, 39, 34, 35, 36, 37, 38, 39, 50, 42, 41, 97, 44, 34, 35, 36, 37,
39, 42, 14, 15, 3, 44, 14, 15, 76, 77, 38, 39, 43, 14, 15, 3, 44, 14, 15, 14,
78, 79, 80, 81, 82, 83, 43, 3, 44, 111, 15, 44, 71, 72, 73, 74, 75, 76, 77, 78,
122, 124, 34, 35, 36, 37, 38, 39, 36, 37, 3, 114, 125, 34, 35, 36, 37, 38, 39, 36,
38, 39, 16, 17, 18, 19, 20, 21, 22, 74, 37, 38, 39, 38, 39, 16, 17, 18, 19, 20,
125, 65, -1, -1, 108, -1, -1, -1, -1, 33 21, 22, 126, 124, 100, 69, -1, 101, -1, -1,
-1, -1, 33
}; };
/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
@ -812,18 +818,18 @@ static const yytype_uint8 yystos[] =
{ {
0, 48, 0, 13, 16, 17, 18, 19, 20, 21, 0, 48, 0, 13, 16, 17, 18, 19, 20, 21,
22, 30, 31, 33, 49, 50, 51, 52, 54, 56, 22, 30, 31, 33, 49, 50, 51, 52, 54, 56,
63, 64, 3, 7, 53, 3, 4, 3, 26, 29, 63, 64, 3, 7, 53, 3, 4, 5, 6, 40,
65, 66, 8, 53, 53, 27, 28, 67, 3, 5, 43, 45, 70, 75, 78, 79, 81, 3, 26, 29,
6, 40, 43, 45, 70, 75, 78, 79, 81, 55, 65, 66, 8, 53, 71, 72, 73, 3, 5, 7,
3, 53, 71, 72, 73, 5, 43, 53, 80, 76, 43, 80, 76, 77, 81, 53, 53, 27, 28, 67,
77, 81, 32, 62, 32, 69, 8, 9, 10, 11, 81, 8, 9, 10, 11, 12, 45, 74, 41, 42,
12, 45, 74, 41, 42, 80, 14, 15, 34, 35, 80, 14, 15, 34, 35, 36, 37, 38, 39, 44,
36, 37, 38, 39, 44, 46, 42, 53, 40, 57, 46, 42, 55, 3, 3, 81, 73, 44, 80, 80,
3, 68, 70, 3, 81, 73, 44, 80, 80, 80, 80, 80, 80, 80, 80, 80, 81, 32, 62, 32,
80, 80, 80, 80, 80, 81, 58, 42, 46, 23, 69, 46, 53, 40, 57, 3, 68, 70, 74, 58,
24, 25, 59, 60, 61, 3, 74, 3, 3, 22, 42, 81, 23, 24, 25, 59, 60, 61, 3, 3,
54, 41, 42, 81, 43, 3, 61, 53, 57, 44, 3, 22, 54, 41, 42, 43, 3, 61, 53, 57,
3 44, 3
}; };
#define yyerrok (yyerrstatus = 0) #define yyerrok (yyerrstatus = 0)
@ -1711,8 +1717,8 @@ yyreduce:
/* Line 1806 of yacc.c */ /* Line 1806 of yacc.c */
#line 160 "config_parser.yy" #line 160 "config_parser.yy"
{ {
context->HandleInclude((yyvsp[(2) - (2)].text), false, yylloc); context->HandleInclude(*(yyvsp[(2) - (2)].variant), false, yylloc);
free((yyvsp[(2) - (2)].text)); delete (yyvsp[(2) - (2)].variant);
} }
break; break;
@ -2251,7 +2257,7 @@ yyreduce:
/* Line 1806 of yacc.c */ /* Line 1806 of yacc.c */
#line 538 "config_parser.yy" #line 538 "config_parser.yy"
{ {
(yyval.num) = (yyvsp[(2) - (3)].num); (yyval.variant) = (yyvsp[(2) - (3)].variant);
} }
break; break;
@ -2260,17 +2266,17 @@ yyreduce:
/* Line 1806 of yacc.c */ /* Line 1806 of yacc.c */
#line 543 "config_parser.yy" #line 543 "config_parser.yy"
{ {
(yyval.num) = (yyvsp[(1) - (1)].num); (yyval.variant) = new Value((yyvsp[(1) - (1)].text));
free((yyvsp[(1) - (1)].text));
} }
break; break;
case 77: case 77:
/* Line 1806 of yacc.c */ /* Line 1806 of yacc.c */
#line 547 "config_parser.yy" #line 548 "config_parser.yy"
{ {
(yyval.num) = ScriptVariable::Get((yyvsp[(1) - (1)].text)); (yyval.variant) = new Value((yyvsp[(1) - (1)].num));
free((yyvsp[(1) - (1)].text));
} }
break; break;
@ -2279,105 +2285,118 @@ yyreduce:
/* Line 1806 of yacc.c */ /* Line 1806 of yacc.c */
#line 552 "config_parser.yy" #line 552 "config_parser.yy"
{ {
(yyval.num) = (yyvsp[(1) - (3)].num) + (yyvsp[(3) - (3)].num); (yyval.variant) = new Value(ScriptVariable::Get((yyvsp[(1) - (1)].text)));
free((yyvsp[(1) - (1)].text));
} }
break; break;
case 79: case 79:
/* Line 1806 of yacc.c */ /* Line 1806 of yacc.c */
#line 556 "config_parser.yy" #line 557 "config_parser.yy"
{ {
(yyval.num) = (yyvsp[(1) - (3)].num) - (yyvsp[(3) - (3)].num); if ((yyvsp[(1) - (3)].variant)->GetType() == ValueString || (yyvsp[(3) - (3)].variant)->GetType() == ValueString)
(yyval.variant) = new Value((String)*(yyvsp[(1) - (3)].variant) + (String)*(yyvsp[(3) - (3)].variant));
else
(yyval.variant) = new Value((double)*(yyvsp[(1) - (3)].variant) + (double)*(yyvsp[(3) - (3)].variant));
} }
break; break;
case 80: case 80:
/* Line 1806 of yacc.c */ /* Line 1806 of yacc.c */
#line 560 "config_parser.yy" #line 564 "config_parser.yy"
{ {
(yyval.num) = (yyvsp[(1) - (3)].num) * (yyvsp[(3) - (3)].num); (yyval.variant) = new Value((double)*(yyvsp[(1) - (3)].variant) - (double)*(yyvsp[(3) - (3)].variant));
} }
break; break;
case 81: case 81:
/* Line 1806 of yacc.c */ /* Line 1806 of yacc.c */
#line 564 "config_parser.yy" #line 568 "config_parser.yy"
{ {
(yyval.num) = (yyvsp[(1) - (3)].num) / (yyvsp[(3) - (3)].num); (yyval.variant) = new Value((double)*(yyvsp[(1) - (3)].variant) * (double)*(yyvsp[(3) - (3)].variant));
} }
break; break;
case 82: case 82:
/* Line 1806 of yacc.c */ /* Line 1806 of yacc.c */
#line 568 "config_parser.yy" #line 572 "config_parser.yy"
{ {
(yyval.num) = (long)(yyvsp[(1) - (3)].num) & (long)(yyvsp[(3) - (3)].num); (yyval.variant) = new Value((double)*(yyvsp[(1) - (3)].variant) / (double)*(yyvsp[(3) - (3)].variant));
} }
break; break;
case 83: case 83:
/* Line 1806 of yacc.c */ /* Line 1806 of yacc.c */
#line 572 "config_parser.yy" #line 576 "config_parser.yy"
{ {
(yyval.num) = (long)(yyvsp[(1) - (3)].num) | (long)(yyvsp[(3) - (3)].num); (yyval.variant) = new Value((long)*(yyvsp[(1) - (3)].variant) & (long)*(yyvsp[(3) - (3)].variant));
} }
break; break;
case 84: case 84:
/* Line 1806 of yacc.c */ /* Line 1806 of yacc.c */
#line 576 "config_parser.yy" #line 580 "config_parser.yy"
{ {
(yyval.num) = (long)(yyvsp[(1) - (3)].num) << (long)(yyvsp[(3) - (3)].num); (yyval.variant) = new Value((long)*(yyvsp[(1) - (3)].variant) | (long)*(yyvsp[(3) - (3)].variant));
} }
break; break;
case 85: case 85:
/* Line 1806 of yacc.c */ /* Line 1806 of yacc.c */
#line 580 "config_parser.yy" #line 584 "config_parser.yy"
{ {
(yyval.num) = (long)(yyvsp[(1) - (3)].num) >> (long)(yyvsp[(3) - (3)].num); (yyval.variant) = new Value((long)*(yyvsp[(1) - (3)].variant) << (long)*(yyvsp[(3) - (3)].variant));
} }
break; break;
case 86: case 86:
/* Line 1806 of yacc.c */ /* Line 1806 of yacc.c */
#line 584 "config_parser.yy" #line 588 "config_parser.yy"
{ {
(yyval.num) = (yyvsp[(2) - (3)].num); (yyval.variant) = new Value((long)*(yyvsp[(1) - (3)].variant) >> (long)*(yyvsp[(3) - (3)].variant));
} }
break; break;
case 88: case 87:
/* Line 1806 of yacc.c */ /* Line 1806 of yacc.c */
#line 591 "config_parser.yy" #line 592 "config_parser.yy"
{ {
ExpressionList::Ptr exprl = ExpressionList::Ptr((yyvsp[(1) - (1)].exprl)); (yyval.variant) = (yyvsp[(2) - (3)].variant);
(yyval.variant) = new Value(exprl);
} }
break; break;
case 89: case 89:
/* Line 1806 of yacc.c */ /* Line 1806 of yacc.c */
#line 596 "config_parser.yy" #line 599 "config_parser.yy"
{ {
(yyval.variant) = new Value((yyvsp[(1) - (1)].num)); ExpressionList::Ptr exprl = ExpressionList::Ptr((yyvsp[(1) - (1)].exprl));
(yyval.variant) = new Value(exprl);
}
break;
case 90:
/* Line 1806 of yacc.c */
#line 604 "config_parser.yy"
{
(yyval.variant) = (yyvsp[(1) - (1)].variant);
} }
break; break;
/* Line 1806 of yacc.c */ /* Line 1806 of yacc.c */
#line 2381 "../../../lib/config/config_parser.cc" #line 2400 "../../../lib/config/config_parser.cc"
default: break; default: break;
} }
/* User semantic actions sometimes alter yychar, and that requires /* User semantic actions sometimes alter yychar, and that requires
@ -2615,6 +2634,6 @@ yyreturn:
/* Line 2067 of yacc.c */ /* Line 2067 of yacc.c */
#line 600 "config_parser.yy" #line 608 "config_parser.yy"

View File

@ -110,8 +110,8 @@ using namespace icinga;
%type <num> partial_specifier %type <num> partial_specifier
%type <slist> object_inherits_list %type <slist> object_inherits_list
%type <slist> object_inherits_specifier %type <slist> object_inherits_specifier
%type <num> constterm %type <variant> constterm
%type <num> constexpression %type <variant> constexpression
%left '+' '-' %left '+' '-'
%left '*' '/' %left '*' '/'
%left '&' %left '&'
@ -156,10 +156,10 @@ statements: /* empty */
statement: object | type | include | library | variable statement: object | type | include | library | variable
; ;
include: T_INCLUDE T_STRING include: T_INCLUDE value
{ {
context->HandleInclude($2, false, yylloc); context->HandleInclude(*$2, false, yylloc);
free($2); delete $2;
} }
| T_INCLUDE T_STRING_ANGLE | T_INCLUDE T_STRING_ANGLE
{ {
@ -539,46 +539,54 @@ constterm: '(' constexpression ')'
$$ = $2; $$ = $2;
} }
constexpression: T_NUMBER constexpression: T_STRING
{ {
$$ = $1; $$ = new Value($1);
free($1);
} }
| identifier | T_NUMBER
{ {
$$ = ScriptVariable::Get($1); $$ = new Value($1);
}
| T_IDENTIFIER
{
$$ = new Value(ScriptVariable::Get($1));
free($1); free($1);
} }
| constexpression '+' constexpression | constexpression '+' constexpression
{ {
$$ = $1 + $3; if ($1->GetType() == ValueString || $3->GetType() == ValueString)
$$ = new Value((String)*$1 + (String)*$3);
else
$$ = new Value((double)*$1 + (double)*$3);
} }
| constexpression '-' constexpression | constexpression '-' constexpression
{ {
$$ = $1 - $3; $$ = new Value((double)*$1 - (double)*$3);
} }
| constexpression '*' constexpression | constexpression '*' constexpression
{ {
$$ = $1 * $3; $$ = new Value((double)*$1 * (double)*$3);
} }
| constexpression '/' constexpression | constexpression '/' constexpression
{ {
$$ = $1 / $3; $$ = new Value((double)*$1 / (double)*$3);
} }
| constexpression '&' constexpression | constexpression '&' constexpression
{ {
$$ = (long)$1 & (long)$3; $$ = new Value((long)*$1 & (long)*$3);
} }
| constexpression '|' constexpression | constexpression '|' constexpression
{ {
$$ = (long)$1 | (long)$3; $$ = new Value((long)*$1 | (long)*$3);
} }
| constexpression T_SHIFT_LEFT constexpression | constexpression T_SHIFT_LEFT constexpression
{ {
$$ = (long)$1 << (long)$3; $$ = new Value((long)*$1 << (long)*$3);
} }
| constexpression T_SHIFT_RIGHT constexpression | constexpression T_SHIFT_RIGHT constexpression
{ {
$$ = (long)$1 >> (long)$3; $$ = new Value((long)*$1 >> (long)*$3);
} }
| '(' constexpression ')' | '(' constexpression ')'
{ {
@ -594,7 +602,7 @@ value: simplevalue
} }
| constterm | constterm
{ {
$$ = new Value($1); $$ = $1;
} }
; ;
%% %%

View File

@ -99,7 +99,7 @@ void ConfigCompiler::HandleInclude(const String& include, bool search, const Deb
{ {
String path; String path;
if (search) if (search || (include.GetLength() > 0 && include[0] == '/'))
path = include; path = include;
else else
path = Utility::DirName(GetPath()) + "/" + include; path = Utility::DirName(GetPath()) + "/" + include;

View File

@ -618,7 +618,7 @@ void Service::ProcessCheckResult(const Dictionary::Ptr& cr, const String& author
" threshold: " + Convert::ToString(GetFlappingThreshold()) + " threshold: " + Convert::ToString(GetFlappingThreshold()) +
"% current: " + Convert::ToString(GetFlappingCurrent()) + "%."); "% current: " + Convert::ToString(GetFlappingCurrent()) + "%.");
OnNewCheckResult(GetSelf(), cr, authority); Utility::QueueAsyncCallback(bind(boost::ref(OnNewCheckResult), GetSelf(), cr, authority));
OnStateChanged(GetSelf()); OnStateChanged(GetSelf());
if (call_eventhandler) if (call_eventhandler)