X-Git-Url: http://git.hcoop.net/hcoop/zz_old/portal.git/blobdiff_plain/892e3ea166707b9eb737af7b21e1def215b49cb8..e23ca71c9431301fe484a74654c1ef5d73deca3b:/util.sml diff --git a/util.sml b/util.sml index a9ed02b..ee6c872 100644 --- a/util.sml +++ b/util.sml @@ -34,7 +34,7 @@ fun mult (r1, r2) = real r1 * r2 fun isIdent ch = Char.isLower ch orelse Char.isDigit ch orelse ch = #"-" fun validHost s = - size s > 0 andalso size s < 20 andalso List.all isIdent (String.explode s) + size s > 0 andalso size s < 40 andalso List.all isIdent (String.explode s) fun validDomain s = size s > 0 andalso size s < 100 andalso List.all validHost (String.fields (fn ch => ch = #".") s) @@ -64,7 +64,7 @@ fun init () = rnd := Random.rand (SysWord.toInt (Posix.Process.pidToWord (Posix. fun randomPassword () = Int.toString (Int.abs (Random.randInt (!rnd))) fun domainDir dom = - String.concatWith "/" ("/etc/domains" :: String.fields (fn ch => ch = #".") dom) + String.concatWith "/" ("/afs/hcoop.net/common/etc/domtool/nodes/deleuze" :: List.rev (String.fields (fn ch => ch = #".") dom)) fun readFile fname = let @@ -81,4 +81,10 @@ fun readFile fname = fun mem (x, ls) = List.exists (fn y => y = x) ls +val allLower = CharVector.map Char.toLower + +fun normEmail s = case String.tokens Char.isSpace (allLower s) of + s :: _ => s + | [] => "" + end