diff --git a/Makefile b/Makefile index b54a896b3..25c86c5b6 100644 --- a/Makefile +++ b/Makefile @@ -261,7 +261,6 @@ V_OFILES=\ v/loop.o \ v/raft.o \ v/reck.o \ - v/save.o \ v/sist.o \ v/term.o \ v/time.o \ diff --git a/g/a.c b/g/a.c index 0c681b1bc..c96e4ec06 100644 --- a/g/a.c +++ b/g/a.c @@ -1,4 +1,4 @@ -/* n/a.c +/* g/a.c ** ** This file is in the public domain. */ diff --git a/g/h.c b/g/h.c index 51c6e1c9d..ca844ccf9 100644 --- a/g/h.c +++ b/g/h.c @@ -1,4 +1,4 @@ -/* n/h.c +/* g/h.c ** ** This file is in the public domain. */ diff --git a/g/i.c b/g/i.c index d386c1e40..0dc7fd6df 100644 --- a/g/i.c +++ b/g/i.c @@ -1,4 +1,4 @@ -/* n/i.c +/* g/i.c ** ** This file is in the public domain. */ diff --git a/g/j.c b/g/j.c index 385e5c9f3..321ee42f0 100644 --- a/g/j.c +++ b/g/j.c @@ -1,4 +1,4 @@ -/* n/j.c +/* g/j.c ** ** This file is in the public domain. */ diff --git a/g/m.c b/g/m.c index b98f7b6d0..f9a7b51a5 100644 --- a/g/m.c +++ b/g/m.c @@ -1,7 +1,8 @@ -/* c/m.c +/* g/m.c ** ** This file is in the public domain. */ +#include #include #include @@ -9,7 +10,7 @@ /* u3_cm_file(): load file, as atom, or bail. */ -static u3_noun +u3_noun u3_cm_file(c3_c* pas_c) { struct stat buf_b; @@ -111,7 +112,7 @@ u3_cm_boot(c3_p adr_p, c3_w len_w) exit(1); } printf("loom: mapped %dMB\n", (len_w >> 18)); - u3L = map_v; + u3_Loom = map_v; u3H = (u3_cs_home *)_boot_north(map_v, c3_wiseof(u3_cs_home), len_w); u3R = &u3H->rod_u; } @@ -241,10 +242,14 @@ u3_cm_leap() u3_road* rod_u; if ( u3_yes == u3_co_is_north ) { - rod_u = _boot_south(u3R->hat_w, (u3R->cap_w - u3R->hat_w)); + rod_u = _boot_south(u3R->hat_w, + c3_wiseof(u3_cs_road), + (u3R->cap_w - u3R->hat_w)); } else { - rod_u = _boot_north(u3R->cap_w, (u3R->hat_w - u3R->cap_w)); + rod_u = _boot_north(u3R->cap_w, + c3_wiseof(u3_cs_road), + (u3R->hat_w - u3R->cap_w)); } c3_assert(0 == u3R->kid_u); @@ -294,26 +299,25 @@ u3_cm_flog(c3_w gof_w) void u3_cm_water(c3_w* low_w, c3_w* hig_w) { - c3_assert(u3R == u3H); + c3_assert(u3R == &u3H->rod_u); - *low_w = (u3H->hat_w - u3H->rut_w); - *hig_w = (u3H->mat_w - u3H->cap_w) + c3_wiseof(u3_road); + *low_w = (u3H->rod_u.hat_w - u3H->rod_u.rut_w); + *hig_w = (u3H->rod_u.mat_w - u3H->rod_u.cap_w) + c3_wiseof(u3_cs_home); } -/* u2_cm_soft(): system soft wrapper. unifies unix and nock errors. +/* u3_cm_soft(): system soft wrapper. unifies unix and nock errors. ** ** Produces [%$ result] or [%error (list tank)]. */ -u2_noun -u2_cm_soft(c3_w sec_w, u2_funk fun_f, u2_noun arg) +u3_noun +u3_cm_soft(c3_w sec_w, u3_funk fun_f, u3_noun arg) { - u2_noun why_a; + u3_noun why_a; + u3_noun ton; u3_cm_leap(); if ( u3_no == (why_a = u3_cm_trap()) ) { - u3_noun ton; - if ( 0 != u3R->net.nyd ) { c3_assert(0); // XX actually, convert to error } diff --git a/g/n.c b/g/n.c index 7ae0a8a45..5b3c72f61 100644 --- a/g/n.c +++ b/g/n.c @@ -1,4 +1,4 @@ -/* n/n.c +/* g/n.c ** ** This file is in the public domain. */ diff --git a/g/r.c b/g/r.c index 32a5732e4..8e46afda9 100644 --- a/g/r.c +++ b/g/r.c @@ -1,4 +1,4 @@ -/* n/r.c +/* g/r.c ** ** This file is in the public domain. */ diff --git a/g/t.c b/g/t.c index 82fffbb63..4879cbb3c 100644 --- a/g/t.c +++ b/g/t.c @@ -1,4 +1,4 @@ -/* n/t.c +/* g/t.c ** ** This file is in the public domain. */ diff --git a/g/x.c b/g/x.c index 431a17726..68ef124ae 100644 --- a/g/x.c +++ b/g/x.c @@ -1,4 +1,4 @@ -/* n/x.c +/* g/x.c ** ** This file is in the public domain. */ diff --git a/g/z.c b/g/z.c index de938f9d8..9e4782281 100644 --- a/g/z.c +++ b/g/z.c @@ -1,4 +1,4 @@ -/* n/z.c +/* g/z.c ** ** This file is in the public domain. */ diff --git a/gen164/watt.c b/gen164/watt.c deleted file mode 100644 index 408ea136c..000000000 --- a/gen164/watt.c +++ /dev/null @@ -1,277 +0,0 @@ -/* genxxx/watt.c -** -** This file is in the public domain. -*/ -#include "all.h" -#include "pit.h" - - -/* declarations -*/ - /* models - */ - extern u2_ho_jet j2_mbj(PtM, tape)[]; - - /* tier 1 - */ - extern u2_ho_jet j2_mbj(Pt1, add)[]; - extern u2_ho_jet j2_mbj(Pt1, dec)[]; - extern u2_ho_jet j2_mbj(Pt1, div)[]; - extern u2_ho_jet j2_mbj(Pt1, gte)[]; - extern u2_ho_jet j2_mbj(Pt1, gth)[]; - extern u2_ho_jet j2_mbj(Pt1, lte)[]; - extern u2_ho_jet j2_mbj(Pt1, lth)[]; - extern u2_ho_jet j2_mbj(Pt1, mod)[]; - extern u2_ho_jet j2_mbj(Pt1, mul)[]; - extern u2_ho_jet j2_mbj(Pt1, sub)[]; - - /* tier 2 - */ - extern u2_ho_jet j2_mbj(Pt2, bind)[]; - extern u2_ho_jet j2_mbj(Pt2, clap)[]; - extern u2_ho_jet j2_mbj(Pt2, drop)[]; - extern u2_ho_jet j2_mbj(Pt2, flop)[]; - extern u2_ho_jet j2_mbj(Pt2, lent)[]; - extern u2_ho_jet j2_mbj(Pt2, levy)[]; - extern u2_ho_jet j2_mbj(Pt2, lien)[]; - extern u2_ho_jet j2_mbj(Pt2, need)[]; - extern u2_ho_jet j2_mbj(Pt2, reel)[]; - extern u2_ho_jet j2_mbj(Pt2, roll)[]; - extern u2_ho_jet j2_mbj(Pt2, skim)[]; - extern u2_ho_jet j2_mbj(Pt2, skip)[]; - extern u2_ho_jet j2_mbj(Pt2, scag)[]; - extern u2_ho_jet j2_mbj(Pt2, slag)[]; - extern u2_ho_jet j2_mbj(Pt2, snag)[]; - extern u2_ho_jet j2_mbj(Pt2, turn)[]; - extern u2_ho_jet j2_mbj(Pt2, weld)[]; - - /* tier 3 - */ - extern u2_ho_jet j2_mbj(Pt3, bex)[]; - extern u2_ho_jet j2_mbj(Pt3, can)[]; - extern u2_ho_jet j2_mbj(Pt3, cap)[]; - extern u2_ho_jet j2_mbj(Pt3, cat)[]; - extern u2_ho_jet j2_mbj(Pt3, con)[]; - extern u2_ho_jet j2_mbj(Pt3, cut)[]; - extern u2_ho_jet j2_mbj(Pt3, dis)[]; - extern u2_ho_jet j2_mbj(Pt3, dor)[]; - extern u2_ho_jet j2_mbj(Pt3, end)[]; - extern u2_ho_jet j2_mbj(Pt3, gor)[]; - extern u2_ho_jet j2_mbj(Pt3, hor)[]; - extern u2_ho_jet j2_mbj(Pt3, lsh)[]; - extern u2_ho_jet j2_mbj(Pt3, mas)[]; - extern u2_ho_jet j2_mbj(Pt3, met)[]; - extern u2_ho_jet j2_mbj(Pt3, mix)[]; - extern u2_ho_jet j2_mbj(Pt3, mug)[]; - extern u2_ho_jet j2_mbj(Pt3, mum)[]; - extern u2_ho_jet j2_mbj(Pt3, mur)[]; - extern u2_ho_jet j2_mbj(Pt3, peg)[]; - extern u2_ho_jet j2_mbj(Pt3, rap)[]; - extern u2_ho_jet j2_mbj(Pt3, rip)[]; - extern u2_ho_jet j2_mbj(Pt3, ryp)[]; - extern u2_ho_jet j2_mbj(Pt3, rsh)[]; - extern u2_ho_jet j2_mbj(Pt3, vor)[]; - - extern u2_ho_driver j2_mbd(Pt3, po)[]; - - /* tier 4 - */ - extern u2_ho_driver j2_mbd(Pt4, in)[]; - extern u2_ho_driver j2_mbd(Pt4, by)[]; - - /* tier 5 - */ - extern u2_ho_jet j2_mbj(Pt5, cue)[]; - extern u2_ho_jet j2_mbj(Pt5, mat)[]; - extern u2_ho_jet j2_mbj(Pt5, mink)[]; - extern u2_ho_jet j2_mbj(Pt5, mule)[]; - extern u2_ho_jet j2_mbj(Pt5, jam)[]; - extern u2_ho_jet j2_mbj(Pt5, loss)[]; - extern u2_ho_jet j2_mbj(Pt5, lore)[]; - extern u2_ho_jet j2_mbj(Pt5, pfix)[]; - extern u2_ho_jet j2_mbj(Pt5, plug)[]; - extern u2_ho_jet j2_mbj(Pt5, pose)[]; - extern u2_ho_jet j2_mbj(Pt5, repg)[]; - extern u2_ho_jet j2_mbj(Pt5, rexp)[]; - extern u2_ho_jet j2_mbj(Pt5, rub)[]; - extern u2_ho_jet j2_mbj(Pt5, sfix)[]; - extern u2_ho_jet j2_mbj(Pt5, shax)[]; - extern u2_ho_jet j2_mbj(Pt5, tape)[]; - extern u2_ho_jet j2_mbj(Pt5, trip)[]; - - extern u2_ho_driver j2_mbd(Pt5, aesc)[]; - extern u2_ho_driver j2_mbd(Pt5, bend)[]; - extern u2_ho_driver j2_mbd(Pt5, cold)[]; - extern u2_ho_driver j2_mbd(Pt5, comp)[]; - extern u2_ho_driver j2_mbd(Pt5, cook)[]; - extern u2_ho_driver j2_mbd(Pt5, easy)[]; - extern u2_ho_driver j2_mbd(Pt5, coco)[]; - extern u2_ho_driver j2_mbd(Pt5, coed)[]; - extern u2_ho_driver j2_mbd(Pt5, glue)[]; - extern u2_ho_driver j2_mbd(Pt5, here)[]; - extern u2_ho_driver j2_mbd(Pt5, just)[]; - extern u2_ho_driver j2_mbd(Pt5, mask)[]; - extern u2_ho_driver j2_mbd(Pt5, og)[]; - extern u2_ho_driver j2_mbd(Pt5, rd)[]; - extern u2_ho_driver j2_mbd(Pt5, shim)[]; - extern u2_ho_driver j2_mbd(Pt5, stag)[]; - extern u2_ho_driver j2_mbd(Pt5, stew)[]; - extern u2_ho_driver j2_mbd(Pt5, stir)[]; - - /* tier 6 - */ - extern u2_ho_jet j2_mbj(Pt6, bull)[]; - extern u2_ho_jet j2_mbj(Pt6, cell)[]; - extern u2_ho_jet j2_mbj(Pt6, comb)[]; - extern u2_ho_jet j2_mbj(Pt6, cons)[]; - extern u2_ho_jet j2_mbj(Pt6, core)[]; - extern u2_ho_jet j2_mbj(Pt6, cube)[]; - extern u2_ho_jet j2_mbj(Pt6, face)[]; - extern u2_ho_jet j2_mbj(Pt6, fitz)[]; - extern u2_ho_jet j2_mbj(Pt6, flan)[]; - extern u2_ho_jet j2_mbj(Pt6, flip)[]; - extern u2_ho_jet j2_mbj(Pt6, flor)[]; - extern u2_ho_jet j2_mbj(Pt6, fork)[]; - extern u2_ho_jet j2_mbj(Pt6, hike)[]; - extern u2_ho_jet j2_mbj(Pt6, look)[]; - extern u2_ho_jet j2_mbj(Pt6, open)[]; - extern u2_ho_jet j2_mbj(Pt6, rake)[]; - extern u2_ho_jet j2_mbj(Pt6, ream)[]; - extern u2_ho_jet j2_mbj(Pt6, vest)[]; - - extern u2_ho_jet j2_mbj(Pt6, ap)[]; - extern u2_ho_driver j2_mbd(Pt6, ap)[]; - - extern u2_ho_jet j2_mbj(Pt6, ut)[]; - extern u2_ho_driver j2_mbd(Pt6, ut)[]; - -/* structures -*/ - static u2_ho_driver - _watt_drivers_0[], - _watt_drivers_1[], - _watt_drivers_2[]; - - u2_ho_driver - j2_da(Pt0) = { j2_sa(Pt0), 0, _watt_drivers_0, 0, u2_none }; - - static u2_ho_driver - _watt_drivers_0[] = { - { j2_sb(Pt0, mood), 0, _watt_drivers_1, 0, u2_none }, - { } - }; - - static u2_ho_driver - _watt_drivers_1[] = { - { j2_sb(PtM, tape), j2_mbj(PtM, tape), 0, 0, u2_none }, - { j2_sb(PtM, hoon), 0, _watt_drivers_2, 0, u2_none }, - { } - }; - - static u2_ho_driver - _watt_drivers_2[] = { - { j2_sb(Pt1, add), j2_mbj(Pt1, add), 0, 0, u2_none }, - { j2_sb(Pt1, dec), j2_mbj(Pt1, dec), 0, 0, u2_none }, - { j2_sb(Pt1, div), j2_mbj(Pt1, div), 0, 0, u2_none }, - { j2_sb(Pt1, gte), j2_mbj(Pt1, gte), 0, 0, u2_none }, - { j2_sb(Pt1, gth), j2_mbj(Pt1, gth), 0, 0, u2_none }, - { j2_sb(Pt1, lte), j2_mbj(Pt1, lte), 0, 0, u2_none }, - { j2_sb(Pt1, lth), j2_mbj(Pt1, lth), 0, 0, u2_none }, - { j2_sb(Pt1, mod), j2_mbj(Pt1, mod), 0, 0, u2_none }, - { j2_sb(Pt1, mul), j2_mbj(Pt1, mul), 0, 0, u2_none }, - { j2_sb(Pt1, sub), j2_mbj(Pt1, sub), 0, 0, u2_none }, - { j2_sb(Pt2, bind), j2_mbj(Pt2, bind), 0, 0, u2_none }, - { j2_sb(Pt2, clap), j2_mbj(Pt2, clap), 0, 0, u2_none }, - { j2_sb(Pt2, drop), j2_mbj(Pt2, drop), 0, 0, u2_none }, - { j2_sb(Pt2, flop), j2_mbj(Pt2, flop), 0, 0, u2_none }, - { j2_sb(Pt2, lent), j2_mbj(Pt2, lent), 0, 0, u2_none }, - { j2_sb(Pt2, levy), j2_mbj(Pt2, levy), 0, 0, u2_none }, - { j2_sb(Pt2, lien), j2_mbj(Pt2, lien), 0, 0, u2_none }, - { j2_sb(Pt2, need), j2_mbj(Pt2, need), 0, 0, u2_none }, - { j2_sb(Pt2, reel), j2_mbj(Pt2, reel), 0, 0, u2_none }, - { j2_sb(Pt2, roll), j2_mbj(Pt2, roll), 0, 0, u2_none }, - { j2_sb(Pt2, skim), j2_mbj(Pt2, skim), 0, 0, u2_none }, - { j2_sb(Pt2, skip), j2_mbj(Pt2, skip), 0, 0, u2_none }, - { j2_sb(Pt2, scag), j2_mbj(Pt2, scag), 0, 0, u2_none }, - { j2_sb(Pt2, slag), j2_mbj(Pt2, slag), 0, 0, u2_none }, - { j2_sb(Pt2, snag), j2_mbj(Pt2, snag), 0, 0, u2_none }, - { j2_sb(Pt2, turn), j2_mbj(Pt2, turn), 0, 0, u2_none }, - { j2_sb(Pt2, weld), j2_mbj(Pt2, weld), 0, 0, u2_none }, - { j2_sb(Pt3, bex), j2_mbj(Pt3, bex), 0, 0, u2_none }, - { j2_sb(Pt3, can), j2_mbj(Pt3, can), 0, 0, u2_none }, - { j2_sb(Pt3, cap), j2_mbj(Pt3, cap), 0, 0, u2_none }, - { j2_sb(Pt3, cat), j2_mbj(Pt3, cat), 0, 0, u2_none }, - { j2_sb(Pt3, con), j2_mbj(Pt3, con), 0, 0, u2_none }, - { j2_sb(Pt3, cut), j2_mbj(Pt3, cut), 0, 0, u2_none }, - { j2_sb(Pt3, dor), j2_mbj(Pt3, dor), 0, 0, u2_none }, - { j2_sb(Pt3, dis), j2_mbj(Pt3, dis), 0, 0, u2_none }, - { j2_sb(Pt3, end), j2_mbj(Pt3, end), 0, 0, u2_none }, - { j2_sb(Pt3, gor), j2_mbj(Pt3, gor), 0, 0, u2_none }, - { j2_sb(Pt3, hor), j2_mbj(Pt3, hor), 0, 0, u2_none }, - { j2_sb(Pt3, lsh), j2_mbj(Pt3, lsh), 0, 0, u2_none }, - { j2_sb(Pt3, mas), j2_mbj(Pt3, mas), 0, 0, u2_none }, - { j2_sb(Pt3, met), j2_mbj(Pt3, met), 0, 0, u2_none }, - { j2_sb(Pt3, mix), j2_mbj(Pt3, mix), 0, 0, u2_none }, - { j2_sb(Pt3, mug), j2_mbj(Pt3, mug), 0, 0, u2_none }, - { j2_sb(Pt3, mum), j2_mbj(Pt3, mum), 0, 0, u2_none }, - { j2_sb(Pt3, mur), j2_mbj(Pt3, mur), 0, 0, u2_none }, - { j2_sb(Pt3, peg), j2_mbj(Pt3, peg), 0, 0, u2_none }, - { j2_sb(Pt3, rap), j2_mbj(Pt3, rap), 0, 0, u2_none }, - { j2_sb(Pt3, rip), j2_mbj(Pt3, rip), 0, 0, u2_none }, - { j2_sb(Pt3, rsh), j2_mbj(Pt3, rsh), 0, 0, u2_none }, - { j2_sb(Pt3, vor), j2_mbj(Pt3, vor), 0, 0, u2_none }, - { j2_sb(Pt3, po), 0, j2_mbd(Pt3, po), 0, u2_none }, - { j2_sb(Pt4, in), 0, j2_mbd(Pt4, in), 0, u2_none }, - { j2_sb(Pt4, by), 0, j2_mbd(Pt4, by), 0, u2_none }, - { j2_sb(Pt5, aesc), 0, j2_mbd(Pt5, aesc), 0, u2_none }, - { j2_sb(Pt5, bend), 0, j2_mbd(Pt5, bend), 0, u2_none }, - { j2_sb(Pt5, coco), 0, j2_mbd(Pt5, coco), 0, u2_none }, - { j2_sb(Pt5, coed), 0, j2_mbd(Pt5, coed), 0, u2_none }, - { j2_sb(Pt5, cold), 0, j2_mbd(Pt5, cold), 0, u2_none }, - { j2_sb(Pt5, comp), 0, j2_mbd(Pt5, comp), 0, u2_none }, - { j2_sb(Pt5, cook), 0, j2_mbd(Pt5, cook), 0, u2_none }, - { j2_sb(Pt5, cue), j2_mbj(Pt5, cue), 0, 0, u2_none }, - { j2_sb(Pt5, easy), 0, j2_mbd(Pt5, easy), 0, u2_none }, - { j2_sb(Pt5, glue), 0, j2_mbd(Pt5, glue), 0, u2_none }, - { j2_sb(Pt5, here), 0, j2_mbd(Pt5, here), 0, u2_none }, - { j2_sb(Pt5, jam), j2_mbj(Pt5, jam), 0, 0, u2_none }, - { j2_sb(Pt5, loss), j2_mbj(Pt5, loss), 0, 0, u2_none }, - { j2_sb(Pt5, lore), j2_mbj(Pt5, lore), 0, 0, u2_none }, - { j2_sb(Pt5, just), 0, j2_mbd(Pt5, just), 0, u2_none }, - { j2_sb(Pt5, mask), 0, j2_mbd(Pt5, mask), 0, u2_none }, - { j2_sb(Pt5, mat), j2_mbj(Pt5, mat), 0, 0, u2_none }, - { j2_sb(Pt5, mink), j2_mbj(Pt5, mink), 0, 0, u2_none }, - { j2_sb(Pt5, mule), j2_mbj(Pt5, mule), 0, 0, u2_none }, - { j2_sb(Pt5, og), 0, j2_mbd(Pt5, og), 0, u2_none }, - { j2_sb(Pt5, pfix), j2_mbj(Pt5, pfix), 0, 0, u2_none }, - { j2_sb(Pt5, plug), j2_mbj(Pt5, plug), 0, 0, u2_none }, - { j2_sb(Pt5, pose), j2_mbj(Pt5, pose), 0, 0, u2_none }, - { j2_sb(Pt5, rd), 0, j2_mbd(Pt5, rd), 0, u2_none }, - { j2_sb(Pt5, repg), j2_mbj(Pt5, repg), 0, 0, u2_none }, - { j2_sb(Pt5, rexp), j2_mbj(Pt5, rexp), 0, 0, u2_none }, - { j2_sb(Pt5, rub), j2_mbj(Pt5, rub), 0, 0, u2_none }, - { j2_sb(Pt5, sfix), j2_mbj(Pt5, sfix), 0, 0, u2_none }, - { j2_sb(Pt5, shax), j2_mbj(Pt5, shax), 0, 0, u2_none }, - { j2_sb(Pt5, shim), 0, j2_mbd(Pt5, shim), 0, u2_none }, - { j2_sb(Pt5, stag), 0, j2_mbd(Pt5, stag), 0, u2_none }, - { j2_sb(Pt5, stew), 0, j2_mbd(Pt5, stew), 0, u2_none }, - { j2_sb(Pt5, stir), 0, j2_mbd(Pt5, stir), 0, u2_none }, - { j2_sb(Pt5, trip), j2_mbj(Pt5, trip), 0, 0, u2_none }, - { j2_sb(Pt6, bull), j2_mbj(Pt6, bull), 0, 0, u2_none }, - { j2_sb(Pt6, cell), j2_mbj(Pt6, cell), 0, 0, u2_none }, - { j2_sb(Pt6, comb), j2_mbj(Pt6, comb), 0, 0, u2_none }, - { j2_sb(Pt6, cons), j2_mbj(Pt6, cons), 0, 0, u2_none }, - { j2_sb(Pt6, core), j2_mbj(Pt6, core), 0, 0, u2_none }, - { j2_sb(Pt6, cube), j2_mbj(Pt6, cube), 0, 0, u2_none }, - { j2_sb(Pt6, face), j2_mbj(Pt6, face), 0, 0, u2_none }, - { j2_sb(Pt6, fitz), j2_mbj(Pt6, fitz), 0, 0, u2_none }, - { j2_sb(Pt6, flan), j2_mbj(Pt6, flan), 0, 0, u2_none }, - { j2_sb(Pt6, flip), j2_mbj(Pt6, flip), 0, 0, u2_none }, - { j2_sb(Pt6, flor), j2_mbj(Pt6, flor), 0, 0, u2_none }, - { j2_sb(Pt6, fork), j2_mbj(Pt6, fork), 0, 0, u2_none }, - { j2_sb(Pt6, hike), j2_mbj(Pt6, hike), 0, 0, u2_none }, - { j2_sb(Pt6, look), j2_mbj(Pt6, look), 0, 0, u2_none }, - { j2_sb(Pt6, ap), j2_mbj(Pt6, ap), j2_mbd(Pt6, ap), 0, u2_none }, - { j2_sb(Pt6, ut), j2_mbj(Pt6, ut), j2_mbd(Pt6, ut), 0, u2_none }, - { } - }; diff --git a/include/all.h b/include/all.h index 867b0fd9e..db7cd4983 100644 --- a/include/all.h +++ b/include/all.h @@ -65,6 +65,7 @@ # include "g/r.h" # include "g/t.h" # include "g/x.h" +# include "g/v.h" # include "g/z.h" /** j: the u2 layer, jets. diff --git a/include/c/portable.h b/include/c/portable.h index 3d9640b8a..253de031a 100644 --- a/include/c/portable.h +++ b/include/c/portable.h @@ -165,12 +165,12 @@ /* Stat struct */ # if defined(U2_OS_linux) -# define c3_stat_mtime(dp) (u2_time_t_in_ts((dp)->st_mtime)) +# define c3_stat_mtime(dp) (u3_time_t_in_ts((dp)->st_mtime)) # elif defined(U2_OS_osx) -# define c3_stat_mtime(dp) (u2_time_in_ts(&((dp)->st_mtimespec))) +# define c3_stat_mtime(dp) (u3_time_in_ts(&((dp)->st_mtimespec))) # define lseek64 lseek # elif defined(U2_OS_bsd) -# define c3_stat_mtime(dp) (u2_time_in_ts(&((dp)->st_mtim))) +# define c3_stat_mtime(dp) (u3_time_in_ts(&((dp)->st_mtim))) # define lseek64 lseek # else # error "port: timeconvert" diff --git a/include/c/types.h b/include/c/types.h index af4828584..b42ee631e 100644 --- a/include/c/types.h +++ b/include/c/types.h @@ -16,7 +16,7 @@ typedef int8_t c3_ys; // signed byte typedef uint8_t c3_b; // bit - // typedef uint8_t c3_t; // boolean + typedef uint8_t c3_t; // boolean typedef uint8_t c3_o; // loobean typedef uint8_t c3_g; // 32-bit log - 0-31 bits typedef uint32_t c3_l; // little; 31-bit unsigned integer diff --git a/include/n/glob.h b/include/n/glob.h index d2579321d..a22a0d5e2 100644 --- a/include/n/glob.h +++ b/include/n/glob.h @@ -7,13 +7,12 @@ /* u3_Loom: base of loom, as a word pointer. */ c3_global c3_w* u3_Loom; -# define u3L u3_Loom /* u3_Home / u3H: root of thread. Always north. */ c3_global u3_cs_home* u3_Home; # define u3H u3_Home -# define u3A (u3_Home->arv_u) +# define u3A (&(u3_Home->arv_u)) /* u3_Road / u3R: current road (thread-local). */ diff --git a/include/v/vere.h b/include/v/vere.h index 28c5330e7..c6d8d150d 100644 --- a/include/v/vere.h +++ b/include/v/vere.h @@ -555,22 +555,15 @@ u3_bean liv; // if u3_no, shut down c3_i xit_i; // exit code for shutdown void* ssl_u; // struct SSL_CTX* - - u3_reck* arv_u; // runtime } u3_host; // host == computer == process # define u3L u3_Host.lup_u // global event loop -# define u3R (&(u3_Raft)) +# define u3Z (&(u3_Raft)) # define u3S u3_Host.ssl_u - /* u3_funk: standard system function. - */ - typedef u3_noun (*u3_funk)(u3_reck* rec_u, u3_noun); - /** Global variables. **/ c3_global u3_host u3_Host; - c3_global u3_wire u3_Wire; c3_global u3_raft u3_Raft; c3_global c3_c* u3_Local; c3_global c3_c* u3_System; @@ -674,12 +667,12 @@ /* u3_sync_reck(): traverse filesystem for changes -> lamb */ u3_noun - u3_sync_reck(u3_reck* rec_u); + u3_sync_reck(void); /* u3_walk(): traverse `dir_c` to produce an arch, updating `old`. */ u3_noun - u3_walk(u3_reck* rec_u, const c3_c* dir_c, u3_noun old); + u3_walk(const c3_c* dir_c, u3_noun old); /* u3_path(): C unix path in computer for file or directory. */ @@ -722,118 +715,10 @@ void u3_ve_tank(c3_l tab_l, u3_noun tac); - - /** Kernel control. - **/ - /* u3_reck_do(): use a kernel function. - */ -# define u3_do(t, a) u3_reck_do(t, a) -# define u3_dc(t, a1, a2) u3_reck_do(t, u3nc(a1, a2)) -# define u3_dt(t, a1, a2, a3) u3_reck_do(t, u3nt(a1, a2, a3)) -# define u3_dq(t, a1, a2, a3, a4) u3_reck_do(t, u3nq(a1, a2, a3, a4)) - - u3_noun - u3_reck_do(const c3_c* txt_c, u3_noun arg); - - /* u3_reck_line(): apply a reck line (protected). - */ - void - u3_reck_line(u3_reck* rec_u, u3_noun lin); - - /* u3_reck_numb(): set the instance number. - */ - void - u3_reck_numb(u3_reck* rec_u); - - /* u3_reck_http_request(): hear http request on channel. - */ - void - u3_reck_http_request(u3_reck* rec_u, - u3_bean sec, - u3_noun pox, - u3_noun req); - - /* u3_reck_http_respond(): apply http response. - */ - void - u3_reck_http_respond(u3_reck* rec_u, u3_noun pox, u3_noun rep); - - /* u3_reck_boot(): boot the reck engine (unprotected). - */ - void - u3_reck_boot(u3_reck* rec_u); - - /* u3_reck_launch(): launch the reck engine (unprotected). - */ - u3_bean - u3_reck_launch(u3_reck* rec_u); - - /* u3_reck_nick(): transform enveloped packets, [vir cor]. - */ - u3_noun - u3_reck_nick(u3_reck* rec_u, u3_noun vir, u3_noun cor); - - /* u3_reck_peek(): query the reck namespace (protected). - */ - u3_noun - u3_reck_peek(u3_reck* rec_u, u3_noun hap); - - /* u3_reck_keep(): measure timer. - */ - u3_noun - u3_reck_keep(u3_reck* rec_u, u3_noun hap); - - /* u3_reck_pike(): poke with floating core. - */ - u3_noun - u3_reck_pike(u3_reck* rec_u, u3_noun ovo, u3_noun cor); - - /* u3_reck_poke(): insert and apply an input ovum (protected). - */ - u3_noun - u3_reck_poke(u3_reck* rec_u, u3_noun ovo); - - /* u3_reck_prick(): query the reck namespace (unprotected). - */ - u3_noun - u3_reck_prick(u3_reck* rec_u, u3_noun hap); - /* u3_reck_kick(): handle effect. */ void - u3_reck_kick(u3_reck* rec_u, u3_noun ovo); - - /* u3_reck_sync(): poll and apply sync events (protected). - */ - void - u3_reck_sync(u3_reck* rec_u); - - /* u3_reck_time(): set the reck time. - */ - void - u3_reck_time(u3_reck* rec_u); - - /* u3_reck_wind(): set the reck time artificially. - */ - void - u3_reck_wind(u3_reck* rec_u, u3_noun now); - - /* u3_reck_plan(): queue ovum (external). - */ - void - u3_reck_plan(u3_reck* rec_u, - u3_noun pax, - u3_noun fav); - - /* u3_reck_plow(): queue ovum list in order (external). - */ - void - u3_reck_plow(u3_reck* rec_u, u3_noun ova); - - /* u3_reck_work(): flush ova (unprotected). - */ - void - u3_reck_work(u3_reck* rec_u); + u3_reck_kick(u3_noun ovo); /** Main loop, new style. @@ -846,7 +731,7 @@ /* u3_lo_lead(): actions on promotion to leader. */ void - u3_lo_lead(u3_reck* rec_u); + u3_lo_lead(void); /* u3_lo_exit(): shut down io across pier. */ @@ -862,7 +747,7 @@ /* u3_lo_bail(): clean up all event state. */ void - u3_lo_bail(u3_reck* rec_u); + u3_lo_bail(void); /* u3_lo_tank(): dump single tank. */ @@ -879,13 +764,6 @@ void u3_lo_sway(c3_l tab_l, u3_noun tax); - /* u3_lo_soft(): standard soft wrapper. Unifies unix and nock errors. - ** - ** Produces [%$ result] or %error (list tank)]. - */ - u3_noun - u3_lo_soft(u3_reck* rec_u, c3_w sec_w, u3_funk fun_f, u3_noun arg); - /* u3_lo_grab(): garbage-collect the world, plus roots; end with u3_none */ void @@ -1152,7 +1030,8 @@ /* u3_raft_work(): poke, kick, and push pending events. */ void - u3_raft_work(u3_reck* rec_u); + u3_raft_work(void); + /** Disk persistence. **/ @@ -1171,8 +1050,7 @@ ** Returns the entry's sequence number. */ c3_d - u3_sist_pack(u3_reck* rec_u, - c3_w tem_w, + u3_sist_pack(c3_w tem_w, c3_w typ_w, c3_w* bob_w, c3_w len_w); diff --git a/j/5/parse.c b/j/5/parse.c index ce0ef1a08..44b2c6c61 100644 --- a/j/5/parse.c +++ b/j/5/parse.c @@ -904,13 +904,13 @@ else { u3_noun n_hel, l_hel, r_hel; u3_noun pn_hel, qn_hel; - c3_t bit_t; + c3_o bit_o; u3_cx_trel(hel, &n_hel, &l_hel, &r_hel); u3_cx_cell(n_hel, &pn_hel, &qn_hel); if ( (u3_no == u3du(pn_hel)) ) { - bit_t = (iq_tub == pn_hel); + bit_o = u3_say((iq_tub == pn_hel)); } else { u3_noun hpn_hel = u3h(pn_hel); @@ -920,10 +920,10 @@ u3_ne(u3_co_is_cat(tpn_hel)) ) { return _fail(tub); } - else bit_t = (iq_tub >= hpn_hel) && (iq_tub <= tpn_hel); + else bit_o = u3_say((iq_tub >= hpn_hel) && (iq_tub <= tpn_hel)); } - if ( bit_t ) { + if ( u3_yes == bit_o ) { return u3_cx_good (u3_cn_slam_on(u3k(qn_hel), u3k(tub))); } else { diff --git a/v/ames.c b/v/ames.c index 63657ab9a..673dbbc23 100644 --- a/v/ames.c +++ b/v/ames.c @@ -49,9 +49,9 @@ _ames_free(void* ptr_v) static c3_w _ames_czar(c3_y imp_y, c3_s* por_s) { - u2_ames* sam_u = &u2_Host.sam_u; + u3_ames* sam_u = &u3_Host.sam_u; - if ( u2_yes == u2_Host.ops_u.loh ) { + if ( u3_yes == u3_Host.ops_u.loh ) { *por_s = 31337 + imp_y; return 0x7f000001; } @@ -62,14 +62,14 @@ _ames_czar(c3_y imp_y, c3_s* por_s) return 0; } else if ( 0 == sam_u->imp_w[imp_y] ) { - u2_noun nam = u2_dc("scot", 'p', imp_y); - c3_c* nam_c = u2_cr_string(nam); + u3_noun nam = u3_dc("scot", 'p', imp_y); + c3_c* nam_c = u3_cr_string(nam); c3_c dns_c[64]; snprintf(dns_c, 64, "%s.urbit.org", nam_c + 1); // uL(fprintf(uH, "czar %s, dns %s\n", nam_c, dns_c)); free(nam_c); - u2z(nam); + u3z(nam); { struct addrinfo* air_u; @@ -95,13 +95,13 @@ _ames_czar(c3_y imp_y, c3_s* por_s) sam_u->imp_w[imp_y] = ntohl(add_u->sin_addr.s_addr); #if 1 { - u2_noun wad = u2_ci_words(1, &sam_u->imp_w[imp_y]); - u2_noun nam = u2_dc("scot", c3__if, wad); - c3_c* nam_c = u2_cr_string(nam); + u3_noun wad = u3_ci_words(1, &sam_u->imp_w[imp_y]); + u3_noun nam = u3_dc("scot", c3__if, wad); + c3_c* nam_c = u3_cr_string(nam); uL(fprintf(uH, "ames: czar %s: ip %s\n", dns_c, nam_c)); - free(nam_c); u2z(nam); + free(nam_c); u3z(nam); } #endif break; @@ -118,30 +118,30 @@ _ames_czar(c3_y imp_y, c3_s* por_s) /* _ames_lane_ipv4(): IPv4 address/ from lane. */ -u2_bean -_ames_lane_ip(u2_noun lan, c3_s* por_s, c3_w* pip_w) +u3_bean +_ames_lane_ip(u3_noun lan, c3_s* por_s, c3_w* pip_w) { - switch ( u2h(lan) ) { + switch ( u3h(lan) ) { case c3__if: { - *por_s= (c3_s) u2h(u2t(u2t(lan))); - *pip_w = u2_cr_word(0, u2t(u2t(u2t(lan)))); + *por_s= (c3_s) u3h(u3t(u3t(lan))); + *pip_w = u3_cr_word(0, u3t(u3t(u3t(lan)))); - return u2_yes; + return u3_yes; } break; case c3__is: { - u2_noun pq_lan = u2h(u2t(u2t(lan))); + u3_noun pq_lan = u3h(u3t(u3t(lan))); - if ( u2_nul == pq_lan ) return u2_no; - else return _ames_lane_ip(u2t(pq_lan), por_s, pip_w); + if ( u3_nul == pq_lan ) return u3_no; + else return _ames_lane_ip(u3t(pq_lan), por_s, pip_w); } break; case c3__ix: { - *por_s = (c3_s) u2h(u2t(u2t(lan))); - *pip_w = u2_cr_word(0, u2t(u2t(u2t(lan)))); + *por_s = (c3_s) u3h(u3t(u3t(lan))); + *pip_w = u3_cr_word(0, u3t(u3t(u3t(lan)))); - return u2_yes; + return u3_yes; } break; } - return u2_no; + return u3_no; } /* An unusual lameness in libuv. @@ -149,18 +149,18 @@ _ames_lane_ip(u2_noun lan, c3_s* por_s, c3_w* pip_w) typedef struct { uv_udp_send_t snd_u; c3_y* buf_y; - } _u2_udp_send_t; + } _u3_udp_send_t; /* _ames_send_cb(): send callback. */ static void _ames_send_cb(uv_udp_send_t* req_u, c3_i sas_i) { - _u2_udp_send_t* ruq_u = (void*)req_u; + _u3_udp_send_t* ruq_u = (void*)req_u; #if 0 if ( 0 != sas_i ) { - uL(fprintf(uH, "ames: send_cb: %s\n", uv_strerror(uv_last_error(u2L)))); + uL(fprintf(uH, "ames: send_cb: %s\n", uv_strerror(uv_last_error(u3L)))); } #endif // fprintf(stderr, "ames: tx\r\n"); @@ -169,36 +169,36 @@ _ames_send_cb(uv_udp_send_t* req_u, c3_i sas_i) } void -u2_ames_ef_bake(void) +u3_ames_ef_bake(void) { - u2_noun pax = u2nq(u2_blip, c3__newt, u2k(u2A->sen), u2_nul); + u3_noun pax = u3nq(u3_blip, c3__newt, u3k(u3A->sen), u3_nul); - u2_reck_plan(u2A, pax, u2nc(c3__barn, u2_nul)); + u3_cv_plan(pax, u3nc(c3__barn, u3_nul)); } -/* u2_ames_ef_send(): send packet to network (v4). +/* u3_ames_ef_send(): send packet to network (v4). */ void -u2_ames_ef_send(u2_noun lan, u2_noun pac) +u3_ames_ef_send(u3_noun lan, u3_noun pac) { - u2_ames* sam_u = &u2_Host.sam_u; + u3_ames* sam_u = &u3_Host.sam_u; c3_s por_s; c3_w pip_w; - if ( u2_Host.ops_u.fuz_w && ((rand() % 100) < u2_Host.ops_u.fuz_w) ) { - u2z(pac); + if ( u3_Host.ops_u.fuz_w && ((rand() % 100) < u3_Host.ops_u.fuz_w) ) { + u3z(pac); return; } - if ( u2_yes == _ames_lane_ip(lan, &por_s, &pip_w) ) { - c3_w len_w = u2_cr_met(3, pac); + if ( u3_yes == _ames_lane_ip(lan, &por_s, &pip_w) ) { + c3_w len_w = u3_cr_met(3, pac); c3_y* buf_y = c3_malloc(len_w); - u2_cr_bytes(0, len_w, buf_y, pac); + u3_cr_bytes(0, len_w, buf_y, pac); if ( 0 == pip_w ) { pip_w = 0x7f000001; - por_s = u2_Host.sam_u.por_s; + por_s = u3_Host.sam_u.por_s; } { struct sockaddr_in add_u; @@ -211,7 +211,7 @@ u2_ames_ef_send(u2_noun lan, u2_noun pac) if ( 0 != pip_w ) { uv_buf_t buf_u = uv_buf_init((c3_c*)buf_y, len_w); - _u2_udp_send_t* ruq_u = c3_malloc(sizeof(_u2_udp_send_t)); + _u3_udp_send_t* ruq_u = c3_malloc(sizeof(_u3_udp_send_t)); ruq_u->buf_y = buf_y; @@ -232,7 +232,7 @@ u2_ames_ef_send(u2_noun lan, u2_noun pac) } } } - u2z(lan); u2z(pac); + u3z(lan); u3z(pac); } /* _ames_time_cb(): timer callback. @@ -240,17 +240,16 @@ u2_ames_ef_send(u2_noun lan, u2_noun pac) static void _ames_time_cb(uv_timer_t* tim_uo) { - u2_ames* sam_u = &u2_Host.sam_u; - u2_lo_open(); + u3_ames* sam_u = &u3_Host.sam_u; + u3_lo_open(); sam_u->law_w = time(0); { - u2_reck_plan - (u2A, - u2nt(u2_blip, c3__ames, u2_nul), - u2nc(c3__wake, u2_nul)); + u3_cv_plan + (u3nt(u3_blip, c3__ames, u3_nul), + u3nc(c3__wake, u3_nul)); } - u2_lo_shut(u2_no); + u3_lo_shut(u3_no); } /* _ames_recv_cb(): receive callback. @@ -268,53 +267,52 @@ _ames_recv_cb(uv_udp_t* wax_u, _ames_free(buf_u->base); } else { - u2_lo_open(); + u3_lo_open(); { struct sockaddr_in* add_u = (struct sockaddr_in *)adr_u; - u2_noun msg = u2_ci_bytes((c3_w)nrd_i, (c3_y*)buf_u->base); + u3_noun msg = u3_ci_bytes((c3_w)nrd_i, (c3_y*)buf_u->base); c3_s por_s = ntohs(add_u->sin_port); c3_w pip_w = ntohl(add_u->sin_addr.s_addr); // fprintf(stderr, "ames: plan\r\n"); - u2_reck_plan - (u2A, - u2nt(u2_blip, c3__ames, u2_nul), - u2nt(c3__hear, - u2nq(c3__if, u2k(u2A->now), por_s, u2_ci_words(1, &pip_w)), + u3_cv_plan + (u3nt(u3_blip, c3__ames, u3_nul), + u3nt(c3__hear, + u3nq(c3__if, u3k(u3A->now), por_s, u3_ci_words(1, &pip_w)), msg)); } _ames_free(buf_u->base); - u2_lo_shut(u2_yes); + u3_lo_shut(u3_yes); } } -/* u2_ames_io_init(): initialize ames I/O. +/* u3_ames_io_init(): initialize ames I/O. */ void -u2_ames_io_init() +u3_ames_io_init() { - u2_ames* sam_u = &u2_Host.sam_u; + u3_ames* sam_u = &u3_Host.sam_u; c3_s por_s; - por_s = u2_Host.ops_u.por_s; - if ( 0 != u2_Host.ops_u.imp_c ) { - u2_noun imp = u2_ci_string(u2_Host.ops_u.imp_c); - u2_noun num = u2_dc("slaw", 'p', imp); + por_s = u3_Host.ops_u.por_s; + if ( 0 != u3_Host.ops_u.imp_c ) { + u3_noun imp = u3_ci_string(u3_Host.ops_u.imp_c); + u3_noun num = u3_dc("slaw", 'p', imp); c3_y num_y; - if ( u2_no == u2du(num) ) { - uL(fprintf(uH, "malformed emperor: %s\n", u2_Host.ops_u.imp_c)); + if ( u3_no == u3du(num) ) { + uL(fprintf(uH, "malformed emperor: %s\n", u3_Host.ops_u.imp_c)); exit(1); } - num_y = u2_cr_byte(0, u2t(num)); + num_y = u3_cr_byte(0, u3t(num)); _ames_czar(num_y, &por_s); - uL(fprintf(uH, "ames: czar: %s on %d\n", u2_Host.ops_u.imp_c, por_s)); - u2z(num); + uL(fprintf(uH, "ames: czar: %s on %d\n", u3_Host.ops_u.imp_c, por_s)); + u3z(num); } int ret; - if ( 0 != (ret = uv_udp_init(u2L, &u2_Host.sam_u.wax_u)) ) { + if ( 0 != (ret = uv_udp_init(u3L, &u3_Host.sam_u.wax_u)) ) { uL(fprintf(uH, "ames: init: %s\n", uv_strerror(ret))); c3_assert(0); } @@ -347,61 +345,61 @@ u2_ames_io_init() // Timer too. { - uv_timer_init(u2L, &sam_u->tim_u); + uv_timer_init(u3L, &sam_u->tim_u); } } -/* u2_ames_io_talk(): start receiving ames traffic. +/* u3_ames_io_talk(): start receiving ames traffic. */ void -u2_ames_io_talk() +u3_ames_io_talk() { - u2_ames* sam_u = &u2_Host.sam_u; + u3_ames* sam_u = &u3_Host.sam_u; uL(fprintf(uH, "ames: on localhost, UDP %d.\n", sam_u->por_s)); uv_udp_recv_start(&sam_u->wax_u, _ames_alloc, _ames_recv_cb); } -/* u2_ames_io_exit(): terminate ames I/O. +/* u3_ames_io_exit(): terminate ames I/O. */ void -u2_ames_io_exit() +u3_ames_io_exit() { - u2_ames* sam_u = &u2_Host.sam_u; + u3_ames* sam_u = &u3_Host.sam_u; uv_close((uv_handle_t*)&sam_u->wax_u, 0); } -/* u2_ames_io_poll(): update ames IO state. +/* u3_ames_io_poll(): update ames IO state. */ void -u2_ames_io_poll() +u3_ames_io_poll() { - u2_ames* sam_u = &u2_Host.sam_u; - u2_noun wen = u2_reck_keep(u2A, u2nt(u2_blip, c3__ames, u2_nul)); + u3_ames* sam_u = &u3_Host.sam_u; + u3_noun wen = u3_cv_keep(u3nt(u3_blip, c3__ames, u3_nul)); - if ( (u2_nul != wen) && - (u2_yes == u2du(wen)) && - (u2_yes == u2ud(u2t(wen))) ) + if ( (u3_nul != wen) && + (u3_yes == u3du(wen)) && + (u3_yes == u3ud(u3t(wen))) ) { - c3_d gap_d = u2_time_gap_ms(u2k(u2A->now), u2k(u2t(wen))); + c3_d gap_d = u3_time_gap_ms(u3k(u3A->now), u3k(u3t(wen))); c3_w lem_w = (time(0) - sam_u->law_w); c3_w lef_w = (lem_w > 32) ? 0 : (32 - lem_w); gap_d = c3_min(gap_d, (c3_d)(1000 * lef_w)); - if ( u2_yes == sam_u->alm ) { + if ( u3_yes == sam_u->alm ) { uv_timer_stop(&sam_u->tim_u); } - else sam_u->alm = u2_yes; + else sam_u->alm = u3_yes; uv_timer_start(&sam_u->tim_u, _ames_time_cb, gap_d, 0); } else { - if ( u2_yes == sam_u->alm ) { + if ( u3_yes == sam_u->alm ) { uv_timer_stop(&sam_u->tim_u); } - sam_u->alm = u2_no; + sam_u->alm = u3_no; } - u2z(wen); + u3z(wen); } diff --git a/v/batz.c b/v/batz.c index af3ea3863..74f6c0171 100644 --- a/v/batz.c +++ b/v/batz.c @@ -19,24 +19,23 @@ #include #include "all.h" -#include "f/coal.h" #include "v/vere.h" -/* u2_batz_io_init(): initialize batz timer. +/* u3_batz_io_init(): initialize batz timer. */ void -u2_batz_io_init(void) +u3_batz_io_init(void) { - u2_batz* beh_u = &u2_Host.beh_u; + u3_batz* beh_u = &u3_Host.beh_u; - uv_timer_init(u2L, &beh_u->tim_u); - beh_u->alm = u2_no; + uv_timer_init(u3L, &beh_u->tim_u); + beh_u->alm = u3_no; } -/* u2_batz_io_exit(): terminate timer. +/* u3_batz_io_exit(): terminate timer. */ void -u2_batz_io_exit(void) +u3_batz_io_exit(void) { } @@ -45,49 +44,48 @@ u2_batz_io_exit(void) static void _batz_time_cb(uv_timer_t* tim_u) { - u2_batz* beh_u = &u2_Host.beh_u; + u3_batz* beh_u = &u3_Host.beh_u; if(beh_u->run_w < 1024) { beh_u->run_w++; } - u2_lo_open(); + u3_lo_open(); { - u2_reck_plan - (u2A, - u2nt(u2_blip, c3__batz, u2_nul), - u2nc(c3__wake, u2_nul)); + u3_cv_plan + (u3nt(u3_blip, c3__batz, u3_nul), + u3nc(c3__wake, u3_nul)); } - u2_lo_shut(u2_no); + u3_lo_shut(u3_no); } -/* u2_batz_io_poll(): update batz IO state. +/* u3_batz_io_poll(): update batz IO state. */ void -u2_batz_io_poll(void) +u3_batz_io_poll(void) { - u2_batz* beh_u = &u2_Host.beh_u; - u2_noun wen = u2_reck_keep(u2A, u2nt(u2_blip, c3__batz, u2_nul)); + u3_batz* beh_u = &u3_Host.beh_u; + u3_noun wen = u3_cv_keep(u3nt(u3_blip, c3__batz, u3_nul)); - if ( (u2_nul != wen) && - (u2_yes == u2du(wen)) && - (u2_yes == u2ud(u2t(wen))) ) + if ( (u3_nul != wen) && + (u3_yes == u3du(wen)) && + (u3_yes == u3ud(u3t(wen))) ) { - c3_d gap_d = u2_time_gap_ms(u2k(u2A->now), u2k(u2t(wen))); + c3_d gap_d = u3_time_gap_ms(u3k(u3A->now), u3k(u3t(wen))); gap_d += beh_u->run_w; - if ( u2_yes == beh_u->alm ) { + if ( u3_yes == beh_u->alm ) { uv_timer_stop(&beh_u->tim_u); } - else beh_u->alm = u2_yes; + else beh_u->alm = u3_yes; uv_timer_start(&beh_u->tim_u, _batz_time_cb, gap_d, 0); } else { - if ( u2_yes == beh_u->alm ) { + if ( u3_yes == beh_u->alm ) { uv_timer_stop(&beh_u->tim_u); } - beh_u->alm = u2_no; + beh_u->alm = u3_no; } - u2z(wen); + u3z(wen); } diff --git a/v/cttp.c b/v/cttp.c index 2251aa0b3..edb0c9374 100644 --- a/v/cttp.c +++ b/v/cttp.c @@ -36,13 +36,13 @@ /* Forward declarations. */ - static void _cttp_ccon_kick(u2_ccon* coc_u); - static void _cttp_ccon_cryp_hurr(u2_ccon* coc_u, c3_i rev_i); - static void _cttp_ccon_cryp_rout(u2_ccon* coc_u); - static void _cttp_ccon_fill(u2_ccon* coc_u); - static void _cttp_ccon_fire(u2_ccon* coc_u, u2_creq* ceq_u); + static void _cttp_ccon_kick(u3_ccon* coc_u); + static void _cttp_ccon_cryp_hurr(u3_ccon* coc_u, c3_i rev_i); + static void _cttp_ccon_cryp_rout(u3_ccon* coc_u); + static void _cttp_ccon_fill(u3_ccon* coc_u); + static void _cttp_ccon_fire(u3_ccon* coc_u, u3_creq* ceq_u); static void _cttp_ccon_fail_cb(uv_handle_t* wax_u); - static c3_c* _cttp_creq_url(u2_noun pul); + static c3_c* _cttp_creq_url(u3_noun pul); /* _cttp_alloc(): libuv buffer allocator. */ @@ -56,10 +56,10 @@ _cttp_alloc(uv_handle_t* had_u, size_t len_i, uv_buf_t* buf ) /* _cttp_bod(): create a data buffer. */ -static u2_hbod* +static u3_hbod* _cttp_bod(c3_w len_w, const c3_y* hun_y) { - u2_hbod* bod_u = c3_malloc(len_w + sizeof(*bod_u)); + u3_hbod* bod_u = c3_malloc(len_w + sizeof(*bod_u)); bod_u->len_w = len_w; memcpy(bod_u->hun_y, hun_y, len_w); @@ -70,13 +70,13 @@ _cttp_bod(c3_w len_w, const c3_y* hun_y) /* _cttp_bud(): create a header buffer. Not null-terminated! */ -static u2_hbod* +static u3_hbod* _cttp_bud(c3_c* nam_c, c3_c* val_c) { c3_w lnm_w = strlen(nam_c); c3_w lvl_w = strlen(val_c); c3_w len_w = lnm_w + 2 + lvl_w + 2; - u2_hbod* bod_u = c3_malloc(len_w + sizeof(*bod_u)); + u3_hbod* bod_u = c3_malloc(len_w + sizeof(*bod_u)); strncpy((c3_c *)bod_u->hun_y, nam_c, lnm_w); strncpy((c3_c *)bod_u->hun_y + lnm_w, ": ", 2); @@ -91,14 +91,14 @@ _cttp_bud(c3_c* nam_c, c3_c* val_c) /* _cttp_heds_to_list(): C headers to list. */ -static u2_noun -_cttp_heds_to_list(u2_hhed* hed_u) +static u3_noun +_cttp_heds_to_list(u3_hhed* hed_u) { if ( 0 == hed_u ) { - return u2_nul; + return u3_nul; } else { - return u2nc(u2nc(u2_ci_string(hed_u->nam_c), - hed_u->val_c ? u2_ci_string(hed_u->val_c) : u2_nul), + return u3nc(u3nc(u3_ci_string(hed_u->nam_c), + hed_u->val_c ? u3_ci_string(hed_u->val_c) : u3_nul), _cttp_heds_to_list(hed_u->nex_u)); } } @@ -106,10 +106,10 @@ _cttp_heds_to_list(u2_hhed* hed_u) /* _cttp_heds_free(): free header structure. */ static void -_cttp_heds_free(u2_hhed* hed_u) +_cttp_heds_free(u3_hhed* hed_u) { while ( hed_u ) { - u2_hhed* nex_u = hed_u->nex_u; + u3_hhed* nex_u = hed_u->nex_u; if ( hed_u->nam_c ) free(hed_u->nam_c); if ( hed_u->val_c ) free(hed_u->val_c); @@ -122,10 +122,10 @@ _cttp_heds_free(u2_hhed* hed_u) /* _cttp_bods_free(): free body structure. */ static void -_cttp_bods_free(u2_hbod* bod_u) +_cttp_bods_free(u3_hbod* bod_u) { while ( bod_u ) { - u2_hbod* nex_u = bod_u->nex_u; + u3_hbod* nex_u = bod_u->nex_u; free(bod_u); bod_u = nex_u; @@ -134,15 +134,15 @@ _cttp_bods_free(u2_hbod* bod_u) /* _cttp_bods_to_octs: translate body into octet-stream noun. */ -static u2_noun -_cttp_bods_to_octs(u2_hbod* bod_u) +static u3_noun +_cttp_bods_to_octs(u3_hbod* bod_u) { c3_w len_w; c3_y* buf_y; - u2_noun cos; + u3_noun cos; { - u2_hbod* bid_u; + u3_hbod* bid_u; len_w = 0; for ( bid_u = bod_u; bid_u; bid_u = bid_u->nex_u ) { @@ -160,80 +160,80 @@ _cttp_bods_to_octs(u2_hbod* bod_u) bod_u = bod_u->nex_u; } } - cos = u2_ci_bytes(len_w, buf_y); + cos = u3_ci_bytes(len_w, buf_y); free(buf_y); - return u2nc(len_w, cos); + return u3nc(len_w, cos); } /* _cttp_heds_list(): create headers from list. */ -static u2_hhed* -_cttp_heds_list(u2_hhed* hed_u, u2_noun nam, u2_noun vaz) +static u3_hhed* +_cttp_heds_list(u3_hhed* hed_u, u3_noun nam, u3_noun vaz) { - u2_noun viz = vaz; + u3_noun viz = vaz; - while ( u2_nul != viz ) { - u2_hhed* deh_u; + while ( u3_nul != viz ) { + u3_hhed* deh_u; deh_u = c3_malloc(sizeof(*deh_u)); - deh_u->nam_c = u2_cr_string(nam); - deh_u->val_c = u2_cr_string(u2h(viz)); + deh_u->nam_c = u3_cr_string(nam); + deh_u->val_c = u3_cr_string(u3h(viz)); deh_u->nex_u = hed_u; hed_u = deh_u; - viz = u2t(viz); + viz = u3t(viz); } - u2z(nam); - u2z(vaz); + u3z(nam); + u3z(vaz); return hed_u; } /* _cttp_heds_math(): create headers from noun. */ -static u2_hhed* -_cttp_heds_math(u2_hhed* hed_u, u2_noun mah) +static u3_hhed* +_cttp_heds_math(u3_hhed* hed_u, u3_noun mah) { - if ( u2_nul == mah ) { + if ( u3_nul == mah ) { return hed_u; } else { - u2_noun n_mah = u2h(mah); - u2_noun pn_mah = u2h(n_mah); - u2_noun qn_mah = u2t(n_mah); - u2_noun l_mah = u2h(u2t(mah)); - u2_noun r_mah = u2t(u2t(mah)); + u3_noun n_mah = u3h(mah); + u3_noun pn_mah = u3h(n_mah); + u3_noun qn_mah = u3t(n_mah); + u3_noun l_mah = u3h(u3t(mah)); + u3_noun r_mah = u3t(u3t(mah)); - hed_u = _cttp_heds_list(hed_u, u2k(pn_mah), u2k(qn_mah)); - hed_u = _cttp_heds_math(hed_u, u2k(l_mah)); - hed_u = _cttp_heds_math(hed_u, u2k(r_mah)); + hed_u = _cttp_heds_list(hed_u, u3k(pn_mah), u3k(qn_mah)); + hed_u = _cttp_heds_math(hed_u, u3k(l_mah)); + hed_u = _cttp_heds_math(hed_u, u3k(r_mah)); - u2z(mah); + u3z(mah); return hed_u; } } /* _cttp_octs_to_bod(): translate octet-stream noun into body. */ -static u2_hbod* -_cttp_octs_to_bod(u2_noun oct) +static u3_hbod* +_cttp_octs_to_bod(u3_noun oct) { c3_w len_w; - if ( !u2_fly_is_cat(u2h(oct)) ) { // 2GB max - u2_cm_bail(c3__fail); return 0; + if ( u3_ne(u3_co_is_cat(u3h(oct))) ) { // 2GB max + u3_cm_bail(c3__fail); return 0; } - len_w = u2h(oct); + len_w = u3h(oct); { - u2_hbod* bod_u = c3_malloc(len_w + sizeof(*bod_u)); + u3_hbod* bod_u = c3_malloc(len_w + sizeof(*bod_u)); bod_u->len_w = len_w; - u2_cr_bytes(0, len_w, bod_u->hun_y, u2t(oct)); + u3_cr_bytes(0, len_w, bod_u->hun_y, u3t(oct)); bod_u->nex_u = 0; - u2z(oct); + u3z(oct); return bod_u; } } @@ -265,48 +265,48 @@ _cttp_mcut_str(c3_c* buf_c, c3_w len_w, const c3_c* str_c) /* _cttp_mcut_span(): measure/cut span. */ static c3_w -_cttp_mcut_span(c3_c* buf_c, c3_w len_w, u2_noun san) +_cttp_mcut_span(c3_c* buf_c, c3_w len_w, u3_noun san) { - c3_w ten_w = u2_cr_met(3, san); + c3_w ten_w = u3_cr_met(3, san); if ( buf_c ) { - u2_cr_bytes(0, ten_w, (c3_y *)(buf_c + len_w), san); + u3_cr_bytes(0, ten_w, (c3_y *)(buf_c + len_w), san); } - u2z(san); + u3z(san); return (len_w + ten_w); } /* _cttp_mcut_path(): measure/cut span list. */ static c3_w -_cttp_mcut_path(c3_c* buf_c, c3_w len_w, c3_c sep_c, u2_noun pax) +_cttp_mcut_path(c3_c* buf_c, c3_w len_w, c3_c sep_c, u3_noun pax) { - u2_noun axp = pax; + u3_noun axp = pax; - while ( u2_nul != axp ) { - u2_noun h_axp = u2h(axp); + while ( u3_nul != axp ) { + u3_noun h_axp = u3h(axp); - len_w = _cttp_mcut_span(buf_c, len_w, u2k(h_axp)); - axp = u2t(axp); + len_w = _cttp_mcut_span(buf_c, len_w, u3k(h_axp)); + axp = u3t(axp); - if ( u2_nul != axp ) { + if ( u3_nul != axp ) { len_w = _cttp_mcut_char(buf_c, len_w, sep_c); } } - u2z(pax); + u3z(pax); return len_w; } /* _cttp_mcut_host(): measure/cut host. */ static c3_w -_cttp_mcut_host(c3_c* buf_c, c3_w len_w, u2_noun hot) +_cttp_mcut_host(c3_c* buf_c, c3_w len_w, u3_noun hot) { - if ( u2_yes == u2h(hot) ) { - len_w = _cttp_mcut_path(buf_c, len_w, '.', u2_ckb_flop(u2k(u2t(hot)))); + if ( u3_yes == u3h(hot) ) { + len_w = _cttp_mcut_path(buf_c, len_w, '.', u3_ckb_flop(u3k(u3t(hot)))); } else { - c3_w ipf_w = u2_cr_word(0, u2t(hot)); + c3_w ipf_w = u3_cr_word(0, u3t(hot)); c3_c ipf_c[17]; snprintf(ipf_c, 16, "%d.%d.%d.%d", (ipf_w >> 24), @@ -315,7 +315,7 @@ _cttp_mcut_host(c3_c* buf_c, c3_w len_w, u2_noun hot) (ipf_w & 255)); len_w = _cttp_mcut_str(buf_c, len_w, ipf_c); } - u2z(hot); + u3z(hot); return len_w; } @@ -323,27 +323,27 @@ _cttp_mcut_host(c3_c* buf_c, c3_w len_w, u2_noun hot) /* _cttp_mcut_pfix(): measure/cut prefix. */ static c3_w -_cttp_mcut_pfix(c3_c* buf_c, c3_w len_w, u2_noun hat) +_cttp_mcut_pfix(c3_c* buf_c, c3_w len_w, u3_noun hat) { - u2_noun p_hat = u2h(hat); - u2_noun q_hat = u2h(u2t(hat)); - u2_noun r_hat = u2t(u2t(hat)); + u3_noun p_hat = u3h(hat); + u3_noun q_hat = u3h(u3t(hat)); + u3_noun r_hat = u3t(u3t(hat)); - if ( u2_yes == p_hat ) { + if ( u3_yes == p_hat ) { len_w = _cttp_mcut_str(buf_c, len_w, "https://"); } else { len_w = _cttp_mcut_str(buf_c, len_w, "http://"); } - len_w = _cttp_mcut_host(buf_c, len_w, u2k(r_hat)); + len_w = _cttp_mcut_host(buf_c, len_w, u3k(r_hat)); - if ( u2_nul != q_hat ) { - c3_w por_w = 0xffff & u2_cr_word(0, u2t(q_hat)); + if ( u3_nul != q_hat ) { + c3_w por_w = 0xffff & u3_cr_word(0, u3t(q_hat)); c3_c por_c[8]; snprintf(por_c, 7, ":%d", por_w); len_w = _cttp_mcut_str(buf_c, len_w, por_c); } - u2z(hat); + u3z(hat); return len_w; } #endif @@ -351,71 +351,71 @@ _cttp_mcut_pfix(c3_c* buf_c, c3_w len_w, u2_noun hat) /* _cttp_mcut_pork(): measure/cut path/extension. */ static c3_w -_cttp_mcut_pork(c3_c* buf_c, c3_w len_w, u2_noun pok) +_cttp_mcut_pork(c3_c* buf_c, c3_w len_w, u3_noun pok) { - u2_noun h_pok = u2h(pok); - u2_noun t_pok = u2t(pok); + u3_noun h_pok = u3h(pok); + u3_noun t_pok = u3t(pok); - len_w = _cttp_mcut_path(buf_c, len_w, '/', u2k(t_pok)); - if ( u2_nul != h_pok ) { + len_w = _cttp_mcut_path(buf_c, len_w, '/', u3k(t_pok)); + if ( u3_nul != h_pok ) { len_w = _cttp_mcut_char(buf_c, len_w, '.'); - len_w = _cttp_mcut_span(buf_c, len_w, u2k(u2t(h_pok))); + len_w = _cttp_mcut_span(buf_c, len_w, u3k(u3t(h_pok))); } - u2z(pok); + u3z(pok); return len_w; } /* _cttp_mcut_quay(): measure/cut query. */ static c3_w -_cttp_mcut_quay(c3_c* buf_c, c3_w len_w, u2_noun quy) +_cttp_mcut_quay(c3_c* buf_c, c3_w len_w, u3_noun quy) { - if ( u2_nul == quy ) { + if ( u3_nul == quy ) { return len_w; } else { - u2_noun i_quy = u2h(quy); - u2_noun pi_quy = u2h(i_quy); - u2_noun qi_quy = u2t(i_quy); - u2_noun t_quy = u2t(quy); + u3_noun i_quy = u3h(quy); + u3_noun pi_quy = u3h(i_quy); + u3_noun qi_quy = u3t(i_quy); + u3_noun t_quy = u3t(quy); len_w = _cttp_mcut_char(buf_c, len_w, '&'); - len_w = _cttp_mcut_span(buf_c, len_w, u2k(pi_quy)); + len_w = _cttp_mcut_span(buf_c, len_w, u3k(pi_quy)); len_w = _cttp_mcut_char(buf_c, len_w, '='); - len_w = _cttp_mcut_span(buf_c, len_w, u2k(qi_quy)); + len_w = _cttp_mcut_span(buf_c, len_w, u3k(qi_quy)); - len_w = _cttp_mcut_quay(buf_c, len_w, u2k(t_quy)); + len_w = _cttp_mcut_quay(buf_c, len_w, u3k(t_quy)); } - u2z(quy); + u3z(quy); return len_w; } /* _cttp_mcut_url(): measure/cut purl, producing relative URL. */ static c3_w -_cttp_mcut_url(c3_c* buf_c, c3_w len_w, u2_noun pul) +_cttp_mcut_url(c3_c* buf_c, c3_w len_w, u3_noun pul) { - u2_noun q_pul = u2h(u2t(pul)); - u2_noun r_pul = u2t(u2t(pul)); + u3_noun q_pul = u3h(u3t(pul)); + u3_noun r_pul = u3t(u3t(pul)); - // len_w = _cttp_mcut_pfix(buf_c, len_w, u2k(p_pul)); + // len_w = _cttp_mcut_pfix(buf_c, len_w, u3k(p_pul)); len_w = _cttp_mcut_char(buf_c, len_w, '/'); - len_w = _cttp_mcut_pork(buf_c, len_w, u2k(q_pul)); + len_w = _cttp_mcut_pork(buf_c, len_w, u3k(q_pul)); - if ( u2_nul != r_pul ) { + if ( u3_nul != r_pul ) { len_w = _cttp_mcut_char(buf_c, len_w, '?'); - len_w = _cttp_mcut_quay(buf_c, len_w, u2k(r_pul)); + len_w = _cttp_mcut_quay(buf_c, len_w, u3k(r_pul)); } - u2z(pul); + u3z(pul); return len_w; } /* _cttp_creq_url(): construct url from noun. */ static c3_c* -_cttp_creq_url(u2_noun pul) +_cttp_creq_url(u3_noun pul) { - c3_w len_w = _cttp_mcut_url(0, 0, u2k(pul)); + c3_w len_w = _cttp_mcut_url(0, 0, u3k(pul)); c3_c* url_c = c3_malloc(len_w + 1); _cttp_mcut_url(url_c, 0, pul); @@ -427,9 +427,9 @@ _cttp_creq_url(u2_noun pul) /* _cttp_creq_host(): construct host from noun. */ static c3_c* -_cttp_creq_host(u2_noun hot) +_cttp_creq_host(u3_noun hot) { - c3_w len_w = _cttp_mcut_host(0, 0, u2k(hot)); + c3_w len_w = _cttp_mcut_host(0, 0, u3k(hot)); c3_c* hot_c = c3_malloc(len_w + 1); _cttp_mcut_host(hot_c, 0, hot); @@ -441,24 +441,24 @@ _cttp_creq_host(u2_noun hot) /* _cttp_httr(): deliver http result. */ static void -_cttp_httr(c3_l num_l, c3_w sas_w, u2_noun mes, u2_noun uct) +_cttp_httr(c3_l num_l, c3_w sas_w, u3_noun mes, u3_noun uct) { - u2_noun htr = u2nt(sas_w, mes, uct); - u2_noun pox = u2nt(u2_blip, c3__http, u2_nul); + u3_noun htr = u3nt(sas_w, mes, uct); + u3_noun pox = u3nt(u3_blip, c3__http, u3_nul); - u2_reck_plan(u2_Host.arv_u, pox, u2nt(c3__they, num_l, htr)); + u3_cv_plan(pox, u3nt(c3__they, num_l, htr)); } /* _cttp_httr_cres(): deliver valid response. */ static void -_cttp_httr_cres(c3_l num_l, u2_cres* res_u) +_cttp_httr_cres(c3_l num_l, u3_cres* res_u) { _cttp_httr (num_l, res_u->sas_w, _cttp_heds_to_list(res_u->hed_u), - res_u->bod_u ? u2nc(u2_nul, _cttp_bods_to_octs(res_u->bod_u)) : u2_nul); + res_u->bod_u ? u3nc(u3_nul, _cttp_bods_to_octs(res_u->bod_u)) : u3_nul); } /* _cttp_httr_fail(): fail out a request by number. @@ -466,13 +466,13 @@ _cttp_httr_cres(c3_l num_l, u2_cres* res_u) static void _cttp_httr_fail(c3_l num_l, c3_c* msg_c) { - return _cttp_httr(num_l, 404, u2_nul, u2_nul); + return _cttp_httr(num_l, 404, u3_nul, u3_nul); } -/* _cttp_cres_free(): free a u2_cres. +/* _cttp_cres_free(): free a u3_cres. */ static void -_cttp_cres_free(u2_cres* res_u) +_cttp_cres_free(u3_cres* res_u) { _cttp_heds_free(res_u->hed_u); _cttp_bods_free(res_u->bod_u); @@ -481,10 +481,10 @@ _cttp_cres_free(u2_cres* res_u) free(res_u); } -/* _cttp_creq_free(): free a u2_creq. +/* _cttp_creq_free(): free a u3_creq. */ static void -_cttp_creq_free(u2_creq* ceq_u) +_cttp_creq_free(u3_creq* ceq_u) { _cttp_heds_free(ceq_u->hed_u); _cttp_bods_free(ceq_u->bod_u); @@ -538,13 +538,13 @@ _cttp_url(http_parser* par_u, const c3_c* buf_c, size_t siz_i) static c3_i _cttp_header_field(http_parser* par_u, const c3_c* buf_c, size_t siz_i) { - u2_creq* ceq_u = par_u->data; - u2_cres* res_u = ceq_u->res_u; + u3_creq* ceq_u = par_u->data; + u3_cres* res_u = ceq_u->res_u; switch ( res_u->rat_e ) { - case u2_hreq_non: - case u2_hreq_val: { - u2_hhed* hed_u = c3_malloc(sizeof(*hed_u)); + case u3_hreq_non: + case u3_hreq_val: { + u3_hhed* hed_u = c3_malloc(sizeof(*hed_u)); hed_u->nam_c = _cttp_more(0, buf_c, siz_i); hed_u->val_c = 0; @@ -553,12 +553,12 @@ _cttp_header_field(http_parser* par_u, const c3_c* buf_c, size_t siz_i) break; } - case u2_hreq_nam: { + case u3_hreq_nam: { res_u->hed_u->nam_c = _cttp_more(res_u->hed_u->nam_c, buf_c, siz_i); break; } } - res_u->rat_e = u2_hreq_nam; + res_u->rat_e = u3_hreq_nam; return 0; } @@ -567,22 +567,22 @@ _cttp_header_field(http_parser* par_u, const c3_c* buf_c, size_t siz_i) static c3_i _cttp_header_value(http_parser* par_u, const c3_c* buf_c, size_t siz_i) { - u2_creq* ceq_u = par_u->data; - u2_cres* res_u = ceq_u->res_u; + u3_creq* ceq_u = par_u->data; + u3_cres* res_u = ceq_u->res_u; switch ( res_u->rat_e ) { - case u2_hreq_non: fprintf(stderr, "http: odd value\r\n"); return 1; + case u3_hreq_non: fprintf(stderr, "http: odd value\r\n"); return 1; - case u2_hreq_nam: { + case u3_hreq_nam: { res_u->hed_u->val_c = _cttp_more(0, buf_c, siz_i); break; } - case u2_hreq_val: { + case u3_hreq_val: { res_u->hed_u->val_c = _cttp_more(res_u->hed_u->val_c, buf_c, siz_i); break; } } - res_u->rat_e = u2_hreq_val; + res_u->rat_e = u3_hreq_val; return 0; } @@ -599,9 +599,9 @@ _cttp_headers_complete(http_parser* par_u) static c3_i _cttp_body(http_parser* par_u, const c3_c* buf_c, size_t siz_i) { - u2_creq* ceq_u = par_u->data; - u2_cres* res_u = ceq_u->res_u; - u2_hbod* bod_u; + u3_creq* ceq_u = par_u->data; + u3_cres* res_u = ceq_u->res_u; + u3_hbod* bod_u; bod_u = _cttp_bod(siz_i, (const c3_y*)buf_c); @@ -620,9 +620,9 @@ _cttp_body(http_parser* par_u, const c3_c* buf_c, size_t siz_i) static c3_i _cttp_message_complete(http_parser* par_u) { - u2_creq* ceq_u = par_u->data; - u2_ccon* coc_u = ceq_u->coc_u; - u2_cres* res_u = ceq_u->res_u; + u3_creq* ceq_u = par_u->data; + u3_ccon* coc_u = ceq_u->coc_u; + u3_cres* res_u = ceq_u->res_u; res_u->sas_w = par_u->status_code; @@ -639,7 +639,7 @@ _cttp_message_complete(http_parser* par_u) c3_assert(ceq_u == coc_u->qec_u); coc_u->qec_u = 0; } - if ( u2_yes == coc_u->sec ) { + if ( u3_yes == coc_u->sec ) { SSL_shutdown(coc_u->ssl.ssl_u); _cttp_ccon_cryp_rout(coc_u); // uL(fprintf(uH, "cttp: close b: %p\n", coc_u)); @@ -663,9 +663,9 @@ static struct http_parser_settings _cttp_settings = { /* _cttp_cres_start(): set up new cttp response for creq. */ static void -_cttp_cres_start(u2_creq* ceq_u) +_cttp_cres_start(u3_creq* ceq_u) { - u2_cres* res_u = c3_malloc(sizeof(*res_u)); + u3_cres* res_u = c3_malloc(sizeof(*res_u)); memset(res_u, 0, sizeof(*res_u)); ceq_u->res_u = res_u; @@ -678,36 +678,36 @@ _cttp_cres_start(u2_creq* ceq_u) /* _cttp_ccon_wax(): connection from wax_u. */ -static u2_ccon* +static u3_ccon* _cttp_ccon_wax(uv_tcp_t* wax_u) { - u2_ccon* coc_u = 0; + u3_ccon* coc_u = 0; - return (u2_ccon*)(void *) + return (u3_ccon*)(void *) ( ((c3_y *)(void *)wax_u) - (((c3_y *)(void *)&(coc_u->wax_u)) - ((c3_y *)(void *)(coc_u))) ); } /* _cttp_ccon_cot(): connection from cot_u. */ -static u2_ccon* +static u3_ccon* _cttp_ccon_cot(uv_connect_t* cot_u) { - u2_ccon* coc_u = 0; + u3_ccon* coc_u = 0; - return (u2_ccon*)(void *) + return (u3_ccon*)(void *) ( ((c3_y *)(void *)cot_u) - (((c3_y *)(void *)&(coc_u->cot_u)) - ((c3_y *)(void *)(coc_u))) ); } /* _cttp_ccon_adr(): connection from adr_u. */ -static u2_ccon* +static u3_ccon* _cttp_ccon_adr(uv_getaddrinfo_t* adr_u) { - u2_ccon* coc_u = 0; + u3_ccon* coc_u = 0; - return (u2_ccon*)(void *) + return (u3_ccon*)(void *) ( ((c3_y *)(void *)adr_u) - (((c3_y *)(void *)&(coc_u->adr_u)) - ((c3_y *)(void *)(coc_u))) ); } @@ -715,10 +715,10 @@ _cttp_ccon_adr(uv_getaddrinfo_t* adr_u) /* _cttp_ccon_waste(): fail out whole connection, with message. */ static void -_cttp_ccon_waste(u2_ccon* coc_u, c3_c* msg_c) +_cttp_ccon_waste(u3_ccon* coc_u, c3_c* msg_c) { while ( coc_u->ceq_u ) { - u2_creq* ceq_u = coc_u->ceq_u; + u3_creq* ceq_u = coc_u->ceq_u; _cttp_httr_fail(ceq_u->num_l, msg_c); coc_u->ceq_u = ceq_u->nex_u; @@ -735,7 +735,7 @@ _cttp_ccon_waste(u2_ccon* coc_u, c3_c* msg_c) if ( coc_u->pre_u ) { coc_u->pre_u->nex_u = coc_u->nex_u; } else { - u2_Host.ctp_u.coc_u = coc_u->nex_u; + u3_Host.ctp_u.coc_u = coc_u->nex_u; } if ( coc_u->nex_u ) { coc_u->nex_u->pre_u = coc_u->pre_u; @@ -752,7 +752,7 @@ _cttp_ccon_waste(u2_ccon* coc_u, c3_c* msg_c) /* _cttp_ccon_reset(): reset a live connection. */ void -_cttp_ccon_reset(u2_ccon* coc_u) +_cttp_ccon_reset(u3_ccon* coc_u) { if ( coc_u->ceq_u ) { _cttp_bods_free(coc_u->rub_u); @@ -771,32 +771,32 @@ _cttp_ccon_reset(u2_ccon* coc_u) /* _cttp_ccon_reboot(): stop appropriate I/O on failure case. */ static void -_cttp_ccon_reboot(u2_ccon* coc_u) +_cttp_ccon_reboot(u3_ccon* coc_u) { switch ( coc_u->sat_e ) { default: c3_assert(0); - case u2_csat_dead: { + case u3_csat_dead: { /* Failed to resolve an address. Waste it. */ _cttp_ccon_waste(coc_u, "could not resolve address"); break; } - case u2_csat_addr: { + case u3_csat_addr: { /* Got an address but not a connection. Waste it. */ _cttp_ccon_waste(coc_u, "connection failed"); break; } - case u2_csat_crop: - case u2_csat_sing: { + case u3_csat_crop: + case u3_csat_sing: { /* Got a connection, but SSL failed. Waste it. */ _cttp_ccon_waste(coc_u, "ssl handshake failed"); break; } - case u2_csat_cryp: - case u2_csat_clyr: { + case u3_csat_cryp: + case u3_csat_clyr: { /* We had a connection but it broke. Either there are no ** living requests, in which case waste; otherwise reset. */ @@ -806,7 +806,7 @@ _cttp_ccon_reboot(u2_ccon* coc_u) else { /* Clear any unsent data. */ - coc_u->sat_e = u2_csat_dead; + coc_u->sat_e = u3_csat_dead; _cttp_ccon_reset(coc_u); /* Begin again. @@ -824,7 +824,7 @@ _cttp_ccon_reboot(u2_ccon* coc_u) static void _cttp_ccon_fail_cb(uv_handle_t* wax_u) { - u2_ccon *coc_u = _cttp_ccon_wax((uv_tcp_t*)wax_u); + u3_ccon *coc_u = _cttp_ccon_wax((uv_tcp_t*)wax_u); _cttp_ccon_reboot(coc_u); } @@ -832,13 +832,13 @@ _cttp_ccon_fail_cb(uv_handle_t* wax_u) /* _cttp_ccon_fail(): report failure and reset connection. */ static void -_cttp_ccon_fail(u2_ccon* coc_u, u2_bean say) +_cttp_ccon_fail(u3_ccon* coc_u, u3_bean say) { - if ( u2_yes == say ) { + if ( u3_yes == say ) { uL(fprintf(uH, "cttp: ERROR\n")); } - if ( coc_u->sat_e < u2_csat_crop ) { + if ( coc_u->sat_e < u3_csat_crop ) { _cttp_ccon_reboot(coc_u); } else { @@ -854,17 +854,17 @@ _cttp_ccon_kick_resolve_cb(uv_getaddrinfo_t* adr_u, c3_i sas_i, struct addrinfo* aif_u) { - u2_ccon* coc_u = _cttp_ccon_adr(adr_u); + u3_ccon* coc_u = _cttp_ccon_adr(adr_u); - c3_assert(u2_csat_dead == coc_u->sat_e); + c3_assert(u3_csat_dead == coc_u->sat_e); if ( 0 != sas_i ) { - _cttp_ccon_fail(coc_u, u2_yes); + _cttp_ccon_fail(coc_u, u3_yes); } else { coc_u->ipf_w = ntohl(((struct sockaddr_in *)aif_u->ai_addr)-> sin_addr.s_addr); - coc_u->sat_e = u2_csat_addr; + coc_u->sat_e = u3_csat_addr; _cttp_ccon_kick(coc_u); } @@ -873,12 +873,12 @@ _cttp_ccon_kick_resolve_cb(uv_getaddrinfo_t* adr_u, /* _cttp_ccon_kick_resolve(): start address resolution. */ static void -_cttp_ccon_kick_resolve(u2_ccon* coc_u) +_cttp_ccon_kick_resolve(u3_ccon* coc_u) { c3_c por_c[8]; struct addrinfo hin_u; - c3_assert(u2_csat_dead == coc_u->sat_e); + c3_assert(u3_csat_dead == coc_u->sat_e); snprintf(por_c, 7, "%d", 65535 & coc_u->por_s); memset(&hin_u, 0, sizeof(struct addrinfo)); @@ -886,11 +886,11 @@ _cttp_ccon_kick_resolve(u2_ccon* coc_u) hin_u.ai_socktype = SOCK_STREAM; hin_u.ai_protocol = IPPROTO_TCP; - if ( 0 != uv_getaddrinfo(u2L, &coc_u->adr_u, + if ( 0 != uv_getaddrinfo(u3L, &coc_u->adr_u, _cttp_ccon_kick_resolve_cb, coc_u->hot_c, por_c, &hin_u) ) { - _cttp_ccon_fail(coc_u, u2_yes); + _cttp_ccon_fail(coc_u, u3_yes); } } @@ -900,17 +900,17 @@ static void _cttp_ccon_kick_connect_cb(uv_connect_t* cot_u, c3_i sas_i) { - u2_ccon* coc_u = _cttp_ccon_cot(cot_u); + u3_ccon* coc_u = _cttp_ccon_cot(cot_u); - c3_assert(u2_csat_addr == coc_u->sat_e); + c3_assert(u3_csat_addr == coc_u->sat_e); if ( 0 != sas_i ) { - _cttp_ccon_fail(coc_u, u2_yes); + _cttp_ccon_fail(coc_u, u3_yes); } else { - coc_u->sat_e = (u2_yes == coc_u->sec) ? - u2_csat_crop : - u2_csat_clyr; + coc_u->sat_e = (u3_yes == coc_u->sec) ? + u3_csat_crop : + u3_csat_clyr; _cttp_ccon_kick(coc_u); } } @@ -918,14 +918,14 @@ _cttp_ccon_kick_connect_cb(uv_connect_t* cot_u, /* _cttp_ccon_kick_connect(): start connect resolution. */ static void -_cttp_ccon_kick_connect(u2_ccon* coc_u) +_cttp_ccon_kick_connect(u3_ccon* coc_u) { struct sockaddr_in add_u; - c3_assert(u2_csat_addr == coc_u->sat_e); + c3_assert(u3_csat_addr == coc_u->sat_e); - if ( 0 != uv_tcp_init(u2L, &coc_u->wax_u) ) { - _cttp_ccon_fail(coc_u, u2_yes); + if ( 0 != uv_tcp_init(u3L, &coc_u->wax_u) ) { + _cttp_ccon_fail(coc_u, u3_yes); } add_u.sin_family = AF_INET; @@ -937,7 +937,7 @@ _cttp_ccon_kick_connect(u2_ccon* coc_u) (const struct sockaddr*) & add_u, _cttp_ccon_kick_connect_cb) ) { - _cttp_ccon_fail(coc_u, u2_yes); + _cttp_ccon_fail(coc_u, u3_yes); } } @@ -945,39 +945,39 @@ _cttp_ccon_kick_connect(u2_ccon* coc_u) */ typedef struct { uv_write_t wri_u; - u2_ccon* coc_u; + u3_ccon* coc_u; c3_y* buf_y; - } _u2_write_t; + } _u3_write_t; /* _cttp_ccon_kick_write_cb(): general write callback */ static void _cttp_ccon_kick_write_cb(uv_write_t* wri_u, c3_i sas_i) { - u2_lo_open(); + u3_lo_open(); { - _u2_write_t* ruq_u = (void *)wri_u; + _u3_write_t* ruq_u = (void *)wri_u; if ( 0 != sas_i ) { - _cttp_ccon_fail(ruq_u->coc_u, u2_yes); + _cttp_ccon_fail(ruq_u->coc_u, u3_yes); } free(ruq_u->buf_y); free(ruq_u); } - u2_lo_shut(u2_no); + u3_lo_shut(u3_no); } /* _cttp_ccon_kick_write() */ static void -_cttp_ccon_kick_write_cryp(u2_ccon* coc_u) +_cttp_ccon_kick_write_cryp(u3_ccon* coc_u) { if (!SSL_is_init_finished(coc_u->ssl.ssl_u)) { return; } while ( coc_u->rub_u ) { - u2_hbod* rub_u = coc_u->rub_u; + u3_hbod* rub_u = coc_u->rub_u; c3_i rev_i; coc_u->rub_u = coc_u->rub_u->nex_u; @@ -996,9 +996,9 @@ _cttp_ccon_kick_write_cryp(u2_ccon* coc_u) /* _cttp_ccon_kick_write_buf(): transmit buffer. */ static void -_cttp_ccon_kick_write_buf(u2_ccon* coc_u, uv_buf_t buf_u) +_cttp_ccon_kick_write_buf(u3_ccon* coc_u, uv_buf_t buf_u) { - _u2_write_t* ruq_u = (_u2_write_t*) c3_malloc(sizeof(_u2_write_t)); + _u3_write_t* ruq_u = (_u3_write_t*) c3_malloc(sizeof(_u3_write_t)); ruq_u->coc_u = coc_u; ruq_u->buf_y = (c3_y*)buf_u.base; @@ -1008,14 +1008,14 @@ _cttp_ccon_kick_write_buf(u2_ccon* coc_u, uv_buf_t buf_u) &buf_u, 1, _cttp_ccon_kick_write_cb) ) { - _cttp_ccon_fail(coc_u, u2_yes); + _cttp_ccon_fail(coc_u, u3_yes); } } /* _cttp_ccon_kick_write_body(): attach response body. */ static void -_cttp_ccon_kick_write_body(u2_ccon* coc_u, u2_hbod *rub_u) +_cttp_ccon_kick_write_body(u3_ccon* coc_u, u3_hbod *rub_u) { uv_buf_t buf_u; @@ -1036,10 +1036,10 @@ _cttp_ccon_kick_write_body(u2_ccon* coc_u, u2_hbod *rub_u) /* _cttp_ccon_kick_write() */ static void -_cttp_ccon_kick_write(u2_ccon* coc_u) +_cttp_ccon_kick_write(u3_ccon* coc_u) { while ( coc_u->rub_u ) { - u2_hbod* rub_u = coc_u->rub_u; + u3_hbod* rub_u = coc_u->rub_u; coc_u->rub_u = coc_u->rub_u->nex_u; if ( 0 == coc_u->rub_u ) { @@ -1053,7 +1053,7 @@ _cttp_ccon_kick_write(u2_ccon* coc_u) /* _cttp_ccon_cryp_rout: write the SSL buffer to the network */ static void -_cttp_ccon_cryp_rout(u2_ccon* coc_u) +_cttp_ccon_cryp_rout(u3_ccon* coc_u) { uv_buf_t buf_u; c3_i bur_i; @@ -1070,9 +1070,9 @@ _cttp_ccon_cryp_rout(u2_ccon* coc_u) /* _cttp_ccon_cryp_hurr: handle SSL errors */ static void -_cttp_ccon_cryp_hurr(u2_ccon* coc_u, int rev) +_cttp_ccon_cryp_hurr(u3_ccon* coc_u, int rev) { - u2_sslx* ssl = &coc_u->ssl; + u3_sslx* ssl = &coc_u->ssl; c3_i err = SSL_get_error(ssl->ssl_u, rev); switch ( err ) { @@ -1093,10 +1093,10 @@ _cttp_ccon_cryp_hurr(u2_ccon* coc_u, int rev) /* _cttp_ccon_pars_shov: shove a data buffer into the parser */ static void -_cttp_ccon_pars_shov(u2_ccon* coc_u, void* buf_u, ssize_t siz_i) +_cttp_ccon_pars_shov(u3_ccon* coc_u, void* buf_u, ssize_t siz_i) { - u2_creq* ceq_u = coc_u->ceq_u; + u3_creq* ceq_u = coc_u->ceq_u; if ( !ceq_u ) { // spurious input uL(fprintf(uH, "http: response to no request\n")); @@ -1112,7 +1112,7 @@ _cttp_ccon_pars_shov(u2_ccon* coc_u, void* buf_u, ssize_t siz_i) siz_i) ) { uL(fprintf(uH, "http: parse error\n")); - _cttp_ccon_fail(coc_u, u2_no); + _cttp_ccon_fail(coc_u, u3_no); } } } @@ -1120,7 +1120,7 @@ _cttp_ccon_pars_shov(u2_ccon* coc_u, void* buf_u, ssize_t siz_i) /* _cttp_ccon_cryp_pull(): pull cleartext data off of the SSL buffer */ static void -_cttp_ccon_cryp_pull(u2_ccon* coc_u) +_cttp_ccon_cryp_pull(u3_ccon* coc_u) { if ( SSL_is_init_finished(coc_u->ssl.ssl_u) ) { static c3_c buf[1<<14]; @@ -1139,7 +1139,7 @@ _cttp_ccon_cryp_pull(u2_ccon* coc_u) _cttp_ccon_cryp_hurr(coc_u, r); } else { - coc_u->sat_e = u2_csat_cryp; + coc_u->sat_e = u3_csat_cryp; _cttp_ccon_kick(coc_u); } } @@ -1163,18 +1163,18 @@ _cttp_ccon_kick_read_cryp_cb(uv_stream_t* tcp_u, ssize_t siz_w, const uv_buf_t * buf_u) { - u2_ccon *coc_u = _cttp_ccon_wax((uv_tcp_t*)tcp_u); + u3_ccon *coc_u = _cttp_ccon_wax((uv_tcp_t*)tcp_u); - u2_lo_open(); + u3_lo_open(); { if ( siz_w == UV_EOF ) { - _cttp_ccon_fail(coc_u, u2_no); + _cttp_ccon_fail(coc_u, u3_no); } else if ( siz_w < 0 ) { uL(fprintf(uH, "cttp: read 2: %s\n", uv_strerror(siz_w))); - _cttp_ccon_fail(coc_u, u2_yes); + _cttp_ccon_fail(coc_u, u3_yes); } else { - u2_creq* ceq_u = coc_u->ceq_u; + u3_creq* ceq_u = coc_u->ceq_u; if ( !ceq_u ) { // spurious input uL(fprintf(uH, "http: response to no request\n")); @@ -1188,7 +1188,7 @@ _cttp_ccon_kick_read_cryp_cb(uv_stream_t* tcp_u, free(buf_u->base); } } - u2_lo_shut(u2_yes); + u3_lo_shut(u3_yes); } /* _cttp_ccon_read_clyr_cb() @@ -1209,15 +1209,15 @@ _cttp_ccon_kick_read_clyr_cb(uv_stream_t* tcp_u, ssize_t siz_w, const uv_buf_t * buf_u) { - u2_ccon *coc_u = _cttp_ccon_wax((uv_tcp_t*)tcp_u); + u3_ccon *coc_u = _cttp_ccon_wax((uv_tcp_t*)tcp_u); - u2_lo_open(); + u3_lo_open(); { if ( siz_w == UV_EOF ) { - _cttp_ccon_fail(coc_u, u2_no); + _cttp_ccon_fail(coc_u, u3_no); } else if ( siz_w < 0 ) { uL(fprintf(uH, "cttp: read 1: %s\n", uv_strerror(siz_w))); - _cttp_ccon_fail(coc_u, u2_yes); + _cttp_ccon_fail(coc_u, u3_yes); } else { _cttp_ccon_pars_shov(coc_u, buf_u->base, siz_w); @@ -1226,13 +1226,13 @@ _cttp_ccon_kick_read_clyr_cb(uv_stream_t* tcp_u, free(buf_u->base); } } - u2_lo_shut(u2_yes); + u3_lo_shut(u3_yes); } /* _cttp_ccon_kick_read_clyr(): start reading on insecure socket. */ static void -_cttp_ccon_kick_read_clyr(u2_ccon* coc_u) +_cttp_ccon_kick_read_clyr(u3_ccon* coc_u) { uv_read_start((uv_stream_t*)&coc_u->wax_u, _cttp_alloc, @@ -1242,7 +1242,7 @@ _cttp_ccon_kick_read_clyr(u2_ccon* coc_u) /* _cttp_ccon_kick_read_cryp(): start reading on secure socket. */ static void -_cttp_ccon_kick_read_cryp(u2_ccon* coc_u) +_cttp_ccon_kick_read_cryp(u3_ccon* coc_u) { uv_read_start((uv_stream_t*)&coc_u->wax_u, _cttp_alloc, @@ -1252,9 +1252,9 @@ _cttp_ccon_kick_read_cryp(u2_ccon* coc_u) /* _cttp_ccon_kick_handshake(): start ssl handshake. */ static void -_cttp_ccon_kick_handshake(u2_ccon* coc_u) +_cttp_ccon_kick_handshake(u3_ccon* coc_u) { - coc_u->ssl.ssl_u = SSL_new(u2S); + coc_u->ssl.ssl_u = SSL_new(u3S); c3_assert(coc_u->ssl.ssl_u); coc_u->ssl.rio_u = BIO_new(BIO_s_mem()); @@ -1273,14 +1273,14 @@ _cttp_ccon_kick_handshake(u2_ccon* coc_u) SSL_set_connect_state(coc_u->ssl.ssl_u); SSL_do_handshake(coc_u->ssl.ssl_u); - coc_u->sat_e = u2_csat_sing; + coc_u->sat_e = u3_csat_sing; _cttp_ccon_kick(coc_u); } /* _cttp_ccon_kick(): start appropriate I/O on client connection. */ static void -_cttp_ccon_kick(u2_ccon* coc_u) +_cttp_ccon_kick(u3_ccon* coc_u) { if ( 0 == coc_u->ceq_u ) { return; @@ -1288,24 +1288,24 @@ _cttp_ccon_kick(u2_ccon* coc_u) switch ( coc_u->sat_e ) { default: c3_assert(0); - case u2_csat_dead: { + case u3_csat_dead: { _cttp_ccon_kick_resolve(coc_u); break; } - case u2_csat_addr: { + case u3_csat_addr: { _cttp_ccon_kick_connect(coc_u); break; } - case u2_csat_crop: { + case u3_csat_crop: { _cttp_ccon_kick_handshake(coc_u); break; } - case u2_csat_sing: { + case u3_csat_sing: { _cttp_ccon_kick_read_cryp(coc_u); _cttp_ccon_cryp_pull(coc_u); break; } - case u2_csat_cryp: { + case u3_csat_cryp: { _cttp_ccon_fill(coc_u); if ( coc_u->rub_u ) { @@ -1314,7 +1314,7 @@ _cttp_ccon_kick(u2_ccon* coc_u) _cttp_ccon_cryp_pull(coc_u); break; } - case u2_csat_clyr: { + case u3_csat_clyr: { _cttp_ccon_fill(coc_u); if ( coc_u->rub_u ) { @@ -1328,12 +1328,12 @@ _cttp_ccon_kick(u2_ccon* coc_u) /* _cttp_ccon_new(): create client connection. Return 0 if url invalid. */ -static u2_ccon* -_cttp_ccon_new(u2_bean sec, c3_s por_s, c3_c* hot_c) +static u3_ccon* +_cttp_ccon_new(u3_bean sec, c3_s por_s, c3_c* hot_c) { - u2_ccon* coc_u = c3_malloc(sizeof(u2_ccon)); + u3_ccon* coc_u = c3_malloc(sizeof(u3_ccon)); - memset(coc_u, 0, sizeof(u2_ccon)); + memset(coc_u, 0, sizeof(u3_ccon)); coc_u->por_s = por_s; coc_u->hot_c = hot_c; @@ -1342,11 +1342,11 @@ _cttp_ccon_new(u2_bean sec, c3_s por_s, c3_c* hot_c) coc_u->pre_u = 0; coc_u->nex_u = 0; - if ( u2_Host.ctp_u.coc_u ) { - coc_u->nex_u = u2_Host.ctp_u.coc_u; - u2_Host.ctp_u.coc_u->pre_u = coc_u; + if ( u3_Host.ctp_u.coc_u ) { + coc_u->nex_u = u3_Host.ctp_u.coc_u; + u3_Host.ctp_u.coc_u->pre_u = coc_u; } - u2_Host.ctp_u.coc_u = coc_u; + u3_Host.ctp_u.coc_u = coc_u; return coc_u; } @@ -1354,14 +1354,14 @@ _cttp_ccon_new(u2_bean sec, c3_s por_s, c3_c* hot_c) #ifndef CTTP_NO_PIPELINE /* _cttp_ccon_find(): find existing connection for remote server. */ -static u2_ccon* -_cttp_ccon_find(u2_bean sec, c3_s por_s, c3_c* hot_c) +static u3_ccon* +_cttp_ccon_find(u3_bean sec, c3_s por_s, c3_c* hot_c) { - u2_ccon* coc_u; + u3_ccon* coc_u; /* XX: linear search. */ - for ( coc_u = u2_Host.ctp_u.coc_u; coc_u; coc_u = coc_u->nex_u ) { + for ( coc_u = u3_Host.ctp_u.coc_u; coc_u; coc_u = coc_u->nex_u ) { if ( !strcmp(hot_c, coc_u->hot_c) && (por_s == coc_u->por_s) ) { return coc_u; } @@ -1372,11 +1372,11 @@ _cttp_ccon_find(u2_bean sec, c3_s por_s, c3_c* hot_c) /* _cttp_ccon(): create or find persistent client connection. */ -static u2_ccon* -_cttp_ccon(u2_bean sec, c3_s por_s, c3_c* hot_c) +static u3_ccon* +_cttp_ccon(u3_bean sec, c3_s por_s, c3_c* hot_c) { #ifndef CTTP_NO_PIPELINE - u2_ccon* coc_c = _cttp_ccon_find(sec, por_s, hot_c); + u3_ccon* coc_c = _cttp_ccon_find(sec, por_s, hot_c); if ( 0 != coc_c ) { free(hot_c); @@ -1389,57 +1389,57 @@ _cttp_ccon(u2_bean sec, c3_s por_s, c3_c* hot_c) /* _cttp_creq(): cttp request from noun. */ -static u2_creq* -_cttp_creq_new(c3_l num_l, u2_noun hes) +static u3_creq* +_cttp_creq_new(c3_l num_l, u3_noun hes) { - u2_creq* ceq_u = c3_malloc(sizeof(u2_creq)); - u2_noun pul = u2h(hes); - u2_noun hat = u2h(pul); - u2_noun sec = u2h(hat); - u2_noun pus = u2h(u2t(hat)); - u2_noun hot = u2t(u2t(hat)); - u2_noun moh = u2t(hes); - u2_noun meh = u2h(moh); - u2_noun mah = u2h(u2t(moh)); - u2_noun moc = u2t(u2t(moh)); + u3_creq* ceq_u = c3_malloc(sizeof(u3_creq)); + u3_noun pul = u3h(hes); + u3_noun hat = u3h(pul); + u3_noun sec = u3h(hat); + u3_noun pus = u3h(u3t(hat)); + u3_noun hot = u3t(u3t(hat)); + u3_noun moh = u3t(hes); + u3_noun meh = u3h(moh); + u3_noun mah = u3h(u3t(moh)); + u3_noun moc = u3t(u3t(moh)); memset(ceq_u, 0, sizeof(*ceq_u)); ceq_u->num_l = num_l; ceq_u->sec = sec; - ceq_u->por_s = (u2_nul == pus) ? - ( (u2_yes == sec) ? 443 : 80 ) : u2t(pus); - ceq_u->hot_c = _cttp_creq_host(u2k(hot)); // XX duplicate work with url - ceq_u->url_c = _cttp_creq_url(u2k(pul)); + ceq_u->por_s = (u3_nul == pus) ? + ( (u3_yes == sec) ? 443 : 80 ) : u3t(pus); + ceq_u->hot_c = _cttp_creq_host(u3k(hot)); // XX duplicate work with url + ceq_u->url_c = _cttp_creq_url(u3k(pul)); // uL(fprintf(uH, "requesting %s\n", ceq_u->url_c)); switch ( meh ) { default: c3_assert(0); - case c3__delt: ceq_u->met_e = u2_hmet_delete; break; - case c3__get: ceq_u->met_e = u2_hmet_get; break; - case c3__head: ceq_u->met_e = u2_hmet_head; break; - case c3__post: ceq_u->met_e = u2_hmet_post; break; - case c3__put: ceq_u->met_e = u2_hmet_put; break; + case c3__delt: ceq_u->met_e = u3_hmet_delete; break; + case c3__get: ceq_u->met_e = u3_hmet_get; break; + case c3__head: ceq_u->met_e = u3_hmet_head; break; + case c3__post: ceq_u->met_e = u3_hmet_post; break; + case c3__put: ceq_u->met_e = u3_hmet_put; break; } - ceq_u->hed_u = _cttp_heds_math(0, u2k(mah)); + ceq_u->hed_u = _cttp_heds_math(0, u3k(mah)); - if ( u2_nul == moc ) { + if ( u3_nul == moc ) { ceq_u->bod_u = 0; } else { - ceq_u->bod_u = _cttp_octs_to_bod(u2k(u2t(moc))); + ceq_u->bod_u = _cttp_octs_to_bod(u3k(u3t(moc))); } ceq_u->nex_u = 0; - u2z(hes); + u3z(hes); return ceq_u; } /* _cttp_ccon_fire_body(): attach body to request buffers. */ static void -_cttp_ccon_fire_body(u2_ccon* coc_u, u2_hbod *rub_u) +_cttp_ccon_fire_body(u3_ccon* coc_u, u3_hbod *rub_u) { if ( !(coc_u->rub_u) ) { coc_u->rub_u = coc_u->bur_u = rub_u; @@ -1453,7 +1453,7 @@ _cttp_ccon_fire_body(u2_ccon* coc_u, u2_hbod *rub_u) /* _cttp_ccon_fire_str(): attach string to request buffers. */ static void -_cttp_ccon_fire_str(u2_ccon* coc_u, const c3_c* str_c) +_cttp_ccon_fire_str(u3_ccon* coc_u, const c3_c* str_c) { _cttp_ccon_fire_body(coc_u, _cttp_bod(strlen(str_c), (const c3_y*)str_c)); } @@ -1461,8 +1461,8 @@ _cttp_ccon_fire_str(u2_ccon* coc_u, const c3_c* str_c) /* _cttp_ccon_fire_heds(): attach output headers. */ static void -_cttp_ccon_fire_heds(u2_ccon* coc_u, - u2_hhed* hed_u) +_cttp_ccon_fire_heds(u3_ccon* coc_u, + u3_hhed* hed_u) { while ( hed_u ) { _cttp_ccon_fire_body(coc_u, _cttp_bud(hed_u->nam_c, hed_u->val_c)); @@ -1473,24 +1473,24 @@ _cttp_ccon_fire_heds(u2_ccon* coc_u, /* _cttp_ccon_fire(): load request data for into buffers. */ static void -_cttp_ccon_fire(u2_ccon* coc_u, u2_creq* ceq_u) +_cttp_ccon_fire(u3_ccon* coc_u, u3_creq* ceq_u) { switch ( ceq_u->met_e ) { default: c3_assert(0); - case u2_hmet_nop: c3_assert(0); break; // XX - case u2_hmet_delete: _cttp_ccon_fire_str(coc_u, "DELETE "); break; - case u2_hmet_get: _cttp_ccon_fire_str(coc_u, "GET "); break; - case u2_hmet_head: _cttp_ccon_fire_str(coc_u, "HEAD "); break; - case u2_hmet_post: _cttp_ccon_fire_str(coc_u, "POST "); break; - case u2_hmet_put: _cttp_ccon_fire_str(coc_u, "PUT "); break; + case u3_hmet_nop: c3_assert(0); break; // XX + case u3_hmet_delete: _cttp_ccon_fire_str(coc_u, "DELETE "); break; + case u3_hmet_get: _cttp_ccon_fire_str(coc_u, "GET "); break; + case u3_hmet_head: _cttp_ccon_fire_str(coc_u, "HEAD "); break; + case u3_hmet_post: _cttp_ccon_fire_str(coc_u, "POST "); break; + case u3_hmet_put: _cttp_ccon_fire_str(coc_u, "PUT "); break; } _cttp_ccon_fire_str(coc_u, ceq_u->url_c); _cttp_ccon_fire_str(coc_u, " HTTP/1.1\r\n"); _cttp_ccon_fire_str(coc_u, "User-Agent: urbit/vere.0.2\r\n"); _cttp_ccon_fire_str(coc_u, "Accept: */*\r\n"); // XX it's more painful than it's worth to deal with SSL+Keepalive - if ( u2_no == coc_u->sec ) { + if ( u3_no == coc_u->sec ) { _cttp_ccon_fire_str(coc_u, "Connection: Keep-Alive\r\n"); } _cttp_ccon_fire_body(coc_u, _cttp_bud("Host", ceq_u->hot_c)); @@ -1513,10 +1513,10 @@ _cttp_ccon_fire(u2_ccon* coc_u, u2_creq* ceq_u) /* _cttp_ccon_fill(): fill send pipeline as far as possible. */ static void -_cttp_ccon_fill(u2_ccon* coc_u) +_cttp_ccon_fill(u3_ccon* coc_u) { - u2_creq* ceq_u = coc_u->ceq_u; - u2_bean fir_t = u2_yes; + u3_creq* ceq_u = coc_u->ceq_u; + u3_bean fir_t = u3_yes; while ( ceq_u ) { // @@ -1535,14 +1535,14 @@ _cttp_ccon_fill(u2_ccon* coc_u) // // Extend for any other non-idempotent method (XX add). // - if ( (u2_no == fir_t) && (u2_hmet_nop == ceq_u->met_e) ) { + if ( (u3_no == fir_t) && (u3_hmet_nop == ceq_u->met_e) ) { ceq_u = ceq_u->nex_u; continue; } - if ( (u2_no == fir_t) && (u2_hmet_post == ceq_u->met_e) ) { + if ( (u3_no == fir_t) && (u3_hmet_post == ceq_u->met_e) ) { return; } - fir_t = u2_no; + fir_t = u3_no; _cttp_ccon_fire(coc_u, ceq_u); ceq_u = ceq_u->nex_u; } @@ -1551,11 +1551,11 @@ _cttp_ccon_fill(u2_ccon* coc_u) /* _cttp_ccon_send(): add I/O operation. */ static void -_cttp_ccon_send(u2_ccon* coc_u, u2_creq* ceq_u) +_cttp_ccon_send(u3_ccon* coc_u, u3_creq* ceq_u) { - u2_bean nou = ((0 == coc_u->ceq_u) ? u2_yes : u2_no); + u3_bean nou = ((0 == coc_u->ceq_u) ? u3_yes : u3_no); - if ( u2_yes == nou ) { + if ( u3_yes == nou ) { c3_assert(0 == coc_u->qec_u); coc_u->ceq_u = coc_u->qec_u = ceq_u; @@ -1568,44 +1568,44 @@ _cttp_ccon_send(u2_ccon* coc_u, u2_creq* ceq_u) } } -/* u2_cttp_ef_thus(): send %thus effect (outgoing request) to cttp. +/* u3_cttp_ef_thus(): send %thus effect (outgoing request) to cttp. */ void -u2_cttp_ef_thus(c3_l num_l, - u2_noun cuq) +u3_cttp_ef_thus(c3_l num_l, + u3_noun cuq) { - if ( u2_nul == cuq ) { + if ( u3_nul == cuq ) { uL(fprintf(uH, "thus: cancel?\n")); } else { - u2_creq* ceq_u = _cttp_creq_new(num_l, u2k(u2t(cuq))); - u2_ccon* coc_u = _cttp_ccon(ceq_u->sec, ceq_u->por_s, ceq_u->hot_c); + u3_creq* ceq_u = _cttp_creq_new(num_l, u3k(u3t(cuq))); + u3_ccon* coc_u = _cttp_ccon(ceq_u->sec, ceq_u->por_s, ceq_u->hot_c); ceq_u->coc_u = coc_u; _cttp_ccon_send(coc_u, ceq_u); } - u2z(cuq); + u3z(cuq); } -/* u2_cttp_io_init(): initialize http client I/O. +/* u3_cttp_io_init(): initialize http client I/O. */ void -u2_cttp_io_init() +u3_cttp_io_init() { c3_i rad; c3_y buf[4096]; - u2_Host.ctp_u.coc_u = 0; + u3_Host.ctp_u.coc_u = 0; SSL_library_init(); SSL_load_error_strings(); - u2_Host.ssl_u = SSL_CTX_new(TLSv1_client_method()); - SSL_CTX_set_options(u2S, SSL_OP_NO_SSLv2); - SSL_CTX_set_verify(u2S, SSL_VERIFY_PEER, NULL); - SSL_CTX_set_default_verify_paths(u2S); - SSL_CTX_set_session_cache_mode(u2S, SSL_SESS_CACHE_OFF); - SSL_CTX_set_cipher_list(u2S, "ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:" + u3_Host.ssl_u = SSL_CTX_new(TLSv1_client_method()); + SSL_CTX_set_options(u3S, SSL_OP_NO_SSLv2); + SSL_CTX_set_verify(u3S, SSL_VERIFY_PEER, NULL); + SSL_CTX_set_default_verify_paths(u3S); + SSL_CTX_set_session_cache_mode(u3S, SSL_SESS_CACHE_OFF); + SSL_CTX_set_cipher_list(u3S, "ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:" "ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AESGCM:" "RSA+AES:RSA+3DES:!aNULL:!MD5:!DSS"); @@ -1620,17 +1620,17 @@ u2_cttp_io_init() close(rad); } -/* u2_cttp_io_poll(): poll kernel for cttp I/O. +/* u3_cttp_io_poll(): poll kernel for cttp I/O. */ void -u2_cttp_io_poll(void) +u3_cttp_io_poll(void) { } -/* u2_cttp_io_exit(): shut down cttp. +/* u3_cttp_io_exit(): shut down cttp. */ void -u2_cttp_io_exit(void) +u3_cttp_io_exit(void) { - SSL_CTX_free(u2S); + SSL_CTX_free(u3S); } diff --git a/v/http.c b/v/http.c index 503a04e2b..d3ad44aef 100644 --- a/v/http.c +++ b/v/http.c @@ -23,9 +23,9 @@ #include "all.h" #include "v/vere.h" -static void _http_request(u2_hreq* req_u); -static void _http_request_dead(u2_hreq* req_u); -static void _http_conn_dead(u2_hcon *hon_u); +static void _http_request(u3_hreq* req_u); +static void _http_request_dead(u3_hreq* req_u); +static void _http_conn_dead(u3_hcon *hon_u); /* _http_alloc(): libuv buffer allocator. */ @@ -41,10 +41,10 @@ _http_alloc(uv_handle_t* had_u, /* _http_bod(): create a data buffer. */ -static u2_hbod* +static u3_hbod* _http_bod(c3_w len_w, const c3_y* hun_y) { - u2_hbod* bod_u = c3_malloc(len_w + sizeof(*bod_u)); + u3_hbod* bod_u = c3_malloc(len_w + sizeof(*bod_u)); bod_u->len_w = len_w; memcpy(bod_u->hun_y, hun_y, len_w); @@ -55,13 +55,13 @@ _http_bod(c3_w len_w, const c3_y* hun_y) /* _http_bud(): create a header buffer. Not null-terminated! */ -static u2_hbod* +static u3_hbod* _http_bud(c3_c* nam_c, c3_c* val_c) { c3_w lnm_w = strlen(nam_c); c3_w lvl_w = strlen(val_c); c3_w len_w = lnm_w + 2 + lvl_w + 2; - u2_hbod* bod_u = c3_malloc(len_w + sizeof(*bod_u)); + u3_hbod* bod_u = c3_malloc(len_w + sizeof(*bod_u)); strncpy((c3_c *)bod_u->hun_y, nam_c, lnm_w); strncpy((c3_c *)bod_u->hun_y + lnm_w, ": ", 2); @@ -77,10 +77,10 @@ _http_bud(c3_c* nam_c, c3_c* val_c) /* _http_heds_free(): free header structure. */ static void -_http_heds_free(u2_hhed* hed_u) +_http_heds_free(u3_hhed* hed_u) { while ( hed_u ) { - u2_hhed* nex_u = hed_u->nex_u; + u3_hhed* nex_u = hed_u->nex_u; if ( hed_u->nam_c ) free(hed_u->nam_c); if ( hed_u->val_c ) free(hed_u->val_c); @@ -93,10 +93,10 @@ _http_heds_free(u2_hhed* hed_u) /* _http_bods_free(): free body structure. */ static void -_http_bods_free(u2_hbod* bod_u) +_http_bods_free(u3_hbod* bod_u) { while ( bod_u ) { - u2_hbod* nex_u = bod_u->nex_u; + u3_hbod* nex_u = bod_u->nex_u; free(bod_u); bod_u = nex_u; @@ -106,7 +106,7 @@ _http_bods_free(u2_hbod* bod_u) /* _http_req_free(): free http request. */ static void -_http_req_free(u2_hreq* req_u) +_http_req_free(u3_hreq* req_u) { if ( req_u ) { if ( req_u->url_c ) { @@ -126,14 +126,14 @@ _http_req_free(u2_hreq* req_u) typedef struct { uv_write_t wri_u; c3_y* buf_y; - } _u2_write_t; + } _u3_write_t; /* _http_write_cb(): general write callback. */ static void _http_write_cb(uv_write_t* wri_u, c3_i sas_i) { - _u2_write_t* ruq_u = (void *)wri_u; + _u3_write_t* ruq_u = (void *)wri_u; if ( 0 != sas_i ) { uL(fprintf(uH, "http: write: ERROR\n")); @@ -145,9 +145,9 @@ _http_write_cb(uv_write_t* wri_u, c3_i sas_i) /* _http_respond_buf(): write back to http. */ static void -_http_respond_buf(u2_hreq* req_u, uv_buf_t buf_u) +_http_respond_buf(u3_hreq* req_u, uv_buf_t buf_u) { - _u2_write_t* ruq_u; + _u3_write_t* ruq_u; // don't respond to a dead connection if ( uv_is_closing((uv_handle_t*) &(req_u->hon_u->wax_u)) ) { @@ -155,7 +155,7 @@ _http_respond_buf(u2_hreq* req_u, uv_buf_t buf_u) return; } - ruq_u = (_u2_write_t*) c3_malloc(sizeof(_u2_write_t)); + ruq_u = (_u3_write_t*) c3_malloc(sizeof(_u3_write_t)); ruq_u->buf_y = (c3_y*)buf_u.base; @@ -172,8 +172,8 @@ _http_respond_buf(u2_hreq* req_u, uv_buf_t buf_u) /* _http_respond_body(): attach response body. */ static void -_http_send_body(u2_hreq *req_u, - u2_hbod *rub_u) +_http_send_body(u3_hreq *req_u, + u3_hbod *rub_u) { uv_buf_t buf_u; @@ -191,8 +191,8 @@ _http_send_body(u2_hreq *req_u, /* _http_respond_body(): attach response body. */ static void -_http_respond_body(u2_hreq *req_u, - u2_hbod *rub_u) +_http_respond_body(u3_hreq *req_u, + u3_hbod *rub_u) { if ( !(req_u->rub_u) ) { req_u->rub_u = req_u->bur_u = rub_u; @@ -206,7 +206,7 @@ _http_respond_body(u2_hreq *req_u, /* _http_respond_str(): attach output string. */ static void -_http_respond_str(u2_hreq* req_u, +_http_respond_str(u3_hreq* req_u, const c3_c* str_c) { _http_respond_body(req_u, _http_bod(strlen(str_c), (const c3_y*)str_c)); @@ -215,8 +215,8 @@ _http_respond_str(u2_hreq* req_u, /* _http_respond_headers(): attach output headers. */ static void -_http_respond_headers(u2_hreq* req_u, - u2_hhed* hed_u) +_http_respond_headers(u3_hreq* req_u, + u3_hhed* hed_u) { while ( hed_u ) { _http_respond_body(req_u, _http_bud(hed_u->nam_c, hed_u->val_c)); @@ -227,8 +227,8 @@ _http_respond_headers(u2_hreq* req_u, /* _http_respond_request(): attach response to request, then free it. */ static void -_http_respond_request(u2_hreq* req_u, - u2_hrep* rep_u) +_http_respond_request(u3_hreq* req_u, + u3_hrep* rep_u) { c3_c buf_c[81]; @@ -260,8 +260,8 @@ _http_respond_request(u2_hreq* req_u, } free(rep_u); - c3_assert(u2_no == req_u->end); - req_u->end = u2_yes; + c3_assert(u3_no == req_u->end); + req_u->end = u3_yes; } /* _http_conn_free_early(): free http connection on failure. @@ -269,7 +269,7 @@ _http_respond_request(u2_hreq* req_u, static void _http_conn_free_early(uv_handle_t* han_t) { - u2_hcon* hon_u = (void*) han_t; + u3_hcon* hon_u = (void*) han_t; free(hon_u); } @@ -278,16 +278,16 @@ _http_conn_free_early(uv_handle_t* han_t) static void _http_conn_free(uv_handle_t* han_t) { - u2_hcon* hon_u = (void*) han_t; + u3_hcon* hon_u = (void*) han_t; { - struct _u2_http *htp_u = hon_u->htp_u; + struct _u3_http *htp_u = hon_u->htp_u; if ( htp_u->hon_u == hon_u ) { htp_u->hon_u = hon_u->nex_u; } else { - u2_hcon *pre_u = htp_u->hon_u; + u3_hcon *pre_u = htp_u->hon_u; // XX glories of linear search // @@ -301,8 +301,8 @@ _http_conn_free(uv_handle_t* han_t) } while ( 0 != hon_u->req_u ) { - u2_hreq* req_u = hon_u->req_u; - u2_hreq* nex_u = req_u->nex_u; + u3_hreq* req_u = hon_u->req_u; + u3_hreq* nex_u = req_u->nex_u; _http_request_dead(req_u); _http_req_free(req_u); @@ -314,7 +314,7 @@ _http_conn_free(uv_handle_t* han_t) /* _http_conn_dead(): free http connection, close fd. */ static void -_http_conn_dead(u2_hcon *hon_u) +_http_conn_dead(u3_hcon *hon_u) { // uL(fprintf(uH, "connection dead: %d\n", hon_u->coq_l)); @@ -326,14 +326,14 @@ _http_conn_dead(u2_hcon *hon_u) /* _http_req_dump(): dump complete http request. */ static void -_http_req_dump(u2_hreq* req_u) +_http_req_dump(u3_hreq* req_u) { c3_c* mets[] = { "delete", "get", "head", "post", "put", "other" }; printf("%s %s\n", mets[req_u->met_e], req_u->url_c ? req_u->url_c : "(null)"); { - u2_hhed* hed_u = req_u->hed_u; + u3_hhed* hed_u = req_u->hed_u; while ( hed_u ) { printf("%s: %s\r\n", hed_u->nam_c, hed_u->val_c); @@ -341,7 +341,7 @@ _http_req_dump(u2_hreq* req_u) } } { - u2_hbod* bod_u = req_u->bod_u; + u3_hbod* bod_u = req_u->bod_u; c3_w bod_w = 0; while ( bod_u ) { @@ -386,7 +386,7 @@ _http_more(c3_c* str_c, const c3_c* buf_c, size_t siz_i) static c3_i _http_url(http_parser* par_u, const c3_c* buf_c, size_t siz_i) { - u2_hreq *req_u = par_u->data; + u3_hreq *req_u = par_u->data; req_u->url_c = _http_more(req_u->url_c, buf_c, siz_i); return 0; @@ -397,12 +397,12 @@ _http_url(http_parser* par_u, const c3_c* buf_c, size_t siz_i) static c3_i _http_header_field(http_parser* par_u, const c3_c* buf_c, size_t siz_i) { - u2_hreq *req_u = par_u->data; + u3_hreq *req_u = par_u->data; switch ( req_u->rat_e ) { - case u2_hreq_non: - case u2_hreq_val: { - u2_hhed* hed_u = c3_malloc(sizeof(*hed_u)); + case u3_hreq_non: + case u3_hreq_val: { + u3_hhed* hed_u = c3_malloc(sizeof(*hed_u)); hed_u->nam_c = _http_more(0, buf_c, siz_i); hed_u->val_c = 0; @@ -411,12 +411,12 @@ _http_header_field(http_parser* par_u, const c3_c* buf_c, size_t siz_i) break; } - case u2_hreq_nam: { + case u3_hreq_nam: { req_u->hed_u->nam_c = _http_more(req_u->hed_u->nam_c, buf_c, siz_i); break; } } - req_u->rat_e = u2_hreq_nam; + req_u->rat_e = u3_hreq_nam; return 0; } @@ -425,21 +425,21 @@ _http_header_field(http_parser* par_u, const c3_c* buf_c, size_t siz_i) static c3_i _http_header_value(http_parser* par_u, const c3_c* buf_c, size_t siz_i) { - u2_hreq *req_u = par_u->data; + u3_hreq *req_u = par_u->data; switch ( req_u->rat_e ) { - case u2_hreq_non: fprintf(stderr, "http: odd value\r\n"); return 1; + case u3_hreq_non: fprintf(stderr, "http: odd value\r\n"); return 1; - case u2_hreq_nam: { + case u3_hreq_nam: { req_u->hed_u->val_c = _http_more(0, buf_c, siz_i); break; } - case u2_hreq_val: { + case u3_hreq_val: { req_u->hed_u->val_c = _http_more(req_u->hed_u->val_c, buf_c, siz_i); break; } } - req_u->rat_e = u2_hreq_val; + req_u->rat_e = u3_hreq_val; return 0; } @@ -448,10 +448,10 @@ _http_header_value(http_parser* par_u, const c3_c* buf_c, size_t siz_i) static c3_i _http_headers_complete(http_parser* par_u) { - u2_hreq *req_u = par_u->data; + u3_hreq *req_u = par_u->data; - if ( par_u->method >= u2_hmet_other ) { - req_u->met_e = u2_hmet_other; + if ( par_u->method >= u3_hmet_other ) { + req_u->met_e = u3_hmet_other; } else req_u->met_e = par_u->method; return 0; @@ -462,8 +462,8 @@ _http_headers_complete(http_parser* par_u) static c3_i _http_body(http_parser* par_u, const c3_c* buf_c, size_t siz_i) { - u2_hreq *req_u = par_u->data; - u2_hbod* bod_u; + u3_hreq *req_u = par_u->data; + u3_hbod* bod_u; bod_u = _http_bod(siz_i, (const c3_y*)buf_c); @@ -483,8 +483,8 @@ _http_body(http_parser* par_u, const c3_c* buf_c, size_t siz_i) static c3_i _http_message_complete(http_parser* par_u) { - u2_hreq* req_u = par_u->data; - u2_hcon* hon_u = req_u->hon_u; + u3_hreq* req_u = par_u->data; + u3_hcon* hon_u = req_u->hon_u; c3_assert(req_u == hon_u->ruc_u); hon_u->ruc_u = 0; @@ -522,16 +522,16 @@ static struct http_parser_settings _http_settings = { /* _http_req_new(): new http request. */ -static u2_hreq* -_http_req_new(u2_hcon* hon_u) +static u3_hreq* +_http_req_new(u3_hcon* hon_u) { - u2_hreq* req_u = c3_malloc(sizeof(*req_u)); + u3_hreq* req_u = c3_malloc(sizeof(*req_u)); req_u->hon_u = hon_u; req_u->seq_l = hon_u->seq_l++; - req_u->met_e = (u2_hmet)0; - req_u->rat_e = (u2_hrat)0; + req_u->met_e = (u3_hmet)0; + req_u->rat_e = (u3_hrat)0; req_u->par_u = c3_malloc(sizeof(struct http_parser)); http_parser_init(req_u->par_u, HTTP_REQUEST); @@ -548,8 +548,8 @@ _http_req_new(u2_hcon* hon_u) else req_u->ipf_w = ntohl(adr_u.sin_addr.s_addr); } - req_u->liv = u2_no; - req_u->end = u2_no; + req_u->liv = u3_no; + req_u->end = u3_no; req_u->url_c = 0; @@ -581,9 +581,9 @@ _http_conn_read_cb(uv_stream_t* tcp_u, ssize_t siz_w, const uv_buf_t * buf_u) { - u2_hcon* hon_u = (u2_hcon*)(void*) tcp_u; + u3_hcon* hon_u = (u3_hcon*)(void*) tcp_u; - u2_lo_open(); + u3_lo_open(); { if ( siz_w == UV_EOF ) { _http_conn_dead(hon_u); @@ -609,17 +609,17 @@ _http_conn_read_cb(uv_stream_t* tcp_u, free(buf_u->base); } } - u2_lo_shut(u2_yes); + u3_lo_shut(u3_yes); } /* _http_conn_new(): create http connection. */ static void -_http_conn_new(u2_http *htp_u) +_http_conn_new(u3_http *htp_u) { - u2_hcon *hon_u = c3_malloc(sizeof(*hon_u)); + u3_hcon *hon_u = c3_malloc(sizeof(*hon_u)); - uv_tcp_init(u2L, &hon_u->wax_u); + uv_tcp_init(u3L, &hon_u->wax_u); c3_w ret_w; ret_w = uv_accept((uv_stream_t*)&htp_u->wax_u, @@ -650,10 +650,10 @@ _http_conn_new(u2_http *htp_u) /* _http_req_find(): find http request by sequence. */ -static u2_hreq* -_http_req_find(u2_hcon* hon_u, c3_w seq_l) +static u3_hreq* +_http_req_find(u3_hcon* hon_u, c3_w seq_l) { - u2_hreq* req_u = hon_u->req_u; + u3_hreq* req_u = hon_u->req_u; // XX glories of linear search // @@ -668,10 +668,10 @@ _http_req_find(u2_hcon* hon_u, c3_w seq_l) /* _http_serv_find(): find http connection by sequence. */ -static u2_http* +static u3_http* _http_serv_find(c3_l sev_l) { - u2_http* htp_u = u2_Host.htp_u; + u3_http* htp_u = u3_Host.htp_u; // XX glories of linear search // @@ -686,10 +686,10 @@ _http_serv_find(c3_l sev_l) /* _http_conn_find(): find http connection by sequence. */ -static u2_hcon* -_http_conn_find(u2_http *htp_u, c3_w coq_l) +static u3_hcon* +_http_conn_find(u3_http *htp_u, c3_w coq_l) { - u2_hcon* hon_u = htp_u->hon_u; + u3_hcon* hon_u = htp_u->hon_u; // XX glories of linear search // @@ -704,60 +704,60 @@ _http_conn_find(u2_http *htp_u, c3_w coq_l) /* _http_heds_to_list(): C headers to list. */ -static u2_noun -_http_heds_to_list(u2_hhed* hed_u) +static u3_noun +_http_heds_to_list(u3_hhed* hed_u) { if ( 0 == hed_u ) { - return u2_nul; + return u3_nul; } else { - return u2nc(u2nc(u2_ci_string(hed_u->nam_c), - hed_u->val_c ? u2_ci_string(hed_u->val_c) : u2_nul), + return u3nc(u3nc(u3_ci_string(hed_u->nam_c), + hed_u->val_c ? u3_ci_string(hed_u->val_c) : u3_nul), _http_heds_to_list(hed_u->nex_u)); } } /* _http_list_to_heds(): list to C headers. */ -static u2_hhed* -_http_list_to_heds(u2_noun lix) +static u3_hhed* +_http_list_to_heds(u3_noun lix) { - u2_noun yix = lix; - u2_hhed* hed_u = 0; + u3_noun yix = lix; + u3_hhed* hed_u = 0; while ( 1 ) { - if ( u2_nul == lix ) { + if ( u3_nul == lix ) { break; } else { - u2_noun i_lix = u2h(lix); - u2_noun pi_lix = u2h(i_lix); - u2_noun qi_lix = u2t(i_lix); - u2_noun t_lix = u2t(lix); - u2_hhed* nex_u = c3_malloc(sizeof(u2_hhed)); + u3_noun i_lix = u3h(lix); + u3_noun pi_lix = u3h(i_lix); + u3_noun qi_lix = u3t(i_lix); + u3_noun t_lix = u3t(lix); + u3_hhed* nex_u = c3_malloc(sizeof(u3_hhed)); - nex_u->nam_c = u2_cr_string(pi_lix); - nex_u->val_c = u2_cr_string(qi_lix); + nex_u->nam_c = u3_cr_string(pi_lix); + nex_u->val_c = u3_cr_string(qi_lix); nex_u->nex_u = hed_u; hed_u = nex_u; lix = t_lix; } } - u2z(yix); + u3z(yix); return hed_u; } /* _http_bods_to_octs: translate body into octet-stream noun. */ -static u2_noun -_http_bods_to_octs(u2_hbod* bod_u) +static u3_noun +_http_bods_to_octs(u3_hbod* bod_u) { c3_w len_w; c3_y* buf_y; - u2_noun cos; + u3_noun cos; { - u2_hbod* bid_u; + u3_hbod* bid_u; len_w = 0; for ( bid_u = bod_u; bid_u; bid_u = bid_u->nex_u ) { @@ -775,144 +775,141 @@ _http_bods_to_octs(u2_hbod* bod_u) bod_u = bod_u->nex_u; } } - cos = u2_ci_bytes(len_w, buf_y); + cos = u3_ci_bytes(len_w, buf_y); free(buf_y); - return u2nc(len_w, cos); + return u3nc(len_w, cos); } /* _http_octs_to_bod(): translate octet-stream noun into body. */ -static u2_hbod* -_http_octs_to_bod(u2_noun oct) +static u3_hbod* +_http_octs_to_bod(u3_noun oct) { c3_w len_w; - if ( !u2_fly_is_cat(u2h(oct)) ) { + if ( u3_ne(u3_co_is_cat(u3h(oct))) ) { // 2GB max - u2_cm_bail(c3__fail); return 0; + u3_cm_bail(c3__fail); return 0; } - len_w = u2h(oct); + len_w = u3h(oct); { - u2_hbod* bod_u = c3_malloc(len_w + sizeof(*bod_u)); + u3_hbod* bod_u = c3_malloc(len_w + sizeof(*bod_u)); bod_u->len_w = len_w; - u2_cr_bytes(0, len_w, bod_u->hun_y, u2t(oct)); + u3_cr_bytes(0, len_w, bod_u->hun_y, u3t(oct)); bod_u->nex_u = 0; - u2z(oct); + u3z(oct); return bod_u; } } /* _http_pox_to_noun(): translate srv/con/req to path noun (pox). */ -static u2_noun +static u3_noun _http_pox_to_noun(c3_w sev_l, c3_w coq_l, c3_w seq_l) { return - u2nt( - u2_blip, + u3nt( + u3_blip, c3__http, - u2nq(u2_dc("scot", c3_s2('u','v'), sev_l), - u2_dc("scot", c3_s2('u','d'), coq_l), - u2_dc("scot", c3_s2('u','d'), seq_l), - u2_nul)); + u3nq(u3_dc("scot", c3_s2('u','v'), sev_l), + u3_dc("scot", c3_s2('u','d'), coq_l), + u3_dc("scot", c3_s2('u','d'), seq_l), + u3_nul)); } -/* _http_request_to_noun(): translate http request into noun, or u2_none. +/* _http_request_to_noun(): translate http request into noun, or u3_none. */ -static u2_noun -_http_request_to_noun(u2_hreq* req_u) +static u3_noun +_http_request_to_noun(u3_hreq* req_u) { - u2_noun med, url, hed, bod; + u3_noun med, url, hed, bod; switch ( req_u->met_e ) { - default: fprintf(stderr, "strange request\r\n"); return u2_none; - case u2_hmet_put: { med = c3__put; break; } - case u2_hmet_get: { med = c3__get; break; } - case u2_hmet_post: { med = c3__post; break; } + default: fprintf(stderr, "strange request\r\n"); return u3_none; + case u3_hmet_put: { med = c3__put; break; } + case u3_hmet_get: { med = c3__get; break; } + case u3_hmet_post: { med = c3__post; break; } } - url = u2_ci_string(req_u->url_c); + url = u3_ci_string(req_u->url_c); hed = _http_heds_to_list(req_u->hed_u); - bod = req_u->bod_u ? u2nc(u2_nul, _http_bods_to_octs(req_u->bod_u)) : u2_nul; + bod = req_u->bod_u ? u3nc(u3_nul, _http_bods_to_octs(req_u->bod_u)) : u3_nul; - return u2nq(med, url, hed, bod); + return u3nq(med, url, hed, bod); } /* _http_new_response(): create http response structure. */ -static u2_hrep* -_http_new_response(c3_l sev_l, c3_l coq_l, c3_l seq_l, u2_noun rep) +static u3_hrep* +_http_new_response(c3_l sev_l, c3_l coq_l, c3_l seq_l, u3_noun rep) { - u2_noun p_rep, q_rep, r_rep; + u3_noun p_rep, q_rep, r_rep; - if ( u2_no == u2_cr_trel(rep, &p_rep, &q_rep, &r_rep) ) { + if ( u3_no == u3_cr_trel(rep, &p_rep, &q_rep, &r_rep) ) { uL(fprintf(uH, "strange response\n")); return 0; } else { - u2_hrep* rep_u = c3_malloc(sizeof(u2_hrep)); + u3_hrep* rep_u = c3_malloc(sizeof(u3_hrep)); rep_u->sev_l = sev_l; rep_u->coq_l = coq_l; rep_u->seq_l = seq_l; rep_u->sas_w = p_rep; - rep_u->hed_u = _http_list_to_heds(u2k(q_rep)); - rep_u->bod_u = (u2_nul == r_rep) ? 0 : _http_octs_to_bod(u2k(u2t(r_rep))); + rep_u->hed_u = _http_list_to_heds(u3k(q_rep)); + rep_u->bod_u = (u3_nul == r_rep) ? 0 : _http_octs_to_bod(u3k(u3t(r_rep))); - u2z(rep); return rep_u; + u3z(rep); return rep_u; } } /* _http_request(): dispatch http request, returning null if async. */ static void -_http_request(u2_hreq* req_u) +_http_request(u3_hreq* req_u) { - u2_noun req = _http_request_to_noun(req_u); + u3_noun req = _http_request_to_noun(req_u); - if ( u2_none != req ) { - u2_noun pox = _http_pox_to_noun(req_u->hon_u->htp_u->sev_l, + if ( u3_none != req ) { + u3_noun pox = _http_pox_to_noun(req_u->hon_u->htp_u->sev_l, req_u->hon_u->coq_l, req_u->seq_l); - u2_reck_plan(u2_Host.arv_u, - pox, - u2nq(c3__this, - req_u->hon_u->htp_u->sec, - u2nc(u2_yes, u2_ci_words(1, &req_u->ipf_w)), - req)); + u3_cv_plan(pox, + u3nq(c3__this, + req_u->hon_u->htp_u->sec, + u3nc(u3_yes, u3_ci_words(1, &req_u->ipf_w)), + req)); } } /* _http_request_dead(): kill http request. */ static void -_http_request_dead(u2_hreq* req_u) +_http_request_dead(u3_hreq* req_u) { - u2_noun pox = _http_pox_to_noun(req_u->hon_u->htp_u->sev_l, + u3_noun pox = _http_pox_to_noun(req_u->hon_u->htp_u->sev_l, req_u->hon_u->coq_l, req_u->seq_l); - u2_reck_plan(u2_Host.arv_u, - pox, - u2nc(c3__thud, u2_nul)); + u3_cv_plan(pox, u3nc(c3__thud, u3_nul)); } /* _http_flush(): transmit any ready data. */ static void -_http_flush(u2_hcon* hon_u) +_http_flush(u3_hcon* hon_u) { while ( hon_u->req_u ) { - u2_hreq* req_u = hon_u->req_u; - u2_hbod* rub_u = req_u->rub_u; + u3_hreq* req_u = hon_u->req_u; + u3_hbod* rub_u = req_u->rub_u; if ( 0 == rub_u ) { - if ( u2_yes == req_u->end ) { + if ( u3_yes == req_u->end ) { hon_u->req_u = req_u->nex_u; if ( 0 == hon_u->req_u ) { c3_assert(req_u == hon_u->qer_u); @@ -945,11 +942,11 @@ _http_flush(u2_hcon* hon_u) /* _http_respond(): attach http response. */ static void -_http_respond(u2_hrep* rep_u) +_http_respond(u3_hrep* rep_u) { - u2_http* htp_u; - u2_hcon* hon_u; - u2_hreq* req_u; + u3_http* htp_u; + u3_hcon* hon_u; + u3_hreq* req_u; if ( !(htp_u = _http_serv_find(rep_u->sev_l)) ) { uL(fprintf(uH, "http: server not found: %x\r\n", rep_u->sev_l)); @@ -980,22 +977,22 @@ _http_respond(u2_hrep* rep_u) } void -u2_http_ef_bake(void) +u3_http_ef_bake(void) { - u2_noun pax = u2nq(u2_blip, c3__http, u2k(u2A->sen), u2_nul); + u3_noun pax = u3nq(u3_blip, c3__http, u3k(u3A->sen), u3_nul); - u2_reck_plan(u2A, pax, u2nc(c3__born, u2_nul)); + u3_cv_plan(pax, u3nc(c3__born, u3_nul)); } -/* u2_http_ef_thou(): send %thou effect (incoming response) to http. +/* u3_http_ef_thou(): send %thou effect (incoming response) to http. */ void -u2_http_ef_thou(c3_l sev_l, +u3_http_ef_thou(c3_l sev_l, c3_l coq_l, c3_l seq_l, - u2_noun rep) + u3_noun rep) { - u2_hrep* rep_u = _http_new_response(sev_l, coq_l, seq_l, rep); + u3_hrep* rep_u = _http_new_response(sev_l, coq_l, seq_l, rep); if ( !rep_u ) { uL(fprintf(uH, "http: response dropped\r\n")); @@ -1008,7 +1005,7 @@ u2_http_ef_thou(c3_l sev_l, static void _http_listen_cb(uv_stream_t* str_u, c3_i sas_i) { - u2_http* htp_u = (u2_http*)str_u; + u3_http* htp_u = (u3_http*)str_u; if ( 0 != sas_i ) { uL(fprintf(uH, "http: listen_cb: ERROR\n")); @@ -1021,11 +1018,11 @@ _http_listen_cb(uv_stream_t* str_u, c3_i sas_i) /* _http_start(): start http server. */ static void -_http_start(u2_http* htp_u) +_http_start(u3_http* htp_u) { struct sockaddr_in add_u; - uv_tcp_init(u2L, &htp_u->wax_u); + uv_tcp_init(u3L, &htp_u->wax_u); memset(&add_u, 0, sizeof(add_u)); add_u.sin_family = AF_INET; @@ -1057,75 +1054,75 @@ _http_start(u2_http* htp_u) } } uL(fprintf(uH, "http: live (%s) on %d\n", - (u2_yes == htp_u->sec) ? "\"secure\"" : "insecure", + (u3_yes == htp_u->sec) ? "\"secure\"" : "insecure", htp_u->por_w)); break; } } -/* u2_http_io_init(): initialize http I/O. +/* u3_http_io_init(): initialize http I/O. */ void -u2_http_io_init() +u3_http_io_init() { // Logically secure port. { - u2_http *htp_u = c3_malloc(sizeof(*htp_u)); + u3_http *htp_u = c3_malloc(sizeof(*htp_u)); - htp_u->sev_l = u2A->sev_l + 1; + htp_u->sev_l = u3A->sev_l + 1; htp_u->coq_l = 1; htp_u->por_w = 8443; - htp_u->sec = u2_yes; + htp_u->sec = u3_yes; htp_u->hon_u = 0; htp_u->nex_u = 0; - htp_u->nex_u = u2_Host.htp_u; - u2_Host.htp_u = htp_u; + htp_u->nex_u = u3_Host.htp_u; + u3_Host.htp_u = htp_u; } // Insecure port. // { - u2_http *htp_u = c3_malloc(sizeof(*htp_u)); + u3_http *htp_u = c3_malloc(sizeof(*htp_u)); - htp_u->sev_l = u2A->sev_l; + htp_u->sev_l = u3A->sev_l; htp_u->coq_l = 1; htp_u->por_w = 8080; - htp_u->sec = u2_no; + htp_u->sec = u3_no; htp_u->hon_u = 0; htp_u->nex_u = 0; - htp_u->nex_u = u2_Host.htp_u; - u2_Host.htp_u = htp_u; + htp_u->nex_u = u3_Host.htp_u; + u3_Host.htp_u = htp_u; } - u2_Host.ctp_u.coc_u = 0; + u3_Host.ctp_u.coc_u = 0; } -/* u2_http_io_talk(): bring up listener. +/* u3_http_io_talk(): bring up listener. */ void -u2_http_io_talk() +u3_http_io_talk() { - u2_http* htp_u; + u3_http* htp_u; - for ( htp_u = u2_Host.htp_u; htp_u; htp_u = htp_u->nex_u ) { + for ( htp_u = u3_Host.htp_u; htp_u; htp_u = htp_u->nex_u ) { _http_start(htp_u); } } -/* u2_http_io_poll(): poll kernel for http I/O. +/* u3_http_io_poll(): poll kernel for http I/O. */ void -u2_http_io_poll(void) +u3_http_io_poll(void) { } -/* u2_http_io_exit(): shut down http. +/* u3_http_io_exit(): shut down http. */ void -u2_http_io_exit(void) +u3_http_io_exit(void) { } diff --git a/v/loop.c b/v/loop.c index 6d1979438..3fa4ce71b 100644 --- a/v/loop.c +++ b/v/loop.c @@ -24,12 +24,16 @@ #include "all.h" #include "v/vere.h" + +#if 0 static jmp_buf Signal_buf; #ifndef SIGSTKSZ # define SIGSTKSZ 16384 #endif static uint8_t Sigstk[SIGSTKSZ]; +uint8_t u3_Critical; + typedef enum { sig_none, sig_overflow, @@ -38,9 +42,9 @@ typedef enum { sig_memory, sig_assert, sig_timer -} u2_kill; +} u3_kill; -volatile u2_kill Sigcause; // reasons for exception +volatile u3_kill Sigcause; // reasons for exception static void _lo_cont(void *arg1, void *arg2, void *arg3) { @@ -53,7 +57,7 @@ static void _lo_cont(void *arg1, void *arg2, void *arg3) static void _lo_signal_handle_over(int emergency, stackoverflow_context_t scp) { - if ( u2_Critical ) { + if ( u3_Critical ) { // Careful not to grow the stack during critical sections. // write(2, "stack disaster\n", strlen("stack disaster" + 2)); @@ -75,9 +79,9 @@ _lo_signal_handle_over(int emergency, stackoverflow_context_t scp) static void _lo_signal_handle_term(int x) { - if ( !u2_Critical ) { + if ( !u3_Critical ) { Sigcause = sig_terminate; - u2_Host.liv = u2_no; + u3_Host.liv = u3_no; longjmp(Signal_buf, 1); } } @@ -85,7 +89,7 @@ _lo_signal_handle_term(int x) static void _lo_signal_handle_intr(int x) { - if ( !u2_Critical ) { + if ( !u3_Critical ) { Sigcause = sig_interrupt; longjmp(Signal_buf, 1); } @@ -94,7 +98,7 @@ _lo_signal_handle_intr(int x) static void _lo_signal_handle_alrm(int x) { - if ( !u2_Critical ) { + if ( !u3_Critical ) { Sigcause = sig_timer; longjmp(Signal_buf, 1); } @@ -118,7 +122,7 @@ _lo_signal_done() setitimer(ITIMER_VIRTUAL, &itm_u, 0); } - u2_unix_ef_move(); + u3_unix_ef_move(); } /* _lo_signal_deep(): start deep processing; set timer for sec_w or 0. @@ -126,7 +130,7 @@ _lo_signal_done() static void _lo_signal_deep(c3_w sec_w) { - u2_unix_ef_hold(); + u3_unix_ef_hold(); stackoverflow_install_handler(_lo_signal_handle_over, Sigstk, SIGSTKSZ); signal(SIGINT, _lo_signal_handle_intr); @@ -143,17 +147,20 @@ _lo_signal_deep(c3_w sec_w) } signal(SIGVTALRM, _lo_signal_handle_alrm); } +#endif -/* u2_loop_signal_memory(): end computation for out-of-memory. +/* u3_loop_signal_memory(): end computation for out-of-memory. */ void -u2_loop_signal_memory() +u3_loop_signal_memory() { fprintf(stderr, "\r\nout of memory\r\n"); c3_assert(0); +#if 0 Sigcause = sig_memory; longjmp(Signal_buf, 1); +#endif } /* _lo_init(): initialize I/O across the process. @@ -161,13 +168,13 @@ u2_loop_signal_memory() static void _lo_init() { - u2_unix_io_init(); - u2_ames_io_init(); - u2_term_io_init(); - u2_http_io_init(); - u2_cttp_io_init(); - u2_save_io_init(); - u2_batz_io_init(); + u3_unix_io_init(); + u3_ames_io_init(); + u3_term_io_init(); + u3_http_io_init(); + u3_cttp_io_init(); + // u3_save_io_init(); + u3_batz_io_init(); } /* _lo_talk(): bring up listeners across the process. @@ -175,24 +182,24 @@ _lo_init() static void _lo_talk() { - u2_unix_io_talk(); - u2_ames_io_talk(); - u2_http_io_talk(); - u2_term_io_talk(); + u3_unix_io_talk(); + u3_ames_io_talk(); + u3_http_io_talk(); + u3_term_io_talk(); } -/* u2_lo_exit(): terminate I/O across the process. +/* u3_lo_exit(): terminate I/O across the process. */ void -u2_lo_exit(void) +u3_lo_exit(void) { - u2_unix_io_exit(); - u2_ames_io_exit(); - u2_term_io_exit(); - u2_http_io_exit(); - u2_cttp_io_exit(); - u2_save_io_exit(); - u2_batz_io_exit(); + u3_unix_io_exit(); + u3_ames_io_exit(); + u3_term_io_exit(); + u3_http_io_exit(); + u3_cttp_io_exit(); + // u3_save_io_exit(); + u3_batz_io_exit(); } /* _lo_poll(): reset event flags across the process. @@ -200,19 +207,19 @@ u2_lo_exit(void) static void _lo_poll(void) { - u2_ames_io_poll(); - u2_http_io_poll(); - u2_term_io_poll(); - u2_save_io_poll(); - u2_unix_io_poll(); - u2_batz_io_poll(); + u3_ames_io_poll(); + u3_http_io_poll(); + u3_term_io_poll(); + // u3_save_io_poll(); + u3_unix_io_poll(); + u3_batz_io_poll(); } #if 0 /* _lo_how(): print how. */ static const c3_c* -_lo_how(u2_noun how) +_lo_how(u3_noun how) { switch ( how ) { default: c3_assert(0); break; @@ -228,263 +235,156 @@ _lo_how(u2_noun how) } #endif -/* u2_lo_bail(): clean up all event state. +/* u3_lo_bail(): clean up all event state. */ void -u2_lo_bail(u2_reck* rec_u) +u3_lo_bail(void) { fflush(stdout); - u2_lo_exit(); + u3_lo_exit(); exit(1); } -int c3_cooked() { u2_lo_exit(); return 0; } +int c3_cooked() { u3_lo_exit(); return 0; } /* _lo_tape(): dump a tape, old style. Don't do this. */ static void -_lo_tape(u2_reck* rec_u, FILE* fil_u, u2_noun tep) +_lo_tape(FILE* fil_u, u3_noun tep) { - u2_noun tap = tep; + u3_noun tap = tep; - while ( u2_nul != tap ) { + while ( u3_nul != tap ) { c3_c car_c; - if ( u2h(tap) >= 127 ) { + if ( u3h(tap) >= 127 ) { car_c = '?'; - } else car_c = u2h(tap); + } else car_c = u3h(tap); putc(car_c, fil_u); - tap = u2t(tap); + tap = u3t(tap); } - u2z(tep); + u3z(tep); } /* _lo_wall(): dump a wall, old style. Don't do this. */ static void -_lo_wall(u2_reck* rec_u, u2_noun wol) +_lo_wall(u3_noun wol) { - FILE* fil_u = u2_term_io_hija(); - u2_noun wal = wol; + FILE* fil_u = u3_term_io_hija(); + u3_noun wal = wol; - while ( u2_nul != wal ) { - _lo_tape(rec_u, fil_u, u2k(u2h(wal))); + while ( u3_nul != wal ) { + _lo_tape(fil_u, u3k(u3h(wal))); putc(13, fil_u); putc(10, fil_u); - wal = u2t(wal); + wal = u3t(wal); } - u2_term_io_loja(0); - u2z(wol); + u3_term_io_loja(0); + u3z(wol); } -/* u2_lo_tank(): dump single tank. +/* u3_lo_tank(): dump single tank. */ void -u2_lo_tank(c3_l tab_l, u2_noun tac) +u3_lo_tank(c3_l tab_l, u3_noun tac) { - u2_lo_punt(tab_l, u2nc(tac, u2_nul)); + u3_lo_punt(tab_l, u3nc(tac, u3_nul)); } -/* u2_lo_punt(): dump tank list. +/* u3_lo_punt(): dump tank list. */ void -u2_lo_punt(c3_l tab_l, u2_noun tac) +u3_lo_punt(c3_l tab_l, u3_noun tac) { - u2_noun blu = u2_term_get_blew(0); - c3_l col_l = u2h(blu); - u2_noun cat = tac; + u3_noun blu = u3_term_get_blew(0); + c3_l col_l = u3h(blu); + u3_noun cat = tac; // We are calling nock here, but hopefully need no protection. // - while ( u2_yes == u2_cr_du(cat) ) { - u2_noun wol = u2_dc("wash", u2nc(tab_l, col_l), u2k(u2h(cat))); + while ( u3_yes == u3_cr_du(cat) ) { + u3_noun wol = u3_dc("wash", u3nc(tab_l, col_l), u3k(u3h(cat))); - _lo_wall(u2_Arv, wol); - cat = u2t(cat); + _lo_wall(wol); + cat = u3t(cat); } - u2z(tac); - u2z(blu); + u3z(tac); + u3z(blu); } -/* u2_lo_sway(): print trace. +/* u3_lo_sway(): print trace. */ void -u2_lo_sway(c3_l tab_l, u2_noun tax) +u3_lo_sway(c3_l tab_l, u3_noun tax) { - u2_noun mok = u2_dc("mook", 2, tax); + u3_noun mok = u3_dc("mook", 2, tax); - u2_lo_punt(tab_l, u2k(u2t(mok))); - u2z(mok); + u3_lo_punt(tab_l, u3k(u3t(mok))); + u3z(mok); } -/* u2_lo_soft(): standard soft wrapper. unifies unix and nock errors. -** -** Produces [%$ result] or [%error (list tank)]. +/* _lo_time(): set time. */ -u2_noun -u2_lo_soft(u2_reck* rec_u, c3_w sec_w, u2_funk fun_f, u2_noun arg) +static void +_lo_time(void) { - u2_noun hoe, pro, rop; + struct timeval tim_tv; - u2_rl_leap(u2_Wire, c3__rock); - - // system level setjmp, for signals - // - c3_assert(u2_nul == u2_wire_tax(u2_Wire)); - c3_assert(0 == u2_wire_kit_r(u2_Wire)); - - // stop signals - // - u2_unix_ef_hold(); - _lo_signal_deep(sec_w); - - if ( 0 != sigsetjmp(Signal_buf, 1) ) { - u2_noun tax, pre, mok; - - // return to blank state - // - _lo_signal_done(); - - // acquire trace and reset memory - // - tax = u2_wire_tax(u2_Wire); - u2_rl_fall(u2_Wire); - u2z(arg); - - tax = u2_rl_take(u2_Wire, tax); - u2_wire_tax(u2_Wire) = u2_nul; - mok = u2_dc("mook", 2, tax); - - // other ugly disgusting cleanups - { - u2_wire_kit_r(u2_Wire) = 0; - - u2_hevx_be(u2_wire_hev_r(u2_Wire), u2_pryr, god) = 0; - u2_hevx_at(u2_wire_hev_r(u2_Wire), lad) = 0; - } - - switch ( Sigcause ) { - default: pre = c3__wyrd; break; - case sig_none: pre = c3__none; break; - case sig_overflow: pre = c3__over; break; - case sig_interrupt: pre = c3__intr; break; - case sig_terminate: pre = c3__term; break; - case sig_memory: pre = c3__full; break; - case sig_assert: pre = c3__lame; break; - case sig_timer: fprintf(stderr, "timer!!\r\n"); pre = c3__slow; break; - } - rop = u2nc(pre, u2k(u2t(mok))); - u2z(mok); - fprintf(stderr, "error computed\r\n"); - return rop; - } - - if ( 0 != (hoe = u2_cm_trap()) ) { - u2_noun mok; - - u2_rl_fall(u2_Wire); - hoe = u2_rl_take(u2_Wire, hoe); - u2_rl_flog(u2_Wire); - - mok = u2_dc("mook", 2, u2k(u2t(hoe))); - rop = u2nc(u2k(u2h(hoe)), u2k(u2t(mok))); - - u2z(arg); - u2z(hoe); - u2z(mok); - } - else { - u2_noun pro = fun_f(rec_u, arg); - - _lo_signal_done(); - u2_cm_done(); - - u2_rl_fall(u2_Wire); - pro = u2_rl_take(u2_Wire, pro); - u2_rl_flog(u2_Wire); - - u2z(arg); - rop = u2nc(u2_blip, pro); - } - pro = rop; - - return pro; + gettimeofday(&tim_tv, 0); + u3_cv_time(u3_time_in_tv(&tim_tv)); } -#if 0 -/* _lo_hard(): standard hard wrapper. Produces result and/or asserts. -*/ -static u2_noun -_lo_hard(u2_reck* rec_u, u2_funk fun_f, u2_noun arg) -{ - u2_noun pro = u2_lo_soft(rec_u, 0, fun_f, arg); - - if ( u2_blip == u2h(pro) ) { - u2_noun poo = u2k(u2t(pro)); - - u2z(pro); return poo; - } - else { - u2_lo_punt(2, u2k(u2t(pro))); - u2z(pro); - c3_assert(0); - } -} -#endif - -/* u2_lo_open(): begin callback processing. +/* u3_lo_open(): begin callback processing. */ void -u2_lo_open(void) +u3_lo_open(void) { - // update time - // - u2_reck_time(u2A); + _lo_time(); } -/* u2_lo_shut(): end callback processing. +/* u3_lo_shut(): end callback processing. */ void -u2_lo_shut(u2_bean inn) +u3_lo_shut(u3_bean inn) { - // u2_lo_grab("lo_shut a", u2_none); + // u3_lo_grab("lo_shut a", u3_none); // process actions // - u2_raft_work(u2A); + u3_raft_work(); - // u2_lo_grab("lo_shut b", u2_none); + // u3_lo_grab("lo_shut b", u3_none); // update time // - u2_reck_time(u2A); + _lo_time(); - // u2_lo_grab("lo_shut c", u2_none); + // u3_lo_grab("lo_shut c", u3_none); // for input operations, poll fs (XX not permanent) // XX remove raty_lead guard // - if ( u2R->typ_e == u2_raty_lead && u2_yes == inn ) { - u2_unix_ef_look(); + if ( u3_yes == inn ) { + u3_unix_ef_look(); } - // u2_lo_grab("lo_shut d", u2_none); + // u3_lo_grab("lo_shut d", u3_none); // clean shutdown // - if ( u2_no == u2_Host.liv ) { + if ( u3_no == u3_Host.liv ) { // direct save and die // - u2_cm_purge(); - // u2_lo_grab("lo_exit", u2_none); - u2_loom_save(u2A->ent_d); - u2_loom_exit(); - u2_lo_exit(); + // u3_lo_grab("lo_exit", u3_none); + // u3_loom_save(u3A->ent_d); + // u3_loom_exit(); + u3_lo_exit(); - exit(u2_Host.xit_i); + exit(u3_Host.xit_i); } else { // poll arvo to generate any event binding changes @@ -502,11 +402,11 @@ _lo_bench_noop(c3_w num_w) c3_w i_w; for ( i_w = 0; i_w < num_w; i_w++ ) { - u2_reck_plan(u2A, u2nq(u2_blip, c3__term, 1, u2_nul), - u2nc(c3__noop, u2_nul)); + u3_reck_plan(u3A, u3nq(u3_blip, c3__term, 1, u3_nul), + u3nc(c3__noop, u3_nul)); } - u2_raft_work(u2A); + u3_raft_work(u3A); } // _lo_bench_scot_p(): benchmark prettyprint. @@ -517,9 +417,9 @@ _lo_bench_scot_p(c3_w num_w) c3_w i_w; for ( i_w = 0; i_w < num_w; i_w++ ) { - u2_noun soc = u2_dc("scot", 'p', u2k(u2A->now)); + u3_noun soc = u3_dc("scot", 'p', u3k(u3A->now)); - u2z(soc); + u3z(soc); } } @@ -531,10 +431,10 @@ _lo_bench_slay_p(c3_w num_w) c3_w i_w; for ( i_w = 0; i_w < num_w; i_w++ ) { - u2_noun soc = u2_dc("scot", 'p', u2k(u2A->now)); - u2_noun dub = u2_do("slay", soc); + u3_noun soc = u3_dc("scot", 'p', u3k(u3A->now)); + u3_noun dub = u3_do("slay", soc); - u2z(dub); + u3z(dub); } } @@ -546,9 +446,9 @@ _lo_bench_scot_da(c3_w num_w) c3_w i_w; for ( i_w = 0; i_w < num_w; i_w++ ) { - u2_noun soc = u2_dc("scot", c3__da, u2k(u2A->now)); + u3_noun soc = u3_dc("scot", c3__da, u3k(u3A->now)); - u2z(soc); + u3z(soc); } } @@ -560,9 +460,9 @@ _lo_bench_dec(c3_w num_w) c3_w i_w; for ( i_w = 0; i_w < num_w; i_w++ ) { - u2_noun soc = u2_do("dec", u2k(u2A->now)); + u3_noun soc = u3_do("dec", u3k(u3A->now)); - u2z(soc); + u3z(soc); } } @@ -574,9 +474,9 @@ _lo_bench_scot_ud(c3_w num_w) c3_w i_w; for ( i_w = 0; i_w < num_w; i_w++ ) { - u2_noun soc = u2_dc("scot", c3__ud, u2k(u2A->now)); + u3_noun soc = u3_dc("scot", c3__ud, u3k(u3A->now)); - u2z(soc); + u3z(soc); } } @@ -585,18 +485,18 @@ _lo_bench_scot_ud(c3_w num_w) static void _lo_bench(const c3_c* lab_c, void (*fun)(c3_w), c3_w num_w) { - u2_noun old, new; + u3_noun old, new; uL(fprintf(uH, "bench: %s: start...\n", lab_c)); - u2_reck_time(u2A); - old = u2k(u2A->now); + u3_reck_time(u3A); + old = u3k(u3A->now); fun(num_w); - u2_reck_time(u2A); - new = u2k(u2A->now); + u3_reck_time(u3A); + new = u3k(u3A->now); { - c3_w tms_w = (c3_w)u2_time_gap_ms(old, new); + c3_w tms_w = (c3_w)u3_time_gap_ms(old, new); if ( tms_w > (10 * num_w) ) { uL(fprintf(uH, "bench: %s*%d: %d ms, %d ms each.\n", @@ -610,16 +510,16 @@ _lo_bench(const c3_c* lab_c, void (*fun)(c3_w), c3_w num_w) } #endif -/* u2_lo_show(): generic noun print. +/* u3_lo_show(): generic noun print. */ void -u2_lo_show(c3_c* cap_c, u2_noun nun) +u3_lo_show(c3_c* cap_c, u3_noun nun) { - u2_noun pav = u2_dc("pave", c3__noun, nun); - c3_c* txt_c = (c3_c*)u2_cr_tape(pav); + u3_noun pav = u3_dc("pave", c3__noun, nun); + c3_c* txt_c = (c3_c*)u3_cr_tape(pav); fprintf(stderr, "%s: %s\r\n", cap_c, txt_c); - u2z(pav); + u3z(pav); free(txt_c); } @@ -635,53 +535,53 @@ _lo_slow() #endif } -/* u2_lo_loop(): begin main event loop. +/* u3_lo_loop(): begin main event loop. */ void -u2_lo_loop() +u3_lo_loop() { uv_loop_t* lup_u = uv_default_loop(); - u2_Host.lup_u = lup_u; + u3_Host.lup_u = lup_u; signal(SIGPIPE, SIG_IGN); // pipe, schmipe // signal(SIGIO, SIG_IGN); // linux is wont to produce for some reason _lo_init(); - u2_raft_init(); + u3_raft_init(); - if ( u2_no == u2_Host.ops_u.bat ) { - uv_run(u2L, UV_RUN_DEFAULT); + if ( u3_no == u3_Host.ops_u.bat ) { + uv_run(u3L, UV_RUN_DEFAULT); } } -/* u2_lo_lead(): actions on promotion to leader. +/* u3_lo_lead(): actions on promotion to leader. */ void -u2_lo_lead(u2_reck* rec_u) +u3_lo_lead(void) { // Further server configuration. // { - u2_http_ef_bake(); + u3_http_ef_bake(); } _lo_talk(); { - u2_unix_ef_look(); - u2_reck_plan(rec_u, u2nt(u2_blip, c3__ames, u2_nul), - u2nc(c3__kick, u2k(rec_u->now))); + u3_unix_ef_look(); + u3_cv_plan(u3nt(u3_blip, c3__ames, u3_nul), + u3nc(c3__kick, u3k(u3A->now))); } _lo_poll(); -#if 1 - u2_loom_save(rec_u->ent_d); +#if 0 + u3_loom_save(u3A->ent_d); - u2_Host.sav_u.ent_d = rec_u->ent_d; + u3_Host.sav_u.ent_d = rec_u->ent_d; #endif - if ( u2_yes == u2_Host.ops_u.nuu ) { - u2_term_ef_boil(1); + if ( u3_yes == u3_Host.ops_u.nuu ) { + u3_term_ef_boil(1); } #if 1 @@ -689,31 +589,32 @@ u2_lo_lead(u2_reck* rec_u) #endif } +#if 0 /* _lo_mark_reck(): mark a reck. */ static c3_w -_lo_mark_reck(u2_reck* rec_u) +_lo_mark_reck(u3_reck* rec_u) { c3_w siz_w = 0; c3_w egg_w; - siz_w += u2_cm_mark_noun(rec_u->ken); - siz_w += u2_cm_mark_noun(rec_u->roc); + siz_w += u3_cm_mark_noun(rec_u->ken); + siz_w += u3_cm_mark_noun(rec_u->roc); - siz_w += u2_cm_mark_noun(rec_u->yot); - siz_w += u2_cm_mark_noun(rec_u->now); - siz_w += u2_cm_mark_noun(rec_u->wen); - siz_w += u2_cm_mark_noun(rec_u->sen); - siz_w += u2_cm_mark_noun(rec_u->own); - siz_w += u2_cm_mark_noun(rec_u->roe); - siz_w += u2_cm_mark_noun(rec_u->key); + siz_w += u3_cm_mark_noun(rec_u->yot); + siz_w += u3_cm_mark_noun(rec_u->now); + siz_w += u3_cm_mark_noun(rec_u->wen); + siz_w += u3_cm_mark_noun(rec_u->sen); + siz_w += u3_cm_mark_noun(rec_u->own); + siz_w += u3_cm_mark_noun(rec_u->roe); + siz_w += u3_cm_mark_noun(rec_u->key); { - u2_cart* egg_u; + u3_cart* egg_u; egg_w = 0; for ( egg_u = rec_u->ova.egg_u; egg_u; egg_u = egg_u->nex_u ) { - egg_w += u2_cm_mark_noun(egg_u->vir); + egg_w += u3_cm_mark_noun(egg_u->vir); } siz_w += egg_w; } @@ -731,64 +632,66 @@ _lo_mark() { c3_w siz_w; - siz_w = u2_cm_mark_internal(); - siz_w += _lo_mark_reck(u2_Host.arv_u); + siz_w = u3_cm_mark_internal(); + siz_w += _lo_mark_reck(u3_Host.arv_u); return siz_w; } +#endif +#if 0 /* _lo_word(): print a word to the passed stream. */ static void _lo_word(FILE* fil_u, c3_w wod_w) { - u2_bean top = u2_yes; + u3_bean top = u3_yes; if ( wod_w / (1000 * 1000 * 1000) ) { fprintf(fil_u, "%u.", wod_w / (1000 * 1000 * 1000)); wod_w %= (1000 * 1000 * 1000); - top = u2_no; + top = u3_no; } if ( wod_w / (1000 * 1000) ) { - fprintf(fil_u, ((top == u2_yes) ? "%u." : "%03u."), + fprintf(fil_u, ((top == u3_yes) ? "%u." : "%03u."), wod_w / (1000 * 1000)); wod_w %= (1000 * 1000); - top = u2_no; + top = u3_no; } if ( wod_w / 1000 ) { - fprintf(fil_u, ((top == u2_yes) ? "%u." : "%03u."), wod_w / 1000); + fprintf(fil_u, ((top == u3_yes) ? "%u." : "%03u."), wod_w / 1000); wod_w %= 1000; - top = u2_no; + top = u3_no; } - fprintf(fil_u, ((top == u2_yes) ? "%u" : "%03u"), wod_w); + fprintf(fil_u, ((top == u3_yes) ? "%u" : "%03u"), wod_w); } -/* u2_lo_grab(): garbage-collect the world, plus roots. +/* u3_lo_grab(): garbage-collect the world, plus roots. */ void -u2_lo_grab(c3_c* cap_c, u2_noun som, ...) +u3_lo_grab(c3_c* cap_c, u3_noun som, ...) { c3_w siz_w, lec_w; siz_w = _lo_mark(); { va_list vap; - u2_noun tur; + u3_noun tur; va_start(vap, som); - if ( som != u2_none ) { - siz_w += u2_cm_mark_noun(som); + if ( som != u3_none ) { + siz_w += u3_cm_mark_noun(som); - while ( u2_none != (tur = va_arg(vap, u2_noun)) ) { - siz_w += u2_cm_mark_noun(tur); + while ( u3_none != (tur = va_arg(vap, u3_noun)) ) { + siz_w += u3_cm_mark_noun(tur); } } va_end(vap); } - lec_w = u2_cm_sweep(siz_w); + lec_w = u3_cm_sweep(siz_w); - // if ( lec_w || (u2_yes == u2_Flag_Verbose) ) + // if ( lec_w || (u3_yes == u3_Flag_Verbose) ) if ( lec_w || !strcmp("init", cap_c) ) { FILE* fil_u = uH; fprintf(fil_u, "%s: gc: ", cap_c); @@ -802,11 +705,12 @@ u2_lo_grab(c3_c* cap_c, u2_noun som, ...) #if 0 if ( lec_w ) { uL(fprintf(uH, "zero garbage tolerance!\n")); - u2_lo_exit(); + u3_lo_exit(); c3_assert(0); exit(1); } #endif } - u2_wire_lan(u2_Wire) = u2_yes; + u3_wire_lan(u3_Wire) = u3_yes; } +#endif diff --git a/v/main.c b/v/main.c index 31d4c86d9..f35443070 100644 --- a/v/main.c +++ b/v/main.c @@ -25,24 +25,10 @@ #define C3_GLOBAL #include "all.h" #include "v/vere.h" -#include "v/arvo.h" - -/** Legacy fixed jet linkage. Destroy me please. -**/ - /* External drivers. - */ - extern u2_ho_driver j2_da(k_164); - - /* Built-in battery drivers. Null `cos` terminates. - */ - u2_ho_driver *HostDriverBase[] = { - &j2_k_164_d, - 0 - }; /* _main_readw(): parse a word from a string. */ -static u2_bean +static u3_bean _main_readw(const c3_c* str_c, c3_w max_w, c3_w* out_w) { c3_c* end_c; @@ -50,117 +36,117 @@ _main_readw(const c3_c* str_c, c3_w max_w, c3_w* out_w) if ( *str_c != '\0' && *end_c == '\0' && par_w < max_w ) { *out_w = par_w; - return u2_yes; + return u3_yes; } - else return u2_no; + else return u3_no; } /* _main_getopt(): extract option map from command line. */ -static u2_bean +static u3_bean _main_getopt(c3_i argc, c3_c** argv) { c3_i ch_i; c3_w arg_w; - u2_Host.ops_u.abo = u2_no; - u2_Host.ops_u.bat = u2_no; - u2_Host.ops_u.gab = u2_no; - u2_Host.ops_u.loh = u2_no; - u2_Host.ops_u.dem = u2_no; - u2_Host.ops_u.fog = u2_no; - u2_Host.ops_u.fak = u2_no; - u2_Host.ops_u.pro = u2_no; - u2_Host.ops_u.veb = u2_yes; - u2_Host.ops_u.nuu = u2_no; - u2_Host.ops_u.mem = u2_no; - u2_Host.ops_u.kno_w = DefaultKernel; + u3_Host.ops_u.abo = u3_no; + u3_Host.ops_u.bat = u3_no; + u3_Host.ops_u.gab = u3_no; + u3_Host.ops_u.loh = u3_no; + u3_Host.ops_u.dem = u3_no; + u3_Host.ops_u.fog = u3_no; + u3_Host.ops_u.fak = u3_no; + u3_Host.ops_u.pro = u3_no; + u3_Host.ops_u.veb = u3_yes; + u3_Host.ops_u.nuu = u3_no; + u3_Host.ops_u.mem = u3_no; + u3_Host.ops_u.kno_w = DefaultKernel; while ( (ch_i = getopt(argc, argv, "I:X:f:k:l:n:p:r:LabcdgqvFM")) != -1 ) { switch ( ch_i ) { case 'M': { - u2_Host.ops_u.mem = u2_yes; + u3_Host.ops_u.mem = u3_yes; break; } case 'I': { - u2_Host.ops_u.imp_c = strdup(optarg); + u3_Host.ops_u.imp_c = strdup(optarg); break; } case 'X': { if ( 0 != strcmp("wtf", optarg) ) { - return u2_no; - } else u2_Host.ops_u.fog = u2_yes; + return u3_no; + } else u3_Host.ops_u.fog = u3_yes; break; } case 'f': { - if ( u2_no == _main_readw(optarg, 100, &u2_Host.ops_u.fuz_w) ) { - return u2_no; + if ( u3_no == _main_readw(optarg, 100, &u3_Host.ops_u.fuz_w) ) { + return u3_no; } break; } case 'k': { - if ( u2_no == _main_readw(optarg, 256, &u2_Host.ops_u.kno_w) ) { - return u2_no; + if ( u3_no == _main_readw(optarg, 256, &u3_Host.ops_u.kno_w) ) { + return u3_no; } break; } case 'l': { - if ( u2_no == _main_readw(optarg, 65536, &arg_w) ) { - return u2_no; - } else u2_Host.ops_u.rop_s = arg_w; + if ( u3_no == _main_readw(optarg, 65536, &arg_w) ) { + return u3_no; + } else u3_Host.ops_u.rop_s = arg_w; break; } case 'n': { - u2_Host.ops_u.nam_c = strdup(optarg); + u3_Host.ops_u.nam_c = strdup(optarg); break; } case 'p': { - if ( u2_no == _main_readw(optarg, 65536, &arg_w) ) { - return u2_no; - } else u2_Host.ops_u.por_s = arg_w; + if ( u3_no == _main_readw(optarg, 65536, &arg_w) ) { + return u3_no; + } else u3_Host.ops_u.por_s = arg_w; break; } case 'r': { - u2_Host.ops_u.raf_c = strdup(optarg); + u3_Host.ops_u.raf_c = strdup(optarg); break; } - case 'L': { u2_Host.ops_u.loh = u2_yes; break; } + case 'L': { u3_Host.ops_u.loh = u3_yes; break; } case 'F': { - u2_Host.ops_u.loh = u2_yes; - u2_Host.ops_u.fak = u2_yes; + u3_Host.ops_u.loh = u3_yes; + u3_Host.ops_u.fak = u3_yes; break; } - case 'a': { u2_Host.ops_u.abo = u2_yes; break; } - case 'b': { u2_Host.ops_u.bat = u2_yes; break; } - case 'c': { u2_Host.ops_u.nuu = u2_yes; break; } - case 'd': { u2_Host.ops_u.dem = u2_yes; break; } - case 'g': { u2_Host.ops_u.gab = u2_yes; break; } - case 'q': { u2_Host.ops_u.veb = u2_no; break; } - case 'v': { u2_Host.ops_u.veb = u2_yes; break; } + case 'a': { u3_Host.ops_u.abo = u3_yes; break; } + case 'b': { u3_Host.ops_u.bat = u3_yes; break; } + case 'c': { u3_Host.ops_u.nuu = u3_yes; break; } + case 'd': { u3_Host.ops_u.dem = u3_yes; break; } + case 'g': { u3_Host.ops_u.gab = u3_yes; break; } + case 'q': { u3_Host.ops_u.veb = u3_no; break; } + case 'v': { u3_Host.ops_u.veb = u3_yes; break; } case '?': default: { - return u2_no; + return u3_no; } } } - if ( u2_Host.ops_u.rop_s == 0 && u2_Host.ops_u.raf_c != 0 ) { + if ( u3_Host.ops_u.rop_s == 0 && u3_Host.ops_u.raf_c != 0 ) { fprintf(stderr, "The -r flag requires -l.\n"); - return u2_no; + return u3_no; } - if ( u2_yes == u2_Host.ops_u.bat ) { - u2_Host.ops_u.dem = u2_yes; - u2_Host.ops_u.nuu = u2_yes; + if ( u3_yes == u3_Host.ops_u.bat ) { + u3_Host.ops_u.dem = u3_yes; + u3_Host.ops_u.nuu = u3_yes; } - if ( u2_Host.ops_u.nam_c == 0 ) { - u2_Host.ops_u.nam_c = getenv("HOSTNAME"); - if ( u2_Host.ops_u.nam_c == 0 ) { + if ( u3_Host.ops_u.nam_c == 0 ) { + u3_Host.ops_u.nam_c = getenv("HOSTNAME"); + if ( u3_Host.ops_u.nam_c == 0 ) { c3_w len_w = sysconf(_SC_HOST_NAME_MAX) + 1; - u2_Host.ops_u.nam_c = c3_malloc(len_w); - if ( 0 != gethostname(u2_Host.ops_u.nam_c, len_w) ) { + u3_Host.ops_u.nam_c = c3_malloc(len_w); + if ( 0 != gethostname(u3_Host.ops_u.nam_c, len_w) ) { perror("gethostname"); exit(1); } @@ -168,7 +154,7 @@ _main_getopt(c3_i argc, c3_c** argv) } if ( argc != (optind + 1) ) { - return u2_no; + return u3_no; } else { { c3_c* ash_c; @@ -178,43 +164,46 @@ _main_getopt(c3_i argc, c3_c** argv) } } - u2_Host.cpu_c = strdup(argv[optind]); - return u2_yes; + u3_Host.cpu_c = strdup(argv[optind]); + return u3_yes; } } -/* u2_ve_usage(): print usage and exit. +/* u3_ve_usage(): print usage and exit. */ static void -u2_ve_usage(c3_i argc, c3_c** argv) +u3_ve_usage(c3_i argc, c3_c** argv) { fprintf(stderr, "%s: usage: [-v] [-k stage] [-p ames_port] computer\n", argv[0]); exit(1); } -/* u2_ve_panic(): panic and exit. +#if 0 +/* u3_ve_panic(): panic and exit. */ static void -u2_ve_panic(c3_i argc, c3_c** argv) +u3_ve_panic(c3_i argc, c3_c** argv) { fprintf(stderr, "%s: gross system failure\n", argv[0]); exit(1); } +#endif -/* u2_ve_sysopt(): apply option map to system state. +/* u3_ve_sysopt(): apply option map to system state. */ static void -u2_ve_sysopt() +u3_ve_sysopt() { - u2_Local = strdup(u2_Host.cpu_c); - u2_System = U2_LIB; - u2_Flag_Abort = u2_Host.ops_u.abo; - u2_Flag_Garbage = u2_Host.ops_u.gab; - u2_Flag_Profile = u2_Host.ops_u.pro; - u2_Flag_Verbose = u2_Host.ops_u.veb; + u3_Local = strdup(u3_Host.cpu_c); + u3_System = U2_LIB; + u3_Flag_Abort = u3_Host.ops_u.abo; + u3_Flag_Garbage = u3_Host.ops_u.gab; + u3_Flag_Profile = u3_Host.ops_u.pro; + u3_Flag_Verbose = u3_Host.ops_u.veb; } +#if 0 static jmp_buf Signal_buf; #ifndef SIGSTKSZ # define SIGSTKSZ 16384 @@ -249,31 +238,30 @@ interrupt_handler(int x) Sigcause = sig_interrupt; longjmp(Signal_buf, 1); } +#endif c3_i main(c3_i argc, c3_c** argv) { - c3_w kno_w; - _MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON); _MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON); // Parse options. // - if ( u2_no == _main_getopt(argc, argv) ) { - u2_ve_usage(argc, argv); + if ( u3_no == _main_getopt(argc, argv) ) { + u3_ve_usage(argc, argv); return 1; } - u2_ve_sysopt(); + u3_ve_sysopt(); printf("~\n"); printf("welcome.\n"); - printf("vere: urbit home is %s\n", u2_Host.cpu_c); - printf("vere: hostname is %s\n", u2_Host.ops_u.nam_c); + printf("vere: urbit home is %s\n", u3_Host.cpu_c); + printf("vere: hostname is %s\n", u3_Host.ops_u.nam_c); - if ( u2_yes == u2_Host.ops_u.dem && u2_no == u2_Host.ops_u.bat ) { + if ( u3_yes == u3_Host.ops_u.dem && u3_no == u3_Host.ops_u.bat ) { printf("Starting daemon\n"); } @@ -283,75 +271,30 @@ main(c3_i argc, // Instantiate process globals. { - u2_wr_check_init(u2_Host.cpu_c); - u2_Host.xit_i = 0; - if ( (u2_no == u2_Host.ops_u.nuu) && - (u2_yes == u2_loom_load()) ) + /* Boot memory. + */ + u3_cm_boot(U2_OS_LoomBase, (1 << U2_OS_LoomBits)); + + /* Boot jets. + */ + u3_cj_boot(); + + /* Boot arvo kernel. + */ { - u2_Host.wir_r = u2_ray_of(0, 0); - u2_Wire = u2_Host.wir_r; + struct timeval tim_tv; + u3_noun now; + c3_c pas_c[2048]; - u2_Host.arv_u = u2_Arv; + snprintf(pas_c, 2048, "%s/.urb/urbit.pill", u3_Host.cpu_c); + gettimeofday(&tim_tv, 0); + now = u3_time_in_tv(&tim_tv); - u2_Arv->ova.egg_u = u2_Arv->ova.geg_u = 0; - - u2_lo_grab("init", u2_none); - - // Horrible ancient stuff. - // - kno_w = u2_Host.arv_u->kno_w; - u2_Host.kno_w = kno_w; - - u2_ho_push(); - } - else { - u2_loom_boot(); - u2_Host.wir_r = u2_wr_init(c3__rock, u2_ray_of(0, 0), u2_ray_of(1, 0)); - u2_Wire = u2_Host.wir_r; - - u2_Host.arv_u = u2_Arv; - } - } - - // If we have not loaded from checkpoint, build kernel. - // - if ( 0 != u2_Host.arv_u->ent_d ) { - u2_reck_time(u2_Host.arv_u); - u2_reck_numb(u2_Host.arv_u); - { - c3_c* dyt_c = u2_cr_string(u2_Host.arv_u->wen); - - printf("time: %s\n", dyt_c); - free(dyt_c); - } - } - else { - // Set outside bail trap. Should not be used, but you never know... - // - if ( 0 != u2_cm_trap() ) { - u2_ve_panic(argc, argv); - } - else { - // Set boot and goal stages. - { - if ( (0 == u2_Host.ops_u.kno_w) || (u2_Host.ops_u.kno_w > 255) ) { - kno_w = DefaultKernel; - } else { - kno_w = u2_Host.ops_u.kno_w; - } - } - - // Load the system. - // - { - u2_Host.kno_w = u2_Host.ops_u.kno_w; - - u2_reck_boot(u2_Host.arv_u); - } - u2_cm_done(); + u3_cv_make(pas_c, now); } } +#if 0 // Install signal handlers and set buffers. // // Note that we use the sigmask-restoring variant. Essentially, when @@ -373,9 +316,9 @@ main(c3_i argc, // // This is half-assed at present, so we exit. // - u2_lo_sway(0, u2k(u2_wire_tax(u2_Wire))); + u3_lo_sway(0, u3k(u3_wire_tax(u3_Wire))); - u2_lo_bail(u2_Host.arv_u); + u3_lo_bail(u3A); exit(1); } @@ -391,9 +334,10 @@ main(c3_i argc, #endif } - u2_lo_grab("main", u2_none); + u3_lo_grab("main", u3_none); +#endif - u2_lo_loop(); + u3_lo_loop(); return 0; } diff --git a/v/raft.c b/v/raft.c index f0c071609..2939f5e0c 100644 --- a/v/raft.c +++ b/v/raft.c @@ -12,18 +12,18 @@ #include "v/vere.h" -/* u2_rent: Log entry wire format. +/* u3_rent: Log entry wire format. */ typedef struct { c3_w tem_w; // Log entry term c3_w typ_w; // Entry type, %ra|%ov c3_w len_w; // Word length of blob c3_w* bob_w; // Blob -} u2_rent; +} u3_rent; -/* u2_rmsg: Raft RPC wire format. +/* u3_rmsg: Raft RPC wire format. */ -typedef struct _u2_rmsg { +typedef struct _u3_rmsg { c3_w ver_w; // version, mug('a')... c3_d len_d; // Words in message c3_w tem_w; // Current term @@ -41,25 +41,25 @@ typedef struct _u2_rmsg { struct { c3_d cit_d; // Leader commitIndex c3_d ent_d; // Number of entries - u2_rent* ent_u; // Entries + u3_rent* ent_u; // Entries } apen; }; } rest; }; -} u2_rmsg; +} u3_rmsg; -static ssize_t _raft_rmsg_read(const u2_rbuf* buf_u, u2_rmsg* msg_u); -static void _raft_rmsg_send(u2_rcon* ron_u, const u2_rmsg* msg_u); -static void _raft_rmsg_free(u2_rmsg* msg_u); -static void _raft_conn_dead(u2_rcon* ron_u); -static u2_bean _raft_remove_run(u2_rcon* ron_u); -static void _raft_send_rasp(u2_rcon* ron_u, c3_t suc_t); -static void _raft_rreq_free(u2_rreq* req_u); +static ssize_t _raft_rmsg_read(const u3_rbuf* buf_u, u3_rmsg* msg_u); +static void _raft_rmsg_send(u3_rcon* ron_u, const u3_rmsg* msg_u); +static void _raft_rmsg_free(u3_rmsg* msg_u); +static void _raft_conn_dead(u3_rcon* ron_u); +static u3_bean _raft_remove_run(u3_rcon* ron_u); +static void _raft_send_rasp(u3_rcon* ron_u, c3_t suc_t); +static void _raft_rreq_free(u3_rreq* req_u); static void _raft_time_cb(uv_timer_t* tim_u); static void -_raft_rnam_free(u2_rnam* nam_u) +_raft_rnam_free(u3_rnam* nam_u) { if ( nam_u ) { c3_assert(0 == nam_u->ron_u); @@ -73,10 +73,10 @@ _raft_rnam_free(u2_rnam* nam_u) /* _raft_readname(): parse a raft host:port peer name. */ -static u2_rnam* +static u3_rnam* _raft_readname(const c3_c* str_c, c3_w siz_w) { - u2_rnam* nam_u = calloc(1, sizeof(*nam_u)); + u3_rnam* nam_u = calloc(1, sizeof(*nam_u)); c3_c* col_c; c3_w nam_w; @@ -99,13 +99,13 @@ _raft_readname(const c3_c* str_c, c3_w siz_w) return nam_u; } -/* u2_raft_readopt(): parse a string into a list of raft peers. +/* u3_raft_readopt(): parse a string into a list of raft peers. */ -u2_rnam* -u2_raft_readopt(const c3_c* arg_c, c3_c* our_c, c3_s oup_s) +u3_rnam* +u3_raft_readopt(const c3_c* arg_c, c3_c* our_c, c3_s oup_s) { - u2_rnam* nam_u; - u2_rnam* nex_u; + u3_rnam* nam_u; + u3_rnam* nex_u; c3_c* com_c; if ( 0 == (com_c = strchr(arg_c, ',')) ) { @@ -114,7 +114,7 @@ u2_raft_readopt(const c3_c* arg_c, c3_c* our_c, c3_s oup_s) } else { nam_u = _raft_readname(arg_c, com_c - arg_c); - nex_u = u2_raft_readopt(com_c + 1, our_c, oup_s); + nex_u = u3_raft_readopt(com_c + 1, our_c, oup_s); } if ( nam_u ) { @@ -165,9 +165,9 @@ _raft_election_rand() /* _raft_promote(): actions on raft leader election. */ static void -_raft_promote(u2_raft* raf_u) +_raft_promote(u3_raft* raf_u) { - if ( u2_raty_lead == raf_u->typ_e ) { + if ( u3_raty_lead == raf_u->typ_e ) { uL(fprintf(uH, "raft: double promote; ignoring\n")); } else { @@ -175,17 +175,17 @@ _raft_promote(u2_raft* raf_u) if ( 1 == raf_u->pop_w ) { uL(fprintf(uH, "raft: -> lead\n")); - raf_u->typ_e = u2_raty_lead; + raf_u->typ_e = u3_raty_lead; // TODO boot in multiuser mode - u2_sist_boot(); - if ( u2_no == u2_Host.ops_u.bat ) { - u2_lo_lead(u2A); + u3_sist_boot(); + if ( u3_no == u3_Host.ops_u.bat ) { + u3_lo_lead(); } } else { - c3_assert(u2_raty_cand == raf_u->typ_e); + c3_assert(u3_raty_cand == raf_u->typ_e); uL(fprintf(uH, "raft: cand -> lead\n")); - raf_u->typ_e = u2_raty_lead; + raf_u->typ_e = u3_raty_lead; sas_i = uv_timer_stop(&raf_u->tim_u); c3_assert(0 == sas_i); @@ -198,16 +198,16 @@ _raft_promote(u2_raft* raf_u) /* _raft_demote(): demote to follower. */ static void -_raft_demote(u2_raft* raf_u) +_raft_demote(u3_raft* raf_u) { - u2_raty typ_e = raf_u->typ_e; + u3_raty typ_e = raf_u->typ_e; raf_u->vog_c = 0; - u2_sist_nil("vote"); + u3_sist_nil("vote"); raf_u->vot_w = 0; - raf_u->typ_e = u2_raty_foll; + raf_u->typ_e = u3_raty_foll; - if ( u2_raty_lead == typ_e ) { + if ( u3_raty_lead == typ_e ) { c3_i sas_i; uL(fprintf(uH, "raft: lead -> foll\n")); @@ -219,7 +219,7 @@ _raft_demote(u2_raft* raf_u) // TODO dump not-yet-committed events } else { - c3_assert(u2_raty_cand == typ_e); + c3_assert(u3_raty_cand == typ_e); uL(fprintf(uH, "raft: cand -> foll\n")); } } @@ -227,14 +227,14 @@ _raft_demote(u2_raft* raf_u) /* _raft_note_term(): note a term from the network, demoting if it is newer. */ static void -_raft_note_term(u2_raft* raf_u, c3_w tem_w) +_raft_note_term(u3_raft* raf_u, c3_w tem_w) { if ( raf_u->tem_w < tem_w ) { uL(fprintf(uH, "raft: got term from network: %d\n", tem_w)); raf_u->tem_w = tem_w; - u2_sist_put("term", (c3_y*)&raf_u->tem_w, sizeof(c3_w)); - c3_assert(raf_u->typ_e != u2_raty_none); - if ( raf_u->typ_e == u2_raty_foll ) { + u3_sist_put("term", (c3_y*)&raf_u->tem_w, sizeof(c3_w)); + c3_assert(raf_u->typ_e != u3_raty_none); + if ( raf_u->typ_e == u3_raty_foll ) { c3_assert(0 == raf_u->vot_w); } else _raft_demote(raf_u); } @@ -247,7 +247,7 @@ _raft_note_term(u2_raft* raf_u, c3_w tem_w) ** connections to that name. */ static void // TODO indicate whether conn died -_raft_rest_name(u2_rcon* ron_u, const c3_c* nam_c) +_raft_rest_name(u3_rcon* ron_u, const c3_c* nam_c) { if ( 0 != ron_u->nam_u ) { if ( 0 != strcmp(ron_u->nam_u->str_c, nam_c) ) { @@ -257,8 +257,8 @@ _raft_rest_name(u2_rcon* ron_u, const c3_c* nam_c) } } else { - u2_raft* raf_u = ron_u->raf_u; - u2_rnam* nam_u = raf_u->nam_u; + u3_raft* raf_u = ron_u->raf_u; + u3_rnam* nam_u = raf_u->nam_u; while ( nam_u ) { if ( 0 == strcmp(nam_u->str_c, nam_c) ) { @@ -286,11 +286,11 @@ _raft_rest_name(u2_rcon* ron_u, const c3_c* nam_c) /* _raft_do_rest(): effects of an incoming request. */ static void -_raft_do_rest(u2_rcon* ron_u, const u2_rmsg* msg_u) +_raft_do_rest(u3_rcon* ron_u, const u3_rmsg* msg_u) { - u2_raft* raf_u = ron_u->raf_u; + u3_raft* raf_u = ron_u->raf_u; - if ( u2_raty_cand == raf_u->typ_e || u2_raty_foll == raf_u->typ_e ) { + if ( u3_raty_cand == raf_u->typ_e || u3_raty_foll == raf_u->typ_e ) { c3_i sas_i; sas_i = uv_timer_stop(&raf_u->tim_u); @@ -307,7 +307,7 @@ _raft_do_rest(u2_rcon* ron_u, const u2_rmsg* msg_u) /* _raft_do_apen(): Handle incoming AppendEntries. */ static void -_raft_do_apen(u2_rcon* ron_u, const u2_rmsg* msg_u) +_raft_do_apen(u3_rcon* ron_u, const u3_rmsg* msg_u) { c3_assert(c3__apen == msg_u->typ_w); _raft_do_rest(ron_u, msg_u); @@ -317,7 +317,7 @@ _raft_do_apen(u2_rcon* ron_u, const u2_rmsg* msg_u) /* _raft_apen_done(): process AppendEntries response. */ static void -_raft_apen_done(u2_rreq* req_u, c3_w suc_w) +_raft_apen_done(u3_rreq* req_u, c3_w suc_w) { c3_assert(c3__apen == req_u->msg_u->typ_w); /* TODO */ @@ -326,9 +326,9 @@ _raft_apen_done(u2_rreq* req_u, c3_w suc_w) /* _raft_do_revo(): Handle incoming RequestVote. */ static void -_raft_do_revo(u2_rcon* ron_u, const u2_rmsg* msg_u) +_raft_do_revo(u3_rcon* ron_u, const u3_rmsg* msg_u) { - u2_raft* raf_u = ron_u->raf_u; + u3_raft* raf_u = ron_u->raf_u; c3_assert(c3__revo == msg_u->typ_w); _raft_do_rest(ron_u, msg_u); @@ -342,7 +342,7 @@ _raft_do_revo(u2_rcon* ron_u, const u2_rmsg* msg_u) raf_u->ent_d <= msg_u->rest.lai_d)) ) { raf_u->vog_c = ron_u->nam_u->str_c; - u2_sist_put("vote", (c3_y*)raf_u->vog_c, strlen(raf_u->vog_c)); + u3_sist_put("vote", (c3_y*)raf_u->vog_c, strlen(raf_u->vog_c)); uL(fprintf(uH, "raft: granting vote to %s\n", raf_u->vog_c)); _raft_send_rasp(ron_u, 1); } @@ -352,15 +352,15 @@ _raft_do_revo(u2_rcon* ron_u, const u2_rmsg* msg_u) /* _raft_revo_done(): process RequestVote response. */ static void -_raft_revo_done(u2_rreq* req_u, c3_w suc_w) +_raft_revo_done(u3_rreq* req_u, c3_w suc_w) { - u2_rcon* ron_u = req_u->ron_u; - u2_raft* raf_u = ron_u->raf_u; + u3_rcon* ron_u = req_u->ron_u; + u3_raft* raf_u = ron_u->raf_u; c3_assert(c3__revo == req_u->msg_u->typ_w); if ( suc_w && req_u->msg_u->tem_w == raf_u->tem_w ) { - if ( u2_no == ron_u->nam_u->vog ) { - ron_u->nam_u->vog = u2_yes; + if ( u3_no == ron_u->nam_u->vog ) { + ron_u->nam_u->vog = u3_yes; raf_u->vot_w++; } else { @@ -378,9 +378,9 @@ _raft_revo_done(u2_rreq* req_u, c3_w suc_w) /* _raft_do_rasp(): act on an incoming raft RPC response. */ static void -_raft_do_rasp(u2_rcon* ron_u, u2_rmsg* msg_u) +_raft_do_rasp(u3_rcon* ron_u, u3_rmsg* msg_u) { - u2_raft* raf_u = ron_u->raf_u; + u3_raft* raf_u = ron_u->raf_u; c3_assert(c3__rasp == msg_u->typ_w); if ( 0 == ron_u->nam_u ) { @@ -388,7 +388,7 @@ _raft_do_rasp(u2_rcon* ron_u, u2_rmsg* msg_u) _raft_conn_dead(ron_u); } else { - u2_rreq* req_u = ron_u->out_u; + u3_rreq* req_u = ron_u->out_u; if ( !req_u ) { uL(fprintf(uH, "raft: response with no request from %s\n", @@ -424,7 +424,7 @@ _raft_do_rasp(u2_rcon* ron_u, u2_rmsg* msg_u) } } -/* _raft_rmsg_read(): read a u2_rmsg from a buffer. +/* _raft_rmsg_read(): read a u3_rmsg from a buffer. ** ** Returns <0 on parse failure. ** Returns 0 on partial data. @@ -433,7 +433,7 @@ _raft_do_rasp(u2_rcon* ron_u, u2_rmsg* msg_u) ** If successful, caller must eventually call _raft_free_rmsg() on msg_u. */ static ssize_t -_raft_rmsg_read(const u2_rbuf* buf_u, u2_rmsg* msg_u) +_raft_rmsg_read(const u3_rbuf* buf_u, u3_rmsg* msg_u) { ssize_t red_i = 0; c3_d ben_d; @@ -443,9 +443,9 @@ _raft_rmsg_read(const u2_rbuf* buf_u, u2_rmsg* msg_u) } memcpy(&msg_u->ver_w, buf_u->buf_y + red_i, sizeof(c3_w)); red_i += sizeof(c3_w); - if ( msg_u->ver_w != u2_cr_mug('a') ) { + if ( msg_u->ver_w != u3_cr_mug('a') ) { uL(fprintf(uH, "raft: versions don't match: %x %x\n", - msg_u->ver_w, u2_cr_mug('a'))); + msg_u->ver_w, u3_cr_mug('a'))); return -1; } @@ -521,10 +521,10 @@ _raft_rmsg_read(const u2_rbuf* buf_u, u2_rmsg* msg_u) red_i += sizeof(c3_d); msg_u->rest.apen.ent_u = calloc( - 1, msg_u->rest.apen.ent_d * sizeof(u2_rent)); + 1, msg_u->rest.apen.ent_d * sizeof(u3_rent)); { c3_d i_d; - u2_rent* ent_u = msg_u->rest.apen.ent_u; + u3_rent* ent_u = msg_u->rest.apen.ent_u; for ( i_d = 0; i_d < msg_u->rest.apen.ent_d; i_d++ ) { if ( ben_d < red_i + 3 * sizeof(c3_w) ) { @@ -567,8 +567,8 @@ fail: ** ** Returns new buffer location, as realloc. */ -static u2_rbuf* -_raft_rbuf_grow(u2_rbuf* buf_u, const c3_y* buf_y, size_t siz_i) +static u3_rbuf* +_raft_rbuf_grow(u3_rbuf* buf_u, const c3_y* buf_y, size_t siz_i) { if ( 0 == buf_u ) { buf_u = c3_malloc(sizeof(*buf_u) + siz_i); @@ -591,15 +591,15 @@ _raft_rbuf_grow(u2_rbuf* buf_u, const c3_y* buf_y, size_t siz_i) /* _raft_bytes_send(): */ static void -_raft_bytes_send(u2_rcon* ron_u, const void* ptr_v, size_t siz_i) +_raft_bytes_send(u3_rcon* ron_u, const void* ptr_v, size_t siz_i) { ron_u->wri_u = _raft_rbuf_grow(ron_u->wri_u, ptr_v, siz_i); } -/* _raft_rmsg_send(): send a u2_rmsg over the wire. +/* _raft_rmsg_send(): send a u3_rmsg over the wire. */ static void -_raft_rmsg_send(u2_rcon* ron_u, const u2_rmsg* msg_u) +_raft_rmsg_send(u3_rcon* ron_u, const u3_rmsg* msg_u) { c3_d len_d = sizeof(c3_d) + 3 * sizeof(c3_w); @@ -628,7 +628,7 @@ _raft_rmsg_send(u2_rcon* ron_u, const u2_rmsg* msg_u) } if ( c3__apen == msg_u->typ_w ) { c3_d i_d; - u2_rent* ent_u = msg_u->rest.apen.ent_u; + u3_rent* ent_u = msg_u->rest.apen.ent_u; len_d += 2 * sizeof(c3_d); _raft_bytes_send(ron_u, &msg_u->rest.apen.cit_d, sizeof(c3_d)); @@ -647,10 +647,10 @@ _raft_rmsg_send(u2_rcon* ron_u, const u2_rmsg* msg_u) c3_assert(len_d == 4 * msg_u->len_d); } -/* _raft_rmsg_free(): free a u2_rmsg's resources (but not the msg itself). +/* _raft_rmsg_free(): free a u3_rmsg's resources (but not the msg itself). */ static void -_raft_rmsg_free(u2_rmsg* msg_u) { +_raft_rmsg_free(u3_rmsg* msg_u) { if ( c3__apen == msg_u->typ_w && msg_u->rest.apen.ent_u ) { c3_d i_d; @@ -668,7 +668,7 @@ _raft_rmsg_free(u2_rmsg* msg_u) { /* An unusual lameness in libuv. */ -struct _u2_write_t { +struct _u3_write_t { uv_write_t wri_u; c3_y* buf_y; }; @@ -678,11 +678,11 @@ struct _u2_write_t { static void _raft_write_cb(uv_write_t* wri_u, c3_i sas_i) { - struct _u2_write_t* req_u = (struct _u2_write_t*)wri_u; + struct _u3_write_t* req_u = (struct _u3_write_t*)wri_u; if ( 0 != sas_i ) { uL(fprintf(uH, "raft: write_cb: error\n")); - _raft_conn_dead((u2_rcon*)wri_u->handle); + _raft_conn_dead((u3_rcon*)wri_u->handle); } free(req_u->buf_y); free(req_u); @@ -691,14 +691,14 @@ _raft_write_cb(uv_write_t* wri_u, c3_i sas_i) /* _raft_conn_work(): read and write requests and responses. */ static void -_raft_conn_work(u2_rcon* ron_u) +_raft_conn_work(u3_rcon* ron_u) { - c3_assert(u2_yes == ron_u->liv); - if ( u2_yes == ron_u->red ) { + c3_assert(u3_yes == ron_u->liv); + if ( u3_yes == ron_u->red ) { c3_assert(ron_u->red_u); - ron_u->red = u2_no; + ron_u->red = u3_no; while (1) { - u2_rmsg msg_u; + u3_rmsg msg_u; ssize_t ret_i = _raft_rmsg_read(ron_u->red_u, &msg_u); if ( ret_i < 0 ) { @@ -754,7 +754,7 @@ _raft_conn_work(u2_rcon* ron_u) if ( ron_u->wri_u && ron_u->wri_u->len_w > 0 ) { uv_buf_t buf_u; - struct _u2_write_t* req_u = c3_malloc(sizeof(*req_u)); + struct _u3_write_t* req_u = c3_malloc(sizeof(*req_u)); req_u->buf_y = c3_malloc(ron_u->wri_u->len_w); @@ -787,9 +787,9 @@ _raft_conn_read_cb(uv_stream_t* tcp_u, ssize_t siz_i, const uv_buf_t * buf_u) { - u2_rcon* ron_u = (u2_rcon*)tcp_u; + u3_rcon* ron_u = (u3_rcon*)tcp_u; - u2_lo_open(); + u3_lo_open(); { if ( siz_i < 0 ) { uL(fprintf(uH, "raft: read ERROR")); @@ -799,58 +799,58 @@ _raft_conn_read_cb(uv_stream_t* tcp_u, // do nothing } else { - if ( u2_yes == ron_u->liv ) { + if ( u3_yes == ron_u->liv ) { ron_u->red_u = _raft_rbuf_grow(ron_u->red_u, (c3_y*)buf_u->base, siz_i); - ron_u->red = u2_yes; + ron_u->red = u3_yes; _raft_conn_work(ron_u); } else uL(fprintf(uH, "XX raft: read on dead conn %p\n", ron_u)); } } free(buf_u->base); - u2_lo_shut(u2_no); + u3_lo_shut(u3_no); } /* _raft_conn_new(): allocate a new raft connection. */ -static u2_rcon* -_raft_conn_new(u2_raft* raf_u) +static u3_rcon* +_raft_conn_new(u3_raft* raf_u) { - u2_rcon* ron_u = c3_malloc(sizeof(*ron_u)); + u3_rcon* ron_u = c3_malloc(sizeof(*ron_u)); - uv_tcp_init(u2L, &ron_u->wax_u); + uv_tcp_init(u3L, &ron_u->wax_u); ron_u->red_u = 0; ron_u->out_u = ron_u->tou_u = 0; ron_u->red_u = 0; - ron_u->red = u2_no; + ron_u->red = u3_no; ron_u->wri_u = 0; ron_u->nam_u = 0; ron_u->raf_u = raf_u; ron_u->nex_u = 0; - ron_u->liv = u2_no; + ron_u->liv = u3_no; return ron_u; } /* _raft_remove_run(): remove a connection from the list of unknowns. */ -static u2_bean -_raft_remove_run(u2_rcon* ron_u) +static u3_bean +_raft_remove_run(u3_rcon* ron_u) { - u2_raft* raf_u = ron_u->raf_u; - u2_bean suc = u2_no; + u3_raft* raf_u = ron_u->raf_u; + u3_bean suc = u3_no; if ( raf_u->run_u == ron_u ) { raf_u->run_u = ron_u->nex_u; - suc = u2_yes; + suc = u3_yes; } else { - u2_rcon* pre_u = raf_u->run_u; + u3_rcon* pre_u = raf_u->run_u; while ( pre_u ) { if ( pre_u->nex_u == ron_u ) { pre_u->nex_u = ron_u->nex_u; - suc = u2_yes; + suc = u3_yes; break; } else pre_u = pre_u->nex_u; @@ -860,10 +860,10 @@ _raft_remove_run(u2_rcon* ron_u) return suc; } -static u2_rreq* -_raft_rreq_new(u2_rcon* ron_u) +static u3_rreq* +_raft_rreq_new(u3_rcon* ron_u) { - u2_rreq* req_u = c3_malloc(sizeof(*req_u)); + u3_rreq* req_u = c3_malloc(sizeof(*req_u)); req_u->msg_u = c3_malloc(sizeof(*req_u->msg_u)); req_u->nex_u = 0; @@ -881,7 +881,7 @@ _raft_rreq_new(u2_rcon* ron_u) } static void -_raft_rreq_free(u2_rreq* req_u) +_raft_rreq_free(u3_rreq* req_u) { _raft_rmsg_free(req_u->msg_u); free(req_u->msg_u); // XX @@ -893,24 +893,24 @@ _raft_rreq_free(u2_rreq* req_u) static void _raft_conn_free(uv_handle_t* had_u) { - u2_rcon* ron_u = (void*)had_u; - u2_raft* raf_u = ron_u->raf_u; + u3_rcon* ron_u = (void*)had_u; + u3_raft* raf_u = ron_u->raf_u; //uL(fprintf(uH, "raft: conn_free %p\n", ron_u)); // Unlink references. if ( ron_u->nam_u ) { - c3_assert(u2_no == _raft_remove_run(ron_u)); + c3_assert(u3_no == _raft_remove_run(ron_u)); if ( ron_u->nam_u->ron_u == ron_u ) { ron_u->nam_u->ron_u = 0; } } else { - u2_bean suc = _raft_remove_run(ron_u); - c3_assert(u2_yes == suc); + u3_bean suc = _raft_remove_run(ron_u); + c3_assert(u3_yes == suc); // Slow, expensive debug assert. { - u2_rnam* nam_u = raf_u->nam_u; + u3_rnam* nam_u = raf_u->nam_u; while ( nam_u ) { c3_assert(nam_u->ron_u != ron_u); @@ -921,7 +921,7 @@ _raft_conn_free(uv_handle_t* had_u) // Free requests. { - u2_rreq* req_u = ron_u->out_u; + u3_rreq* req_u = ron_u->out_u; if ( 0 == req_u ) { c3_assert(0 == ron_u->tou_u); @@ -945,15 +945,15 @@ _raft_conn_free(uv_handle_t* had_u) /* _raft_conn_dead(): kill a connection. */ static void -_raft_conn_dead(u2_rcon* ron_u) +_raft_conn_dead(u3_rcon* ron_u) { - if ( u2_no == ron_u->liv ) { + if ( u3_no == ron_u->liv ) { //uL(fprintf(uH, "raft: conn already dead %p\n", ron_u)); return; } else { uL(fprintf(uH, "raft: conn_dead %p\n", ron_u)); - ron_u->liv = u2_no; + ron_u->liv = u3_no; } uv_read_stop((uv_stream_t*)&ron_u->wax_u); @@ -965,13 +965,13 @@ _raft_conn_dead(u2_rcon* ron_u) static void _raft_listen_cb(uv_stream_t* str_u, c3_i sas_i) { - u2_raft* raf_u = (u2_raft*)str_u; + u3_raft* raf_u = (u3_raft*)str_u; if ( 0 != sas_i ) { uL(fprintf(uH, "raft: listen_cb: error\n")); } else { - u2_rcon* ron_u = _raft_conn_new(raf_u); + u3_rcon* ron_u = _raft_conn_new(raf_u); if ( 0 != uv_accept((uv_stream_t*)&raf_u->wax_u, (uv_stream_t*)&ron_u->wax_u) ) @@ -982,7 +982,7 @@ _raft_listen_cb(uv_stream_t* str_u, c3_i sas_i) free(ron_u); } else { - ron_u->liv = u2_yes; + ron_u->liv = u3_yes; uv_read_start((uv_stream_t*)&ron_u->wax_u, _raft_alloc, @@ -999,7 +999,7 @@ _raft_listen_cb(uv_stream_t* str_u, c3_i sas_i) static void _raft_connect_cb(uv_connect_t* con_u, c3_i sas_i) { - u2_rcon* ron_u = con_u->data; + u3_rcon* ron_u = con_u->data; free(con_u); if ( 0 != sas_i ) { @@ -1010,7 +1010,7 @@ _raft_connect_cb(uv_connect_t* con_u, c3_i sas_i) else { c3_assert(ron_u->nam_u); uL(fprintf(uH, "raft: connected to %s\n", ron_u->nam_u->str_c)); - ron_u->liv = u2_yes; + ron_u->liv = u3_yes; uv_read_start((uv_stream_t*)&ron_u->wax_u, _raft_alloc, @@ -1029,7 +1029,7 @@ _raft_getaddrinfo_cb(uv_getaddrinfo_t* raq_u, { struct addrinfo* res_u; uv_connect_t* con_u = c3_malloc(sizeof(*con_u)); - u2_rcon* ron_u = raq_u->data; + u3_rcon* ron_u = raq_u->data; //uL(fprintf(uH, "getaddrinfo_cb %s\n", ron_u->nam_u->nam_c)); @@ -1067,13 +1067,13 @@ _raft_getaddrinfo_cb(uv_getaddrinfo_t* raq_u, /* _raft_conn_all(): ensure that we are connected to each peer. */ static void -_raft_conn_all(u2_raft* raf_u, void (*con_f)(u2_rcon* ron_u)) +_raft_conn_all(u3_raft* raf_u, void (*con_f)(u3_rcon* ron_u)) { - u2_rnam* nam_u = raf_u->nam_u; - u2_rcon* ron_u; + u3_rnam* nam_u = raf_u->nam_u; + u3_rcon* ron_u; while ( nam_u ) { - if ( 0 == nam_u->ron_u || u2_no == nam_u->ron_u->liv ) { + if ( 0 == nam_u->ron_u || u3_no == nam_u->ron_u->liv ) { struct addrinfo hit_u; uv_getaddrinfo_t* raq_u = c3_malloc(sizeof(*raq_u)); @@ -1090,7 +1090,7 @@ _raft_conn_all(u2_raft* raf_u, void (*con_f)(u2_rcon* ron_u)) raq_u->data = ron_u; int ret; - if ( 0 != (ret = uv_getaddrinfo(u2L, + if ( 0 != (ret = uv_getaddrinfo(u3L, raq_u, _raft_getaddrinfo_cb, nam_u->nam_c, @@ -1116,7 +1116,7 @@ _raft_conn_all(u2_raft* raf_u, void (*con_f)(u2_rcon* ron_u)) //uL(fprintf(uH, "raft: existing connection %p for %s\n", // nam_u->ron_u, nam_u->str_c)); con_f(nam_u->ron_u); - if ( u2_yes == nam_u->ron_u->liv ) { + if ( u3_yes == nam_u->ron_u->liv ) { _raft_conn_work(nam_u->ron_u); } } @@ -1124,16 +1124,16 @@ _raft_conn_all(u2_raft* raf_u, void (*con_f)(u2_rcon* ron_u)) } } -/* _raft_write_base(): Populate the base fields of a u2_rmsg. +/* _raft_write_base(): Populate the base fields of a u3_rmsg. ** ** Should not be called directly. */ static void -_raft_write_base(u2_rcon* ron_u, u2_rmsg* msg_u) +_raft_write_base(u3_rcon* ron_u, u3_rmsg* msg_u) { - u2_raft* raf_u = ron_u->raf_u; + u3_raft* raf_u = ron_u->raf_u; - msg_u->ver_w = u2_cr_mug('a'); + msg_u->ver_w = u3_cr_mug('a'); msg_u->tem_w = raf_u->tem_w; msg_u->len_d = 5; } @@ -1143,9 +1143,9 @@ _raft_write_base(u2_rcon* ron_u, u2_rmsg* msg_u) ** Should not be called directly. */ static void -_raft_write_rest(u2_rcon* ron_u, c3_d lai_d, c3_w lat_w, u2_rmsg* msg_u) +_raft_write_rest(u3_rcon* ron_u, c3_d lai_d, c3_w lat_w, u3_rmsg* msg_u) { - u2_raft* raf_u = ron_u->raf_u; + u3_raft* raf_u = ron_u->raf_u; c3_assert(ron_u->nam_u); _raft_write_base(ron_u, msg_u); @@ -1160,10 +1160,10 @@ _raft_write_rest(u2_rcon* ron_u, c3_d lai_d, c3_w lat_w, u2_rmsg* msg_u) /* _raft_write_apen(): Write fields for an AppendEntries request. */ static void -_raft_write_apen(u2_rcon* ron_u, +_raft_write_apen(u3_rcon* ron_u, c3_d lai_d, c3_w lat_w, - c3_d cit_d, c3_d ent_d, u2_rent* ent_u, - u2_rmsg* msg_u) + c3_d cit_d, c3_d ent_d, u3_rent* ent_u, + u3_rmsg* msg_u) { _raft_write_rest(ron_u, lai_d, lat_w, msg_u); msg_u->typ_w = c3__apen; @@ -1184,9 +1184,9 @@ _raft_write_apen(u2_rcon* ron_u, /* _raft_write_revo(): Write fields for a RequestVote request. */ static void -_raft_write_revo(u2_rcon* ron_u, u2_rmsg* msg_u) +_raft_write_revo(u3_rcon* ron_u, u3_rmsg* msg_u) { - u2_raft* raf_u = ron_u->raf_u; + u3_raft* raf_u = ron_u->raf_u; _raft_write_rest(ron_u, raf_u->ent_d, raf_u->lat_w, msg_u); msg_u->typ_w = c3__revo; @@ -1195,9 +1195,9 @@ _raft_write_revo(u2_rcon* ron_u, u2_rmsg* msg_u) /* _raft_send_rasp(): Send a rasp (raft response) to a peer. */ static void -_raft_send_rasp(u2_rcon* ron_u, c3_t suc_t) +_raft_send_rasp(u3_rcon* ron_u, c3_t suc_t) { - u2_rmsg msg_u; + u3_rmsg msg_u; _raft_write_base(ron_u, &msg_u); msg_u.typ_w = c3__rasp; @@ -1211,10 +1211,10 @@ _raft_send_rasp(u2_rcon* ron_u, c3_t suc_t) ** Creates a new request. */ static void -_raft_send_beat(u2_rcon* ron_u) +_raft_send_beat(u3_rcon* ron_u) { - u2_rreq* req_u = _raft_rreq_new(ron_u); - u2_rmsg* msg_u = req_u->msg_u; + u3_rreq* req_u = _raft_rreq_new(ron_u); + u3_rmsg* msg_u = req_u->msg_u; c3_log_every(50, "raft: beat 50\n"); @@ -1227,10 +1227,10 @@ _raft_send_beat(u2_rcon* ron_u) ** Creates a new request. */ static void -_raft_send_revo(u2_rcon* ron_u) +_raft_send_revo(u3_rcon* ron_u) { - u2_rreq* req_u = _raft_rreq_new(ron_u); - u2_rmsg* msg_u = req_u->msg_u; + u3_rreq* req_u = _raft_rreq_new(ron_u); + u3_rmsg* msg_u = req_u->msg_u; _raft_write_revo(ron_u, msg_u); _raft_rmsg_send(ron_u, msg_u); @@ -1239,7 +1239,7 @@ _raft_send_revo(u2_rcon* ron_u) /* _raft_start_election(): bump term, vote for self, solicit votes from peers. */ static void -_raft_start_election(u2_raft* raf_u) +_raft_start_election(u3_raft* raf_u) { c3_i sas_i; @@ -1249,19 +1249,19 @@ _raft_start_election(u2_raft* raf_u) c3_assert(sas_i == 0); raf_u->tem_w++; - u2_sist_put("term", (c3_y*)&raf_u->tem_w, sizeof(c3_w)); + u3_sist_put("term", (c3_y*)&raf_u->tem_w, sizeof(c3_w)); uL(fprintf(uH, "raft: starting election [tem:%d]\n", raf_u->tem_w)); { - u2_rnam* nam_u; + u3_rnam* nam_u; for ( nam_u = raf_u->nam_u; nam_u; nam_u = nam_u->nex_u ) { - nam_u->vog = u2_no; + nam_u->vog = u3_no; } } raf_u->vot_w = 1; raf_u->vog_c = raf_u->str_c; - u2_sist_put("vote", (c3_y*)raf_u->vog_c, strlen(raf_u->vog_c)); + u3_sist_put("vote", (c3_y*)raf_u->vog_c, strlen(raf_u->vog_c)); _raft_conn_all(raf_u, _raft_send_revo); } @@ -1269,7 +1269,7 @@ _raft_start_election(u2_raft* raf_u) /* _raft_heartbeat(): send a heartbeat to all peers. */ static void -_raft_heartbeat(u2_raft* raf_u) +_raft_heartbeat(u3_raft* raf_u) { _raft_conn_all(raf_u, _raft_send_beat); } @@ -1282,7 +1282,7 @@ _raft_heartbeat(u2_raft* raf_u) static void _raft_time_cb(uv_timer_t* tim_u) { - u2_raft* raf_u = tim_u->data; + u3_raft* raf_u = tim_u->data; //uL(fprintf(uH, "raft: time\n")); switch ( raf_u->typ_e ) { @@ -1290,16 +1290,16 @@ _raft_time_cb(uv_timer_t* tim_u) uL(fprintf(uH, "raft: time_cb: unknown server state\n")); c3_assert(0); } - case u2_raty_foll: { + case u3_raty_foll: { uL(fprintf(uH, "raft: foll -> cand\n")); - raf_u->typ_e = u2_raty_cand; + raf_u->typ_e = u3_raty_cand; // continue to cand } - case u2_raty_cand: { + case u3_raty_cand: { _raft_start_election(raf_u); break; } - case u2_raty_lead: { + case u3_raty_lead: { _raft_heartbeat(raf_u); break; } @@ -1309,20 +1309,20 @@ _raft_time_cb(uv_timer_t* tim_u) /* _raft_foll_init(): begin, follower mode. */ static void -_raft_foll_init(u2_raft* raf_u) +_raft_foll_init(u3_raft* raf_u) { uL(fprintf(uH, "raft: none -> foll\n")); - raf_u->typ_e = u2_raty_foll; + raf_u->typ_e = u3_raty_foll; // Initialize and count peers. { - u2_rnam* nam_u = u2_raft_readopt(u2_Host.ops_u.raf_c, - u2_Host.ops_u.nam_c, - u2_Host.ops_u.rop_s); + u3_rnam* nam_u = u3_raft_readopt(u3_Host.ops_u.raf_c, + u3_Host.ops_u.nam_c, + u3_Host.ops_u.rop_s); if ( 0 == nam_u ) { - uL(fprintf(uH, "raft: couldn't parse arg '%s'\n", u2_Host.ops_u.raf_c)); - u2_lo_bail(u2A); + uL(fprintf(uH, "raft: couldn't parse arg '%s'\n", u3_Host.ops_u.raf_c)); + u3_lo_bail(); } raf_u->pop_w = 1; raf_u->nam_u = nam_u; @@ -1335,10 +1335,10 @@ _raft_foll_init(u2_raft* raf_u) { c3_i wri_i, siz_i; - siz_i = strlen(u2_Host.ops_u.nam_c) + strlen(":65536") + 1; + siz_i = strlen(u3_Host.ops_u.nam_c) + strlen(":65536") + 1; raf_u->str_c = c3_malloc(siz_i); wri_i = snprintf(raf_u->str_c, siz_i, "%s:%d", - u2_Host.ops_u.nam_c, u2_Host.ops_u.rop_s); + u3_Host.ops_u.nam_c, u3_Host.ops_u.rop_s); c3_assert(wri_i < siz_i); } @@ -1348,15 +1348,15 @@ _raft_foll_init(u2_raft* raf_u) c3_c* vog_c = 0; c3_i ret_i; - if ( (ret_i = u2_sist_has("term")) >= 0 ) { + if ( (ret_i = u3_sist_has("term")) >= 0 ) { c3_assert(sizeof(c3_w) == ret_i); - u2_sist_get("term", (c3_y*)&tem_w); + u3_sist_get("term", (c3_y*)&tem_w); uL(fprintf(uH, "raft: term from sist: %u\n", tem_w)); } - if ( (ret_i = u2_sist_has("vote")) >= 0 ) { + if ( (ret_i = u3_sist_has("vote")) >= 0 ) { c3_assert(ret_i > 0); vog_c = c3_malloc(ret_i); - u2_sist_get("vote", (c3_y*)vog_c); + u3_sist_get("vote", (c3_y*)vog_c); uL(fprintf(uH, "raft: vote from sist: %s\n", vog_c)); } @@ -1365,10 +1365,10 @@ _raft_foll_init(u2_raft* raf_u) if ( 0 == strcmp(vog_c, raf_u->str_c) ) { raf_u->vog_c = raf_u->str_c; raf_u->vot_w = 1; - raf_u->typ_e = u2_raty_cand; + raf_u->typ_e = u3_raty_cand; } else { - u2_rnam* nam_u; + u3_rnam* nam_u; for ( nam_u = raf_u->nam_u; nam_u; nam_u = nam_u->nex_u ) { if ( 0 == strcmp(vog_c, nam_u->str_c) ) { @@ -1388,12 +1388,12 @@ _raft_foll_init(u2_raft* raf_u) { struct sockaddr_in add_u; c3_w ret_w; - if (0 != (ret_w = uv_ip4_addr("0.0.0.0", u2_Host.ops_u.rop_s, &add_u ))){ + if (0 != (ret_w = uv_ip4_addr("0.0.0.0", u3_Host.ops_u.rop_s, &add_u ))){ uL(fprintf(uH, "raft: init: %s\n", uv_strerror(ret_w))); c3_assert(0); } - if ( 0 != (ret_w = uv_tcp_init(u2L, &raf_u->wax_u)) ) { + if ( 0 != (ret_w = uv_tcp_init(u3L, &raf_u->wax_u)) ) { uL(fprintf(uH, "raft: init: %s\n", uv_strerror(ret_w))); c3_assert(0); } @@ -1406,7 +1406,7 @@ _raft_foll_init(u2_raft* raf_u) c3_assert(0); } else { - uL(fprintf(uH, "raft: on TCP %d\n", u2_Host.ops_u.rop_s)); + uL(fprintf(uH, "raft: on TCP %d\n", u3_Host.ops_u.rop_s)); } } @@ -1417,26 +1417,26 @@ _raft_foll_init(u2_raft* raf_u) /* _raft_lone_init(): begin, single-instance mode. */ static void -_raft_lone_init(u2_raft* raf_u) +_raft_lone_init(u3_raft* raf_u) { uL(fprintf(uH, "raft: single-instance mode\n")); raf_u->pop_w = 1; _raft_promote(raf_u); } -/* u2_raft_init(): start Raft process. +/* u3_raft_init(): start Raft process. */ void -u2_raft_init() +u3_raft_init() { - u2_raft* raf_u = u2R; + u3_raft* raf_u = u3Z; // Initialize timer -- used in both single and multi-instance mode, // for different things. - uv_timer_init(u2L, &raf_u->tim_u); + uv_timer_init(u3L, &raf_u->tim_u); raf_u->tim_u.data = raf_u; - if ( 0 == u2_Host.ops_u.raf_c ) { + if ( 0 == u3_Host.ops_u.raf_c ) { _raft_lone_init(raf_u); } else { @@ -1447,27 +1447,27 @@ u2_raft_init() /* _raft_sure(): apply and save an input ovum and its result. */ static void -_raft_sure(u2_reck* rec_u, u2_noun ovo, u2_noun vir, u2_noun cor) +_raft_sure(u3_noun ovo, u3_noun vir, u3_noun cor) { // Whatever worked, save it. (XX - should be concurrent with execute.) // We'd like more events that don't change the state but need work here. { - u2_mug(cor); - u2_mug(rec_u->roc); + u3_cr_mug(cor); + u3_cr_mug(u3A->roc); - if ( u2_no == u2_sing(cor, rec_u->roc) ) { - rec_u->roe = u2nc(u2nc(vir, ovo), rec_u->roe); + if ( u3_no == u3_cr_sing(cor, u3A->roc) ) { + u3A->roe = u3nc(u3nc(vir, ovo), u3A->roe); - u2z(rec_u->roc); - rec_u->roc = cor; + u3z(u3A->roc); + u3A->roc = cor; } else { - u2z(ovo); + u3z(ovo); // push a new event into queue - rec_u->roe = u2nc(u2nc(vir, u2_nul), rec_u->roe); + u3A->roe = u3nc(u3nc(vir, u3_nul), u3A->roe); - u2z(cor); + u3z(cor); } } } @@ -1475,13 +1475,13 @@ _raft_sure(u2_reck* rec_u, u2_noun ovo, u2_noun vir, u2_noun cor) /* _raft_lame(): handle an application failure. */ static void -_raft_lame(u2_reck* rec_u, u2_noun ovo, u2_noun why, u2_noun tan) +_raft_lame(u3_noun ovo, u3_noun why, u3_noun tan) { - u2_noun bov, gon; + u3_noun bov, gon; #if 0 { - c3_c* oik_c = u2_cr_string(u2h(u2t(ovo))); + c3_c* oik_c = u3_cr_string(u3h(u3t(ovo))); // uL(fprintf(uH, "lame: %s\n", oik_c)); free(oik_c); @@ -1494,43 +1494,42 @@ _raft_lame(u2_reck* rec_u, u2_noun ovo, u2_noun why, u2_noun tan) // to prevent timing attacks, but isn't right now. To deal // with a crypto failure, just drop the packet. // - if ( (c3__exit == why) && (c3__hear == u2h(u2t(ovo))) ) { - u2_lo_punt(2, u2_ckb_flop(u2k(tan))); + if ( (c3__exit == why) && (c3__hear == u3h(u3t(ovo))) ) { + u3_lo_punt(2, u3_ckb_flop(u3k(tan))); - bov = u2nc(u2k(u2h(ovo)), u2nc(c3__hole, u2k(u2t(u2t(ovo))))); - u2z(why); + bov = u3nc(u3k(u3h(ovo)), u3nc(c3__hole, u3k(u3t(u3t(ovo))))); + u3z(why); } else { - bov = u2nc(u2k(u2h(ovo)), u2nt(c3__crud, why, u2k(tan))); - u2_hevn_at(lad) = u2_nul; + bov = u3nc(u3k(u3h(ovo)), u3nt(c3__crud, why, u3k(tan))); } - // u2_lo_show("data", u2k(u2t(u2t(ovo)))); + // u3_lo_show("data", u3k(u3t(u3t(ovo)))); - u2z(ovo); + u3z(ovo); - gon = u2_lo_soft(rec_u, 0, u2_reck_poke, u2k(bov)); - if ( u2_blip == u2h(gon) ) { - _raft_sure(rec_u, bov, u2k(u2h(u2t(gon))), u2k(u2t(u2t(gon)))); + gon = u3_cm_soft(0, u3_cv_poke, u3k(bov)); + if ( u3_blip == u3h(gon) ) { + _raft_sure(bov, u3k(u3h(u3t(gon))), u3k(u3t(u3t(gon)))); - u2z(gon); + u3z(gon); } else { - u2z(gon); + u3z(gon); { - u2_noun vab = u2nc(u2k(u2h(bov)), - u2nc(c3__warn, u2_ci_tape("crude crash!"))); - u2_noun nog = u2_lo_soft(rec_u, 0, u2_reck_poke, u2k(vab)); + u3_noun vab = u3nc(u3k(u3h(bov)), + u3nc(c3__warn, u3_ci_tape("crude crash!"))); + u3_noun nog = u3_cm_soft(0, u3_cv_poke, u3k(vab)); - if ( u2_blip == u2h(nog) ) { - _raft_sure(rec_u, vab, u2k(u2h(u2t(nog))), u2k(u2t(u2t(nog)))); - u2z(nog); + if ( u3_blip == u3h(nog) ) { + _raft_sure(vab, u3k(u3h(u3t(nog))), u3k(u3t(u3t(nog)))); + u3z(nog); } else { - u2z(nog); - u2z(vab); + u3z(nog); + u3z(vab); uL(fprintf(uH, "crude: all delivery failed!\n")); - u2_lo_punt(2, u2_ckb_flop(u2k(tan))); + u3_lo_punt(2, u3_ckb_flop(u3k(tan))); c3_assert(!"crud"); } } @@ -1540,28 +1539,28 @@ _raft_lame(u2_reck* rec_u, u2_noun ovo, u2_noun why, u2_noun tan) /* _raft_punk(): insert and apply an input ovum (unprotected). */ static void -_raft_punk(u2_reck* rec_u, u2_noun ovo) +_raft_punk(u3_noun ovo) { #ifdef GHETTO - c3_c* txt_c = u2_cr_string(u2h(u2t(ovo))); + c3_c* txt_c = u3_cr_string(u3h(u3t(ovo))); #endif c3_w sec_w; // static c3_w num_w; - u2_noun gon; + u3_noun gon; - // uL(fprintf(uH, "punk: %s: %d\n", u2_cr_string(u2h(u2t(ovo))), num_w++)); + // uL(fprintf(uH, "punk: %s: %d\n", u3_cr_string(u3h(u3t(ovo))), num_w++)); // XX this is wrong - the timer should be on the original hose. // - if ( (c3__term == u2h(u2t(u2h(ovo)))) || - (c3__batz == u2h(u2t(u2h(ovo)))) ) { + if ( (c3__term == u3h(u3t(u3h(ovo)))) || + (c3__batz == u3h(u3t(u3h(ovo)))) ) { sec_w = 0; } else sec_w = 600; // Control alarm loops. // - if ( c3__wake != u2h(u2t(ovo)) ) { - u2_Host.beh_u.run_w = 0; + if ( c3__wake != u3h(u3t(ovo)) ) { + u3_Host.beh_u.run_w = 0; } #ifdef GHETTO @@ -1570,7 +1569,7 @@ _raft_punk(u2_reck* rec_u, u2_noun ovo) uL(fprintf(uH, "%%soft %s\n", txt_c)); #endif - gon = u2_lo_soft(rec_u, sec_w, u2_reck_poke, u2k(ovo)); + gon = u3_cm_soft(sec_w, u3_cv_poke, u3k(ovo)); #ifdef GHETTO c3_w ms_w; @@ -1582,34 +1581,34 @@ _raft_punk(u2_reck* rec_u, u2_noun ovo) free(txt_c); #endif - if ( u2_blip != u2h(gon) ) { - u2_noun why = u2k(u2h(gon)); - u2_noun tan = u2k(u2t(gon)); + if ( u3_blip != u3h(gon) ) { + u3_noun why = u3k(u3h(gon)); + u3_noun tan = u3k(u3t(gon)); - u2z(gon); - _raft_lame(rec_u, ovo, why, tan); + u3z(gon); + _raft_lame(ovo, why, tan); } else { - u2_noun vir = u2k(u2h(u2t(gon))); - u2_noun cor = u2k(u2t(u2t(gon))); - u2_noun nug; + u3_noun vir = u3k(u3h(u3t(gon))); + u3_noun cor = u3k(u3t(u3t(gon))); + u3_noun nug; - u2z(gon); - nug = u2_reck_nick(rec_u, vir, cor); + u3z(gon); + nug = u3_cv_nick(vir, cor); - if ( u2_blip != u2h(nug) ) { - u2_noun why = u2k(u2h(nug)); - u2_noun tan = u2k(u2t(nug)); + if ( u3_blip != u3h(nug) ) { + u3_noun why = u3k(u3h(nug)); + u3_noun tan = u3k(u3t(nug)); - u2z(nug); - _raft_lame(rec_u, ovo, why, tan); + u3z(nug); + _raft_lame(ovo, why, tan); } else { - vir = u2k(u2h(u2t(nug))); - cor = u2k(u2t(u2t(nug))); + vir = u3k(u3h(u3t(nug))); + cor = u3k(u3t(u3t(nug))); - u2z(nug); - _raft_sure(rec_u, ovo, vir, cor); + u3z(nug); + _raft_sure(ovo, vir, cor); } } // uL(fprintf(uH, "punk oot %s\n", txt_c)); @@ -1618,40 +1617,40 @@ _raft_punk(u2_reck* rec_u, u2_noun ovo) static void -_raft_comm(u2_reck* rec_u, c3_d bid_d) +_raft_comm(c3_d bid_d) { - u2_cart* egg_u; + u3_cart* egg_u; - u2_lo_open(); + u3_lo_open(); - egg_u = rec_u->ova.egg_u; + egg_u = u3A->ova.egg_u; while ( egg_u ) { if ( egg_u->ent_d <= bid_d ) { - egg_u->cit = u2_yes; + egg_u->cit = u3_yes; } else break; egg_u = egg_u->nex_u; } - u2_lo_shut(u2_yes); + u3_lo_shut(u3_yes); } static void _raft_comm_cb(uv_timer_t* tim_u) { - u2_raft* raf_u = tim_u->data; + u3_raft* raf_u = tim_u->data; - _raft_comm(u2A, raf_u->ent_d); + _raft_comm(raf_u->ent_d); } static c3_d -_raft_push(u2_raft* raf_u, c3_w* bob_w, c3_w len_w) +_raft_push(u3_raft* raf_u, c3_w* bob_w, c3_w len_w) { - c3_assert(raf_u->typ_e == u2_raty_lead); + c3_assert(raf_u->typ_e == u3_raty_lead); c3_assert(0 != bob_w && 0 < len_w); if ( 1 == raf_u->pop_w ) { - c3_assert(u2_raty_lead == raf_u->typ_e); - raf_u->ent_d = u2_sist_pack(u2A, raf_u->tem_w, c3__ov, bob_w, len_w); + c3_assert(u3_raty_lead == raf_u->typ_e); + raf_u->ent_d = u3_sist_pack(raf_u->tem_w, c3__ov, bob_w, len_w); raf_u->lat_w = raf_u->tem_w; // XX if ( !uv_is_active((uv_handle_t*)&raf_u->tim_u) ) { @@ -1671,76 +1670,74 @@ _raft_push(u2_raft* raf_u, c3_w* bob_w, c3_w len_w) /* _raft_kick_all(): kick a list of events, transferring. */ static void -_raft_kick_all(u2_reck* rec_u, u2_noun vir) +_raft_kick_all(u3_noun vir) { - while ( u2_nul != vir ) { - u2_noun ovo = u2k(u2h(vir)); - u2_noun nex = u2k(u2t(vir)); - u2z(vir); vir = nex; + while ( u3_nul != vir ) { + u3_noun ovo = u3k(u3h(vir)); + u3_noun nex = u3k(u3t(vir)); + u3z(vir); vir = nex; - u2_reck_kick(rec_u, ovo); + u3_reck_kick(ovo); } } - - -/* u2_raft_work(): work in rec_u. +/* u3_raft_work(): work. */ void -u2_raft_work(u2_reck* rec_u) +u3_raft_work(void) { - if ( u2R->typ_e != u2_raty_lead ) { - c3_assert(rec_u->ova.egg_u == 0); - if ( u2_nul != rec_u->roe ) { + if ( u3Z->typ_e != u3_raty_lead ) { + c3_assert(u3A->ova.egg_u == 0); + if ( u3_nul != u3A->roe ) { uL(fprintf(uH, "raft: dropping roe!!\n")); - u2z(rec_u->roe); - rec_u->roe = u2_nul; + u3z(u3A->roe); + u3A->roe = u3_nul; } } else { - u2_cart* egg_u; - u2_noun ova; - u2_noun vir; - u2_noun nex; + u3_cart* egg_u; + u3_noun ova; + u3_noun vir; + u3_noun nex; // Delete finished events. // - while ( rec_u->ova.egg_u ) { - egg_u = rec_u->ova.egg_u; + while ( u3A->ova.egg_u ) { + egg_u = u3A->ova.egg_u; - if ( u2_yes == egg_u->did ) { + if ( u3_yes == egg_u->did ) { vir = egg_u->vir; - if ( egg_u == rec_u->ova.geg_u ) { + if ( egg_u == u3A->ova.geg_u ) { c3_assert(egg_u->nex_u == 0); - rec_u->ova.geg_u = rec_u->ova.egg_u = 0; + u3A->ova.geg_u = u3A->ova.egg_u = 0; } else { c3_assert(egg_u->nex_u != 0); - rec_u->ova.egg_u = egg_u->nex_u; + u3A->ova.egg_u = egg_u->nex_u; } - egg_u->cit = u2_yes; + egg_u->cit = u3_yes; free(egg_u); } else break; } - // Poke pending events, leaving the poked events and errors on rec_u->roe. + // Poke pending events, leaving the poked events and errors on u3A->roe. // { - if ( 0 == u2R->lug_u.len_d ) { + if ( 0 == u3Z->lug_u.len_d ) { return; } - ova = u2_ckb_flop(rec_u->roe); - rec_u->roe = u2_nul; + ova = u3_ckb_flop(u3A->roe); + u3A->roe = u3_nul; - while ( u2_nul != ova ) { - _raft_punk(rec_u, u2k(u2t(u2h(ova)))); - c3_assert(u2_nul == u2h(u2h(ova))); + while ( u3_nul != ova ) { + _raft_punk(u3k(u3t(u3h(ova)))); + c3_assert(u3_nul == u3h(u3h(ova))); - nex = u2k(u2t(ova)); - u2z(ova); ova = nex; + nex = u3k(u3t(ova)); + u3z(ova); ova = nex; } } @@ -1750,48 +1747,48 @@ u2_raft_work(u2_reck* rec_u) c3_d bid_d; c3_w len_w; c3_w* bob_w; - u2_noun ron; - u2_noun ovo; + u3_noun ron; + u3_noun ovo; - ova = u2_ckb_flop(rec_u->roe); - rec_u->roe = u2_nul; + ova = u3_ckb_flop(u3A->roe); + u3A->roe = u3_nul; - while ( u2_nul != ova ) { - ovo = u2k(u2t(u2h(ova))); - vir = u2k(u2h(u2h(ova))); - nex = u2k(u2t(ova)); - u2z(ova); ova = nex; + while ( u3_nul != ova ) { + ovo = u3k(u3t(u3h(ova))); + vir = u3k(u3h(u3h(ova))); + nex = u3k(u3t(ova)); + u3z(ova); ova = nex; - if ( u2_nul != ovo ) { + if ( u3_nul != ovo ) { egg_u = c3_malloc(sizeof(*egg_u)); egg_u->nex_u = 0; - egg_u->cit = u2_no; - egg_u->did = u2_no; + egg_u->cit = u3_no; + egg_u->did = u3_no; egg_u->vir = vir; - ron = u2_cke_jam(u2nc(u2k(rec_u->now), ovo)); - c3_assert(rec_u->key); - ron = u2_dc("en:crua", u2k(rec_u->key), ron); + ron = u3_cke_jam(u3nc(u3k(u3A->now), ovo)); + c3_assert(u3A->key); + ron = u3_dc("en:crua", u3k(u3A->key), ron); - len_w = u2_cr_met(5, ron); + len_w = u3_cr_met(5, ron); bob_w = c3_malloc(len_w * 4L); - u2_cr_words(0, len_w, bob_w, ron); - u2z(ron); + u3_cr_words(0, len_w, bob_w, ron); + u3z(ron); - bid_d = _raft_push(u2R, bob_w, len_w); + bid_d = _raft_push(u3Z, bob_w, len_w); egg_u->ent_d = bid_d; - if ( 0 == rec_u->ova.geg_u ) { - c3_assert(0 == rec_u->ova.egg_u); - rec_u->ova.geg_u = rec_u->ova.egg_u = egg_u; + if ( 0 == u3A->ova.geg_u ) { + c3_assert(0 == u3A->ova.egg_u); + u3A->ova.geg_u = u3A->ova.egg_u = egg_u; } else { - c3_assert(0 == rec_u->ova.geg_u->nex_u); - rec_u->ova.geg_u->nex_u = egg_u; - rec_u->ova.geg_u = egg_u; + c3_assert(0 == u3A->ova.geg_u->nex_u); + u3A->ova.geg_u->nex_u = egg_u; + u3A->ova.geg_u = egg_u; } - _raft_kick_all(rec_u, vir); - egg_u->did = u2_yes; + _raft_kick_all(vir); + egg_u->did = u3_yes; } } } diff --git a/v/reck.c b/v/reck.c index 88e46932a..5023f478f 100644 --- a/v/reck.c +++ b/v/reck.c @@ -18,429 +18,94 @@ #include #include "all.h" -#include "f/coal.h" #include "v/vere.h" -/* _reck_mung(): formula wrapper with gate and sample. -*/ - static u2_noun - _reck_mung_in(u2_reck* rec_u, u2_noun gam) - { - u2_noun pro = u2_cn_mung(u2k(u2h(gam)), u2k(u2t(gam))); - - u2z(gam); return pro; - } -static u2_noun -_reck_mung(u2_reck* rec_u, c3_w sec_w, u2_noun gat, u2_noun sam) -{ - u2_noun gam = u2nc(gat, sam); - - return u2_lo_soft(rec_u, 0, _reck_mung_in, gam); -} - -/* u2_reck_pike(): poke with floating core. -*/ -u2_noun -u2_reck_pike(u2_reck* rec_u, u2_noun ovo, u2_noun cor) -{ - u2_noun fun = u2_cn_nock(cor, u2k(u2_cx_at(42, cor))); - u2_noun sam = u2nc(u2k(rec_u->now), ovo); - - return _reck_mung(rec_u, 0, fun, sam); -} - -/* u2_reck_nick(): transform enveloped packets, [vir cor]. -*/ -u2_noun -u2_reck_nick(u2_reck* rec_u, u2_noun vir, u2_noun cor) -{ - if ( u2_nul == vir ) { - return u2nt(u2_blip, vir, cor); - } - else { - u2_noun i_vir = u2h(vir); - u2_noun pi_vir, qi_vir; - u2_noun vix; - - if ( (u2_yes == u2_cr_cell((i_vir=u2h(vir)), &pi_vir, &qi_vir)) && - (u2_yes == u2du(qi_vir)) && - (c3__hear == u2h(qi_vir)) ) - { - u2_noun gon; - - gon = u2_reck_pike(rec_u, u2k(i_vir), cor); - if ( u2_blip != u2h(gon) ) { - u2z(vir); - return gon; - } - else { - u2_noun viz; - - vix = u2k(u2h(u2t(gon))); - cor = u2k(u2t(u2t(gon))); - u2z(gon); - - viz = u2_ckb_weld(vix, u2k(u2t(vir))); - u2z(vir); - - return u2_reck_nick(rec_u, viz, cor); - } - } - else { - u2_noun nez = u2_reck_nick(rec_u, u2k(u2t(vir)), cor); - - if ( u2_blip != u2h(nez) ) { - u2z(vir); - return nez; - } else { - u2_noun viz; - - viz = u2nc(u2k(i_vir), u2k(u2h(u2t(nez)))); - cor = u2k(u2t(u2t(nez))); - - u2z(vir); - u2z(nez); - - return u2nt(u2_blip, viz, cor); - } - } - } -} - - -/* _reck_spat(): spat with toy. -*/ -static u2_noun -_reck_spat(u2_reck* rec_u, u2_noun pox) -{ - return u2_do("spat", pox); -} - -/* _reck_nock_poke(): call poke through hardcoded interface. -*/ -static u2_noun -_reck_nock_poke(u2_reck* rec_u, u2_noun ovo) -{ - u2_noun fun = u2_cn_nock(u2k(rec_u->roc), u2k(u2_cx_at(42, rec_u->roc))); - u2_noun sam, pro; - - sam = u2nc(u2k(rec_u->now), ovo); -#if 0 - { - c3_c* ovi_c = u2_cr_string(u2h(u2t(ovo))); - u2_noun tox = _reck_spat(rec_u, u2k(u2h(ovo))); - c3_c* tox_c = u2_cr_string(tox); - - uL(fprintf(uH, "poke: %%%s on %s\n", ovi_c, tox_c)); - - free(tox_c); free(ovi_c); u2z(tox); - } -#endif - -#if 0 - { - c3_c* ovi_c = u2_cr_string(u2h(u2t(ovo))); - - uL(fprintf(uH, "poke: %s\n", ovi_c)); - - free(ovi_c); - } -#endif - - pro = u2_cn_mung(fun, sam); - return pro; -} - -/* _reck_nock_peek(): call peek through hardcoded interface. -*/ -static u2_noun -_reck_nock_peek(u2_reck* rec_u, u2_noun hap) -{ - u2_noun fun = u2_cn_nock(u2k(rec_u->roc), u2k(u2_cx_at(87, rec_u->roc))); - u2_noun sam = u2nc(u2k(rec_u->now), hap); - - return u2_cn_mung(fun, sam); -} - -/* _reck_nock_keep(): call wait through hardcoded interface. -*/ -static u2_noun -_reck_nock_keep(u2_reck* rec_u, u2_noun hap) -{ - u2_noun fun = u2_cn_nock(u2k(rec_u->roc), u2k(u2_cx_at(4, rec_u->roc))); - u2_noun sam = u2nc(u2k(rec_u->now), hap); - - return u2_cn_mung(fun, sam); -} - -/* _reck_nock_wish(): call wish through hardcoded interface. -*/ -static u2_noun -_reck_nock_wish(u2_reck* rec_u, u2_noun txt) -{ - u2_noun fun = u2_cn_nock(u2k(rec_u->roc), u2k(u2_cx_at(20, rec_u->roc))); - - return u2_cn_mung(fun, txt); -} - -/* u2_reck_do(): use a kernel function. -*/ -u2_noun -u2_reck_do(const c3_c* txt_c, u2_noun arg) -{ - return u2_cn_mung(u2_reck_gate(txt_c), arg); -} - -/* u2_reck_wish(): noun from expression -*/ -u2_noun -u2_reck_wish(u2_reck* rec_u, c3_c* str_c) -{ - return _reck_nock_wish(rec_u, u2_ci_string(str_c)); -} - -/* _reck_scot(): print atom. -*/ -static u2_noun -_reck_scot(u2_reck* rec_u, u2_noun dim) -{ - return u2_do("scot", dim); -} - -/* u2_reck_time(): set the reck time. -*/ -void -u2_reck_time(u2_reck* rec_u) -{ - struct timeval tim_tv; - - gettimeofday(&tim_tv, 0); - u2z(rec_u->now); - rec_u->now = u2_time_in_tv(&tim_tv); - - u2z(rec_u->wen); - rec_u->wen = _reck_scot(rec_u, u2nc(c3__da, u2k(rec_u->now))); -} - -/* u2_reck_wind(): set the reck time artificially. -*/ -void -u2_reck_wind(u2_reck* rec_u, u2_noun now) -{ - u2z(rec_u->now); - rec_u->now = now; - - u2z(rec_u->wen); - rec_u->wen = _reck_scot(rec_u, u2nc(c3__da, u2k(rec_u->now))); -} - -/* u2_reck_numb(): set the instance number. -*/ -void -u2_reck_numb(u2_reck* rec_u) -{ - struct timeval tp; - - gettimeofday(&tp, 0); - rec_u->sev_l = 0x7fffffff & - ( ((c3_w) tp.tv_sec) ^ - u2_mug(0x7fffffff & ((c3_w) tp.tv_usec)) ^ - u2_mug(getpid())); - u2z(rec_u->sen); - rec_u->sen = _reck_scot(rec_u, u2nc(c3__uv, rec_u->sev_l)); -} - -#if 0 -/* _reck_time_bump(): advance the reck time by a small increment. -*/ -static void -_reck_time_bump(u2_reck* rec_u) -{ - c3_d bum_d = (1ULL << 48ULL); - - rec_u->now = u2_cka_add(rec_u->now, u2_ci_chubs(1, &bum_d)); -} -#endif - -/* u2_reck_peek(): query the reck namespace (protected). -*/ -u2_noun -u2_reck_peek(u2_reck* rec_u, u2_noun hap) -{ - return _reck_nock_peek(rec_u, hap); -} - -/* u2_reck_keep(): measure timer. -*/ -u2_noun -u2_reck_keep(u2_reck* rec_u, u2_noun hap) -{ - return _reck_nock_keep(rec_u, hap); -} - -/* u2_reck_cold(): load full arvo with vanes, from new solid state. -*/ -void -u2_reck_cold(u2_reck* rec_u, c3_w kno_w) -{ - memset(rec_u, 0, sizeof(*rec_u)); - rec_u->kno_w = kno_w; - rec_u->rno_w = 0; - rec_u->ent_d = 1; - - rec_u->own = 0; - rec_u->now = 0; - rec_u->wen = 0; - rec_u->sen = 0; - rec_u->roe = 0; - rec_u->key = 0; - rec_u->yot = 0; - - { - u2_noun pot, eng; - c3_c ful_c[2048]; - - if ( u2_yes == u2_Host.ops_u.nuu ) { - snprintf(ful_c, 2048, "%s/urbit.pill", U2_LIB); - } else { - snprintf(ful_c, 2048, "%s/.urb/urbit.pill", u2_Host.cpu_c); - } - printf("loading %s\n", ful_c); - - if ( 0 == (pot = u2_walk_load(ful_c)) ) { - perror(ful_c); - exit(1); - } - - // Copy into basket to propitiate jet gods. - { - u2_rail bas_r = u2_wire_bas_r(u2_Wire); - u2_noun tup; - - tup = u2_cke_cue(pot); - eng = u2_rx(bas_r, tup); - u2z(tup); - } - - rec_u->ken = u2h(eng); - rec_u->roc = u2t(eng); - - // Execute from kernel to propitiate jet gods. - { - u2_noun fak; - - fak = u2_cn_nock(0, rec_u->ken); - u2z(fak); - } - } - - // Gates called deep when memory is wrapped. - { - u2z(u2_reck_gate("wash")); - u2z(u2_reck_gate("mook")); - } - - u2_reck_time(rec_u); - - u2_reck_numb(rec_u); - { - c3_c* dyt_c = u2_cr_string(rec_u->wen); - - printf("time: %s\n", dyt_c); - free(dyt_c); - } -} - /* _reck_mole(): parse simple atomic mole. */ -static u2_bean -_reck_mole(u2_reck* rec_u, - u2_noun fot, - u2_noun san, +static u3_bean +_reck_mole(u3_noun fot, + u3_noun san, c3_d* ato_d) { - u2_noun uco = u2_do("slay", san); - u2_noun p_uco, q_uco, r_uco, s_uco; + u3_noun uco = u3_do("slay", san); + u3_noun p_uco, q_uco, r_uco, s_uco; - if ( (u2_no == u2_cr_qual(uco, &p_uco, &q_uco, &r_uco, &s_uco)) || + if ( (u3_no == u3_cr_qual(uco, &p_uco, &q_uco, &r_uco, &s_uco)) || (0 != p_uco) || (0 != q_uco) || - (u2_no == u2_sing(fot, r_uco)) ) + (u3_no == u3_cr_sing(fot, r_uco)) ) { - uL(fprintf(uH, "strange mole %s\n", u2_cr_string(san))); + uL(fprintf(uH, "strange mole %s\n", u3_cr_string(san))); - u2z(fot); u2z(uco); return u2_no; + u3z(fot); u3z(uco); return u3_no; } else { - *ato_d = u2_cr_chub(0, s_uco); + *ato_d = u3_cr_chub(0, s_uco); - u2z(fot); u2z(uco); return u2_yes; + u3z(fot); u3z(uco); return u3_yes; } } /* _reck_lily(): parse little atom. */ -static u2_bean -_reck_lily(u2_reck* rec_u, u2_noun fot, u2_noun txt, c3_l* tid_l) +static u3_bean +_reck_lily(u3_noun fot, u3_noun txt, c3_l* tid_l) { c3_d ato_d; - if ( u2_no == _reck_mole(rec_u, fot, txt, &ato_d) ) { - return u2_no; + if ( u3_no == _reck_mole(fot, txt, &ato_d) ) { + return u3_no; } else { if ( ato_d >= 0x80000000ULL ) { - return u2_no; + return u3_no; } else { *tid_l = (c3_l) ato_d; - return u2_yes; + return u3_yes; } } } /* _reck_kick_term(): apply terminal outputs. */ -static u2_bean -_reck_kick_term(u2_reck* rec_u, u2_noun pox, c3_l tid_l, u2_noun fav) +static u3_bean +_reck_kick_term(u3_noun pox, c3_l tid_l, u3_noun fav) { - u2_noun p_fav; + u3_noun p_fav; - if ( u2_no == u2du(fav) ) { - u2z(pox); u2z(fav); return u2_no; + if ( u3_no == u3du(fav) ) { + u3z(pox); u3z(fav); return u3_no; } - else switch ( u2h(fav) ) { - default: u2z(pox); u2z(fav); return u2_no; + else switch ( u3h(fav) ) { + default: u3z(pox); u3z(fav); return u3_no; case c3__bbye: { - u2_reck_sync(rec_u); - // u2_reck_plan(rec_u, pox, u2nc(c3__helo, u2_nul)); - - u2z(pox); u2z(fav); return u2_yes; + u3z(pox); u3z(fav); return u3_yes; } break; - case c3__blit: p_fav = u2t(fav); + case c3__blit: p_fav = u3t(fav); { - u2_term_ef_blit(tid_l, u2k(p_fav)); + u3_term_ef_blit(tid_l, u3k(p_fav)); - u2z(pox); u2z(fav); return u2_yes; + u3z(pox); u3z(fav); return u3_yes; } break; case c3__logo: { - u2_Host.liv = u2_no; - u2_Host.xit_i = u2t(fav); + u3_Host.liv = u3_no; + u3_Host.xit_i = u3t(fav); - u2z(pox); u2z(fav); return u2_yes; + u3z(pox); u3z(fav); return u3_yes; } break; - case c3__init: p_fav = u2t(fav); + case c3__init: p_fav = u3t(fav); { - rec_u->own = u2nc(u2k(p_fav), rec_u->own); + u3A->own = u3nc(u3k(p_fav), u3A->own); - u2_unix_ef_init(u2k(p_fav)); + u3_unix_ef_init(u3k(p_fav)); // uL(fprintf(uH, "kick: init: %d\n", p_fav)); - u2z(pox); u2z(fav); return u2_yes; + u3z(pox); u3z(fav); return u3_yes; } break; } c3_assert(!"not reached"); return 0; @@ -448,380 +113,266 @@ _reck_kick_term(u2_reck* rec_u, u2_noun pox, c3_l tid_l, u2_noun fav) /* _reck_kick_http(): apply http effects. */ -static u2_bean -_reck_kick_http(u2_reck* rec_u, - u2_noun pox, +static u3_bean +_reck_kick_http(u3_noun pox, c3_l sev_l, c3_l coq_l, c3_l seq_l, - u2_noun fav) + u3_noun fav) { - u2_noun p_fav, q_fav; + u3_noun p_fav, q_fav; - if ( u2_no == u2du(fav) ) { - u2z(pox); u2z(fav); return u2_no; + if ( u3_no == u3du(fav) ) { + u3z(pox); u3z(fav); return u3_no; } - else switch ( u2h(fav) ) { - default: u2z(pox); u2z(fav); return u2_no; + else switch ( u3h(fav) ) { + default: u3z(pox); u3z(fav); return u3_no; - case c3__thus: p_fav = u2h(u2t(fav)); q_fav = u2t(u2t(fav)); + case c3__thus: p_fav = u3h(u3t(fav)); q_fav = u3t(u3t(fav)); { - u2_cttp_ef_thus(u2_cr_word(0, p_fav), u2k(q_fav)); + u3_cttp_ef_thus(u3_cr_word(0, p_fav), u3k(q_fav)); - u2z(pox); u2z(fav); - return u2_yes; + u3z(pox); u3z(fav); + return u3_yes; } - case c3__thou: p_fav = u2t(fav); + case c3__thou: p_fav = u3t(fav); { - u2_http_ef_thou(sev_l, coq_l, seq_l, u2k(p_fav)); + u3_http_ef_thou(sev_l, coq_l, seq_l, u3k(p_fav)); - u2z(pox); u2z(fav); - return u2_yes; + u3z(pox); u3z(fav); + return u3_yes; } break; } - c3_assert(!"not reached"); return u2_no; + c3_assert(!"not reached"); return u3_no; } /* _reck_kick_sync(): apply sync outputs. */ -static u2_bean -_reck_kick_sync(u2_reck* rec_u, u2_noun pox, u2_noun fav) +static u3_bean +_reck_kick_sync(u3_noun pox, u3_noun fav) { - switch ( u2h(fav) ) { + switch ( u3h(fav) ) { default: break; case c3__ergo: { - u2_noun who = u2k(u2h(u2t(fav))); - u2_noun syd = u2k(u2h(u2t(u2t(fav)))); - u2_noun rel = u2k(u2t(u2t(u2t(fav)))); + u3_noun who = u3k(u3h(u3t(fav))); + u3_noun syd = u3k(u3h(u3t(u3t(fav)))); + u3_noun rel = u3k(u3t(u3t(u3t(fav)))); - u2_unix_ef_ergo(who, syd, rel); - u2z(pox); u2z(fav); return u2_yes; + u3_unix_ef_ergo(who, syd, rel); + u3z(pox); u3z(fav); return u3_yes; } break; } // XX obviously not right! // - u2z(pox); u2z(fav); return u2_no; + u3z(pox); u3z(fav); return u3_no; } -static u2_bean -_reck_kick_newt(u2_reck* rec_u, u2_noun pox, u2_noun fav) +static u3_bean +_reck_kick_newt(u3_noun pox, u3_noun fav) { - u2_noun p_fav; - - switch ( u2h(fav) ) { + switch ( u3h(fav) ) { default: break; case c3__send: { - u2_noun lan = u2k(u2h(u2t(fav))); - u2_noun pac = u2k(u2t(u2t(fav))); + u3_noun lan = u3k(u3h(u3t(fav))); + u3_noun pac = u3k(u3t(u3t(fav))); - u2_ames_ef_send(lan, pac); - u2z(pox); u2z(fav); return u2_yes; + u3_ames_ef_send(lan, pac); + u3z(pox); u3z(fav); return u3_yes; } break; } - u2z(pox); u2z(fav); return u2_no; + u3z(pox); u3z(fav); return u3_no; } /* _reck_kick_ames(): apply packet network outputs. */ -static u2_bean -_reck_kick_ames(u2_reck* rec_u, u2_noun pox, u2_noun fav) +static u3_bean +_reck_kick_ames(u3_noun pox, u3_noun fav) { - u2_noun p_fav; + u3_noun p_fav; - switch ( u2h(fav) ) { + switch ( u3h(fav) ) { default: break; - case c3__init: p_fav = u2t(fav); + case c3__init: p_fav = u3t(fav); { - rec_u->own = u2nc(u2k(p_fav), rec_u->own); + u3A->own = u3nc(u3k(p_fav), u3A->own); - u2_unix_ef_init(u2k(p_fav)); + u3_unix_ef_init(u3k(p_fav)); // uL(fprintf(uH, "kick: init: %d\n", p_fav)); - u2z(pox); u2z(fav); return u2_yes; + u3z(pox); u3z(fav); return u3_yes; } break; } - u2z(pox); u2z(fav); return u2_no; + u3z(pox); u3z(fav); return u3_no; } /* _reck_kick_spec(): apply an effect, by path. */ -static u2_bean -_reck_kick_spec(u2_reck* rec_u, u2_noun pox, u2_noun fav) +static u3_bean +_reck_kick_spec(u3_noun pox, u3_noun fav) { - u2_noun i_pox, t_pox; + u3_noun i_pox, t_pox; - if ( (u2_no == u2_cr_cell(pox, &i_pox, &t_pox)) || - ((i_pox != u2_blip) && + if ( (u3_no == u3_cr_cell(pox, &i_pox, &t_pox)) || + ((i_pox != u3_blip) && (i_pox != c3__gold) && (i_pox != c3__iron) && (i_pox != c3__lead)) ) { - u2z(pox); u2z(fav); return u2_no; + u3z(pox); u3z(fav); return u3_no; } else { - u2_noun it_pox, tt_pox; + u3_noun it_pox, tt_pox; - if ( (u2_no == u2_cr_cell(t_pox, &it_pox, &tt_pox)) ) { - u2z(pox); u2z(fav); return u2_no; + if ( (u3_no == u3_cr_cell(t_pox, &it_pox, &tt_pox)) ) { + u3z(pox); u3z(fav); return u3_no; } else switch ( it_pox ) { - default: return u2_no; + default: return u3_no; case c3__http: { - u2_noun pud = tt_pox; - u2_noun p_pud, t_pud, tt_pud, q_pud, r_pud, s_pud; + u3_noun pud = tt_pox; + u3_noun p_pud, t_pud, tt_pud, q_pud, r_pud, s_pud; c3_l sev_l, coq_l, seq_l; - if ( (u2_no == u2_cr_cell(pud, &p_pud, &t_pud)) || - (u2_no == _reck_lily(rec_u, c3__uv, u2k(p_pud), &sev_l)) ) + if ( (u3_no == u3_cr_cell(pud, &p_pud, &t_pud)) || + (u3_no == _reck_lily(c3__uv, u3k(p_pud), &sev_l)) ) { - u2z(pox); u2z(fav); return u2_no; + u3z(pox); u3z(fav); return u3_no; } - if ( u2_nul == t_pud ) { + if ( u3_nul == t_pud ) { coq_l = seq_l = 0; } else { - if ( (u2_no == u2_cr_cell(t_pud, &q_pud, &tt_pud)) || - (u2_no == _reck_lily(rec_u, c3__ud, u2k(q_pud), &coq_l)) ) + if ( (u3_no == u3_cr_cell(t_pud, &q_pud, &tt_pud)) || + (u3_no == _reck_lily(c3__ud, u3k(q_pud), &coq_l)) ) { - u2z(pox); u2z(fav); return u2_no; + u3z(pox); u3z(fav); return u3_no; } - if ( u2_nul == tt_pud ) { + if ( u3_nul == tt_pud ) { seq_l = 0; } else { - if ( (u2_no == u2_cr_cell(tt_pud, &r_pud, &s_pud)) || - (u2_nul != s_pud) || - (u2_no == _reck_lily(rec_u, c3__ud, u2k(r_pud), &seq_l)) ) + if ( (u3_no == u3_cr_cell(tt_pud, &r_pud, &s_pud)) || + (u3_nul != s_pud) || + (u3_no == _reck_lily(c3__ud, u3k(r_pud), &seq_l)) ) { - u2z(pox); u2z(fav); return u2_no; + u3z(pox); u3z(fav); return u3_no; } } } - return _reck_kick_http(rec_u, pox, sev_l, coq_l, seq_l, fav); + return _reck_kick_http(pox, sev_l, coq_l, seq_l, fav); } break; case c3__clay: case c3__sync: { - return _reck_kick_sync(rec_u, pox, fav); + return _reck_kick_sync(pox, fav); } break; case c3__newt: { - return _reck_kick_newt(rec_u, pox, fav); + return _reck_kick_newt(pox, fav); } break; case c3__ames: { - if ( (u2_nul != tt_pox) ) { - u2z(pox); u2z(fav); return u2_no; + if ( (u3_nul != tt_pox) ) { + u3z(pox); u3z(fav); return u3_no; } else { - return _reck_kick_ames(rec_u, pox, fav); + return _reck_kick_ames(pox, fav); } } break; case c3__term: { - u2_noun pud = tt_pox; - u2_noun p_pud, q_pud; + u3_noun pud = tt_pox; + u3_noun p_pud, q_pud; c3_l tid_l; - if ( (u2_no == u2_cr_cell(pud, &p_pud, &q_pud)) || - (u2_nul != q_pud) || - (u2_no == _reck_lily(rec_u, c3__ud, u2k(p_pud), &tid_l)) ) + if ( (u3_no == u3_cr_cell(pud, &p_pud, &q_pud)) || + (u3_nul != q_pud) || + (u3_no == _reck_lily(c3__ud, u3k(p_pud), &tid_l)) ) { uL(fprintf(uH, "term: bad tire\n")); - u2z(pox); u2z(fav); return u2_no; + u3z(pox); u3z(fav); return u3_no; } else { - return _reck_kick_term(rec_u, pox, tid_l, fav); + return _reck_kick_term(pox, tid_l, fav); } } break; } } c3_assert(!"not reached"); - return u2_no; + return u3_no; } /* _reck_kick_norm(): non path-specific effect handling. */ -static u2_bean -_reck_kick_norm(u2_reck* rec_u, u2_noun pox, u2_noun fav) +static u3_bean +_reck_kick_norm(u3_noun pox, u3_noun fav) { - if ( u2_no == u2du(fav) ) { - u2z(pox); u2z(fav); return u2_no; + if ( u3_no == u3du(fav) ) { + u3z(pox); u3z(fav); return u3_no; } - else switch ( u2h(fav) ) { - default: u2z(pox); u2z(fav); return u2_no; + else switch ( u3h(fav) ) { + default: u3z(pox); u3z(fav); return u3_no; case c3__vega: { // uL(fprintf(uH, "reset\n")); - u2z(pox); u2z(fav); + u3z(pox); u3z(fav); - // u2_ds_wipe(u2_Wire); // doesn't work + // u3_ds_wipe(u3_Wire); // doesn't work - return u2_yes; + return u3_yes; } case c3__exit: { uL(fprintf(uH, "<<>>\n")); - u2_lo_bail(rec_u); + u3_lo_bail(); - u2z(pox); u2z(fav); return u2_yes; + u3z(pox); u3z(fav); return u3_yes; } break; } - c3_assert(!"not reached"); return u2_no; - u2z(pox); u2z(fav); return u2_no; + c3_assert(!"not reached"); return u3_no; + u3z(pox); u3z(fav); return u3_no; } -/* u2_reck_kick(): handle effect. +/* u3_reck_kick(): handle effect. */ void -u2_reck_kick(u2_reck* rec_u, u2_noun ovo) +u3_reck_kick(u3_noun ovo) { - if ( (u2_no == _reck_kick_spec(rec_u, u2k(u2h(ovo)), u2k(u2t(ovo)))) && - (u2_no == _reck_kick_norm(rec_u, u2k(u2h(ovo)), u2k(u2t(ovo)))) ) + if ( (u3_no == _reck_kick_spec(u3k(u3h(ovo)), u3k(u3t(ovo)))) && + (u3_no == _reck_kick_norm(u3k(u3h(ovo)), u3k(u3t(ovo)))) ) { - u2_noun tox = _reck_spat(rec_u, u2k(u2h(ovo))); + u3_noun tox = u3_do("spat", u3k(u3h(ovo))); #if 0 - if ( (c3__warn != u2h(u2t(ovo))) && - (c3__text != u2h(u2t(ovo))) && - (c3__note != u2h(u2t(ovo))) ) + if ( (c3__warn != u3h(u3t(ovo))) && + (c3__text != u3h(u3t(ovo))) && + (c3__note != u3h(u3t(ovo))) ) #endif #if 1 - if ( (c3__crud == u2h(u2t(ovo))) ) + if ( (c3__crud == u3h(u3t(ovo))) ) #if 0 - (c3__talk == u2h(u2t(ovo))) || - (c3__helo == u2h(u2t(ovo))) || - (c3__init == u2h(u2t(ovo))) ) + (c3__talk == u3h(u3t(ovo))) || + (c3__helo == u3h(u3t(ovo))) || + (c3__init == u3h(u3t(ovo))) ) #endif { - u2_reck_plan(rec_u, u2nt(u2_blip, c3__term, u2_nul), - u2nc(c3__flog, u2k(u2t(ovo)))); + u3_cv_plan(u3nt(u3_blip, c3__term, u3_nul), + u3nc(c3__flog, u3k(u3t(ovo)))); } else { uL(fprintf(uH, "kick: lost %%%s on %s\n", - u2_cr_string(u2h(u2t(ovo))), - u2_cr_string(tox))); + u3_cr_string(u3h(u3t(ovo))), + u3_cr_string(tox))); #if 0 - if ( c3__hear == u2h(u2t(ovo)) ) { + if ( c3__hear == u3h(u3t(ovo)) ) { c3_assert(0); } #endif } #endif - u2z(tox); + u3z(tox); } - u2z(ovo); -} - -/* u2_reck_poke(): insert and apply an input ovum (protected). -*/ -u2_noun -u2_reck_poke(u2_reck* rec_u, u2_noun ovo) -{ - return _reck_nock_poke(rec_u, ovo); -} - -/* u2_reck_sync(): poll and apply sync events (protected). -*/ -void -u2_reck_sync(u2_reck* rec_u) -{ -#if 0 - u2_reck_plow(rec_u, u2_sync_reck(rec_u)); -#endif -} - -/* u2_reck_boot(): boot the reck engine (unprotected). -*/ -void -u2_reck_boot(u2_reck* rec_u) -{ - u2_noun hoe; - - memset(rec_u, 0, sizeof *rec_u); - if ( 0 != (hoe = u2_cm_trap()) ) { - u2_cm_purge(); - - u2_lo_sway(2, u2_ckb_flop(u2k(u2t(hoe)))); - u2z(hoe); - - exit(1); - } - else { - u2_reck_cold(rec_u, u2_Host.kno_w); - u2_cm_done(); - - u2_cm_purge(); - } -} - -/* u2_reck_http_request(): hear http request on channel (unprotected). -*/ -void -u2_reck_http_request(u2_reck* rec_u, u2_bean sec, u2_noun pox, u2_noun req) -{ - // uL(fprintf(uH, "http: request\n")); - u2_reck_plan(rec_u, pox, u2nq(c3__this, sec, 0, req)); -} - -/* u2_reck_prick(): query the reck namespace (unprotected). -*/ -u2_noun -u2_reck_prick(u2_reck* rec_u, u2_noun hap) -{ - u2_noun hoe; - u2_noun que; - - if ( 0 != (hoe = u2_cm_trap()) ) { - u2_cm_purge(); - - u2_lo_sway(2, u2_ckb_flop(u2k(u2t(hoe)))); - u2z(hoe); - - return u2_nul; - } - else { - que = u2_reck_peek(rec_u, hap); - u2_cm_done(); - - u2_cm_purge(); - } - return que; -} - -/* u2_reck_plan(): queue ovum (external). -*/ -void -u2_reck_plan(u2_reck* rec_u, - u2_noun pax, - u2_noun fav) -{ - if ( u2_raty_lead == u2R->typ_e ) { - u2_noun egg = u2nc(pax, fav); - rec_u->roe = u2nc(u2nc(u2_nul, egg), rec_u->roe); - } - else { - c3_c* hed_c = u2_cr_string(u2h(u2t(pax))); - uL(fprintf(uH, "reck: dropping roe from %s\n", hed_c)); - free(hed_c); - u2z(pax); u2z(fav); - } -} - -/* u2_reck_plow(): queue multiple ova (external). -*/ -void -u2_reck_plow(u2_reck* rec_u, u2_noun ova) -{ - u2_noun ovi = ova; - - while ( u2_nul != ovi ) { - u2_noun ovo=u2h(ovi); - - u2_reck_plan(rec_u, u2k(u2h(ovo)), u2k(u2t(ovo))); - ovi = u2t(ovi); - } - u2z(ova); + u3z(ovo); } diff --git a/v/save.c b/v/save.c index 37c14ef56..f8f9aea1b 100644 --- a/v/save.c +++ b/v/save.c @@ -26,7 +26,7 @@ _save_sign_cb(uv_signal_t* sil_u, c3_i num_i) uL(fprintf(uH, "save: signal %d\n", num_i)); { switch ( num_i ) { - case SIGCHLD: u2_save_ef_chld(); break; + case SIGCHLD: u3_save_ef_chld(); break; } } } @@ -36,43 +36,43 @@ _save_sign_cb(uv_signal_t* sil_u, c3_i num_i) static void _save_time_cb(uv_timer_t* tim_u, c3_i sas_i) { - u2_save* sav_u = &u2_Host.sav_u; + u3_save* sav_u = &u3_Host.sav_u; if ( sav_u->pid_w ) { return; } - if ( u2A->ent_d > sav_u->ent_d ) { - // uL(fprintf(uH, "autosaving... ent_d %llu\n", u2A->ent_d)); + if ( u3A->ent_d > sav_u->ent_d ) { + // uL(fprintf(uH, "autosaving... ent_d %llu\n", u3A->ent_d)); - u2_cm_purge(); - // u2_lo_grab("save", u2_none); + u3_cm_purge(); + // u3_lo_grab("save", u3_none); #ifdef FORKPT c3_w pid_w; if ( 0 == (pid_w = fork()) ) { - u2_loom_save(u2A->ent_d); + u3_loom_save(u3A->ent_d); exit(0); } else { uL(fprintf(uH, "checkpoint: process %d\n", pid_w)); - sav_u->ent_d = u2A->ent_d; + sav_u->ent_d = u3A->ent_d; sav_u->pid_w = pid_w; } #else - u2_loom_save(u2A->ent_d); - sav_u->ent_d = u2A->ent_d; + u3_loom_save(u3A->ent_d); + sav_u->ent_d = u3A->ent_d; #endif } } -/* u2_save_ef_chld(): report save termination. +/* u3_save_ef_chld(): report save termination. */ void -u2_save_ef_chld(void) +u3_save_ef_chld(void) { - u2_save* sav_u = &u2_Host.sav_u; + u3_save* sav_u = &u3_Host.sav_u; c3_i loc_i; c3_w pid_w; @@ -89,33 +89,32 @@ u2_save_ef_chld(void) sav_u->pid_w = 0; } -/* u2_save_io_init(): initialize autosave. +/* u3_save_io_init(): initialize autosave. */ void -u2_save_io_init(void) +u3_save_io_init(void) { - u2_save* sav_u = &u2_Host.sav_u; + u3_save* sav_u = &u3_Host.sav_u; sav_u->ent_d = 0; sav_u->pid_w = 0; - uv_timer_init(u2L, &sav_u->tim_u); + uv_timer_init(u3L, &sav_u->tim_u); uv_timer_start(&sav_u->tim_u, _save_time_cb, 15000, 15000); uv_signal_start(&sav_u->sil_u, _save_sign_cb, SIGCHLD); } -/* u2_save_io_exit(): terminate save I/O. +/* u3_save_io_exit(): terminate save I/O. */ void -u2_save_io_exit(void) +u3_save_io_exit(void) { } -/* u2_save_io_poll(): poll kernel for save I/O. +/* u3_save_io_poll(): poll kernel for save I/O. */ void -u2_save_io_poll(void) +u3_save_io_poll(void) { } - diff --git a/v/sist.c b/v/sist.c index ba37a596b..938109025 100644 --- a/v/sist.c +++ b/v/sist.c @@ -22,25 +22,25 @@ #endif -/* u2_sist_pack(): write a blob to disk, transferring. +/* u3_sist_pack(): write a blob to disk, transferring. */ c3_d -u2_sist_pack(u2_reck* rec_u, c3_w tem_w, c3_w typ_w, c3_w* bob_w, c3_w len_w) +u3_sist_pack(c3_w tem_w, c3_w typ_w, c3_w* bob_w, c3_w len_w) { - u2_ulog* lug_u = &u2R->lug_u; + u3_ulog* lug_u = &u3Z->lug_u; c3_d tar_d; - u2_ular lar_u; + u3_ular lar_u; tar_d = lug_u->len_d + len_w; lar_u.tem_w = tem_w; lar_u.typ_w = typ_w; - lar_u.syn_w = u2_cr_mug((c3_w)tar_d); - lar_u.mug_w = u2_cr_mug_both(u2_cr_mug_words(bob_w, len_w), - u2_cr_mug_both(u2_cr_mug(lar_u.tem_w), - u2_cr_mug(lar_u.typ_w))); - lar_u.ent_d = rec_u->ent_d; - rec_u->ent_d++; + lar_u.syn_w = u3_cr_mug((c3_w)tar_d); + lar_u.mug_w = u3_cr_mug_both(u3_cr_mug_words(bob_w, len_w), + u3_cr_mug_both(u3_cr_mug(lar_u.tem_w), + u3_cr_mug(lar_u.typ_w))); + lar_u.ent_d = u3A->ent_d; + u3A->ent_d++; lar_u.len_w = len_w; if ( -1 == lseek64(lug_u->fid_i, 4ULL * tar_d, SEEK_SET) ) { @@ -79,32 +79,32 @@ u2_sist_pack(u2_reck* rec_u, c3_w tem_w, c3_w typ_w, c3_w* bob_w, c3_w len_w) fsync(lug_u->fid_i); // fsync is almost useless, F_FULLFSYNC too slow } - return rec_u->ent_d; + return u3A->ent_d; } -/* u2_sist_put(): moronic key-value store put. +/* u3_sist_put(): moronic key-value store put. */ void -u2_sist_put(const c3_c* key_c, const c3_y* val_y, size_t siz_i) +u3_sist_put(const c3_c* key_c, const c3_y* val_y, size_t siz_i) { c3_c ful_c[2048]; c3_i ret_i; c3_i fid_i; - ret_i = snprintf(ful_c, 2048, "%s/.urb/sis/_%s", u2_Host.cpu_c, key_c); + ret_i = snprintf(ful_c, 2048, "%s/.urb/sis/_%s", u3_Host.cpu_c, key_c); c3_assert(ret_i < 2048); if ( (fid_i = open(ful_c, O_CREAT | O_TRUNC | O_WRONLY, 0600)) < 0 ) { uL(fprintf(uH, "sist: could not put %s\n", key_c)); perror("open"); - u2_lo_bail(u2A); + u3_lo_bail(); } if ( (ret_i = write(fid_i, val_y, siz_i)) != siz_i ) { uL(fprintf(uH, "sist: could not write %s\n", key_c)); if ( ret_i < 0 ) { perror("write"); } - u2_lo_bail(u2A); + u3_lo_bail(); } ret_i = c3_sync(fid_i); if ( ret_i < 0 ) { @@ -114,16 +114,16 @@ u2_sist_put(const c3_c* key_c, const c3_y* val_y, size_t siz_i) c3_assert(0 == ret_i); } -/* u2_sist_has(): moronic key-value store existence check. +/* u3_sist_has(): moronic key-value store existence check. */ ssize_t -u2_sist_has(const c3_c* key_c) +u3_sist_has(const c3_c* key_c) { c3_c ful_c[2048]; c3_i ret_i; struct stat sat_u; - ret_i = snprintf(ful_c, 2048, "%s/.urb/sis/_%s", u2_Host.cpu_c, key_c); + ret_i = snprintf(ful_c, 2048, "%s/.urb/sis/_%s", u3_Host.cpu_c, key_c); c3_assert(ret_i < 2048); if ( (ret_i = stat(ful_c, &sat_u)) < 0 ) { @@ -133,7 +133,7 @@ u2_sist_has(const c3_c* key_c) else { uL(fprintf(uH, "sist: could not stat %s\n", key_c)); perror("stat"); - u2_lo_bail(u2A); + u3_lo_bail(); } } else { @@ -142,49 +142,49 @@ u2_sist_has(const c3_c* key_c) c3_assert(!"not reached"); } -/* u2_sist_get(): moronic key-value store get. +/* u3_sist_get(): moronic key-value store get. */ void -u2_sist_get(const c3_c* key_c, c3_y* val_y) +u3_sist_get(const c3_c* key_c, c3_y* val_y) { c3_c ful_c[2048]; c3_i ret_i; c3_i fid_i; struct stat sat_u; - ret_i = snprintf(ful_c, 2048, "%s/.urb/sis/_%s", u2_Host.cpu_c, key_c); + ret_i = snprintf(ful_c, 2048, "%s/.urb/sis/_%s", u3_Host.cpu_c, key_c); c3_assert(ret_i < 2048); if ( (fid_i = open(ful_c, O_RDONLY)) < 0 ) { uL(fprintf(uH, "sist: could not get %s\n", key_c)); perror("open"); - u2_lo_bail(u2A); + u3_lo_bail(); } if ( (ret_i = fstat(fid_i, &sat_u)) < 0 ) { uL(fprintf(uH, "sist: could not stat %s\n", key_c)); perror("fstat"); - u2_lo_bail(u2A); + u3_lo_bail(); } if ( (ret_i = read(fid_i, val_y, sat_u.st_size)) != sat_u.st_size ) { uL(fprintf(uH, "sist: could not read %s\n", key_c)); if ( ret_i < 0 ) { perror("read"); } - u2_lo_bail(u2A); + u3_lo_bail(); } ret_i = close(fid_i); c3_assert(0 == ret_i); } -/* u2_sist_nil(): moronic key-value store rm. +/* u3_sist_nil(): moronic key-value store rm. */ void -u2_sist_nil(const c3_c* key_c) +u3_sist_nil(const c3_c* key_c) { c3_c ful_c[2048]; c3_i ret_i; - ret_i = snprintf(ful_c, 2048, "%s/.urb/sis/_%s", u2_Host.cpu_c, key_c); + ret_i = snprintf(ful_c, 2048, "%s/.urb/sis/_%s", u3_Host.cpu_c, key_c); c3_assert(ret_i < 2048); if ( (ret_i = unlink(ful_c)) < 0 ) { @@ -194,7 +194,7 @@ u2_sist_nil(const c3_c* key_c) else { uL(fprintf(uH, "sist: could not unlink %s\n", key_c)); perror("unlink"); - u2_lo_bail(u2A); + u3_lo_bail(); } } } @@ -202,19 +202,19 @@ u2_sist_nil(const c3_c* key_c) /* _sist_suck(): past failure. */ static void -_sist_suck(u2_reck* rec_u, u2_noun ovo, u2_noun gon) +_sist_suck(u3_noun ovo, u3_noun gon) { uL(fprintf(uH, "sing: ovum failed!\n")); { - c3_c* hed_c = u2_cr_string(u2h(u2t(ovo))); + c3_c* hed_c = u3_cr_string(u3h(u3t(ovo))); uL(fprintf(uH, "fail %s\n", hed_c)); free(hed_c); } - u2_lo_punt(2, u2_ckb_flop(u2k(u2t(gon)))); - u2_loom_exit(); - u2_lo_exit(); + u3_lo_punt(2, u3_ckb_flop(u3k(u3t(gon)))); + // u3_loom_exit(); + u3_lo_exit(); exit(1); } @@ -222,42 +222,42 @@ _sist_suck(u2_reck* rec_u, u2_noun ovo, u2_noun gon) /* _sist_sing(): replay ovum from the past, time already set. */ static void -_sist_sing(u2_reck* rec_u, u2_noun ovo) +_sist_sing(u3_noun ovo) { - u2_noun gon = u2_lo_soft(rec_u, 0, u2_reck_poke, u2k(ovo)); + u3_noun gon = u3_cm_soft(0, u3_cv_poke, u3k(ovo)); - if ( u2_blip != u2h(gon) ) { - _sist_suck(rec_u, ovo, gon); + if ( u3_blip != u3h(gon) ) { + _sist_suck(ovo, gon); } else { - u2_noun vir = u2k(u2h(u2t(gon))); - u2_noun cor = u2k(u2t(u2t(gon))); - u2_noun nug; + u3_noun vir = u3k(u3h(u3t(gon))); + u3_noun cor = u3k(u3t(u3t(gon))); + u3_noun nug; - u2z(gon); - nug = u2_reck_nick(rec_u, vir, cor); + u3z(gon); + nug = u3_cv_nick(vir, cor); - if ( u2_blip != u2h(nug) ) { - _sist_suck(rec_u, ovo, nug); + if ( u3_blip != u3h(nug) ) { + _sist_suck(ovo, nug); } else { - vir = u2h(u2t(nug)); - cor = u2k(u2t(u2t(nug))); + vir = u3h(u3t(nug)); + cor = u3k(u3t(u3t(nug))); - while ( u2_nul != vir ) { - u2_noun fex = u2h(vir); - u2_noun fav = u2t(fex); + while ( u3_nul != vir ) { + u3_noun fex = u3h(vir); + u3_noun fav = u3t(fex); - if ( (c3__init == u2h(fav)) || (c3__inuk == u2h(fav)) ) { - rec_u->own = u2nc(u2k(u2t(fav)), rec_u->own); + if ( (c3__init == u3h(fav)) || (c3__inuk == u3h(fav)) ) { + u3A->own = u3nc(u3k(u3t(fav)), u3A->own); } - vir = u2t(vir); + vir = u3t(vir); } - u2z(nug); - u2z(rec_u->roc); - rec_u->roc = cor; + u3z(nug); + u3z(u3A->roc); + u3A->roc = cor; } - u2z(ovo); + u3z(ovo); } } @@ -265,34 +265,34 @@ _sist_sing(u2_reck* rec_u, u2_noun ovo) /* _sist_home(): create ship directory. */ static void -_sist_home(u2_reck* rec_u) +_sist_home() { c3_c ful_c[2048]; // Create subdirectories. // { - mkdir(u2_Host.cpu_c, 0700); + mkdir(u3_Host.cpu_c, 0700); - snprintf(ful_c, 2048, "%s/.urb", u2_Host.cpu_c); + snprintf(ful_c, 2048, "%s/.urb", u3_Host.cpu_c); mkdir(ful_c, 0700); - snprintf(ful_c, 2048, "%s/.urb/get", u2_Host.cpu_c); + snprintf(ful_c, 2048, "%s/.urb/get", u3_Host.cpu_c); if ( 0 != mkdir(ful_c, 0700) ) { perror(ful_c); - u2_lo_bail(rec_u); + u3_lo_bail(); } - snprintf(ful_c, 2048, "%s/.urb/put", u2_Host.cpu_c); + snprintf(ful_c, 2048, "%s/.urb/put", u3_Host.cpu_c); if ( 0 != mkdir(ful_c, 0700) ) { perror(ful_c); - u2_lo_bail(rec_u); + u3_lo_bail(); } - snprintf(ful_c, 2048, "%s/.urb/sis", u2_Host.cpu_c); + snprintf(ful_c, 2048, "%s/.urb/sis", u3_Host.cpu_c); if ( 0 != mkdir(ful_c, 0700) ) { perror(ful_c); - u2_lo_bail(rec_u); + u3_lo_bail(); } } @@ -300,43 +300,43 @@ _sist_home(u2_reck* rec_u) // { snprintf(ful_c, 2048, "cp %s/urbit.pill %s/.urb", - U2_LIB, u2_Host.cpu_c); + U2_LIB, u3_Host.cpu_c); if ( 0 != system(ful_c) ) { uL(fprintf(uH, "could not %s\n", ful_c)); - u2_lo_bail(rec_u); + u3_lo_bail(); } } // Copy zod files, if we're generating a carrier. // - if ( u2_Host.ops_u.imp_c ) { + if ( u3_Host.ops_u.imp_c ) { snprintf(ful_c, 2048, "cp -r %s/zod %s/%s", - U2_LIB, u2_Host.cpu_c, u2_Host.ops_u.imp_c+1); + U2_LIB, u3_Host.cpu_c, u3_Host.ops_u.imp_c+1); if ( 0 != system(ful_c) ) { uL(fprintf(uH, "could not %s\n", ful_c)); - u2_lo_bail(rec_u); + u3_lo_bail(); } } } /* _sist_cask(): ask for a passcode. */ -static u2_noun -_sist_cask(u2_reck* rec_u, c3_c* dir_c, u2_bean nun) +static u3_noun +_sist_cask(c3_c* dir_c, u3_bean nun) { c3_c paw_c[60]; - u2_noun key; + u3_noun key; uH; while ( 1 ) { - printf("passcode for %s%s? ~", dir_c, (u2_yes == nun) ? " [none]" : ""); + printf("passcode for %s%s? ~", dir_c, (u3_yes == nun) ? " [none]" : ""); paw_c[0] = 0; c3_fpurge(stdin); fgets(paw_c, 59, stdin); if ( '\n' == paw_c[0] ) { - if ( u2_yes == nun ) { + if ( u3_yes == nun ) { key = 0; break; } else { @@ -345,23 +345,23 @@ _sist_cask(u2_reck* rec_u, c3_c* dir_c, u2_bean nun) } else { c3_c* say_c = c3_malloc(strlen(paw_c) + 2); - u2_noun say; + u3_noun say; say_c[0] = '~'; say_c[1] = 0; strncat(say_c, paw_c, strlen(paw_c) - 1); - say = u2_do("slay", u2_ci_string(say_c)); - if ( (u2_nul == say) || - (u2_blip != u2h(u2t(say))) || - ('p' != u2h(u2t(u2t(say)))) ) + say = u3_do("slay", u3_ci_string(say_c)); + if ( (u3_nul == say) || + (u3_blip != u3h(u3t(say))) || + ('p' != u3h(u3t(u3t(say)))) ) { printf("invalid passcode\n"); continue; } - key = u2k(u2t(u2t(u2t(say)))); + key = u3k(u3t(u3t(u3t(say)))); - u2z(say); + u3z(say); break; } } @@ -371,11 +371,11 @@ _sist_cask(u2_reck* rec_u, c3_c* dir_c, u2_bean nun) /* _sist_text(): ask for a name string. */ -static u2_noun -_sist_text(u2_reck* rec_u, c3_c* pom_c) +static u3_noun +_sist_text(c3_c* pom_c) { c3_c paw_c[60]; - u2_noun say; + u3_noun say; uH; while ( 1 ) { @@ -394,7 +394,7 @@ _sist_text(u2_reck* rec_u, c3_c* pom_c) if ( paw_c[len_w - 1] == '\n' ) { paw_c[len_w-1] = 0; } - say = u2_ci_string(paw_c); + say = u3_ci_string(paw_c); break; } } @@ -405,10 +405,10 @@ _sist_text(u2_reck* rec_u, c3_c* pom_c) #if 0 /* _sist_bask(): ask a yes or no question. */ -static u2_bean -_sist_bask(c3_c* pop_c, u2_bean may) +static u3_bean +_sist_bask(c3_c* pop_c, u3_bean may) { - u2_bean yam; + u3_bean yam; uH; while ( 1 ) { @@ -423,7 +423,7 @@ _sist_bask(c3_c* pop_c, u2_bean may) if ( (ans_c[0] != 'y') && (ans_c[0] != 'n') ) { continue; } else { - yam = (ans_c[0] != 'n') ? u2_yes : u2_no; + yam = (ans_c[0] != 'n') ? u3_yes : u3_no; break; } } @@ -435,7 +435,7 @@ _sist_bask(c3_c* pop_c, u2_bean may) /* _sist_rand(): fill a 256-bit (8-word) buffer. */ static void -_sist_rand(u2_reck* rec_u, c3_w* rad_w) +_sist_rand(c3_w* rad_w) { c3_i fid_i = open(DEVRANDOM, O_RDONLY); @@ -448,14 +448,14 @@ _sist_rand(u2_reck* rec_u, c3_w* rad_w) /* _sist_fast(): offer to save passcode by mug in home directory. */ static void -_sist_fast(u2_reck* rec_u, u2_noun pas, c3_l key_l) +_sist_fast(u3_noun pas, c3_l key_l) { c3_c ful_c[2048]; - c3_c* hom_c = u2_Host.cpu_c; - u2_noun gum = u2_dc("scot", 'p', key_l); - c3_c* gum_c = u2_cr_string(gum); - u2_noun yek = u2_dc("scot", 'p', pas); - c3_c* yek_c = u2_cr_string(yek); + c3_c* hom_c = u3_Host.cpu_c; + u3_noun gum = u3_dc("scot", 'p', key_l); + c3_c* gum_c = u3_cr_string(gum); + u3_noun yek = u3_dc("scot", 'p', pas); + c3_c* yek_c = u3_cr_string(yek); printf("saving passcode in %s/.urb/code.%s\r\n", hom_c, gum_c); printf("(for real security, write it down and delete the file...)\r\n"); @@ -465,72 +465,72 @@ _sist_fast(u2_reck* rec_u, u2_noun pas, c3_l key_l) snprintf(ful_c, 2048, "%s/.urb/code.%s", hom_c, gum_c); if ( (fid_i = open(ful_c, O_CREAT | O_TRUNC | O_WRONLY, 0600)) < 0 ) { uL(fprintf(uH, "fast: could not save %s\n", ful_c)); - u2_lo_bail(rec_u); + u3_lo_bail(); } write(fid_i, yek_c, strlen(yek_c)); close(fid_i); } free(gum_c); - u2z(gum); + u3z(gum); free(yek_c); - u2z(yek); + u3z(yek); } /* _sist_staf(): try to load passcode by mug from home directory. */ -static u2_noun -_sist_staf(u2_reck* rec_u, c3_l key_l) +static u3_noun +_sist_staf(c3_l key_l) { c3_c ful_c[2048]; - c3_c* hom_c = u2_Host.cpu_c; - u2_noun gum = u2_dc("scot", 'p', key_l); - c3_c* gum_c = u2_cr_string(gum); - u2_noun txt; + c3_c* hom_c = u3_Host.cpu_c; + u3_noun gum = u3_dc("scot", 'p', key_l); + c3_c* gum_c = u3_cr_string(gum); + u3_noun txt; snprintf(ful_c, 2048, "%s/.urb/code.%s", hom_c, gum_c); free(gum_c); - u2z(gum); - txt = u2_walk_safe(ful_c); + u3z(gum); + txt = u3_walk_safe(ful_c); if ( 0 == txt ) { uL(fprintf(uH, "staf: no passcode %s\n", ful_c)); return 0; } else { - // c3_c* txt_c = u2_cr_string(txt); - u2_noun say = u2_do("slay", txt); - u2_noun pas; + // c3_c* txt_c = u3_cr_string(txt); + u3_noun say = u3_do("slay", txt); + u3_noun pas; - if ( (u2_nul == say) || - (u2_blip != u2h(u2t(say))) || - ('p' != u2h(u2t(u2t(say)))) ) + if ( (u3_nul == say) || + (u3_blip != u3h(u3t(say))) || + ('p' != u3h(u3t(u3t(say)))) ) { uL(fprintf(uH, "staf: %s is corrupt\n", ful_c)); - u2z(say); + u3z(say); return 0; } uL(fprintf(uH, "loaded passcode from %s\n", ful_c)); - pas = u2k(u2t(u2t(u2t(say)))); + pas = u3k(u3t(u3t(u3t(say)))); - u2z(say); + u3z(say); return pas; } } /* _sist_fatt(): stretch a 64-bit passcode to make a 128-bit key. */ -static u2_noun -_sist_fatt(c3_l sal_l, u2_noun pas) +static u3_noun +_sist_fatt(c3_l sal_l, u3_noun pas) { c3_w i_w; - u2_noun key = pas; + u3_noun key = pas; // XX use scrypt() - this is a stupid iterated hash // for ( i_w = 0; i_w < 32768; i_w++ ) { - key = u2_dc("shaf", sal_l, key); + key = u3_dc("shaf", sal_l, key); } return key; } @@ -538,7 +538,7 @@ _sist_fatt(c3_l sal_l, u2_noun pas) /* _sist_zest(): create a new, empty record. */ static void -_sist_zest(u2_reck* rec_u) +_sist_zest() { struct stat buf_b; c3_i fid_i; @@ -547,7 +547,7 @@ _sist_zest(u2_reck* rec_u) // Create the ship directory. // - _sist_home(rec_u); + _sist_home(); // Create the record file. { @@ -555,21 +555,21 @@ _sist_zest(u2_reck* rec_u) #ifdef O_DSYNC pig_i |= O_DSYNC; #endif - snprintf(ful_c, 2048, "%s/.urb/egz.hope", u2_Host.cpu_c); + snprintf(ful_c, 2048, "%s/.urb/egz.hope", u3_Host.cpu_c); if ( ((fid_i = open(ful_c, pig_i, 0600)) < 0) || (fstat(fid_i, &buf_b) < 0) ) { uL(fprintf(uH, "can't create record (%s)\n", ful_c)); - u2_lo_bail(rec_u); + u3_lo_bail(); } #ifdef F_NOCACHE if ( -1 == fcntl(fid_i, F_NOCACHE, 1) ) { uL(fprintf(uH, "zest: can't uncache %s: %s\n", ful_c, strerror(errno))); - u2_lo_bail(rec_u); + u3_lo_bail(); } #endif - u2R->lug_u.fid_i = fid_i; + u3Z->lug_u.fid_i = fid_i; } // Generate a 31-bit salt. @@ -577,7 +577,7 @@ _sist_zest(u2_reck* rec_u) { c3_w rad_w[8]; - _sist_rand(rec_u, rad_w); + _sist_rand(rad_w); sal_l = (0x7fffffff & rad_w[0]); } @@ -585,69 +585,69 @@ _sist_zest(u2_reck* rec_u) // { c3_w rad_w[8]; - u2_noun pas; + u3_noun pas; - _sist_rand(rec_u, rad_w); - pas = u2_ci_words(2, rad_w); + _sist_rand(rad_w); + pas = u3_ci_words(2, rad_w); - rec_u->key = _sist_fatt(sal_l, u2k(pas)); - _sist_fast(rec_u, pas, u2_mug(rec_u->key)); + u3A->key = _sist_fatt(sal_l, u3k(pas)); + _sist_fast(pas, u3_cr_mug(u3A->key)); } // Write the header. { - u2_uled led_u; + u3_uled led_u; - led_u.mag_l = u2_mug('g'); - led_u.kno_w = rec_u->kno_w; + led_u.mag_l = u3_cr_mug('g'); + led_u.kno_w = 164; - if ( 0 == rec_u->key ) { + if ( 0 == u3A->key ) { led_u.key_l = 0; } else { - led_u.key_l = u2_mug(rec_u->key); + led_u.key_l = u3_cr_mug(u3A->key); c3_assert(!(led_u.key_l >> 31)); } led_u.sal_l = sal_l; - led_u.sev_l = rec_u->sev_l; + led_u.sev_l = u3A->sev_l; led_u.tno_l = 1; if ( sizeof(led_u) != write(fid_i, &led_u, sizeof(led_u)) ) { uL(fprintf(uH, "can't write record (%s)\n", ful_c)); - u2_lo_bail(rec_u); + u3_lo_bail(); } - u2R->lug_u.len_d = c3_wiseof(led_u); + u3Z->lug_u.len_d = c3_wiseof(led_u); } // Work through the boot events. - u2_raft_work(rec_u); + u3_raft_work(); } /* _sist_make(): boot from scratch. */ static void -_sist_make(u2_reck* rec_u, u2_noun fav) +_sist_make(u3_noun fav) { // Initialize ames - u2_ames_ef_bake(); + u3_ames_ef_bake(); // Authenticate and initialize terminal. // - u2_term_ef_bake(fav); + u3_term_ef_bake(fav); // Create the ship directory. // - _sist_zest(rec_u); + _sist_zest(); } /* _sist_rest_nuu(): upgrade log from previous format. */ static void -_sist_rest_nuu(u2_ulog* lug_u, u2_uled led_u, c3_c* old_c) +_sist_rest_nuu(u3_ulog* lug_u, u3_uled led_u, c3_c* old_c) { c3_c nuu_c[2048]; - u2_noun roe = u2_nul; + u3_noun roe = u3_nul; c3_i fid_i = lug_u->fid_i; c3_i fud_i; c3_i ret_i; @@ -655,36 +655,36 @@ _sist_rest_nuu(u2_ulog* lug_u, u2_uled led_u, c3_c* old_c) uL(fprintf(uH, "rest: converting log from prior format\n")); - c3_assert(led_u.mag_l == u2_mug('f')); + c3_assert(led_u.mag_l == u3_cr_mug('f')); if ( -1 == lseek64(fid_i, 4ULL * end_d, SEEK_SET) ) { uL(fprintf(uH, "rest_nuu failed (a)\n")); perror("lseek64"); - u2_lo_bail(u2A); + u3_lo_bail(); } - while ( end_d != c3_wiseof(u2_uled) ) { + while ( end_d != c3_wiseof(u3_uled) ) { c3_d tar_d; - u2_olar lar_u; + u3_olar lar_u; c3_w* img_w; - u2_noun ron; + u3_noun ron; - tar_d = (end_d - (c3_d)c3_wiseof(u2_olar)); + tar_d = (end_d - (c3_d)c3_wiseof(u3_olar)); if ( -1 == lseek64(fid_i, 4ULL * tar_d, SEEK_SET) ) { uL(fprintf(uH, "rest_nuu failed (b)\n")); perror("lseek64"); - u2_lo_bail(u2A); + u3_lo_bail(); } - if ( sizeof(u2_olar) != read(fid_i, &lar_u, sizeof(u2_olar)) ) { + if ( sizeof(u3_olar) != read(fid_i, &lar_u, sizeof(u3_olar)) ) { uL(fprintf(uH, "rest_nuu failed (c)\n")); perror("read"); - u2_lo_bail(u2A); + u3_lo_bail(); } - if ( lar_u.syn_w != u2_mug((c3_w)tar_d) ) { + if ( lar_u.syn_w != u3_cr_mug((c3_w)tar_d) ) { uL(fprintf(uH, "rest_nuu failed (d)\n")); - u2_lo_bail(u2A); + u3_lo_bail(); } img_w = c3_malloc(4 * lar_u.len_w); @@ -693,97 +693,97 @@ _sist_rest_nuu(u2_ulog* lug_u, u2_uled led_u, c3_c* old_c) if ( -1 == lseek64(fid_i, 4ULL * end_d, SEEK_SET) ) { uL(fprintf(uH, "rest_nuu failed (e)\n")); perror("lseek64"); - u2_lo_bail(u2A); + u3_lo_bail(); } if ( (4 * lar_u.len_w) != read(fid_i, img_w, (4 * lar_u.len_w)) ) { uL(fprintf(uH, "rest_nuu failed (f)\n")); perror("read"); - u2_lo_bail(u2A); + u3_lo_bail(); } - ron = u2_ci_words(lar_u.len_w, img_w); + ron = u3_ci_words(lar_u.len_w, img_w); free(img_w); - if ( lar_u.mug_w != u2_cr_mug(ron) ) { + if ( lar_u.mug_w != u3_cr_mug(ron) ) { uL(fprintf(uH, "rest_nuu failed (g)\n")); - u2_lo_bail(u2A); + u3_lo_bail(); } - roe = u2nc(ron, roe); + roe = u3nc(ron, roe); } if ( 0 != close(fid_i) ) { uL(fprintf(uH, "rest: could not close\n")); perror("close"); - u2_lo_bail(u2A); + u3_lo_bail(); } - ret_i = snprintf(nuu_c, 2048, "%s/.urb/ham.hope", u2_Host.cpu_c); + ret_i = snprintf(nuu_c, 2048, "%s/.urb/ham.hope", u3_Host.cpu_c); c3_assert(ret_i < 2048); if ( (fud_i = open(nuu_c, O_CREAT | O_TRUNC | O_RDWR, 0600)) < 0 ) { uL(fprintf(uH, "rest: can't open record (%s)\n", nuu_c)); perror("open"); - u2_lo_bail(u2A); + u3_lo_bail(); } - led_u.mag_l = u2_mug('g'); + led_u.mag_l = u3_cr_mug('g'); if ( (sizeof(led_u) != write(fud_i, &led_u, sizeof(led_u))) ) { uL(fprintf(uH, "rest: can't write header\n")); perror("write"); - u2_lo_bail(u2A); + u3_lo_bail(); } { c3_d ent_d = 1; - c3_assert(end_d == c3_wiseof(u2_uled)); - while ( u2_nul != roe ) { - u2_noun ovo = u2k(u2h(roe)); - u2_noun nex = u2k(u2t(roe)); - u2_ular lar_u; + c3_assert(end_d == c3_wiseof(u3_uled)); + while ( u3_nul != roe ) { + u3_noun ovo = u3k(u3h(roe)); + u3_noun nex = u3k(u3t(roe)); + u3_ular lar_u; c3_w* img_w; c3_d tar_d; - lar_u.len_w = u2_cr_met(5, ovo); + lar_u.len_w = u3_cr_met(5, ovo); tar_d = end_d + lar_u.len_w; - lar_u.syn_w = u2_cr_mug(tar_d); + lar_u.syn_w = u3_cr_mug(tar_d); lar_u.ent_d = ent_d; lar_u.tem_w = 0; lar_u.typ_w = c3__ov; - lar_u.mug_w = u2_cr_mug_both(u2_cr_mug(ovo), - u2_cr_mug_both(u2_cr_mug(0), - u2_cr_mug(c3__ov))); + lar_u.mug_w = u3_cr_mug_both(u3_cr_mug(ovo), + u3_cr_mug_both(u3_cr_mug(0), + u3_cr_mug(c3__ov))); img_w = c3_malloc(lar_u.len_w << 2); - u2_cr_words(0, lar_u.len_w, img_w, ovo); - u2z(ovo); + u3_cr_words(0, lar_u.len_w, img_w, ovo); + u3z(ovo); if ( (lar_u.len_w << 2) != write(fud_i, img_w, lar_u.len_w << 2) ) { uL(fprintf(uH, "rest_nuu failed (h)\n")); perror("write"); - u2_lo_bail(u2A); + u3_lo_bail(); } - if ( sizeof(u2_ular) != write(fud_i, &lar_u, sizeof(u2_ular)) ) { + if ( sizeof(u3_ular) != write(fud_i, &lar_u, sizeof(u3_ular)) ) { uL(fprintf(uH, "rest_nuu failed (i)\n")); perror("write"); - u2_lo_bail(u2A); + u3_lo_bail(); } ent_d++; - end_d = tar_d + c3_wiseof(u2_ular); - u2z(roe); roe = nex; + end_d = tar_d + c3_wiseof(u3_ular); + u3z(roe); roe = nex; } } if ( 0 != rename(nuu_c, old_c) ) { uL(fprintf(uH, "rest_nuu failed (k)\n")); perror("rename"); - u2_lo_bail(u2A); + u3_lo_bail(); } - if ( -1 == lseek64(fud_i, sizeof(u2_uled), SEEK_SET) ) { + if ( -1 == lseek64(fud_i, sizeof(u3_uled), SEEK_SET) ) { uL(fprintf(uH, "rest_nuu failed (l)\n")); perror("lseek64"); - u2_lo_bail(u2A); + u3_lo_bail(); } lug_u->fid_i = fud_i; lug_u->len_d = end_d; @@ -792,27 +792,27 @@ _sist_rest_nuu(u2_ulog* lug_u, u2_uled led_u, c3_c* old_c) /* _sist_rest(): restore from record, or exit. */ static void -_sist_rest(u2_reck* rec_u) +_sist_rest() { struct stat buf_b; c3_i fid_i; c3_c ful_c[2048]; - c3_d old_d = rec_u->ent_d; + c3_d old_d = u3A->ent_d; c3_d las_d = 0; - u2_noun roe = u2_nul; - u2_noun sev_l, tno_l, key_l, sal_l; - u2_bean ohh = u2_no; + u3_noun roe = u3_nul; + u3_noun sev_l, tno_l, key_l, sal_l; + u3_bean ohh = u3_no; - if ( 0 != rec_u->ent_d ) { - u2_noun ent; + if ( 0 != u3A->ent_d ) { + u3_noun ent; c3_c* ent_c; - ent = u2_ci_chubs(1, &rec_u->ent_d); - ent = u2_dc("scot", c3__ud, ent); - ent_c = u2_cr_string(ent); + ent = u3_ci_chubs(1, &u3A->ent_d); + ent = u3_dc("scot", c3__ud, ent); + ent_c = u3_cr_string(ent); uL(fprintf(uH, "rest: checkpoint to event %s\n", ent_c)); free(ent_c); - u2z(ent); + u3z(ent); } // Open the fscking file. Does it even exist? @@ -821,49 +821,49 @@ _sist_rest(u2_reck* rec_u) #ifdef O_DSYNC pig_i |= O_DSYNC; #endif - snprintf(ful_c, 2048, "%s/.urb/egz.hope", u2_Host.cpu_c); + snprintf(ful_c, 2048, "%s/.urb/egz.hope", u3_Host.cpu_c); if ( ((fid_i = open(ful_c, pig_i)) < 0) || (fstat(fid_i, &buf_b) < 0) ) { uL(fprintf(uH, "rest: can't open record (%s)\n", ful_c)); - u2_lo_bail(rec_u); + u3_lo_bail(); return; } #ifdef F_NOCACHE if ( -1 == fcntl(fid_i, F_NOCACHE, 1) ) { uL(fprintf(uH, "rest: can't uncache %s: %s\n", ful_c, strerror(errno))); - u2_lo_bail(rec_u); + u3_lo_bail(); return; } #endif - u2R->lug_u.fid_i = fid_i; - u2R->lug_u.len_d = ((buf_b.st_size + 3ULL) >> 2ULL); + u3Z->lug_u.fid_i = fid_i; + u3Z->lug_u.len_d = ((buf_b.st_size + 3ULL) >> 2ULL); } // Check the fscking header. It's probably corrupt. { - u2_uled led_u; + u3_uled led_u; if ( sizeof(led_u) != read(fid_i, &led_u, sizeof(led_u)) ) { uL(fprintf(uH, "record (%s) is corrupt (a)\n", ful_c)); - u2_lo_bail(rec_u); + u3_lo_bail(); } - if ( u2_mug('f') == led_u.mag_l ) { - _sist_rest_nuu(&u2R->lug_u, led_u, ful_c); - fid_i = u2R->lug_u.fid_i; + if ( u3_cr_mug('f') == led_u.mag_l ) { + _sist_rest_nuu(&u3Z->lug_u, led_u, ful_c); + fid_i = u3Z->lug_u.fid_i; } - else if (u2_mug('g') != led_u.mag_l ) { + else if (u3_cr_mug('g') != led_u.mag_l ) { uL(fprintf(uH, "record (%s) is obsolete (or corrupt)\n", ful_c)); - u2_lo_bail(rec_u); + u3_lo_bail(); } - if ( led_u.kno_w != rec_u->kno_w ) { + if ( led_u.kno_w != 164 ) { // XX perhaps we should actually do something here // uL(fprintf(uH, "rest: (not) translating events (old %d, now %d)\n", led_u.kno_w, - rec_u->kno_w)); + 164)); } sev_l = led_u.sev_l; sal_l = led_u.sal_l; @@ -871,38 +871,38 @@ _sist_rest(u2_reck* rec_u) tno_l = led_u.tno_l; { - u2_noun old = u2_dc("scot", c3__uv, sev_l); - u2_noun nuu = u2_dc("scot", c3__uv, rec_u->sev_l); - c3_c* old_c = u2_cr_string(old); - c3_c* nuu_c = u2_cr_string(nuu); + u3_noun old = u3_dc("scot", c3__uv, sev_l); + u3_noun nuu = u3_dc("scot", c3__uv, u3A->sev_l); + c3_c* old_c = u3_cr_string(old); + c3_c* nuu_c = u3_cr_string(nuu); uL(fprintf(uH, "rest: old %s, new %s\n", old_c, nuu_c)); free(old_c); free(nuu_c); - u2z(old); u2z(nuu); + u3z(old); u3z(nuu); } - c3_assert(sev_l != rec_u->sev_l); // 1 in 2 billion, just retry + c3_assert(sev_l != u3A->sev_l); // 1 in 2 billion, just retry } // Oh, and let's hope you didn't forget the fscking passcode. { if ( 0 != key_l ) { - u2_noun pas = _sist_staf(rec_u, key_l); - u2_noun key; + u3_noun pas = _sist_staf(key_l); + u3_noun key; while ( 1 ) { - pas = pas ? pas : _sist_cask(rec_u, u2_Host.cpu_c, u2_no); + pas = pas ? pas : _sist_cask(u3_Host.cpu_c, u3_no); key = _sist_fatt(sal_l, pas); - if ( u2_mug(key) != key_l ) { + if ( u3_cr_mug(key) != key_l ) { uL(fprintf(uH, "incorrect passcode\n")); - u2z(key); + u3z(key); pas = 0; } else { - u2z(rec_u->key); - rec_u->key = key; + u3z(u3A->key); + u3A->key = key; break; } } @@ -913,51 +913,51 @@ _sist_rest(u2_reck* rec_u) { c3_d ent_d; c3_d end_d; - u2_bean rup = u2_no; + u3_bean rup = u3_no; - end_d = u2R->lug_u.len_d; + end_d = u3Z->lug_u.len_d; ent_d = 0; if ( -1 == lseek64(fid_i, 4ULL * end_d, SEEK_SET) ) { fprintf(stderr, "end_d %llu\n", end_d); perror("lseek"); uL(fprintf(uH, "record (%s) is corrupt (c)\n", ful_c)); - u2_lo_bail(rec_u); + u3_lo_bail(); } - while ( end_d != c3_wiseof(u2_uled) ) { - c3_d tar_d = (end_d - (c3_d)c3_wiseof(u2_ular)); - u2_ular lar_u; + while ( end_d != c3_wiseof(u3_uled) ) { + c3_d tar_d = (end_d - (c3_d)c3_wiseof(u3_ular)); + u3_ular lar_u; c3_w* img_w; - u2_noun ron; + u3_noun ron; // uL(fprintf(uH, "rest: reading event at %llx\n", end_d)); if ( -1 == lseek64(fid_i, 4ULL * tar_d, SEEK_SET) ) { uL(fprintf(uH, "record (%s) is corrupt (d)\n", ful_c)); - u2_lo_bail(rec_u); + u3_lo_bail(); } - if ( sizeof(u2_ular) != read(fid_i, &lar_u, sizeof(u2_ular)) ) { + if ( sizeof(u3_ular) != read(fid_i, &lar_u, sizeof(u3_ular)) ) { uL(fprintf(uH, "record (%s) is corrupt (e)\n", ful_c)); - u2_lo_bail(rec_u); + u3_lo_bail(); } - if ( lar_u.syn_w != u2_mug((c3_w)tar_d) ) { - if ( u2_no == rup ) { + if ( lar_u.syn_w != u3_cr_mug((c3_w)tar_d) ) { + if ( u3_no == rup ) { uL(fprintf(uH, "corruption detected; attempting to fix\n")); - rup = u2_yes; + rup = u3_yes; } - uL(fprintf(uH, "lar:%x mug:%x\n", lar_u.syn_w, u2_mug((c3_w)tar_d))); - end_d--; u2R->lug_u.len_d--; + uL(fprintf(uH, "lar:%x mug:%x\n", lar_u.syn_w, u3_cr_mug((c3_w)tar_d))); + end_d--; u3Z->lug_u.len_d--; continue; } - else if ( u2_yes == rup ) { + else if ( u3_yes == rup ) { uL(fprintf(uH, "matched at %x\n", lar_u.syn_w)); - rup = u2_no; + rup = u3_no; } if ( lar_u.ent_d == 0 ) { - ohh = u2_yes; + ohh = u3_yes; } #if 0 @@ -968,14 +968,14 @@ _sist_rest(u2_reck* rec_u) lar_u.len_w, lar_u.mug_w)); #endif - if ( end_d == u2R->lug_u.len_d ) { + if ( end_d == u3Z->lug_u.len_d ) { ent_d = las_d = lar_u.ent_d; } else { if ( lar_u.ent_d != (ent_d - 1ULL) ) { uL(fprintf(uH, "record (%s) is corrupt (g)\n", ful_c)); uL(fprintf(uH, "lar_u.ent_d %llx, ent_d %llx\n", lar_u.ent_d, ent_d)); - u2_lo_bail(rec_u); + u3_lo_bail(); } ent_d -= 1ULL; } @@ -991,63 +991,63 @@ _sist_rest(u2_reck* rec_u) if ( -1 == lseek64(fid_i, 4ULL * end_d, SEEK_SET) ) { uL(fprintf(uH, "record (%s) is corrupt (h)\n", ful_c)); - u2_lo_bail(rec_u); + u3_lo_bail(); } if ( (4 * lar_u.len_w) != read(fid_i, img_w, (4 * lar_u.len_w)) ) { uL(fprintf(uH, "record (%s) is corrupt (i)\n", ful_c)); - u2_lo_bail(rec_u); + u3_lo_bail(); } - ron = u2_ci_words(lar_u.len_w, img_w); + ron = u3_ci_words(lar_u.len_w, img_w); free(img_w); if ( lar_u.mug_w != - u2_cr_mug_both(u2_cr_mug(ron), - u2_cr_mug_both(u2_cr_mug(lar_u.tem_w), - u2_cr_mug(lar_u.typ_w))) ) + u3_cr_mug_both(u3_cr_mug(ron), + u3_cr_mug_both(u3_cr_mug(lar_u.tem_w), + u3_cr_mug(lar_u.typ_w))) ) { uL(fprintf(uH, "record (%s) is corrupt (j)\n", ful_c)); - u2_lo_bail(rec_u); + u3_lo_bail(); } if ( c3__ov != lar_u.typ_w ) { - u2z(ron); + u3z(ron); continue; } - if ( rec_u->key ) { - u2_noun dep; + if ( u3A->key ) { + u3_noun dep; - dep = u2_dc("de:crua", u2k(rec_u->key), ron); - if ( u2_no == u2du(dep) ) { + dep = u3_dc("de:crua", u3k(u3A->key), ron); + if ( u3_no == u3du(dep) ) { uL(fprintf(uH, "record (%s) is corrupt (k)\n", ful_c)); - u2_lo_bail(rec_u); + u3_lo_bail(); } else { - ron = u2k(u2t(dep)); - u2z(dep); + ron = u3k(u3t(dep)); + u3z(dep); } } - roe = u2nc(u2_cke_cue(ron), roe); + roe = u3nc(u3_cke_cue(ron), roe); } - rec_u->ent_d = c3_max(las_d + 1ULL, old_d); + u3A->ent_d = c3_max(las_d + 1ULL, old_d); } - if ( u2_nul == roe ) { + if ( u3_nul == roe ) { // Nothing in the log that was not also in the checkpoint. // - c3_assert(rec_u->ent_d == old_d); + c3_assert(u3A->ent_d == old_d); if ( las_d + 1 != old_d ) { uL(fprintf(uH, "checkpoint and log disagree! las:%llu old:%llu\n", las_d + 1, old_d)); uL(fprintf(uH, "Some events appear to be missing from the log.\n" "Please contact the authorities, " "and do not delete your pier!\n")); - u2_lo_bail(rec_u); + u3_lo_bail(); } } else { - u2_noun rou = roe; + u3_noun rou = roe; c3_w xno_w; // Execute the fscking things. This is pretty much certain to crash. @@ -1056,25 +1056,25 @@ _sist_rest(u2_reck* rec_u) fprintf(uH, "---------------- playback starting----------------\n"); xno_w = 0; - while ( u2_nul != roe ) { - u2_noun i_roe = u2h(roe); - u2_noun t_roe = u2t(roe); - u2_noun now = u2h(i_roe); - u2_noun ovo = u2t(i_roe); + while ( u3_nul != roe ) { + u3_noun i_roe = u3h(roe); + u3_noun t_roe = u3t(roe); + u3_noun now = u3h(i_roe); + u3_noun ovo = u3t(i_roe); - u2_reck_wind(rec_u, u2k(now)); - if ( (u2_yes == u2_Host.ops_u.vno) && - ( (c3__veer == u2h(u2t(ovo)) || - (c3__vega == u2h(u2t(ovo)))) ) ) + u3_cv_time(u3k(now)); + if ( (u3_yes == u3_Host.ops_u.vno) && + ( (c3__veer == u3h(u3t(ovo)) || + (c3__vega == u3h(u3t(ovo)))) ) ) { fprintf(stderr, "replay: skipped veer\n"); } - else if ( u2_yes == u2_Host.ops_u.fog && - u2_nul == t_roe ) { + else if ( u3_yes == u3_Host.ops_u.fog && + u3_nul == t_roe ) { fprintf(stderr, "replay: -Xwtf, skipped last event\n"); } else { - _sist_sing(rec_u, u2k(ovo)); + _sist_sing(u3k(ovo)); fputc('.', stderr); } @@ -1085,10 +1085,10 @@ _sist_rest(u2_reck* rec_u) if ( 0 == (xno_w % 1000) ) { uL(fprintf(uH, "{%d}\n", xno_w)); - u2_lo_grab("rest", rou, u2_none); + // u3_lo_grab("rest", rou, u3_none); } } - u2z(rou); + u3z(rou); } uL(fprintf(stderr, "\n---------------- playback complete----------------\n")); @@ -1096,63 +1096,63 @@ _sist_rest(u2_reck* rec_u) // If you see this error, your record is totally fscking broken! // Which probably serves you right. Please consult a consultant. { - if ( u2_nul == rec_u->own ) { + if ( u3_nul == u3A->own ) { uL(fprintf(uH, "record did not install a master!\n")); - u2_lo_bail(rec_u); + u3_lo_bail(); } - rec_u->our = u2k(u2h(rec_u->own)); - rec_u->pod = u2_dc("scot", 'p', u2k(rec_u->our))); + u3A->our = u3k(u3h(u3A->own)); + u3A->pod = u3_dc("scot", 'p', u3k(u3A->our))); } // Now, who the fsck are you? No, really. { - u2_noun who; + u3_noun who; c3_c* fil_c; c3_c* who_c; - if ( (fil_c = strrchr(u2_Host.cpu_c, '/')) ) { + if ( (fil_c = strrchr(u3_Host.cpu_c, '/')) ) { fil_c++; - } else fil_c = u2_Host.cpu_c; + } else fil_c = u3_Host.cpu_c; - who = u2_dc("scot", 'p', u2k(rec_u->our))); - who_c = u2_cr_string(who); - u2z(who); + who = u3_dc("scot", 'p', u3k(u3A->our))); + who_c = u3_cr_string(who); + u3z(who); if ( strncmp(fil_c, who_c + 1, strlen(fil_c)) ) { uL(fprintf(uH, "record master (%s) does not match filename!\n", who_c)); - u2_lo_bail(rec_u); + u3_lo_bail(); } free(who_c); } #endif // Increment sequence numbers. New logs start at 1. - if ( u2_yes == ohh ) { + if ( u3_yes == ohh ) { uL(fprintf(uH, "rest: bumping ent_d, don't panic.\n")); - u2_ular lar_u; + u3_ular lar_u; c3_d end_d; c3_d tar_d; - rec_u->ent_d++; - end_d = u2R->lug_u.len_d; - while ( end_d != c3_wiseof(u2_uled) ) { - tar_d = end_d - c3_wiseof(u2_ular); + u3A->ent_d++; + end_d = u3Z->lug_u.len_d; + while ( end_d != c3_wiseof(u3_uled) ) { + tar_d = end_d - c3_wiseof(u3_ular); if ( -1 == lseek64(fid_i, 4ULL * tar_d, SEEK_SET) ) { uL(fprintf(uH, "bumping sequence numbers failed (a)\n")); - u2_lo_bail(rec_u); + u3_lo_bail(); } if ( sizeof(lar_u) != read(fid_i, &lar_u, sizeof(lar_u)) ) { uL(fprintf(uH, "bumping sequence numbers failed (b)\n")); - u2_lo_bail(rec_u); + u3_lo_bail(); } lar_u.ent_d++; if ( -1 == lseek64(fid_i, 4ULL * tar_d, SEEK_SET) ) { uL(fprintf(uH, "bumping sequence numbers failed (c)\n")); - u2_lo_bail(rec_u); + u3_lo_bail(); } if ( sizeof(lar_u) != write(fid_i, &lar_u, sizeof(lar_u)) ) { uL(fprintf(uH, "bumping sequence numbers failed (d)\n")); - u2_lo_bail(rec_u); + u3_lo_bail(); } end_d = tar_d - lar_u.len_w; } @@ -1160,96 +1160,96 @@ _sist_rest(u2_reck* rec_u) // Rewrite the header. Will probably corrupt the record. { - u2_uled led_u; + u3_uled led_u; - led_u.mag_l = u2_mug('g'); + led_u.mag_l = u3_cr_mug('g'); led_u.sal_l = sal_l; - led_u.sev_l = rec_u->sev_l; - led_u.key_l = rec_u->key ? u2_mug(rec_u->key) : 0; - led_u.kno_w = rec_u->kno_w; // may need actual translation! + led_u.sev_l = u3A->sev_l; + led_u.key_l = u3A->key ? u3_cr_mug(u3A->key) : 0; + led_u.kno_w = 164; // may need actual translation! led_u.tno_l = 1; if ( (-1 == lseek64(fid_i, 0, SEEK_SET)) || (sizeof(led_u) != write(fid_i, &led_u, sizeof(led_u))) ) { uL(fprintf(uH, "record (%s) failed to rewrite\n", ful_c)); - u2_lo_bail(rec_u); + u3_lo_bail(); } } // Hey, fscker! It worked. { - u2_term_ef_boil(); + u3_term_ef_boil(); } } /* _sist_zen(): get OS entropy. */ -static u2_noun -_sist_zen(u2_reck* rec_u) +static u3_noun +_sist_zen() { c3_w rad_w[8]; - _sist_rand(rec_u, rad_w); - return u2_ci_words(8, rad_w); + _sist_rand(rad_w); + return u3_ci_words(8, rad_w); } -/* u2_sist_boot(): restore or create. +/* u3_sist_boot(): restore or create. */ void -u2_sist_boot(void) +u3_sist_boot(void) { uL(fprintf(uH, "sist: booting\n")); - if ( u2_yes == u2_Host.ops_u.nuu ) { - u2_noun pig = u2_none; + if ( u3_yes == u3_Host.ops_u.nuu ) { + u3_noun pig = u3_none; - if ( 0 == u2_Host.ops_u.imp_c ) { + if ( 0 == u3_Host.ops_u.imp_c ) { c3_c get_c[2049]; - snprintf(get_c, 2048, "%s/.urb/get", u2_Host.cpu_c); + snprintf(get_c, 2048, "%s/.urb/get", u3_Host.cpu_c); if ( 0 == access(get_c, 0) ) { uL(fprintf(uH, "pier: already built\n")); - u2_lo_bail(u2A); + u3_lo_bail(); } - u2_noun ten = _sist_zen(u2A); + u3_noun ten = _sist_zen(); uL(fprintf(uH, "generating 2048-bit RSA pair...\n")); - pig = u2nq(c3__make, u2_nul, 11, u2nc(ten, u2_Host.ops_u.fak)); + pig = u3nq(c3__make, u3_nul, 11, u3nc(ten, u3_Host.ops_u.fak)); } else { - u2_noun imp = u2_ci_string(u2_Host.ops_u.imp_c); - u2_noun whu = u2_dc("slaw", 'p', u2k(imp)); + u3_noun imp = u3_ci_string(u3_Host.ops_u.imp_c); + u3_noun whu = u3_dc("slaw", 'p', u3k(imp)); - if ( (u2_nul == whu) ) { + if ( (u3_nul == whu) ) { fprintf(stderr, "czar: incorrect format\r\n"); - u2_lo_bail(u2A); + u3_lo_bail(); } else { - u2_noun gen = u2_nul; - u2_noun gun = u2_nul; - if (u2_no == u2_Host.ops_u.fak) { - gen = _sist_text(u2A, "generator"); - gun = u2_dc("slaw", c3__uw, gen); + u3_noun gen = u3_nul; + u3_noun gun = u3_nul; + if (u3_no == u3_Host.ops_u.fak) { + gen = _sist_text("generator"); + gun = u3_dc("slaw", c3__uw, gen); - if ( u2_nul == gun ) { + if ( u3_nul == gun ) { fprintf(stderr, "czar: incorrect format\r\n"); - u2_lo_bail(u2A); + u3_lo_bail(); } } else { - gun = u2nc(u2_nul, u2_nul); + gun = u3nc(u3_nul, u3_nul); } - pig = u2nq(c3__sith, - u2k(u2t(whu)), - u2k(u2t(gun)), - u2_Host.ops_u.fak); + pig = u3nq(c3__sith, + u3k(u3t(whu)), + u3k(u3t(gun)), + u3_Host.ops_u.fak); - u2z(whu); u2z(gun); + u3z(whu); u3z(gun); } - u2z(imp); + u3z(imp); } - _sist_make(u2A, pig); + _sist_make(pig); } else { - _sist_rest(u2A); + _sist_rest(); } } diff --git a/v/term.c b/v/term.c index fbc82e818..a21a4f897 100644 --- a/v/term.c +++ b/v/term.c @@ -29,7 +29,7 @@ static void _term_read_tn_cb(uv_stream_t* tcp_u, static void _term_read_cb(uv_stream_t* tcp_u, ssize_t siz_i, const uv_buf_t * buf_u); -static void _term_suck(u2_utty*, const c3_y*, ssize_t); +static void _term_suck(u3_utty*, const c3_y*, ssize_t); static void _tel_event(telnet_nvt*, telnet_event*); static void _tel_opt(telnet_nvt*, telnet_byte, telnet_telopt_event*); @@ -55,13 +55,13 @@ _term_alloc(uv_handle_t* had_u, static void _term_close_cb(uv_handle_t* han_t) { - u2_utty* tty_u = (void*) han_t; - if ( u2_Host.uty_u == tty_u ) { - u2_Host.uty_u = tty_u->nex_u; + u3_utty* tty_u = (void*) han_t; + if ( u3_Host.uty_u == tty_u ) { + u3_Host.uty_u = tty_u->nex_u; } else { - u2_utty* uty_u; - for (uty_u = u2_Host.uty_u; uty_u; uty_u = uty_u->nex_u ) { + u3_utty* uty_u; + for (uty_u = u3_Host.uty_u; uty_u; uty_u = uty_u->nex_u ) { if ( uty_u->nex_u == tty_u ) { uty_u->nex_u = tty_u->nex_u; break; @@ -70,10 +70,10 @@ _term_close_cb(uv_handle_t* han_t) } { - u2_noun tid = u2_dc("scot", c3__ud, tty_u->tid_l); - u2_noun pax = u2nq(u2_blip, c3__term, tid, u2_nul); - u2_reck_plan(u2A, u2k(pax), u2nc(c3__hook, u2_nul)); - u2z(pax); + u3_noun tid = u3_dc("scot", c3__ud, tty_u->tid_l); + u3_noun pax = u3nq(u3_blip, c3__term, tid, u3_nul); + u3_cv_plan(u3k(pax), u3nc(c3__hook, u3_nul)); + u3z(pax); } free(tty_u); } @@ -83,22 +83,22 @@ _term_close_cb(uv_handle_t* han_t) static void _tel_close_cb(uv_handle_t* han_t) { - u2_utel* pty_u = (u2_utel*)(void*)han_t; + u3_utel* pty_u = (u3_utel*)(void*)han_t; telnet_nvt_free(pty_u->tel_u); _term_close_cb(han_t); } -/* u2_term_io_init(): initialize terminal. +/* u3_term_io_init(): initialize terminal. */ void -u2_term_io_init() +u3_term_io_init() { - u2_utty* uty_u = calloc(1, sizeof(u2_utty)); + u3_utty* uty_u = calloc(1, sizeof(u3_utty)); - if ( u2_yes == u2_Host.ops_u.dem ) { + if ( u3_yes == u3_Host.ops_u.dem ) { uty_u->fid_i = 1; - uv_pipe_init(u2L, &(uty_u->pop_u), 0); + uv_pipe_init(u3L, &(uty_u->pop_u), 0); uv_pipe_open(&(uty_u->pop_u), uty_u->fid_i); } else { @@ -107,7 +107,7 @@ u2_term_io_init() { uty_u->fid_i = 0; // stdin, yes we write to it... - uv_pipe_init(u2L, &(uty_u->pop_u), 0); + uv_pipe_init(u3L, &(uty_u->pop_u), 0); uv_pipe_open(&(uty_u->pop_u), uty_u->fid_i); uv_read_start((uv_stream_t*)&(uty_u->pop_u), _term_alloc, _term_read_cb); } @@ -217,8 +217,8 @@ u2_term_io_init() uty_u->tat_u.mir.len_w = 0; uty_u->tat_u.mir.cus_w = 0; - uty_u->tat_u.esc.ape = u2_no; - uty_u->tat_u.esc.bra = u2_no; + uty_u->tat_u.esc.ape = u3_no; + uty_u->tat_u.esc.bra = u3_no; uty_u->tat_u.fut.len_w = 0; uty_u->tat_u.fut.wid_w = 0; @@ -230,10 +230,10 @@ u2_term_io_init() { uty_u->tid_l = 1; uty_u->nex_u = 0; - u2_Host.uty_u = uty_u; + u3_Host.uty_u = uty_u; } - if ( u2_no == u2_Host.ops_u.dem ) { + if ( u3_no == u3_Host.ops_u.dem ) { // Start raw input. // { @@ -250,9 +250,9 @@ u2_term_io_init() void _term_listen_cb(uv_stream_t *wax_u, int sas_i) { - u2_utel* pty_u = calloc(1, sizeof(*pty_u)); - u2_utty* tty_u = &pty_u->uty_t; - uv_tcp_init(u2L, &tty_u->wax_u); + u3_utel* pty_u = calloc(1, sizeof(*pty_u)); + u3_utty* tty_u = &pty_u->uty_t; + uv_tcp_init(u3L, &tty_u->wax_u); c3_w ret_w; if ( 0 != (ret_w = uv_accept(wax_u, (uv_stream_t*)&tty_u->wax_u)) ) { uL(fprintf(uH, "term: accept: %s\n", @@ -287,8 +287,8 @@ _term_listen_cb(uv_stream_t *wax_u, int sas_i) tty_u->tat_u.mir.len_w = 0; tty_u->tat_u.mir.cus_w = 0; - tty_u->tat_u.esc.ape = u2_no; - tty_u->tat_u.esc.bra = u2_no; + tty_u->tat_u.esc.ape = u3_no; + tty_u->tat_u.esc.bra = u3_no; tty_u->tat_u.fut.len_w = 0; tty_u->tat_u.fut.wid_w = 0; @@ -296,17 +296,17 @@ _term_listen_cb(uv_stream_t *wax_u, int sas_i) tty_u->tat_u.siz.col_l = 80; tty_u->tat_u.siz.row_l = 25; - tty_u->tid_l = u2_Host.uty_u->tid_l + 1; - tty_u->nex_u = u2_Host.uty_u; - u2_Host.uty_u = tty_u; + tty_u->tid_l = u3_Host.uty_u->tid_l + 1; + tty_u->nex_u = u3_Host.uty_u; + u3_Host.uty_u = tty_u; pty_u->tel_u = telnet_nvt_new(tty_u, _tel_event, _tel_opt, NULL); { - u2_noun tid = u2_dc("scot", c3__ud, tty_u->tid_l); - u2_noun pax = u2nq(u2_blip, c3__term, tid, u2_nul); - u2_reck_plan(u2A, u2k(pax), u2nc(c3__blew, u2nc(80, 25))); - u2_reck_plan(u2A, u2k(pax), u2nc(c3__hail, u2_nul)); - u2z(pax); + u3_noun tid = u3_dc("scot", c3__ud, tty_u->tid_l); + u3_noun pax = u3nq(u3_blip, c3__term, tid, u3_nul); + u3_cv_plan(u3k(pax), u3nc(c3__blew, u3nc(80, 25))); + u3_cv_plan(u3k(pax), u3nc(c3__hail, u3_nul)); + u3z(pax); } telnet_telopt_enable(pty_u->tel_u, _T_ECHO, TELNET_LOCAL); @@ -316,12 +316,12 @@ _term_listen_cb(uv_stream_t *wax_u, int sas_i) } void -u2_term_io_talk(void) +u3_term_io_talk(void) { struct sockaddr_in add_u; - u2_utel* tel_u = &u2_Host.tel_u; + u3_utel* tel_u = &u3_Host.tel_u; - uv_tcp_init(u2L, &tel_u->uty_t.wax_u); + uv_tcp_init(u3L, &tel_u->uty_t.wax_u); tel_u->por_s = 10023; memset(&add_u, 0, sizeof(add_u)); @@ -360,18 +360,18 @@ u2_term_io_talk(void) } } -/* u2_term_io_exit(): clean up terminal. +/* u3_term_io_exit(): clean up terminal. */ void -u2_term_io_exit(void) +u3_term_io_exit(void) { - if ( u2_yes == u2_Host.ops_u.dem ) { - uv_close((uv_handle_t*)&u2_Host.uty_u->pop_u, NULL); + if ( u3_yes == u3_Host.ops_u.dem ) { + uv_close((uv_handle_t*)&u3_Host.uty_u->pop_u, NULL); } else { - u2_utty* uty_u; + u3_utty* uty_u; - for ( uty_u = u2_Host.uty_u; uty_u; uty_u = uty_u->nex_u ) { + for ( uty_u = u3_Host.uty_u; uty_u; uty_u = uty_u->nex_u ) { if ( uty_u->fid_i == -1 ) { continue; } if ( 0 != tcsetattr(uty_u->fid_i, TCSADRAIN, &uty_u->bak_u) ) { c3_assert(!"exit-tcsetattr"); @@ -385,16 +385,16 @@ u2_term_io_exit(void) } void -u2_term_io_poll(void) +u3_term_io_poll(void) { } /* _term_it_buf(): create a data buffer. */ -static u2_ubuf* +static u3_ubuf* _term_it_buf(c3_w len_w, const c3_y* hun_y) { - u2_ubuf* buf_u = c3_malloc(len_w + sizeof(*buf_u)); + u3_ubuf* buf_u = c3_malloc(len_w + sizeof(*buf_u)); buf_u->len_w = len_w; memcpy(buf_u->hun_y, hun_y, len_w); @@ -408,14 +408,14 @@ _term_it_buf(c3_w len_w, const c3_y* hun_y) typedef struct { uv_write_t wri_u; c3_y* buf_y; - } _u2_write_t; + } _u3_write_t; /* _term_write_cb(): general write callback. */ static void _term_write_cb(uv_write_t* wri_u, c3_i sas_i) { - _u2_write_t* ruq_u = (void *)wri_u; + _u3_write_t* ruq_u = (void *)wri_u; if ( 0 != sas_i ) { uL(fprintf(uH, "term: write: ERROR\n")); @@ -427,9 +427,9 @@ _term_write_cb(uv_write_t* wri_u, c3_i sas_i) /* _term_it_write_buf(): write buffer uv style. */ static void -_term_it_write_buf(u2_utty* uty_u, uv_buf_t buf_u) +_term_it_write_buf(u3_utty* uty_u, uv_buf_t buf_u) { - _u2_write_t* ruq_u = (_u2_write_t*) c3_malloc(sizeof(_u2_write_t)); + _u3_write_t* ruq_u = (_u3_write_t*) c3_malloc(sizeof(_u3_write_t)); ruq_u->buf_y = (c3_y*)buf_u.base; @@ -446,8 +446,8 @@ _term_it_write_buf(u2_utty* uty_u, uv_buf_t buf_u) /* _term_it_write_old(): write buffer, transferring pointer. */ static void -_term_it_write_old(u2_utty* uty_u, - u2_ubuf* old_u) +_term_it_write_old(u3_utty* uty_u, + u3_ubuf* old_u) { uv_buf_t buf_u; @@ -467,7 +467,7 @@ _term_it_write_old(u2_utty* uty_u, /* _term_it_write_bytes(): write bytes, retaining pointer. */ static void -_term_it_write_bytes(u2_utty* uty_u, +_term_it_write_bytes(u3_utty* uty_u, c3_w len_w, const c3_y* hun_y) { @@ -477,7 +477,7 @@ _term_it_write_bytes(u2_utty* uty_u, /* _term_it_write_txt(): write null-terminated string, retaining pointer. */ static void -_term_it_write_txt(u2_utty* uty_u, +_term_it_write_txt(u3_utty* uty_u, const c3_y* hun_y) { _term_it_write_bytes(uty_u, strlen((const c3_c*)hun_y), hun_y); @@ -486,7 +486,7 @@ _term_it_write_txt(u2_utty* uty_u, /* _term_it_write_str(): write null-terminated string, retaining pointer. */ static void -_term_it_write_str(u2_utty* uty_u, +_term_it_write_str(u3_utty* uty_u, const c3_c* str_c) { _term_it_write_txt(uty_u, (const c3_y*) str_c); @@ -495,15 +495,15 @@ _term_it_write_str(u2_utty* uty_u, /* _term_it_show_wide(): show wide text, retaining. */ static void -_term_it_show_wide(u2_utty* uty_u, c3_w len_w, c3_w* txt_w) +_term_it_show_wide(u3_utty* uty_u, c3_w len_w, c3_w* txt_w) { - u2_noun wad = u2_ci_words(len_w, txt_w); - u2_noun txt = u2_do("tuft", wad); - c3_c* txt_c = u2_cr_string(txt); + u3_noun wad = u3_ci_words(len_w, txt_w); + u3_noun txt = u3_do("tuft", wad); + c3_c* txt_c = u3_cr_string(txt); _term_it_write_str(uty_u, txt_c); free(txt_c); - u2z(txt); + u3z(txt); uty_u->tat_u.mir.cus_w += len_w; } @@ -511,9 +511,9 @@ _term_it_show_wide(u2_utty* uty_u, c3_w len_w, c3_w* txt_w) /* _term_it_show_clear(): clear to the beginning of the current line. */ static void -_term_it_show_clear(u2_utty* uty_u) +_term_it_show_clear(u3_utty* uty_u) { - u2_utat* tat_u = &uty_u->tat_u; + u3_utat* tat_u = &uty_u->tat_u; if ( tat_u->siz.col_l ) { c3_w ful_w = tat_u->mir.cus_w / tat_u->siz.col_l; @@ -539,7 +539,7 @@ _term_it_show_clear(u2_utty* uty_u) /* _term_it_show_blank(): blank the screen. */ static void -_term_it_show_blank(u2_utty* uty_u) +_term_it_show_blank(u3_utty* uty_u) { _term_it_write_txt(uty_u, uty_u->ufo_u.out.clear_y); uty_u->tat_u.mir.cus_w = 0; @@ -548,7 +548,7 @@ _term_it_show_blank(u2_utty* uty_u) /* _term_it_show_cursor(): set current line, transferring pointer. */ static void -_term_it_show_cursor(u2_utty* uty_u, c3_w cur_w) +_term_it_show_cursor(u3_utty* uty_u, c3_w cur_w) { if ( cur_w < uty_u->tat_u.mir.cus_w ) { c3_w dif_w = (uty_u->tat_u.mir.cus_w - cur_w); @@ -570,7 +570,7 @@ _term_it_show_cursor(u2_utty* uty_u, c3_w cur_w) /* _term_it_show_line(): set current line */ static void -_term_it_show_line(u2_utty* uty_u, c3_w* lin_w, c3_w len_w) +_term_it_show_line(u3_utty* uty_u, c3_w* lin_w, c3_w len_w) { _term_it_show_wide(uty_u, len_w, lin_w); @@ -586,7 +586,7 @@ _term_it_show_line(u2_utty* uty_u, c3_w* lin_w, c3_w len_w) /* _term_it_refresh_line(): refresh current line. */ static void -_term_it_refresh_line(u2_utty* uty_u) +_term_it_refresh_line(u3_utty* uty_u) { c3_w len_w = uty_u->tat_u.mir.len_w; @@ -597,9 +597,9 @@ _term_it_refresh_line(u2_utty* uty_u) /* _term_it_show_more(): new current line. */ static void -_term_it_show_more(u2_utty* uty_u) +_term_it_show_more(u3_utty* uty_u) { - if ( u2_yes == u2_Host.ops_u.dem ) { + if ( u3_yes == u3_Host.ops_u.dem ) { _term_it_write_str(uty_u, "\n"); } else { _term_it_write_str(uty_u, "\r\n"); @@ -610,73 +610,73 @@ _term_it_show_more(u2_utty* uty_u) /* _term_it_path(): path for console file. */ static c3_c* -_term_it_path(u2_bean fyl, u2_noun pax) +_term_it_path(u3_bean fyl, u3_noun pax) { c3_w len_w; c3_c *pas_c; // measure // - len_w = strlen(u2_Host.cpu_c); + len_w = strlen(u3_Host.cpu_c); { - u2_noun wiz = pax; + u3_noun wiz = pax; - while ( u2_nul != wiz ) { - len_w += (1 + u2_cr_met(3, u2h(wiz))); - wiz = u2t(wiz); + while ( u3_nul != wiz ) { + len_w += (1 + u3_cr_met(3, u3h(wiz))); + wiz = u3t(wiz); } } // cut // pas_c = c3_malloc(len_w + 1); - strncpy(pas_c, u2_Host.cpu_c, len_w); + strncpy(pas_c, u3_Host.cpu_c, len_w); pas_c[len_w] = '\0'; { - u2_noun wiz = pax; + u3_noun wiz = pax; c3_c* waq_c = (pas_c + strlen(pas_c)); - while ( u2_nul != wiz ) { - c3_w tis_w = u2_cr_met(3, u2h(wiz)); + while ( u3_nul != wiz ) { + c3_w tis_w = u3_cr_met(3, u3h(wiz)); - if ( (u2_yes == fyl) && (u2_nul == u2t(wiz)) ) { + if ( (u3_yes == fyl) && (u3_nul == u3t(wiz)) ) { *waq_c++ = '.'; } else *waq_c++ = '/'; - u2_cr_bytes(0, tis_w, (c3_y*)waq_c, u2h(wiz)); + u3_cr_bytes(0, tis_w, (c3_y*)waq_c, u3h(wiz)); waq_c += tis_w; - wiz = u2t(wiz); + wiz = u3t(wiz); } *waq_c = 0; } - u2z(pax); + u3z(pax); return pas_c; } /* _term_it_save(): save file by path. */ static void -_term_it_save(u2_noun pax, u2_noun pad) +_term_it_save(u3_noun pax, u3_noun pad) { c3_c* pax_c; - pax = u2nt(c3_s4('.','u','r','b'), c3_s3('p','u','t'), pax); - pax_c = _term_it_path(u2_yes, pax); + pax = u3nt(c3_s4('.','u','r','b'), c3_s3('p','u','t'), pax); + pax_c = _term_it_path(u3_yes, pax); - u2_walk_save(pax_c, 0, pad); + u3_walk_save(pax_c, 0, pad); free(pax_c); } /* _term_io_belt(): send belt. */ static void -_term_io_belt(u2_utty* uty_u, u2_noun blb) +_term_io_belt(u3_utty* uty_u, u3_noun blb) { - u2_noun tid = u2_dc("scot", c3__ud, uty_u->tid_l); - u2_noun pax = u2nq(u2_blip, c3__term, tid, u2_nul); + u3_noun tid = u3_dc("scot", c3__ud, uty_u->tid_l); + u3_noun pax = u3nq(u3_blip, c3__term, tid, u3_nul); - u2_reck_plan(u2A, pax, u2nc(c3__belt, blb)); + u3_cv_plan(pax, u3nc(c3__belt, blb)); } /* _tel_event(): telnet sucker @@ -688,21 +688,21 @@ _term_io_belt(u2_utty* uty_u, u2_noun blb) static void _tel_event(_te_nvt* nvt, _te_evt* evt) { - u2_utel* tel_u; + u3_utel* tel_u; c3_assert(0 < telnet_get_userdata(nvt, (void**)&tel_u)); switch (evt->type) { case TELNET_EV_DATA: { _te_dvt* dv = (_te_dvt*)evt; - _term_suck((u2_utty*)tel_u, dv->data, dv->length); + _term_suck((u3_utty*)tel_u, dv->data, dv->length); break; } case TELNET_EV_SEND: { _te_svt* sv = (_te_svt*)evt; - _term_it_write_bytes((u2_utty*)tel_u, sv->length, sv->data); + _term_it_write_bytes((u3_utty*)tel_u, sv->length, sv->data); break; } default: @@ -726,10 +726,10 @@ _tel_opt(_te_nvt* nvt, telnet_byte opt, _to_evt* evt) case TELNET_EV_TELOPT_DATA: { _to_dvt* dv = (_to_dvt*)evt; - u2_utel* tel_u; - u2_noun pax; - u2_noun blu; - u2_noun tid; + u3_utel* tel_u; + u3_noun pax; + u3_noun blu; + u3_noun tid; c3_s col_s; c3_s row_s; @@ -745,10 +745,10 @@ _tel_opt(_te_nvt* nvt, telnet_byte opt, _to_evt* evt) tel_u->uty_t.tat_u.siz.col_l = col_s; tel_u->uty_t.tat_u.siz.row_l = row_s; - tid = u2_dc("scot", c3__ud, tel_u->uty_t.tid_l); - pax = u2nq(u2_blip, c3__term, tid, u2_nul); - blu = u2nc(col_s, row_s); - u2_reck_plan(u2A, pax, u2nc(c3__blew, blu)); + tid = u3_dc("scot", c3__ud, tel_u->uty_t.tid_l); + pax = u3nq(u3_blip, c3__term, tid, u3_nul); + blu = u3nc(col_s, row_s); + u3_cv_plan(pax, u3nc(c3__blew, blu)); break; } } @@ -756,34 +756,34 @@ _tel_opt(_te_nvt* nvt, telnet_byte opt, _to_evt* evt) /* _term_io_suck_char(): process a single character. */ static void -_term_io_suck_char(u2_utty* uty_u, c3_y cay_y) +_term_io_suck_char(u3_utty* uty_u, c3_y cay_y) { - u2_utat* tat_u = &uty_u->tat_u; + u3_utat* tat_u = &uty_u->tat_u; - if ( u2_yes == tat_u->esc.ape ) { - if ( u2_yes == tat_u->esc.bra ) { + if ( u3_yes == tat_u->esc.ape ) { + if ( u3_yes == tat_u->esc.bra ) { switch ( cay_y ) { default: { _term_it_write_txt(uty_u, uty_u->ufo_u.out.bel_y); break; } - case 'A': _term_io_belt(uty_u, u2nc(c3__aro, 'u')); break; - case 'B': _term_io_belt(uty_u, u2nc(c3__aro, 'd')); break; - case 'C': _term_io_belt(uty_u, u2nc(c3__aro, 'r')); break; - case 'D': _term_io_belt(uty_u, u2nc(c3__aro, 'l')); break; + case 'A': _term_io_belt(uty_u, u3nc(c3__aro, 'u')); break; + case 'B': _term_io_belt(uty_u, u3nc(c3__aro, 'd')); break; + case 'C': _term_io_belt(uty_u, u3nc(c3__aro, 'r')); break; + case 'D': _term_io_belt(uty_u, u3nc(c3__aro, 'l')); break; } - tat_u->esc.ape = tat_u->esc.bra = u2_no; + tat_u->esc.ape = tat_u->esc.bra = u3_no; } else { if ( (cay_y >= 'a') && (cay_y <= 'z') ) { - tat_u->esc.ape = u2_no; - _term_io_belt(uty_u, u2nc(c3__met, cay_y)); + tat_u->esc.ape = u3_no; + _term_io_belt(uty_u, u3nc(c3__met, cay_y)); } else if ( ('[' == cay_y) || ('O' == cay_y) ) { - tat_u->esc.bra = u2_yes; + tat_u->esc.bra = u3_yes; } else { - tat_u->esc.ape = u2_no; + tat_u->esc.ape = u3_no; _term_it_write_txt(uty_u, uty_u->ufo_u.out.bel_y); } @@ -793,36 +793,36 @@ _term_io_suck_char(u2_utty* uty_u, c3_y cay_y) tat_u->fut.syb_y[tat_u->fut.len_w++] = cay_y; if ( tat_u->fut.len_w == tat_u->fut.wid_w ) { - u2_noun huv = u2_ci_bytes(tat_u->fut.wid_w, tat_u->fut.syb_y); - u2_noun wug; + u3_noun huv = u3_ci_bytes(tat_u->fut.wid_w, tat_u->fut.syb_y); + u3_noun wug; // uL(fprintf(uH, "muck-utf8 len %d\n", tat_u->fut.len_w)); // uL(fprintf(uH, "muck-utf8 %x\n", huv)); - wug = u2_do("turf", huv); + wug = u3_do("turf", huv); // uL(fprintf(uH, "muck-utf32 %x\n", tat_u->fut.len_w)); tat_u->fut.len_w = tat_u->fut.wid_w = 0; - _term_io_belt(uty_u, u2nt(c3__txt, wug, u2_nul)); + _term_io_belt(uty_u, u3nt(c3__txt, wug, u3_nul)); } } else { if ( (cay_y >= 32) && (cay_y < 127) ) { - _term_io_belt(uty_u, u2nt(c3__txt, cay_y, u2_nul)); + _term_io_belt(uty_u, u3nt(c3__txt, cay_y, u3_nul)); } else if ( 0 == cay_y ) { _term_it_write_txt(uty_u, uty_u->ufo_u.out.bel_y); } else if ( 8 == cay_y || 127 == cay_y ) { - _term_io_belt(uty_u, u2nc(c3__bac, u2_nul)); + _term_io_belt(uty_u, u3nc(c3__bac, u3_nul)); } else if ( 13 == cay_y ) { - _term_io_belt(uty_u, u2nc(c3__ret, u2_nul)); + _term_io_belt(uty_u, u3nc(c3__ret, u3_nul)); } else if ( cay_y <= 26 ) { - _term_io_belt(uty_u, u2nc(c3__ctl, ('a' + (cay_y - 1)))); + _term_io_belt(uty_u, u3nc(c3__ctl, ('a' + (cay_y - 1)))); } else if ( 27 == cay_y ) { - tat_u->esc.ape = u2_yes; + tat_u->esc.ape = u3_yes; } else if ( cay_y >= 128 ) { tat_u->fut.len_w = 1; @@ -844,9 +844,9 @@ _term_read_tn_cb(uv_stream_t* tcp_u, ssize_t siz_i, const uv_buf_t * buf_u) { - u2_utel* pty_u = (u2_utel*)(void*) tcp_u; + u3_utel* pty_u = (u3_utel*)(void*) tcp_u; - u2_lo_open(); + u3_lo_open(); { if ( siz_i == UV_EOF ) { // nothing @@ -862,7 +862,7 @@ _term_read_tn_cb(uv_stream_t* tcp_u, err: free(buf_u->base); } - u2_lo_shut(u2_yes); + u3_lo_shut(u3_yes); } /* _term_suck(): process a chunk of input @@ -881,9 +881,9 @@ _term_read_tn_cb(uv_stream_t* tcp_u, */ static inline void -_term_suck(u2_utty* uty_u, const c3_y* buf, ssize_t siz_i) +_term_suck(u3_utty* uty_u, const c3_y* buf, ssize_t siz_i) { - u2_lo_open(); + u3_lo_open(); { if ( siz_i == UV_EOF ) { // nothing @@ -898,7 +898,7 @@ _term_suck(u2_utty* uty_u, const c3_y* buf, ssize_t siz_i) } } } - u2_lo_shut(u2_yes); + u3_lo_shut(u3_yes); } /* _term_read_cb(): server read callback. @@ -908,35 +908,35 @@ _term_read_cb(uv_stream_t* tcp_u, ssize_t siz_i, const uv_buf_t * buf_u) { - u2_utty* uty_u = (u2_utty*)(void*)tcp_u; + u3_utty* uty_u = (u3_utty*)(void*)tcp_u; _term_suck(uty_u, (const c3_y*)buf_u->base, siz_i); free(buf_u->base); } /* _term_main(): return main or console terminal. */ -static u2_utty* +static u3_utty* _term_main() { - u2_utty* uty_u; + u3_utty* uty_u; - for ( uty_u = u2_Host.uty_u; uty_u; uty_u = uty_u->nex_u ) { + for ( uty_u = u3_Host.uty_u; uty_u; uty_u = uty_u->nex_u ) { if ( (uty_u->fid_i != -1) && (uty_u->fid_i <= 2) ) { return uty_u; } } - return u2_Host.uty_u; + return u3_Host.uty_u; } /* _term_ef_get(): terminal by id. */ -static u2_utty* +static u3_utty* _term_ef_get(c3_l tid_l) { if ( 0 != tid_l ) { - u2_utty* uty_u; + u3_utty* uty_u; - for ( uty_u = u2_Host.uty_u; uty_u; uty_u = uty_u->nex_u ) { + for ( uty_u = u3_Host.uty_u; uty_u; uty_u = uty_u->nex_u ) { if ( tid_l == uty_u->tid_l ) { return uty_u; } @@ -945,12 +945,12 @@ _term_ef_get(c3_l tid_l) return _term_main(); } -/* u2_term_get_blew(): return window size [columns rows]. +/* u3_term_get_blew(): return window size [columns rows]. */ -u2_noun -u2_term_get_blew(c3_l tid_l) +u3_noun +u3_term_get_blew(c3_l tid_l) { - u2_utty* uty_u = _term_ef_get(tid_l); + u3_utty* uty_u = _term_ef_get(tid_l); c3_l col_l, row_l; struct winsize siz_u; @@ -967,101 +967,101 @@ u2_term_get_blew(c3_l tid_l) uty_u->tat_u.siz.row_l = row_l; } - return u2nc(col_l, row_l); + return u3nc(col_l, row_l); } -/* u2_term_ef_winc(): window change. Just console right now. +/* u3_term_ef_winc(): window change. Just console right now. */ void -u2_term_ef_winc(void) +u3_term_ef_winc(void) { - u2_noun pax = u2nq(u2_blip, c3__term, '1', u2_nul); + u3_noun pax = u3nq(u3_blip, c3__term, '1', u3_nul); - u2_reck_plan(u2A, pax, u2nc(c3__blew, u2_term_get_blew(1))); + u3_cv_plan(pax, u3nc(c3__blew, u3_term_get_blew(1))); } -/* u2_term_ef_ctlc(): send ^C on console. +/* u3_term_ef_ctlc(): send ^C on console. */ void -u2_term_ef_ctlc(void) +u3_term_ef_ctlc(void) { - u2_noun pax = u2nq(u2_blip, c3__term, '1', u2_nul); + u3_noun pax = u3nq(u3_blip, c3__term, '1', u3_nul); - u2_reck_plan(u2A, pax, u2nt(c3__belt, c3__ctl, 'c')); + u3_cv_plan(pax, u3nt(c3__belt, c3__ctl, 'c')); } -/* u2_term_ef_boil(): initial effects for loaded servers. +/* u3_term_ef_boil(): initial effects for loaded servers. */ void -u2_term_ef_boil(void) +u3_term_ef_boil(void) { { - u2_noun pax = u2nq(u2_blip, c3__term, '1', u2_nul); + u3_noun pax = u3nq(u3_blip, c3__term, '1', u3_nul); - // u2_reck_plan(u2A, u2k(pax), u2nc(c3__init, u2k(u2h(u2A->own)))); - u2_reck_plan(u2A, u2k(pax), u2nc(c3__harm, u2_nul)); - u2_reck_plan(u2A, u2k(pax), u2nc(c3__blew, u2_term_get_blew(1))); - u2_reck_plan(u2A, u2k(pax), u2nc(c3__hail, u2_nul)); + // u3_cv_plan(u3k(pax), u3nc(c3__init, u3k(u3h(u3A->own)))); + u3_cv_plan(u3k(pax), u3nc(c3__harm, u3_nul)); + u3_cv_plan(u3k(pax), u3nc(c3__blew, u3_term_get_blew(1))); + u3_cv_plan(u3k(pax), u3nc(c3__hail, u3_nul)); - u2z(pax); + u3z(pax); } } -/* u2_term_ef_bake(): initial effects for new terminal. +/* u3_term_ef_bake(): initial effects for new terminal. */ void -u2_term_ef_bake(u2_noun fav) +u3_term_ef_bake(u3_noun fav) { - u2_noun pax = u2nq(u2_blip, c3__term, '1', u2_nul); + u3_noun pax = u3nq(u3_blip, c3__term, '1', u3_nul); - u2_reck_plan(u2A, u2k(pax), u2nc(c3__boot, fav)); - u2_reck_plan(u2A, u2k(pax), u2nc(c3__blew, u2_term_get_blew(1))); - u2_reck_plan(u2A, u2k(pax), u2nc(c3__hail, u2_nul)); + u3_cv_plan(u3k(pax), u3nc(c3__boot, fav)); + u3_cv_plan(u3k(pax), u3nc(c3__blew, u3_term_get_blew(1))); + u3_cv_plan(u3k(pax), u3nc(c3__hail, u3_nul)); - u2z(pax); + u3z(pax); } /* _term_ef_blit(): send blit to terminal. */ static void -_term_ef_blit(u2_utty* uty_u, - u2_noun blt) +_term_ef_blit(u3_utty* uty_u, + u3_noun blt) { - switch ( u2h(blt) ) { + switch ( u3h(blt) ) { default: break; case c3__bel: { - if ( u2_no == u2_Host.ops_u.dem ) { + if ( u3_no == u3_Host.ops_u.dem ) { _term_it_write_txt(uty_u, uty_u->ufo_u.out.bel_y); } } break; case c3__clr: { - if ( u2_no == u2_Host.ops_u.dem ) { + if ( u3_no == u3_Host.ops_u.dem ) { _term_it_show_blank(uty_u); _term_it_refresh_line(uty_u); } } break; case c3__hop: { - if ( u2_no == u2_Host.ops_u.dem ) { - _term_it_show_cursor(uty_u, u2t(blt)); + if ( u3_no == u3_Host.ops_u.dem ) { + _term_it_show_cursor(uty_u, u3t(blt)); } } break; case c3__lin: { - u2_noun lin = u2t(blt); - c3_w len_w = u2_ckb_lent(u2k(lin)); + u3_noun lin = u3t(blt); + c3_w len_w = u3_ckb_lent(u3k(lin)); c3_w* lin_w = c3_malloc(4 * len_w); { c3_w i_w; - for ( i_w = 0; u2_nul != lin; i_w++, lin = u2t(lin) ) { - lin_w[i_w] = u2_cr_word(0, u2h(lin)); + for ( i_w = 0; u3_nul != lin; i_w++, lin = u3t(lin) ) { + lin_w[i_w] = u3_cr_word(0, u3h(lin)); } } - if ( u2_no == u2_Host.ops_u.dem ) { + if ( u3_no == u3_Host.ops_u.dem ) { _term_it_show_clear(uty_u); _term_it_show_line(uty_u, lin_w, len_w); } else { @@ -1074,57 +1074,57 @@ _term_ef_blit(u2_utty* uty_u, } break; case c3__sav: { - _term_it_save(u2k(u2h(u2t(blt))), u2k(u2t(u2t(blt)))); + _term_it_save(u3k(u3h(u3t(blt))), u3k(u3t(u3t(blt)))); } break; case c3__sag: { - u2_noun pib = u2k(u2t(u2t(blt))); - u2_noun jam; + u3_noun pib = u3k(u3t(u3t(blt))); + u3_noun jam; fprintf(stderr, "jamming...\r\n"); - jam = u2_cke_jam(pib); + jam = u3_cke_jam(pib); fprintf(stderr, "jammed.\r\n"); - _term_it_save(u2k(u2h(u2t(blt))), jam); + _term_it_save(u3k(u3h(u3t(blt))), jam); } break; } - u2z(blt); + u3z(blt); return; } -/* u2_term_ef_blit(): send %blit list to specific terminal. +/* u3_term_ef_blit(): send %blit list to specific terminal. */ void -u2_term_ef_blit(c3_l tid_l, - u2_noun bls) +u3_term_ef_blit(c3_l tid_l, + u3_noun bls) { - u2_utty* uty_u = _term_ef_get(tid_l); + u3_utty* uty_u = _term_ef_get(tid_l); if ( 0 == uty_u ) { // uL(fprintf(uH, "no terminal %d\n", tid_l)); - // uL(fprintf(uH, "uty_u %p\n", u2_Host.uty_u)); + // uL(fprintf(uH, "uty_u %p\n", u3_Host.uty_u)); - u2z(bls); return; + u3z(bls); return; } { - u2_noun bis = bls; + u3_noun bis = bls; - while ( u2_yes == u2du(bis) ) { - _term_ef_blit(uty_u, u2k(u2h(bis))); - bis = u2t(bis); + while ( u3_yes == u3du(bis) ) { + _term_ef_blit(uty_u, u3k(u3h(bis))); + bis = u3t(bis); } - u2z(bls); + u3z(bls); } } -/* u2_term_io_hija(): hijack console for fprintf, returning FILE*. +/* u3_term_io_hija(): hijack console for fprintf, returning FILE*. */ FILE* -u2_term_io_hija(void) +u3_term_io_hija(void) { - u2_utty* uty_u = _term_main(); + u3_utty* uty_u = _term_main(); if ( uty_u ) { if ( uty_u->fid_i > 2 ) { @@ -1134,7 +1134,7 @@ u2_term_io_hija(void) c3_assert(0); } else { - if ( u2_no == u2_Host.ops_u.dem ) { + if ( u3_no == u3_Host.ops_u.dem ) { if ( 0 != tcsetattr(1, TCSADRAIN, &uty_u->bak_u) ) { c3_assert(!"hija-tcsetattr"); } @@ -1157,12 +1157,12 @@ u2_term_io_hija(void) else return stdout; } -/* u2_term_io_loja(): release console from fprintf. +/* u3_term_io_loja(): release console from fprintf. */ void -u2_term_io_loja(int x) +u3_term_io_loja(int x) { - u2_utty* uty_u = _term_main(); + u3_utty* uty_u = _term_main(); if ( uty_u ) { if ( uty_u->fid_i > 2 ) { @@ -1172,7 +1172,7 @@ u2_term_io_loja(int x) c3_assert(0); } else { - if ( u2_yes == u2_Host.ops_u.dem ) { + if ( u3_yes == u3_Host.ops_u.dem ) { fflush(stdout); } else { diff --git a/v/time.c b/v/time.c index 38f1ffd56..c00badabb 100644 --- a/v/time.c +++ b/v/time.c @@ -18,25 +18,24 @@ #include #include "all.h" -#include "f/coal.h" #include "v/vere.h" -/* u2_time_sec_in(): urbit seconds from unix time. +/* u3_time_sec_in(): urbit seconds from unix time. ** ** Adjust for future leap secs! */ c3_d -u2_time_sec_in(c3_w unx_w) +u3_time_sec_in(c3_w unx_w) { return 0x8000000cce9e0d80ULL + (c3_d)unx_w; } -/* u2_time_sec_out(): unix time from urbit seconds. +/* u3_time_sec_out(): unix time from urbit seconds. ** ** Adjust for future leap secs! */ c3_w -u2_time_sec_out(c3_d urs_d) +u3_time_sec_out(c3_d urs_d) { c3_d adj_d = (urs_d - 0x8000000cce9e0d80ULL); @@ -47,137 +46,137 @@ u2_time_sec_out(c3_d urs_d) return (c3_w)adj_d; } -/* u2_time_fsc_in(): urbit fracto-seconds from unix microseconds. +/* u3_time_fsc_in(): urbit fracto-seconds from unix microseconds. */ c3_d -u2_time_fsc_in(c3_w usc_w) +u3_time_fsc_in(c3_w usc_w) { c3_d usc_d = usc_w; return ((usc_d * 65536ULL) / 1000000ULL) << 48ULL; } -/* u2_time_fsc_out: unix microseconds from urbit fracto-seconds. +/* u3_time_fsc_out: unix microseconds from urbit fracto-seconds. */ c3_w -u2_time_fsc_out(c3_d ufc_d) +u3_time_fsc_out(c3_d ufc_d) { return (c3_w) (((ufc_d >> 48ULL) * 1000000ULL) / 65536ULL); } -/* u2_time_msc_out: unix microseconds from urbit fracto-seconds. +/* u3_time_msc_out: unix microseconds from urbit fracto-seconds. */ c3_w -u2_time_msc_out(c3_d ufc_d) +u3_time_msc_out(c3_d ufc_d) { return (c3_w) (((ufc_d >> 48ULL) * 1000ULL) / 65536ULL); } -/* u2_time_in_tv(): urbit time from struct timeval. +/* u3_time_in_tv(): urbit time from struct timeval. */ -u2_atom -u2_time_in_tv(struct timeval* tim_tv) +u3_atom +u3_time_in_tv(struct timeval* tim_tv) { c3_w unx_w = tim_tv->tv_sec; c3_w usc_w = tim_tv->tv_usec; c3_d cub_d[2]; - cub_d[0] = u2_time_fsc_in(usc_w); - cub_d[1] = u2_time_sec_in(unx_w); + cub_d[0] = u3_time_fsc_in(usc_w); + cub_d[1] = u3_time_sec_in(unx_w); - return u2_ci_chubs(2, cub_d); + return u3_ci_chubs(2, cub_d); } -/* u2_time_out_tv(): struct timeval from urbit time. +/* u3_time_out_tv(): struct timeval from urbit time. */ void -u2_time_out_tv(struct timeval* tim_tv, u2_noun now) +u3_time_out_tv(struct timeval* tim_tv, u3_noun now) { - c3_d ufc_d = u2_cr_chub(0, now); - c3_d urs_d = u2_cr_chub(1, now); + c3_d ufc_d = u3_cr_chub(0, now); + c3_d urs_d = u3_cr_chub(1, now); - tim_tv->tv_sec = u2_time_sec_out(urs_d); - tim_tv->tv_usec = u2_time_fsc_out(ufc_d); + tim_tv->tv_sec = u3_time_sec_out(urs_d); + tim_tv->tv_usec = u3_time_fsc_out(ufc_d); - u2z(now); + u3z(now); } -/* u2_time_in_ts(): urbit time from struct timespec. +/* u3_time_in_ts(): urbit time from struct timespec. */ -u2_atom -u2_time_in_ts(struct timespec* tim_ts) +u3_atom +u3_time_in_ts(struct timespec* tim_ts) { struct timeval tim_tv; tim_tv.tv_sec = tim_ts->tv_sec; tim_tv.tv_usec = (tim_ts->tv_nsec / 1000); - return u2_time_in_tv(&tim_tv); + return u3_time_in_tv(&tim_tv); } #if defined(U2_OS_linux) -/* u2_time_t_in_ts(): urbit time from time_t. +/* u3_time_t_in_ts(): urbit time from time_t. */ -u2_atom -u2_time_t_in_ts(time_t tim) +u3_atom +u3_time_t_in_ts(time_t tim) { struct timeval tim_tv; tim_tv.tv_sec = tim; tim_tv.tv_usec = 0; - return u2_time_in_tv(&tim_tv); + return u3_time_in_tv(&tim_tv); } #endif // defined(U2_OS_linux) -/* u2_time_out_ts(): struct timespec from urbit time. +/* u3_time_out_ts(): struct timespec from urbit time. */ void -u2_time_out_ts(struct timespec* tim_ts, u2_noun now) +u3_time_out_ts(struct timespec* tim_ts, u3_noun now) { struct timeval tim_tv; - u2_time_out_tv(&tim_tv, now); + u3_time_out_tv(&tim_tv, now); tim_ts->tv_sec = tim_tv.tv_sec; tim_ts->tv_nsec = (tim_tv.tv_usec * 1000); } -/* u2_time_gap_ms(): (wen - now) in ms. +/* u3_time_gap_ms(): (wen - now) in ms. */ c3_d -u2_time_gap_ms(u2_noun now, u2_noun wen) +u3_time_gap_ms(u3_noun now, u3_noun wen) { - if ( u2_no == u2_cka_gth(u2k(wen), u2k(now)) ) { - u2z(wen); u2z(now); + if ( u3_no == u3_cka_gth(u3k(wen), u3k(now)) ) { + u3z(wen); u3z(now); return 0ULL; } else { - u2_noun dif = u2_cka_sub(wen, now); - c3_d fsc_d = u2_cr_chub(0, dif); - c3_d sec_d = u2_cr_chub(1, dif); + u3_noun dif = u3_cka_sub(wen, now); + c3_d fsc_d = u3_cr_chub(0, dif); + c3_d sec_d = u3_cr_chub(1, dif); - u2z(dif); - return (sec_d * 1000ULL) + u2_time_msc_out(fsc_d); + u3z(dif); + return (sec_d * 1000ULL) + u3_time_msc_out(fsc_d); } } -/* u2_time_gap_double(): (wen - now) in libev resolution. +/* u3_time_gap_double(): (wen - now) in libev resolution. */ double -u2_time_gap_double(u2_noun now, u2_noun wen) +u3_time_gap_double(u3_noun now, u3_noun wen) { mpz_t now_mp, wen_mp, dif_mp; double sec_g = (((double)(1ULL << 32ULL)) * ((double)(1ULL << 32ULL))); double gap_g, dif_g; - u2_cr_mp(now_mp, now); - u2_cr_mp(wen_mp, wen); + u3_cr_mp(now_mp, now); + u3_cr_mp(wen_mp, wen); mpz_init(dif_mp); mpz_sub(dif_mp, wen_mp, now_mp); - u2z(now); - u2z(wen); + u3z(now); + u3z(wen); dif_g = mpz_get_d(dif_mp) / sec_g; gap_g = (dif_g > 0.0) ? dif_g : 0.0; diff --git a/v/unix.c b/v/unix.c index 3d696cd8c..a991f3126 100644 --- a/v/unix.c +++ b/v/unix.c @@ -18,7 +18,6 @@ #include #include "all.h" -#include "f/coal.h" #include "v/vere.h" /* _unix_down(): descend path. @@ -79,10 +78,10 @@ _unix_unlink(c3_c* pax_c) } } -/* u2_unix_acquire(): acquire a lockfile, killing anything that holds it. +/* u3_unix_acquire(): acquire a lockfile, killing anything that holds it. */ void -u2_unix_acquire(c3_c* pax_c) +u3_unix_acquire(c3_c* pax_c) { c3_c* paf_c = _unix_down(pax_c, ".vere.lock"); c3_w pid_w; @@ -145,10 +144,10 @@ u2_unix_acquire(c3_c* pax_c) free(paf_c); } -/* u2_unix_release(): release a lockfile. +/* u3_unix_release(): release a lockfile. */ void -u2_unix_release(c3_c* pax_c) +u3_unix_release(c3_c* pax_c) { c3_c* paf_c = _unix_down(pax_c, ".vere.lock"); @@ -159,17 +158,17 @@ u2_unix_release(c3_c* pax_c) /* _unix_dir_dry(): recursively dry a directory. */ static void -_unix_dir_dry(u2_udir* dir_u) +_unix_dir_dry(u3_udir* dir_u) { - u2_udir* dis_u; - u2_ufil* fil_u; + u3_udir* dis_u; + u3_ufil* fil_u; - dir_u->dry = u2_yes; + dir_u->dry = u3_yes; for ( dis_u = dir_u->dis_u; dis_u; dis_u = dis_u->nex_u ) { _unix_dir_dry(dis_u); } for ( fil_u = dir_u->fil_u; fil_u; fil_u = fil_u->nex_u ) { - fil_u->dry = u2_yes; + fil_u->dry = u3_yes; } } @@ -190,23 +189,23 @@ _unix_fs_event_cb(uv_fs_event_t* was_u, // * this is what we pass into libuv up top // * this is what we get out of libuv down below // * thus a cast is cool - u2_unod* nod_u = (u2_unod*) was_u; + u3_unod* nod_u = (u3_unod*) was_u; #ifdef SYNCLOG - c3_w slot = u2_Host.unx_u.lot_w++ % 1024; - free(u2_Host.unx_u.sylo[slot].pax_c); - u2_Host.unx_u.sylo[slot].pax_c = 0; - u2_Host.unx_u.sylo[slot].unx = u2_yes; - u2_Host.unx_u.sylo[slot].wer_m = c3_s4('u','v','s','y'); - u2_Host.unx_u.sylo[slot].wot_m = 0; - u2_Host.unx_u.sylo[slot].pax_c = strdup(nod_u->pax_c); + c3_w slot = u3_Host.unx_u.lot_w++ % 1024; + free(u3_Host.unx_u.sylo[slot].pax_c); + u3_Host.unx_u.sylo[slot].pax_c = 0; + u3_Host.unx_u.sylo[slot].unx = u3_yes; + u3_Host.unx_u.sylo[slot].wer_m = c3_s4('u','v','s','y'); + u3_Host.unx_u.sylo[slot].wot_m = 0; + u3_Host.unx_u.sylo[slot].pax_c = strdup(nod_u->pax_c); #endif { while ( nod_u ) { - nod_u->dry = u2_no; - nod_u = (u2_unod*) nod_u->par_u; + nod_u->dry = u3_no; + nod_u = (u3_unod*) nod_u->par_u; } } } @@ -214,15 +213,15 @@ _unix_fs_event_cb(uv_fs_event_t* was_u, /* _unix_file_watch(): create file tracker (from filesystem) */ static void -_unix_file_watch(u2_ufil* fil_u, - u2_udir* dir_u, +_unix_file_watch(u3_ufil* fil_u, + u3_udir* dir_u, c3_c* pax_c, mpz_t mod_mp) { // (1) build data structure // - fil_u->non = u2_no; - fil_u->dry = u2_no; + fil_u->non = u3_no; + fil_u->dry = u3_no; fil_u->pax_c = pax_c; { c3_c* dot_c = strrchr(pax_c, '.'); @@ -241,7 +240,7 @@ _unix_file_watch(u2_ufil* fil_u, // (2) stuff data structure into libuv // - c3_w ret_w = uv_fs_event_init(u2L, // loop + c3_w ret_w = uv_fs_event_init(u3L, // loop &fil_u->was_u // uv_fs_event_t ); if (0 != ret_w){ @@ -265,31 +264,31 @@ _unix_file_watch(u2_ufil* fil_u, /* _unix_file_form(): form a filename path downward. */ static c3_c* -_unix_file_form(u2_udir* dir_u, - u2_noun pre, - u2_bean ket, - u2_noun ext) +_unix_file_form(u3_udir* dir_u, + u3_noun pre, + u3_bean ket, + u3_noun ext) { - c3_c* pre_c = u2_cr_string(pre); - c3_c* ext_c = u2_cr_string(ext); + c3_c* pre_c = u3_cr_string(pre); + c3_c* ext_c = u3_cr_string(ext); c3_w pax_w = strlen(dir_u->pax_c); c3_w pre_w = strlen(pre_c); c3_w ext_w = strlen(ext_c); - c3_w ket_w = (u2_yes == ket) ? 1 : 0; + c3_w ket_w = (u3_yes == ket) ? 1 : 0; c3_c* pax_c = c3_malloc(pax_w + 1 + pre_w + 1 + ket_w + ext_w + 1); strncpy(pax_c, dir_u->pax_c, pax_w); pax_c[pax_w] = '/'; strncpy(pax_c + pax_w + 1, pre_c, pre_w); pax_c[pax_w + 1 + pre_w] = '.'; - if ( u2_yes == ket ) { + if ( u3_yes == ket ) { pax_c[pax_w + 1 + pre_w + 1] = '^'; } strncpy(pax_c + pax_w + 1 + pre_w + 1 + ket_w, ext_c, ext_w); pax_c[pax_w + 1 + pre_w + 1 + ket_w + ext_w] = '\0'; free(pre_c); free(ext_c); - u2z(pre); u2z(ext); + u3z(pre); u3z(ext); return pax_c; } @@ -297,12 +296,12 @@ _unix_file_form(u2_udir* dir_u, /* _unix_dir_watch(): instantiate directory tracker. */ static void -_unix_dir_watch(u2_udir* dir_u, u2_udir* par_u, c3_c* pax_c) +_unix_dir_watch(u3_udir* dir_u, u3_udir* par_u, c3_c* pax_c) { // (1) build data structure // - dir_u->yes = u2_yes; - dir_u->dry = u2_no; + dir_u->yes = u3_yes; + dir_u->dry = u3_no; dir_u->pax_c = pax_c; dir_u->par_u = par_u; dir_u->dis_u = 0; @@ -312,7 +311,7 @@ _unix_dir_watch(u2_udir* dir_u, u2_udir* par_u, c3_c* pax_c) // (2) stuff data structure into libuv // - c3_w ret_w = uv_fs_event_init(u2L, &dir_u->was_u ); + c3_w ret_w = uv_fs_event_init(u3L, &dir_u->was_u ); if (0 != ret_w){ uL(fprintf(uH, "event init: %s\n", uv_strerror(ret_w))); c3_assert(0); @@ -334,9 +333,9 @@ _unix_dir_watch(u2_udir* dir_u, u2_udir* par_u, c3_c* pax_c) /* _unix_dir_forge: instantiate directory tracker (and make directory). */ static void -_unix_dir_forge(u2_udir* dir_u, u2_udir* par_u, u2_noun tet) +_unix_dir_forge(u3_udir* dir_u, u3_udir* par_u, u3_noun tet) { - c3_c* tet_c = u2_cr_string(tet); + c3_c* tet_c = u3_cr_string(tet); c3_w pax_w = strlen(par_u->pax_c); c3_w tet_w = strlen(tet_c); c3_c* pax_c = c3_malloc(pax_w + 1 + tet_w + 1); @@ -347,7 +346,7 @@ _unix_dir_forge(u2_udir* dir_u, u2_udir* par_u, u2_noun tet) pax_c[pax_w + tet_w + 1] = '\0'; free(tet_c); - u2z(tet); + u3z(tet); _unix_mkdir(pax_c); _unix_dir_watch(dir_u, par_u, pax_c); @@ -358,7 +357,7 @@ _unix_dir_forge(u2_udir* dir_u, u2_udir* par_u, u2_noun tet) static void _unix_file_done(uv_handle_t* was_u) { - u2_ufil* fil_u = (void*) was_u; + u3_ufil* fil_u = (void*) was_u; // uL(fprintf(uH, "file: dun: %s\n", fil_u->pax_c)); free(fil_u->pax_c); @@ -369,7 +368,7 @@ _unix_file_done(uv_handle_t* was_u) /* _unix_file_free(): free (within) file tracker. */ static void -_unix_file_free(u2_ufil* fil_u) +_unix_file_free(u3_ufil* fil_u) { // uL(fprintf(uH, "file: free: %s\n", fil_u->pax_c)); uv_close((uv_handle_t*)&fil_u->was_u, _unix_file_done); @@ -379,17 +378,17 @@ _unix_file_free(u2_ufil* fil_u) /* _unix_file_sane(): sanity check file. */ static void -_unix_file_sane(u2_ufil* fil_u) +_unix_file_sane(u3_ufil* fil_u) { } /* _unix_dir_sane(): sanity check directory. */ static void -_unix_dir_sane(u2_udir* dir_u) +_unix_dir_sane(u3_udir* dir_u) { - u2_udir* dis_u; - u2_ufil* fil_u; + u3_udir* dis_u; + u3_ufil* fil_u; for ( dis_u = dir_u->dis_u; dis_u; dis_u = dis_u->nex_u ) { _unix_dir_sane(dis_u); @@ -402,20 +401,20 @@ _unix_dir_sane(u2_udir* dir_u) /* _unix_dir_free(): free (within) directory tracker. */ -static void _unix_dir_free(u2_udir* dir_u); +static void _unix_dir_free(u3_udir* dir_u); static void _unix_dir_done(uv_handle_t* was_u) { - u2_udir* dir_u = (void*) was_u; + u3_udir* dir_u = (void*) was_u; while ( dir_u->dis_u ) { - u2_udir* nex_u = dir_u->dis_u->nex_u; + u3_udir* nex_u = dir_u->dis_u->nex_u; _unix_dir_free(dir_u->dis_u); dir_u->dis_u = nex_u; } while ( dir_u->fil_u ) { - u2_ufil* nex_u = dir_u->fil_u->nex_u; + u3_ufil* nex_u = dir_u->fil_u->nex_u; _unix_file_free(dir_u->fil_u); dir_u->fil_u = nex_u; @@ -425,7 +424,7 @@ _unix_dir_done(uv_handle_t* was_u) free(dir_u); } static void -_unix_dir_free(u2_udir* dir_u) +_unix_dir_free(u3_udir* dir_u) { uv_close((uv_handle_t*)&dir_u->was_u, _unix_dir_done); } @@ -433,16 +432,16 @@ _unix_dir_free(u2_udir* dir_u) #if 0 /* _unix_file_update(): update file, true if plausibly changed. */ -static u2_bean -_unix_file_update(u2_ufil* fil_u, mpz_t mod_mp) +static u3_bean +_unix_file_update(u3_ufil* fil_u, mpz_t mod_mp) { if ( 0 == mpz_cmp(mod_mp, fil_u->mod_mp) ) { - return u2_no; + return u3_no; } else { mpz_clear(fil_u->mod_mp); mpz_init_set(fil_u->mod_mp, mod_mp); - return u2_yes; + return u3_yes; } } #endif @@ -450,27 +449,27 @@ _unix_file_update(u2_ufil* fil_u, mpz_t mod_mp) /* _unix_dir_update(): update directory. */ static void -_unix_dir_update(u2_udir* dir_u, DIR* rid_u) +_unix_dir_update(u3_udir* dir_u, DIR* rid_u) { - if ( u2_yes == dir_u->dry ) { + if ( u3_yes == dir_u->dry ) { return; } else { // Update all wet subdirectories. // - u2_udir** dis_u; - u2_ufil** fil_u; + u3_udir** dis_u; + u3_ufil** fil_u; for ( dis_u = &(dir_u->dis_u); *dis_u; ) { - if ( u2_yes == (*dis_u)->dry ) { + if ( u3_yes == (*dis_u)->dry ) { dis_u = &(*dis_u)->nex_u; } else { DIR* red_u = opendir((*dis_u)->pax_c); if ( 0 == red_u ) { - u2_udir* ded_u = *dis_u; - u2_udir* nex_u = ded_u->nex_u; + u3_udir* ded_u = *dis_u; + u3_udir* nex_u = ded_u->nex_u; // uL(fprintf(uH, "removed directory %s\n", ded_u->pax_c)); _unix_dir_free(ded_u); @@ -489,7 +488,7 @@ _unix_dir_update(u2_udir* dir_u, DIR* rid_u) // Check all wet files to see if they need deleting. // for ( fil_u = &(dir_u->fil_u); *fil_u; ) { - if ( u2_yes == (*fil_u)->dry ) { + if ( u3_yes == (*fil_u)->dry ) { fil_u = &(*fil_u)->nex_u; } else { @@ -498,8 +497,8 @@ _unix_dir_update(u2_udir* dir_u, DIR* rid_u) if ( -1 == stat((*fil_u)->pax_c, &buf_u) || !(S_IFREG & buf_u.st_mode) ) { - u2_ufil* ded_u = *fil_u; - u2_ufil* nex_u = ded_u->nex_u; + u3_ufil* ded_u = *fil_u; + u3_ufil* nex_u = ded_u->nex_u; // uL(fprintf(uH, "removed file %s\n", ded_u->pax_c)); _unix_file_free(ded_u); @@ -540,7 +539,7 @@ _unix_dir_update(u2_udir* dir_u, DIR* rid_u) else { if ( !S_ISDIR(buf_u.st_mode) ) { mpz_t mod_mp; - u2_ufil* fil_u; + u3_ufil* fil_u; if ( ( NULL == strrchr(out_u->d_name, '.')) || ( '~' == out_u->d_name[strlen(out_u->d_name) - 1] ) @@ -549,10 +548,10 @@ _unix_dir_update(u2_udir* dir_u, DIR* rid_u) } { - u2_noun mod = c3_stat_mtime(&buf_u); + u3_noun mod = c3_stat_mtime(&buf_u); - u2_cr_mp(mod_mp, mod); - u2z(mod); + u3_cr_mp(mod_mp, mod); + u3z(mod); } for ( fil_u = dir_u->fil_u; fil_u; fil_u = fil_u->nex_u ) { if ( !strcmp(pax_c, fil_u->pax_c) ) { @@ -560,7 +559,7 @@ _unix_dir_update(u2_udir* dir_u, DIR* rid_u) } } if ( !fil_u ) { - fil_u = c3_malloc(sizeof(u2_ufil)); + fil_u = c3_malloc(sizeof(u3_ufil)); // uL(fprintf(uH, "found file %s\n", pax_c)); _unix_file_watch(fil_u, dir_u, pax_c, mod_mp); @@ -571,7 +570,7 @@ _unix_dir_update(u2_udir* dir_u, DIR* rid_u) mpz_clear(mod_mp); } else { - u2_udir* dis_u; + u3_udir* dis_u; for ( dis_u = dir_u->dis_u; dis_u; dis_u = dis_u->nex_u ) { if ( !strcmp(pax_c, dis_u->pax_c) ) { @@ -580,7 +579,7 @@ _unix_dir_update(u2_udir* dir_u, DIR* rid_u) } if ( !dis_u ) { DIR* red_u = _unix_opendir(pax_c); - dis_u = c3_malloc(sizeof(u2_udir)); + dis_u = c3_malloc(sizeof(u3_udir)); // uL(fprintf(uH, "found directory %s\n", pax_c)); _unix_dir_watch(dis_u, dir_u, pax_c); @@ -602,7 +601,7 @@ _unix_dir_update(u2_udir* dir_u, DIR* rid_u) /* unix_load(): load a file. */ -static u2_noun +static u3_noun _unix_load(c3_c* pax_c) { struct stat buf_u; @@ -629,7 +628,7 @@ _unix_load(c3_c* pax_c) return 0; } else { - u2_noun pad = u2_ci_bytes(fln_w, (c3_y *)pad_y); + u3_noun pad = u3_ci_bytes(fln_w, (c3_y *)pad_y); free(pad_y); return pad; @@ -639,7 +638,7 @@ _unix_load(c3_c* pax_c) /* unix_save(): save a file. */ static void -_unix_save(c3_c* pax_c, u2_atom oat) +_unix_save(c3_c* pax_c, u3_atom oat) { c3_i fid_i = open(pax_c, O_WRONLY | O_CREAT | O_TRUNC, 0666); c3_w fln_w, rit_w; @@ -647,13 +646,13 @@ _unix_save(c3_c* pax_c, u2_atom oat) if ( fid_i < 0 ) { uL(fprintf(uH, "%s: %s\n", pax_c, strerror(errno))); - u2_cm_bail(c3__fail); + u3_cm_bail(c3__fail); } - fln_w = u2_met(3, oat); + fln_w = u3_cr_met(3, oat); oat_y = c3_malloc(fln_w); - u2_cr_bytes(0, fln_w, oat_y, oat); - u2z(oat); + u3_cr_bytes(0, fln_w, oat_y, oat); + u3z(oat); rit_w = write(fid_i, oat_y, fln_w); if ( rit_w != fln_w ) { @@ -667,267 +666,266 @@ _unix_save(c3_c* pax_c, u2_atom oat) /* _unix_file_load(): load a file by watcher. */ -static u2_noun -_unix_file_load(u2_ufil* fil_u) +static u3_noun +_unix_file_load(u3_ufil* fil_u) { - u2_noun raw = _unix_load(fil_u->pax_c); + u3_noun raw = _unix_load(fil_u->pax_c); if ( (0 == raw) || ('^' != fil_u->dot_c[1]) ) { return raw; } - else return u2_cke_cue(raw); + else return u3_cke_cue(raw); } /* _unix_dir_name(): directory name. */ -static u2_noun -_unix_dir_name(u2_udir* dir_u) +static u3_noun +_unix_dir_name(u3_udir* dir_u) { c3_w pel_w = strlen(dir_u->par_u->pax_c); c3_c* pax_c = dir_u->pax_c + pel_w + 1; c3_c* fas_c = strchr(pax_c, '/'); - return fas_c ? u2_ci_bytes((fas_c - pax_c), (c3_y*) pax_c) - : u2_ci_string(pax_c); + return fas_c ? u3_ci_bytes((fas_c - pax_c), (c3_y*) pax_c) + : u3_ci_string(pax_c); } /* _unix_file_tame(): file name/extension for toplevel. */ -static u2_noun -_unix_file_tame(u2_ufil* fil_u) +static u3_noun +_unix_file_tame(u3_ufil* fil_u) { c3_c* fas_c = strrchr(fil_u->pax_c, '/'); c3_c* pax_c = fil_u->pax_c + (fas_c-fil_u->pax_c) + 1; if ( !fil_u->dot_c ) { - return u2_none; + return u3_none; } else { c3_c* ext_c = fil_u->dot_c + 1; c3_w nam_w = fil_u->dot_c - pax_c; - return u2nc(u2_ci_bytes(nam_w, (c3_y*)pax_c), - u2_ci_string(ext_c)); + return u3nc(u3_ci_bytes(nam_w, (c3_y*)pax_c), + u3_ci_string(ext_c)); } } /* _unix_file_name(): file name/extension. */ -static u2_noun -_unix_file_name(u2_ufil* fil_u) +static u3_noun +_unix_file_name(u3_ufil* fil_u) { c3_w pel_w = strlen(fil_u->par_u->pax_c); c3_c* pax_c = fil_u->pax_c + pel_w + 1; if ( !fil_u->dot_c ) { - return u2_ci_string(pax_c); + return u3_ci_string(pax_c); } else { c3_c* ext_c = fil_u->dot_c + 1; ext_c = (*ext_c == '^') ? (ext_c + 1) : ext_c; - return u2nc(u2_ci_bytes((fil_u->dot_c - pax_c), (c3_y*)pax_c), - u2_ci_string(ext_c)); + return u3nc(u3_ci_bytes((fil_u->dot_c - pax_c), (c3_y*)pax_c), + u3_ci_string(ext_c)); } } /* _unix_dir_ankh_file(): process a file for ankh. */ -static u2_noun -_unix_dir_ankh_file(u2_noun pam, u2_noun wib, u2_noun baw, u2_noun woz) +static u3_noun +_unix_dir_ankh_file(u3_noun pam, u3_noun wib, u3_noun baw, u3_noun woz) { - u2_weak ole; - if ( u2_no == u2du(wib) ) { - ole = u2_ckd_by_get(u2k(pam), u2k(wib)); + u3_weak ole; + if ( u3_no == u3du(wib) ) { + ole = u3_ckdb_get(u3k(pam), u3k(wib)); - if ( u2_none == ole ) { - ole = u2_do("cosh", u2nt(0, woz, u2_nul)); + if ( u3_none == ole ) { + ole = u3_do("cosh", u3nt(0, woz, u3_nul)); } else { - u2_noun elo; + u3_noun elo; - elo = u2_do("cosh", u2nt(0, woz, u2k(u2t(u2t(ole))))); - u2z(ole); + elo = u3_do("cosh", u3nt(0, woz, u3k(u3t(u3t(ole))))); + u3z(ole); ole = elo; } - pam = u2_ckd_by_put(pam, wib, ole); + pam = u3_ckdb_put(pam, wib, ole); } else { - u2_noun fid = u2h(wib); - u2_noun har = u2t(wib); + u3_noun fid = u3h(wib); + u3_noun har = u3t(wib); - ole = u2_ckd_by_get(u2k(pam), u2k(fid)); + ole = u3_ckdb_get(u3k(pam), u3k(fid)); - if ( u2_none == ole ) { - ole = u2nt - (0, u2_nul, u2_ckd_by_put(u2_nul, - u2k(har), - u2_do("cosh", u2nt(0, woz, u2_nul)))); - ole = u2_do("cosh", ole); + if ( u3_none == ole ) { + ole = u3nt + (0, u3_nul, u3_ckdb_put(u3_nul, + u3k(har), + u3_do("cosh", u3nt(0, woz, u3_nul)))); + ole = u3_do("cosh", ole); } else { - u2_noun roo = u2t(u2t(ole)); - u2_weak tup = u2_ckd_by_get(u2k(roo), u2k(har)); - u2_noun oor, elo; + u3_noun roo = u3t(u3t(ole)); + u3_weak tup = u3_ckdb_get(u3k(roo), u3k(har)); + u3_noun oor, elo; - if ( u2_none == tup ) { - tup = u2_do("cosh", u2nt(0, woz, u2_nul)); + if ( u3_none == tup ) { + tup = u3_do("cosh", u3nt(0, woz, u3_nul)); } else { - u2_noun upt; + u3_noun upt; - upt = u2_do("cosh", u2nt(0, woz, u2k(u2t(u2t(tup))))); - u2z(tup); + upt = u3_do("cosh", u3nt(0, woz, u3k(u3t(u3t(tup))))); + u3z(tup); tup = upt; } - oor = u2_ckd_by_put(u2k(roo), u2k(har), tup); - elo = u2_do("cosh", u2nt(0, u2k(u2h(u2t(ole))), oor)); + oor = u3_ckdb_put(u3k(roo), u3k(har), tup); + elo = u3_do("cosh", u3nt(0, u3k(u3h(u3t(ole))), oor)); - u2z(ole); ole = elo; + u3z(ole); ole = elo; } - pam = u2_ckd_by_put(pam, u2k(fid), ole); - u2z(wib); + pam = u3_ckdb_put(pam, u3k(fid), ole); + u3z(wib); } return pam; } /* _unix_dir_ankh(): resolve directory to new style ankh. */ -static u2_noun -_unix_dir_ankh(u2_udir* dir_u) +static u3_noun +_unix_dir_ankh(u3_udir* dir_u) { - u2_udir* dis_u; - u2_ufil* fil_u; - u2_noun pam = u2_nul; + u3_udir* dis_u; + u3_ufil* fil_u; + u3_noun pam = u3_nul; for ( dis_u = dir_u->dis_u; dis_u; dis_u = dis_u->nex_u ) { - u2_noun pre = _unix_dir_name(dis_u); - u2_noun ank = _unix_dir_ankh(dis_u); + u3_noun pre = _unix_dir_name(dis_u); + u3_noun ank = _unix_dir_ankh(dis_u); - // uL(fprintf(uH, "dir %s\n", u2_cr_string(pre))); - if ( 0 != u2h(ank) ) { - pam = u2_ckd_by_put(pam, pre, ank); + // uL(fprintf(uH, "dir %s\n", u3_cr_string(pre))); + if ( 0 != u3h(ank) ) { + pam = u3_ckdb_put(pam, pre, ank); } } if ( !dir_u->par_u->par_u ) { // toplevel for ( fil_u = dir_u->par_u->fil_u; fil_u; fil_u = fil_u->nex_u ) { // uL(fprintf(uH, "top %s\n", fil_u->pax_c)); - u2_noun wib = _unix_file_tame(fil_u); - if ( u2_none == wib ) continue; - u2_noun dur = _unix_dir_name(dir_u); - if ( u2_no == u2_sing(dur, u2h(wib)) ) { // wrong desk - u2z(wib); u2z(dur); + u3_noun wib = _unix_file_tame(fil_u); + if ( u3_none == wib ) continue; + u3_noun dur = _unix_dir_name(dir_u); + if ( u3_no == u3_cr_sing(dur, u3h(wib)) ) { // wrong desk + u3z(wib); u3z(dur); continue; } - u2_noun baw = _unix_file_load(fil_u); - u2_noun woz = u2nt(u2_nul, u2_do("sham", u2k(baw)), baw); - u2z(dur); - pam = _unix_dir_ankh_file(pam, u2k(u2t(wib)), baw, woz); - u2z(wib); + u3_noun baw = _unix_file_load(fil_u); + u3_noun woz = u3nt(u3_nul, u3_do("sham", u3k(baw)), baw); + u3z(dur); + pam = _unix_dir_ankh_file(pam, u3k(u3t(wib)), baw, woz); + u3z(wib); } } for ( fil_u = dir_u->fil_u; fil_u; fil_u = fil_u->nex_u ) { - u2_noun wib = _unix_file_name(fil_u); - u2_noun baw = _unix_file_load(fil_u); - u2_noun woz = u2nt(u2_nul, u2_do("sham", u2k(baw)), baw); + u3_noun wib = _unix_file_name(fil_u); + u3_noun baw = _unix_file_load(fil_u); + u3_noun woz = u3nt(u3_nul, u3_do("sham", u3k(baw)), baw); pam = _unix_dir_ankh_file(pam, wib, baw, woz); } - return u2_do("cosh", u2nt(0, u2_nul, pam)); + return u3_do("cosh", u3nt(0, u3_nul, pam)); } /* _unix_desk_peek(): peek for ankh. */ -static u2_noun -_unix_desk_peek(u2_noun hox, - u2_noun syd, - u2_noun lok) +static u3_noun +_unix_desk_peek(u3_noun hox, + u3_noun syd, + u3_noun lok) { - u2_noun cay; + u3_noun cay; - cay = u2_reck_prick - (u2A, u2nc(c3_s2('c','z'), u2nq(hox, syd, lok, u2_nul))); + cay = u3_cv_peek(u3nc(c3_s2('c','z'), u3nq(hox, syd, lok, u3_nul))); - if ( u2_nul == cay ) { - return u2nt(0, u2_nul, u2_nul); + if ( u3_nul == cay ) { + return u3nt(0, u3_nul, u3_nul); } else { - u2_noun ank = u2k(u2t(cay)); + u3_noun ank = u3k(u3t(cay)); - u2z(cay); return ank; + u3z(cay); return ank; } } #if 0 -/* _unix_ankh_sing_map(): compare ankh maps for u2_ankh_sing(). +/* _unix_ankh_sing_map(): compare ankh maps for u3_ankh_sing(). */ -static u2_bean _unix_ankh_sing_in(u2_noun, u2_noun); +static u3_bean _unix_ankh_sing_in(u3_noun, u3_noun); -static u2_bean -_unix_ankh_sing_map(u2_noun mun, u2_noun mur) // retain +static u3_bean +_unix_ankh_sing_map(u3_noun mun, u3_noun mur) // retain { - u2_noun n_mun, l_mun, r_mun; - u2_noun n_mur, l_mur, r_mur; + u3_noun n_mun, l_mun, r_mun; + u3_noun n_mur, l_mur, r_mur; - if ( (u2_nul == mun) && (u2_nul == mur) ) { return u2_yes; } - if ( (u2_nul == mun) || (u2_nul == mur) ) { return u2_no; } + if ( (u3_nul == mun) && (u3_nul == mur) ) { return u3_yes; } + if ( (u3_nul == mun) || (u3_nul == mur) ) { return u3_no; } - u2_cx_trel(mun, &n_mun, &l_mun, &r_mun); - u2_cx_trel(mur, &n_mur, &l_mur, &r_mur); + u3_cx_trel(mun, &n_mun, &l_mun, &r_mun); + u3_cx_trel(mur, &n_mur, &l_mur, &r_mur); - if ( (u2_no == (u2_sing(u2h(n_mun), u2h(n_mur)))) || - (u2_no == _unix_ankh_sing_in(u2t(n_mun), u2t(n_mur))) || - (u2_no == _unix_ankh_sing_map(l_mun, l_mur)) || - (u2_no == _unix_ankh_sing_map(r_mun, r_mur)) ) + if ( (u3_no == (u3_cr_sing(u3h(n_mun), u3h(n_mur)))) || + (u3_no == _unix_ankh_sing_in(u3t(n_mun), u3t(n_mur))) || + (u3_no == _unix_ankh_sing_map(l_mun, l_mur)) || + (u3_no == _unix_ankh_sing_map(r_mun, r_mur)) ) { - return u2_no; - } else return u2_yes; + return u3_no; + } else return u3_yes; } /* _unix_node_sing(): test node equality. */ -static u2_bean -_unix_node_sing(u2_noun xud, u2_noun bud) +static u3_bean +_unix_node_sing(u3_noun xud, u3_noun bud) { - if ( (u2_nul == xud) && (u2_nul == bud) ) { return u2_yes; } - if ( (u2_nul == xud) || (u2_nul == bud) ) { return u2_no; } + if ( (u3_nul == xud) && (u3_nul == bud) ) { return u3_yes; } + if ( (u3_nul == xud) || (u3_nul == bud) ) { return u3_no; } - return u2_sing(u2t(u2t(xud)), u2t(u2t(bud))); + return u3_cr_sing(u3t(u3t(xud)), u3t(u3t(bud))); } /* _unix_ankh_sing_in(): stupid ankh test which ignores broken hash. */ -static u2_bean -_unix_ankh_sing_in(u2_noun xun, u2_noun bur) // retain +static u3_bean +_unix_ankh_sing_in(u3_noun xun, u3_noun bur) // retain { - u2_noun p_xun, q_xun, r_xun; - u2_noun p_bur, q_bur, r_bur; + u3_noun p_xun, q_xun, r_xun; + u3_noun p_bur, q_bur, r_bur; - u2_cx_trel(xun, &p_xun, &q_xun, &r_xun); - u2_cx_trel(bur, &p_bur, &q_bur, &r_bur); + u3_cx_trel(xun, &p_xun, &q_xun, &r_xun); + u3_cx_trel(bur, &p_bur, &q_bur, &r_bur); - if ( u2_no == _unix_node_sing(q_xun, q_bur) ) { - return u2_no; + if ( u3_no == _unix_node_sing(q_xun, q_bur) ) { + return u3_no; } return _unix_ankh_sing_map(r_xun, r_bur); } /* _unix_ankh_sing(): full ankh compare. */ -static u2_bean -_unix_ankh_sing(u2_noun xun, u2_noun bur) // retain +static u3_bean +_unix_ankh_sing(u3_noun xun, u3_noun bur) // retain { - if ( u2_yes == u2_sing(xun, bur) ) { - return u2_yes; + if ( u3_yes == u3_cr_sing(xun, bur) ) { + return u3_yes; } else { - if ( u2_no == _unix_ankh_sing_in(xun, bur) ) { - // fprintf(stderr, "uas: no, no (%x, %x)\r\n", u2_mug(xun), u2_mug(bur)); - return u2_no; + if ( u3_no == _unix_ankh_sing_in(xun, bur) ) { + // fprintf(stderr, "uas: no, no (%x, %x)\r\n", u3_mug(xun), u3_mug(bur)); + return u3_no; } else { // fprintf(stderr, "uas: no, yes\r\n"); - return u2_yes; + return u3_yes; } } } @@ -936,42 +934,42 @@ _unix_ankh_sing(u2_noun xun, u2_noun bur) // retain /* _unix_desk_sync_into(): sync external changes to desk. */ static void -_unix_desk_sync_into(u2_noun who, - u2_noun hox, - u2_noun syd, - u2_udir* dir_u) +_unix_desk_sync_into(u3_noun who, + u3_noun hox, + u3_noun syd, + u3_udir* dir_u) { - u2_noun xun, bur, doz, fav, pax; + u3_noun xun, bur, doz, fav, pax; xun = _unix_dir_ankh(dir_u); - bur = _unix_desk_peek(hox, u2k(syd), u2k(u2A->wen)); + bur = _unix_desk_peek(hox, u3k(syd), u3k(u3A->wen)); - if ( (u2_no == u2_sing(u2h(xun), u2h(bur)))) //&& - // (u2_no == _unix_ankh_sing(xun, bur)) ) + if ( (u3_no == u3_cr_sing(u3h(xun), u3h(bur)))) //&& + // (u3_no == _unix_ankh_sing(xun, bur)) ) { - doz = u2_dc("cost", xun, bur); + doz = u3_dc("cost", xun, bur); - pax = u2nq(u2_blip, c3__sync, u2k(u2A->sen), u2_nul); - fav = u2nq(c3__into, who, syd, u2nc(u2_yes, doz)); + pax = u3nq(u3_blip, c3__sync, u3k(u3A->sen), u3_nul); + fav = u3nq(c3__into, who, syd, u3nc(u3_yes, doz)); - u2_reck_plan(u2A, pax, fav); + u3_cv_plan(pax, fav); } else { - u2z(who); u2z(syd); u2z(xun); u2z(bur); + u3z(who); u3z(syd); u3z(xun); u3z(bur); } } /* _unix_ship_update(): update top level ship. */ static void -_unix_ship_update(u2_uhot* hot_u) +_unix_ship_update(u3_uhot* hot_u) { - u2_udir* dir_u = &(hot_u->dir_u); + u3_udir* dir_u = &(hot_u->dir_u); - if ( u2_no == dir_u->dry ) { + if ( u3_no == dir_u->dry ) { DIR* rid_u = _unix_opendir(dir_u->pax_c); - u2_udir* dis_u; - u2_noun who, hox; + u3_udir* dis_u; + u3_noun who, hox; _unix_dir_update(dir_u, rid_u); @@ -979,18 +977,18 @@ _unix_ship_update(u2_uhot* hot_u) mpz_t who_mp; mpz_init_set(who_mp, hot_u->who_mp); - who = u2_ci_mp(who_mp); - hox = u2_dc("scot", 'p', u2k(who)); + who = u3_ci_mp(who_mp); + hox = u3_dc("scot", 'p', u3k(who)); } for ( dis_u = dir_u->dis_u; dis_u; dis_u = dis_u->nex_u ) { - u2_noun syd = _unix_dir_name(dis_u); + u3_noun syd = _unix_dir_name(dis_u); - // uL(fprintf(uH, "sync %s %s\n", u2_cr_string(hox), u2_cr_string(syd))); - _unix_desk_sync_into(u2k(who), u2k(hox), syd, dis_u); + // uL(fprintf(uH, "sync %s %s\n", u3_cr_string(hox), u3_cr_string(syd))); + _unix_desk_sync_into(u3k(who), u3k(hox), syd, dis_u); } - u2z(hox); - u2z(who); + u3z(hox); + u3z(who); closedir(rid_u); _unix_dir_dry(dir_u); @@ -1000,45 +998,45 @@ _unix_ship_update(u2_uhot* hot_u) /* _unix_hot_gain(): gain ship. */ static void -_unix_hot_gain(u2_noun who, u2_bean mek) +_unix_hot_gain(u3_noun who, u3_bean mek) { - u2_noun hox = u2_dc("scot", 'p', u2k(who)); - c3_c* hox_c = u2_cr_string(hox); - c3_c* pax_c = _unix_down(u2_Host.cpu_c, hox_c + 1); + u3_noun hox = u3_dc("scot", 'p', u3k(who)); + c3_c* hox_c = u3_cr_string(hox); + c3_c* pax_c = _unix_down(u3_Host.cpu_c, hox_c + 1); DIR* rid_u = opendir(pax_c); if ( !rid_u ) { - if ( u2_yes == mek ) { + if ( u3_yes == mek ) { _unix_mkdir(pax_c); } else { - u2z(who); - u2z(hox); + u3z(who); + u3z(hox); return; } } else closedir(rid_u); // uL(fprintf(uH, "GAIN %s\n", pax_c)); free(hox_c); - u2z(hox); - u2_unix_acquire(pax_c); + u3z(hox); + u3_unix_acquire(pax_c); { - u2_uhot* hot_u = c3_malloc(sizeof(u2_uhot)); + u3_uhot* hot_u = c3_malloc(sizeof(u3_uhot)); _unix_dir_watch(&hot_u->dir_u, 0, pax_c); - u2_cr_mp(hot_u->who_mp, who); - u2z(who); + u3_cr_mp(hot_u->who_mp, who); + u3z(who); - hot_u->nex_u = u2_Host.unx_u.hot_u; - u2_Host.unx_u.hot_u = hot_u; + hot_u->nex_u = u3_Host.unx_u.hot_u; + u3_Host.unx_u.hot_u = hot_u; } } /* _unix_hot_lose(): release within a host directory. */ static void -_unix_hot_lose(u2_uhot* hot_u) +_unix_hot_lose(u3_uhot* hot_u) { // uL(fprintf(uH, "lose: %s\n", hot_u->dir_u.pax_c)); _unix_dir_free(&(hot_u->dir_u)); @@ -1046,12 +1044,12 @@ _unix_hot_lose(u2_uhot* hot_u) /* _unix_pdir(): find directory reference from text. */ -static u2_udir** -_unix_pdir(u2_udir* par_u, u2_noun tet) +static u3_udir** +_unix_pdir(u3_udir* par_u, u3_noun tet) { - c3_c* tet_c = u2_cr_string(tet); + c3_c* tet_c = u3_cr_string(tet); c3_w pax_w = strlen(par_u->pax_c); - u2_udir** dir_u; + u3_udir** dir_u; dir_u = &(par_u->dis_u); while ( 1 ) { @@ -1064,14 +1062,14 @@ _unix_pdir(u2_udir* par_u, u2_noun tet) /* _unix_home(): find home directory from identity. */ -static u2_uhot* -_unix_home(u2_noun who) +static u3_uhot* +_unix_home(u3_noun who) { - u2_unix* unx_u = &u2_Host.unx_u; - u2_uhot* hot_u; + u3_unix* unx_u = &u3_Host.unx_u; + u3_uhot* hot_u; mpz_t who_mp; - u2_cr_mp(who_mp, who); + u3_cr_mp(who_mp, who); for ( hot_u = unx_u->hot_u; hot_u && (0 != mpz_cmp(who_mp, hot_u->who_mp)); hot_u = hot_u->nex_u ) @@ -1084,30 +1082,30 @@ _unix_home(u2_noun who) /* _unix_desk_sync_udon(): apply udon to existing value. */ -static u2_noun -_unix_desk_sync_udon(u2_noun don, u2_noun old) +static u3_noun +_unix_desk_sync_udon(u3_noun don, u3_noun old) { - return u2_dc("lump", don, old); + return u3_dc("lump", don, old); } /* _unix_desk_sync_tofu(): sync out file install. */ static void -_unix_desk_sync_tofu(u2_udir* dir_u, - u2_noun pre, - u2_noun ext, - u2_noun mis) +_unix_desk_sync_tofu(u3_udir* dir_u, + u3_noun pre, + u3_noun ext, + u3_noun mis) { - c3_c* pox_c = _unix_file_form(dir_u, u2k(pre), u2_no, u2k(ext)); - c3_c* pux_c = _unix_file_form(dir_u, u2k(pre), u2_yes, u2k(ext)); - u2_ufil** fil_u; + c3_c* pox_c = _unix_file_form(dir_u, u3k(pre), u3_no, u3k(ext)); + c3_c* pux_c = _unix_file_form(dir_u, u3k(pre), u3_yes, u3k(ext)); + u3_ufil** fil_u; - // uL(fprintf(uH, "tofu pox_c %s op %s\n", pox_c, u2_cr_string(u2h(mis)))); + // uL(fprintf(uH, "tofu pox_c %s op %s\n", pox_c, u3_cr_string(u3h(mis)))); #ifdef SYNCLOG - c3_w slot = u2_Host.unx_u.lot_w++ % 1024; - free(u2_Host.unx_u.sylo[slot].pax_c); - u2_Host.unx_u.sylo[slot].pax_c = 0; + c3_w slot = u3_Host.unx_u.lot_w++ % 1024; + free(u3_Host.unx_u.sylo[slot].pax_c); + u3_Host.unx_u.sylo[slot].pax_c = 0; #endif fil_u = &(dir_u->fil_u); @@ -1121,14 +1119,14 @@ _unix_desk_sync_tofu(u2_udir* dir_u, else fil_u = &((*fil_u)->nex_u); } - if ( *fil_u && (c3__del == u2h(mis)) ) { - u2_ufil* ded_u = *fil_u; + if ( *fil_u && (c3__del == u3h(mis)) ) { + u3_ufil* ded_u = *fil_u; #ifdef SYNCLOG - u2_Host.unx_u.sylo[slot].unx = u2_no; - u2_Host.unx_u.sylo[slot].wer_m = c3_s4('t','o','f','u'); - u2_Host.unx_u.sylo[slot].wot_m = c3__del; - u2_Host.unx_u.sylo[slot].pax_c = strdup(ded_u->pax_c); + u3_Host.unx_u.sylo[slot].unx = u3_no; + u3_Host.unx_u.sylo[slot].wer_m = c3_s4('t','o','f','u'); + u3_Host.unx_u.sylo[slot].wot_m = c3__del; + u3_Host.unx_u.sylo[slot].pax_c = strdup(ded_u->pax_c); #endif *fil_u = ded_u->nex_u; @@ -1139,24 +1137,24 @@ _unix_desk_sync_tofu(u2_udir* dir_u, free(pux_c); } else { - u2_noun god, oat; + u3_noun god, oat; c3_c* pax_c; if ( *fil_u ) { - u2_noun old = _unix_file_load(*fil_u); - c3_assert(c3__mut == u2h(mis)); + u3_noun old = _unix_file_load(*fil_u); + c3_assert(c3__mut == u3h(mis)); - god = _unix_desk_sync_udon(u2k(u2t(mis)), old); + god = _unix_desk_sync_udon(u3k(u3t(mis)), old); _unix_unlink((*fil_u)->pax_c); free((*fil_u)->pax_c); } else { - c3_assert(c3__ins == u2h(mis)); - god = u2k(u2t(mis)); + c3_assert(c3__ins == u3h(mis)); + god = u3k(u3t(mis)); } - if ( u2_yes == u2du(god) ) { - oat = u2_cke_jam(god); + if ( u3_yes == u3du(god) ) { + oat = u3_cke_jam(god); pax_c = pux_c; free(pox_c); } else { oat = god; @@ -1164,10 +1162,10 @@ _unix_desk_sync_tofu(u2_udir* dir_u, } #ifdef SYNCLOG - u2_Host.unx_u.sylo[slot].unx = u2_no; - u2_Host.unx_u.sylo[slot].wer_m = c3_s4('t','o','f','u'); - u2_Host.unx_u.sylo[slot].wot_m = u2h(mis); - u2_Host.unx_u.sylo[slot].pax_c = strdup(pax_c); + u3_Host.unx_u.sylo[slot].unx = u3_no; + u3_Host.unx_u.sylo[slot].wer_m = c3_s4('t','o','f','u'); + u3_Host.unx_u.sylo[slot].wot_m = u3h(mis); + u3_Host.unx_u.sylo[slot].pax_c = strdup(pax_c); #endif _unix_save(pax_c, oat); @@ -1177,138 +1175,138 @@ _unix_desk_sync_tofu(u2_udir* dir_u, (*fil_u)->pax_c = pax_c; mpz_clear((*fil_u)->mod_mp); - u2_cr_mp((*fil_u)->mod_mp, u2A->now); + u3_cr_mp((*fil_u)->mod_mp, u3A->now); } else { mpz_t mod_mp; - u2_cr_mp(mod_mp, u2A->now); - *fil_u = c3_malloc(sizeof(u2_ufil)); + u3_cr_mp(mod_mp, u3A->now); + *fil_u = c3_malloc(sizeof(u3_ufil)); _unix_file_watch(*fil_u, dir_u, pax_c, mod_mp); mpz_clear(mod_mp); } } - u2z(pre); u2z(ext); u2z(mis); + u3z(pre); u3z(ext); u3z(mis); } /* _unix_desk_sync_tako(): sync out change. */ static void -_unix_desk_sync_tako(u2_udir* dir_u, u2_noun pax, u2_noun mis) +_unix_desk_sync_tako(u3_udir* dir_u, u3_noun pax, u3_noun mis) { - if ( (u2_no == u2du(pax)) ) { + if ( (u3_no == u3du(pax)) ) { c3_assert(!"tack"); } - else if ( u2_no == u2du(u2t(pax)) ) { // at toplevel - u2_noun i_pax = u2h(pax); - u2_noun t_pax = u2t(pax); + else if ( u3_no == u3du(u3t(pax)) ) { // at toplevel + u3_noun i_pax = u3h(pax); + u3_noun t_pax = u3t(pax); c3_c* par_u = strrchr(dir_u->pax_c, '/') + 1; - u2_noun pem = u2_ci_string(par_u); - c3_assert( u2_nul == t_pax ); // XX ugly, wrong + u3_noun pem = u3_ci_string(par_u); + c3_assert( u3_nul == t_pax ); // XX ugly, wrong - _unix_desk_sync_tofu(dir_u->par_u, pem, u2k(i_pax), mis); + _unix_desk_sync_tofu(dir_u->par_u, pem, u3k(i_pax), mis); } else { - u2_noun i_pax = u2h(pax); - u2_noun t_pax = u2t(pax); - u2_noun it_pax = u2h(t_pax); - u2_noun tt_pax = u2t(t_pax); + u3_noun i_pax = u3h(pax); + u3_noun t_pax = u3t(pax); + u3_noun it_pax = u3h(t_pax); + u3_noun tt_pax = u3t(t_pax); - if ( u2_nul == tt_pax ) { - _unix_desk_sync_tofu(dir_u, u2k(i_pax), u2k(it_pax), mis); + if ( u3_nul == tt_pax ) { + _unix_desk_sync_tofu(dir_u, u3k(i_pax), u3k(it_pax), mis); } else { - u2_udir** dis_u = _unix_pdir(dir_u, u2k(i_pax)); + u3_udir** dis_u = _unix_pdir(dir_u, u3k(i_pax)); if ( !*dis_u ) { - *dis_u = c3_malloc(sizeof(u2_udir)); + *dis_u = c3_malloc(sizeof(u3_udir)); - _unix_dir_forge(*dis_u, dir_u, u2k(i_pax)); + _unix_dir_forge(*dis_u, dir_u, u3k(i_pax)); } - _unix_desk_sync_tako(*dis_u, u2k(t_pax), mis); + _unix_desk_sync_tako(*dis_u, u3k(t_pax), mis); } } - u2z(pax); + u3z(pax); } /* _unix_desk_sync_soba(): sync computed changes. */ static void -_unix_desk_sync_soba(u2_udir* dir_u, u2_noun doz) +_unix_desk_sync_soba(u3_udir* dir_u, u3_noun doz) { - u2_noun zod = u2t(doz); + u3_noun zod = u3t(doz); - while ( u2_nul != zod ) { - _unix_desk_sync_tako(dir_u, u2k(u2h(u2h(zod))), u2k(u2t(u2h(zod)))); - zod = u2t(zod); + while ( u3_nul != zod ) { + _unix_desk_sync_tako(dir_u, u3k(u3h(u3h(zod))), u3k(u3t(u3h(zod)))); + zod = u3t(zod); } - u2z(doz); + u3z(doz); } /* _unix_desk_sync_ergo(): sync desk changes to unix. */ static void -_unix_desk_sync_ergo(u2_noun hox, - u2_noun syd, - u2_noun lok, - u2_uhot* hot_u) +_unix_desk_sync_ergo(u3_noun hox, + u3_noun syd, + u3_noun lok, + u3_uhot* hot_u) { - u2_udir** dir_u = _unix_pdir(&(hot_u->dir_u), syd); - u2_noun xun; + u3_udir** dir_u = _unix_pdir(&(hot_u->dir_u), syd); + u3_noun xun; #if 0 - uL(fprintf(uH, "ergo %s %s %s\n", u2_cr_string(hox), - u2_cr_string(syd), - u2_cr_string(lok))); + uL(fprintf(uH, "ergo %s %s %s\n", u3_cr_string(hox), + u3_cr_string(syd), + u3_cr_string(lok))); #endif if ( !*dir_u ) { - *dir_u = c3_malloc(sizeof(u2_udir)); + *dir_u = c3_malloc(sizeof(u3_udir)); - xun = u2nt(0, u2_nul, u2_nul); - _unix_dir_forge(*dir_u, &(hot_u->dir_u), u2k(syd)); + xun = u3nt(0, u3_nul, u3_nul); + _unix_dir_forge(*dir_u, &(hot_u->dir_u), u3k(syd)); } else { xun = _unix_dir_ankh(*dir_u); } { - u2_noun bur = _unix_desk_peek(hox, syd, lok); + u3_noun bur = _unix_desk_peek(hox, syd, lok); - if ( u2_no == u2_sing(xun, bur) ) { - u2_noun doz = u2_dc("cost", bur, xun); + if ( u3_no == u3_cr_sing(xun, bur) ) { + u3_noun doz = u3_dc("cost", bur, xun); _unix_desk_sync_soba(*dir_u, doz); } else { - u2z(xun); u2z(bur); + u3z(xun); u3z(bur); } } } -/* u2_unix_ef_init(): update filesystem for new acquisition. +/* u3_unix_ef_init(): update filesystem for new acquisition. */ void -u2_unix_ef_init(u2_noun who) +u3_unix_ef_init(u3_noun who) { - _unix_hot_gain(u2k(who), u2_yes); + _unix_hot_gain(u3k(who), u3_yes); - u2_reck_plan(u2A, u2nq(u2_blip, c3__sync, u2k(u2A->sen), u2_nul), - u2nq(c3__into, who, - u2_blip, - u2nt(u2_yes, u2nc(0, 0), u2_nul))); + u3_cv_plan(u3nq(u3_blip, c3__sync, u3k(u3A->sen), u3_nul), + u3nq(c3__into, who, + u3_blip, + u3nt(u3_yes, u3nc(0, 0), u3_nul))); } -/* u2_unix_ef_ergo(): update filesystem, outbound. +/* u3_unix_ef_ergo(): update filesystem, outbound. */ void -u2_unix_ef_ergo(u2_noun who, - u2_noun syd, - u2_noun rel) +u3_unix_ef_ergo(u3_noun who, + u3_noun syd, + u3_noun rel) { - u2_noun hox = u2_dc("scot", 'p', u2k(who)); - u2_noun lok = u2_dc("scot", c3__ud, rel); - u2_uhot* hot_u; + u3_noun hox = u3_dc("scot", 'p', u3k(who)); + u3_noun lok = u3_dc("scot", c3__ud, rel); + u3_uhot* hot_u; hot_u = _unix_home(who); @@ -1317,16 +1315,16 @@ u2_unix_ef_ergo(u2_noun who, } } -/* u2_unix_ef_look(): update the root. +/* u3_unix_ef_look(): update the root. */ void -u2_unix_ef_look(void) +u3_unix_ef_look(void) { - u2_unix* unx_u = &u2_Host.unx_u; - u2_noun won; - u2_uhot* hot_u; + u3_unix* unx_u = &u3_Host.unx_u; + u3_noun won; + u3_uhot* hot_u; - if ( u2_nul != u2A->roe ) { + if ( u3_nul != u3A->roe ) { // We can't generate a working %into event here because there // are other events, possibly containing %into, that are queued; // they will change the state of %clay and cause a patch that @@ -1337,33 +1335,33 @@ u2_unix_ef_look(void) // find owners without directories { - for ( won = u2A->own; u2_nul != won; won = u2t(won) ) { - u2_noun who = u2h(won); + for ( won = u3A->own; u3_nul != won; won = u3t(won) ) { + u3_noun who = u3h(won); mpz_t who_mp; - u2_cr_mp(who_mp, who); + u3_cr_mp(who_mp, who); for ( hot_u = unx_u->hot_u; hot_u && (0 != mpz_cmp(who_mp, hot_u->who_mp)); hot_u = hot_u->nex_u ); mpz_clear(who_mp); if ( 0 == hot_u ) { - _unix_hot_gain(u2k(who), u2_no); + _unix_hot_gain(u3k(who), u3_no); } } } // find directories without owners { - u2_uhot** het_u = &(unx_u->hot_u); + u3_uhot** het_u = &(unx_u->hot_u); while ( 0 != (hot_u=*het_u) ) { - for ( won = u2A->own; u2_nul != won; won = u2t(won) ) { - u2_noun who = u2h(won); + for ( won = u3A->own; u3_nul != won; won = u3t(won) ) { + u3_noun who = u3h(won); mpz_t who_mp; c3_w cmp_w; - u2_cr_mp(who_mp, who); + u3_cr_mp(who_mp, who); cmp_w = mpz_cmp(who_mp, hot_u->who_mp); mpz_clear(who_mp); if ( 0 == cmp_w ) { @@ -1371,7 +1369,7 @@ u2_unix_ef_look(void) } } - if ( u2_nul == won ) { + if ( u3_nul == won ) { *het_u = hot_u->nex_u; // uL(fprintf(uH, "sync: lose %s\n", hot_u->dir_u.pax_c)); @@ -1388,7 +1386,7 @@ u2_unix_ef_look(void) // update all ships { - u2_uhot* hot_u; + u3_uhot* hot_u; for ( hot_u = unx_u->hot_u; hot_u; hot_u = hot_u->nex_u ) { _unix_ship_update(hot_u); @@ -1401,8 +1399,8 @@ u2_unix_ef_look(void) static void _unix_ef_sync(uv_check_t* han_u) { - u2_lo_open(); - u2_lo_shut(u2_yes); + u3_lo_open(); + u3_lo_shut(u3_yes); } /* _unix_time_cb(): timer callback. @@ -1410,14 +1408,13 @@ _unix_ef_sync(uv_check_t* han_u) static void _unix_time_cb(uv_timer_t* tim_u) { - u2_lo_open(); + u3_lo_open(); { - u2_reck_plan - (u2A, - u2nt(u2_blip, c3__clay, u2_nul), - u2nc(c3__wake, u2_nul)); + u3_cv_plan + (u3nt(u3_blip, c3__clay, u3_nul), + u3nc(c3__wake, u3_nul)); } - u2_lo_shut(u2_no); + u3_lo_shut(u3_no); } /* _unix_sign_cb: signal callback. @@ -1425,84 +1422,84 @@ _unix_time_cb(uv_timer_t* tim_u) static void _unix_sign_cb(uv_signal_t* sil_u, c3_i num_i) { - u2_lo_open(); + u3_lo_open(); { switch ( num_i ) { default: fprintf(stderr, "\r\nmysterious signal %d\r\n", num_i); break; case SIGTERM: fprintf(stderr, "\r\ncaught signal %d\r\n", num_i); - u2_Host.liv = u2_no; + u3_Host.liv = u3_no; break; - case SIGINT: u2_term_ef_ctlc(); break; - case SIGWINCH: u2_term_ef_winc(); break; - // case SIGCHLD: u2_save_ef_chld(); break; + case SIGINT: u3_term_ef_ctlc(); break; + case SIGWINCH: u3_term_ef_winc(); break; + // case SIGCHLD: u3_save_ef_chld(); break; } } - u2_lo_shut(u2_yes); + u3_lo_shut(u3_yes); } -/* u2_unix_ef_hold() +/* u3_unix_ef_hold() */ void -u2_unix_ef_hold(void) +u3_unix_ef_hold(void) { - u2_unix* unx_u = &u2_Host.unx_u; - u2_usig* sig_u; + u3_unix* unx_u = &u3_Host.unx_u; + u3_usig* sig_u; for ( sig_u = unx_u->sig_u; sig_u; sig_u = sig_u->nex_u ) { uv_signal_stop(&sig_u->sil_u); } } -/* u2_unix_ef_move() +/* u3_unix_ef_move() */ void -u2_unix_ef_move(void) +u3_unix_ef_move(void) { - u2_unix* unx_u = &u2_Host.unx_u; - u2_usig* sig_u; + u3_unix* unx_u = &u3_Host.unx_u; + u3_usig* sig_u; for ( sig_u = unx_u->sig_u; sig_u; sig_u = sig_u->nex_u ) { uv_signal_start(&sig_u->sil_u, _unix_sign_cb, sig_u->num_i); } } -/* u2_unix_io_init(): initialize unix sync. +/* u3_unix_io_init(): initialize unix sync. */ void -u2_unix_io_init(void) +u3_unix_io_init(void) { - u2_unix* unx_u = &u2_Host.unx_u; + u3_unix* unx_u = &u3_Host.unx_u; - uv_timer_init(u2L, &unx_u->tim_u); - unx_u->alm = u2_no; + uv_timer_init(u3L, &unx_u->tim_u); + unx_u->alm = u3_no; { - u2_usig* sig_u; + u3_usig* sig_u; - sig_u = c3_malloc(sizeof(u2_usig)); - uv_signal_init(u2L, &sig_u->sil_u); + sig_u = c3_malloc(sizeof(u3_usig)); + uv_signal_init(u3L, &sig_u->sil_u); sig_u->num_i = SIGTERM; sig_u->nex_u = unx_u->sig_u; unx_u->sig_u = sig_u; } { - u2_usig* sig_u; + u3_usig* sig_u; - sig_u = c3_malloc(sizeof(u2_usig)); - uv_signal_init(u2L, &sig_u->sil_u); + sig_u = c3_malloc(sizeof(u3_usig)); + uv_signal_init(u3L, &sig_u->sil_u); sig_u->num_i = SIGINT; sig_u->nex_u = unx_u->sig_u; unx_u->sig_u = sig_u; } { - u2_usig* sig_u; + u3_usig* sig_u; - sig_u = c3_malloc(sizeof(u2_usig)); - uv_signal_init(u2L, &sig_u->sil_u); + sig_u = c3_malloc(sizeof(u3_usig)); + uv_signal_init(u3L, &sig_u->sil_u); sig_u->num_i = SIGWINCH; sig_u->nex_u = unx_u->sig_u; @@ -1512,67 +1509,67 @@ u2_unix_io_init(void) unx_u->lot_w = 0; memset(unx_u->sylo, 0, sizeof(unx_u->sylo)); #endif - uv_check_init(u2_Host.lup_u, &u2_Host.unx_u.syn_u); + uv_check_init(u3_Host.lup_u, &u3_Host.unx_u.syn_u); } -/* u2_unix_io_talk(): start listening for fs events. +/* u3_unix_io_talk(): start listening for fs events. */ void -u2_unix_io_talk() +u3_unix_io_talk() { - u2_unix_acquire(u2_Host.cpu_c); - u2_unix_ef_move(); - uv_check_start(&u2_Host.unx_u.syn_u, _unix_ef_sync); + u3_unix_acquire(u3_Host.cpu_c); + u3_unix_ef_move(); + uv_check_start(&u3_Host.unx_u.syn_u, _unix_ef_sync); } -/* u2_unix_io_exit(): terminate unix I/O. +/* u3_unix_io_exit(): terminate unix I/O. */ void -u2_unix_io_exit(void) +u3_unix_io_exit(void) { - uv_check_stop(&u2_Host.unx_u.syn_u); - u2_unix_release(u2_Host.cpu_c); + uv_check_stop(&u3_Host.unx_u.syn_u); + u3_unix_release(u3_Host.cpu_c); { - u2_uhot* hot_u; + u3_uhot* hot_u; - for ( hot_u = u2_Host.unx_u.hot_u; hot_u; hot_u = hot_u->nex_u ) { - u2_unix_release(hot_u->dir_u.pax_c); + for ( hot_u = u3_Host.unx_u.hot_u; hot_u; hot_u = hot_u->nex_u ) { + u3_unix_release(hot_u->dir_u.pax_c); } } #ifdef SYNCLOG for (int i = 0; i<1024; i++) { - free(u2_Host.unx_u.sylo[i].pax_c); + free(u3_Host.unx_u.sylo[i].pax_c); } #endif } -/* u2_unix_io_poll(): update unix IO state. +/* u3_unix_io_poll(): update unix IO state. */ void -u2_unix_io_poll(void) +u3_unix_io_poll(void) { - u2_unix* unx_u = &u2_Host.unx_u; - u2_noun wen = u2_reck_keep(u2A, u2nt(u2_blip, c3__clay, u2_nul)); + u3_unix* unx_u = &u3_Host.unx_u; + u3_noun wen = u3_cv_keep(u3nt(u3_blip, c3__clay, u3_nul)); - if ( (u2_nul != wen) && - (u2_yes == u2du(wen)) && - (u2_yes == u2ud(u2t(wen))) ) + if ( (u3_nul != wen) && + (u3_yes == u3du(wen)) && + (u3_yes == u3ud(u3t(wen))) ) { - c3_d gap_d = u2_time_gap_ms(u2k(u2A->now), u2k(u2t(wen))); + c3_d gap_d = u3_time_gap_ms(u3k(u3A->now), u3k(u3t(wen))); - if ( u2_yes == unx_u->alm ) { + if ( u3_yes == unx_u->alm ) { uv_timer_stop(&unx_u->tim_u); } - else unx_u->alm = u2_yes; + else unx_u->alm = u3_yes; uv_timer_start(&unx_u->tim_u, _unix_time_cb, gap_d, 0); } else { - if ( u2_yes == unx_u->alm ) { + if ( u3_yes == unx_u->alm ) { uv_timer_stop(&unx_u->tim_u); } - unx_u->alm = u2_no; + unx_u->alm = u3_no; } - u2z(wen); + u3z(wen); } diff --git a/v/walk.c b/v/walk.c index 1bf58b929..575155e9f 100644 --- a/v/walk.c +++ b/v/walk.c @@ -19,7 +19,6 @@ #include #include "all.h" -#include "f/coal.h" #include "v/vere.h" /* |% @@ -31,23 +30,23 @@ */ #if 0 -static u2_noun -_walk_ok(u2_reck* rec_u, u2_noun nod) +static u3_noun +_walk_ok(u3_noun nod) { - u2_noun don = u2_cn_mung(u2k(rec_u->toy.arch), u2k(nod)); + u3_noun don = u3_cn_mung(u3k(u2A->toy.arch), u3k(nod)); - if ( u2_no == u2_sing(nod, don) ) { + if ( u3_no == u3_sing(nod, don) ) { c3_assert(0); } - u2z(don); + u3z(don); return nod; } #endif -/* u2_walk_safe(): load file or 0. +/* u3_walk_safe(): load file or 0. */ -u2_noun -u2_walk_safe(c3_c* pas_c) +u3_noun +u3_walk_safe(c3_c* pas_c) { struct stat buf_b; c3_i fid_i = open(pas_c, O_RDONLY, 0644); @@ -69,17 +68,17 @@ u2_walk_safe(c3_c* pas_c) return 0; } else { - u2_noun pad = u2_ci_bytes(fln_w, (c3_y *)pad_y); + u3_noun pad = u3_ci_bytes(fln_w, (c3_y *)pad_y); free(pad_y); return pad; } } -/* u2_walk_load(): load file or bail. +/* u3_walk_load(): load file or bail. */ -u2_noun -u2_walk_load(c3_c* pas_c) +u3_noun +u3_walk_load(c3_c* pas_c) { struct stat buf_b; c3_i fid_i = open(pas_c, O_RDONLY, 0644); @@ -88,7 +87,7 @@ u2_walk_load(c3_c* pas_c) if ( (fid_i < 0) || (fstat(fid_i, &buf_b) < 0) ) { uL(fprintf(uH, "%s: %s\n", pas_c, strerror(errno))); - return u2_cm_bail(c3__fail); + return u3_cm_bail(c3__fail); } fln_w = buf_b.st_size; pad_y = c3_malloc(buf_b.st_size); @@ -98,20 +97,20 @@ u2_walk_load(c3_c* pas_c) if ( fln_w != red_w ) { free(pad_y); - return u2_cm_bail(c3__fail); + return u3_cm_bail(c3__fail); } else { - u2_noun pad = u2_ci_bytes(fln_w, (c3_y *)pad_y); + u3_noun pad = u3_ci_bytes(fln_w, (c3_y *)pad_y); free(pad_y); return pad; } } -/* u2_walk_save(): save file or bail. +/* u3_walk_save(): save file or bail. */ void -u2_walk_save(c3_c* pas_c, u2_noun tim, u2_atom pad) +u3_walk_save(c3_c* pas_c, u3_noun tim, u3_atom pad) { c3_i fid_i = open(pas_c, O_WRONLY | O_CREAT | O_TRUNC, 0666); c3_w fln_w, rit_w; @@ -119,13 +118,13 @@ u2_walk_save(c3_c* pas_c, u2_noun tim, u2_atom pad) if ( fid_i < 0 ) { uL(fprintf(uH, "%s: %s\n", pas_c, strerror(errno))); - u2_cm_bail(c3__fail); + u3_cm_bail(c3__fail); } - fln_w = u2_met(3, pad); + fln_w = u3_cr_met(3, pad); pad_y = c3_malloc(fln_w); - u2_cr_bytes(0, fln_w, pad_y, pad); - u2z(pad); + u3_cr_bytes(0, fln_w, pad_y, pad); + u3z(pad); rit_w = write(fid_i, pad_y, fln_w); close(fid_i); @@ -133,14 +132,14 @@ u2_walk_save(c3_c* pas_c, u2_noun tim, u2_atom pad) if ( rit_w != fln_w ) { uL(fprintf(uH, "%s: %s\n", pas_c, strerror(errno))); - u2_cm_bail(c3__fail); + u3_cm_bail(c3__fail); } if ( 0 != tim ) { struct timeval tim_tv[2]; - u2_time_out_tv(&tim_tv[0], u2k(tim)); - u2_time_out_tv(&tim_tv[1], tim); + u3_time_out_tv(&tim_tv[0], u3k(tim)); + u3_time_out_tv(&tim_tv[1], tim); utimes(pas_c, tim_tv); } @@ -148,14 +147,14 @@ u2_walk_save(c3_c* pas_c, u2_noun tim, u2_atom pad) /* _walk_in(): inner loop of _walk(), producing map. */ -static u2_noun -_walk_in(u2_reck* rec_u, const c3_c* dir_c, c3_w len_w) +static u3_noun +_walk_in(const c3_c* dir_c, c3_w len_w) { DIR* dir_d = opendir(dir_c); - u2_noun map = u2_nul; + u3_noun map = u3_nul; if ( !dir_d ) { - return u2_nul; + return u3_nul; } else while ( 1 ) { struct dirent ent_n; @@ -189,7 +188,7 @@ _walk_in(u2_reck* rec_u, const c3_c* dir_c, c3_w len_w) if ( 0 != stat(pat_c, &buf_b) ) { free(pat_c); } else { - u2_noun tim = c3_stat_mtime(&buf_b); + u3_noun tim = c3_stat_mtime(&buf_b); if ( !S_ISDIR(buf_b.st_mode) ) { c3_c* dot_c = strrchr(fil_c, '.'); @@ -198,32 +197,32 @@ _walk_in(u2_reck* rec_u, const c3_c* dir_c, c3_w len_w) nam_c[dot_c - fil_c] = 0; { - u2_noun nam = u2_ci_string(nam_c); - u2_noun ext = u2_ci_string(ext_c); - u2_noun get = u2_ckd_by_get(u2k(map), u2k(nam)); - u2_noun dat = u2_walk_load(pat_c); - u2_noun hax; + u3_noun nam = u3_ci_string(nam_c); + u3_noun ext = u3_ci_string(ext_c); + u3_noun get = u3_ckdb_get(u3k(map), u3k(nam)); + u3_noun dat = u3_walk_load(pat_c); + u3_noun hax; if ( !strcmp("noun", ext_c) ) { - dat = u2_cke_cue(dat); + dat = u3_cke_cue(dat); } - hax = u2_do("sham", u2k(dat)); - if ( u2_none == get ) { get = u2_nul; } + hax = u3_do("sham", u3k(dat)); + if ( u3_none == get ) { get = u3_nul; } - get = u2_ckd_by_put(get, ext, u2nt(u2_yes, hax, dat)); - map = u2_ckd_by_put(map, nam, u2nc(u2_no, get)); + get = u3_ckdb_put(get, ext, u3nt(u3_yes, hax, dat)); + map = u3_ckdb_put(map, nam, u3nc(u3_no, get)); } free(nam_c); free(ext_c); } else { - u2_noun dir = _walk_in(rec_u, pat_c, lef_w); + u3_noun dir = _walk_in(pat_c, lef_w); - if ( u2_nul != dir ) { - map = u2_ckd_by_put - (map, u2_ci_string(fil_c), u2nc(u2_no, dir)); + if ( u3_nul != dir ) { + map = u3_ckdb_put + (map, u3_ci_string(fil_c), u3nc(u3_no, dir)); } - else u2z(tim); + else u3z(tim); } free(pat_c); } @@ -233,71 +232,71 @@ _walk_in(u2_reck* rec_u, const c3_c* dir_c, c3_w len_w) return map; } -/* u2_walk(): traverse `dir_c` to produce an arch, updating `old`. +/* u3_walk(): traverse `dir_c` to produce an arch, updating `old`. */ -u2_noun -u2_walk(u2_reck* rec_u, const c3_c* dir_c, u2_noun old) +u3_noun +u3_walk(const c3_c* dir_c, u3_noun old) { // XX - obviously, cheaper to update old data. - u2z(old); + u3z(old); { struct stat buf_b; if ( 0 != stat(dir_c, &buf_b) ) { uL(fprintf(uH, "can't stat %s\n", dir_c)); - // return u2_cm_bail(c3__fail); + // return u3_cm_bail(c3__fail); c3_assert(0); } else { - return u2nc(u2_no, - _walk_in(rec_u, dir_c, strlen(dir_c))); + return u3nc(u3_no, + _walk_in(dir_c, strlen(dir_c))); } } } -/* u2_path(): C unix path in computer for file or directory. +/* u3_path(): C unix path in computer for file or directory. */ c3_c* -u2_path(u2_bean fyl, u2_noun pax) +u3_path(u3_bean fyl, u3_noun pax) { c3_w len_w; c3_c *pas_c; // measure // - len_w = strlen(u2_Local); + len_w = strlen(u3_Local); { - u2_noun wiz = pax; + u3_noun wiz = pax; - while ( u2_nul != wiz ) { - len_w += (1 + u2_cr_met(3, u2h(wiz))); - wiz = u2t(wiz); + while ( u3_nul != wiz ) { + len_w += (1 + u3_cr_met(3, u3h(wiz))); + wiz = u3t(wiz); } } // cut // pas_c = c3_malloc(len_w + 1); - strncpy(pas_c, u2_Local, len_w); + strncpy(pas_c, u3_Local, len_w); pas_c[len_w] = '\0'; { - u2_noun wiz = pax; + u3_noun wiz = pax; c3_c* waq_c = (pas_c + strlen(pas_c)); - while ( u2_nul != wiz ) { - c3_w tis_w = u2_cr_met(3, u2h(wiz)); + while ( u3_nul != wiz ) { + c3_w tis_w = u3_cr_met(3, u3h(wiz)); - if ( (u2_yes == fyl) && (u2_nul == u2t(wiz)) ) { + if ( (u3_yes == fyl) && (u3_nul == u3t(wiz)) ) { *waq_c++ = '.'; } else *waq_c++ = '/'; - u2_cr_bytes(0, tis_w, (c3_y*)waq_c, u2h(wiz)); + u3_cr_bytes(0, tis_w, (c3_y*)waq_c, u3h(wiz)); waq_c += tis_w; - wiz = u2t(wiz); + wiz = u3t(wiz); } *waq_c = 0; } - u2z(pax); + u3z(pax); return pas_c; }