1 /*************************************************************************
2 * Copyright (C) 2023 Francesco Palumbo <phranz@subfc.net>, Naples (Italy)
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 *************************************************************************/
28 map_strint_t
* commands
;
32 static char* elements
[E_END
];
33 static char* attrs
[ATTR_END
];
34 static elementdata_t composition
[E_END
];
35 static map_strint_t
* eids
;
36 static map_strint_t
* cids
;
37 static map_strint_t
* aids
;
39 int sid(int e
, char* g
) {
44 if (composition
[e
].sigs
->get(composition
[e
].sigs
, g
, &s
))
49 int eid(const char* n
) {
53 for (int i
=E_ALL
+1; i
<E_END
; ++i
) {
56 if (eq(elements
[i
], n
))
62 int cidbe(int e
, char* s
) {
63 if (!composition
[e
].commands
)
67 if (composition
[e
].commands
->get(composition
[e
].commands
, s
, &c
))
72 int cid(const char* n
) {
76 if (cids
->get(cids
, (char*)n
, &c
))
82 int aid(const char* n
) {
86 if (aids
->get(aids
, (char*)n
, &a
))
92 const char* ename(int e
) {
93 if (!e
|| e
== E_ALL
|| !elements
[e
])
99 int sidbe(int e
, char* t
) {
100 if (!composition
[E_ALL
].sigs
|| !t
)
104 if (composition
[E_ALL
].sigs
->get(composition
[E_ALL
].sigs
, t
, &g
))
107 if (!composition
[e
].sigs
)
110 if (composition
[e
].sigs
->get(composition
[e
].sigs
, t
, &g
))
117 char* commands
[CMD_END
];
118 static char* funcs
[F_END
];
119 static char* sigs
[SIG_END
];
120 static int cmdargs
[CMD_END
];
121 static int funcargs
[F_END
];
123 static map_strint_t
* kids
;
125 static map_strint_t
* sids
; // used just for general signals
126 static map_strint_t
* fids
;
130 if (sids
->get(sids
, s
, &g
))
135 int kid(const char* n
) {
139 if (kids
->get(kids
, (char*)n
, &k
))
145 int fid(const char* n
) {
149 if (fids
->get(fids
, (char*)n
, &f
))
162 const char* fname(int e
) {
163 if (!e
|| e
== F_END
)
171 for (int i
=E_ALL
; i
<E_END
; ++i
) {
172 release(composition
[i
].commands
);
173 release(composition
[i
].sigs
);
185 /* [NOTE FOR FUNCS AND COMMANDS] number of arguments:
188 * -X = at least (X-1) args, and variable
189 * X = there must be X args
196 elements
[E_BUTTON
] = "b";
197 elements
[E_INPUT
] = "i";
198 elements
[E_PAGE
] = "p";
199 elements
[E_LABEL
] = "l";
200 elements
[E_CHECKBOX
] = "c";
201 elements
[E_TRANS
] = "t";
204 funcs
[F_EXISTS
] = "exists"; funcargs
[F_EXISTS
] = 1;
220 attrs
[ATTR_TL
] = "T";
222 attrs
[ATTR_PID
] = "pid";
224 aids
= alloc(map_strint_t
);
227 for (e
=ATTR_NONE
+1; e
<ATTR_END
; ++e
)
228 aids
->insert(aids
, attrs
[e
], e
);
231 commands
[CMD_DELETE
] = "del"; cmdargs
[CMD_DELETE
] = 1;
232 commands
[CMD_RELATE
] = "rel"; cmdargs
[CMD_RELATE
] = 3;
233 commands
[CMD_WIDS
] = "ls"; cmdargs
[CMD_WIDS
] = -1;
234 #ifdef ENABLE_CONTROL
235 commands
[CMD_SENDKEYS
] = "send"; cmdargs
[CMD_SENDKEYS
] = 2;
236 commands
[CMD_SENDCONTROLKEYS
] = "ctrl"; cmdargs
[CMD_SENDCONTROLKEYS
] = 2;
239 commands
[CMD_TRAY
] = "T"; cmdargs
[CMD_TRAY
] = 0;
240 commands
[CMD_GHOST
] = "G"; cmdargs
[CMD_GHOST
] = 0;
241 commands
[CMD_FULLSCREEN
] = "F"; cmdargs
[CMD_FULLSCREEN
] = 0;
242 commands
[CMD_SETDEFAULT
] = "d"; cmdargs
[CMD_SETDEFAULT
] = 0;
243 commands
[CMD_BYPASSWM
] = "!"; cmdargs
[CMD_BYPASSWM
] = 0;
244 commands
[CMD_FOLLOWWM
] = "!!"; cmdargs
[CMD_FOLLOWWM
] = 0;
245 commands
[CMD_CENTER
] = "n"; cmdargs
[CMD_CENTER
] = 0;
246 commands
[CMD_HIDE
] = "-"; cmdargs
[CMD_HIDE
] = 0;
247 commands
[CMD_SHOW
] = "+"; cmdargs
[CMD_SHOW
] = 0;
248 commands
[CMD_DRAW
] = "/"; cmdargs
[CMD_DRAW
] = -1;
249 commands
[CMD_FOCUS
] = "f"; cmdargs
[CMD_FOCUS
] = 0;
250 commands
[CMD_TOP
] = "t"; cmdargs
[CMD_TOP
] = 0;
251 commands
[CMD_BOTTOM
] = "b"; cmdargs
[CMD_BOTTOM
] = 0;
252 commands
[CMD_CLOSE
] = "x"; cmdargs
[CMD_CLOSE
] = 0;
253 commands
[CMD_CLICK
] = "c"; cmdargs
[CMD_CLICK
] = 0;
254 commands
[CMD_LOWER
] = "l"; cmdargs
[CMD_LOWER
] = 0;
255 commands
[CMD_RAISE
] = "r"; cmdargs
[CMD_RAISE
] = 0;
256 commands
[CMD_MAXIMIZE
] = "M"; cmdargs
[CMD_MAXIMIZE
] = 0;
257 commands
[CMD_FREEZE
] = "D"; cmdargs
[CMD_FREEZE
] = 0;
258 commands
[CMD_UNFREEZE
] = "E"; cmdargs
[CMD_UNFREEZE
] = 0;
259 commands
[CMD_FIT
] = "o"; cmdargs
[CMD_FIT
] = 0;
260 commands
[CMD_FILL
] = "w"; cmdargs
[CMD_FILL
] = 0;
261 commands
[CMD_FILLNOLIMIT
] = "nfill"; cmdargs
[CMD_FILLNOLIMIT
] = 0;
262 commands
[CMD_FILLRIGHT
] = "rfill"; cmdargs
[CMD_FILLRIGHT
] = 0;
263 commands
[CMD_FILLRIGHTNOLIMIT
] = "nrfill"; cmdargs
[CMD_FILLRIGHTNOLIMIT
] = 0;
264 commands
[CMD_FILLBOTTOM
] = "bfill"; cmdargs
[CMD_FILLBOTTOM
] = 0;
265 commands
[CMD_FILLBOTTOMNOLIMIT
] = "nbfill"; cmdargs
[CMD_FILLBOTTOMNOLIMIT
] = 0;
266 commands
[CMD_CLEAR
] = "L"; cmdargs
[CMD_CLEAR
] = 0;
267 commands
[CMD_ENTITLE
] = ":"; cmdargs
[CMD_ENTITLE
] = 1;
268 commands
[CMD_STYLE
] = "s"; cmdargs
[CMD_STYLE
] = 1;
269 commands
[CMD_RESIZE
] = "z"; cmdargs
[CMD_RESIZE
] = 2;
270 commands
[CMD_MOVE
] = "m"; cmdargs
[CMD_MOVE
] = 2;
271 commands
[CMD_TXMOVABLE
] = "X"; cmdargs
[CMD_TXMOVABLE
] = 0;
272 commands
[CMD_TYMOVABLE
] = "Y"; cmdargs
[CMD_TYMOVABLE
] = 0;
273 commands
[CMD_MOVEALIGN
] = "A"; cmdargs
[CMD_MOVEALIGN
] = 2;
274 // common to some elements
275 commands
[CMD_SETTEXT
] = "<"; cmdargs
[CMD_SETTEXT
] = 1;
276 commands
[CMD_ADDTEXT
] = "<+"; cmdargs
[CMD_ADDTEXT
] = 1;
277 commands
[CMD_DEFTEXT
] = ">"; cmdargs
[CMD_DEFTEXT
] = 1;
278 commands
[CMD_TGRIP
] = "g"; cmdargs
[CMD_TGRIP
] = 0;
280 commands
[CMD_CHECK
] = "C"; cmdargs
[CMD_CHECK
] = 0;
281 commands
[CMD_UNCHECK
] = "U"; cmdargs
[CMD_UNCHECK
] = 0;
283 commands
[CMD_SHOWINPUT
] = "S"; cmdargs
[CMD_SHOWINPUT
] = 0;
284 commands
[CMD_HIDEINPUT
] = "H"; cmdargs
[CMD_HIDEINPUT
] = 0;
285 commands
[CMD_PASSWORD
] = "P"; cmdargs
[CMD_PASSWORD
] = 0;
286 commands
[CMD_TRET
] = "W"; cmdargs
[CMD_TRET
] = 0;
288 commands
[CMD_EQUALIZE
] = "Q"; cmdargs
[CMD_EQUALIZE
] = 0;
289 commands
[CMD_STYLESUBS
] = "S"; cmdargs
[CMD_STYLESUBS
] = 1;
290 commands
[CMD_EXPLODE
] = "P"; cmdargs
[CMD_EXPLODE
] = 0;
291 commands
[CMD_EMBED
] = "<<"; cmdargs
[CMD_EMBED
] = 1;
292 commands
[CMD_FITEMBED
] = "<<<"; cmdargs
[CMD_FITEMBED
] = 1;
293 commands
[CMD_UNTIE
] = ">>"; cmdargs
[CMD_UNTIE
] = 1;
294 commands
[CMD_FITUNTIE
] = ">>>"; cmdargs
[CMD_FITUNTIE
] = 1;
295 commands
[CMD_VERTICAL
] = "v"; cmdargs
[CMD_VERTICAL
] = 0;
296 commands
[CMD_HORIZONTAL
] = "h"; cmdargs
[CMD_HORIZONTAL
] = 0;
297 commands
[CMD_SWAP
] = "Z"; cmdargs
[CMD_SWAP
] = 2;
298 commands
[CMD_INVERT
] = "N"; cmdargs
[CMD_INVERT
] = 0;
301 sigs
[SIG_ENTER
] = "e";
302 sigs
[SIG_LEAVE
] = "l";
303 sigs
[SIG_FOCUS
] = "f";
304 sigs
[SIG_UNFOCUS
] = "u";
305 sigs
[SIG_CLOSED
] = "x";
306 sigs
[SIG_CLICKED
] = "c";
307 sigs
[SIG_LCLICKED
] = "lc";
308 sigs
[SIG_RCLICKED
] = "rc";
309 sigs
[SIG_MCLICKED
] = "mc";
310 sigs
[SIG_DCLICKED
] = "cc";
311 sigs
[SIG_LDCLICKED
] = "lcc";
312 sigs
[SIG_RDCLICKED
] = "rcc";
313 sigs
[SIG_MDCLICKED
] = "mcc";
314 sigs
[SIG_PRESSED
] = "p";
315 sigs
[SIG_LPRESSED
] = "lp";
316 sigs
[SIG_RPRESSED
] = "rp";
317 sigs
[SIG_MPRESSED
] = "mp";
318 sigs
[SIG_RELEASED
] = "r";
319 sigs
[SIG_LRELEASED
] = "lr";
320 sigs
[SIG_RRELEASED
] = "rr";
321 sigs
[SIG_MRELEASED
] = "mr";
322 sigs
[SIG_SCROLLUP
] = "S";
323 sigs
[SIG_SCROLLDOWN
] = "s";
324 sigs
[SIG_MOVED
] = "m";
325 sigs
[SIG_RESIZED
] = "z";
326 sigs
[SIG_UNCHECKED
] = "U";
327 sigs
[SIG_CHECKED
] = "C";
328 sigs
[SIG_RETURNPRESSED
] = "R";
330 eids
= alloc(map_strint_t
);
331 cids
= alloc(map_strint_t
);
337 for (e
=EIDS_START
; e
<EIDS_END
; ++e
)
338 eids
->insert(eids
, elements
[e
], e
);
341 for (e
=CIDS_START
; e
<CIDS_END
; ++e
)
342 cids
->insert(cids
, commands
[e
], e
);
344 if (cids
->full(cids
))
348 map_strint_t
* cs
= alloc(map_strint_t
);
349 map_strint_t
* ss
= alloc(map_strint_t
);
353 cs
->insert(cs
, commands
[CMD_TRAY
], CMD_TRAY
);
354 cs
->insert(cs
, commands
[CMD_GHOST
], CMD_GHOST
);
355 cs
->insert(cs
, commands
[CMD_CENTER
], CMD_CENTER
);
356 cs
->insert(cs
, commands
[CMD_HIDE
], CMD_HIDE
);
357 cs
->insert(cs
, commands
[CMD_SHOW
], CMD_SHOW
);
358 cs
->insert(cs
, commands
[CMD_DRAW
], CMD_DRAW
);
359 cs
->insert(cs
, commands
[CMD_FOCUS
], CMD_FOCUS
);
360 cs
->insert(cs
, commands
[CMD_TOP
], CMD_TOP
);
361 cs
->insert(cs
, commands
[CMD_BOTTOM
], CMD_BOTTOM
);
362 cs
->insert(cs
, commands
[CMD_CLOSE
], CMD_CLOSE
);
363 cs
->insert(cs
, commands
[CMD_CLICK
], CMD_CLICK
);
364 cs
->insert(cs
, commands
[CMD_DELETE
], CMD_DELETE
);
365 cs
->insert(cs
, commands
[CMD_LOWER
], CMD_LOWER
);
366 cs
->insert(cs
, commands
[CMD_RAISE
], CMD_RAISE
);
367 cs
->insert(cs
, commands
[CMD_MAXIMIZE
], CMD_MAXIMIZE
);
368 cs
->insert(cs
, commands
[CMD_FREEZE
], CMD_FREEZE
);
369 cs
->insert(cs
, commands
[CMD_UNFREEZE
], CMD_UNFREEZE
);
370 cs
->insert(cs
, commands
[CMD_FIT
], CMD_FIT
);
371 cs
->insert(cs
, commands
[CMD_FILL
], CMD_FILL
);
372 cs
->insert(cs
, commands
[CMD_FILLNOLIMIT
], CMD_FILLNOLIMIT
);
373 cs
->insert(cs
, commands
[CMD_FILLRIGHT
], CMD_FILLRIGHT
);
374 cs
->insert(cs
, commands
[CMD_FILLRIGHTNOLIMIT
], CMD_FILLRIGHTNOLIMIT
);
375 cs
->insert(cs
, commands
[CMD_FILLBOTTOM
], CMD_FILLBOTTOM
);
376 cs
->insert(cs
, commands
[CMD_FILLBOTTOMNOLIMIT
], CMD_FILLBOTTOMNOLIMIT
);
377 cs
->insert(cs
, commands
[CMD_CLEAR
], CMD_CLEAR
);
378 cs
->insert(cs
, commands
[CMD_ENTITLE
], CMD_ENTITLE
);
379 cs
->insert(cs
, commands
[CMD_STYLE
], CMD_STYLE
);
380 cs
->insert(cs
, commands
[CMD_RESIZE
], CMD_RESIZE
);
381 cs
->insert(cs
, commands
[CMD_MOVE
], CMD_MOVE
);
382 cs
->insert(cs
, commands
[CMD_TXMOVABLE
], CMD_TXMOVABLE
);
383 cs
->insert(cs
, commands
[CMD_TYMOVABLE
], CMD_TYMOVABLE
);
384 cs
->insert(cs
, commands
[CMD_SETDEFAULT
], CMD_SETDEFAULT
);
385 cs
->insert(cs
, commands
[CMD_BYPASSWM
], CMD_BYPASSWM
);
386 cs
->insert(cs
, commands
[CMD_FOLLOWWM
], CMD_FOLLOWWM
);
387 cs
->insert(cs
, commands
[CMD_FULLSCREEN
], CMD_FULLSCREEN
);
388 cs
->insert(cs
, commands
[CMD_SETTEXT
], CMD_SETTEXT
);
389 cs
->insert(cs
, commands
[CMD_ADDTEXT
], CMD_ADDTEXT
);
390 cs
->insert(cs
, commands
[CMD_DEFTEXT
], CMD_DEFTEXT
);
392 ss
->insert(ss
, sigs
[SIG_ENTER
], SIG_ENTER
);
393 ss
->insert(ss
, sigs
[SIG_LEAVE
], SIG_LEAVE
);
394 ss
->insert(ss
, sigs
[SIG_FOCUS
], SIG_FOCUS
);
395 ss
->insert(ss
, sigs
[SIG_UNFOCUS
], SIG_UNFOCUS
);
396 ss
->insert(ss
, sigs
[SIG_CLOSED
], SIG_CLOSED
);
397 ss
->insert(ss
, sigs
[SIG_CLICKED
], SIG_CLICKED
);
398 ss
->insert(ss
, sigs
[SIG_LCLICKED
], SIG_LCLICKED
);
399 ss
->insert(ss
, sigs
[SIG_RCLICKED
], SIG_RCLICKED
);
400 ss
->insert(ss
, sigs
[SIG_MCLICKED
], SIG_MCLICKED
);
401 ss
->insert(ss
, sigs
[SIG_DCLICKED
], SIG_DCLICKED
);
402 ss
->insert(ss
, sigs
[SIG_LDCLICKED
], SIG_LDCLICKED
);
403 ss
->insert(ss
, sigs
[SIG_RDCLICKED
], SIG_RDCLICKED
);
404 ss
->insert(ss
, sigs
[SIG_MDCLICKED
], SIG_MDCLICKED
);
405 ss
->insert(ss
, sigs
[SIG_PRESSED
], SIG_PRESSED
);
406 ss
->insert(ss
, sigs
[SIG_LPRESSED
], SIG_LPRESSED
);
407 ss
->insert(ss
, sigs
[SIG_RPRESSED
], SIG_RPRESSED
);
408 ss
->insert(ss
, sigs
[SIG_MPRESSED
], SIG_MPRESSED
);
409 ss
->insert(ss
, sigs
[SIG_RELEASED
], SIG_RELEASED
);
410 ss
->insert(ss
, sigs
[SIG_LRELEASED
], SIG_LRELEASED
);
411 ss
->insert(ss
, sigs
[SIG_RRELEASED
], SIG_RRELEASED
);
412 ss
->insert(ss
, sigs
[SIG_MRELEASED
], SIG_MRELEASED
);
413 ss
->insert(ss
, sigs
[SIG_SCROLLUP
], SIG_SCROLLUP
);
414 ss
->insert(ss
, sigs
[SIG_SCROLLDOWN
], SIG_SCROLLDOWN
);
415 ss
->insert(ss
, sigs
[SIG_MOVED
], SIG_MOVED
);
416 ss
->insert(ss
, sigs
[SIG_RESIZED
], SIG_RESIZED
);
423 composition
[E_ALL
].commands
= cs
;
424 composition
[E_ALL
].sigs
= ss
;
427 composition
[E_BUTTON
].commands
= NULL
;
428 composition
[E_BUTTON
].sigs
= NULL
;
431 cs
= alloc(map_strint_t
);
432 ss
= alloc(map_strint_t
);
436 cs
->insert(cs
, commands
[CMD_SHOWINPUT
], CMD_SHOWINPUT
);
437 cs
->insert(cs
, commands
[CMD_HIDEINPUT
], CMD_HIDEINPUT
);
438 cs
->insert(cs
, commands
[CMD_PASSWORD
], CMD_PASSWORD
);
439 cs
->insert(cs
, commands
[CMD_TRET
], CMD_TRET
);
440 ss
->insert(ss
, sigs
[SIG_RETURNPRESSED
], SIG_RETURNPRESSED
);
442 composition
[E_INPUT
].commands
= cs
;
443 composition
[E_INPUT
].sigs
= ss
;
446 cs
= alloc(map_strint_t
);
447 ss
= alloc(map_strint_t
);
451 cs
->insert(cs
, commands
[CMD_EMBED
], CMD_EMBED
);
452 cs
->insert(cs
, commands
[CMD_FITEMBED
], CMD_FITEMBED
);
453 cs
->insert(cs
, commands
[CMD_UNTIE
], CMD_UNTIE
);
454 cs
->insert(cs
, commands
[CMD_FITUNTIE
], CMD_FITUNTIE
);
455 cs
->insert(cs
, commands
[CMD_EXPLODE
], CMD_EXPLODE
);
456 cs
->insert(cs
, commands
[CMD_VERTICAL
], CMD_VERTICAL
);
457 cs
->insert(cs
, commands
[CMD_HORIZONTAL
], CMD_HORIZONTAL
);
458 cs
->insert(cs
, commands
[CMD_SWAP
], CMD_SWAP
);
459 cs
->insert(cs
, commands
[CMD_INVERT
], CMD_INVERT
);
460 cs
->insert(cs
, commands
[CMD_EQUALIZE
], CMD_EQUALIZE
);
461 cs
->insert(cs
, commands
[CMD_STYLESUBS
], CMD_STYLESUBS
);
463 composition
[E_PAGE
].commands
= cs
;
464 composition
[E_PAGE
].sigs
= ss
;
467 composition
[E_LABEL
].commands
= NULL
;
468 composition
[E_LABEL
].sigs
= NULL
;
471 cs
= alloc(map_strint_t
);
472 ss
= alloc(map_strint_t
);
476 cs
->insert(cs
, commands
[CMD_CHECK
], CMD_CHECK
);
477 cs
->insert(cs
, commands
[CMD_UNCHECK
], CMD_UNCHECK
);
478 ss
->insert(ss
, sigs
[SIG_CHECKED
], SIG_CHECKED
);
479 ss
->insert(ss
, sigs
[SIG_UNCHECKED
], SIG_UNCHECKED
);
481 composition
[E_CHECKBOX
].commands
= cs
;
482 composition
[E_CHECKBOX
].sigs
= ss
;
486 funcs
[F_READ
] = "read"; funcargs
[F_READ
] = -1;
487 funcs
[F_WRITE
] = "write"; funcargs
[F_WRITE
] = 2;
488 funcs
[F_APPEND
] = "append"; funcargs
[F_APPEND
] = 2;
489 funcs
[F_EVAL
] = "eval"; funcargs
[F_EVAL
] = -1;
490 funcs
[F_BUILTIN
] = "builtin"; funcargs
[F_BUILTIN
] = -2;
491 funcs
[F_BLOCK
] = "block"; funcargs
[F_BLOCK
] = -1;
492 funcs
[F_FLAT
] = "flat"; funcargs
[F_FLAT
] = -1;
493 funcs
[F_EACH
] = "each"; funcargs
[F_EACH
] = -2;
494 funcs
[F_LET
] = "let"; funcargs
[F_LET
] = -1;
495 funcs
[F_SOME
] = "some"; funcargs
[F_SOME
] = -1;
496 funcs
[F_TRUE
] = "true"; funcargs
[F_TRUE
] = 1;
497 funcs
[F_FALSE
] = "false"; funcargs
[F_FALSE
] = 1;
498 funcs
[F_ENV
] = "env"; funcargs
[F_ENV
] = 1;
499 funcs
[F_CWD
] = "cwd"; funcargs
[F_CWD
] = 0;
500 funcs
[F_PUTS
] = "puts"; funcargs
[F_PUTS
] = -1;
501 funcs
[F_PUSH
] = "push"; funcargs
[F_PUSH
] = -1;
502 funcs
[F_PUSHB
] = "pushb"; funcargs
[F_PUSHB
] = -1;
503 funcs
[F_POP
] = "pop"; funcargs
[F_POP
] = -1;
504 funcs
[F_POPB
] = "popb"; funcargs
[F_POPB
] = -1;
505 funcs
[F_REV
] = "rev"; funcargs
[F_REV
] = -1;
506 funcs
[F_GET
] = "get"; funcargs
[F_GET
] = 1;
507 funcs
[F_IN
] = "in"; funcargs
[F_IN
] = 2;
508 funcs
[F_JOIN
] = "join"; funcargs
[F_JOIN
] = -1;
509 funcs
[F_TIMES
] = "times"; funcargs
[F_TIMES
] = 2;
510 funcs
[F_ISDEF
] = "isdef"; funcargs
[F_ISDEF
] = 1;
511 funcs
[F_ISVAR
] = "isvar"; funcargs
[F_ISVAR
] = 1;
512 funcs
[F_ISFUNC
] = "isfunc"; funcargs
[F_ISFUNC
] = 1;
513 funcs
[F_ISBLOCK
] = "isblock"; funcargs
[F_ISBLOCK
] = -1;
514 funcs
[F_ISINT
] = "isint"; funcargs
[F_ISINT
] = -1;
515 funcs
[F_LEN
] = "len"; funcargs
[F_LEN
] = 1;
516 funcs
[F_SPLIT
] = "split"; funcargs
[F_SPLIT
] = 2;
517 funcs
[F_CSPLIT
] = "csplit"; funcargs
[F_CSPLIT
] = 2;
518 funcs
[F_IF
] = "if"; funcargs
[F_IF
] = -1;
519 funcs
[F_AND
] = "and"; funcargs
[F_AND
] = -1;
520 funcs
[F_OR
] = "or"; funcargs
[F_OR
] = -1;
521 funcs
[F_UNLESS
] = "unless"; funcargs
[F_UNLESS
] = -1;
522 funcs
[F_ADD
] = "add"; funcargs
[F_ADD
] = -1;
523 funcs
[F_SUB
] = "sub"; funcargs
[F_SUB
] = -1;
524 funcs
[F_ABS
] = "abs"; funcargs
[F_ABS
] = 1;
525 funcs
[F_NEG
] = "neg"; funcargs
[F_NEG
] = 1;
526 funcs
[F_NOT
] = "not"; funcargs
[F_NOT
] = 1;
527 funcs
[F_MUL
] = "mul"; funcargs
[F_MUL
] = -1;
528 funcs
[F_DIV
] = "div"; funcargs
[F_DIV
] = -1;
529 funcs
[F_MOD
] = "mod"; funcargs
[F_MOD
] = -1;
530 funcs
[F_CBRT
] = "cbrt"; funcargs
[F_CBRT
] = 1;
531 funcs
[F_SQRT
] = "sqrt"; funcargs
[F_SQRT
] = 1;
532 funcs
[F_POW
] = "pow"; funcargs
[F_POW
] = 2;
533 funcs
[F_LOG
] = "log"; funcargs
[F_LOG
] = 1;
534 funcs
[F_LN
] = "ln"; funcargs
[F_LN
] = 1;
535 funcs
[F_RAND
] = "rand"; funcargs
[F_RAND
] = 0;
536 funcs
[F_SIN
] = "sin"; funcargs
[F_SIN
] = 1;
537 funcs
[F_COS
] = "cos"; funcargs
[F_COS
] = 1;
538 funcs
[F_TAN
] = "tan"; funcargs
[F_TAN
] = 1;
539 funcs
[F_HEX
] = "hex"; funcargs
[F_HEX
] = 1;
540 funcs
[F_INT
] = "int"; funcargs
[F_INT
] = 1;
541 funcs
[F_XOR
] = "xor"; funcargs
[F_XOR
] = -3;
542 funcs
[F_BAND
] = "band"; funcargs
[F_BAND
] = -3;
543 funcs
[F_BOR
] = "bor"; funcargs
[F_BOR
] = -3;
544 funcs
[F_LSHIFT
] = "lsh"; funcargs
[F_LSHIFT
] = -3;
545 funcs
[F_RSHIFT
] = "rsh"; funcargs
[F_RSHIFT
] = -3;
546 funcs
[F_SEQ
] = "seq"; funcargs
[F_SEQ
] = -3;
547 funcs
[F_EQ
] = "eq"; funcargs
[F_EQ
] = -3;
548 funcs
[F_NE
] = "ne"; funcargs
[F_NE
] = -3;
549 funcs
[F_GT
] = "gt"; funcargs
[F_GT
] = -3;
550 funcs
[F_GE
] = "ge"; funcargs
[F_GE
] = -3;
551 funcs
[F_LT
] = "lt"; funcargs
[F_LT
] = -3;
552 funcs
[F_LE
] = "le"; funcargs
[F_LE
] = -3;
555 commands
[CMD_SUBCMD
] = "=>"; cmdargs
[CMD_SUBCMD
] = 2;
556 commands
[CMD_DELSUBCMD
] = "!>"; cmdargs
[CMD_DELSUBCMD
] = 1;
557 commands
[CMD_QUIT
] = "q"; cmdargs
[CMD_QUIT
] = 0;
558 commands
[CMD_EXIT
] = "exit"; cmdargs
[CMD_EXIT
] = 1;
559 commands
[CMD_CD
] = "cd"; cmdargs
[CMD_CD
] = 1;
560 commands
[CMD_RUN
] = "run"; cmdargs
[CMD_RUN
] = 1;
561 commands
[CMD_PUTS
] = "puts"; cmdargs
[CMD_PUTS
] = -1;
562 commands
[CMD_PRINT
] = "p"; cmdargs
[CMD_PRINT
] = -1;
563 commands
[CMD_ERROR
] = "e"; cmdargs
[CMD_ERROR
] = -1;
564 commands
[CMD_UNSET
] = "unset"; cmdargs
[CMD_UNSET
] = -2;
565 commands
[CMD_SOURCE
] = "source"; cmdargs
[CMD_SOURCE
] = 1;
566 commands
[CMD_VARS
] = "vars"; cmdargs
[CMD_VARS
] = -1;
567 commands
[CMD_EVERY
] = "every"; cmdargs
[CMD_EVERY
] = 2;
568 commands
[CMD_AFTER
] = "after"; cmdargs
[CMD_AFTER
] = 2;
569 commands
[CMD_WAIT
] = "wait"; cmdargs
[CMD_WAIT
] = 1;
570 commands
[CMD_IF
] = "if"; cmdargs
[CMD_IF
] = 2;
571 commands
[CMD_UNLESS
] = "unless"; cmdargs
[CMD_UNLESS
] = 2;
572 commands
[CMD_RETURN
] = "return"; cmdargs
[CMD_RETURN
] = -1;
573 commands
[CMD_ELSE
] = "else"; cmdargs
[CMD_ELSE
] = 1;
574 commands
[CMD_WHILE
] = "while"; cmdargs
[CMD_WHILE
] = 2;
575 commands
[CMD_UNTIL
] = "until"; cmdargs
[CMD_UNTIL
] = 2;
576 commands
[CMD_FOR
] = "for"; cmdargs
[CMD_FOR
] = -4;
577 commands
[CMD_BREAK
] = "break"; cmdargs
[CMD_BREAK
] = 0;
578 commands
[CMD_PASS
] = "pass"; cmdargs
[CMD_PASS
] = -1;
581 sigs
[SIG_EXIT
] = "q";
582 sigs
[SIG_TERM
] = "t";
584 kids
= alloc(map_strint_t
);
585 sids
= alloc(map_strint_t
);
586 fids
= alloc(map_strint_t
);
593 for (e
=FIDS_START
; e
<FIDS_END
; ++e
)
594 fids
->insert(fids
, funcs
[e
], e
);
596 for (e
=KIDS_START
; e
<KIDS_END
; ++e
)
597 kids
->insert(kids
, commands
[e
], e
);
599 for (e
=SIDS_START
; e
<SIDS_END
; ++e
)
600 sids
->insert(sids
, sigs
[e
], e
);
602 if (kids
->full(kids
))
604 if (fids
->full(fids
))