Initial commit.
[virt-resize-ui.git] / utils.mli
1 (* Virt-resize UI.
2  * Copyright (C) 2011 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 val (&^) : int64 -> int64 -> int64
26   (** Int64 arithmetic operators. *)
27
28 type ('a, 'b) either = Left of 'a | Right of 'b
29   (** A value which is either an ['a] or a ['b], just like Haskell's
30       "Either" type. *)
31
32 val verbose : unit -> bool
33 val set_verbose_flag : unit -> unit
34   (** If this contains [true] then {!debug} will send debugging
35       messages to stderr, else debugging messages are dropped.
36
37       This is set through the --verbose command line option. *)
38
39 val debug : ('a, unit, string, unit) format4 -> 'a
40   (** A printf-like function for writing debugging messages. *)
41
42 val failwith : ('a, unit, string, 'b) format4 -> 'a
43   (** Replacement for standard OCaml [failwith] function.  This can
44       take a printf-like argument list, and also logs errors on stderr
45       when verbose is enabled. *)
46
47 val trace : unit -> bool
48 val set_trace_flag : unit -> unit
49   (** If this contains [true] then calls to libguestfs are traced.
50
51       This is set through the [-x] command line option. *)
52
53 val connect_uri : unit -> string option
54 val set_connect_uri : string option -> unit
55   (** The libvirt connection URI.
56
57       This is set through the [--connect] command line option. *)
58
59 val utf8_copyright : string (** UTF-8 copyright symbol *)
60 val utf8_rarrow : string (** UTF-8 RIGHTWARDS ARROW *)
61
62 val human_size : int64 -> string
63   (** Convert a number of bytes into a human readable string. *)
64
65 val human_size_1k : int64 -> string
66   (** Same as {!human_size} but the argument is 1KB blocks (used for
67       disk usage). *)
68
69 val unique : unit -> int
70   (** Return a new integer each time called. *)
71
72 val find_map : ('a -> 'b option) -> 'a list -> 'b
73   (** [find_map f xs] calls function [f] on each member of [xs] in order.
74       If [f] returns [Some b] then we stop and return [b].  If all calls
75       to [f] return [None] then this raises [Not_found]. *)
76
77 val markup_escape : string -> string
78   (** Like g_markup_escape but with extra protection for strings
79       containing \0 characters. *)
80
81 val libguestfs_version_string : unit -> string
82   (** Return the version of libguestfs as a string. *)
83
84 val libvirt_version_string : unit -> string
85   (** Return the version of libvirt as a string. *)