bool init_xmlsec(void) { if(!has_init) { init_lock_.lock(); has_init = true; init_lock_.unlock(); //Init libxml and libxslt libraries xmlInitParser(); //Init xmlsec library if(xmlSecInit() < 0) { std::cerr<<"XMLSec initialization failed"<<std::endl; goto err; } /* Load default crypto engine if we are supporting dynamic * loading for xmlsec-crypto libraries. Use the crypto library * name ("openssl", "nss", etc.) to load corresponding * xmlsec-crypto library. */ #ifdef XMLSEC_CRYPTO_DYNAMIC_LOADING if(xmlSecCryptoDLLoadLibrary(BAD_CAST XMLSEC_CRYPTO) < 0) { std::cerr<<"Unable to load default xmlsec-crypto library. Make sure" "that you have it installed and check shared libraries path" "(LD_LIBRARY_PATH) envornment variable."<<std::endl; goto err; } #endif /* XMLSEC_CRYPTO_DYNAMIC_LOADING */ // Init crypto library if(xmlSecCryptoAppInit(NULL) < 0) { std::cerr<<"crypto initialization failed"<<std::endl; goto err; } //Init xmlsec-crypto library if(xmlSecCryptoInit() < 0) { std::cerr<<"xmlsec-crypto initialization failed"<<std::endl; goto err; } return true; err: init_lock_.lock(); has_init = false; init_lock_.unlock(); return false; } return true; }
void ThreadSleep::Sleep(unsigned int milliseconds) { Glib::Mutex condMutex; Glib::Cond condition; condMutex.lock(); Glib::TimeVal wait_period(milliseconds/1000,milliseconds%1000); Glib::TimeVal abs_time; abs_time.assign_current_time(); abs_time.add(wait_period); condition.timed_wait(condMutex, abs_time); condMutex.unlock(); }
bool final_xmlsec(void) { if(has_init) { init_lock_.lock(); has_init = false; init_lock_.unlock(); //Shutdown xmlsec-crypto library xmlSecCryptoShutdown(); //Shutdown crypto library xmlSecCryptoAppShutdown(); //Shutdown xmlsec library xmlSecShutdown(); //Shutdown libxml xmlCleanupParser(); } return true; }