hostname : string,
id : string}
- fun checkSsl host =
- case String.fields (fn ch => ch = #".") host of
- first::rest =>
- (case String.fields (fn ch => ch = #"_") first of
- [first, "ssl"] => {ssl = true, hostname = String.concatWith "." (first::rest),
- id = host}
- | _ => {ssl = false, hostname = host, id = host})
- | _ => {ssl = false, hostname = host, id = host}
+ fun checkSsl (node, host) =
+ let
+ val id = case String.tokens (fn ch => ch = #".") host of
+ [] => node ^ "/" ^ host
+ | first :: rest =>
+ case rev (String.tokens (fn ch => ch = #"_") first) of
+ "ssl" :: rest' => node ^ "/" ^ String.concatWith "_" (rev rest')
+ ^ "." ^ String.concatWith "." rest ^ ".ssl"
+ | _ => node ^ "/" ^ host
+ in
+ case String.fields (fn ch => ch = #".") host of
+ first::rest =>
+ (case String.fields (fn ch => ch = #"_") first of
+ [first, "ssl"] => {ssl = true, hostname = String.concatWith "." (first::rest),
+ id = id}
+ | _ => {ssl = false, hostname = host, id = id})
+ | _ => {ssl = false, hostname = host, id = id}
+ end
fun getWebbw last =
let
(NONE | SOME "\n") => List.rev L
| SOME l =>
case String.tokens (fn ch => Char.isSpace ch orelse ch = #":") l of
- [d, n] => readEm ((checkSsl d, valOf (Int.fromString n)) :: L)
- | _ => raise Fail "Bad row in webbw"
+ [d, n] =>
+ (case String.tokens (fn ch => ch = #"@") d of
+ [d, node] => readEm ({host = checkSsl (node, d), size = valOf (Int.fromString n)} :: L)
+ | _ => raise Fail ("Bad row in webbw [2]: " ^ l))
+ | _ => raise Fail ("Bad row in webbw [1]: " ^ l)
fun splitLast [] = raise Fail "Not enough items for splitLast"
| splitLast [x] = ([], x)
d :: rest =>
let
val (l, x) = splitLast rest
+
+ fun split s =
+ case String.tokens (fn ch => ch = #"@") s of
+ [host, node] => (node, host)
+ | _ => raise Fail ("Bad row in webbw [3]: " ^ s)
in
- readGroups ((d, map checkSsl l, valOf (Int.fromString x)) :: L)
+ readGroups ({user = d, hosts = map (checkSsl o split) l, size = valOf (Int.fromString x)} :: L)
end
- | _ => raise Fail "Bad row in webbw, part 2"
+ | _ => raise Fail ("Bad row in webbw [4]: " ^ l)
in
TextIO.inputLine inf;
- (sum, readEm [], readGroups [])
+ {total = sum, vhosts = readEm [], users = readGroups []}
before TextIO.closeIn inf
end
NONE => done ()
| SOME s =>
case String.tokens Char.isSpace s of
- [uname, dash, blocks, bsoft, bhard, files, fsoft, fhard] =>
+ [uname, "--", blocks, bsoft, bhard, files, fsoft, fhard] =>
+ readData ({uname = uname,
+ blocks = valOf (Int.fromString blocks),
+ files = valOf (Int.fromString files)} :: acc)
+ | [uname, "+-", blocks, bsoft, bhard, _, files, fsoft, fhard] =>
+ readData ({uname = uname,
+ blocks = valOf (Int.fromString blocks),
+ files = valOf (Int.fromString files)} :: acc)
+ | [uname, "-+", blocks, bsoft, bhard, files, fsoft, fhard, _] =>
+ readData ({uname = uname,
+ blocks = valOf (Int.fromString blocks),
+ files = valOf (Int.fromString files)} :: acc)
+ | [uname, "++", blocks, bsoft, bhard, _, files, fsoft, fhard, _] =>
readData ({uname = uname,
blocks = valOf (Int.fromString blocks),
files = valOf (Int.fromString files)} :: acc)