Family: setenv
Authors: Kevin S Braunsdorf
Mail: [email protected]
Version: 5.1
Bugs: None known.

Introduction

This code emulates the setenv code for systems which do not support that interface.

Configuration

#define USE_MALLOC_H
If defined to a non-zero we include <malloc.h> to get the declarations for malloc and calloc.
#define REALLY_USE_STDLIB
If defined to a non-zero we include <stdlib.h> to get the declarations for malloc and calloc. If there is a declaration of setenv in there it must match our prototype.
#define EMU_UINT32
The type that malloc takes for the size parameter. Only used when !USE_MALLOC_H && !REALLY_USE_STDLIB. Defaults to (unsigned int).

Provides

int setenv(const char *pcName, const char *pcValue, int fOver);
Given a named environment variable and a value this code updates the global C variable environ to point to a new vector with the variable replaced or added (someplace).

If the new value is (char *)0 (the NULL pointer) then the variable is removed from the global environment.

I added the silly fOver parameter to make it compatible with FreeBSD and AIX versions with the same name. I would add that this code is much older than those interfaces.

To Do List

Port to more systems. Add a putenv interface.
$Id: setenv.html,v 6.10 2012/08/30 14:53:51 ksb Exp $