File: stdlib.c

package info (click to toggle)
ocaml-extunix 0.4.4-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 632 kB
  • sloc: ml: 3,316; ansic: 3,294; makefile: 24
file content (47 lines) | stat: -rw-r--r-- 822 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#define EXTUNIX_WANT_SETENV
#define EXTUNIX_WANT_CLEARENV
#define EXTUNIX_WANT_MKDTEMP
#include "config.h"

#if defined(EXTUNIX_HAVE_SETENV)

CAMLprim value caml_extunix_setenv(value v_name, value v_val, value v_overwrite)
{
  CAMLparam3(v_name, v_val, v_overwrite);

  if (0 != setenv(String_val(v_name), String_val(v_val), Bool_val(v_overwrite)))
  {
    caml_uerror("setenv",v_name);
  }

  CAMLreturn(Val_unit);
}

CAMLprim value caml_extunix_unsetenv(value v_name)
{
  CAMLparam1(v_name);

  if (0 != unsetenv(String_val(v_name)))
  {
    caml_uerror("unsetenv",v_name);
  }

  CAMLreturn(Val_unit);
}

#endif

#if defined(EXTUNIX_HAVE_CLEARENV)

CAMLprim value caml_extunix_clearenv(value v_unit)
{
  UNUSED(v_unit);
  if (0 != clearenv())
  {
    caml_uerror("clearenv", Nothing);
  }

  return Val_unit;
}

#endif