]> xenbits.xensource.com Git - xenclient/toolstack.git/commitdiff
recognize more value as boolean when doing a set
authorVincent Hanquez <vincent.hanquez@eu.citrix.com>
Tue, 21 Jul 2009 09:00:09 +0000 (10:00 +0100)
committerVincent Hanquez <vincent.hanquez@eu.citrix.com>
Tue, 21 Jul 2009 09:00:09 +0000 (10:00 +0100)
xenvm/vmconfig.ml

index b19cdb0c29438d32ce6d3709492ed57a7ec2b9a4..f6fc9fa666853f59f2312274ce31f35ded6d3104 100644 (file)
@@ -275,10 +275,17 @@ let config_notify_of_string s =
        | _ ->
                failwith "bah"
 
+exception Unknown_boolean of string
+
 let string_of_string_option opt = match opt with None -> "" | Some v -> v
 let string_option_of_string s = match s with "" -> None | _ -> Some s
 let string_of_int_option opt = match opt with None -> "" | Some v -> string_of_int v
 let int_option_of_string s = if s = "" then None else Some (int_of_string s)
+let bool_of_string s =
+       match (String.lowercase s) with
+       | "1" | "y" | "yes" | "true" -> true
+       | "0" | "n" | "no" | "false" -> false
+       | _                          -> raise (Unknown_boolean s)
 
 exception Unknown_field of string