Switch all the links to https
[ocaml-libvirt.git] / libvirt / libvirt_c_prologue.c
index af4a4e9..8533618 100644 (file)
@@ -1,6 +1,6 @@
 /* OCaml bindings for libvirt.
  * (C) Copyright 2007 Richard W.M. Jones, Red Hat Inc.
- * http://libvirt.org/
+ * https://libvirt.org/
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -20,7 +20,7 @@
 
 /* Please read libvirt/README file. */
 
-static char *Optstring_val (value strv);
+static const char *Optstring_val (value strv);
 typedef value (*Val_ptr_t) (void *);
 static value Val_opt (void *ptr, Val_ptr_t Val_ptr);
 typedef value (*Val_const_ptr_t) (const void *);
@@ -34,7 +34,7 @@ static value Val_virconnectcredential (const virConnectCredentialPtr cred);
 /* Use this around synchronous libvirt API calls to release the OCaml
  * lock, allowing other threads to run simultaneously.  'code' must not
  * perform any caml_* calls, run any OCaml code, or raise any exception.
- * http://web.archive.org/web/20030521020915/http://caml.inria.fr/archives/200106/msg00199.html
+ * https://web.archive.org/web/20030521020915/http://caml.inria.fr/archives/200106/msg00199.html
  */
 #define NONBLOCKING(code)                      \
   do {                                         \
@@ -43,11 +43,18 @@ static value Val_virconnectcredential (const virConnectCredentialPtr cred);
     caml_leave_blocking_section ();            \
   } while (0)
 
+/* Empty macro to use as empty parameter for other macros, since
+ * a null token as parameter when calling a macro is not allowed
+ * before C99.
+ */
+#define EMPTY
 /* Check error condition from a libvirt function, and automatically raise
  * an exception if one is found.
  */
+#define CHECK_ERROR_CLEANUP(cond, cleanup, fn) \
+  do { if (cond) { cleanup; _raise_virterror (fn); } } while (0)
 #define CHECK_ERROR(cond, fn) \
-  do { if (cond) _raise_virterror (fn); } while (0)
+  CHECK_ERROR_CLEANUP(cond, EMPTY, fn)
 
 /*----------------------------------------------------------------------*/
 
@@ -96,6 +103,7 @@ static value Val_virconnectcredential (const virConnectCredentialPtr cred);
 #define Net_val(rv) (*((virNetworkPtr *)Data_custom_val(rv)))
 #define Pol_val(rv) (*((virStoragePoolPtr *)Data_custom_val(rv)))
 #define Vol_val(rv) (*((virStorageVolPtr *)Data_custom_val(rv)))
+#define Sec_val(rv) (*((virSecretPtr *)Data_custom_val(rv)))
 
 /* Wrap up a pointer to something in a custom block. */
 static value Val_connect (virConnectPtr conn);
@@ -103,6 +111,7 @@ static value Val_dom (virDomainPtr dom);
 static value Val_net (virNetworkPtr net);
 static value Val_pol (virStoragePoolPtr pool);
 static value Val_vol (virStorageVolPtr vol);
+static value Val_sec (virSecretPtr sec);
 
 /* Domains and networks are stored as pairs (dom/net, conn), so have
  * some convenience functions for unwrapping and wrapping them.
@@ -111,12 +120,15 @@ static value Val_vol (virStorageVolPtr vol);
 #define Network_val(rv) (Net_val(Field((rv),0)))
 #define Pool_val(rv) (Pol_val(Field((rv),0)))
 #define Volume_val(rv) (Vol_val(Field((rv),0)))
+#define Secret_val(rv) (Sec_val(Field((rv),0)))
 #define Connect_domv(rv) (Connect_val(Field((rv),1)))
 #define Connect_netv(rv) (Connect_val(Field((rv),1)))
 #define Connect_polv(rv) (Connect_val(Field((rv),1)))
 #define Connect_volv(rv) (Connect_val(Field((rv),1)))
+#define Connect_secv(rv) (Connect_val(Field((rv),1)))
 
 static value Val_domain (virDomainPtr dom, value connv);
 static value Val_network (virNetworkPtr net, value connv);
 static value Val_pool (virStoragePoolPtr pol, value connv);
 static value Val_volume (virStorageVolPtr vol, value connv);
+static value Val_secret (virSecretPtr sec, value connv);