X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?a=blobdiff_plain;f=lib.c;h=bd40ee08ab77376f74b1ce5715b9740a16c82e71;hb=5ecf822a1500a6f945bead39c508f9dca673cfed;hp=7a22d19eae1e96a29dd9214447f33e1024b8418b;hpb=b6c671fd90134d458ad4722ec3a99742bced1a34;p=userv.git diff --git a/lib.c b/lib.c index 7a22d19..bd40ee0 100644 --- a/lib.c +++ b/lib.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include "config.h" @@ -112,3 +113,19 @@ void snytprintfcat(char *buffer, size_t size, const char *fmt, ...) { vsnytprintfcat(buffer,size,fmt,al); va_end(al); } + +#ifndef HAVE_SETENV +int setenv(const char *name, const char *value, int overwrite) { + static char *buffer= 0; + static int avail= 0; + + int r; + + assert(overwrite==1); + r= makeroom(&buffer,&avail,strlen(name)+strlen(value)+2); + if (r) { errno= EINVAL; return -1; } + + sprintf(buffer,"%s=%s",name,value); + return putenv(buffer); +} +#endif /* HAVE_SETENV */