MCPcopy Create free account
hub / github.com/F-Stack/f-stack / lolwutCommand

Function lolwutCommand

app/redis-6.2.6/src/lolwut.c:54–85  ·  view source on GitHub ↗

LOLWUT [VERSION ] [... version specific arguments ...] */

Source from the content-addressed store, hash-verified

52
53/* LOLWUT [VERSION <version>] [... version specific arguments ...] */
54void lolwutCommand(client *c) {
55 char *v = REDIS_VERSION;
56 char verstr[64];
57
58 if (c->argc >= 3 && !strcasecmp(c->argv[1]->ptr,"version")) {
59 long ver;
60 if (getLongFromObjectOrReply(c,c->argv[2],&ver,NULL) != C_OK) return;
61 snprintf(verstr,sizeof(verstr),"%u.0.0",(unsigned int)ver);
62 v = verstr;
63
64 /* Adjust argv/argc to filter the "VERSION ..." option, since the
65 * specific LOLWUT version implementations don't know about it
66 * and expect their arguments. */
67 c->argv += 2;
68 c->argc -= 2;
69 }
70
71 if ((v[0] == '5' && v[1] == '.' && v[2] != '9') ||
72 (v[0] == '4' && v[1] == '.' && v[2] == '9'))
73 lolwut5Command(c);
74 else if ((v[0] == '6' && v[1] == '.' && v[2] != '9') ||
75 (v[0] == '5' && v[1] == '.' && v[2] == '9'))
76 lolwut6Command(c);
77 else
78 lolwutUnstableCommand(c);
79
80 /* Fix back argc/argv in case of VERSION argument. */
81 if (v == verstr) {
82 c->argv -= 2;
83 c->argc += 2;
84 }
85}
86
87/* ========================== LOLWUT Canvase ===============================
88 * Many LOLWUT versions will likely print some computer art to the screen.

Callers

nothing calls this directly

Calls 6

strcasecmpFunction · 0.85
getLongFromObjectOrReplyFunction · 0.85
snprintfFunction · 0.85
lolwut5CommandFunction · 0.85
lolwut6CommandFunction · 0.85
lolwutUnstableCommandFunction · 0.85

Tested by

no test coverage detected