Send AUTH command to the server */
| 787 | |
| 788 | /* Send AUTH command to the server */ |
| 789 | static int cliAuth(redisContext *ctx, char *user, char *auth) { |
| 790 | redisReply *reply; |
| 791 | if (auth == NULL) return REDIS_OK; |
| 792 | |
| 793 | if (user == NULL) |
| 794 | reply = redisCommand(ctx,"AUTH %s",auth); |
| 795 | else |
| 796 | reply = redisCommand(ctx,"AUTH %s %s",user,auth); |
| 797 | |
| 798 | if (reply == NULL) { |
| 799 | fprintf(stderr, "\nI/O error\n"); |
| 800 | return REDIS_ERR; |
| 801 | } |
| 802 | |
| 803 | int result = REDIS_OK; |
| 804 | if (reply->type == REDIS_REPLY_ERROR) { |
| 805 | result = REDIS_ERR; |
| 806 | fprintf(stderr, "AUTH failed: %s\n", reply->str); |
| 807 | } |
| 808 | freeReplyObject(reply); |
| 809 | return result; |
| 810 | } |
| 811 | |
| 812 | /* Send SELECT input_dbnum to the server */ |
| 813 | static int cliSelect(void) { |
no test coverage detected