9base

revived minimalist port of Plan 9 userland to Unix
git clone git://git.suckless.org/9base
Log | Files | Refs | README | LICENSE

getenv.c (281B)


      1 #include <u.h>
      2 #define NOPLAN9DEFINES
      3 #include <libc.h>
      4 
      5 char*
      6 p9getenv(char *s)
      7 {
      8 	char *t;
      9 
     10 	t = getenv(s);
     11 	if(t == 0)
     12 		return 0;
     13 	return strdup(t);
     14 }
     15 
     16 int
     17 p9putenv(char *s, char *v)
     18 {
     19 	char *t;
     20 
     21 	t = smprint("%s=%s", s, v);
     22 	if(t == nil)
     23 		return -1;
     24 	putenv(t);
     25 	return 0;
     26 }