/* u3_term_ef_bake(): initial effects for new terminal. */ void u3_term_ef_bake(u3_noun fav) { u3_noun pax = u3nq(u3_blip, c3__term, '1', u3_nul); u3v_plan(u3k(pax), u3nc(c3__boot, fav)); u3v_plan(u3k(pax), u3nc(c3__blew, u3_term_get_blew(1))); u3v_plan(u3k(pax), u3nc(c3__hail, u3_nul)); u3z(pax); }
/* u3_term_ef_boil(): initial effects for loaded servers. */ void u3_term_ef_boil(void) { { u3_noun pax = u3nq(u3_blip, c3__term, '1', u3_nul); // u3v_plan(u3k(pax), u3nc(c3__init, u3k(u3h(u3A->own)))); u3v_plan(u3k(pax), u3nc(c3__harm, u3_nul)); u3v_plan(u3k(pax), u3nc(c3__blew, u3_term_get_blew(1))); u3v_plan(u3k(pax), u3nc(c3__hail, u3_nul)); u3z(pax); } }
/* u3_term_ef_winc(): window change. Just console right now. */ void u3_term_ef_winc(void) { u3_noun pax = u3nq(u3_blip, c3__term, '1', u3_nul); u3v_plan(pax, u3nc(c3__blew, u3_term_get_blew(1))); }
/* u3_term_ef_ctlc(): send ^C on console. */ void u3_term_ef_ctlc(void) { u3_noun pax = u3nq(u3_blip, c3__term, '1', u3_nul); u3v_plan(pax, u3nt(c3__belt, c3__ctl, 'c')); }
/* u3_term_ef_verb(): initial effects for verbose events */ void u3_term_ef_verb(void) { u3_noun pax = u3nq(u3_blip, c3__term, '1', u3_nul); u3v_plan(pax, u3nc(c3__verb, u3_nul)); }
void u3_http_ef_bake(void) { u3_noun pax = u3nq(u3_blip, c3__http, u3k(u3A->sen), u3_nul); u3v_plan(pax, u3nc(c3__born, u3_nul)); }
/* _term_close_cb(): free terminal. */ static void _term_close_cb(uv_handle_t* han_t) { u3_utty* tty_u = (void*) han_t; if ( u3_Host.uty_u == tty_u ) { u3_Host.uty_u = tty_u->nex_u; } else { 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; } } } { u3_noun tid = u3dc("scot", c3__ud, tty_u->tid_l); u3_noun pax = u3nq(u3_blip, c3__term, tid, u3_nul); u3v_plan(u3k(pax), u3nc(c3__hook, u3_nul)); u3z(pax); } free(tty_u); }
/* _term_io_belt(): send belt. */ static void _term_io_belt(u3_utty* uty_u, u3_noun blb) { u3_noun tid = u3dc("scot", c3__ud, uty_u->tid_l); u3_noun pax = u3nq(u3_blip, c3__term, tid, u3_nul); u3v_plan(pax, u3nc(c3__belt, blb)); }
/* _http_request_dead(): kill http request. */ static void _http_request_dead(u3_hreq* req_u) { 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); u3v_plan(pox, u3nc(c3__thud, u3_nul)); }
void u3_unix_ef_initial_into() { c3_c* pax_c = _unix_down(U3_LIB, "arvo"); u3_noun can = _unix_initial_update_dir(pax_c); free(pax_c); u3v_plan(u3nq(u3_blip, c3__sync, u3k(u3A->sen), u3_nul), u3nq(c3__into, u3_nul, c3y, can)); }
/* _unix_update_mount(): update mount point */ static void _unix_update_mount(u3_umon* mon_u, u3_noun all) { if ( c3n == mon_u->dir_u.dry ) { u3_noun can = u3_nul; u3_unod* nod_u; for ( nod_u = mon_u->dir_u.kid_u; nod_u; nod_u = nod_u->nex_u ) { can = u3kb_weld(_unix_update_node(nod_u), can); } u3v_plan(u3nq(u3_blip, c3__sync, u3k(u3A->sen), u3_nul), u3nq(c3__into, u3i_string(mon_u->nam_c), all, can)); } }
/* u3_unix_io_init(): initialize unix sync. */ void u3_unix_io_init(void) { u3_unix* unx_u = &u3_Host.unx_u; unx_u->mon_u = NULL; { u3_usig* sig_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; } { u3_usig* sig_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; } { u3_usig* sig_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; unx_u->sig_u = sig_u; } uv_check_init(u3_Host.lup_u, &u3_Host.unx_u.syn_u); uv_timer_init(u3L, &unx_u->tim_u); unx_u->alm = c3n; unx_u->dyr = c3n; if ( c3n == u3_Host.ops_u.nuu ) { u3v_plan(u3nt(u3_blip, c3__boat, u3_nul), u3nc(c3__boat, u3_nul)); } }
/* _temp_time_cb(): timer callback. */ static void _temp_time_cb(uv_timer_t* tim_u) { u3_temp* teh_u = &u3_Host.teh_u; if(teh_u->run_w < 1024) { teh_u->run_w++; } u3_lo_open(); { u3v_plan (u3nt(u3_blip, c3__temp, u3_nul), u3nc(c3__wake, u3_nul)); } u3_lo_shut(c3n); }
/* _http_request(): dispatch http request, returning null if async. */ static void _http_request(u3_hreq* req_u) { u3_noun req = _http_request_to_noun(req_u); 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); u3v_plan(pox, u3nq(c3__this, req_u->hon_u->htp_u->sec, u3nc(c3y, u3i_words(1, &req_u->ipf_w)), req)); } }
/* u3_term_ef_ticket(): initial effects for new ticket. */ void u3_term_ef_ticket(c3_c* who_c, c3_c* tic_c) { u3_noun pax = u3nq(u3_blip, c3__term, '1', u3_nul); u3_noun who, tic; u3_noun whu, tuc; whu = u3dc("slaw", 'p', u3i_string(who_c)); if ( u3_nul == whu ) { fprintf(stderr, "ticket: invalid planet '%s'\r\n", who_c); exit(1); } else { who = u3k(u3t(whu)); u3z(whu); } tuc = u3dc("slaw", 'p', u3i_string(tic_c)); if ( u3_nul == tuc ) { fprintf(stderr, "ticket: invalid secret '%s'\r\n", tic_c); exit(1); } else { tic = u3k(u3t(tuc)); u3z(tuc); } u3v_plan(pax, u3nt(c3__tick, who, tic)); }
/* _tel_opt(): telnet event sucker */ static void _tel_opt(_te_nvt* nvt, telnet_byte opt, _to_evt* evt) { switch (evt->type) { default: break; case TELNET_EV_TELOPT_DATA: { _to_dvt* dv = (_to_dvt*)evt; u3_utel* tel_u; u3_noun pax; u3_noun blu; u3_noun tid; c3_s col_s; c3_s row_s; if ( opt != _T_NAWS ) { return; } c3_assert(0 < telnet_get_userdata(nvt, (void**)&tel_u)); col_s = dv->data[1] | (dv->data[0] << 8); row_s = dv->data[3] | (dv->data[2] << 8); tel_u->uty_t.tat_u.siz.col_l = col_s; tel_u->uty_t.tat_u.siz.row_l = row_s; tid = u3dc("scot", c3__ud, tel_u->uty_t.tid_l); pax = u3nq(u3_blip, c3__term, tid, u3_nul); blu = u3nc(col_s, row_s); u3v_plan(pax, u3nc(c3__blew, blu)); break; } } }
void _term_listen_cb(uv_stream_t *wax_u, int sas_i) { 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", uv_strerror(ret_w))); uv_close((uv_handle_t*)&tty_u->wax_u, NULL); free(tty_u); } else { uv_read_start((uv_stream_t*)&tty_u->wax_u, _term_alloc, _term_read_tn_cb); tty_u->ufo_u.out.clear_y = (const c3_y*)"\033[H\033[J"; tty_u->ufo_u.out.el_y = (const c3_y*)"\033[K"; tty_u->ufo_u.out.ed_y = (const c3_y*)"\033[J"; tty_u->ufo_u.out.bel_y = (const c3_y*)"\007"; tty_u->ufo_u.out.cub1_y = (const c3_y*)"\010"; tty_u->ufo_u.out.cud1_y = (const c3_y*)"\033[B"; tty_u->ufo_u.out.cuu1_y = (const c3_y*)"\033[A"; tty_u->ufo_u.out.cuf1_y = (const c3_y*)"\033[C"; tty_u->ufo_u.inn.kcuu1_y = (const c3_y*)"\033[A"; tty_u->ufo_u.inn.kcud1_y = (const c3_y*)"\033[B"; tty_u->ufo_u.inn.kcuf1_y = (const c3_y*)"\033[C"; tty_u->ufo_u.inn.kcub1_y = (const c3_y*)"\033[D"; tty_u->ufo_u.inn.max_w = strlen("\033[D"); tty_u->fid_i = -1; tty_u->tat_u.mir.lin_w = 0; tty_u->tat_u.mir.len_w = 0; tty_u->tat_u.mir.cus_w = 0; tty_u->tat_u.esc.ape = c3n; tty_u->tat_u.esc.bra = c3n; tty_u->tat_u.fut.len_w = 0; tty_u->tat_u.fut.wid_w = 0; tty_u->tat_u.siz.col_l = 80; tty_u->tat_u.siz.row_l = 25; 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); { u3_noun tid = u3dc("scot", c3__ud, tty_u->tid_l); u3_noun pax = u3nq(u3_blip, c3__term, tid, u3_nul); u3v_plan(u3k(pax), u3nc(c3__blew, u3nc(80, 25))); u3v_plan(u3k(pax), u3nc(c3__hail, u3_nul)); u3z(pax); } telnet_telopt_enable(pty_u->tel_u, _T_ECHO, TELNET_LOCAL); telnet_telopt_enable(pty_u->tel_u, _T_CTIM, TELNET_LOCAL); telnet_telopt_enable(pty_u->tel_u, _T_NAWS, TELNET_REMOTE); } }