X-Git-Url: https://tinc-vpn.org/git/browse?p=tinc;a=blobdiff_plain;f=lib%2Fdropin.c;h=a500a0348a8cca2711feceeef6d5550b00f4d1fd;hp=5f4fcebd39135873b013da52e1d26b9b35e3d4c9;hb=9d769e0bf2ce266e8533e5e7c16bf07e44a9be34;hpb=1ca04711aeab615161746c6bbb5d137388c73263 diff --git a/lib/dropin.c b/lib/dropin.c index 5f4fcebd..a500a034 100644 --- a/lib/dropin.c +++ b/lib/dropin.c @@ -1,7 +1,7 @@ /* dropin.c -- a set of drop-in replacements for libc functions - Copyright (C) 2000 Ivo Timmermans , - 2000 Guus Sliepen + Copyright (C) 2000,2001 Ivo Timmermans , + 2000,2001 Guus Sliepen 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.2 2000/11/29 00:33:15 zarq Exp $ + $Id: dropin.c,v 1.1.2.9 2002/06/09 15:26:10 zarq Exp $ */ #include "config.h" @@ -27,10 +27,15 @@ #include #include #include +#include +#include #include #include +#include + +#include "fake-getnameinfo.c" #ifndef HAVE_DAEMON /* @@ -95,6 +100,8 @@ int daemon(int nochdir, int noclose) dup2(fd, 2); } } + + return 0; } #endif @@ -113,6 +120,7 @@ char *get_current_dir_name(void) { size_t size; char *buf; + char *r; /* Start with 100 bytes. If this turns out to be insufficient to contain the working directory, double the size. */ @@ -123,7 +131,7 @@ char *get_current_dir_name(void) r = getcwd(buf, size); /* getcwd returns NULL and sets errno to ERANGE if the bufferspace is insufficient to contain the entire working directory. */ - while(r == NULL && errno = ERANGE) + while(r == NULL && errno == ERANGE) { free(buf); size <<= 1; /* double the size */ @@ -134,3 +142,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