chiark / gitweb /
Avoid accessing backup, auto-save files, etc, with include-lookup.
[userv.git] / lib.c
diff --git a/lib.c b/lib.c
index e36382927e158d007eed9bdbb13a3246c73f8f97..22c8cd1750a52af1855b242104191d6abb3028a1 100644 (file)
--- a/lib.c
+++ b/lib.c
@@ -2,7 +2,7 @@
  * userv - lib.c
  * useful utility routines, used in daemon, but not very dependent on it
  *
- * Copyright (C)1996-1997 Ian Jackson
+ * Copyright (C)1996-1997,1999 Ian Jackson
  *
  * This is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by
@@ -25,6 +25,7 @@
 #include <stdarg.h>
 #include <stdio.h>
 #include <string.h>
+#include <assert.h>
 #include <sys/types.h>
 
 #include "config.h"
@@ -112,3 +113,15 @@ 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) {
+  char *buffer= 0;
+  
+  assert(overwrite==1);
+  buffer= xmalloc(strlen(name)+strlen(value)+2);
+
+  sprintf(buffer,"%s=%s",name,value);
+  return putenv(buffer);
+}
+#endif /* HAVE_SETENV */