1998-04-30 06:30:03 -07:00
|
|
|
/***********************************************************************/
|
|
|
|
/* */
|
|
|
|
/* Objective Caml */
|
|
|
|
/* */
|
|
|
|
/* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
|
|
|
|
/* */
|
|
|
|
/* Copyright 1998 Institut National de Recherche en Informatique et */
|
1999-11-17 10:59:06 -08:00
|
|
|
/* en Automatique. All rights reserved. This file is distributed */
|
2001-12-07 05:41:02 -08:00
|
|
|
/* under the terms of the GNU Library General Public License, with */
|
|
|
|
/* the special exception on linking described in file ../../LICENSE. */
|
1998-04-30 06:30:03 -07:00
|
|
|
/* */
|
|
|
|
/***********************************************************************/
|
|
|
|
|
|
|
|
/* $Id$ */
|
|
|
|
|
1998-05-23 07:10:37 -07:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
1998-04-30 06:30:03 -07:00
|
|
|
#include <memory.h>
|
|
|
|
#include <mlvalues.h>
|
1998-05-23 07:10:37 -07:00
|
|
|
|
1998-04-30 06:30:03 -07:00
|
|
|
#include "unixsupport.h"
|
|
|
|
|
|
|
|
#ifdef HAS_PUTENV
|
|
|
|
|
2001-08-28 07:47:48 -07:00
|
|
|
CAMLprim value unix_putenv(value name, value val)
|
1998-04-30 06:30:03 -07:00
|
|
|
{
|
|
|
|
mlsize_t namelen = string_length(name);
|
|
|
|
mlsize_t vallen = string_length(val);
|
|
|
|
char * s = (char *) stat_alloc(namelen + 1 + vallen + 1);
|
|
|
|
|
2000-11-23 05:45:03 -08:00
|
|
|
memmove (s, String_val(name), namelen);
|
1998-04-30 06:30:03 -07:00
|
|
|
s[namelen] = '=';
|
2000-11-23 05:45:03 -08:00
|
|
|
memmove (s + namelen + 1, String_val(val), vallen);
|
1998-04-30 06:30:03 -07:00
|
|
|
s[namelen + 1 + vallen] = 0;
|
|
|
|
if (putenv(s) == -1) uerror("putenv", name);
|
|
|
|
return Val_unit;
|
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
2001-08-28 07:47:48 -07:00
|
|
|
CAMLprim value unix_putenv(value name, value val)
|
1998-04-30 06:30:03 -07:00
|
|
|
{ invalid_argument("putenv not implemented"); }
|
|
|
|
|
|
|
|
#endif
|