| 284 | } |
| 285 | |
| 286 | int redis_pubsub::check_channel(const redis_result* obj, const char* cmd, |
| 287 | const char* channel) |
| 288 | { |
| 289 | if (obj->get_type() != REDIS_RESULT_ARRAY) { |
| 290 | return -1; |
| 291 | } |
| 292 | |
| 293 | const redis_result* rr = obj->get_child(0); |
| 294 | if (rr == NULL || rr->get_type() != REDIS_RESULT_STRING) { |
| 295 | return -1; |
| 296 | } |
| 297 | |
| 298 | string buf; |
| 299 | rr->argv_to_string(buf); |
| 300 | if (strcasecmp(buf.c_str(), cmd) != 0) { |
| 301 | acl::string tmp; |
| 302 | obj->to_string(tmp); |
| 303 | logger_warn("invalid cmd=%s, %s, result=%s", |
| 304 | buf.c_str(), cmd, tmp.c_str()); |
| 305 | return -1; |
| 306 | } |
| 307 | |
| 308 | rr = obj->get_child(1); |
| 309 | if (rr == NULL || rr->get_type() != REDIS_RESULT_STRING) { |
| 310 | return -1; |
| 311 | } |
| 312 | |
| 313 | buf.clear(); |
| 314 | rr->argv_to_string(buf); |
| 315 | if (strcasecmp(buf.c_str(), channel) != 0) { |
| 316 | acl::string tmp; |
| 317 | obj->to_string(tmp); |
| 318 | logger_warn("invalid channel=%s, %s, result=%s", |
| 319 | buf.c_str(), channel, tmp.c_str()); |
| 320 | return -1; |
| 321 | } |
| 322 | |
| 323 | rr = obj->get_child(2); |
| 324 | if (rr == NULL || rr->get_type() != REDIS_RESULT_INTEGER) { |
| 325 | return -1; |
| 326 | } |
| 327 | |
| 328 | return rr->get_integer(); |
| 329 | } |
| 330 | |
| 331 | bool redis_pubsub::get_message(string& channel, string& msg, |
| 332 | string* message_type /* = NULL */, string* pattern /* = NULL */, |
nothing calls this directly
no test coverage detected