Version 0.0.1
[guestfs-browser.git] / utils.mli
1 (* Guestfs Browser.
2  * Copyright (C) 2010 Red Hat Inc.
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  *)
18
19 (** General-purpose utility code used everywhere. *)
20
21 val (+^) : int64 -> int64 -> int64
22 val (-^) : int64 -> int64 -> int64
23 val ( *^ ) : int64 -> int64 -> int64
24 val (/^) : int64 -> int64 -> int64
25   (** Int64 arithmetic operators. *)
26
27 type ('a, 'b) either = Left of 'a | Right of 'b
28   (** A value which is either an ['a] or a ['b], just like Haskell's
29       "Either" type. *)
30
31 val verbose : unit -> bool
32 val set_verbose_flag : unit -> unit
33   (** If this contains [true] then {!debug} will send debugging
34       messages to stderr, else debugging messages are dropped.
35
36       This is set through the --verbose command line option. *)
37
38 val write_flag : unit -> bool
39 val set_write_flag : unit -> unit
40   (** Writes are prevented unless the user sets this to [true]
41       through the command line option --write. *)
42
43 val debug : ('a, unit, string, unit) format4 -> 'a
44   (** A printf-like function for writing debugging messages. *)
45
46 val failwith : ('a, unit, string, 'b) format4 -> 'a
47   (** Replacement for standard OCaml [failwith] function.  This can
48       take a printf-like argument list, and also logs errors on stderr
49       when verbose is enabled. *)
50
51 val utf8_rarrow : string (** UTF-8 RIGHTWARDS ARROW *)
52
53 val human_size_1k : int64 -> string
54   (** Convert a number (of 1K blocks) into a human readable string. *)