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 if (s != "") {
149 } else {
150 LOG_INFO(
"rpn: empty cvar name for 'load'");
152 }
153 } else if(rpncmd == "exch") {
158 } else if(rpncmd == "dup") {
160 } else if(rpncmd == "pop") {
162 } else if(rpncmd == "add" || rpncmd == "+") {
165 } else if(rpncmd == "sub" || rpncmd == "-") {
168 } else if(rpncmd == "mul" || rpncmd == "*") {
171 } else if(rpncmd == "div" || rpncmd == "/") {
174 } else if(rpncmd == "mod" || rpncmd == "%") {
178 } else if(rpncmd == "pow" || rpncmd == "**") {
181 } else if(rpncmd == "bitand" || rpncmd == "&") {
184 } else if(rpncmd == "bitor" || rpncmd == "|") {
187 } else if(rpncmd == "bitxor" || rpncmd == "^") {
190 } else if(rpncmd == "and" || rpncmd == "&&") {
193 } else if(rpncmd == "or" || rpncmd == "||") {
196 } else if(rpncmd == "xor" || rpncmd == "^^") {
199 } else if(rpncmd == "bitnot") {
201 } else if(rpncmd == "not") {
203 } else if(rpncmd == "abs") {
205 } else if(rpncmd == "sgn") {
207 if(f < 0)
209 else if(f > 0)
211 else
213 } else if(rpncmd == "neg" || rpncmd == "~") {
215 } else if(rpncmd == "floor" || rpncmd == "f") {
217 } else if(rpncmd == "ceil" || rpncmd == "c") {
219 } else if(rpncmd == "exp") {
221 } else if(rpncmd == "log") {
223 } else if(rpncmd == "sin") {
225 } else if(rpncmd == "cos") {
227 } else if(rpncmd == "max") {
231 } else if(rpncmd == "min") {
235 } else if(rpncmd == "bound") {
240 } else if(rpncmd == "when") {
244 if(f)
246 else
248 } else if(rpncmd == ">" || rpncmd == "gt") {
251 } else if(rpncmd == "<" || rpncmd == "lt") {
254 } else if(rpncmd == "==" || rpncmd == "eq") {
257 } else if(rpncmd == ">=" || rpncmd == "ge") {
260 } else if(rpncmd == "<=" || rpncmd == "le") {
263 } else if(rpncmd == "!=" || rpncmd == "ne") {
266 } else if(rpncmd == "rand") {
268 } else if(rpncmd == "crc16") {
270 } else if(rpncmd == "put") {
273 {
277 }
278 } else if(rpncmd == "get") {
282 } else if(rpncmd == "dbpush") {
285 {
289 if(!i)
291 }
292 } else if(rpncmd == "dbpop") {
294 if(i)
295 {
300 if(j >= i)
302 } else {
304 LOG_INFO(
"rpn: database underflow");
305 }
306 } else if(rpncmd == "dbget") {
307
309 if(i)
310 {
312 } else {
315 }
316 } else if(rpncmd == "dblen") {
318 } else if(rpncmd == "dbclr") {
323 } else if(rpncmd == "dbsave") {
327 } else if(rpncmd == "dbload") {
330 {
333 }
334 } else if(rpncmd == "dbins") {
337
338 {
341
342 if(i < 0)
343 {
344 i = 0;
346 }
347
349 for(--j; j >= i; --j)
350 {
353 );
354 }
356 }
357 } else if(rpncmd == "dbext") {
360 if(!j)
361 {
364 } else {
365 --j;
368 if(i == j)
369 {
371 } else {
372 while(i < j)
373 {
376 );
377 ++i;
378 }
379 }
380 }
381 } else if(rpncmd == "dbread") {
384 {
386 } else {
389 }
390 } else if(rpncmd == "dbat") {
392 } else if(rpncmd == "dbmov") {
397 {
398 if(i < 0 || i >= j)
399 {
400 LOG_INFO(
"rpn: database cursor out of bounds");
402 }
404 {
406 }
407 }
408 } else if(rpncmd == "dbgoto") {
411 if(!j)
412 {
414 LOG_INFO(
"rpn: empty database, cannot move cursor");
415 }
417 {
418 if(s == "end")
420 else if(s == "beg")
421 i = 0;
422 else
424
426 if(i < 0 || i >= j)
427 {
428 LOG_INFO(
"rpn: database cursor destination out of bounds");
430 }
432 {
434 }
435 }
436 } else if(rpncmd == "union") {
437
442
443
444
445 s = "";
446 for(i = 0; i < f; ++i)
448 for(i = f; i <
f2; ++i) {
449 for(j = 0; j < f; ++j)
451 goto skip_union;
454 }
459 } else if(rpncmd == "intersection") {
460
465
466
467
468 s = "";
469 for(i = 0; i < f; ++i) {
470 for(j = f; j <
f2; ++j)
472 {
474 break;
475 }
476 }
481 } else if(rpncmd == "difference") {
482
487
488
489
490 s = "";
491 for(i = 0; i < f; ++i) {
492 for(j = f; j <
f2; ++j)
494 goto skip_difference;
496LABEL(skip_difference)
497 }
502 } else if(rpncmd == "shuffle") {
503
506
507 for(i = 0; i < f - 1; ++i) {
508
509 s = "";
511 for(j = 0; j < i; ++j)
514 for(j = i; j < f; ++j)
518 }
519
524 } else if(rpncmd == "fexists_assert") {
527 {
529 {
530 LOG_INFO(
"rpn: ERROR: ", s,
" does not exist!");
532 }
533 }
534 } else if(rpncmd == "fexists") {
537 {
540 else
542 }
543 } else if(rpncmd == "localtime") {
545 } else if(rpncmd == "gmtime") {
547 } else if(rpncmd == "time") {
549 } else if(rpncmd == "digest") {
552 } else if(rpncmd == "sprintf1s") {
555 } else if(rpncmd == "eval") {
559 rpnpos = -1;
560 } else {
562 }
564 break;
565 }
567 {
569 LOG_INFO(
"rpn: still on stack: ", s);
570 }
571 }
572
573 return;
574 }
575
576 default:
578 {
581 LOG_HELP(
" x pop -----------------------------> : removes the top");
582 LOG_HELP(
" x dup -----------------------------> x x : duplicates the top");
583 LOG_HELP(
" x x exch --------------------------> x x : swap the top two");
584 LOG_HELP(
" /cvarname load --------------------> x : loads a cvar");
585 LOG_HELP(
" /cvarname x def -------------------> : writes to a cvar");
586 LOG_HELP(
" f f add|sub|mul|div|mod|pow -------> f : adds/... two numbers");
587 LOG_HELP(
" f f and|or|xor|bitand|bitor|bitxor > f : logical and bitwise operations");
588 LOG_HELP(
" f f eq|ne|gt|ge|lt|le|max|min -----> f : compares two numbers");
589 LOG_HELP(
" f neg|abs|sgn|rand|floor|ceil------> f : negates/... a number");
590 LOG_HELP(
" f not|bitnot ----------------------> f : logical and bitwise negation");
591 LOG_HELP(
" f exp|log|sin|cos -----------------> f : exponential function & Co.");
592 LOG_HELP(
" f f f bound -----------------------> f : bounds the middle number");
593 LOG_HELP(
" f1 f2 b when ----------------------> f : f1 if b, f2 otherwise");
594 LOG_HELP(
" s s union|intersection|difference -> s : set operations");
595 LOG_HELP(
" s shuffle -------------------------> s : randomly arrange elements");
596 LOG_HELP(
" /key /value put -------------------> : set a database key");
597 LOG_HELP(
" /key get --------------------------> x : get a database value");
598 LOG_HELP(
" x dbpush --------------------------> : pushes the top onto the database");
599 LOG_HELP(
" dbpop|dbget -----------------------> x : removes/reads DB's top");
600 LOG_HELP(
" dblen|dbat ------------------------> f : gets the DB's size/cursor pos");
601 LOG_HELP(
" dbclr -----------------------------> : clear the DB");
602 LOG_HELP(
" x dbsave|dbload--------------------> : save/load the DB to/from a file");
603 LOG_HELP(
" x dbins ---------------------------> : moves the top into the DB");
604 LOG_HELP(
" dbext|dbread ----------------------> x : extract/get from the DB's cursor");
605 LOG_HELP(
" f dbmov|dbgoto --------------------> : move or set the DB's cursor");
606 LOG_HELP(
" x localtime -----------------------> x : formats the current local time");
607 LOG_HELP(
" x gmtime --------------------------> x : formats the current UTC time");
608 LOG_HELP(
" time ------------------------------> f : seconds since VM start");
609 LOG_HELP(
" x /MD4 digest ---------------------> x : MD4 digest");
610 LOG_HELP(
" x /SHA256 digest ------------------> x : SHA256 digest");
611 LOG_HELP(
" x /formatstring sprintf1s ---------> x : sprintf with 1 string (pad, cut)");
612 LOG_HELP(
" x fexists -------------------------> f : checks if a file exists");
613 LOG_HELP(
" x eval ----------------------------> : does something eval");
617 LOG_HELP(
" x: string defined like this: /abc or \"/abc def\"");
618 LOG_HELP(
" s: string defined like x and containing a set of space-separated strings");
619 LOG_HELP(
" Unknown tokens insert their cvar value.");
620 return;
621 }
622 }
623}
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."))