source: trunk/minix/lib/other/setenv.c@ 15

Last change on this file since 15 was 9, checked in by Mattia Monga, 14 years ago

Minix 3.1.2a

File size: 332 bytes
Line 
1
2#include <stdlib.h>
3#include <string.h>
4
5int
6setenv(const char *name, const char *val, int overwrite)
7{
8 char *bf;
9 int r;
10
11 if(!overwrite && getenv(name))
12 return 0;
13
14 if(!(bf=malloc(strlen(name)+strlen(val)+2)))
15 return -1;
16
17 strcpy(bf, name);
18 strcat(bf, "=");
19 strcat(bf, val);
20
21 r = putenv(bf);
22
23 return r == 0 ? 0 : -1;
24}
25
Note: See TracBrowser for help on using the repository browser.