Cleanups:
[tinc] / lib / dropin.c
index 9de5c2c..661c455 100644 (file)
@@ -1,7 +1,7 @@
 /*
     dropin.c -- a set of drop-in replacements for libc functions
-    Copyright (C) 2000,2001 Ivo Timmermans <itimmermans@bigfoot.com>,
-                  2000,2001 Guus Sliepen <guus@sliepen.warande.net>
+    Copyright (C) 2000,2001 Ivo Timmermans <ivo@o2w.nl>,
+                  2000,2001 Guus Sliepen <guus@sliepen.eu.org>
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -17,7 +17,7 @@
     along with this program; if not, write to the Free Software
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
-    $Id: dropin.c,v 1.1.2.4 2001/02/06 10:12:51 guus Exp $
+    $Id: dropin.c,v 1.1.2.11 2002/07/12 11:45:21 guus Exp $
 */
 
 #include "config.h"
@@ -27,6 +27,8 @@
 #include <fcntl.h>
 #include <unistd.h>
 #include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
 
 #include <xalloc.h>
 
@@ -96,6 +98,8 @@ int daemon(int nochdir, int noclose)
           dup2(fd, 2);
         }
     }
+
+  return 0;
 }
 #endif
 
@@ -136,3 +140,32 @@ char *get_current_dir_name(void)
   return buf;
 }
 #endif
+
+#ifndef HAVE_ASPRINTF
+int asprintf(char **buf, const char *fmt, ...)
+{
+  int status;
+  va_list ap;
+  int len;
+  
+  len = 4096;
+  *buf = xmalloc(len);
+
+  va_start(ap, fmt);
+  status = vsnprintf (*buf, len, fmt, ap);
+  va_end (ap);
+
+  if(status >= 0)
+    *buf = xrealloc(*buf, status);
+
+  if(status > len-1)
+    {
+      len = status;
+      va_start(ap, fmt);
+      status = vsnprintf (*buf, len, fmt, ap);
+      va_end (ap);
+    }
+
+  return status;
+}
+#endif