LOLWUT [VERSION ] [... version specific arguments ...] */
| 52 | |
| 53 | /* LOLWUT [VERSION <version>] [... version specific arguments ...] */ |
| 54 | void 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. |
nothing calls this directly
no test coverage detected