X-Git-Url: https://git.librecmc.org/?p=oweals%2Ftinc.git;a=blobdiff_plain;f=lib%2Futils.c;h=7f588b475a3e54e34aea13e5817f25d0a7bb55de;hp=795ece92f5700c188d127e692738efb342d59522;hb=f8f1007bf469d44480d95d0d78ddc156d00e059f;hpb=56bd0864e4c5680fee59af48228b1ec3fb97b57b diff --git a/lib/utils.c b/lib/utils.c index 795ece9..7f588b4 100644 --- a/lib/utils.c +++ b/lib/utils.c @@ -21,11 +21,13 @@ #include #include #include +#include #include "config.h" #include #include +#include volatile int (cp_line[]) = {0, 0, 0, 0, 0, 0, 0, 0}; volatile char (*cp_file[]) = {"?", "?", "?", "?", "?", "?", "?", "?"}; @@ -72,3 +74,32 @@ void cp_trace() cp_file[cp_index], cp_line[cp_index] ); } + +#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