mirror of
https://github.com/fluencelabs/redis
synced 2025-03-19 09:00:51 +00:00
LOLWUT: wrap it into a proper command.
This commit is contained in:
parent
eac2a79cf5
commit
43385c4375
@ -144,7 +144,7 @@ endif
|
|||||||
|
|
||||||
REDIS_SERVER_NAME=redis-server
|
REDIS_SERVER_NAME=redis-server
|
||||||
REDIS_SENTINEL_NAME=redis-sentinel
|
REDIS_SENTINEL_NAME=redis-sentinel
|
||||||
REDIS_SERVER_OBJ=adlist.o quicklist.o ae.o anet.o dict.o server.o sds.o zmalloc.o lzf_c.o lzf_d.o pqsort.o zipmap.o sha1.o ziplist.o release.o networking.o util.o object.o db.o replication.o rdb.o t_string.o t_list.o t_set.o t_zset.o t_hash.o config.o aof.o pubsub.o multi.o debug.o sort.o intset.o syncio.o cluster.o crc16.o endianconv.o slowlog.o scripting.o bio.o rio.o rand.o memtest.o crc64.o bitops.o sentinel.o notify.o setproctitle.o blocked.o hyperloglog.o latency.o sparkline.o redis-check-rdb.o redis-check-aof.o geo.o lazyfree.o module.o evict.o expire.o geohash.o geohash_helper.o childinfo.o defrag.o siphash.o rax.o t_stream.o listpack.o localtime.o
|
REDIS_SERVER_OBJ=adlist.o quicklist.o ae.o anet.o dict.o server.o sds.o zmalloc.o lzf_c.o lzf_d.o pqsort.o zipmap.o sha1.o ziplist.o release.o networking.o util.o object.o db.o replication.o rdb.o t_string.o t_list.o t_set.o t_zset.o t_hash.o config.o aof.o pubsub.o multi.o debug.o sort.o intset.o syncio.o cluster.o crc16.o endianconv.o slowlog.o scripting.o bio.o rio.o rand.o memtest.o crc64.o bitops.o sentinel.o notify.o setproctitle.o blocked.o hyperloglog.o latency.o sparkline.o redis-check-rdb.o redis-check-aof.o geo.o lazyfree.o module.o evict.o expire.o geohash.o geohash_helper.o childinfo.o defrag.o siphash.o rax.o t_stream.o listpack.o localtime.o lolwut.o
|
||||||
REDIS_CLI_NAME=redis-cli
|
REDIS_CLI_NAME=redis-cli
|
||||||
REDIS_CLI_OBJ=anet.o adlist.o dict.o redis-cli.o zmalloc.o release.o anet.o ae.o crc64.o siphash.o crc16.o
|
REDIS_CLI_OBJ=anet.o adlist.o dict.o redis-cli.o zmalloc.o release.o anet.o ae.o crc64.o siphash.o crc16.o
|
||||||
REDIS_BENCHMARK_NAME=redis-benchmark
|
REDIS_BENCHMARK_NAME=redis-benchmark
|
||||||
|
49
src/lolwut.c
49
src/lolwut.c
@ -236,17 +236,40 @@ sds lwRenderCanvas(lwCanvas *canvas) {
|
|||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(void) {
|
/* The LOLWUT command:
|
||||||
#if 0
|
*
|
||||||
lwCanvas *c = lwCreateCanvas(80,80);
|
* LOLWUT [terminal columns] [squares-per-row] [squares-per-col]
|
||||||
for (int i = 0; i < 40; i++) {
|
*
|
||||||
lwDrawPixel(c,i,i,1);
|
* By default the command uses 80 columns, 6 squares per row, 10 squares
|
||||||
}
|
* per column.
|
||||||
lwDrawLine(c,10,10,60,30,1);
|
*/
|
||||||
lwDrawSquare(c,40,40,40,0.5);
|
void lolwutCommand(client *c) {
|
||||||
lwDrawSquare(c,50,40,10,1);
|
long cols = 80;
|
||||||
#endif
|
long squares_per_row = 6;
|
||||||
lwCanvas *c = lwDrawSchotter(80,6,10);
|
long squares_per_col = 10;
|
||||||
sds rendered = lwRenderCanvas(c);
|
|
||||||
printf("%s\n", rendered);
|
/* Parse the optional arguments if any. */
|
||||||
|
if (c->argc > 1 &&
|
||||||
|
getLongFromObjectOrReply(c,c->argv[1],&cols,NULL) != C_OK)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (c->argc > 2 &&
|
||||||
|
getLongFromObjectOrReply(c,c->argv[2],&squares_per_row,NULL) != C_OK)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (c->argc > 3 &&
|
||||||
|
getLongFromObjectOrReply(c,c->argv[3],&squares_per_col,NULL) != C_OK)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (cols < 1) cols = 1;
|
||||||
|
if (squares_per_row < 1) squares_per_row = 1;
|
||||||
|
if (squares_per_col < 1) squares_per_col = 1;
|
||||||
|
|
||||||
|
/* Generate some computer art and reply. */
|
||||||
|
lwCanvas *canvas = lwDrawSchotter(cols,squares_per_row,squares_per_col);
|
||||||
|
sds rendered = lwRenderCanvas(canvas);
|
||||||
|
rendered = sdscat(rendered,
|
||||||
|
"\nGeorg Ness - Schotter, Plotter on paper, 1968.\n");
|
||||||
|
addReplyBulkSds(c,rendered);
|
||||||
|
lwFreeCanvas(canvas);
|
||||||
}
|
}
|
||||||
|
@ -322,7 +322,8 @@ struct redisCommand redisCommandTable[] = {
|
|||||||
{"xtrim",xtrimCommand,-2,"wF",0,NULL,1,1,1,0,0},
|
{"xtrim",xtrimCommand,-2,"wF",0,NULL,1,1,1,0,0},
|
||||||
{"post",securityWarningCommand,-1,"lt",0,NULL,0,0,0,0,0},
|
{"post",securityWarningCommand,-1,"lt",0,NULL,0,0,0,0,0},
|
||||||
{"host:",securityWarningCommand,-1,"lt",0,NULL,0,0,0,0,0},
|
{"host:",securityWarningCommand,-1,"lt",0,NULL,0,0,0,0,0},
|
||||||
{"latency",latencyCommand,-2,"aslt",0,NULL,0,0,0,0,0}
|
{"latency",latencyCommand,-2,"aslt",0,NULL,0,0,0,0,0},
|
||||||
|
{"lolwut",lolwutCommand,-1,"r",0,NULL,0,0,0,0,0}
|
||||||
};
|
};
|
||||||
|
|
||||||
/*============================ Utility functions ============================ */
|
/*============================ Utility functions ============================ */
|
||||||
|
@ -2109,6 +2109,7 @@ void xclaimCommand(client *c);
|
|||||||
void xinfoCommand(client *c);
|
void xinfoCommand(client *c);
|
||||||
void xdelCommand(client *c);
|
void xdelCommand(client *c);
|
||||||
void xtrimCommand(client *c);
|
void xtrimCommand(client *c);
|
||||||
|
void lolwutCommand(client *c);
|
||||||
|
|
||||||
#if defined(__GNUC__)
|
#if defined(__GNUC__)
|
||||||
void *calloc(size_t count, size_t size) __attribute__ ((deprecated));
|
void *calloc(size_t count, size_t size) __attribute__ ((deprecated));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user