MCPcopy Create free account
hub / github.com/BZFlag-Dev/bzflag / done

Method done

plugins/plugin_utils/plugin_HTTP.cpp:245–277  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

243std::map<int, PendingTokenTask*> pendingTokenTasks;
244
245void PendingTokenTask::done(const char* /*URL*/, void* inData, unsigned int size, bool complete) {
246 char* t = (char*)malloc(size + 1);
247 memcpy(t, inData, size);
248 t[size] = 0;
249 data += t;
250 free(t);
251
252 if (complete) {
253 // parse out the info
254
255 data = replace_all(data, std::string("\r\n"), "\n");
256 data = replace_all(data, std::string("\r"), "\n");
257
258 std::vector<std::string> lines = tokenize(data, std::string("\n"), 0, false);
259
260 groups.clear();
261
262 for (size_t i = 0; i < lines.size(); i++) {
263 std::string& line = lines[i];
264
265 if (line.size()) {
266 if (strstr(line.c_str(), "TOKGOOD") != NULL) {
267 groups = tokenize(line, std::string(":"), 0, false);
268
269 if (groups.size() > 1) { // yank the first 2 since that is the sign and the name
270 groups.erase(groups.begin(), groups.begin() + 1);
271 }
272 }
273 }
274 }
275 pendingTokenTasks[requestID] = this;
276 }
277}
278
279void PendingTokenTask::timeout(const char* /*URL*/, int /*errorCode*/) {
280 groups.clear();

Callers

nothing calls this directly

Calls 6

c_strMethod · 0.80
replace_allFunction · 0.70
tokenizeFunction · 0.70
clearMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected