-int do__hbytes(ClientData cd, Tcl_Interp *ip,
- const HBytes_SubCommand *subcmd,
- int objc, Tcl_Obj *const *objv) {
- return subcmd->func(0,ip,objc,objv);
+int cht_do_hbytes_random(ClientData cd, Tcl_Interp *ip,
+ int length, HBytes_Value *result) {
+ Byte *space;
+ int rc;
+
+ space= cht_hb_arrayspace(result, length);
+ rc= cht_get_urandom(ip, space, length);
+ if (rc) { cht_hb_free(result); return rc; }
+ return TCL_OK;
+}
+
+int cht_do_hbytes_overwrite(ClientData cd, Tcl_Interp *ip,
+ HBytes_Var v, int start, HBytes_Value sub) {
+ int sub_l;
+
+ sub_l= cht_hb_len(&sub);
+ if (start < 0)
+ return cht_staticerr(ip, "hbytes overwrite start -ve",
+ "HBYTES LENGTH RANGE");
+ if (start + sub_l > cht_hb_len(v.hb))
+ return cht_staticerr(ip, "hbytes overwrite out of range",
+ "HBYTES LENGTH UNDERRUN");
+ memcpy(cht_hb_data(v.hb) + start, cht_hb_data(&sub), sub_l);
+ return TCL_OK;