64{
65 switch(request)
66 {
68 {
69 float i, j, f,
f2, f3, rpnpos;
70
72
74 {
78 }
79
80 if(argc >= 2)
81 {
84 for(rpnpos = 1; rpnpos < argc; ++rpnpos)
85 {
86 rpncmd =
argv(rpnpos);
88 if(rpncmd == "") {
91 }
else if(
substring(rpncmd, 0, 1) ==
"0") {
93 }
else if(f >= 2 &&
substring(rpncmd, 0, 1) ==
"+") {
95 }
else if(f >= 2 &&
substring(rpncmd, 0, 1) ==
"-") {
97 }
else if(f >= 2 &&
substring(rpncmd, 0, 1) ==
"/") {
99 } else if(rpncmd == "clear") {
101 } else if(rpncmd == "def" || rpncmd == "=") {
104
106 {
107 #ifdef MENUQC
109 #else
111 #endif
114 }
115 else
116 {
117 LOG_INFO(
"rpn: empty cvar name for 'def'");
119 }
120 } else if(rpncmd == "defs" || rpncmd == "@") {
121 s = "";
123 j = (i == 0);
124 while(
rpn_sp > 1 && (j || i > 0))
125 {
127 --i;
128 }
131 {
132 #ifdef MENUQC
134 #else
136 #endif
139 }
140 else
141 {
142 LOG_INFO(
"rpn: empty cvar name for 'defs'");
144 }
145 } else if(rpncmd == "load") {
147 } else if(rpncmd == "exch") {
152 } else if(rpncmd == "dup") {
154 } else if(rpncmd == "pop") {
156 } else if(rpncmd == "add" || rpncmd == "+") {
159 } else if(rpncmd == "sub" || rpncmd == "-") {
162 } else if(rpncmd == "mul" || rpncmd == "*") {
165 } else if(rpncmd == "div" || rpncmd == "/") {
168 } else if(rpncmd == "mod" || rpncmd == "%") {
172 } else if(rpncmd == "pow" || rpncmd == "**") {
175 } else if(rpncmd == "bitand" || rpncmd == "&") {
178 } else if(rpncmd == "bitor" || rpncmd == "|") {
181 } else if(rpncmd == "bitxor" || rpncmd == "^") {
184 } else if(rpncmd == "and" || rpncmd == "&&") {
187 } else if(rpncmd == "or" || rpncmd == "||") {
190 } else if(rpncmd == "xor" || rpncmd == "^^") {
193 } else if(rpncmd == "bitnot") {
195 } else if(rpncmd == "not") {
197 } else if(rpncmd == "abs") {
199 } else if(rpncmd == "sgn") {
201 if(f < 0)
203 else if(f > 0)
205 else
207 } else if(rpncmd == "neg" || rpncmd == "~") {
209 } else if(rpncmd == "floor" || rpncmd == "f") {
211 } else if(rpncmd == "ceil" || rpncmd == "c") {
213 } else if(rpncmd == "exp") {
215 } else if(rpncmd == "log") {
217 } else if(rpncmd == "sin") {
219 } else if(rpncmd == "cos") {
221 } else if(rpncmd == "max") {
225 } else if(rpncmd == "min") {
229 } else if(rpncmd == "bound") {
234 } else if(rpncmd == "when") {
238 if(f)
240 else
242 } else if(rpncmd == ">" || rpncmd == "gt") {
245 } else if(rpncmd == "<" || rpncmd == "lt") {
248 } else if(rpncmd == "==" || rpncmd == "eq") {
251 } else if(rpncmd == ">=" || rpncmd == "ge") {
254 } else if(rpncmd == "<=" || rpncmd == "le") {
257 } else if(rpncmd == "!=" || rpncmd == "ne") {
260 } else if(rpncmd == "rand") {
262 } else if(rpncmd == "crc16") {
264 } else if(rpncmd == "put") {
267 {
271 }
272 } else if(rpncmd == "get") {
276 } else if(rpncmd == "dbpush") {
279 {
283 if(!i)
285 }
286 } else if(rpncmd == "dbpop") {
288 if(i)
289 {
294 if(j >= i)
296 } else {
298 LOG_INFO(
"rpn: database underflow");
299 }
300 } else if(rpncmd == "dbget") {
301
303 if(i)
304 {
306 } else {
309 }
310 } else if(rpncmd == "dblen") {
312 } else if(rpncmd == "dbclr") {
317 } else if(rpncmd == "dbsave") {
321 } else if(rpncmd == "dbload") {
324 {
327 }
328 } else if(rpncmd == "dbins") {
331
332 {
335
336 if(i < 0)
337 {
338 i = 0;
340 }
341
343 for(--j; j >= i; --j)
344 {
347 );
348 }
350 }
351 } else if(rpncmd == "dbext") {
354 if(!j)
355 {
358 } else {
359 --j;
362 if(i == j)
363 {
365 } else {
366 while(i < j)
367 {
370 );
371 ++i;
372 }
373 }
374 }
375 } else if(rpncmd == "dbread") {
378 {
380 } else {
383 }
384 } else if(rpncmd == "dbat") {
386 } else if(rpncmd == "dbmov") {
391 {
392 if(i < 0 || i >= j)
393 {
394 LOG_INFO(
"rpn: database cursor out of bounds");
396 }
398 {
400 }
401 }
402 } else if(rpncmd == "dbgoto") {
405 if(!j)
406 {
408 LOG_INFO(
"rpn: empty database, cannot move cursor");
409 }
411 {
412 if(s == "end")
414 else if(s == "beg")
415 i = 0;
416 else
418
420 if(i < 0 || i >= j)
421 {
422 LOG_INFO(
"rpn: database cursor destination out of bounds");
424 }
426 {
428 }
429 }
430 } else if(rpncmd == "union") {
431
436
437
438
439 s = "";
440 for(i = 0; i < f; ++i)
442 for(i = f; i <
f2; ++i) {
443 for(j = 0; j < f; ++j)
445 goto skip_union;
448 }
453 } else if(rpncmd == "intersection") {
454
459
460
461
462 s = "";
463 for(i = 0; i < f; ++i) {
464 for(j = f; j <
f2; ++j)
466 {
468 break;
469 }
470 }
475 } else if(rpncmd == "difference") {
476
481
482
483
484 s = "";
485 for(i = 0; i < f; ++i) {
486 for(j = f; j <
f2; ++j)
488 goto skip_difference;
490LABEL(skip_difference)
491 }
496 } else if(rpncmd == "shuffle") {
497
500
501 for(i = 0; i < f - 1; ++i) {
502
503 s = "";
505 for(j = 0; j < i; ++j)
508 for(j = i; j < f; ++j)
512 }
513
518 } else if(rpncmd == "fexists_assert") {
521 {
523 {
524 LOG_INFO(
"rpn: ERROR: ", s,
" does not exist!");
526 }
527 }
528 } else if(rpncmd == "fexists") {
531 {
534 else
536 }
537 } else if(rpncmd == "localtime") {
539 } else if(rpncmd == "gmtime") {
541 } else if(rpncmd == "time") {
543 } else if(rpncmd == "digest") {
546 } else if(rpncmd == "sprintf1s") {
549 } else if(rpncmd == "eval") {
553 rpnpos = -1;
554 } else {
556 }
558 break;
559 }
561 {
563 LOG_INFO(
"rpn: still on stack: ", s);
564 }
565 }
566
567 return;
568 }
569
570 default:
572 {
575 LOG_HELP(
" x pop -----------------------------> : removes the top");
576 LOG_HELP(
" x dup -----------------------------> x x : duplicates the top");
577 LOG_HELP(
" x x exch --------------------------> x x : swap the top two");
578 LOG_HELP(
" /cvarname load --------------------> x : loads a cvar");
579 LOG_HELP(
" /cvarname x def -------------------> : writes to a cvar");
580 LOG_HELP(
" f f add|sub|mul|div|mod|pow -------> f : adds/... two numbers");
581 LOG_HELP(
" f f and|or|xor|bitand|bitor|bitxor > f : logical and bitwise operations");
582 LOG_HELP(
" f f eq|ne|gt|ge|lt|le|max|min -----> f : compares two numbers");
583 LOG_HELP(
" f neg|abs|sgn|rand|floor|ceil------> f : negates/... a number");
584 LOG_HELP(
" f not|bitnot ----------------------> f : logical and bitwise negation");
585 LOG_HELP(
" f exp|log|sin|cos -----------------> f : exponential function & Co.");
586 LOG_HELP(
" f f f bound -----------------------> f : bounds the middle number");
587 LOG_HELP(
" f1 f2 b when ----------------------> f : f1 if b, f2 otherwise");
588 LOG_HELP(
" s s union|intersection|difference -> s : set operations");
589 LOG_HELP(
" s shuffle -------------------------> s : randomly arrange elements");
590 LOG_HELP(
" /key /value put -------------------> : set a database key");
591 LOG_HELP(
" /key get --------------------------> x : get a database value");
592 LOG_HELP(
" x dbpush --------------------------> : pushes the top onto the database");
593 LOG_HELP(
" dbpop|dbget -----------------------> x : removes/reads DB's top");
594 LOG_HELP(
" dblen|dbat ------------------------> f : gets the DB's size/cursor pos");
595 LOG_HELP(
" dbclr -----------------------------> : clear the DB");
596 LOG_HELP(
" x dbsave|dbload--------------------> : save/load the DB to/from a file");
597 LOG_HELP(
" x dbins ---------------------------> : moves the top into the DB");
598 LOG_HELP(
" dbext|dbread ----------------------> x : extract/get from the DB's cursor");
599 LOG_HELP(
" f dbmov|dbgoto --------------------> : move or set the DB's cursor");
600 LOG_HELP(
" x localtime -----------------------> x : formats the current local time");
601 LOG_HELP(
" x gmtime --------------------------> x : formats the current UTC time");
602 LOG_HELP(
" time ------------------------------> f : seconds since VM start");
603 LOG_HELP(
" x /MD4 digest ---------------------> x : MD4 digest");
604 LOG_HELP(
" x /SHA256 digest ------------------> x : SHA256 digest");
605 LOG_HELP(
" x /formatstring sprintf1s ---------> x : sprintf with 1 string (pad, cut)");
606 LOG_HELP(
" x fexists -------------------------> f : checks if a file exists");
607 LOG_HELP(
" x eval ----------------------------> : does something eval");
611 LOG_HELP(
" x: string defined like this: /abc or \"/abc def\"");
612 LOG_HELP(
" s: string defined like x and containing a set of space-separated strings");
613 LOG_HELP(
" Unknown tokens insert their cvar value.");
614 return;
615 }
616 }
617}
const int CMD_REQUEST_COMMAND
const int CMD_REQUEST_USAGE
ERASEABLE bool fexists(string f)
#define GetProgramCommandPrefix()
ERASEABLE void db_close(int db)
ERASEABLE int db_load(string filename)
ERASEABLE int db_create()
ERASEABLE void db_save(int db, string filename)
ERASEABLE string db_get(int db, string key)
ERASEABLE void db_put(int db, string key, string value)
spree_inf s1 s2 s3loc s2 spree_inf s1 s2 s3loc s2 spree_inf s1 s2 s3loc s2 s1 s2loc s1 s2loc s1 s2loc s1 s2loc s1 s2loc s1 s2loc s1 s2 f1points f2
spree_inf s1 s2 s3loc s2 spree_inf s1 s2 s3loc s2 spree_inf s1 s2 s3loc s2 s1 s2loc s1 s2loc s1 s2loc s1 s2loc s1 s2loc s1 s2loc s1 s2 f1points s1 s2
strcat(_("^F4Countdown stopped!"), "\n^BG", _("Teams are too unbalanced."))