Re: [Libguestfs] [PATCH v12 04/11] New API: Deprecate hivex_value_utf8 and replace with hivex_value_string.

2017-09-13 Thread Pino Toscano
On Tuesday, 12 September 2017 19:58:44 CEST Richard W.M. Jones wrote:
> On Tue, Sep 12, 2017 at 06:42:11PM +0200, Pino Toscano wrote:
> > On Wednesday, 9 August 2017 19:23:39 CEST Richard W.M. Jones wrote:
> > > hivex has a function hivex_value_string.  We were not calling it under
> > > the mistaken belief that because hivex implements this using iconv,
> > > the function wouldn't work inside the daemon.  Instead we
> > > reimplemented the functionality in the library.
> > > 
> > > This commit deprecates hivex_value_utf8 and removes the library side
> > > code.  It replaces it with a plain wrapper around hivex_value_string.
> > > 
> > > Thanks: Pino Toscano
> > > ---
> > 
> > The only thing here is that I would leave hivex_value_utf8 as non-daemon
> > function, just to avoid adding an extra daemon function.
> 
> The saving in code on the library side is quite significant:
> 
>  lib/hivex.c| 111 
> - 
> plus it's pretty ugly code since it has to use iconv ...

Oh sorry, I did not mean to leave it as-is, but to just leave the
wrapper calling hivex_value_string there.

-- 
Pino Toscano

signature.asc
Description: This is a digitally signed message part.
___
Libguestfs mailing list
Libguestfs@redhat.com
https://www.redhat.com/mailman/listinfo/libguestfs

Re: [Libguestfs] [PATCH v12 04/11] New API: Deprecate hivex_value_utf8 and replace with hivex_value_string.

2017-09-12 Thread Richard W.M. Jones
On Tue, Sep 12, 2017 at 06:42:11PM +0200, Pino Toscano wrote:
> On Wednesday, 9 August 2017 19:23:39 CEST Richard W.M. Jones wrote:
> > hivex has a function hivex_value_string.  We were not calling it under
> > the mistaken belief that because hivex implements this using iconv,
> > the function wouldn't work inside the daemon.  Instead we
> > reimplemented the functionality in the library.
> > 
> > This commit deprecates hivex_value_utf8 and removes the library side
> > code.  It replaces it with a plain wrapper around hivex_value_string.
> > 
> > Thanks: Pino Toscano
> > ---
> 
> The only thing here is that I would leave hivex_value_utf8 as non-daemon
> function, just to avoid adding an extra daemon function.

The saving in code on the library side is quite significant:

 lib/hivex.c| 111 - 
plus it's pretty ugly code since it has to use iconv ...

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-top is 'top' for virtual machines.  Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://people.redhat.com/~rjones/virt-top

___
Libguestfs mailing list
Libguestfs@redhat.com
https://www.redhat.com/mailman/listinfo/libguestfs


Re: [Libguestfs] [PATCH v12 04/11] New API: Deprecate hivex_value_utf8 and replace with hivex_value_string.

2017-09-12 Thread Pino Toscano
On Wednesday, 9 August 2017 19:23:39 CEST Richard W.M. Jones wrote:
> hivex has a function hivex_value_string.  We were not calling it under
> the mistaken belief that because hivex implements this using iconv,
> the function wouldn't work inside the daemon.  Instead we
> reimplemented the functionality in the library.
> 
> This commit deprecates hivex_value_utf8 and removes the library side
> code.  It replaces it with a plain wrapper around hivex_value_string.
> 
> Thanks: Pino Toscano
> ---

The only thing here is that I would leave hivex_value_utf8 as non-daemon
function, just to avoid adding an extra daemon function.

-- 
Pino Toscano

signature.asc
Description: This is a digitally signed message part.
___
Libguestfs mailing list
Libguestfs@redhat.com
https://www.redhat.com/mailman/listinfo/libguestfs

[Libguestfs] [PATCH v12 04/11] New API: Deprecate hivex_value_utf8 and replace with hivex_value_string.

2017-08-09 Thread Richard W.M. Jones
hivex has a function hivex_value_string.  We were not calling it under
the mistaken belief that because hivex implements this using iconv,
the function wouldn't work inside the daemon.  Instead we
reimplemented the functionality in the library.

This commit deprecates hivex_value_utf8 and removes the library side
code.  It replaces it with a plain wrapper around hivex_value_string.

Thanks: Pino Toscano
---
 daemon/hivex.c |  23 +++
 docs/C_SOURCE_FILES|   1 -
 examples/virt-dhcp-address.c   |   2 +-
 generator/Makefile.am  |   3 +
 generator/actions.ml   |   2 +-
 generator/actions_hivex.ml |  35 +--
 generator/actions_hivex.mli|   1 -
 generator/actions_hivex_deprecated.ml  |  43 +
 generator/actions_hivex_deprecated.mli |  21 +++
 generator/proc_nr.ml   |   2 +
 lib/MAX_PROC_NR|   2 +-
 lib/Makefile.am|   1 -
 lib/hivex.c| 111 -
 lib/inspect-apps.c |  12 ++--
 lib/inspect-fs-windows.c   |   8 +--
 v2v/convert_windows.ml |   6 +-
 16 files changed, 124 insertions(+), 149 deletions(-)

