Implement returning these two types from OCaml daemon functions.
---
daemon/daemon-c.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++
daemon/daemon-c.h | 2 ++
generator/daemon.ml | 13 +++++++++++--
3 files changed, 65 insertions(+), 2 deletions(-)
diff --git a/daemon/daemon-c.c b/daemon/daemon-c.c
index 4d04dc0dc..533bf7ce7 100644
--- a/daemon/daemon-c.c
+++ b/daemon/daemon-c.c
@@ -151,6 +151,30 @@ guestfs_int_daemon_return_string_mountable (value retv)
}
}
+/* Implement RStringList (RMountable, _). */
+char **
+guestfs_int_daemon_return_string_mountable_list (value retv)
+{
+ CLEANUP_FREE_STRINGSBUF DECLARE_STRINGSBUF (ret);
+ value v;
+ char *m;
+
+ while (retv != Val_int (0)) {
+ v = Field (retv, 0);
+ m = guestfs_int_daemon_return_string_mountable (v);
+ if (m == NULL)
+ return NULL;
+ if (add_string_nodup (&ret, m) == -1)
+ return NULL;
+ retv = Field (retv, 1);
+ }
+
+ if (end_stringsbuf (&ret) == -1)
+ return NULL;
+
+ return take_stringsbuf (&ret); /* caller frees */
+}
+
/* Implement RHashtable (RPlainString, RPlainString, _). */
char **
guestfs_int_daemon_return_hashtable_string_string (value retv)
@@ -202,3 +226,31 @@ guestfs_int_daemon_return_hashtable_mountable_string (value retv)
return take_stringsbuf (&ret); /* caller frees */
}
+
+/* Implement RHashtable (RPlainString, RMountable, _). */
+char **
+guestfs_int_daemon_return_hashtable_string_mountable (value retv)
+{
+ CLEANUP_FREE_STRINGSBUF DECLARE_STRINGSBUF (ret);
+ value sv, v, mv;
+ char *m;
+
+ while (retv != Val_int (0)) {
+ v = Field (retv, 0); /* (string, Mountable.t) */
+ sv = Field (v, 0); /* string */
+ if (add_string (&ret, String_val (sv)) == -1)
+ return NULL;
+ mv = Field (v, 1); /* Mountable.t */
+ m = guestfs_int_daemon_return_string_mountable (mv);
+ if (m == NULL)
+ return NULL;
+ if (add_string_nodup (&ret, m) == -1)
+ return NULL;
+ retv = Field (retv, 1);
+ }
+
+ if (end_stringsbuf (&ret) == -1)
+ return NULL;
+
+ return take_stringsbuf (&ret); /* caller frees */
+}
diff --git a/daemon/daemon-c.h b/daemon/daemon-c.h
index 1fcfd707c..9b7085bce 100644
--- a/daemon/daemon-c.h
+++ b/daemon/daemon-c.h
@@ -31,7 +31,9 @@ extern void guestfs_int_daemon_exn_to_reply_with_error (const char
*func, value
extern value guestfs_int_daemon_copy_mountable (const mountable_t *mountable);
extern char **guestfs_int_daemon_return_string_list (value retv);
extern char *guestfs_int_daemon_return_string_mountable (value retv);
+extern char **guestfs_int_daemon_return_string_mountable_list (value retv);
extern char **guestfs_int_daemon_return_hashtable_string_string (value retv);
extern char **guestfs_int_daemon_return_hashtable_mountable_string (value retv);
+extern char **guestfs_int_daemon_return_hashtable_string_mountable (value retv);
#endif /* GUESTFSD_DAEMON_C_H */
diff --git a/generator/daemon.ml b/generator/daemon.ml
index b4d4cfe8e..2e8d6c830 100644
--- a/generator/daemon.ml
+++ b/generator/daemon.ml
@@ -761,9 +761,13 @@ let generate_daemon_caml_stubs () =
pr " char *ret =\n";
pr " guestfs_int_daemon_return_string_mountable (retv);\n";
pr " CAMLreturnT (char *, ret); /* caller frees */\n"
- | RStringList _ ->
+ | RStringList ((RPlainString|RDevice), _) ->
pr " char **ret = guestfs_int_daemon_return_string_list (retv);\n";
pr " CAMLreturnT (char **, ret); /* caller frees */\n"
+ | RStringList (RMountable, _) ->
+ pr " char **ret =\n";
+ pr " guestfs_int_daemon_return_string_mountable_list (retv);\n";
+ pr " CAMLreturnT (char **, ret); /* caller frees */\n"
| RStruct (_, typ) ->
pr " guestfs_int_%s *ret =\n" typ;
pr " return_%s (retv);\n" typ;
@@ -774,7 +778,8 @@ let generate_daemon_caml_stubs () =
pr " return_%s_list (retv);\n" typ;
pr " /* caller frees */\n";
pr " CAMLreturnT (guestfs_int_%s_list *, ret);\n" typ
- | RHashtable (RPlainString, RPlainString, _) ->
+ | RHashtable (RPlainString, RPlainString, _)
+ | RHashtable (RPlainString, RDevice, _) ->
pr " char **ret =\n";
pr " guestfs_int_daemon_return_hashtable_string_string
(retv);\n";
pr " CAMLreturnT (char **, ret); /* caller frees */\n"
@@ -782,6 +787,10 @@ let generate_daemon_caml_stubs () =
pr " char **ret =\n";
pr " guestfs_int_daemon_return_hashtable_mountable_string
(retv);\n";
pr " CAMLreturnT (char **, ret); /* caller frees */\n"
+ | RHashtable (RPlainString, RMountable, _) ->
+ pr " char **ret =\n";
+ pr " guestfs_int_daemon_return_hashtable_string_mountable
(retv);\n";
+ pr " CAMLreturnT (char **, ret); /* caller frees */\n"
| RHashtable _ -> assert false
| RBufferOut _ -> assert false
);
--
2.13.2