2013-09-29 00:21:18 +04:00
|
|
|
/* v/reck.c
|
|
|
|
**
|
|
|
|
** This file is in the public domain.
|
|
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <setjmp.h>
|
|
|
|
#include <gmp.h>
|
|
|
|
#include <dirent.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <uv.h>
|
|
|
|
#include <curses.h>
|
|
|
|
#include <termios.h>
|
|
|
|
#include <term.h>
|
|
|
|
|
|
|
|
#include "all.h"
|
|
|
|
#include "v/vere.h"
|
|
|
|
|
|
|
|
/* _reck_mole(): parse simple atomic mole.
|
|
|
|
*/
|
2014-11-06 06:10:22 +03:00
|
|
|
static u3_noun
|
2014-09-11 04:01:32 +04:00
|
|
|
_reck_mole(u3_noun fot,
|
|
|
|
u3_noun san,
|
2013-09-29 00:21:18 +04:00
|
|
|
c3_d* ato_d)
|
|
|
|
{
|
2014-11-06 06:10:22 +03:00
|
|
|
u3_noun uco = u3do("slay", san);
|
2014-09-11 04:01:32 +04:00
|
|
|
u3_noun p_uco, q_uco, r_uco, s_uco;
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-11-06 03:20:01 +03:00
|
|
|
if ( (c3n == u3r_qual(uco, &p_uco, &q_uco, &r_uco, &s_uco)) ||
|
2013-09-29 00:21:18 +04:00
|
|
|
(0 != p_uco) ||
|
|
|
|
(0 != q_uco) ||
|
2014-11-06 03:20:01 +03:00
|
|
|
(c3n == u3r_sing(fot, r_uco)) )
|
2013-09-29 00:21:18 +04:00
|
|
|
{
|
2014-11-06 03:20:01 +03:00
|
|
|
uL(fprintf(uH, "strange mole %s\n", u3r_string(san)));
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-11-05 04:18:47 +03:00
|
|
|
u3z(fot); u3z(uco); return c3n;
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
|
|
|
else {
|
2014-11-06 03:20:01 +03:00
|
|
|
*ato_d = u3r_chub(0, s_uco);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-11-05 04:18:47 +03:00
|
|
|
u3z(fot); u3z(uco); return c3y;
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* _reck_lily(): parse little atom.
|
|
|
|
*/
|
2014-11-06 06:10:22 +03:00
|
|
|
static u3_noun
|
2014-09-11 04:01:32 +04:00
|
|
|
_reck_lily(u3_noun fot, u3_noun txt, c3_l* tid_l)
|
2013-09-29 00:21:18 +04:00
|
|
|
{
|
|
|
|
c3_d ato_d;
|
|
|
|
|
2014-11-05 04:18:47 +03:00
|
|
|
if ( c3n == _reck_mole(fot, txt, &ato_d) ) {
|
|
|
|
return c3n;
|
2013-09-29 00:21:18 +04:00
|
|
|
} else {
|
|
|
|
if ( ato_d >= 0x80000000ULL ) {
|
2014-11-05 04:18:47 +03:00
|
|
|
return c3n;
|
2013-09-29 00:21:18 +04:00
|
|
|
} else {
|
|
|
|
*tid_l = (c3_l) ato_d;
|
|
|
|
|
2014-11-05 04:18:47 +03:00
|
|
|
return c3y;
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-07 05:25:41 +03:00
|
|
|
/* _reck_spac(): print n spaces.
|
|
|
|
*/
|
|
|
|
void _reck_spac(c3_w n)
|
|
|
|
{
|
|
|
|
for (; n > 0; n--)
|
2015-05-08 02:16:54 +03:00
|
|
|
(fprintf(stderr," "));
|
2015-05-07 05:25:41 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* _reck_print_memory: print memory amount. cf u3a_print_memory().
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
_reck_print_memory(c3_w wor_w)
|
|
|
|
{
|
|
|
|
c3_w byt_w = (wor_w * 4);
|
|
|
|
c3_w gib_w = (byt_w / 1000000000);
|
|
|
|
c3_w mib_w = (byt_w % 1000000000) / 1000000;
|
|
|
|
c3_w kib_w = (byt_w % 1000000) / 1000;
|
|
|
|
c3_w bib_w = (byt_w % 1000);
|
|
|
|
|
|
|
|
if ( gib_w ) {
|
2015-05-08 02:16:54 +03:00
|
|
|
(fprintf(stderr, "GB/%d.%03d.%03d.%03d\r\n",
|
2015-05-07 05:25:41 +03:00
|
|
|
gib_w, mib_w, kib_w, bib_w));
|
|
|
|
}
|
|
|
|
else if ( mib_w ) {
|
2015-05-08 02:16:54 +03:00
|
|
|
(fprintf(stderr, "MB/%d.%03d.%03d\r\n", mib_w, kib_w, bib_w));
|
2015-05-07 05:25:41 +03:00
|
|
|
}
|
|
|
|
else if ( kib_w ) {
|
2015-05-08 02:16:54 +03:00
|
|
|
(fprintf(stderr, "KB/%d.%03d\r\n", kib_w, bib_w));
|
2015-05-07 05:25:41 +03:00
|
|
|
}
|
|
|
|
else {
|
2015-05-08 02:16:54 +03:00
|
|
|
(fprintf(stderr, "B/%d\r\n", bib_w));
|
2015-05-07 05:25:41 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* _reck_meme_noun(): get memory usage, in words, of noun. RETAIN.
|
|
|
|
*/
|
|
|
|
c3_w
|
|
|
|
_reck_meme_noun(u3p(u3h_root) hax, u3_noun non, c3_t dud)
|
|
|
|
{
|
2015-05-08 02:16:54 +03:00
|
|
|
return 0;
|
|
|
|
/*
|
2015-05-07 05:25:41 +03:00
|
|
|
u3_weak got = u3h_git(hax, dud ? non & 0x7fffffff : non);
|
|
|
|
|
|
|
|
if (u3_none != got) {
|
2015-05-08 02:16:54 +03:00
|
|
|
return 1;
|
2015-05-07 05:25:41 +03:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
c3_w res;
|
|
|
|
|
|
|
|
if (!(non & 0x80000000)) {
|
|
|
|
res = 1;
|
|
|
|
}
|
|
|
|
if (_(u3ud(non))) {
|
2015-05-08 02:16:54 +03:00
|
|
|
res = 3 + 3 + u3r_met(5, non);
|
2015-05-07 05:25:41 +03:00
|
|
|
}
|
|
|
|
else {
|
2015-05-08 02:16:54 +03:00
|
|
|
res = 3 + 2
|
2015-05-07 05:25:41 +03:00
|
|
|
+ _reck_meme_noun(hax, u3h(non), dud)
|
|
|
|
+ _reck_meme_noun(hax, u3t(non), dud);
|
|
|
|
}
|
|
|
|
|
|
|
|
u3h_put(hax, dud ? non & 0x7fffffff : non, res);
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
2015-05-08 02:16:54 +03:00
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
|
|
|
/* _reck_noun_grab(): get memory usage, in words, of noun from GC. RETAIN.
|
|
|
|
* XXX what about unmarking stuff? what's a GC cycle?
|
|
|
|
*/
|
|
|
|
c3_w
|
|
|
|
_reck_noun_grab(u3_noun non)
|
|
|
|
{
|
|
|
|
return u3a_mark_noun(non);
|
2015-05-07 05:25:41 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* _reck_meme_prof(): print memory profile. RETAIN.
|
|
|
|
*/
|
2015-05-08 02:16:54 +03:00
|
|
|
c3_w
|
2015-05-07 05:25:41 +03:00
|
|
|
_reck_meme_prof(u3p(u3h_root) hax, c3_w den, u3_noun mas)
|
|
|
|
{
|
2015-05-08 02:16:54 +03:00
|
|
|
c3_w tot_w = 0;
|
2015-05-07 05:25:41 +03:00
|
|
|
u3_noun h_mas, t_mas;
|
|
|
|
|
|
|
|
if (c3n == u3r_cell(mas, &h_mas, &t_mas)) {
|
|
|
|
_reck_spac(den);
|
2015-05-08 02:16:54 +03:00
|
|
|
(fprintf(stderr, "mistyped mass\r\n"));
|
|
|
|
return tot_w;
|
2015-05-07 05:25:41 +03:00
|
|
|
}
|
|
|
|
if (c3y == h_mas) {
|
|
|
|
_reck_spac(den);
|
|
|
|
_reck_print_memory(_reck_meme_noun(hax, t_mas, false));
|
|
|
|
_reck_spac(den);
|
|
|
|
_reck_print_memory(_reck_meme_noun(hax, t_mas, true));
|
2015-05-08 02:16:54 +03:00
|
|
|
_reck_spac(den);
|
|
|
|
tot_w += _reck_noun_grab(t_mas);
|
|
|
|
_reck_print_memory(tot_w);
|
|
|
|
return tot_w;
|
2015-05-07 05:25:41 +03:00
|
|
|
}
|
|
|
|
else if (c3n == h_mas) {
|
|
|
|
u3_noun it_mas, tt_mas, pit_mas, qit_mas;
|
|
|
|
while (u3_nul != t_mas)
|
|
|
|
{
|
|
|
|
_reck_spac(den);
|
|
|
|
if (c3n == u3r_cell(t_mas, &it_mas, &tt_mas)) {
|
2015-05-08 02:16:54 +03:00
|
|
|
(fprintf(stderr, "mistyped mass list\r\n"));
|
|
|
|
return tot_w;
|
2015-05-07 05:25:41 +03:00
|
|
|
}
|
|
|
|
else if (c3n == u3r_cell(it_mas, &pit_mas, &qit_mas)) {
|
2015-05-08 02:16:54 +03:00
|
|
|
(fprintf(stderr, "mistyped mass list element\r\n"));
|
|
|
|
return tot_w;
|
2015-05-07 05:25:41 +03:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
c3_c* pit_c = u3m_pretty(pit_mas);
|
2015-05-08 02:16:54 +03:00
|
|
|
(fprintf(stderr, "%s\r\n", pit_c));
|
2015-05-07 05:25:41 +03:00
|
|
|
free(pit_c);
|
|
|
|
|
2015-05-08 02:16:54 +03:00
|
|
|
tot_w += _reck_meme_prof(hax, den+2, qit_mas);
|
2015-05-07 05:25:41 +03:00
|
|
|
|
|
|
|
t_mas = tt_mas;
|
|
|
|
}
|
|
|
|
}
|
2015-05-08 02:16:54 +03:00
|
|
|
return tot_w;
|
2015-05-07 05:25:41 +03:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
_reck_spac(den);
|
2015-05-08 02:16:54 +03:00
|
|
|
(fprintf(stderr, "mistyped mass head\r\n"));
|
|
|
|
return tot_w;
|
2015-05-07 05:25:41 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-29 00:21:18 +04:00
|
|
|
/* _reck_kick_term(): apply terminal outputs.
|
|
|
|
*/
|
2014-11-06 06:10:22 +03:00
|
|
|
static u3_noun
|
2014-09-11 04:01:32 +04:00
|
|
|
_reck_kick_term(u3_noun pox, c3_l tid_l, u3_noun fav)
|
2013-09-29 00:21:18 +04:00
|
|
|
{
|
2014-09-11 04:01:32 +04:00
|
|
|
u3_noun p_fav;
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-11-05 04:18:47 +03:00
|
|
|
if ( c3n == u3du(fav) ) {
|
|
|
|
u3z(pox); u3z(fav); return c3n;
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
2014-09-11 04:01:32 +04:00
|
|
|
else switch ( u3h(fav) ) {
|
2014-11-05 04:18:47 +03:00
|
|
|
default: u3z(pox); u3z(fav); return c3n;
|
2013-12-19 00:42:29 +04:00
|
|
|
case c3__bbye:
|
2013-09-29 00:21:18 +04:00
|
|
|
{
|
2014-11-05 04:18:47 +03:00
|
|
|
u3z(pox); u3z(fav); return c3y;
|
2013-12-19 00:42:29 +04:00
|
|
|
} break;
|
|
|
|
|
2014-09-11 04:01:32 +04:00
|
|
|
case c3__blit: p_fav = u3t(fav);
|
2013-09-29 00:21:18 +04:00
|
|
|
{
|
2014-09-11 04:01:32 +04:00
|
|
|
u3_term_ef_blit(tid_l, u3k(p_fav));
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-11-05 04:18:47 +03:00
|
|
|
u3z(pox); u3z(fav); return c3y;
|
2013-09-29 00:21:18 +04:00
|
|
|
} break;
|
|
|
|
|
2013-12-19 00:42:29 +04:00
|
|
|
case c3__logo:
|
2013-09-29 00:21:18 +04:00
|
|
|
{
|
2014-11-05 04:18:47 +03:00
|
|
|
u3_Host.liv = c3n;
|
2014-09-11 04:01:32 +04:00
|
|
|
u3_Host.xit_i = u3t(fav);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-11-05 04:18:47 +03:00
|
|
|
u3z(pox); u3z(fav); return c3y;
|
2013-09-29 00:21:18 +04:00
|
|
|
} break;
|
|
|
|
|
2014-09-11 04:01:32 +04:00
|
|
|
case c3__init: p_fav = u3t(fav);
|
2013-09-29 00:21:18 +04:00
|
|
|
{
|
2014-09-11 04:01:32 +04:00
|
|
|
u3A->own = u3nc(u3k(p_fav), u3A->own);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-09-11 04:01:32 +04:00
|
|
|
u3_unix_ef_init(u3k(p_fav));
|
2015-05-01 21:40:01 +03:00
|
|
|
|
|
|
|
u3_noun hox = u3dc("scot", 'p', u3k(p_fav));
|
|
|
|
c3_c* nam_c = u3r_string(hox);
|
|
|
|
|
|
|
|
uL(fprintf(uH, "kick: init: %s\n", nam_c));
|
|
|
|
free(nam_c); u3z(pox); u3z(hox); u3z(fav); return c3y;
|
2013-09-29 00:21:18 +04:00
|
|
|
} break;
|
2015-05-07 05:25:41 +03:00
|
|
|
|
|
|
|
case c3__mass: p_fav = u3t(fav);
|
|
|
|
{
|
2015-05-08 02:16:54 +03:00
|
|
|
u3_Prof = u3k(p_fav);
|
|
|
|
//c3_w usr_w, utm_w, utv_w, ext_w, wep_w;
|
|
|
|
//uL(fprintf(uH, "memory profile:\r\n"));
|
|
|
|
|
|
|
|
//// u3p(u3h_root) hax = u3h_new();
|
|
|
|
|
|
|
|
//usr_w = _reck_meme_prof(u3_nul, 0, p_fav);
|
|
|
|
//(fprintf(stderr, "total userspace: "));
|
|
|
|
//_reck_print_memory(usr_w);
|
|
|
|
|
|
|
|
//utm_w = u3m_mark();
|
|
|
|
//(fprintf(stderr, "u3m stuff: "));
|
|
|
|
//_reck_print_memory(utm_w);
|
|
|
|
|
|
|
|
//utv_w = u3v_mark();
|
|
|
|
//(fprintf(stderr, "u3v stuff: "));
|
|
|
|
//_reck_print_memory(utv_w);
|
|
|
|
|
|
|
|
//ext_w = u3a_mark_noun(pox) + u3a_mark_noun(fav);
|
|
|
|
//(fprintf(stderr, "extra stuff: "));
|
|
|
|
//_reck_print_memory(ext_w);
|
2015-05-07 05:25:41 +03:00
|
|
|
|
2015-05-08 02:16:54 +03:00
|
|
|
//(fprintf(stderr, "total memory: "));
|
|
|
|
//_reck_print_memory(usr_w + utm_w + utv_w + ext_w);
|
2015-05-07 05:25:41 +03:00
|
|
|
|
2015-05-08 02:16:54 +03:00
|
|
|
//wep_w = u3a_sweep();
|
|
|
|
//(fprintf(stderr, "sweep memory: "));
|
|
|
|
//_reck_print_memory(wep_w);
|
2015-05-07 05:25:41 +03:00
|
|
|
|
2015-05-08 02:16:54 +03:00
|
|
|
//// u3h_free(hax);
|
2015-05-07 05:25:41 +03:00
|
|
|
|
|
|
|
u3z(pox); u3z(fav); return c3y;
|
|
|
|
} break;
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
|
|
|
c3_assert(!"not reached"); return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* _reck_kick_http(): apply http effects.
|
|
|
|
*/
|
2014-11-06 06:10:22 +03:00
|
|
|
static u3_noun
|
2014-09-11 04:01:32 +04:00
|
|
|
_reck_kick_http(u3_noun pox,
|
2014-03-20 02:40:40 +04:00
|
|
|
c3_l sev_l,
|
2013-09-29 00:21:18 +04:00
|
|
|
c3_l coq_l,
|
|
|
|
c3_l seq_l,
|
2014-09-11 04:01:32 +04:00
|
|
|
u3_noun fav)
|
2013-09-29 00:21:18 +04:00
|
|
|
{
|
2014-09-11 04:01:32 +04:00
|
|
|
u3_noun p_fav, q_fav;
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-11-05 04:18:47 +03:00
|
|
|
if ( c3n == u3du(fav) ) {
|
|
|
|
u3z(pox); u3z(fav); return c3n;
|
2013-12-19 00:42:29 +04:00
|
|
|
}
|
2014-09-11 04:01:32 +04:00
|
|
|
else switch ( u3h(fav) ) {
|
2014-11-05 04:18:47 +03:00
|
|
|
default: u3z(pox); u3z(fav); return c3n;
|
2013-10-27 07:55:53 +04:00
|
|
|
|
2014-09-11 04:01:32 +04:00
|
|
|
case c3__thus: p_fav = u3h(u3t(fav)); q_fav = u3t(u3t(fav));
|
2013-10-27 07:55:53 +04:00
|
|
|
{
|
2014-11-06 03:20:01 +03:00
|
|
|
u3_cttp_ef_thus(u3r_word(0, p_fav), u3k(q_fav));
|
2013-12-19 00:42:29 +04:00
|
|
|
|
2014-09-11 04:01:32 +04:00
|
|
|
u3z(pox); u3z(fav);
|
2014-11-05 04:18:47 +03:00
|
|
|
return c3y;
|
2013-10-27 07:55:53 +04:00
|
|
|
}
|
2014-09-11 04:01:32 +04:00
|
|
|
case c3__thou: p_fav = u3t(fav);
|
2013-09-29 00:21:18 +04:00
|
|
|
{
|
2014-09-11 04:01:32 +04:00
|
|
|
u3_http_ef_thou(sev_l, coq_l, seq_l, u3k(p_fav));
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-09-11 04:01:32 +04:00
|
|
|
u3z(pox); u3z(fav);
|
2014-11-05 04:18:47 +03:00
|
|
|
return c3y;
|
2013-09-29 00:21:18 +04:00
|
|
|
} break;
|
|
|
|
}
|
2014-11-05 04:18:47 +03:00
|
|
|
c3_assert(!"not reached"); return c3n;
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* _reck_kick_sync(): apply sync outputs.
|
|
|
|
*/
|
2014-11-06 06:10:22 +03:00
|
|
|
static u3_noun
|
2014-09-11 04:01:32 +04:00
|
|
|
_reck_kick_sync(u3_noun pox, u3_noun fav)
|
2013-09-29 00:21:18 +04:00
|
|
|
{
|
2014-09-11 04:01:32 +04:00
|
|
|
switch ( u3h(fav) ) {
|
2013-09-29 00:21:18 +04:00
|
|
|
default: break;
|
|
|
|
case c3__ergo: {
|
2014-09-11 04:01:32 +04:00
|
|
|
u3_noun who = u3k(u3h(u3t(fav)));
|
|
|
|
u3_noun syd = u3k(u3h(u3t(u3t(fav))));
|
2015-02-27 09:35:41 +03:00
|
|
|
u3_noun rel = u3k(u3h(u3t(u3t(u3t(fav)))));
|
|
|
|
u3_noun can = u3k(u3t(u3t(u3t(u3t(fav)))));
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2015-02-27 09:35:41 +03:00
|
|
|
u3_unix_ef_ergo(who, syd, rel, can);
|
2014-11-05 04:18:47 +03:00
|
|
|
u3z(pox); u3z(fav); return c3y;
|
2013-09-29 00:21:18 +04:00
|
|
|
} break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// XX obviously not right!
|
|
|
|
//
|
2014-11-05 04:18:47 +03:00
|
|
|
u3z(pox); u3z(fav); return c3n;
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
|
|
|
|
2014-11-06 06:10:22 +03:00
|
|
|
static u3_noun
|
2014-09-11 04:01:32 +04:00
|
|
|
_reck_kick_newt(u3_noun pox, u3_noun fav)
|
2014-07-10 01:42:08 +04:00
|
|
|
{
|
2014-09-11 04:01:32 +04:00
|
|
|
switch ( u3h(fav) ) {
|
2014-07-10 01:42:08 +04:00
|
|
|
default: break;
|
|
|
|
case c3__send: {
|
2014-09-11 04:01:32 +04:00
|
|
|
u3_noun lan = u3k(u3h(u3t(fav)));
|
|
|
|
u3_noun pac = u3k(u3t(u3t(fav)));
|
2014-07-10 01:42:08 +04:00
|
|
|
|
2014-09-11 04:01:32 +04:00
|
|
|
u3_ames_ef_send(lan, pac);
|
2014-11-05 04:18:47 +03:00
|
|
|
u3z(pox); u3z(fav); return c3y;
|
2014-07-10 01:42:08 +04:00
|
|
|
} break;
|
|
|
|
}
|
2014-11-05 04:18:47 +03:00
|
|
|
u3z(pox); u3z(fav); return c3n;
|
2014-07-10 01:42:08 +04:00
|
|
|
}
|
|
|
|
|
2013-09-29 00:21:18 +04:00
|
|
|
/* _reck_kick_ames(): apply packet network outputs.
|
|
|
|
*/
|
2014-11-06 06:10:22 +03:00
|
|
|
static u3_noun
|
2014-09-11 04:01:32 +04:00
|
|
|
_reck_kick_ames(u3_noun pox, u3_noun fav)
|
2013-09-29 00:21:18 +04:00
|
|
|
{
|
2014-09-11 04:01:32 +04:00
|
|
|
u3_noun p_fav;
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-09-11 04:01:32 +04:00
|
|
|
switch ( u3h(fav) ) {
|
2013-09-29 00:21:18 +04:00
|
|
|
default: break;
|
2014-09-11 04:01:32 +04:00
|
|
|
case c3__init: p_fav = u3t(fav);
|
2013-09-29 00:21:18 +04:00
|
|
|
{
|
2014-09-11 04:01:32 +04:00
|
|
|
u3A->own = u3nc(u3k(p_fav), u3A->own);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-09-11 04:01:32 +04:00
|
|
|
u3_unix_ef_init(u3k(p_fav));
|
2013-09-29 00:21:18 +04:00
|
|
|
|
|
|
|
// uL(fprintf(uH, "kick: init: %d\n", p_fav));
|
2014-11-05 04:18:47 +03:00
|
|
|
u3z(pox); u3z(fav); return c3y;
|
2013-09-29 00:21:18 +04:00
|
|
|
} break;
|
|
|
|
}
|
2014-11-05 04:18:47 +03:00
|
|
|
u3z(pox); u3z(fav); return c3n;
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* _reck_kick_spec(): apply an effect, by path.
|
|
|
|
*/
|
2014-11-06 06:10:22 +03:00
|
|
|
static u3_noun
|
2014-09-11 04:01:32 +04:00
|
|
|
_reck_kick_spec(u3_noun pox, u3_noun fav)
|
2013-09-29 00:21:18 +04:00
|
|
|
{
|
2014-09-11 04:01:32 +04:00
|
|
|
u3_noun i_pox, t_pox;
|
2014-11-20 05:36:36 +03:00
|
|
|
u3_noun p_fav;
|
2013-12-19 00:42:29 +04:00
|
|
|
|
2014-11-06 03:20:01 +03:00
|
|
|
if ( (c3n == u3r_cell(pox, &i_pox, &t_pox)) ||
|
2014-09-11 04:01:32 +04:00
|
|
|
((i_pox != u3_blip) &&
|
2014-06-24 21:32:59 +04:00
|
|
|
(i_pox != c3__gold) &&
|
|
|
|
(i_pox != c3__iron) &&
|
|
|
|
(i_pox != c3__lead)) )
|
2013-09-29 00:21:18 +04:00
|
|
|
{
|
2014-11-05 04:18:47 +03:00
|
|
|
u3z(pox); u3z(fav); return c3n;
|
2013-09-29 00:21:18 +04:00
|
|
|
} else {
|
2014-09-11 04:01:32 +04:00
|
|
|
u3_noun it_pox, tt_pox;
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-11-06 03:20:01 +03:00
|
|
|
if ( (c3n == u3r_cell(t_pox, &it_pox, &tt_pox)) ) {
|
2014-11-05 04:18:47 +03:00
|
|
|
u3z(pox); u3z(fav); return c3n;
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
|
|
|
else switch ( it_pox ) {
|
2014-11-05 04:18:47 +03:00
|
|
|
default: return c3n;
|
2013-09-29 00:21:18 +04:00
|
|
|
|
|
|
|
case c3__http: {
|
2014-09-11 04:01:32 +04:00
|
|
|
u3_noun pud = tt_pox;
|
|
|
|
u3_noun p_pud, t_pud, tt_pud, q_pud, r_pud, s_pud;
|
2014-03-20 02:40:40 +04:00
|
|
|
c3_l sev_l, coq_l, seq_l;
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-11-06 03:20:01 +03:00
|
|
|
if ( (c3n == u3r_cell(pud, &p_pud, &t_pud)) ||
|
2014-11-05 04:18:47 +03:00
|
|
|
(c3n == _reck_lily(c3__uv, u3k(p_pud), &sev_l)) )
|
2013-09-29 00:21:18 +04:00
|
|
|
{
|
2014-11-05 04:18:47 +03:00
|
|
|
u3z(pox); u3z(fav); return c3n;
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
|
|
|
|
2014-09-11 04:01:32 +04:00
|
|
|
if ( u3_nul == t_pud ) {
|
2013-09-29 00:21:18 +04:00
|
|
|
coq_l = seq_l = 0;
|
|
|
|
}
|
|
|
|
else {
|
2014-11-06 03:20:01 +03:00
|
|
|
if ( (c3n == u3r_cell(t_pud, &q_pud, &tt_pud)) ||
|
2014-11-05 04:18:47 +03:00
|
|
|
(c3n == _reck_lily(c3__ud, u3k(q_pud), &coq_l)) )
|
2013-09-29 00:21:18 +04:00
|
|
|
{
|
2014-11-05 04:18:47 +03:00
|
|
|
u3z(pox); u3z(fav); return c3n;
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
|
|
|
|
2014-09-11 04:01:32 +04:00
|
|
|
if ( u3_nul == tt_pud ) {
|
2013-09-29 00:21:18 +04:00
|
|
|
seq_l = 0;
|
|
|
|
} else {
|
2014-11-06 03:20:01 +03:00
|
|
|
if ( (c3n == u3r_cell(tt_pud, &r_pud, &s_pud)) ||
|
2014-09-11 04:01:32 +04:00
|
|
|
(u3_nul != s_pud) ||
|
2014-11-05 04:18:47 +03:00
|
|
|
(c3n == _reck_lily(c3__ud, u3k(r_pud), &seq_l)) )
|
2013-09-29 00:21:18 +04:00
|
|
|
{
|
2014-11-05 04:18:47 +03:00
|
|
|
u3z(pox); u3z(fav); return c3n;
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-09-11 04:01:32 +04:00
|
|
|
return _reck_kick_http(pox, sev_l, coq_l, seq_l, fav);
|
2013-09-29 00:21:18 +04:00
|
|
|
} break;
|
|
|
|
|
2013-12-19 00:42:29 +04:00
|
|
|
case c3__clay:
|
2013-09-29 00:21:18 +04:00
|
|
|
case c3__sync: {
|
2014-09-11 04:01:32 +04:00
|
|
|
return _reck_kick_sync(pox, fav);
|
2013-09-29 00:21:18 +04:00
|
|
|
} break;
|
|
|
|
|
2014-07-10 01:42:08 +04:00
|
|
|
case c3__newt: {
|
2014-09-11 04:01:32 +04:00
|
|
|
return _reck_kick_newt(pox, fav);
|
2014-07-10 01:42:08 +04:00
|
|
|
} break;
|
2014-07-10 02:59:22 +04:00
|
|
|
|
2013-09-29 00:21:18 +04:00
|
|
|
case c3__ames: {
|
2014-09-11 04:01:32 +04:00
|
|
|
if ( (u3_nul != tt_pox) ) {
|
2014-11-05 04:18:47 +03:00
|
|
|
u3z(pox); u3z(fav); return c3n;
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
2013-12-19 00:42:29 +04:00
|
|
|
else {
|
2014-09-11 04:01:32 +04:00
|
|
|
return _reck_kick_ames(pox, fav);
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
|
|
|
} break;
|
|
|
|
|
2014-11-20 05:36:36 +03:00
|
|
|
case c3__init: p_fav = u3t(fav);
|
|
|
|
{
|
|
|
|
u3A->own = u3nc(u3k(p_fav), u3A->own);
|
|
|
|
|
|
|
|
u3_unix_ef_init(u3k(p_fav));
|
|
|
|
|
|
|
|
// uL(fprintf(uH, "kick: init: %d\n", p_fav));
|
|
|
|
u3z(pox); u3z(fav); return c3y;
|
|
|
|
} break;
|
|
|
|
|
2013-09-29 00:21:18 +04:00
|
|
|
case c3__term: {
|
2014-09-11 04:01:32 +04:00
|
|
|
u3_noun pud = tt_pox;
|
|
|
|
u3_noun p_pud, q_pud;
|
2013-09-29 00:21:18 +04:00
|
|
|
c3_l tid_l;
|
|
|
|
|
2014-11-06 03:20:01 +03:00
|
|
|
if ( (c3n == u3r_cell(pud, &p_pud, &q_pud)) ||
|
2014-09-11 04:01:32 +04:00
|
|
|
(u3_nul != q_pud) ||
|
2014-11-05 04:18:47 +03:00
|
|
|
(c3n == _reck_lily(c3__ud, u3k(p_pud), &tid_l)) )
|
2013-09-29 00:21:18 +04:00
|
|
|
{
|
|
|
|
uL(fprintf(uH, "term: bad tire\n"));
|
2014-11-05 04:18:47 +03:00
|
|
|
u3z(pox); u3z(fav); return c3n;
|
2013-09-29 00:21:18 +04:00
|
|
|
} else {
|
2014-09-11 04:01:32 +04:00
|
|
|
return _reck_kick_term(pox, tid_l, fav);
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
|
|
|
} break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
c3_assert(!"not reached");
|
2014-11-05 04:18:47 +03:00
|
|
|
return c3n;
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* _reck_kick_norm(): non path-specific effect handling.
|
|
|
|
*/
|
2014-11-06 06:10:22 +03:00
|
|
|
static u3_noun
|
2014-09-11 04:01:32 +04:00
|
|
|
_reck_kick_norm(u3_noun pox, u3_noun fav)
|
2013-09-29 00:21:18 +04:00
|
|
|
{
|
2014-11-05 04:18:47 +03:00
|
|
|
if ( c3n == u3du(fav) ) {
|
|
|
|
u3z(pox); u3z(fav); return c3n;
|
2013-12-19 00:42:29 +04:00
|
|
|
}
|
2014-09-11 04:01:32 +04:00
|
|
|
else switch ( u3h(fav) ) {
|
2014-11-05 04:18:47 +03:00
|
|
|
default: u3z(pox); u3z(fav); return c3n;
|
2013-12-19 00:42:29 +04:00
|
|
|
|
2014-02-15 05:35:22 +04:00
|
|
|
case c3__vega:
|
|
|
|
{
|
2014-10-26 01:28:14 +04:00
|
|
|
uL(fprintf(uH, "<<<reset>>>\n"));
|
2014-09-11 04:01:32 +04:00
|
|
|
u3z(pox); u3z(fav);
|
2014-02-15 05:35:22 +04:00
|
|
|
|
2014-09-11 04:01:32 +04:00
|
|
|
// u3_ds_wipe(u3_Wire); // doesn't work
|
2014-02-15 05:35:22 +04:00
|
|
|
|
2014-11-05 04:18:47 +03:00
|
|
|
return c3y;
|
2014-02-15 05:35:22 +04:00
|
|
|
}
|
2013-09-29 00:21:18 +04:00
|
|
|
case c3__exit:
|
|
|
|
{
|
|
|
|
uL(fprintf(uH, "<<<goodbye>>>\n"));
|
2014-09-11 04:01:32 +04:00
|
|
|
u3_lo_bail();
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-11-05 04:18:47 +03:00
|
|
|
u3z(pox); u3z(fav); return c3y;
|
2013-09-29 00:21:18 +04:00
|
|
|
} break;
|
|
|
|
}
|
2014-11-05 04:18:47 +03:00
|
|
|
c3_assert(!"not reached"); return c3n;
|
|
|
|
u3z(pox); u3z(fav); return c3n;
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
|
|
|
|
2014-09-11 04:01:32 +04:00
|
|
|
/* u3_reck_kick(): handle effect.
|
2013-09-29 00:21:18 +04:00
|
|
|
*/
|
|
|
|
void
|
2014-09-11 04:01:32 +04:00
|
|
|
u3_reck_kick(u3_noun ovo)
|
2013-09-29 00:21:18 +04:00
|
|
|
{
|
2014-11-05 04:18:47 +03:00
|
|
|
if ( (c3n == _reck_kick_spec(u3k(u3h(ovo)), u3k(u3t(ovo)))) &&
|
|
|
|
(c3n == _reck_kick_norm(u3k(u3h(ovo)), u3k(u3t(ovo)))) )
|
2013-09-29 00:21:18 +04:00
|
|
|
{
|
2014-11-06 06:10:22 +03:00
|
|
|
u3_noun tox = u3do("spat", u3k(u3h(ovo)));
|
2013-09-29 00:21:18 +04:00
|
|
|
|
|
|
|
#if 0
|
2014-09-11 04:01:32 +04:00
|
|
|
if ( (c3__warn != u3h(u3t(ovo))) &&
|
|
|
|
(c3__text != u3h(u3t(ovo))) &&
|
|
|
|
(c3__note != u3h(u3t(ovo))) )
|
2013-09-29 00:21:18 +04:00
|
|
|
#endif
|
|
|
|
#if 1
|
2014-09-11 04:01:32 +04:00
|
|
|
if ( (c3__crud == u3h(u3t(ovo))) )
|
2013-09-29 00:21:18 +04:00
|
|
|
#if 0
|
2014-09-11 04:01:32 +04:00
|
|
|
(c3__talk == u3h(u3t(ovo))) ||
|
|
|
|
(c3__helo == u3h(u3t(ovo))) ||
|
|
|
|
(c3__init == u3h(u3t(ovo))) )
|
2013-09-29 00:21:18 +04:00
|
|
|
#endif
|
|
|
|
{
|
2014-11-06 03:20:01 +03:00
|
|
|
u3v_plan(u3nt(u3_blip, c3__term, u3_nul),
|
2014-09-11 04:01:32 +04:00
|
|
|
u3nc(c3__flog, u3k(u3t(ovo))));
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
|
|
|
else {
|
2013-12-19 00:42:29 +04:00
|
|
|
uL(fprintf(uH, "kick: lost %%%s on %s\n",
|
2014-11-06 03:20:01 +03:00
|
|
|
u3r_string(u3h(u3t(ovo))),
|
|
|
|
u3r_string(tox)));
|
2013-09-29 00:21:18 +04:00
|
|
|
#if 0
|
2014-09-11 04:01:32 +04:00
|
|
|
if ( c3__hear == u3h(u3t(ovo)) ) {
|
2013-09-29 00:21:18 +04:00
|
|
|
c3_assert(0);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
#endif
|
2014-09-11 04:01:32 +04:00
|
|
|
u3z(tox);
|
2013-12-19 00:42:29 +04:00
|
|
|
}
|
2014-09-11 04:01:32 +04:00
|
|
|
u3z(ovo);
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|