2011-09-13 17:50:18 +03:00
|
|
|
#ifndef _misc__hpp__included__
|
|
|
|
#define _misc__hpp__included__
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
2011-11-06 14:41:41 +02:00
|
|
|
#include <stdexcept>
|
2012-10-13 12:48:37 +03:00
|
|
|
#include "library/string.hpp"
|
2011-09-13 17:50:18 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Fatal error.
|
2011-09-15 22:56:33 +03:00
|
|
|
*
|
2011-09-17 01:05:41 +03:00
|
|
|
* Fatal error.
|
2011-09-13 17:50:18 +03:00
|
|
|
*/
|
2011-09-17 01:05:41 +03:00
|
|
|
void fatal_error() throw();
|
2011-09-13 17:50:18 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Get path to config directory.
|
2011-09-15 22:56:33 +03:00
|
|
|
*
|
2011-09-13 17:50:18 +03:00
|
|
|
* \return The config directory path.
|
|
|
|
* \throw std::bad_alloc Not enough memory.
|
|
|
|
*/
|
2011-09-17 01:05:41 +03:00
|
|
|
std::string get_config_path() throw(std::bad_alloc);
|
2011-09-13 17:50:18 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Panic on OOM.
|
|
|
|
*/
|
2011-09-17 01:05:41 +03:00
|
|
|
void OOM_panic();
|
2011-09-13 17:50:18 +03:00
|
|
|
|
|
|
|
|
2011-10-20 17:42:29 +03:00
|
|
|
uint32_t gcd(uint32_t a, uint32_t b) throw();
|
|
|
|
|
2012-01-06 17:28:01 +02:00
|
|
|
/**
|
|
|
|
* Return hexadecimal representation of address
|
|
|
|
*/
|
|
|
|
std::string format_address(void* addr);
|
|
|
|
|
2012-01-11 01:21:13 +02:00
|
|
|
/**
|
|
|
|
* Get state of running global ctors flag.
|
|
|
|
*/
|
|
|
|
bool in_global_ctors();
|
|
|
|
/**
|
|
|
|
* Clear the global ctors flag.
|
|
|
|
*/
|
|
|
|
void reached_main();
|
|
|
|
|
2013-02-09 18:35:13 +02:00
|
|
|
/**
|
|
|
|
* Clean up filename from dangerous chars
|
|
|
|
*/
|
|
|
|
std::string safe_filename(const std::string& str);
|
|
|
|
|
2013-06-26 14:48:19 +03:00
|
|
|
/**
|
|
|
|
* Mangle some characters ()|/
|
|
|
|
*/
|
|
|
|
std::string mangle_name(const std::string& orig);
|
|
|
|
|
2013-11-11 01:49:06 +02:00
|
|
|
/**
|
|
|
|
* Return a new temporary file. The file will be created.
|
|
|
|
*/
|
|
|
|
std::string get_temp_file();
|
|
|
|
|
2011-09-13 17:50:18 +03:00
|
|
|
#endif
|