mirror of https://github.com/Icinga/icinga2.git
55 lines
951 B
C++
55 lines
951 B
C++
#ifndef UTILITY_H
|
|
#define UTILITY_H
|
|
|
|
namespace icinga
|
|
{
|
|
|
|
/**
|
|
* Utility
|
|
*
|
|
* Utility functions.
|
|
*/
|
|
class I2_BASE_API Utility
|
|
{
|
|
private:
|
|
static bool m_SSLInitialized;
|
|
|
|
Utility(void);
|
|
|
|
static void InitializeOpenSSL(void);
|
|
|
|
public:
|
|
/**
|
|
* GetTypeName
|
|
*
|
|
* Returns the type name of an object (using RTTI).
|
|
*/
|
|
template<class T>
|
|
static string GetTypeName(const T& value)
|
|
{
|
|
string klass = typeid(value).name();
|
|
|
|
#ifdef HAVE_GCC_ABI_DEMANGLE
|
|
int status;
|
|
char *realname = abi::__cxa_demangle(klass.c_str(), 0, 0, &status);
|
|
|
|
if (realname != NULL) {
|
|
klass = string(realname);
|
|
free(realname);
|
|
}
|
|
#endif /* HAVE_GCC_ABI_DEMANGLE */
|
|
|
|
return klass;
|
|
}
|
|
|
|
static void Daemonize(void);
|
|
|
|
static shared_ptr<SSL_CTX> MakeSSLContext(string pubkey, string privkey, string cakey);
|
|
static string GetCertificateCN(const shared_ptr<X509>& certificate);
|
|
static shared_ptr<X509> GetX509Certificate(string pemfile);
|
|
};
|
|
|
|
}
|
|
|
|
#endif /* UTILITY_H */
|