/[svn]/ircd-hybrid/contrib/libc_vprintf.c
ViewVC logotype

Contents of /ircd-hybrid/contrib/libc_vprintf.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 30 - (show annotations)
Sun Oct 2 20:03:27 2005 UTC (13 years, 10 months ago) by adx
File MIME type: text/x-chdr
File size: 836 byte(s)
- imported sources
- can be moved later according to the directory/branching scheme,
  but we need the svn up

1 /* $Id: libc_vprintf.c,v 1.1 2005/07/02 01:44:07 db Exp $ */
2 #include <stdio.h>
3 #include <stdarg.h>
4 #include <stdlib.h>
5
6 #define BUFLEN 1024
7
8 static void checkbug(const char *fmt, ...);
9
10 int main(int argc, char *argv[])
11 {
12 checkbug("Constant Format String");
13 checkbug("1=%d, foo=%s", 1, "foo");
14
15 exit(0); /*NOTREACHED*/
16 }
17
18 static void checkbug(const char *fmt, ...)
19 {
20 char buf_a[BUFLEN];
21 char buf_b[BUFLEN];
22 char buf_c[BUFLEN];
23 int n;
24 va_list ap, ap2;
25
26 printf("checkbug(%s)\n", fmt);
27
28 va_start(ap, fmt);
29 va_copy(ap2, ap);
30
31 n = vsnprintf(buf_a, BUFLEN, fmt, ap);
32 printf(" buf_a (len=%4d): %s\n", n, buf_a);
33 vsnprintf(buf_b, BUFLEN, fmt, ap);
34 printf(" buf_b (len=%4d): %s\n", n, buf_b);
35 vsnprintf(buf_c, BUFLEN, fmt, ap2);
36 printf(" buf_c (len=%4d): %s\n", n, buf_c);
37
38 va_end(ap);
39 va_end(ap2);
40 }
41

Properties

Name Value
svn:eol-style native
svn:keywords "Id Revision"

svnadmin@ircd-hybrid.org
ViewVC Help
Powered by ViewVC 1.1.26