Ejemplo n.º 1
0
Archivo: unix.c Proyecto: esaul/urbit
/* _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)
{
  u2_noun xun, bur, doz, fav, pax;

  xun = _unix_dir_ankh(dir_u);
  bur = _unix_desk_peek(hox, u2k(syd), u2k(u2A->wen));

  if ( (u2_no == u2_sing(u2h(xun), u2h(bur)))) //&&
  //     (u2_no == _unix_ankh_sing(xun, bur)) )
  {
    doz = u2_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));

    u2_reck_plan(u2A, pax, fav);
  }
  else {
    u2z(who); u2z(syd); u2z(xun); u2z(bur);
  }
}
Ejemplo n.º 2
0
/* u2_term_ef_boil(): initial effects for loaded servers.
*/
void
u2_term_ef_boil(c3_l ono_l)
{
  if ( ono_l ) {
    u2_noun tid_l;

    for ( tid_l = 2; tid_l <= ono_l; tid_l++ ) {
      u2_noun tin = u2_dc("scot", c3__ud, tid_l);
      u2_noun pax = u2nq(c3__gold, c3__term, tin, u2_nul);
      u2_noun hud = u2nc(c3__wipe, u2_nul);

      u2_reck_plan(u2A, pax, hud);
    }
  }

  {
    u2_noun pax = u2nq(c3__gold, c3__term, '1', u2_nul);

    //  u2_reck_plan(u2A, u2k(pax), u2nc(c3__init, u2k(u2h(u2A->own))));
    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));

    u2z(pax);
  }
}
Ejemplo n.º 3
0
/* u2_unix_ef_init(): update filesystem for new acquisition.
*/
void
u2_unix_ef_init(u2_noun who)
{
  _unix_hot_gain(u2k(who), u2_yes);

  u2_reck_plan(u2A, u2nq(c3__gold, c3__sync, u2k(u2A->sen), u2_nul),
                    u2nq(c3__into, who, u2_blip, u2nc(u2_yes, u2_nul)));
}
/* u2_term_ef_winc(): window change.  Just console right now.
*/
void
u2_term_ef_winc(void)
{
  u2_noun pax = u2nq(u2_blip, c3__term, '1', u2_nul);

  u2_proc_plan(u2A, pax, u2nc(c3__blew, u2_term_get_blew(1)));
}
/* _term_close_cb(): free terminal.
*/
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;
  }
  else {
    u2_utty* uty_u;
    for (uty_u = u2_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;
      }
    }
  }

  {
    u2_noun tid = u2_dc("scot", c3__ud, tty_u->tid_l);
    u2_noun pax = u2nq(u2_blip, c3__term, tid, u2_nul);
    u2_proc_plan(u2A, u2k(pax), u2nc(c3__hook, u2_nul));
    u2z(pax);
  }
  free(tty_u);
}
Ejemplo n.º 6
0
/* u2_term_ef_winc(): window change.  Just console right now.
*/
void
u2_term_ef_winc(void)
{
  u2_noun pax = u2nq(c3__gold, c3__term, '1', u2_nul);

  u2_reck_plan(u2A, pax, u2nc(c3__blew, u2_term_get_blew(1)));
}
Ejemplo n.º 7
0
/* u2_term_ef_ctlc(): send ^C on console.
*/
void
u2_term_ef_ctlc(void)
{
  u2_noun pax = u2nq(c3__gold, c3__term, '1', u2_nul);

  u2_reck_plan(u2A, pax, u2nt(c3__belt, c3__ctl, 'c'));
}
Ejemplo n.º 8
0
void
u2_http_ef_bake(void)
{
  u2_noun pax = u2nq(c3__gold, c3__http, u2k(u2A->sen), u2_nul);

  u2_reck_plan(u2A, pax, u2nc(c3__born, u2_nul));
}
/* u2_term_ef_ctlc(): send ^C on console.
*/
void
u2_term_ef_ctlc(void)
{
  u2_noun pax = u2nq(u2_blip, c3__term, '1', u2_nul);

  u2_proc_plan(u2A, pax, u2nt(c3__belt, c3__ctl, 'c'));
}
Ejemplo n.º 10
0
/* _term_io_belt(): send belt.
*/
static void
_term_io_belt(u2_utty* uty_u, u2_noun  blb)
{
  u2_noun tid = u2_dc("scot", c3__ud, uty_u->tid_l);
  u2_noun pax = u2nq(c3__gold, c3__term, tid, u2_nul);

  u2_reck_plan(u2A, pax, u2nc(c3__belt, blb));
}
Ejemplo n.º 11
0
/* u2_term_ef_bake(): initial effects for new terminal.
*/
void
u2_term_ef_bake(u2_noun  fav)
{
  u2_noun pax = u2nq(c3__gold, c3__term, '1', u2_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));

  u2z(pax);
}
Ejemplo n.º 12
0
//  _lo_bench_noop(): benchmark no-op events.
//
static void
_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(c3__gold, c3__term, 1, u2_nul),
                      u2nc(c3__noop, u2_nul));
  }

  u2_raft_work(u2A);
}
Ejemplo n.º 13
0
/* _http_pox_to_noun(): translate srv/con/req to path noun (pox).
*/
static u2_noun
_http_pox_to_noun(c3_w sev_l, c3_w coq_l, c3_w seq_l)
{
  return
    u2nt(
      c3__iron,
      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));
}
Ejemplo n.º 14
0
/* _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)
{
  u2_noun xun, bur, doz, fav, pax;

  xun = _unix_dir_arch(dir_u);
  bur = _unix_desk_peek(u2k(who), hox, syd, u2k(u2A->wen));

  if ( u2_no == u2_sing(xun, bur) ) {
    doz = u2_dc("cyst", xun, bur);
    pax = u2nq(c3__gold, c3__sync, u2k(u2A->sen), u2_nul);
    fav = u2nq(c3__into, who, syd, u2nc(u2_yes, doz));

    u2_reck_plan(u2A, pax, fav);
  } 
  else {
    u2z(xun); u2z(bur);
  }
}
/* u2_term_ef_boil(): initial effects for loaded servers.
*/
void
u2_term_ef_boil(void)
{
  {
    u2_noun pax = u2nq(u2_blip, c3__term, '1', u2_nul);

    //  u2_proc_plan(u2A, u2k(pax), u2nc(c3__init, u2k(u2h(u2A->own))));
    u2_proc_plan(u2A, u2k(pax), u2nc(c3__harm, u2_nul));
    u2_proc_plan(u2A, u2k(pax), u2nc(c3__blew, u2_term_get_blew(1)));
    u2_proc_plan(u2A, u2k(pax), u2nc(c3__hail, u2_nul));

    u2z(pax);
  }
}
Ejemplo n.º 16
0
/* _http_request_to_noun(): translate http request into noun, or u2_none.
*/
static u2_noun
_http_request_to_noun(u2_hreq* req_u)
{
  u2_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; }
  }
  url = u2_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;

  return u2nq(med, url, hed, bod);
}
Ejemplo n.º 17
0
/* _http_request(): dispatch http request, returning null if async.
*/
static void
_http_request(u2_hreq* req_u)
{
  u2_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,
                                    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));
  }
}
Ejemplo n.º 18
0
Archivo: unix.c Proyecto: esaul/urbit
/* _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;
  }
}
/* _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;
      u2_utel* tel_u;
      u2_noun pax;
      u2_noun blu;
      u2_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 = 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_proc_plan(u2A, pax, u2nc(c3__blew, blu));
      break;
    }
  }
}
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);
  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 = u2_no;
    tty_u->tat_u.esc.bra = u2_no;

    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 = u2_Host.uty_u->tid_l + 1;
    tty_u->nex_u = u2_Host.uty_u;
    u2_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_proc_plan(u2A, u2k(pax), u2nc(c3__blew, u2nc(80, 25)));
      u2_proc_plan(u2A, u2k(pax), u2nc(c3__hail, u2_nul));
      u2z(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);
  }
}