+
+int do_hbytes_mask_map(ClientData cd, Tcl_Interp *ip,
+ const MaskMap_SubCommand *subcmd,
+ int objc, Tcl_Obj *const *objv) {
+ return subcmd->func(0,ip,objc,objv);
+}
+
+/* hbytes representing uint16_t's */
+
+int do_hbytes_h2ushort(ClientData cd, Tcl_Interp *ip,
+ HBytes_Value hex, long *result) {
+ const Byte *data;
+ int l;
+
+ l= hbytes_len(&hex);
+ if (l>2)
+ return staticerr(ip, "hbytes h2ushort input more than 4 hex digits",
+ "HBYTES VALUE OVERFLOW");
+
+ data= hbytes_data(&hex);
+ *result= data[l-1] | (l>1 ? data[0]<<8 : 0);
+ return TCL_OK;
+}
+
+int do_hbytes_ushort2h(ClientData cd, Tcl_Interp *ip,
+ long input, HBytes_Value *result) {
+ uint16_t us;
+
+ if (input > 0x0ffff)
+ return staticerr(ip, "hbytes ushort2h input >2^16",
+ "HBYTES VALUE OVERFLOW");
+
+ us= htons(input);
+ hbytes_array(result,(const Byte*)&us,2);
+ return TCL_OK;
+}
+
+/* toplevel functions */
+