/* _http_list_to_heds(): list to C headers. */ static u2_hhed* _http_list_to_heds(u2_noun lix) { u2_noun yix = lix; u2_hhed* hed_u = 0; while ( 1 ) { if ( u2_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)); nex_u->nam_c = u2_cr_string(pi_lix); nex_u->val_c = u2_cr_string(qi_lix); nex_u->nex_u = hed_u; hed_u = nex_u; lix = t_lix; } } u2z(yix); return hed_u; }
/* u2_unix_io_poll(): update unix IO state. */ void u2_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)); if ( (u2_nul != wen) && (u2_yes == u2du(wen)) && (u2_yes == u2ud(u2t(wen))) ) { c3_d gap_d = u2_time_gap_ms(u2k(u2A->now), u2k(u2t(wen))); if ( u2_yes == unx_u->alm ) { uv_timer_stop(&unx_u->tim_u); } else unx_u->alm = u2_yes; if ( gap_d < 1000 ) { gap_d = 1000; } // band-aid on an unknown clay timer bug uv_timer_start(&unx_u->tim_u, _unix_time_cb, gap_d, 0); } else { if ( u2_yes == unx_u->alm ) { uv_timer_stop(&unx_u->tim_u); } unx_u->alm = u2_no; } u2z(wen); }
/* u2_unix_io_poll(): update unix IO state. */ void u2_unix_io_poll(void) { u2_unix* unx_u = &u2_Host.unx_u; u2_noun wen = u2_reck_keep(u2A, u2nt(c3__gold, c3__clay, u2_nul)); if ( (u2_nul != wen) && (u2_yes == u2du(wen)) && (u2_yes == u2ud(u2t(wen))) ) { c3_d gap_d = u2_time_gap_ms(u2k(u2A->now), u2k(u2t(wen))); if ( u2_yes == unx_u->alm ) { uv_timer_stop(&unx_u->tim_u); } else unx_u->alm = u2_yes; uv_timer_start(&unx_u->tim_u, _unix_time_cb, gap_d, 0); } else { if ( u2_yes == unx_u->alm ) { uv_timer_stop(&unx_u->tim_u); } unx_u->alm = u2_no; } u2z(wen); }
/* _unix_desk_sync_miso(): sync out change. */ static void _unix_desk_sync_miso(u2_udir* dir_u, u2_noun pax, u2_noun mis) { if ( (u2_no == u2du(pax)) || u2_no == u2du(u2t(pax)) ) { c3_assert(0); u2z(pax); u2z(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); if ( u2_nul == tt_pax ) { _unix_desk_sync_tofu(dir_u, u2k(i_pax), u2k(it_pax), mis); } else { u2_udir** dis_u = _unix_pdir(dir_u, u2k(i_pax)); if ( !*dis_u ) { *dis_u = malloc(sizeof(u2_udir)); _unix_dir_forge(*dis_u, dir_u, u2k(i_pax)); } _unix_desk_sync_miso(*dis_u, u2k(t_pax), mis); } } u2z(pax); }
/* u2_batz_io_poll(): update batz IO state. */ void u2_batz_io_poll(void) { u2_batz* beh_u = &u2_Host.beh_u; u2_noun wen = u2_reck_keep(u2A, u2nt(c3__gold, c3__batz, u2_nul)); if ( (u2_nul != wen) && (u2_yes == u2du(wen)) && (u2_yes == u2ud(u2t(wen))) ) { c3_d gap_d = u2_time_gap_ms(u2k(u2A->now), u2k(u2t(wen))); if ( u2_yes == beh_u->alm ) { uv_timer_stop(&beh_u->tim_u); } else beh_u->alm = u2_yes; uv_timer_start(&beh_u->tim_u, _batz_time_cb, gap_d, 0); } else { if ( u2_yes == beh_u->alm ) { uv_timer_stop(&beh_u->tim_u); } beh_u->alm = u2_no; } u2z(wen); }
/* _unix_node_sing(): test node equality. */ static u2_bean _unix_node_sing(u2_noun xud, u2_noun bud) { if ( (u2_nul == xud) && (u2_nul == bud) ) { return u2_yes; } if ( (u2_nul == xud) || (u2_nul == bud) ) { return u2_no; } return u2_sing(u2t(u2t(xud)), u2t(u2t(bud))); }
/* _unix_desk_sync_soba(): sync computed changes. */ static void _unix_desk_sync_soba(u2_udir* dir_u, u2_noun doz) { u2_noun zod = doz; while ( u2_nul != zod ) { _unix_desk_sync_miso(dir_u, u2k(u2h(u2h(zod))), u2k(u2t(u2h(zod)))); zod = u2t(zod); } u2z(doz); }
/* _unix_dir_arch(): resolve directory to old style arch. */ static u2_noun _unix_dir_arch(u2_udir* dir_u) { u2_udir* dis_u; u2_ufil* fil_u; u2_noun pam = u2_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 arc = _unix_dir_arch(dis_u); // uL(fprintf(uH, "dir %s\n", u2_cr_string(pre))); pam = u2_ckd_by_put(pam, pre, arc); } 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 has = u2_do("sham", u2k(baw)); u2_noun fil = u2nt(u2_yes, has, baw); if ( u2_no == u2du(wib) ) { // uL(fprintf(uH, "file %s\n", u2_cr_string(wib))); pam = u2_ckd_by_put(pam, wib, fil); } else { u2_weak ole = u2_ckd_by_get(u2k(pam), u2k(u2h(wib))); u2_noun arc, rac; // uL(fprintf(uH, "file %s.%s\n", u2_cr_string(u2h(wib)), // u2_cr_string(u2t(wib)))); if ( u2_none == ole ) { arc = u2nc(u2_no, u2_nul); } else if ( u2_yes == u2h(ole) ) { u2z(ole); arc = u2nc(u2_no, u2_nul); } else arc = ole; rac = u2nc(u2_no, u2_ckd_by_put(u2k(u2t(arc)), u2k(u2t(wib)), fil)); pam = u2_ckd_by_put(pam, u2k(u2h(wib)), rac); u2z(wib); u2z(arc); } } return u2nc(u2_no, pam); }
/* _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); } }
/* _cf_path_1: write at/inpath. */ static c3_w _cf_path_1(c3_c* buf_c, c3_w pos_w, u2_noun hut) // retain { if ( u2_no == u2_cr_du(hut) ) { c3_w met_w = u2_cr_met(3, hut); if ( buf_c ) u2_cr_bytes(0, met_w, (c3_y*)(buf_c + pos_w), hut); return (pos_w + met_w); } else { c3_w met_w = u2_cr_met(3, u2h(hut)); c3_w end_w = _cf_path_1(buf_c, pos_w, u2t(hut)); u2_noun san = u2h(hut); if ( buf_c ) buf_c[end_w] = '/'; end_w++; // little security thing - last ditch // if ( c3_s2('.', '.') == san ) { san = c3_s3('.','.','.'); } if ( buf_c ) u2_cr_bytes(0, met_w, (c3_y*)(buf_c + end_w), san); end_w += met_w; return end_w; } }
/* _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) { u2_weak ole; if ( u2_no == u2du(wib) ) { ole = u2_ckd_by_get(u2k(pam), u2k(wib)); if ( u2_none == ole ) { ole = u2_do("cosh", u2nt(0, woz, u2_nul)); } else { u2_noun elo; elo = u2_do("cosh", u2nt(0, woz, u2k(u2t(u2t(ole))))); u2z(ole); ole = elo; } pam = u2_ckd_by_put(pam, wib, ole); } else { u2_noun fid = u2h(wib); u2_noun har = u2t(wib); ole = u2_ckd_by_get(u2k(pam), u2k(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); } else { u2_noun roo = u2t(u2t(ole)); u2_weak tup = u2_ckd_by_get(u2k(roo), u2k(har)); u2_noun oor, elo; if ( u2_none == tup ) { tup = u2_do("cosh", u2nt(0, woz, u2_nul)); } else { u2_noun upt; upt = u2_do("cosh", u2nt(0, woz, u2k(u2t(u2t(tup))))); u2z(tup); tup = upt; } oor = u2_ckd_by_put(u2k(roo), u2k(har), tup); elo = u2_do("cosh", u2nt(0, u2k(u2h(u2t(ole))), oor)); u2z(ole); ole = elo; } pam = u2_ckd_by_put(pam, u2k(fid), ole); u2z(wib); } return pam; }
/* u2_lo_sway(): print trace. */ void u2_lo_sway(c3_l tab_l, u2_noun tax) { u2_noun mok = u2_dc("mook", 2, tax); u2_lo_punt(tab_l, u2k(u2t(mok))); u2z(mok); }
/* u2_cr_tape(): `a`, a list of bytes, as malloced C string. */ c3_y* u2_cr_tape(u2_noun a) { u2_noun b; c3_w i_w; c3_y *a_y; for ( i_w = 0, b=a; u2_yes == u2du(b); i_w++, b=u2t(b) ) ; a_y = c3_malloc(i_w + 1); for ( i_w = 0, b=a; u2_yes == u2du(b); i_w++, b=u2t(b) ) { a_y[i_w] = u2h(b); } a_y[i_w] = 0; return a_y; }
/* u2_cm_drop(): drop from meaning stack. */ void u2_cm_drop() { u2_noun tax = u2_wire_tax(u2_Wire); c3_assert(u2_nul != tax); u2_wire_tax(u2_Wire) = u2_ct(u2t(tax)); u2_cz(tax); }
/* _term_it_path(): path for console file. */ static c3_c* _term_it_path(u2_bean fyl, u2_noun pax) { c3_w len_w; c3_c *pas_c; // measure // len_w = strlen(u2_Host.cpu_c); { u2_noun wiz = pax; while ( u2_nul != wiz ) { len_w += (1 + u2_cr_met(3, u2h(wiz))); wiz = u2t(wiz); } } // cut // pas_c = malloc(len_w + 1); strncpy(pas_c, u2_Host.cpu_c, len_w); pas_c[len_w] = '\0'; { u2_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)); if ( (u2_yes == fyl) && (u2_nul == u2t(wiz)) ) { *waq_c++ = '.'; } else *waq_c++ = '/'; u2_cr_bytes(0, tis_w, (c3_y*)waq_c, u2h(wiz)); waq_c += tis_w; wiz = u2t(wiz); } *waq_c = 0; } u2z(pax); return pas_c; }
/* nock_molg(): function call (mung) with kode. Arguments transferred. */ static u2_noun _nock_molg(u2_noun gat, u2_noun sam, u2_kode* pon) { if ( (u2_no == u2du(gat)) || (u2_no == u2du(u2t(gat))) ) { *pon = 2; return u2_cm_wail(); } else { u2_noun cor, fol; cor = u2nc(u2k(u2h(gat)), u2nc(sam, u2k(u2t(u2t(gat))))); fol = u2k(u2h(gat)); u2z(gat); // XX try to chip with u2_ds_find? but a rare case... return _nock_mool(cor, fol, pon); } }
/* bend */ u2_noun // produce j2_mcx(Pt5, bend, fun)(u2_wire wir_r, u2_noun raq, // retain u2_noun vex, // retain u2_noun sab) // retain { u2_noun p_vex, q_vex; u2_bi_cell(wir_r, vex, &p_vex, &q_vex); if ( u2_no == u2_dust(q_vex) ) { return u2_rx(wir_r, vex); } else { u2_noun uq_vex = u2_t(q_vex); u2_noun puq_vex, quq_vex; u2_noun yit, yur; u2_noun p_yit, q_yit; u2_noun ret; u2_bi_cell(wir_r, uq_vex, &puq_vex, &quq_vex); yit = u2_bl_good(wir_r, u2_nk_mong(wir_r, sab, u2_rx(wir_r, quq_vex))); u2_bi_cell(wir_r, yit, &p_yit, &q_yit); yur = _last(wir_r, p_vex, p_yit); if ( u2_no == u2_dust(q_yit) ) { ret = u2_bc(wir_r, yur, u2_rx(wir_r, q_vex)); } else { u2_noun uq_yit = u2_t(q_yit); u2_noun puq_yit, quq_yit; u2_noun vux; u2_bi_cell(wir_r, uq_yit, &puq_yit, &quq_yit); vux = u2_bl_good (wir_r, u2_nk_mong (wir_r, raq, u2_bc(wir_r, u2_rx(wir_r, puq_vex), u2_rx(wir_r, puq_yit)))); if ( u2_nul == vux ) { ret = u2_bc(wir_r, yur, u2_rx(wir_r, q_vex)); } else { ret = u2_bq(wir_r, yur, u2_nul, u2k(u2t(vux)), u2_rx(wir_r, quq_yit)); u2z(vux); } } u2_rz(wir_r, yit); return ret; } }
static u2_bean _unix_ankh_sing_map(u2_noun mun, u2_noun mur) // retain { u2_noun n_mun, l_mun, r_mun; u2_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; } u2_cx_trel(mun, &n_mun, &l_mun, &r_mun); u2_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)) ) { return u2_no; } else return u2_yes; }
u2_noun // transfer j2_mcy(Pt6, ut, seep)(u2_wire wir_r, u2_noun van, // retain u2_noun sut, // retain u2_noun way, // retain u2_noun hyp) // retain { u2_noun zar = j2_mcy(Pt6, ut, seek)(wir_r, van, sut, way, hyp); u2_noun p_zar = u2h(zar); u2_noun q_zar = u2t(zar); if ( u2_yes != u2h(q_zar) ) { return u2_cm_bail(c3__exit); } else { u2_noun ret = u2_bc(wir_r, u2_rx(wir_r, p_zar), u2_rx(wir_r, u2t(q_zar))); u2_rz(wir_r, zar); return ret; } }
/* _cm_depth() */ static c3_w _cm_depth(u2_noun old, u2_noun nuw) { c3_w dep_w = 0; while ( nuw != old ) { c3_assert(u2_yes == u2du(nuw)); nuw = u2t(nuw); dep_w++; } return dep_w; }
/* _nock_pray_mool(): load from namespace, in virtual mode. */ static u2_noun _nock_pray_mool(u2_noun gof, u2_kode *pon) // transfer { u2_noun lad = u2_hevn_at(lad); c3_assert(u2_yes == u2du(lad)); c3_assert(0 == *pon); { u2_noun i_lad = u2fh(lad); u2_noun t_lad = u2ft(lad); u2_noun pro; u2_noun hoe; u2_hevn_at(lad) = t_lad; if ( 0 != (hoe = u2_cm_trap()) ) { u2_cm_done(); return u2_cm_bail(u2k(u2h(hoe))); } else { if ( u2_nul == t_lad ) { pro = u2_cn_mung(u2k(i_lad), u2k(gof)); } else { pro = _nock_molg(u2k(i_lad), u2k(gof), pon); } u2_cm_done(); c3_assert(t_lad == u2_hevn_at(lad)); u2_hevn_at(lad) = lad; if ( 0 != *pon ) { u2z(gof); return pro; } else { if ( u2_no == u2du(pro) ) { *pon = 1; u2z(pro); return u2nc(gof, u2_nul); } else { u2_noun res = u2k(u2t(pro)); u2z(gof); u2z(pro); return res; } } } } }
/* _nock_moog(): u2_cn_mink() with fly set. */ static u2_noun _nock_moog(u2_noun bus, u2_noun fol) { u2_noun res; u2_kode pon; pon = 0; { u2_noun hoe; if ( 0 != (hoe = u2_cm_trap()) ) { if ( u2h(hoe) == c3__exit ) { res = u2nc(2, u2k(u2t(hoe))); c3_assert(0); u2z(hoe); } else if ( u2h(hoe) == c3__need ) { res = u2nc(1, u2k(u2t(hoe))); u2z(hoe); } else { u2_noun wac = u2k(u2h(hoe)); u2z(hoe); return u2_cm_bail(wac); } } else { u2_noun pro = _nock_mool(bus, fol, &pon); u2_cm_done(); res = u2nc(pon, pro); } } return res; }
/* _unix_desk_sync_tako(): sync out change. */ static void _unix_desk_sync_tako(u2_udir* dir_u, u2_noun pax, u2_noun mis) { if ( (u2_no == u2du(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); 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 _unix_desk_sync_tofu(dir_u->par_u, pem, u2k(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); if ( u2_nul == tt_pax ) { _unix_desk_sync_tofu(dir_u, u2k(i_pax), u2k(it_pax), mis); } else { u2_udir** dis_u = _unix_pdir(dir_u, u2k(i_pax)); if ( !*dis_u ) { *dis_u = c3_malloc(sizeof(u2_udir)); _unix_dir_forge(*dis_u, dir_u, u2k(i_pax)); } _unix_desk_sync_tako(*dis_u, u2k(t_pax), mis); } } u2z(pax); }
/* u2_ckd_by_get(): map get for key `b` in map `a` with u2_none. */ u2_weak u2_ckd_by_get(u2_noun a, u2_noun b) { u2_noun c = _coal_by_get(u2_Wire, a, b); u2_cz(a); u2_cz(b); if ( u2_no == u2_cr_du(c) ) { u2_cz(c); return u2_none; } else { u2_noun pro = u2_ct(u2t(c)); u2_cz(c); return pro; } }
/* _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) { u2_noun tap = tep; while ( u2_nul != tap ) { c3_c car_c; if ( u2h(tap) >= 127 ) { car_c = '?'; } else car_c = u2h(tap); putc(car_c, fil_u); tap = u2t(tap); } u2z(tep); }
/* _lo_wall(): dump a wall, old style. Don't do this. */ static void _lo_wall(u2_reck* rec_u, u2_noun wol) { FILE* fil_u = u2_term_io_hija(); u2_noun wal = wol; while ( u2_nul != wal ) { _lo_tape(rec_u, fil_u, u2k(u2h(wal))); putc(13, fil_u); putc(10, fil_u); wal = u2t(wal); } u2_term_io_loja(0); u2z(wol); }
/* u2_lo_punt(): dump tank list. */ void u2_lo_punt(c3_l tab_l, u2_noun tac) { u2_noun blu = u2_term_get_blew(0); c3_l col_l = u2h(blu); u2_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))); _lo_wall(u2_Arv, wol); cat = u2t(cat); } u2z(tac); u2z(blu); }
/* _unix_desk_peek(): peek for ankh. */ static u2_noun _unix_desk_peek(u2_noun hox, u2_noun syd, u2_noun lok) { u2_noun cay; cay = u2_reck_prick (u2A, u2nc(c3_s2('c','z'), u2nq(hox, syd, lok, u2_nul))); if ( u2_nul == cay ) { return u2nt(0, u2_nul, u2_nul); } else { u2_noun ank = u2k(u2t(cay)); u2z(cay); return ank; } }
/* _unix_dir_ankh(): resolve directory to new style ankh. */ static u2_noun _unix_dir_ankh(u2_udir* dir_u) { u2_udir* dis_u; u2_ufil* fil_u; u2_noun pam = u2_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); // uL(fprintf(uH, "dir %s\n", u2_cr_string(pre))); if ( 0 != u2h(ank) ) { pam = u2_ckd_by_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); 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); } } 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); pam = _unix_dir_ankh_file(pam, wib, baw, woz); } return u2_do("cosh", u2nt(0, u2_nul, pam)); }
/** A conversation has been closed */ void mwIm_conversation_closed(mwConversation *conv, guint32 err) { if(err & ERR_FAILURE && err != CONNECTION_RESET) { char *msg = mwError(err); TCHAR *ts = u2t(msg); //MessageBox(0, ts, TranslateT("Sametime Error"), MB_OK | MB_ICONWARNING); ShowError(TranslateTS(ts)); g_free(msg); free(ts); } mwIdBlock *idb = mwConversation_getTarget(conv); HANDLE hContact = FindContactByUserId(idb->user); if(hContact) { ContactMessageQueue::iterator i; EnterCriticalSection(&q_cs); if((i = contact_message_queue.find(hContact)) != contact_message_queue.end()) { contact_message_queue.erase(i); } LeaveCriticalSection(&q_cs); } }