3 #include "stg_client.h"
8 STG_PAIR* toPairs(const PAIRS& source)
10 STG_PAIR * pairs = new STG_PAIR[source.size() + 1];
11 for (size_t pos = 0; pos < source.size(); ++pos) {
12 bzero(pairs[pos].key, sizeof(STG_PAIR::key));
13 bzero(pairs[pos].value, sizeof(STG_PAIR::value));
14 strncpy(pairs[pos].key, source[pos].first.c_str(), sizeof(STG_PAIR::key));
15 strncpy(pairs[pos].value, source[pos].second.c_str(), sizeof(STG_PAIR::value));
18 bzero(pairs[sources.size()].key, sizeof(STG_PAIR::key));
19 bzero(pairs[sources.size()].value, sizeof(STG_PAIR::value));
26 int stgInstantiateImpl(const char* server, uint16_t port, const char* password)
28 if (STG_CLIENT::configure(server, port, password))
34 const STG_PAIR* stgAuthorizeImpl(const char* userName, const char* serviceType)
36 STG_CLIENT* client = STG_CLIENT::get();
38 // TODO: log "Not configured"
41 return toPairs(client->authorize(userName, serviceType));
44 const STG_PAIR* stgAuthenticateImpl(const char* userName, const char* serviceType)
46 STG_CLIENT* client = STG_CLIENT::get();
48 // TODO: log "Not configured"
51 return toPairs(client->authenticate(userName, serviceType));
54 const STG_PAIR* stgPostAuthImpl(const char* userName, const char* serviceType)
56 STG_CLIENT* client = STG_CLIENT::get();
58 // TODO: log "Not configured"
61 return toPairs(client->postAuth(userName, serviceType));
64 const STG_PAIR* stgPreAcctImpl(const char* userName, const char* serviceType)
66 STG_CLIENT* client = STG_CLIENT::get();
68 // TODO: log "Not configured"
71 return toPairs(client->preAcct(userName, serviceType));
74 const STG_PAIR* stgAccountingImpl(const char* userName, const char* serviceType, const char* statusType, const char* sessionId)
76 STG_CLIENT* client = STG_CLIENT::get();
78 // TODO: log "Not configured"
81 return toPairs(client->account(userName, serviceType, statusType, sessionId));
84 int countValuePairs(const VALUE_PAIR* pairs)
87 while (pairs != NULL) {
94 STG_PAIR* fromValuePairs(const VALUE_PAIR* pairs)
96 unsigned size = countValuePairs(pairs);
97 STG_PAIR* res = new STG_PAIR[size + 1];
99 while (pairs != NULL) {
100 bzero(res[pos].key, sizeof(STG_PAIR::key));
101 bzero(res[pos].value, sizeof(STG_PAIR::value));
102 strncpy(res[pos].key, pairs->name, sizeof(STG_PAIR::key));
103 strncpy(res[pos].value, pairs->data.strvalue, sizeof(STG_PAIR::value));
107 bzero(res[pos].key, sizeof(STG_PAIR::key));
108 bzero(res[pos].value, sizeof(STG_PAIR::value));
112 void deletePairs(const STG_PAIR* pairs)