MCPcopy Create free account
hub / github.com/acl-dev/acl / parse_respond

Method parse_respond

lib_acl_cpp/src/hsocket/hsproto.cpp:221–283  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

219static const char* dummy_ok = "ok";
220
221bool hsproto::parse_respond(int nfld, string& buf,
222 int& errnum, const char*& serror)
223{
224 serror = dummy_ok;
225
226 if (buf.empty()) {
227 errnum = HS_ERR_EMPTY;
228 logger_error("respond empty");
229 return false;
230 }
231
232 buf_ptr_ = buf.c_str();
233 char *last = buf_ptr_, *save = NULL;
234 while (*buf_ptr_) {
235 if (*buf_ptr_ == '\t') {
236 save = buf_ptr_;
237 *buf_ptr_++ = 0;
238 break;
239 }
240 buf_ptr_++;
241 }
242 errnum = atoi(last);
243 if (*buf_ptr_ == 0) {
244 if (save) {
245 *save = '\t';
246 }
247 errnum = HS_ERR_INVALID_REPLY;
248 logger_error("respond(%s) invalid", buf.c_str());
249 return false;
250 }
251
252 last = buf_ptr_;
253 save = NULL;
254 while (*buf_ptr_) {
255 if (*buf_ptr_ == '\t') {
256 save = buf_ptr_;
257 *buf_ptr_++ = 0;
258 break;
259 }
260 buf_ptr_++;
261 }
262
263 ntoken_ = atoi(last);
264 if (ntoken_ <= 0) {
265 if (errnum != 0) {
266 errnum = HS_ERR_INVALID_REPLY;
267 logger_error("ntoken(%d) invalid", ntoken_);
268 return false;
269 }
270 return false;
271 }
272
273 if (ntoken_ > nfld) {
274 ntoken_ = nfld;
275 }
276
277 if (errnum == 0) {
278 return true;

Callers 2

open_tblMethod · 0.80
queryMethod · 0.80

Calls 2

emptyMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected