mrc0mmand / rpms / libguestfs

Forked from rpms/libguestfs 3 years ago
Clone

Blame SOURCES/0021-common-mltools-move-the-code-for-machine-readable-up.patch

da373f
From 7ac3289d64b37348f29de9db4d71c3286836066b Mon Sep 17 00:00:00 2001
3efd08
From: Pino Toscano <ptoscano@redhat.com>
3efd08
Date: Thu, 21 Mar 2019 17:16:37 +0100
3efd08
Subject: [PATCH] common/mltools: move the code for machine readable up
3efd08
3efd08
Move the code for handling machine readable up in the file, so it can be
3efd08
used by other functions.
3efd08
3efd08
Only code motion, no behaviour changes.
3efd08
3efd08
(cherry picked from commit 8b06ea0ebc9534e4fda9cc9a33c98f939401af79)
3efd08
---
3efd08
 common/mltools/tools_utils.ml | 60 +++++++++++++++++------------------
3efd08
 1 file changed, 30 insertions(+), 30 deletions(-)
3efd08
3efd08
diff --git a/common/mltools/tools_utils.ml b/common/mltools/tools_utils.ml
3efd08
index 24641369e..5a35708cd 100644
3efd08
--- a/common/mltools/tools_utils.ml
3efd08
+++ b/common/mltools/tools_utils.ml
3efd08
@@ -33,6 +33,36 @@ external c_inspect_decrypt : Guestfs.t -> int64 -> (string * key_store_key) list
3efd08
 external c_set_echo_keys : unit -> unit = "guestfs_int_mllib_set_echo_keys" "noalloc"
3efd08
 external c_set_keys_from_stdin : unit -> unit = "guestfs_int_mllib_set_keys_from_stdin" "noalloc"
3efd08
 
3efd08
+type machine_readable_fn = {
3efd08
+  pr : 'a. ('a, unit, string, unit) format4 -> 'a;
3efd08
+} (* [@@unboxed] *)
3efd08
+
3efd08
+type machine_readable_output_type =
3efd08
+  | NoOutput
3efd08
+  | Channel of out_channel
3efd08
+  | File of string
3efd08
+let machine_readable_output = ref NoOutput
3efd08
+let machine_readable_channel = ref None
3efd08
+let machine_readable () =
3efd08
+  let chan =
3efd08
+    if !machine_readable_channel = None then (
3efd08
+      let chan =
3efd08
+        match !machine_readable_output with
3efd08
+        | NoOutput -> None
3efd08
+        | Channel chan -> Some chan
3efd08
+        | File f -> Some (open_out f) in
3efd08
+      machine_readable_channel := chan
3efd08
+    );
3efd08
+    !machine_readable_channel
3efd08
+  in
3efd08
+  match chan with
3efd08
+  | None -> None
3efd08
+  | Some chan ->
3efd08
+    let pr fs =
3efd08
+      ksprintf (output_string chan) fs
3efd08
+    in
3efd08
+    Some { pr }
3efd08
+
3efd08
 (* ANSI terminal colours. *)
3efd08
 let istty chan =
3efd08
   Unix.isatty (Unix.descr_of_out_channel chan)
3efd08
@@ -236,36 +266,6 @@ let human_size i =
3efd08
     )
3efd08
   )
3efd08
 
3efd08
-type machine_readable_fn = {
3efd08
-  pr : 'a. ('a, unit, string, unit) format4 -> 'a;
3efd08
-} (* [@@unboxed] *)
3efd08
-
3efd08
-type machine_readable_output_type =
3efd08
-  | NoOutput
3efd08
-  | Channel of out_channel
3efd08
-  | File of string
3efd08
-let machine_readable_output = ref NoOutput
3efd08
-let machine_readable_channel = ref None
3efd08
-let machine_readable () =
3efd08
-  let chan =
3efd08
-    if !machine_readable_channel = None then (
3efd08
-      let chan =
3efd08
-        match !machine_readable_output with
3efd08
-        | NoOutput -> None
3efd08
-        | Channel chan -> Some chan
3efd08
-        | File f -> Some (open_out f) in
3efd08
-      machine_readable_channel := chan
3efd08
-    );
3efd08
-    !machine_readable_channel
3efd08
-  in
3efd08
-  match chan with
3efd08
-  | None -> None
3efd08
-  | Some chan ->
3efd08
-    let pr fs =
3efd08
-      ksprintf (output_string chan) fs
3efd08
-    in
3efd08
-    Some { pr }
3efd08
-
3efd08
 type cmdline_options = {
3efd08
   getopt : Getopt.t;
3efd08
   ks : key_store;
3efd08
-- 
da373f
2.18.4
3efd08