+ STG_CLIENT* client = STG_CLIENT::get();
+ if (client == NULL) {
+ RadLog("Client is not configured.");
+ return emptyResult();
+ }
+ try {
+ response.done = false;
+ client->request(type, toString(userName), toString(password), fromSTGPairs(pairs));
+ pthread_mutex_lock(&response.mutex);
+ while (!response.done)
+ pthread_cond_wait(&response.cond, &response.mutex);
+ pthread_mutex_unlock(&response.mutex);
+ if (!response.status)
+ return emptyResult();
+ return toResult(response.result);
+ } catch (const STG_CLIENT::Error& ex) {
+ RadLog("Error: '%s'.", ex.what());
+ return emptyResult();
+ }
+}
+
+}
+
+int stgInstantiateImpl(const char* address)
+{
+ pthread_mutex_init(&response.mutex, NULL);
+ pthread_cond_init(&response.cond, NULL);
+ response.done = false;
+
+ if (STG_CLIENT::configure(toString(address), &Response::callback, &response))
+ return 1;
+
+ return 0;
+}
+
+STG_RESULT stgAuthorizeImpl(const char* userName, const char* password, const STG_PAIR* pairs)
+{
+ return stgRequest(STG_CLIENT::AUTHORIZE, userName, password, pairs);
+}
+
+STG_RESULT stgAuthenticateImpl(const char* userName, const char* password, const STG_PAIR* pairs)
+{
+ return stgRequest(STG_CLIENT::AUTHENTICATE, userName, password, pairs);
+}
+
+STG_RESULT stgPostAuthImpl(const char* userName, const char* password, const STG_PAIR* pairs)
+{
+ return stgRequest(STG_CLIENT::POST_AUTH, userName, password, pairs);
+}