icinga2/base/utility.h

55 lines
951 B
C
Raw Normal View History

2012-04-22 16:45:31 +02:00
#ifndef UTILITY_H
#define UTILITY_H
namespace icinga
{
/**
* Utility
*
* Utility functions.
*/
class I2_BASE_API Utility
{
private:
2012-04-24 14:02:15 +02:00
static bool m_SSLInitialized;
2012-04-22 16:45:31 +02:00
Utility(void);
2012-04-24 14:02:15 +02:00
static void InitializeOpenSSL(void);
2012-04-22 16:45:31 +02:00
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);
2012-04-24 14:02:15 +02:00
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);
2012-04-22 16:45:31 +02:00
};
}
#endif /* UTILITY_H */