142137Sbostic /*- 2*61180Sbostic * Copyright (c) 1988, 1993 3*61180Sbostic * The Regents of the University of California. All rights reserved. 436771Sbostic * 542137Sbostic * %sccs.include.redist.c% 636771Sbostic */ 736771Sbostic 836771Sbostic #if defined(LIBC_SCCS) && !defined(lint) 9*61180Sbostic static char sccsid[] = "@(#)putenv.c 8.1 (Berkeley) 06/04/93"; 1036771Sbostic #endif /* LIBC_SCCS and not lint */ 1136771Sbostic 1242137Sbostic #include <stdlib.h> 1342186Sbostic #include <string.h> 1442137Sbostic 1542186Sbostic int 1636771Sbostic putenv(str) 1746599Sdonn const char *str; 1836771Sbostic { 1942186Sbostic register char *p, *equal; 2036771Sbostic int rval; 2136771Sbostic 2242186Sbostic if (!(p = strdup(str))) 2336771Sbostic return(1); 2442186Sbostic if (!(equal = index(p, '='))) { 2542186Sbostic (void)free(p); 2642186Sbostic return(1); 2742186Sbostic } 2836771Sbostic *equal = '\0'; 2942186Sbostic rval = setenv(p, equal + 1, 1); 3042186Sbostic (void)free(p); 3136771Sbostic return(rval); 3236771Sbostic } 33