Пример #1
0
/* _sh_good(): verify payload integrity in core.
*/
static u2_flag
_sh_good(u2_noun cor,
         u2_noun xip)
{
#if 1
  return u2_yes;    //  Good!  Ja!  Everything good!
#else
  while ( 1 ) {
    u2_noun bat = u2_h(u2_t(xip));
    u2_noun pet = u2_t(u2_t(xip));

    if ( u2_no == u2_sing(bat, u2_t(cor)) ) {
      {
        char *cos_c = u2_ho_cstring(xip);

        printf("sh: cos_c: %s\n", cos_c);
      }
      c3_assert(0);
      u2_ho_warn_here();
      return u2_no;
    }
    else {
      if ( _0 == pet ) {
        return u2_yes;
      } else {
        u2_atom axe = u2_h(pet);
        u2_noun nub = u2_frag(axe, cor);

        if ( u2_none == nub ) {
          return u2_no;
        } else {
          cor = nub;
          xip = u2_t(pet);
          continue;
        }
      }
    }
  }
#endif
}
Пример #2
0
/* u2_ds_mine():
**
**   Register and/or save core.
*/
u2_noun                                                           //  transfer
u2_ds_mine(u2_wire wir_r,
           u2_noun clu,                                           //  retain
           u2_noun cor)                                           //  transfer
{
  u2_noun bas_r = u2_wire_bas_r(wir_r);

  if ( u2_no == u2_dust(cor) ) {
    return cor;
  } else {
    u2_noun pay = u2_t(cor);
    u2_noun bat = u2_h(cor);
    u2_noun pug = u2_cs_find(bas_r, u2_wire_des_r(wir_r), 0, bat);
    u2_noun xip, bat_xip;
    u2_noun gop;

    if ( u2_none == pug ) {
      pug = u2_nul;
    }
    if ( u2_none == (xip = _ds_scan(pug, cor)) ) {
      gop = u2_rc(bas_r, (xip = _ds_chip(wir_r, clu, cor)), u2_rx(bas_r, pug));

      if ( u2_none == gop ) {
        return cor;
      } else {
        bat_xip = u2_h(u2_t(xip));

#if 0
        {
          c3_c* xip_c = u2_ho_cstring(xip);

          fprintf(stderr, "!%s - lent %d\r\n", xip_c, u2_ckb_lent(gop));
          free(xip_c);
        }
#endif
        gop = u2_cs_save(bas_r, u2_wire_des_r(wir_r), 0, bat_xip, gop);
        {
          u2_noun poo = u2_cs_find(bas_r, u2_wire_des_r(wir_r), 0, bat_xip);

          {
            _ds_scan(poo, cor);
          }
        }
        u2_rz(bas_r, gop);

      }
    }
    else {
      bat_xip = u2_h(u2_t(xip));
    }

    if ( bat_xip != bat ) {
      u2_noun cyr = u2_rc(wir_r, bat_xip, u2_rx(wir_r, pay));

      if ( u2_none == cyr ) {
        return cor;
      }
      else {
        u2_rz(wir_r, cor);
        return cyr;
      }
    }
    else return cor;
  }
}