示例#1
0
文件: shax.c 项目: urbit/urbit
  static u3_noun
  _og_list(u3_noun a,
           u3_noun b,
           u3_noun c)
  {
    u3_noun l = u3_nul;

    if ( !_(u3a_is_cat(b)) ) {
      return u3m_bail(c3__fail);
    }
    while ( 0 != b ) {
      u3_noun x = u3qc_mix(a, c);
      u3_noun y = u3qc_mix(b, x);
      u3_noun d = u3qe_shas(c3_s4('o','g','-','b'), y);
      u3_noun m;

      u3z(x); u3z(y);

      if ( b < 256 ) {
        u3_noun e = u3qc_end(0, b, d);

        u3z(d);
        m = u3nc(b, e);
        b = 0;
      } else {
        m = u3nc(256, d);
        c = d;

        b -= 256;
      }
      l = u3nc(m, l);
    }
    return u3kb_flop(l);
  }
示例#2
0
文件: shax.c 项目: aaronlifton/urbit
  static u2_noun                                                  //  produce
  _og_list(u2_wire wir_r,
           u2_noun a,                                             //  retain
           u2_noun b,                                             //  retain
           u2_noun c)                                             //  retain
  {
    u2_noun l = u2_nul;

    if ( !u2_fly_is_cat(b) ) {
      return u2_bl_bail(wir_r, c3__fail);
    }
    while ( 0 != b ) {
      u2_noun x = j2_mbc(Pt3, mix)(wir_r, a, c);
      u2_noun y = j2_mbc(Pt3, mix)(wir_r, b, x);
      u2_noun d = j2_mbc(Pt5, shas)(wir_r, c3_s4('o','g','-','b'), y);
      u2_noun m;

      u2z(x); u2z(y);

      if ( b < 256 ) {
        u2_noun e = j2_mbc(Pt3, end)(wir_r, 0, b, d);
        
        u2z(d);
        m = u2nc(b, e);
        b = 0;
      } else {
        m = u2nc(256, d);
        c = d;

        b -= 256;
      }
      l = u2nc(m, l);
    }
    return u2_ckb_flop(l);
  }
示例#3
0
文件: unix.c 项目: esaul/urbit
/* _unix_fs_event_cb(): filesystem event callback.
*/
static void
_unix_fs_event_cb(uv_fs_event_t* was_u,
                  const c3_c*    pax_c,
                  c3_i           evt_i,
                  c3_i           sas_i)
{
  
  // note that we're doing something tricky and weird here.
  //
  // * libuv passes around a pointer to a uv_fs_event_t
  // * we define a struct that STARTS with a uv_fs_event_t and then has
  //     more fields after it
  // * 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;

#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);
#endif

  {
    while ( nod_u ) {
      nod_u->dry = u2_no;
      nod_u = (u2_unod*) nod_u->par_u;
    }
  }
}
示例#4
0
文件: term.c 项目: laanwj/urbit
/* _term_it_save(): save file by path.
*/
static void
_term_it_save(u3_noun pax, u3_noun pad)
{
  c3_c* pax_c;

  pax = u3nt(c3_s4('.','u','r','b'), c3_s3('p','u','t'), pax);
  pax_c = _term_it_path(c3y, pax);

  u3_walk_save(pax_c, 0, pad);
  free(pax_c);
}
示例#5
0
文件: shax.c 项目: urbit/urbit
  u3_noun
  u3qeo_raw(u3_atom a,
            u3_atom b)
  {
    u3_noun x = u3qc_mix(b, a);
    u3_noun c = u3qe_shas(c3_s4('o','g','-','a'), x);
    u3_noun l = _og_list(a, b, c);
    u3_noun r = u3qc_can(0, l);

    u3z(l);
    u3z(c);
    u3z(x);

    return r;
  }
示例#6
0
文件: shax.c 项目: aaronlifton/urbit
  u2_noun                                                         //  produce
  j2_mcc(Pt5, og, raw)(u2_wire wir_r, 
                       u2_noun a,                                 //  retain
                       u2_noun b)                                 //  retain
  {
    u2_noun x = j2_mbc(Pt3, mix)(wir_r, b, a);
    u2_noun c = j2_mbc(Pt5, shas)(wir_r, c3_s4('o','g','-','a'), x);
    u2_noun l = _og_list(wir_r, a, b, c);
    u2_noun r = j2_mbc(Pt3, can)(wir_r, 0, l);

    u2z(l);
    u2z(c);
    u2z(x);

    return r;
  }
示例#7
0
文件: unix.c 项目: esaul/urbit
/* _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)
{
  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;

  // uL(fprintf(uH, "tofu pox_c %s op %s\n", pox_c, u2_cr_string(u2h(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;
#endif

  fil_u = &(dir_u->fil_u);
  while ( 1 ) {                               //  XX crude!
    if ( !*fil_u ||
         !strcmp((*fil_u)->pax_c, pox_c) ||
         !strcmp((*fil_u)->pax_c, pux_c) )
    {
      break;
    }
    else fil_u = &((*fil_u)->nex_u);
  }

  if ( *fil_u && (c3__del == u2h(mis)) ) {
    u2_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);
#endif

    *fil_u = ded_u->nex_u;
    _unix_unlink(ded_u->pax_c);
    _unix_file_free(ded_u);

    free(pox_c);
    free(pux_c);
  }
  else {
    u2_noun god, oat;
    c3_c*   pax_c;

    if ( *fil_u ) {
      u2_noun old = _unix_file_load(*fil_u);
      c3_assert(c3__mut == u2h(mis));

      god = _unix_desk_sync_udon(u2k(u2t(mis)), old);
      _unix_unlink((*fil_u)->pax_c);
      free((*fil_u)->pax_c);
    }
    else {
      c3_assert(c3__ins == u2h(mis));
      god = u2k(u2t(mis));
    }

    if ( u2_yes == u2du(god) ) {
      oat = u2_cke_jam(god);
      pax_c = pux_c; free(pox_c);
    } else {
      oat = god;
      pax_c = pox_c; free(pux_c);
    }

#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);
#endif

    _unix_save(pax_c, oat);

    if ( *fil_u ) {
      (*fil_u)->dot_c = (pax_c + ((*fil_u)->dot_c - (*fil_u)->pax_c));
      (*fil_u)->pax_c = pax_c;

      mpz_clear((*fil_u)->mod_mp);
      u2_cr_mp((*fil_u)->mod_mp, u2A->now);
    }
    else {
      mpz_t mod_mp;

      u2_cr_mp(mod_mp, u2A->now);
      *fil_u = c3_malloc(sizeof(u2_ufil));

      _unix_file_watch(*fil_u, dir_u, pax_c, mod_mp);
      mpz_clear(mod_mp);
    }
  }
  u2z(pre); u2z(ext); u2z(mis);
}