Version 0.9: Use a nickserv password, and some fixes for OCaml 3.11.
[xavierbot.git] / init.in
diff --git a/init.in b/init.in
index b4168cb..7afac34 100644 (file)
--- a/init.in
+++ b/init.in
@@ -1,5 +1,5 @@
 (* Initialise the toplevel environment. -*- tuareg -*-
- * $Id: init.in,v 1.3 2007/06/29 13:15:02 rjones Exp $
+ * $Id: init.in,v 1.9 2010/04/04 19:38:40 rjones Exp $
  * - Removes the Pervasives module and any dangerous functions.
  * - Loads just the modules we want to give access to, and just
  *   the functions within those modules that we want to give.
@@ -9,8 +9,10 @@
  *)
 
 (* Load some libraries. *)
+#load "dynlink.cma";;
 #load "nums.cma";;
 #load "unix.cma";;
+#load "str.cma";;
 
 (* Remove the Pervasives module. *)
 module Pervasives = struct end;;
@@ -59,11 +61,14 @@ let _ = Complex.zero
 let _ = Hashtbl.create
 let _ = Int32.to_string
 let _ = Int64.to_string
+let _ = Lazy.force
 let _ = List.length
 let _ = Nativeint.to_string
 let _ = Num.add_num
+let _ = Random.int
 let _ = Ratio.null_denominator
 let _ = Stack.create
+let _ = Str.regexp
 
 (* Allow only safe functions from String. *)
 module String : sig
@@ -149,15 +154,52 @@ module Array : sig
   val fast_sort : ('a -> 'a -> int) -> 'a array -> unit
 end = struct include Array end
 
+(* Allow only safe functions from Printf. *)
+module Printf : sig
+  val printf : ('a, out_channel, unit) format -> 'a
+  val sprintf : ('a, unit, string) format -> 'a
+end = struct include Printf end
+
+(* Allow only safe functions from Scanf. *)
+module Scanf : sig
+  module Scanning : sig
+    type scanbuf;;
+    val stdib : scanbuf;;
+    val from_string : string -> scanbuf;;
+    val from_function : (unit -> char) -> scanbuf;;
+    val end_of_input : scanbuf -> bool;;
+    val beginning_of_input : scanbuf -> bool;;
+    val name_of_input : scanbuf -> string;;
+  end;;
+  exception Scan_failure of string;;
+  type ('a, 'b, 'c, 'd) scanner =
+       ('a, Scanning.scanbuf, 'b, 'c, 'a -> 'd, 'd) format6 -> 'c;;
+  val bscanf : Scanning.scanbuf -> ('a, 'b, 'c, 'd) scanner;;
+  val sscanf : string -> ('a, 'b, 'c, 'd) scanner;;
+  val scanf : ('a, 'b, 'c, 'd) scanner;;
+  val kscanf :
+    Scanning.scanbuf -> (Scanning.scanbuf -> exn -> 'd) ->
+      ('a, 'b, 'c, 'd) scanner;;
+  val bscanf_format :
+    Scanning.scanbuf -> ('a, 'b, 'c, 'd, 'e, 'f) format6 ->
+      (('a, 'b, 'c, 'd, 'e, 'f) format6 -> 'g) -> 'g;;
+  val sscanf_format :
+    string -> ('a, 'b, 'c, 'd, 'e, 'f) format6 ->
+      (('a, 'b, 'c, 'd, 'e, 'f) format6 -> 'g) -> 'g;;
+  val format_from_string :
+    string ->
+      ('a, 'b, 'c, 'd, 'e, 'f) format6 -> ('a, 'b, 'c, 'd, 'e, 'f) format6;;
+end = struct include Scanf end
+
 (* Set and Map. *)
 module StringSet = Set.Make(String)
 module StringMap = Map.Make(String)
 
-(* Create an object, so we get the CamlinternalOO module. *)
-(* XXX Are any of the methods unsafe? *)
+(* Create an object, so we get the CamlinternalOO module ... *)
 let _ = object end
 
-(* Load our custom grammar, which disables "external". *)
+(* ... but prevent public access to CamlinternalOO. *)
+module CamlinternalOO = struct end
 
 #load "camlp4o.cma";;
 #load "./pa_noexternal.cmo";;