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

Function lolwut6Command

app/redis-6.2.6/src/lolwut6.c:169–201  ·  view source on GitHub ↗

The LOLWUT 6 command: * * LOLWUT [columns] [rows] * * By default the command uses 80 columns, 40 squares per row * per column. */

Source from the content-addressed store, hash-verified

167 * per column.
168 */
169void lolwut6Command(client *c) {
170 long cols = 80;
171 long rows = 20;
172
173 /* Parse the optional arguments if any. */
174 if (c->argc > 1 &&
175 getLongFromObjectOrReply(c,c->argv[1],&cols,NULL) != C_OK)
176 return;
177
178 if (c->argc > 2 &&
179 getLongFromObjectOrReply(c,c->argv[2],&rows,NULL) != C_OK)
180 return;
181
182 /* Limits. We want LOLWUT to be always reasonably fast and cheap to execute
183 * so we have maximum number of columns, rows, and output resulution. */
184 if (cols < 1) cols = 1;
185 if (cols > 1000) cols = 1000;
186 if (rows < 1) rows = 1;
187 if (rows > 1000) rows = 1000;
188
189 /* Generate the city skyline and reply. */
190 lwCanvas *canvas = lwCreateCanvas(cols,rows,3);
191 generateSkyline(canvas);
192 sds rendered = renderCanvas(canvas);
193 rendered = sdscat(rendered,
194 "\nDedicated to the 8 bit game developers of past and present.\n"
195 "Original 8 bit image from Plaguemon by hikikomori. Redis ver. ");
196 rendered = sdscat(rendered,REDIS_VERSION);
197 rendered = sdscatlen(rendered,"\n",1);
198 addReplyVerbatim(c,rendered,sdslen(rendered),"txt");
199 sdsfree(rendered);
200 lwFreeCanvas(canvas);
201}

Callers 1

lolwutCommandFunction · 0.85

Calls 10

getLongFromObjectOrReplyFunction · 0.85
lwCreateCanvasFunction · 0.85
generateSkylineFunction · 0.85
sdscatFunction · 0.85
sdscatlenFunction · 0.85
addReplyVerbatimFunction · 0.85
sdslenFunction · 0.85
sdsfreeFunction · 0.85
lwFreeCanvasFunction · 0.85
renderCanvasFunction · 0.70

Tested by

no test coverage detected