chiark / gitweb /
hbytes xor
[chiark-tcl.git] / base / hook.c
index 937295842b8045c3b765e45084f7a32c2d0ac058..a9d0316f0c90089cce1f1383caa5030b30dfc8f0 100644 (file)
@@ -255,6 +255,22 @@ int do_hbytes_repeat(ClientData cd, Tcl_Interp *ip,
   return TCL_OK;
 }  
 
+int do_hbytes_xor(ClientData cd, Tcl_Interp *ip,
+                 HBytes_Var v, HBytes_Value d) {
+  int l;
+  Byte *dest;
+  const Byte *source;
+
+  l= hbytes_len(v.hb);
+  if (hbytes_len(&d) != l) return
+    staticerr(ip, "hbytes xor lengths do not match", "HBYTES LENGTH MISMATCH");
+
+  dest= hbytes_data(v.hb);
+  source= hbytes_data(&d);
+  memxor(dest,source,l);
+  return TCL_OK;
+}
+  
 int do_hbytes_zeroes(ClientData cd, Tcl_Interp *ip,
                     int length, HBytes_Value *result) {
   Byte *space;