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 48 49 50 51 52 53 54 55
|
/**************************************************************************/
/* */
/* OCaml */
/* */
/* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
/* */
/* Copyright 1998 Institut National de Recherche en Informatique et */
/* en Automatique. */
/* */
/* All rights reserved. This file is distributed under the terms of */
/* the GNU Lesser General Public License version 2.1, with the */
/* special exception on linking described in the file LICENSE. */
/* */
/**************************************************************************/
#define CAML_INTERNALS
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <caml/fail.h>
#include <caml/memory.h>
#include <caml/mlvalues.h>
#include <caml/osdeps.h>
#include "caml/unixsupport.h"
#ifdef HAS_PUTENV
CAMLprim value caml_unix_putenv(value name, value val)
{
char * s;
char_os * p;
int ret;
if (! (caml_string_is_c_safe(name) && caml_string_is_c_safe(val)))
caml_unix_error(EINVAL, "putenv", name);
s = caml_stat_strconcat(3, name, "=", val);
p = caml_stat_strdup_to_os(s);
caml_stat_free(s);
ret = putenv_os(p);
if (ret == -1) {
caml_stat_free(p);
caml_uerror("putenv", name);
}
return Val_unit;
}
#else
CAMLprim value caml_unix_putenv(value name, value val)
{ caml_invalid_argument("putenv not implemented"); }
#endif
|