(* virt-dmesg * (C) Copyright 2008-2011 Red Hat Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *) (** Utility functions. *) module StringMap : sig type key = String.t type 'a t = 'a Map.Make (String).t val empty : 'a t val is_empty : 'a t -> bool val add : key -> 'a -> 'a t -> 'a t val find : key -> 'a t -> 'a val remove : key -> 'a t -> 'a t val mem : key -> 'a t -> bool val iter : (key -> 'a -> unit) -> 'a t -> unit val map : ('a -> 'b) -> 'a t -> 'b t val mapi : (key -> 'a -> 'b) -> 'a t -> 'b t val fold : (key -> 'a -> 'b -> 'b) -> 'a t -> 'b -> 'b val compare : ('a -> 'a -> int) -> 'a t -> 'a t -> int val equal : ('a -> 'a -> bool) -> 'a t -> 'a t -> bool end (** Map strings -> any type. Used for symbol tables. *) type symbol_table = int64 StringMap.t (** A symbol table is a map from strings (symbols) to virtual addresses. *) val ( +^ ) : int64 -> int64 -> int64 val ( -^ ) : int64 -> int64 -> int64 val ( *^ ) : int64 -> int64 -> int64 val ( /^ ) : int64 -> int64 -> int64 val ( &^ ) : int64 -> int64 -> int64 (** 64 bit operators. *) val frequency : 'a list -> (int * 'a) list (** Take a list of items, and return the list (count, item) in order from most frequent to least frequent occurring in the original list. *) val filter_map : ('a -> 'b option) -> 'a list -> 'b list (** [filter_map f as] maps each 'a' to 'b', but if the function returns [None] then the element is removed from the output. *) val replace_chars : (char -> string) -> string -> string (** [replace_chars f s] returns a string where all chars [c] of [s] have been replaced by the string returned by [f c]. *) val set_debug : unit -> unit (** If called, enables debugging. *) val debug : ('a, unit, string, unit) format4 -> 'a (** If debugging is enabled, this prints the string to stdout followed by a newline character. *) val error : ('a, unit, string, unit) format4 -> 'a (** Print the name of the program and the error message to stderr followed by a newline character. Note this function doesn't exit the program. If you want to do that, call [exit 1] after. *) val set_program_name : string -> unit (** Set the program name. *) val get_program_name : unit -> string (** Get the program name. *)