1 /***************************************************************************
3 * Project ___| | | | _ \| |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
8 * Copyright (C) 1999 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
10 * This software is licensed as described in the file COPYING, which
11 * you should have received as part of this distribution. The terms
12 * are also available at http://curl.haxx.se/docs/copyright.html.
14 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
15 * copies of the Software, and permit persons to whom the Software is
16 * furnished to do so, under the terms of the COPYING file.
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
23 * A merge of Bjorn Reese's format() function and Daniel's dsprintf()
24 * 1.0. A full blooded printf() clone with full support for <num>$
25 * everywhere (parameters, widths and precisions) including variabled
26 * sized parameters (like doubles, long longs, long doubles and even
27 * void * in 64-bit architectures).
29 * Current restrictions:
30 * - Max 128 parameters
31 * - No 'long double' support.
33 * If you ever want truly portable and good *printf() clones, the project that
34 * took on from here is named 'Trio' and you find more details on the trio web
35 * page at http://daniel.haxx.se/trio/
40 #if defined(DJGPP) && (DJGPP_MINOR < 4)
41 #undef _MPRINTF_REPLACE /* don't use x_was_used() here */
44 #include <curl/mprintf.h>
46 #include "curl_memory.h"
47 /* The last #include file should be: */
50 #ifndef SIZEOF_LONG_DOUBLE
51 #define SIZEOF_LONG_DOUBLE 0
55 * If SIZEOF_SIZE_T has not been defined, default to the size of long.
59 # define SIZEOF_SIZE_T CURL_SIZEOF_LONG
63 # define LONG_LONG_TYPE long long
64 # define HAVE_LONG_LONG_TYPE
66 # if defined(_MSC_VER) && (_MSC_VER >= 900) && (_INTEGRAL_MAX_BITS >= 64)
67 # define LONG_LONG_TYPE __int64
68 # define HAVE_LONG_LONG_TYPE
70 # undef LONG_LONG_TYPE
71 # undef HAVE_LONG_LONG_TYPE
76 * Max integer data types that mprintf.c is capable
79 #ifdef HAVE_LONG_LONG_TYPE
80 # define mp_intmax_t LONG_LONG_TYPE
81 # define mp_uintmax_t unsigned LONG_LONG_TYPE
83 # define mp_intmax_t long
84 # define mp_uintmax_t unsigned long
87 #define BUFFSIZE 256 /* buffer for long-to-str and float-to-str calcs */
88 #define MAX_PARAMETERS 128 /* lame static limit */
94 /* Lower-case digits. */
95 static const char lower_digits[] = "0123456789abcdefghijklmnopqrstuvwxyz";
97 /* Upper-case digits. */
98 static const char upper_digits[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
102 if(stream((unsigned char)(x), (FILE *)data) != -1) \
105 return done; /* return immediately on failure */ \
108 /* Data type to read from the arglist */
119 FORMAT_WIDTH /* For internal use */
122 /* conversion and display flags */
126 FLAGS_SHOWSIGN = 1<<1,
131 FLAGS_LONGLONG = 1<<6,
132 FLAGS_LONGDOUBLE = 1<<7,
133 FLAGS_PAD_NIL = 1<<8,
134 FLAGS_UNSIGNED = 1<<9,
138 FLAGS_WIDTH = 1<<13, /* '*' or '*<num>$' used */
139 FLAGS_WIDTHPARAM = 1<<14, /* width PARAMETER was specified */
140 FLAGS_PREC = 1<<15, /* precision was specified */
141 FLAGS_PRECPARAM = 1<<16, /* precision PARAMETER was specified */
142 FLAGS_CHAR = 1<<17, /* %c story */
143 FLAGS_FLOATE = 1<<18, /* %e or %E */
144 FLAGS_FLOATG = 1<<19 /* %g or %G */
150 long width; /* width OR width parameter number */
151 long precision; /* precision OR precision parameter number */
156 mp_intmax_t as_signed;
157 mp_uintmax_t as_unsigned;
170 char *buffer; /* allocated buffer */
171 size_t len; /* length of string */
172 size_t alloc; /* length of alloc */
173 int fail; /* (!= 0) if an alloc has failed and thus
174 the output is not the complete data */
177 static long dprintf_DollarString(char *input, char **end)
180 while(ISDIGIT(*input)) {
182 number += *input-'0';
185 if(number && ('$'==*input++)) {
192 static int dprintf_IsQualifierNoDollar(char c)
195 case '-': case '+': case ' ': case '#': case '.':
196 case '0': case '1': case '2': case '3': case '4':
197 case '5': case '6': case '7': case '8': case '9':
198 case 'h': case 'l': case 'L': case 'z': case 'q':
202 return 0; /* false */
206 #ifdef DPRINTF_DEBUG2
207 static void dprintf_Pass1Report(va_stack_t *vto, int max)
214 for(i=0; i<max; i++) {
216 switch(vto[i].type) {
235 case FORMAT_LONGLONG:
241 case FORMAT_LONGDOUBLE:
242 type = "long double";
249 for(bit=0; bit<31; bit++) {
250 flags = vto[i].flags & (1<<bit);
252 if(flags & FLAGS_SPACE)
253 strcat(buffer, "space ");
254 else if(flags & FLAGS_SHOWSIGN)
255 strcat(buffer, "plus ");
256 else if(flags & FLAGS_LEFT)
257 strcat(buffer, "left ");
258 else if(flags & FLAGS_ALT)
259 strcat(buffer, "alt ");
260 else if(flags & FLAGS_SHORT)
261 strcat(buffer, "short ");
262 else if(flags & FLAGS_LONG)
263 strcat(buffer, "long ");
264 else if(flags & FLAGS_LONGLONG)
265 strcat(buffer, "longlong ");
266 else if(flags & FLAGS_LONGDOUBLE)
267 strcat(buffer, "longdouble ");
268 else if(flags & FLAGS_PAD_NIL)
269 strcat(buffer, "padnil ");
270 else if(flags & FLAGS_UNSIGNED)
271 strcat(buffer, "unsigned ");
272 else if(flags & FLAGS_OCTAL)
273 strcat(buffer, "octal ");
274 else if(flags & FLAGS_HEX)
275 strcat(buffer, "hex ");
276 else if(flags & FLAGS_UPPER)
277 strcat(buffer, "upper ");
278 else if(flags & FLAGS_WIDTH)
279 strcat(buffer, "width ");
280 else if(flags & FLAGS_WIDTHPARAM)
281 strcat(buffer, "widthparam ");
282 else if(flags & FLAGS_PREC)
283 strcat(buffer, "precision ");
284 else if(flags & FLAGS_PRECPARAM)
285 strcat(buffer, "precparam ");
286 else if(flags & FLAGS_CHAR)
287 strcat(buffer, "char ");
288 else if(flags & FLAGS_FLOATE)
289 strcat(buffer, "floate ");
290 else if(flags & FLAGS_FLOATG)
291 strcat(buffer, "floatg ");
293 printf("REPORT: %d. %s [%s]\n", i, type, buffer);
301 /******************************************************************
304 * Create an index with the type of each parameter entry and its
305 * value (may vary in size)
307 ******************************************************************/
309 static long dprintf_Pass1(const char *format, va_stack_t *vto, char **endpos,
312 char *fmt = (char *)format;
325 continue; /* while */
330 /* Handle the positional case (N$) */
334 this_param = dprintf_DollarString(fmt, &fmt);
336 /* we got no positional, get the next counter */
337 this_param = param_num;
339 if(this_param > max_param)
340 max_param = this_param;
343 * The parameter with number 'i' should be used. Next, we need
344 * to get SIZE and TYPE of the parameter. Add the information
351 /* Handle the flags */
353 while(dprintf_IsQualifierNoDollar(*fmt)) {
356 flags |= FLAGS_SPACE;
359 flags |= FLAGS_SHOWSIGN;
363 flags &= ~FLAGS_PAD_NIL;
371 /* The precision is picked from a specified parameter */
373 flags |= FLAGS_PRECPARAM;
377 i = dprintf_DollarString(fmt, &fmt);
381 precision = param_num;
383 if(precision > max_param)
384 max_param = precision;
388 precision = strtol(fmt, &fmt, 10);
392 flags |= FLAGS_SHORT;
395 if(flags & FLAGS_LONG)
396 flags |= FLAGS_LONGLONG;
401 flags |= FLAGS_LONGDOUBLE;
404 flags |= FLAGS_LONGLONG;
407 /* the code below generates a warning if -Wunreachable-code is
409 #if (SIZEOF_SIZE_T > CURL_SIZEOF_LONG)
410 flags |= FLAGS_LONGLONG;
416 #if (CURL_SIZEOF_CURL_OFF_T > CURL_SIZEOF_LONG)
417 flags |= FLAGS_LONGLONG;
423 if(!(flags & FLAGS_LEFT))
424 flags |= FLAGS_PAD_NIL;
426 case '1': case '2': case '3': case '4':
427 case '5': case '6': case '7': case '8': case '9':
428 flags |= FLAGS_WIDTH;
429 width = strtol(fmt-1, &fmt, 10);
431 case '*': /* Special case */
432 flags |= FLAGS_WIDTHPARAM;
435 i = dprintf_DollarString(fmt, &fmt);
440 if(width > max_param)
448 /* Handle the specifier */
457 vto[i].type = FORMAT_STRING;
460 vto[i].type = FORMAT_INTPTR;
463 vto[i].type = FORMAT_PTR;
466 vto[i].type = FORMAT_INT;
469 vto[i].type = FORMAT_INT;
470 flags |= FLAGS_UNSIGNED;
473 vto[i].type = FORMAT_INT;
474 flags |= FLAGS_OCTAL;
477 vto[i].type = FORMAT_INT;
481 vto[i].type = FORMAT_INT;
482 flags |= FLAGS_HEX|FLAGS_UPPER;
485 vto[i].type = FORMAT_INT;
489 vto[i].type = FORMAT_DOUBLE;
492 vto[i].type = FORMAT_DOUBLE;
493 flags |= FLAGS_FLOATE;
496 vto[i].type = FORMAT_DOUBLE;
497 flags |= FLAGS_FLOATE|FLAGS_UPPER;
500 vto[i].type = FORMAT_DOUBLE;
501 flags |= FLAGS_FLOATG;
504 vto[i].type = FORMAT_DOUBLE;
505 flags |= FLAGS_FLOATG|FLAGS_UPPER;
508 vto[i].type = FORMAT_UNKNOWN;
512 vto[i].flags = flags;
513 vto[i].width = width;
514 vto[i].precision = precision;
516 if(flags & FLAGS_WIDTHPARAM) {
517 /* we have the width specified from a parameter, so we make that
518 parameter's info setup properly */
519 vto[i].width = width - 1;
521 vto[i].type = FORMAT_WIDTH;
522 vto[i].flags = FLAGS_NEW;
523 vto[i].precision = vto[i].width = 0; /* can't use width or precision
526 if(flags & FLAGS_PRECPARAM) {
527 /* we have the precision specified from a parameter, so we make that
528 parameter's info setup properly */
529 vto[i].precision = precision - 1;
531 vto[i].type = FORMAT_WIDTH;
532 vto[i].flags = FLAGS_NEW;
533 vto[i].precision = vto[i].width = 0; /* can't use width or precision
536 *endpos++ = fmt + 1; /* end of this sequence */
540 #ifdef DPRINTF_DEBUG2
541 dprintf_Pass1Report(vto, max_param);
544 /* Read the arg list parameters into our data list */
545 for(i=0; i<max_param; i++) {
546 if((i + 1 < max_param) && (vto[i + 1].type == FORMAT_WIDTH)) {
547 /* Width/precision arguments must be read before the main argument
548 * they are attached to
550 vto[i + 1].data.num.as_signed = (mp_intmax_t)va_arg(arglist, int);
553 switch (vto[i].type) {
555 vto[i].data.str = va_arg(arglist, char *);
561 vto[i].data.ptr = va_arg(arglist, void *);
565 #ifdef HAVE_LONG_LONG_TYPE
566 if((vto[i].flags & FLAGS_LONGLONG) && (vto[i].flags & FLAGS_UNSIGNED))
567 vto[i].data.num.as_unsigned =
568 (mp_uintmax_t)va_arg(arglist, mp_uintmax_t);
569 else if(vto[i].flags & FLAGS_LONGLONG)
570 vto[i].data.num.as_signed =
571 (mp_intmax_t)va_arg(arglist, mp_intmax_t);
575 if((vto[i].flags & FLAGS_LONG) && (vto[i].flags & FLAGS_UNSIGNED))
576 vto[i].data.num.as_unsigned =
577 (mp_uintmax_t)va_arg(arglist, unsigned long);
578 else if(vto[i].flags & FLAGS_LONG)
579 vto[i].data.num.as_signed =
580 (mp_intmax_t)va_arg(arglist, long);
581 else if(vto[i].flags & FLAGS_UNSIGNED)
582 vto[i].data.num.as_unsigned =
583 (mp_uintmax_t)va_arg(arglist, unsigned int);
585 vto[i].data.num.as_signed =
586 (mp_intmax_t)va_arg(arglist, int);
591 vto[i].data.dnum = va_arg(arglist, double);
595 /* Argument has been read. Silently convert it into an integer
598 vto[i].type = FORMAT_INT;
610 static int dprintf_formatf(
611 void *data, /* untouched by format(), just sent to the stream() function in
612 the second argument */
613 /* function pointer called for each output character */
614 int (*stream)(int, FILE *),
615 const char *format, /* %-formatted string */
616 va_list ap_save) /* list of parameters */
618 /* Base-36 digits for numbers. */
619 const char *digits = lower_digits;
621 /* Pointer into the format string. */
624 /* Number of characters written. */
627 long param; /* current parameter to read */
628 long param_num=0; /* parameter counter */
630 va_stack_t vto[MAX_PARAMETERS];
631 char *endpos[MAX_PARAMETERS];
638 /* Do the actual %-code parsing */
639 dprintf_Pass1(format, vto, endpos, ap_save);
641 end = &endpos[0]; /* the initial end-position from the list dprintf_Pass1()
646 /* Format spec modifiers. */
649 /* Width of a field. */
652 /* Precision of a field. */
655 /* Decimal integer is negative. */
658 /* Base of a number to be written. */
661 /* Integral values to be written. */
664 /* Used to convert negative in positive. */
665 mp_intmax_t signed_num;
668 /* This isn't a format spec, so write everything out until the next one
669 OR end of string is reached. */
672 } while(*++f && ('%' != *f));
678 /* Check for "%%". Note that although the ANSI standard lists
679 '%' as a conversion specifier, it says "The complete format
680 specification shall be `%%'," so we can avoid all the width
681 and precision processing. */
688 /* If this is a positional parameter, the position must follow immediately
689 after the %, thus create a %<num>$ sequence */
690 param=dprintf_DollarString(f, &f);
697 param_num++; /* increase this always to allow "%2$s %1$s %s" and then the
698 third %s will pick the 3rd argument */
702 /* pick up the specified width */
703 if(p->flags & FLAGS_WIDTHPARAM)
704 width = (long)vto[p->width].data.num.as_signed;
708 /* pick up the specified precision */
709 if(p->flags & FLAGS_PRECPARAM) {
710 prec = (long)vto[p->precision].data.num.as_signed;
711 param_num++; /* since the precision is extraced from a parameter, we
712 must skip that to get to the next one properly */
714 else if(p->flags & FLAGS_PREC)
719 is_alt = (p->flags & FLAGS_ALT) ? 1 : 0;
723 num = p->data.num.as_unsigned;
724 if(p->flags & FLAGS_CHAR) {
726 if(!(p->flags & FLAGS_LEFT))
730 if(p->flags & FLAGS_LEFT)
735 if(p->flags & FLAGS_UNSIGNED) {
736 /* Decimal unsigned integer. */
738 goto unsigned_number;
740 if(p->flags & FLAGS_OCTAL) {
741 /* Octal unsigned integer. */
743 goto unsigned_number;
745 if(p->flags & FLAGS_HEX) {
746 /* Hexadecimal unsigned integer. */
748 digits = (p->flags & FLAGS_UPPER)? upper_digits : lower_digits;
750 goto unsigned_number;
753 /* Decimal integer. */
756 is_neg = (p->data.num.as_signed < (mp_intmax_t)0) ? 1 : 0;
758 /* signed_num might fail to hold absolute negative minimum by 1 */
759 signed_num = p->data.num.as_signed + (mp_intmax_t)1;
760 signed_num = -signed_num;
761 num = (mp_uintmax_t)signed_num;
762 num += (mp_uintmax_t)1;
768 /* Unsigned number of base BASE. */
772 /* Number of base BASE. */
774 char *workend = &work[sizeof(work) - 1];
777 /* Supply a default precision if none was given. */
781 /* Put the number in WORK. */
784 *w-- = digits[num % base];
787 width -= (long)(workend - w);
788 prec -= (long)(workend - w);
790 if(is_alt && base == 8 && prec <= 0) {
801 if(is_alt && base == 16)
804 if(is_neg || (p->flags & FLAGS_SHOWSIGN) || (p->flags & FLAGS_SPACE))
807 if(!(p->flags & FLAGS_LEFT) && !(p->flags & FLAGS_PAD_NIL))
813 else if(p->flags & FLAGS_SHOWSIGN)
815 else if(p->flags & FLAGS_SPACE)
818 if(is_alt && base == 16) {
820 if(p->flags & FLAGS_UPPER)
826 if(!(p->flags & FLAGS_LEFT) && (p->flags & FLAGS_PAD_NIL))
830 /* Write the number. */
831 while(++w <= workend) {
835 if(p->flags & FLAGS_LEFT)
844 static const char null[] = "(nil)";
848 str = (char *) p->data.str;
850 /* Write null[] if there's space. */
851 if(prec == -1 || prec >= (long) sizeof(null) - 1) {
853 len = sizeof(null) - 1;
854 /* Disable quotes around (nil) */
855 p->flags &= (~FLAGS_ALT);
865 if(prec != -1 && (size_t) prec < len)
869 if(p->flags & FLAGS_ALT)
872 if(!(p->flags&FLAGS_LEFT))
878 if(p->flags&FLAGS_LEFT)
882 if(p->flags & FLAGS_ALT)
888 /* Generic pointer. */
891 ptr = (void *) p->data.ptr;
893 /* If the pointer is not NULL, write it as a %#x spec. */
895 digits = (p->flags & FLAGS_UPPER)? upper_digits : lower_digits;
902 /* Write "(nil)" for a nil pointer. */
903 static const char strnil[] = "(nil)";
906 width -= (long)(sizeof(strnil) - 1);
907 if(p->flags & FLAGS_LEFT)
910 for(point = strnil; *point != '\0'; ++point)
912 if(! (p->flags & FLAGS_LEFT))
921 char formatbuf[32]="%";
923 size_t left = sizeof(formatbuf)-strlen(formatbuf);
927 if(p->flags & FLAGS_WIDTH)
929 else if(p->flags & FLAGS_WIDTHPARAM)
930 width = (long)vto[p->width].data.num.as_signed;
933 if(p->flags & FLAGS_PREC)
935 else if(p->flags & FLAGS_PRECPARAM)
936 prec = (long)vto[p->precision].data.num.as_signed;
938 if(p->flags & FLAGS_LEFT)
939 strcat(formatbuf, "-");
940 if(p->flags & FLAGS_SHOWSIGN)
941 strcat(formatbuf, "+");
942 if(p->flags & FLAGS_SPACE)
943 strcat(formatbuf, " ");
944 if(p->flags & FLAGS_ALT)
945 strcat(formatbuf, "#");
947 fptr=&formatbuf[strlen(formatbuf)];
950 /* RECURSIVE USAGE */
951 len = curl_msnprintf(fptr, left, "%ld", width);
956 /* RECURSIVE USAGE */
957 len = curl_msnprintf(fptr, left, ".%ld", prec);
960 if(p->flags & FLAGS_LONG)
963 if(p->flags & FLAGS_FLOATE)
964 *fptr++ = (char)((p->flags & FLAGS_UPPER) ? 'E':'e');
965 else if(p->flags & FLAGS_FLOATG)
966 *fptr++ = (char)((p->flags & FLAGS_UPPER) ? 'G' : 'g');
970 *fptr = 0; /* and a final zero termination */
972 /* NOTE NOTE NOTE!! Not all sprintf() implementations returns number
973 of output characters */
974 (sprintf)(work, formatbuf, p->data.dnum);
976 for(fptr=work; *fptr; fptr++)
982 /* Answer the count of characters written. */
983 #ifdef HAVE_LONG_LONG_TYPE
984 if(p->flags & FLAGS_LONGLONG)
985 *(LONG_LONG_TYPE *) p->data.ptr = (LONG_LONG_TYPE)done;
988 if(p->flags & FLAGS_LONG)
989 *(long *) p->data.ptr = (long)done;
990 else if(!(p->flags & FLAGS_SHORT))
991 *(int *) p->data.ptr = (int)done;
993 *(short *) p->data.ptr = (short)done;
999 f = *end++; /* goto end of %-code */
1005 /* fputc() look-alike */
1006 static int addbyter(int output, FILE *data)
1008 struct nsprintf *infop=(struct nsprintf *)data;
1009 unsigned char outc = (unsigned char)output;
1011 if(infop->length < infop->max) {
1012 /* only do this if we haven't reached max length yet */
1013 infop->buffer[0] = outc; /* store */
1014 infop->buffer++; /* increase pointer */
1015 infop->length++; /* we are now one byte larger */
1016 return outc; /* fputc() returns like this on success */
1021 int curl_mvsnprintf(char *buffer, size_t maxlength, const char *format,
1025 struct nsprintf info;
1027 info.buffer = buffer;
1029 info.max = maxlength;
1031 retcode = dprintf_formatf(&info, addbyter, format, ap_save);
1033 /* we terminate this with a zero byte */
1034 if(info.max == info.length)
1035 /* we're at maximum, scrap the last letter */
1036 info.buffer[-1] = 0;
1043 int curl_msnprintf(char *buffer, size_t maxlength, const char *format, ...)
1046 va_list ap_save; /* argument pointer */
1047 va_start(ap_save, format);
1048 retcode = curl_mvsnprintf(buffer, maxlength, format, ap_save);
1053 /* fputc() look-alike */
1054 static int alloc_addbyter(int output, FILE *data)
1056 struct asprintf *infop=(struct asprintf *)data;
1057 unsigned char outc = (unsigned char)output;
1059 if(!infop->buffer) {
1060 infop->buffer = malloc(32);
1061 if(!infop->buffer) {
1063 return -1; /* fail */
1068 else if(infop->len+1 >= infop->alloc) {
1071 newptr = realloc(infop->buffer, infop->alloc*2);
1075 return -1; /* fail */
1077 infop->buffer = newptr;
1081 infop->buffer[ infop->len ] = outc;
1085 return outc; /* fputc() returns like this on success */
1088 char *curl_maprintf(const char *format, ...)
1090 va_list ap_save; /* argument pointer */
1092 struct asprintf info;
1099 va_start(ap_save, format);
1100 retcode = dprintf_formatf(&info, alloc_addbyter, format, ap_save);
1102 if((-1 == retcode) || info.fail) {
1108 info.buffer[info.len] = 0; /* we terminate this with a zero byte */
1115 char *curl_mvaprintf(const char *format, va_list ap_save)
1118 struct asprintf info;
1125 retcode = dprintf_formatf(&info, alloc_addbyter, format, ap_save);
1126 if((-1 == retcode) || info.fail) {
1133 info.buffer[info.len] = 0; /* we terminate this with a zero byte */
1140 static int storebuffer(int output, FILE *data)
1142 char **buffer = (char **)data;
1143 unsigned char outc = (unsigned char)output;
1146 return outc; /* act like fputc() ! */
1149 int curl_msprintf(char *buffer, const char *format, ...)
1151 va_list ap_save; /* argument pointer */
1153 va_start(ap_save, format);
1154 retcode = dprintf_formatf(&buffer, storebuffer, format, ap_save);
1156 *buffer=0; /* we terminate this with a zero byte */
1160 int curl_mprintf(const char *format, ...)
1163 va_list ap_save; /* argument pointer */
1164 va_start(ap_save, format);
1166 retcode = dprintf_formatf(stdout, fputc, format, ap_save);
1171 int curl_mfprintf(FILE *whereto, const char *format, ...)
1174 va_list ap_save; /* argument pointer */
1175 va_start(ap_save, format);
1176 retcode = dprintf_formatf(whereto, fputc, format, ap_save);
1181 int curl_mvsprintf(char *buffer, const char *format, va_list ap_save)
1184 retcode = dprintf_formatf(&buffer, storebuffer, format, ap_save);
1185 *buffer=0; /* we terminate this with a zero byte */
1189 int curl_mvprintf(const char *format, va_list ap_save)
1191 return dprintf_formatf(stdout, fputc, format, ap_save);
1194 int curl_mvfprintf(FILE *whereto, const char *format, va_list ap_save)
1196 return dprintf_formatf(whereto, fputc, format, ap_save);