]> git.saurik.com Git - redis.git/blobdiff - redis-cli.c
minor fix for a Linux warning
[redis.git] / redis-cli.c
index 7559d00e248423057df67f0eb4c66ae5c0d906c6..58c17613e283f2ab5e4eb896ca6107515b63994f 100644 (file)
@@ -1,6 +1,6 @@
 /* Redis CLI (command line interface)
  *
- * Copyright (c) 2006-2009, Salvatore Sanfilippo <antirez at gmail dot com>
+ * Copyright (c) 2009-2010, Salvatore Sanfilippo <antirez at gmail dot com>
  * 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);