/* environ.c -- library for manipulating environments for GNU.
- Copyright 1986, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 2000
- Free Software Foundation, Inc.
+
+ Copyright 1986, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 2000, 2005
+ 2003 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
/* Return a new environment object. */
-struct environ *
+struct gdb_environ *
make_environ (void)
{
- struct environ *e;
+ struct gdb_environ *e;
- e = (struct environ *) xmalloc (sizeof (struct environ));
+ e = (struct gdb_environ *) xmalloc (sizeof (struct gdb_environ));
e->allocated = 10;
e->vector = (char **) xmalloc ((e->allocated + 1) * sizeof (char *));
/* Free an environment and all the strings in it. */
void
-free_environ (register struct environ *e)
+free_environ (struct gdb_environ *e)
{
char **vector = e->vector;
that all strings in these environments are safe to free. */
void
-init_environ (register struct environ *e)
+init_environ (struct gdb_environ *e)
{
extern char **environ;
int i;
while (--i >= 0)
{
- register int len = strlen (e->vector[i]);
- register char *new = (char *) xmalloc (len + 1);
+ int len = strlen (e->vector[i]);
+ char *new = (char *) xmalloc (len + 1);
memcpy (new, e->vector[i], len + 1);
e->vector[i] = new;
}
This is used to get something to pass to execve. */
char **
-environ_vector (struct environ *e)
+environ_vector (struct gdb_environ *e)
{
return e->vector;
}
/* Return the value in environment E of variable VAR. */
char *
-get_in_environ (const struct environ *e, const char *var)
+get_in_environ (const struct gdb_environ *e, const char *var)
{
int len = strlen (var);
char **vector = e->vector;
char *s;
for (; (s = *vector) != NULL; vector++)
- if (STREQN (s, var, len) && s[len] == '=')
+ if (strncmp (s, var, len) == 0 && s[len] == '=')
return &s[len + 1];
return 0;
/* Store the value in E of VAR as VALUE. */
void
-set_in_environ (struct environ *e, const char *var, const char *value)
+set_in_environ (struct gdb_environ *e, const char *var, const char *value)
{
int i;
int len = strlen (var);
char *s;
for (i = 0; (s = vector[i]) != NULL; i++)
- if (STREQN (s, var, len) && s[len] == '=')
+ if (strncmp (s, var, len) == 0 && s[len] == '=')
break;
if (s == 0)
/* Remove the setting for variable VAR from environment E. */
void
-unset_in_environ (struct environ *e, char *var)
+unset_in_environ (struct gdb_environ *e, char *var)
{
int len = strlen (var);
char **vector = e->vector;
for (; (s = *vector) != NULL; vector++)
{
- if (STREQN (s, var, len) && s[len] == '=')
+ if (DEPRECATED_STREQN (s, var, len) && s[len] == '=')
{
xfree (s);
/* Walk through the vector, shuffling args down by one, including