From: Vincent Hanquez Date: Tue, 21 Jul 2009 09:00:09 +0000 (+0100) Subject: recognize more value as boolean when doing a set X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=26b8418b2b1b75870bd7c5415d6ace7363b16240;p=xenclient%2Ftoolstack.git recognize more value as boolean when doing a set --- diff --git a/xenvm/vmconfig.ml b/xenvm/vmconfig.ml index b19cdb0..f6fc9fa 100644 --- a/xenvm/vmconfig.ml +++ b/xenvm/vmconfig.ml @@ -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