Add contrib directory, and non-upstream patch to add Domain.get_cpu_stats_total.
[ocaml-libvirt.git] / libvirt / libvirt_c_epilogue.c
index 78bd23e..ac69fce 100644 (file)
@@ -5,7 +5,8 @@
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
+ * version 2 of the License, or (at your option) any later version,
+ * with the OCaml linking exception described in ../COPYING.LIB.
  *
  * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -170,47 +171,21 @@ Val_virterror (virErrorPtr err)
   CAMLparam0 ();
   CAMLlocal3 (rv, connv, optv);
 
-  rv = caml_alloc (12, 0);
+  rv = caml_alloc (9, 0);
   Store_field (rv, 0, Val_err_number (err->code));
   Store_field (rv, 1, Val_err_domain (err->domain));
   Store_field (rv, 2,
               Val_opt (err->message, (Val_ptr_t) caml_copy_string));
   Store_field (rv, 3, Val_err_level (err->level));
 
-  /* conn, dom and net fields, all optional */
-  if (err->conn) {
-    connv = Val_connect_no_finalize (err->conn);
-    optv = caml_alloc (1, 0);
-    Store_field (optv, 0, connv);
-    Store_field (rv, 4, optv); /* Some conn */
-
-    if (err->dom) {
-      optv = caml_alloc (1, 0);
-      Store_field (optv, 0, Val_domain_no_finalize (err->dom, connv));
-      Store_field (rv, 5, optv); /* Some (dom, conn) */
-    }
-    else
-      Store_field (rv, 5, Val_int (0)); /* None */
-    if (err->net) {
-      optv = caml_alloc (1, 0);
-      Store_field (optv, 0, Val_network_no_finalize (err->net, connv));
-      Store_field (rv, 11, optv); /* Some (net, conn) */
-    } else
-      Store_field (rv, 11, Val_int (0)); /* None */
-  } else {
-    Store_field (rv, 4, Val_int (0)); /* None */
-    Store_field (rv, 5, Val_int (0)); /* None */
-    Store_field (rv, 11, Val_int (0)); /* None */
-  }
-
-  Store_field (rv, 6,
+  Store_field (rv, 4,
               Val_opt (err->str1, (Val_ptr_t) caml_copy_string));
-  Store_field (rv, 7,
+  Store_field (rv, 5,
               Val_opt (err->str2, (Val_ptr_t) caml_copy_string));
-  Store_field (rv, 8,
+  Store_field (rv, 6,
               Val_opt (err->str3, (Val_ptr_t) caml_copy_string));
-  Store_field (rv, 9, caml_copy_int32 (err->int1));
-  Store_field (rv, 10, caml_copy_int32 (err->int2));
+  Store_field (rv, 7, caml_copy_int32 (err->int1));
+  Store_field (rv, 8, caml_copy_int32 (err->int2));
 
   CAMLreturn (rv);
 }
@@ -224,9 +199,6 @@ 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",
@@ -278,17 +250,6 @@ 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)
 {
@@ -348,52 +309,6 @@ 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.
- */
-static value
-Val_connect_no_finalize (virConnectPtr conn)
-{
-  CAMLparam0 ();
-  CAMLlocal1 (rv);
-  rv = caml_alloc (1, Abstract_tag);
-  Store_field (rv, 0, (value) conn);
-  CAMLreturn (rv);
-}
-
-static value
-Val_dom_no_finalize (virDomainPtr dom)
-{
-  CAMLparam0 ();
-  CAMLlocal1 (rv);
-  rv = caml_alloc (1, Abstract_tag);
-  Store_field (rv, 0, (value) dom);
-  CAMLreturn (rv);
-}
-
-static value
-Val_net_no_finalize (virNetworkPtr net)
-{
-  CAMLparam0 ();
-  CAMLlocal1 (rv);
-  rv = caml_alloc (1, Abstract_tag);
-  Store_field (rv, 0, (value) net);
-  CAMLreturn (rv);
-}
-
 /* This wraps up the (dom, conn) pair (Domain.t). */
 static value
 Val_domain (virDomainPtr dom, value connv)
@@ -454,51 +369,6 @@ 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.
- */
-static value
-Val_domain_no_finalize (virDomainPtr dom, value connv)
-{
-  CAMLparam1 (connv);
-  CAMLlocal2 (rv, v);
-
-  rv = caml_alloc_tuple (2);
-  v = Val_dom_no_finalize (dom);
-  Store_field (rv, 0, v);
-  Store_field (rv, 1, connv);
-  CAMLreturn (rv);
-}
-
-static value
-Val_network_no_finalize (virNetworkPtr net, value connv)
-{
-  CAMLparam1 (connv);
-  CAMLlocal2 (rv, v);
-
-  rv = caml_alloc_tuple (2);
-  v = Val_net_no_finalize (net);
-  Store_field (rv, 0, v);
-  Store_field (rv, 1, connv);
-  CAMLreturn (rv);
-}
-
 static void
 conn_finalize (value connv)
 {
@@ -537,12 +407,3 @@ 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