using namespace ldp_cynara;
-pthread_mutex_t Cynara::__mutex = PTHREAD_MUTEX_INITIALIZER;
-
-Cynara::Cynara() : __inited(false) {
-}
-
-Cynara::~Cynara() {
- int r = cynara_finish(__cynara);
- if (r != CYNARA_API_SUCCESS) {
- //TODO: reaction
- //destructor is usually called when proccess is closed
- //there is no good way to serve this case.
- }
-}
-
bool Cynara::init() {
if (!__inited) {
int r = cynara_initialize(&__cynara, NULL);
return true;
}
-Cynara& Cynara::getInstance() {
- static Cynara __self;
- return __self;
-}
+static pthread_mutex_t __mutex = PTHREAD_MUTEX_INITIALIZER;
+static Cynara c;
CynaraResult Cynara::check(const char* label, const char* privilege, const char* uid) {
const char* _label = "";
if (uid)
_uid = uid;
pthread_mutex_lock(&__mutex);
- Cynara& c = Cynara::getInstance();
if (!c.init()) {
ret = CynaraResult::ERROR_INIT;
} else {
};
class Cynara {
private:
- static pthread_mutex_t __mutex;
cynara* __cynara;
const char* __session;
- bool __inited;
- Cynara();
- ~Cynara();
+ bool __inited = false;
bool init();
- static Cynara& getInstance();
public:
static CynaraResult check(const char* label, const char* privilege, const char* uid);
using namespace ldp_cynara;
-Cynara::Cynara() {
-}
-
-Cynara::~Cynara() {
-}
-
-bool Cynara::init() {
- return true;
-}
-
-Cynara& Cynara::getInstance() {
- static Cynara __self;
- return __self;
-}
-
-
CynaraResult Cynara::check(const char* label, const char* privilege, const char* uid) {
(void)label;
(void)privilege;