/*
 *  setenv() doesn't exist on Ultrix...  it's putenv instead.
 *  So, we write our own setenv routine, and use it instead.
 *
 *  Arguments:  (same as setenv in BSD Unix)
 *      char *name;     name of environment variable to set or change.
 *      char *value;    value to set or change environment variable to.
 *      int overwrite;  if non-zero, force variable to value.
 *                      if zero, and variable does not exist, add variable
 *                              to environment.
 *                      else, do nothing.
 *
 *  Returns:   (same as setenv in bsd Unix)
 *      -1              if unsuccessful (unable to malloc enough space for
 *                              an expanded environment).
 *      0               otherwise.
 *
 */
#if defined(ultrix) || defined(_AIX)
int setenv(name, value, overwrite)
     char *name, *value;
     int overwrite;
{
  char *string;

  if ((overwrite) ||
      (getenv(name) == NULL))
    {
      string = (char *) malloc((strlen(name) + strlen(value) + 1)
                               * sizeof(char));
      if (string == NULL)
        return(-1);
      strcpy(string, name);
      strcat(string, "=");
      strcat(string, value);
      if (! putenv(string) )
        return(-1);
      return(0);
    }
}
#endif
