+ return TCL_OK;
+}
+
+int cht_do_hbytes_range(ClientData cd, Tcl_Interp *ip,
+ HBytes_Value v, int start, int size,
+ HBytes_Value *result) {
+ const Byte *data;
+ int l;
+
+ l= cht_hb_len(&v);
+ if (start<0 || size<0)
+ return cht_staticerr(ip,"hbytes range subscript(s) -ve","HBYTES LENGTH RANGE");
+ if (l<start+size)
+ return cht_staticerr(ip, "hbytes range subscripts too big",
+ "HBYTES LENGTH UNDERRUN");
+
+ data= cht_hb_data(&v);
+ cht_hb_array(result, data+start, size);
+ return TCL_OK;
+}
+
+int cht_do_hbytes_addr_map(ClientData cd, Tcl_Interp *ip,
+ const AddrMap_SubCommand *subcmd,
+ int objc, Tcl_Obj *const *objv) {
+ return subcmd->func(0,ip,objc,objv);
+}
+
+/* hbytes representing uint16_t's */
+
+int cht_do_hbytes_h2ushort(ClientData cd, Tcl_Interp *ip,
+ HBytes_Value hex, long *result) {
+ const Byte *data;
+ int l;
+
+ l= cht_hb_len(&hex);
+ if (l>2)
+ return cht_staticerr(ip, "hbytes h2ushort input more than 4 hex digits",
+ "HBYTES VALUE OVERFLOW");
+
+ data= cht_hb_data(&hex);
+ *result= data[l-1] | (l>1 ? data[0]<<8 : 0);
+ return TCL_OK;