The LOLWUT command: * * LOLWUT [terminal columns] [squares-per-row] [squares-per-col] * * By default the command uses 66 columns, 8 squares per row, 12 squares * per column. */
| 138 | * per column. |
| 139 | */ |
| 140 | void lolwut5Command(client *c) { |
| 141 | long cols = 66; |
| 142 | long squares_per_row = 8; |
| 143 | long squares_per_col = 12; |
| 144 | |
| 145 | /* Parse the optional arguments if any. */ |
| 146 | if (c->argc > 1 && |
| 147 | getLongFromObjectOrReply(c,c->argv[1],&cols,NULL) != C_OK) |
| 148 | return; |
| 149 | |
| 150 | if (c->argc > 2 && |
| 151 | getLongFromObjectOrReply(c,c->argv[2],&squares_per_row,NULL) != C_OK) |
| 152 | return; |
| 153 | |
| 154 | if (c->argc > 3 && |
| 155 | getLongFromObjectOrReply(c,c->argv[3],&squares_per_col,NULL) != C_OK) |
| 156 | return; |
| 157 | |
| 158 | /* Limits. We want LOLWUT to be always reasonably fast and cheap to execute |
| 159 | * so we have maximum number of columns, rows, and output resolution. */ |
| 160 | if (cols < 1) cols = 1; |
| 161 | if (cols > 1000) cols = 1000; |
| 162 | if (squares_per_row < 1) squares_per_row = 1; |
| 163 | if (squares_per_row > 200) squares_per_row = 200; |
| 164 | if (squares_per_col < 1) squares_per_col = 1; |
| 165 | if (squares_per_col > 200) squares_per_col = 200; |
| 166 | |
| 167 | /* Generate some computer art and reply. */ |
| 168 | lwCanvas *canvas = lwDrawSchotter(cols,squares_per_row,squares_per_col); |
| 169 | sds rendered = renderCanvas(canvas); |
| 170 | rendered = sdscat(rendered, |
| 171 | "\nGeorg Nees - schotter, plotter on paper, 1968. Redis ver. "); |
| 172 | rendered = sdscat(rendered,REDIS_VERSION); |
| 173 | rendered = sdscatlen(rendered,"\n",1); |
| 174 | addReplyVerbatim(c,rendered,sdslen(rendered),"txt"); |
| 175 | sdsfree(rendered); |
| 176 | lwFreeCanvas(canvas); |
| 177 | } |
no test coverage detected