Missing from the OCaml stdlib. This implementation is the same as the
one in Jane St's Core, except we don't bother to throw an exception on
error.
---
mllib/unix_utils-c.c | 9 +++++++++
mllib/unix_utils.ml | 4 ++++
mllib/unix_utils.mli | 5 +++++
3 files changed, 18 insertions(+)
diff --git a/mllib/unix_utils-c.c b/mllib/unix_utils-c.c
index f9615ec..1a4c3d7 100644
--- a/mllib/unix_utils-c.c
+++ b/mllib/unix_utils-c.c
@@ -45,6 +45,7 @@ extern void unix_error (int errcode, char * cmdname, value arg)
Noreturn;
extern value guestfs_int_mllib_dev_t_makedev (value majv, value minv);
extern value guestfs_int_mllib_dev_t_major (value devv);
extern value guestfs_int_mllib_dev_t_minor (value devv);
+extern value guestfs_int_mllib_unsetenv (value strv);
extern int guestfs_int_mllib_exit (value rv) __attribute__((noreturn));
extern value guestfs_int_mllib_fnmatch (value patternv, value strv, value flagsv);
extern value guestfs_int_mllib_sync (value unitv);
@@ -74,6 +75,14 @@ guestfs_int_mllib_dev_t_minor (value devv)
}
/* NB: This is a "noalloc" call. */
+value
+guestfs_int_mllib_unsetenv (value strv)
+{
+ unsetenv (String_val (strv));
+ return Val_unit;
+}
+
+/* NB: This is a "noalloc" call. */
int
guestfs_int_mllib_exit (value rv)
{
diff --git a/mllib/unix_utils.ml b/mllib/unix_utils.ml
index aeb24ed..66b6e4f 100644
--- a/mllib/unix_utils.ml
+++ b/mllib/unix_utils.ml
@@ -22,6 +22,10 @@ module Dev_t = struct
external minor : int -> int = "guestfs_int_mllib_dev_t_minor"
"noalloc"
end
+module Env = struct
+ external unsetenv : string -> unit = "guestfs_int_mllib_unsetenv"
"noalloc"
+end
+
module Exit = struct
external _exit : int -> 'a = "guestfs_int_mllib_exit"
"noalloc"
end
diff --git a/mllib/unix_utils.mli b/mllib/unix_utils.mli
index be3eab8..0a4c1b3 100644
--- a/mllib/unix_utils.mli
+++ b/mllib/unix_utils.mli
@@ -32,6 +32,11 @@ module Dev_t : sig
(** minor(3) *)
end
+module Env : sig
+ val unsetenv : string -> unit
+ (** Unset named environment variable, see unsetenv(3). *)
+end
+
module Exit : sig
val _exit : int -> 'a
(** Call _exit directly, ie. do not run OCaml atexit handlers. *)
--
2.9.3