diff --git a/daemon/hivex.c b/daemon/hivex.c
index 1cbfb3458..2d0913f43 100644
--- a/daemon/hivex.c
+++ b/daemon/hivex.c
@@ -335,6 +335,29 @@ do_hivex_value_value (int64_t valueh, size_t *size_r)
   return r;
 }
 
+char *
+do_hivex_value_string (int64_t valueh)
+{
+  char *r;
+
+  NEED_HANDLE (NULL);
+
+  r = hivex_value_string (h, valueh);
+  if (r == NULL) {
+reply_with_perror ("failed");
+return NULL;
+  }
+
+  return r;
+}
+
+/* Deprecated alias for hivex_value_string. */
+char *
+do_hivex_value_utf8 (int64_t valueh)
+{
+  return do_hivex_value_string (valueh);
+}
+
 int
 do_hivex_commit (const char *filename)
 {
diff --git a/docs/C_SOURCE_FILES b/docs/C_SOURCE_FILES
index 65e62f643..d5e358140 100644
--- a/docs/C_SOURCE_FILES
+++ b/docs/C_SOURCE_FILES
@@ -310,7 +310,6 @@ lib/guestfs-internal.h
 lib/guestfs.h
 lib/guid.c
 lib/handle.c
-lib/hivex.c
 lib/info.c
 lib/inspect-apps.c
 lib/inspect-fs-unix.c
diff --git a/examples/virt-dhcp-address.c b/examples/virt-dhcp-address.c
index 0c7e763ff..caf89b88e 100644
--- a/examples/virt-dhcp-address.c
+++ b/examples/virt-dhcp-address.c
@@ -266,7 +266,7 @@ print_dhcp_address_windows (guestfs_h *g, char *root_fs)
   /* Get the string and use libguestfs's auto-conversion to convert it
* to UTF-8 for output.
*/
-  p = guestfs_hivex_value_utf8 (g, value);
+  p = guestfs_hivex_value_string (g, value);
   if (!p)
 exit (EXIT_FAILURE);
 
diff --git a/generator/Makefile.am b/generator/Makefile.am
index 35b7a4209..7c1ac9ee2 100644
--- a/generator/Makefile.am
+++ b/generator/Makefile.am
@@ -31,6 +31,8 @@ sources = \
actions_debug.mli \
actions_hivex.ml \
actions_hivex.mli \
+   actions_hivex_deprecated.ml \
+   actions_hivex_deprecated.mli \
actions_inspection.ml \
actions_inspection.mli \
actions_inspection_deprecated.ml \
@@ -122,6 +124,7 @@ objects = \
actions_core_deprecated.cmo \
actions_debug.cmo \
actions_hivex.cmo \
+   actions_hivex_deprecated.cmo \
actions_inspection.cmo \
actions_inspection_deprecated.cmo \
actions_internal_tests.cmo \
diff --git a/generator/actions.ml b/generator/actions.ml
index 75742397a..79e2265d2 100644
--- a/generator/actions.ml
+++ b/generator/actions.ml
@@ -33,7 +33,6 @@ let non_daemon_functions =
   Actions_core.non_daemon_functions @
   Actions_core_deprecated.non_daemon_functions @
   Actions_debug.non_daemon_functions @
-  Actions_hivex.non_daemon_functions @
   Actions_inspection.non_daemon_functions @
   Actions_inspection_deprecated.non_daemon_functions @
   Actions_properties.non_daemon_functions @
@@ -51,6 +50,7 @@ let daemon_functions =
   Actions_core_deprecated.daemon_functions @
   Actions_debug.daemon_functions @
   Actions_hivex.daemon_functions @
+  Actions_hivex_deprecated.daemon_functions @
   Actions_tsk.daemon_functions @
   Actions_yara.daemon_functions
 
diff --git a/generator/actions_hivex.ml b/generator/actions_hivex.ml
index 0a3d6dd20..6ccb65fa6 100644
--- a/generator/actions_hivex.ml
+++ b/generator/actions_hivex.ml
@@ -22,25 +22,6 @@ open Types
 
 (* Hivex APIs. *)
 
-let non_daemon_functions = [
-  { defaults with
-name = "hivex_value_utf8"; added = (1, 19, 35);
-style = RString (RPlainString, "databuf"), [Int64 "valueh"], [];
-optional = Some "hivex";
-shortdesc = "return the data field from the (key, datatype, data) tuple";
-longdesc = "\
-This calls C (which returns the
-data field from a hivex value tuple).  It then assumes that
-the field is a UTF-16LE string and converts the result to
-UTF-8 (or if this is not possible, it returns an error).
-
-This is useful for reading strin