Storage API almost completed, even more autogeneration.
[virt-top.git] / libvirt / libvirt_c_epilogue.c
index a18749d..a43d8e2 100644 (file)
@@ -224,6 +224,9 @@ static void pol_finalize (value);
 #ifdef HAVE_VIRSTORAGEVOLPTR
 static void vol_finalize (value);
 #endif
+#ifdef HAVE_VIRJOBPTR
+static void jb_finalize (value);
+#endif
 
 static struct custom_operations conn_custom_operations = {
   "conn_custom_operations",
@@ -275,6 +278,17 @@ static struct custom_operations vol_custom_operations = {
 };
 #endif
 
+#ifdef HAVE_VIRJOBPTR
+static struct custom_operations jb_custom_operations = {
+  "jb_custom_operations",
+  jb_finalize,
+  custom_compare_default,
+  custom_hash_default,
+  custom_serialize_default,
+  custom_deserialize_default
+};
+#endif
+
 static value
 Val_connect (virConnectPtr conn)
 {
@@ -334,6 +348,19 @@ Val_vol (virStorageVolPtr vol)
 }
 #endif
 
+#ifdef HAVE_VIRJOBPTR
+static value
+Val_jb (virJobPtr jb)
+{
+  CAMLparam0 ();
+  CAMLlocal1 (rv);
+  rv = caml_alloc_custom (&jb_custom_operations,
+                         sizeof (virJobPtr), 0, 1);
+  Jb_val (rv) = jb;
+  CAMLreturn (rv);
+}
+#endif
+
 /* No-finalize versions of Val_connect, Val_dom, Val_net ONLY for use
  * by virterror wrappers.
  */
@@ -427,6 +454,22 @@ Val_volume (virStorageVolPtr vol, value connv)
 }
 #endif
 
+#ifdef HAVE_VIRJOBPTR
+/* This wraps up the (jb, conn) pair (Job.t). */
+static value
+Val_job (virJobPtr jb, value connv)
+{
+  CAMLparam1 (connv);
+  CAMLlocal2 (rv, v);
+
+  rv = caml_alloc_tuple (2);
+  v = Val_jb (jb);
+  Store_field (rv, 0, v);
+  Store_field (rv, 1, connv);
+  CAMLreturn (rv);
+}
+#endif
+
 /* No-finalize versions of Val_domain, Val_network ONLY for use by
  * virterror wrappers.
  */
@@ -494,3 +537,12 @@ vol_finalize (value volv)
   if (vol) (void) virStorageVolFree (vol);
 }
 #endif
+
+#ifdef HAVE_VIRJOBPTR
+static void
+jb_finalize (value jbv)
+{
+  virJobPtr jb = Jb_val (jbv);
+  if (jb) (void) virJobFree (jb);
+}
+#endif