1 /***************************************************************************
3 * Project ___| | | | _ \| |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
8 * Copyright (C) 1999 - 2010, 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/
45 #if defined(DJGPP) && (DJGPP_MINOR < 4)
46 #undef _MPRINTF_REPLACE /* don't use x_was_used() here */
49 #include <curl/mprintf.h>
51 #include "curl_memory.h"
52 /* The last #include file should be: */
55 #ifndef SIZEOF_LONG_DOUBLE
56 #define SIZEOF_LONG_DOUBLE 0
60 * If SIZEOF_SIZE_T has not been defined, default to the size of long.
64 # define SIZEOF_SIZE_T CURL_SIZEOF_LONG
68 # define LONG_LONG_TYPE long long
69 # define HAVE_LONG_LONG_TYPE
71 # if defined(_MSC_VER) && (_MSC_VER >= 900) && (_INTEGRAL_MAX_BITS >= 64)
72 # define LONG_LONG_TYPE __int64
73 # define HAVE_LONG_LONG_TYPE
75 # undef LONG_LONG_TYPE
76 # undef HAVE_LONG_LONG_TYPE
81 * Max integer data types that mprintf.c is capable
84 #ifdef HAVE_LONG_LONG_TYPE
85 # define mp_intmax_t LONG_LONG_TYPE
86 # define mp_uintmax_t unsigned LONG_LONG_TYPE
88 # define mp_intmax_t long
89 # define mp_uintmax_t unsigned long
92 #define BUFFSIZE 256 /* buffer for long-to-str and float-to-str calcs */
93 #define MAX_PARAMETERS 128 /* lame static limit */
99 /* Lower-case digits. */
100 static const char lower_digits[] = "0123456789abcdefghijklmnopqrstuvwxyz";
102 /* Upper-case digits. */
103 static const char upper_digits[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
107 if(stream((unsigned char)(x), (FILE *)data) != -1) \
110 return done; /* return immediately on failure */ \
113 /* Data type to read from the arglist */
124 FORMAT_WIDTH /* For internal use */
127 /* convertion and display flags */
131 FLAGS_SHOWSIGN = 1<<1,
136 FLAGS_LONGLONG = 1<<6,
137 FLAGS_LONGDOUBLE = 1<<7,
138 FLAGS_PAD_NIL = 1<<8,
139 FLAGS_UNSIGNED = 1<<9,
143 FLAGS_WIDTH = 1<<13, /* '*' or '*<num>$' used */
144 FLAGS_WIDTHPARAM = 1<<14, /* width PARAMETER was specified */
145 FLAGS_PREC = 1<<15, /* precision was specified */
146 FLAGS_PRECPARAM = 1<<16, /* precision PARAMETER was specified */
147 FLAGS_CHAR = 1<<17, /* %c story */
148 FLAGS_FLOATE = 1<<18, /* %e or %E */
149 FLAGS_FLOATG = 1<<19 /* %g or %G */
155 long width; /* width OR width parameter number */
156 long precision; /* precision OR precision parameter number */
161 mp_intmax_t as_signed;
162 mp_uintmax_t as_unsigned;
175 char *buffer; /* allocated buffer */
176 size_t len; /* length of string */
177 size_t alloc; /* length of alloc */
178 int fail; /* (!= 0) if an alloc has failed and thus
179 the output is not the complete data */
182 static long dprintf_DollarString(char *input, char **end)
185 while(ISDIGIT(*input)) {
187 number += *input-'0';
190 if(number && ('$'==*input++)) {
197 static int dprintf_IsQualifierNoDollar(char c)
200 case '-': case '+': case ' ': case '#': case '.':
201 case '0': case '1': case '2': case '3': case '4':
202 case '5': case '6': case '7': case '8': case '9':
203 case 'h': case 'l': case 'L': case 'z': case 'q':
207 return 0; /* false */
211 #ifdef DPRINTF_DEBUG2
212 static void dprintf_Pass1Report(va_stack_t *vto, int max)
219 for(i=0; i<max; i++) {
221 switch(vto[i].type) {
240 case FORMAT_LONGLONG:
246 case FORMAT_LONGDOUBLE:
247 type = "long double";
254 for(bit=0; bit<31; bit++) {
255 flags = vto[i].flags & (1<<bit);
257 if(flags & FLAGS_SPACE)
258 strcat(buffer, "space ");
259 else if(flags & FLAGS_SHOWSIGN)
260 strcat(buffer, "plus ");
261 else if(flags & FLAGS_LEFT)
262 strcat(buffer, "left ");
263 else if(flags & FLAGS_ALT)
264 strcat(buffer, "alt ");
265 else if(flags & FLAGS_SHORT)
266 strcat(buffer, "short ");
267 else if(flags & FLAGS_LONG)
268 strcat(buffer, "long ");
269 else if(flags & FLAGS_LONGLONG)
270 strcat(buffer, "longlong ");
271 else if(flags & FLAGS_LONGDOUBLE)
272 strcat(buffer, "longdouble ");
273 else if(flags & FLAGS_PAD_NIL)
274 strcat(buffer, "padnil ");
275 else if(flags & FLAGS_UNSIGNED)
276 strcat(buffer, "unsigned ");
277 else if(flags & FLAGS_OCTAL)
278 strcat(buffer, "octal ");
279 else if(flags & FLAGS_HEX)
280 strcat(buffer, "hex ");
281 else if(flags & FLAGS_UPPER)
282 strcat(buffer, "upper ");
283 else if(flags & FLAGS_WIDTH)
284 strcat(buffer, "width ");
285 else if(flags & FLAGS_WIDTHPARAM)
286 strcat(buffer, "widthparam ");
287 else if(flags & FLAGS_PREC)
288 strcat(buffer, "precision ");
289 else if(flags & FLAGS_PRECPARAM)
290 strcat(buffer, "precparam ");
291 else if(flags & FLAGS_CHAR)
292 strcat(buffer, "char ");
293 else if(flags & FLAGS_FLOATE)
294 strcat(buffer, "floate ");
295 else if(flags & FLAGS_FLOATG)
296 strcat(buffer, "floatg ");
298 printf("REPORT: %d. %s [%s]\n", i, type, buffer);
306 /******************************************************************
309 * Create an index with the type of each parameter entry and its
310 * value (may vary in size)
312 ******************************************************************/
314 static long dprintf_Pass1(const char *format, va_stack_t *vto, char **endpos,
317 char *fmt = (char *)format;
330 continue; /* while */
335 /* Handle the positional case (N$) */
339 this_param = dprintf_DollarString(fmt, &fmt);
341 /* we got no positional, get the next counter */
342 this_param = param_num;
344 if(this_param > max_param)
345 max_param = this_param;
348 * The parameter with number 'i' should be used. Next, we need
349 * to get SIZE and TYPE of the parameter. Add the information
356 /* Handle the flags */
358 while(dprintf_IsQualifierNoDollar(*fmt)) {
361 flags |= FLAGS_SPACE;
364 flags |= FLAGS_SHOWSIGN;
368 flags &= ~FLAGS_PAD_NIL;
376 /* The precision is picked from a specified parameter */
378 flags |= FLAGS_PRECPARAM;
382 i = dprintf_DollarString(fmt, &fmt);
386 precision = param_num;
388 if(precision > max_param)
389 max_param = precision;
393 precision = strtol(fmt, &fmt, 10);
397 flags |= FLAGS_SHORT;
400 if(flags & FLAGS_LONG)
401 flags |= FLAGS_LONGLONG;
406 flags |= FLAGS_LONGDOUBLE;
409 flags |= FLAGS_LONGLONG;
412 /* the code below generates a warning if -Wunreachable-code is
414 #if (SIZEOF_SIZE_T > CURL_SIZEOF_LONG)
415 flags |= FLAGS_LONGLONG;
421 #if (CURL_SIZEOF_CURL_OFF_T > CURL_SIZEOF_LONG)
422 flags |= FLAGS_LONGLONG;
428 if(!(flags & FLAGS_LEFT))
429 flags |= FLAGS_PAD_NIL;
431 case '1': case '2': case '3': case '4':
432 case '5': case '6': case '7': case '8': case '9':
433 flags |= FLAGS_WIDTH;
434 width = strtol(fmt-1, &fmt, 10);
436 case '*': /* Special case */
437 flags |= FLAGS_WIDTHPARAM;
440 i = dprintf_DollarString(fmt, &fmt);
445 if(width > max_param)
453 /* Handle the specifier */
462 vto[i].type = FORMAT_STRING;
465 vto[i].type = FORMAT_INTPTR;
468 vto[i].type = FORMAT_PTR;
471 vto[i].type = FORMAT_INT;
474 vto[i].type = FORMAT_INT;
475 flags |= FLAGS_UNSIGNED;
478 vto[i].type = FORMAT_INT;
479 flags |= FLAGS_OCTAL;
482 vto[i].type = FORMAT_INT;
486 vto[i].type = FORMAT_INT;
487 flags |= FLAGS_HEX|FLAGS_UPPER;
490 vto[i].type = FORMAT_INT;
494 vto[i].type = FORMAT_DOUBLE;
497 vto[i].type = FORMAT_DOUBLE;
498 flags |= FLAGS_FLOATE;
501 vto[i].type = FORMAT_DOUBLE;
502 flags |= FLAGS_FLOATE|FLAGS_UPPER;
505 vto[i].type = FORMAT_DOUBLE;
506 flags |= FLAGS_FLOATG;
509 vto[i].type = FORMAT_DOUBLE;
510 flags |= FLAGS_FLOATG|FLAGS_UPPER;
513 vto[i].type = FORMAT_UNKNOWN;
517 vto[i].flags = flags;
518 vto[i].width = width;
519 vto[i].precision = precision;
521 if(flags & FLAGS_WIDTHPARAM) {
522 /* we have the width specified from a parameter, so we make that
523 parameter's info setup properly */
524 vto[i].width = width - 1;
526 vto[i].type = FORMAT_WIDTH;
527 vto[i].flags = FLAGS_NEW;
528 vto[i].precision = vto[i].width = 0; /* can't use width or precision
531 if(flags & FLAGS_PRECPARAM) {
532 /* we have the precision specified from a parameter, so we make that
533 parameter's info setup properly */
534 vto[i].precision = precision - 1;
536 vto[i].type = FORMAT_WIDTH;
537 vto[i].flags = FLAGS_NEW;
538 vto[i].precision = vto[i].width = 0; /* can't use width or precision
541 *endpos++ = fmt + 1; /* end of this sequence */
545 #ifdef DPRINTF_DEBUG2
546 dprintf_Pass1Report(vto, max_param);
549 /* Read the arg list parameters into our data list */
550 for (i=0; i<max_param; i++) {
551 if((i + 1 < max_param) && (vto[i + 1].type == FORMAT_WIDTH))
553 /* Width/precision arguments must be read before the main argument
554 * they are attached to
556 vto[i + 1].data.num.as_signed = (mp_intmax_t)va_arg(arglist, int);
562 vto[i].data.str = va_arg(arglist, char *);
568 vto[i].data.ptr = va_arg(arglist, void *);
572 #ifdef HAVE_LONG_LONG_TYPE
573 if((vto[i].flags & FLAGS_LONGLONG) && (vto[i].flags & FLAGS_UNSIGNED))
574 vto[i].data.num.as_unsigned =
575 (mp_uintmax_t)va_arg(arglist, mp_uintmax_t);
576 else if(vto[i].flags & FLAGS_LONGLONG)
577 vto[i].data.num.as_signed =
578 (mp_intmax_t)va_arg(arglist, mp_intmax_t);
582 if((vto[i].flags & FLAGS_LONG) && (vto[i].flags & FLAGS_UNSIGNED))
583 vto[i].data.num.as_unsigned =
584 (mp_uintmax_t)va_arg(arglist, unsigned long);
585 else if(vto[i].flags & FLAGS_LONG)
586 vto[i].data.num.as_signed =
587 (mp_intmax_t)va_arg(arglist, long);
588 else if(vto[i].flags & FLAGS_UNSIGNED)
589 vto[i].data.num.as_unsigned =
590 (mp_uintmax_t)va_arg(arglist, unsigned int);
592 vto[i].data.num.as_signed =
593 (mp_intmax_t)va_arg(arglist, int);
598 vto[i].data.dnum = va_arg(arglist, double);
602 /* Argument has been read. Silently convert it into an integer
605 vto[i].type = FORMAT_INT;
617 static int dprintf_formatf(
618 void *data, /* untouched by format(), just sent to the stream() function in
619 the second argument */
620 /* function pointer called for each output character */
621 int (*stream)(int, FILE *),
622 const char *format, /* %-formatted string */
623 va_list ap_save) /* list of parameters */
625 /* Base-36 digits for numbers. */
626 const char *digits = lower_digits;
628 /* Pointer into the format string. */
631 /* Number of characters written. */
634 long param; /* current parameter to read */
635 long param_num=0; /* parameter counter */
637 va_stack_t vto[MAX_PARAMETERS];
638 char *endpos[MAX_PARAMETERS];
645 /* Do the actual %-code parsing */
646 dprintf_Pass1(format, vto, endpos, ap_save);
648 end = &endpos[0]; /* the initial end-position from the list dprintf_Pass1()
653 /* Format spec modifiers. */
656 /* Width of a field. */
659 /* Precision of a field. */
662 /* Decimal integer is negative. */
665 /* Base of a number to be written. */
668 /* Integral values to be written. */
671 /* Used to convert negative in positive. */
672 mp_intmax_t signed_num;
675 /* This isn't a format spec, so write everything out until the next one
676 OR end of string is reached. */
679 } while(*++f && ('%' != *f));
685 /* Check for "%%". Note that although the ANSI standard lists
686 '%' as a conversion specifier, it says "The complete format
687 specification shall be `%%'," so we can avoid all the width
688 and precision processing. */
695 /* If this is a positional parameter, the position must follow imediately
696 after the %, thus create a %<num>$ sequence */
697 param=dprintf_DollarString(f, &f);
704 param_num++; /* increase this always to allow "%2$s %1$s %s" and then the
705 third %s will pick the 3rd argument */
709 /* pick up the specified width */
710 if(p->flags & FLAGS_WIDTHPARAM)
711 width = (long)vto[p->width].data.num.as_signed;
715 /* pick up the specified precision */
716 if(p->flags & FLAGS_PRECPARAM) {
717 prec = (long)vto[p->precision].data.num.as_signed;
718 param_num++; /* since the precision is extraced from a parameter, we
719 must skip that to get to the next one properly */
721 else if(p->flags & FLAGS_PREC)
726 is_alt = (p->flags & FLAGS_ALT) ? 1 : 0;
730 num = p->data.num.as_unsigned;
731 if(p->flags & FLAGS_CHAR) {
733 if(!(p->flags & FLAGS_LEFT))
737 if(p->flags & FLAGS_LEFT)
742 if(p->flags & FLAGS_UNSIGNED) {
743 /* Decimal unsigned integer. */
745 goto unsigned_number;
747 if(p->flags & FLAGS_OCTAL) {
748 /* Octal unsigned integer. */
750 goto unsigned_number;
752 if(p->flags & FLAGS_HEX) {
753 /* Hexadecimal unsigned integer. */
755 digits = (p->flags & FLAGS_UPPER)? upper_digits : lower_digits;
757 goto unsigned_number;
760 /* Decimal integer. */
763 is_neg = (p->data.num.as_signed < (mp_intmax_t)0) ? 1 : 0;
765 /* signed_num might fail to hold absolute negative minimum by 1 */
766 signed_num = p->data.num.as_signed + (mp_intmax_t)1;
767 signed_num = -signed_num;
768 num = (mp_uintmax_t)signed_num;
769 num += (mp_uintmax_t)1;
775 /* Unsigned number of base BASE. */
779 /* Number of base BASE. */
781 char *workend = &work[sizeof(work) - 1];
784 /* Supply a default precision if none was given. */
788 /* Put the number in WORK. */
791 *w-- = digits[num % base];
794 width -= (long)(workend - w);
795 prec -= (long)(workend - w);
797 if(is_alt && base == 8 && prec <= 0) {
808 if(is_alt && base == 16)
811 if(is_neg || (p->flags & FLAGS_SHOWSIGN) || (p->flags & FLAGS_SPACE))
814 if(!(p->flags & FLAGS_LEFT) && !(p->flags & FLAGS_PAD_NIL))
820 else if(p->flags & FLAGS_SHOWSIGN)
822 else if(p->flags & FLAGS_SPACE)
825 if(is_alt && base == 16) {
827 if(p->flags & FLAGS_UPPER)
833 if(!(p->flags & FLAGS_LEFT) && (p->flags & FLAGS_PAD_NIL))
837 /* Write the number. */
838 while(++w <= workend) {
842 if(p->flags & FLAGS_LEFT)
851 static const char null[] = "(nil)";
855 str = (char *) p->data.str;
857 /* Write null[] if there's space. */
858 if(prec == -1 || prec >= (long) sizeof(null) - 1) {
860 len = sizeof(null) - 1;
861 /* Disable quotes around (nil) */
862 p->flags &= (~FLAGS_ALT);
872 if(prec != -1 && (size_t) prec < len)
876 if(p->flags & FLAGS_ALT)
879 if(!(p->flags&FLAGS_LEFT))
885 if(p->flags&FLAGS_LEFT)
889 if(p->flags & FLAGS_ALT)
895 /* Generic pointer. */
898 ptr = (void *) p->data.ptr;
900 /* If the pointer is not NULL, write it as a %#x spec. */
902 digits = (p->flags & FLAGS_UPPER)? upper_digits : lower_digits;
909 /* Write "(nil)" for a nil pointer. */
910 static const char strnil[] = "(nil)";
913 width -= (long)(sizeof(strnil) - 1);
914 if(p->flags & FLAGS_LEFT)
917 for (point = strnil; *point != '\0'; ++point)
919 if(! (p->flags & FLAGS_LEFT))
928 char formatbuf[32]="%";
930 size_t left = sizeof(formatbuf)-strlen(formatbuf);
934 if(p->flags & FLAGS_WIDTH)
936 else if(p->flags & FLAGS_WIDTHPARAM)
937 width = (long)vto[p->width].data.num.as_signed;
940 if(p->flags & FLAGS_PREC)
942 else if(p->flags & FLAGS_PRECPARAM)
943 prec = (long)vto[p->precision].data.num.as_signed;
945 if(p->flags & FLAGS_LEFT)
946 strcat(formatbuf, "-");
947 if(p->flags & FLAGS_SHOWSIGN)
948 strcat(formatbuf, "+");
949 if(p->flags & FLAGS_SPACE)
950 strcat(formatbuf, " ");
951 if(p->flags & FLAGS_ALT)
952 strcat(formatbuf, "#");
954 fptr=&formatbuf[strlen(formatbuf)];
957 /* RECURSIVE USAGE */
958 len = curl_msnprintf(fptr, left, "%ld", width);
963 /* RECURSIVE USAGE */
964 len = curl_msnprintf(fptr, left, ".%ld", prec);
967 if(p->flags & FLAGS_LONG)
970 if(p->flags & FLAGS_FLOATE)
971 *fptr++ = (char)((p->flags & FLAGS_UPPER) ? 'E':'e');
972 else if(p->flags & FLAGS_FLOATG)
973 *fptr++ = (char)((p->flags & FLAGS_UPPER) ? 'G' : 'g');
977 *fptr = 0; /* and a final zero termination */
979 /* NOTE NOTE NOTE!! Not all sprintf() implementations returns number
980 of output characters */
981 (sprintf)(work, formatbuf, p->data.dnum);
983 for(fptr=work; *fptr; fptr++)
989 /* Answer the count of characters written. */
990 #ifdef HAVE_LONG_LONG_TYPE
991 if(p->flags & FLAGS_LONGLONG)
992 *(LONG_LONG_TYPE *) p->data.ptr = (LONG_LONG_TYPE)done;
995 if(p->flags & FLAGS_LONG)
996 *(long *) p->data.ptr = (long)done;
997 else if(!(p->flags & FLAGS_SHORT))
998 *(int *) p->data.ptr = (int)done;
1000 *(short *) p->data.ptr = (short)done;
1006 f = *end++; /* goto end of %-code */
1012 /* fputc() look-alike */
1013 static int addbyter(int output, FILE *data)
1015 struct nsprintf *infop=(struct nsprintf *)data;
1016 unsigned char outc = (unsigned char)output;
1018 if(infop->length < infop->max) {
1019 /* only do this if we haven't reached max length yet */
1020 infop->buffer[0] = outc; /* store */
1021 infop->buffer++; /* increase pointer */
1022 infop->length++; /* we are now one byte larger */
1023 return outc; /* fputc() returns like this on success */
1028 int curl_mvsnprintf(char *buffer, size_t maxlength, const char *format,
1032 struct nsprintf info;
1034 info.buffer = buffer;
1036 info.max = maxlength;
1038 retcode = dprintf_formatf(&info, addbyter, format, ap_save);
1040 /* we terminate this with a zero byte */
1041 if(info.max == info.length)
1042 /* we're at maximum, scrap the last letter */
1043 info.buffer[-1] = 0;
1050 int curl_msnprintf(char *buffer, size_t maxlength, const char *format, ...)
1053 va_list ap_save; /* argument pointer */
1054 va_start(ap_save, format);
1055 retcode = curl_mvsnprintf(buffer, maxlength, format, ap_save);
1060 /* fputc() look-alike */
1061 static int alloc_addbyter(int output, FILE *data)
1063 struct asprintf *infop=(struct asprintf *)data;
1064 unsigned char outc = (unsigned char)output;
1066 if(!infop->buffer) {
1067 infop->buffer = malloc(32);
1068 if(!infop->buffer) {
1070 return -1; /* fail */
1075 else if(infop->len+1 >= infop->alloc) {
1078 newptr = realloc(infop->buffer, infop->alloc*2);
1082 return -1; /* fail */
1084 infop->buffer = newptr;
1088 infop->buffer[ infop->len ] = outc;
1092 return outc; /* fputc() returns like this on success */
1095 char *curl_maprintf(const char *format, ...)
1097 va_list ap_save; /* argument pointer */
1099 struct asprintf info;
1106 va_start(ap_save, format);
1107 retcode = dprintf_formatf(&info, alloc_addbyter, format, ap_save);
1109 if((-1 == retcode) || info.fail) {
1115 info.buffer[info.len] = 0; /* we terminate this with a zero byte */
1122 char *curl_mvaprintf(const char *format, va_list ap_save)
1125 struct asprintf info;
1132 retcode = dprintf_formatf(&info, alloc_addbyter, format, ap_save);
1133 if((-1 == retcode) || info.fail) {
1140 info.buffer[info.len] = 0; /* we terminate this with a zero byte */
1147 static int storebuffer(int output, FILE *data)
1149 char **buffer = (char **)data;
1150 unsigned char outc = (unsigned char)output;
1153 return outc; /* act like fputc() ! */
1156 int curl_msprintf(char *buffer, const char *format, ...)
1158 va_list ap_save; /* argument pointer */
1160 va_start(ap_save, format);
1161 retcode = dprintf_formatf(&buffer, storebuffer, format, ap_save);
1163 *buffer=0; /* we terminate this with a zero byte */
1167 int curl_mprintf(const char *format, ...)
1170 va_list ap_save; /* argument pointer */
1171 va_start(ap_save, format);
1173 retcode = dprintf_formatf(stdout, fputc, format, ap_save);
1178 int curl_mfprintf(FILE *whereto, const char *format, ...)
1181 va_list ap_save; /* argument pointer */
1182 va_start(ap_save, format);
1183 retcode = dprintf_formatf(whereto, fputc, format, ap_save);
1188 int curl_mvsprintf(char *buffer, const char *format, va_list ap_save)
1191 retcode = dprintf_formatf(&buffer, storebuffer, format, ap_save);
1192 *buffer=0; /* we terminate this with a zero byte */
1196 int curl_mvprintf(const char *format, va_list ap_save)
1198 return dprintf_formatf(stdout, fputc, format, ap_save);
1201 int curl_mvfprintf(FILE *whereto, const char *format, va_list ap_save)
1203 return dprintf_formatf(whereto, fputc, format, ap_save);
1206 #ifdef DPRINTF_DEBUG
1211 #ifdef HAVE_LONG_LONG_TYPE
1212 LONG_LONG_TYPE one=99;
1213 LONG_LONG_TYPE two=100;
1214 LONG_LONG_TYPE test = 0x1000000000LL;
1215 curl_mprintf("%lld %lld %lld\n", one, two, test);
1218 curl_mprintf("%3d %5d\n", 10, 1998);
1220 ptr=curl_maprintf("test this then baby %s%s%s%s%s%s %d %d %d loser baby get a kiss in yer face now!", "", "pretty long string pretty long string pretty long string pretty long string pretty long string", "/", "/", "/", "pretty long string", 1998, 1999, 2001);
1224 memset(ptr, 55, strlen(ptr)+1);
1229 curl_mprintf(buffer, "%s %s %d", "daniel", "stenberg", 19988);
1232 curl_mfprintf(stderr, "%s %#08x\n", "dummy", 65);
1234 printf("%s %#08x\n", "dummy", 65);
1236 double tryout = 3.14156592;
1237 curl_mprintf(buffer, "%.2g %G %f %e %E", tryout, tryout, tryout, tryout, tryout);
1239 printf("%.2g %G %f %e %E\n", tryout, tryout, tryout, tryout, tryout);