-#define URANDOM "/dev/urandom"
-
-int get_urandom(Tcl_Interp *ip, Byte *buffer, int l) {
- static FILE *urandom;
-
- int r, esave;
-
- if (!urandom) {
- urandom= fopen(URANDOM,"rb");
- if (!urandom) return posixerr(ip,errno,"open " URANDOM);
- }
- r= fread(buffer,1,l,urandom);
- if (r==l) return 0;
-
- esave= errno;
- fclose(urandom); urandom=0;
-
- if (ferror(urandom)) {
- return posixerr(ip,errno,"read " URANDOM);
- } else {
- assert(feof(urandom));
- return staticerr(ip, URANDOM " gave eof!");
- }
-}
-
-int Hbytes_Init(Tcl_Interp *ip) {
- const TopLevel_Command *cmd;
-
- Tcl_RegisterObjType(&hbytes_type);
- Tcl_RegisterObjType(&blockcipherkey_type);
- Tcl_RegisterObjType(&enum_nearlytype);
- Tcl_RegisterObjType(&enum1_nearlytype);
- Tcl_RegisterObjType(&sockaddr_type);
- Tcl_RegisterObjType(&dgramsockid_type);
- Tcl_RegisterObjType(&ulong_type);
-
- for (cmd=toplevel_commands;
- cmd->name;
- cmd++)
- Tcl_CreateObjCommand(ip, cmd->name, cmd->func, 0,0);
-
- return TCL_OK;
+extern int Chiark_tcl_hbytes_Init(Tcl_Interp *ip); /*called by load(3tcl)*/
+int Chiark_tcl_hbytes_Init(Tcl_Interp *ip) {
+ static int initd;
+
+ return cht_initextension(ip, cht_hbytestoplevel_entries, &initd,
+ &cht_hbytes_type,
+ &cht_ulong_type,
+ &cht_addrmap_type,
+ (Tcl_ObjType*)0);