|
|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T p
Length: 1853 (0x73d)
Types: TextFile
Names: »putenv.c«
└─⟦2d1937cfd⟧ Bits:30007241 EUUGD22: P.P 5.0
└─⟦35176feda⟧ »EurOpenD22/isode/isode-6.tar.Z«
└─⟦de7628f85⟧
└─⟦this⟧ »isode-6.0/compat/putenv.c«
/* putenv.c - generic putenv() */
#ifndef lint
static char *rcsid = "$Header: /f/osi/compat/RCS/putenv.c,v 7.0 89/11/23 21:23:21 mrose Rel $";
#endif
/*
* $Header: /f/osi/compat/RCS/putenv.c,v 7.0 89/11/23 21:23:21 mrose Rel $
*
*
* $Log: putenv.c,v $
* Revision 7.0 89/11/23 21:23:21 mrose
* Release 6.0
*
*/
/*
* NOTICE
*
* Acquisition, use, and distribution of this module and related
* materials are subject to the restrictions of a license agreement.
* Consult the Preface in the User's Manual for the full terms of
* this agreement.
*
*/
/* LINTLIBRARY */
#include <stdio.h>
#include "general.h"
#include "manifest.h"
/* \f
*/
extern char **environ;
/* \f
*/
int setenv (name, value)
register char *name,
*value;
{
register int i;
register char **ep,
**nep,
*cp;
if ((cp = malloc ((unsigned) (strlen (name) + strlen (value) + 2)))
== NULL)
return 1;
(void) sprintf (cp, "%s=%s", name, value);
for (ep = environ, i = 0; *ep; ep++, i++)
if (nvmatch (name, *ep)) {
*ep = cp;
return 0;
}
if ((nep = (char **) malloc ((unsigned) ((i + 2) * sizeof *nep)))
== NULL) {
free (cp);
return 1;
}
for (ep = environ, i = 0; *ep; nep[i++] = *ep++)
continue;
nep[i++] = cp;
nep[i] = NULL;
environ = nep;
return 0;
}
/* \f
*/
int unsetenv (name)
char *name;
{
char **ep,
**nep;
for (ep = environ; *ep; ep++)
if (nvmatch (name, *ep))
break;
if (*ep == NULL)
return 1;
for (nep = ep + 1; *nep; nep++)
continue;
*ep = *--nep;
*nep = NULL;
return 0;
}
/* \f
*/
static nvmatch (s1, s2)
register char *s1,
*s2;
{
while (*s1 == *s2++)
if (*s1++ == '=')
return 1;
return (*s1 == '\0' && *--s2 == '=');
}