chiark / gitweb /
need cast for crappy tcl no const correct
[chiark-tcl.git] / hbytes / hook.c
index 937295842b8045c3b765e45084f7a32c2d0ac058..32c604f9101a5603fad7cadede960a026e59f68c 100644 (file)
@@ -22,6 +22,13 @@ int posixerr(Tcl_Interp *ip, int errnoval, const char *m) {
   return TCL_ERROR;
 }
 
+int newfdposixerr(Tcl_Interp *ip, int fd, const char *m) {
+  int e;
+  e= errno;
+  close(fd);
+  return posixerr(ip,e,m);
+}
+
 void objfreeir(Tcl_Obj *o) {
   if (o->typePtr && o->typePtr->freeIntRepProc)
     o->typePtr->freeIntRepProc(o);
@@ -255,6 +262,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;
@@ -345,6 +368,12 @@ int do_toplevel_dgram_socket(ClientData cd, Tcl_Interp *ip,
   return subcmd->func(0,ip,objc,objv);
 }
 
+int do_toplevel_tuntap_socket_raw(ClientData cd, Tcl_Interp *ip,
+                                 const TunSocket_SubCommand *subcmd,
+                                 int objc, Tcl_Obj *const *objv) {
+  return subcmd->func(0,ip,objc,objv);
+}
+
 int do_toplevel_ulong(ClientData cd, Tcl_Interp *ip,
                      const ULong_SubCommand *subcmd,
                      int objc, Tcl_Obj *const *objv) {
@@ -384,13 +413,13 @@ int Hbytes_Init(Tcl_Interp *ip) {
   Tcl_RegisterObjType(&enum_nearlytype);
   Tcl_RegisterObjType(&enum1_nearlytype);
   Tcl_RegisterObjType(&sockaddr_type);
-  Tcl_RegisterObjType(&dgramsockid_type);
+  Tcl_RegisterObjType(&tabledataid_nearlytype);
   Tcl_RegisterObjType(&ulong_type);
 
   for (cmd=toplevel_commands;
        cmd->name;
        cmd++)
-    Tcl_CreateObjCommand(ip, cmd->name, cmd->func, 0,0);
+    Tcl_CreateObjCommand(ip, (char*)cmd->name, cmd->func, 0,0);
 
   return TCL_OK;
 }