X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=filetree_markup.ml;h=8b8dc2e95bbe2d22d831ecadf0595f8ae2ec7b89;hb=e3cc4d32de383a8087c1065f150a09c5f3f77ca8;hp=beb41b23060d744d15d875f86690350f8c2a1caa;hpb=8260bc1fce6ab92b77dbe87b8eccd2b415a95ec3;p=guestfs-browser.git
diff --git a/filetree_markup.ml b/filetree_markup.ml
index beb41b2..8b8dc2e 100644
--- a/filetree_markup.ml
+++ b/filetree_markup.ml
@@ -18,11 +18,10 @@
open ExtString
open ExtList
-open CamomileLibrary
-open Default.Camomile
open Unix
open Utils
+open Slave_types
open Filetree_type
open Printf
@@ -47,15 +46,15 @@ let other_color = file_color (* anything not one of the above *)
* http://library.gnome.org/devel/pango/stable/PangoMarkupFormat.html
*)
let rec markup_of_name ?(visited = false) direntry =
- let name = direntry.Slave.dent_name in
- let mode = direntry.Slave.dent_stat.Guestfs.mode in
+ let name = direntry.dent_name in
+ let mode = direntry.dent_stat.Guestfs.mode in
if is_directory mode then ( (* directory *)
let fg = if not visited then normal dir_color else darken dir_color in
sprintf "%s"
fg (markup_escape name)
)
else if is_symlink mode then ( (* symlink *)
- let link = direntry.Slave.dent_link in
+ let link = direntry.dent_link in
let fg =
if not visited then normal symlink_color else darken symlink_color in
sprintf "%s %s %s"
@@ -90,7 +89,6 @@ and markup_of_regkey ?(visited = false) h node =
(* Mark up a registry value. *)
and markup_of_regvalue ?(visited = false) h value =
- debug "markup_of_regvalue";
let k = Hivex.value_key h value in
let k = if k = "" then "@" else k in
let t, v = Hivex.value_value h value in
@@ -98,56 +96,13 @@ and markup_of_regvalue ?(visited = false) h value =
(* Ignore long values. *)
let len = String.length v in
let v =
- if len >= 256 then
- sprintf "<%d bytes not printed>" len
- else (
- (* Deal as best we can with printing the value. *)
- match t with
- | Hivex.REG_NONE -> if v = "" then "" else markup_hex_data v
- | Hivex.REG_SZ -> markup_windows_string v
- | Hivex.REG_EXPAND_SZ -> markup_windows_string v
- | Hivex.REG_BINARY -> markup_hex_data v
- | Hivex.REG_DWORD ->
- (bitmatch Bitstring.bitstring_of_string v with
- | { i : 32 : littleendian } -> sprintf "%08lx" i
- | { _ } -> markup_hex_data v)
- | Hivex.REG_DWORD_BIG_ENDIAN ->
- (bitmatch Bitstring.bitstring_of_string v with
- | { i : 32 : bigendian } -> sprintf "%08lx" i
- | { _ } -> markup_hex_data v)
- | Hivex.REG_LINK -> markup_hex_data v
- | Hivex.REG_MULTI_SZ -> (* XXX could do better with this *)
- markup_hex_data v
- | Hivex.REG_RESOURCE_LIST -> markup_hex_data v
- | Hivex.REG_FULL_RESOURCE_DESCRIPTOR -> markup_hex_data v
- | Hivex.REG_RESOURCE_REQUIREMENTS_LIST -> markup_hex_data v
- | Hivex.REG_QWORD ->
- (bitmatch Bitstring.bitstring_of_string v with
- | { i : 64 : littleendian } -> sprintf "%016Lx" i
- | { _ } -> markup_hex_data v)
- | Hivex.REG_UNKNOWN i32 -> markup_hex_data v
- ) in
+ if len >= 512 then sprintf "<%d bytes not printed>" len
+ else markup_escape (printable_hivex_value ~split_long_lines:true t v) in
let fg = if not visited then normal file_color else darken file_color in
sprintf "%s=%s"
fg (markup_escape k) fg v
-(* Mark up registry value as hex data. *)
-and markup_hex_data v =
- let vs = String.explode v in
- let vs = List.mapi (
- fun i c ->
- sprintf "%s%02x" (if i mod 16 = 0 then "\n" else "") (int_of_char c)
- ) vs in
- String.concat "," vs
-
-(* Best guess the format of the string and convert to UTF-8. *)
-and markup_windows_string v =
- try markup_escape (windows_string_to_utf8 v)
- with CharEncoding.Malformed_code | CharEncoding.Out_of_range ->
- (* Fallback to displaying the string as hex. *)
- markup_hex_data v
-
and normal (r, g, b) =
let r = if r < 0 then 0 else if r > 255 then 255 else r in
let g = if g < 0 then 0 else if g > 255 then 255 else g in
@@ -256,7 +211,7 @@ let set_visited ({ model = model; name_col = name_col } as t) row =
hdata.visited <- true;
match hdata.content with
| Directory direntry | File direntry ->
- debug "set_visited %s" direntry.Slave.dent_name;
+ debug "set_visited %s" direntry.dent_name;
model#set ~row ~column:name_col
(markup_of_name ~visited:true direntry)
| RegKey node ->