Exemplo n.º 1
0
Arquivo: setenv.c Projeto: DonCN/haiku
int
setenv (const char *name, const char *value, int replace)
{
  if (name == NULL || *name == '\0' || strchr (name, '=') != NULL)
    {
      __set_errno (EINVAL);
      return -1;
    }

  return __add_to_environ (name, value, NULL, replace);
}
Exemplo n.º 2
0
/* Put STRING, which is of the form "NAME=VALUE", in the environment.  */
int putenv (char *string)
{
    int result;
    const char *const name_end = strchr (string, '=');

    if (name_end != NULL) {
		char *name = strndup(string, name_end - string);
		result = __add_to_environ (name, NULL, string, 1);
		free(name);
		return(result);
    }
    unsetenv (string);
    return 0;
}
Exemplo n.º 3
0
/* Put STRING, which is of the form "NAME=VALUE", in the environment.  */
int
putenv (char *string)
{
  const char *const name_end = strchr (string, '=');

  if (name_end != NULL)
    {
      char *name;
#ifdef _LIBC
      int use_malloc = !__libc_use_alloca (name_end - string + 1);
      if (__builtin_expect (use_malloc, 0))
	{
	  name = strndup (string, name_end - string);
	  if (name == NULL)
	    return -1;
	}
      else
	name = strndupa (string, name_end - string);
#else
# define use_malloc 1
      name = malloc (name_end - string + 1);
      if (name == NULL)
	return -1;
      memcpy (name, string, name_end - string);
      name[name_end - string] = '\0';
#endif
      int result = __add_to_environ (name, NULL, string, 1);

      if (__glibc_unlikely (use_malloc))
	free (name);

      return result;
    }

  __unsetenv (string);
  return 0;
}
Exemplo n.º 4
0
int
setenv (const char *name, const char *value, int replace)
{
  return __add_to_environ (name, value, NULL, replace);
}