X-Git-Url: https://git.saurik.com/redis.git/blobdiff_plain/a9158272c69ff283fbedf68dd3cb4855e69159fc..54bac49d92bcf02e9896e658ff5e72cc0adbd35d:/redis-cli.c diff --git a/redis-cli.c b/redis-cli.c index 7559d00e..58c17613 100644 --- a/redis-cli.c +++ b/redis-cli.c @@ -1,6 +1,6 @@ /* Redis CLI (command line interface) * - * Copyright (c) 2006-2009, Salvatore Sanfilippo + * Copyright (c) 2009-2010, Salvatore Sanfilippo * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -63,6 +63,7 @@ static struct redisCommand cmdTable[] = { {"get",2,REDIS_CMD_INLINE}, {"set",3,REDIS_CMD_BULK}, {"setnx",3,REDIS_CMD_BULK}, + {"append",3,REDIS_CMD_BULK}, {"del",-2,REDIS_CMD_INLINE}, {"exists",2,REDIS_CMD_INLINE}, {"incr",2,REDIS_CMD_INLINE}, @@ -100,6 +101,7 @@ static struct redisCommand cmdTable[] = { {"zremrangebyscore",4,REDIS_CMD_INLINE}, {"zrange",-4,REDIS_CMD_INLINE}, {"zrangebyscore",-4,REDIS_CMD_INLINE}, + {"zcount",4,REDIS_CMD_INLINE}, {"zrevrange",-4,REDIS_CMD_INLINE}, {"zcard",2,REDIS_CMD_INLINE}, {"zscore",3,REDIS_CMD_BULK}, @@ -134,6 +136,7 @@ static struct redisCommand cmdTable[] = { {"debug",-2,REDIS_CMD_INLINE}, {"mset",-3,REDIS_CMD_MULTIBULK}, {"msetnx",-3,REDIS_CMD_MULTIBULK}, + {"monitor",1,REDIS_CMD_INLINE}, {NULL,0,0} }; @@ -188,6 +191,7 @@ static int cliReadSingleLineReply(int fd, int quiet) { if (reply == NULL) return 1; if (!quiet) printf("%s\n", reply); + sdsfree(reply); return 0; } @@ -287,6 +291,7 @@ static int selectDb(int fd) static int cliSendCommand(int argc, char **argv) { struct redisCommand *rc = lookupCommand(argv[0]); int fd, j, retval = 0; + int read_forever = 0; sds cmd; if (!rc) { @@ -299,6 +304,7 @@ static int cliSendCommand(int argc, char **argv) { fprintf(stderr,"Wrong number of arguments for '%s'\n",rc->name); return 1; } + if (!strcasecmp(rc->name,"monitor")) read_forever = 1; if ((fd = cliConnect()) == -1) return 1; /* Select db number */ @@ -337,6 +343,11 @@ static int cliSendCommand(int argc, char **argv) { } anetWrite(fd,cmd,sdslen(cmd)); sdsfree(cmd); + + while (read_forever) { + cliReadSingleLineReply(fd,0); + } + retval = cliReadReply(fd); if (retval) { close(fd);