Implement returning these two types from OCaml daemon functions.
---
generator/daemon.ml | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 61 insertions(+), 2 deletions(-)
diff --git a/generator/daemon.ml b/generator/daemon.ml
index f20c87bea..b8d0a3a88 100644
--- a/generator/daemon.ml
+++ b/generator/daemon.ml
@@ -597,6 +597,30 @@ return_string_mountable (value retv)
}
}
+/* Implement RStringList (RMountable, _). */
+static char **
+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 = 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, _). */
static char **
return_hashtable_string_string (value retv)
@@ -649,6 +673,34 @@ return_hashtable_mountable_string (value retv)
return take_stringsbuf (&ret); /* caller frees */
}
+/* Implement RHashtable (RPlainString, RMountable, _). */
+static char **
+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 = 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 */
+}
+
";
(* Implement code for returning structs and struct lists. *)
@@ -889,9 +941,12 @@ return_hashtable_mountable_string (value retv)
| RString (RMountable, _) ->
pr " char *ret = return_string_mountable (retv);\n";
pr " CAMLreturnT (char *, ret); /* caller frees */\n"
- | RStringList _ ->
+ | RStringList ((RPlainString|RDevice), _) ->
pr " char **ret = return_string_list (retv);\n";
pr " CAMLreturnT (char **, ret); /* caller frees */\n"
+ | RStringList (RMountable, _) ->
+ pr " char **ret = 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;
@@ -902,12 +957,16 @@ return_hashtable_mountable_string (value retv)
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 = return_hashtable_string_string (retv);\n";
pr " CAMLreturnT (char **, ret); /* caller frees */\n"
| RHashtable (RMountable, RPlainString, _) ->
pr " char **ret = return_hashtable_mountable_string (retv);\n";
pr " CAMLreturnT (char **, ret); /* caller frees */\n"
+ | RHashtable (RPlainString, RMountable, _) ->
+ pr " char **ret = return_hashtable_string_mountable (retv);\n";
+ pr " CAMLreturnT (char **, ret); /* caller frees */\n"
| RHashtable _ -> assert false
| RBufferOut _ -> assert false
);
--
2.13.2