X-Git-Url: https://tinc-vpn.org/git/browse?p=tinc;a=blobdiff_plain;f=lib%2Fdropin.c;h=c26a357c449ea5a5d36bc64d9c6568f209088b56;hp=518a175d56161659125fd2afa5b4c99b8fbb3b87;hb=25a804c94ef0dbc4e5582ea6d8459d5f9a3fe06c;hpb=d3f889c8076dff9c00ebfe1459cb36425f8da41d;ds=inline diff --git a/lib/dropin.c b/lib/dropin.c index 518a175d..c26a357c 100644 --- a/lib/dropin.c +++ b/lib/dropin.c @@ -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.3 2001/01/07 17:08:49 guus Exp $ + $Id: dropin.c,v 1.1.2.5 2001/11/05 19:06:07 guus Exp $ */ #include "config.h" @@ -27,10 +27,12 @@ #include #include #include +#include #include #include +#include #ifndef HAVE_DAEMON /* @@ -113,6 +115,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 +126,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 +137,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