+ if (value == NULL)
+ return "";
+ else
+ return value;
+}
+
+STG_RESULT stgRequest(STG_CLIENT::TYPE type, const char* userName, const char* password, const STG_PAIR* pairs)
+{
+ STG_CLIENT* client = STG_CLIENT::get();
+ if (client == NULL) {
+ // TODO: log "Not configured"
+ return emptyResult();
+ }
+ try {
+ return toResult(client->request(type, toString(userName), toString(password), fromSTGPairs(pairs)));
+ } catch (const STG_CLIENT::Error& ex) {
+ // TODO: log error
+ return emptyResult();
+ }
+}
+
+}
+
+int stgInstantiateImpl(const char* address)
+{
+ if (STG_CLIENT::configure(toString(address)))
+ 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);
+}