Send AUTH command to the server */
| 594 | |
| 595 | /* Send AUTH command to the server */ |
| 596 | static int cliAuth(redisContext *ctx, char *user, char *auth) { |
| 597 | redisReply *reply; |
| 598 | if (auth == NULL) return REDIS_OK; |
| 599 | |
| 600 | if (user == NULL) |
| 601 | reply = redisCommand(ctx,"AUTH %s",auth); |
| 602 | else |
| 603 | reply = redisCommand(ctx,"AUTH %s %s",user,auth); |
| 604 | |
| 605 | if (reply == NULL) { |
| 606 | fprintf(stderr, "\nI/O error\n"); |
| 607 | return REDIS_ERR; |
| 608 | } |
| 609 | |
| 610 | int result = REDIS_OK; |
| 611 | if (reply->type == REDIS_REPLY_ERROR) { |
| 612 | result = REDIS_ERR; |
| 613 | fprintf(stderr, "AUTH failed: %s\n", reply->str); |
| 614 | } |
| 615 | freeReplyObject(reply); |
| 616 | return result; |
| 617 | } |
| 618 | |
| 619 | /* Send SELECT input_dbnum to the server */ |
| 620 | static int cliSelect(void) { |
no test coverage detected