aboutsummaryrefslogtreecommitdiff
blob: 443c2c219cc737fdb5e34f8cbd52a9fa89a1247b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include "headers.h"
#include "sbutil.h"

#define _T(func, fmt, args...) func("%i:[%s] " fmt "\n", __LINE__, fmt, ##args)
#define T(fmt, args...) \
	do { \
		_T(printf, fmt, ## args); \
		_T(sb_printf, fmt, ## args); \
	} while (0)

int main(int argc, char *argv[])
{
	/* sandbox outputs to stderr, so unify it */
	dup2(STDOUT_FILENO, STDERR_FILENO);
	setbuf(stdout, NULL);

	T("%i", argc);
	T("%i", -argc);
	T("%d", 123);
	T("%d", -123);
	T("%u", 1000);
	T("%zi", (ssize_t)argc);
	T("%zi", (ssize_t)-argc);
	T("%zd", (ssize_t)123);
	T("%zd", (ssize_t)-123);
	T("%zu", (size_t)1000);

	T("%x", argc);
	T("%x", 0xabcdef);
	T("%X", argc);
	T("%X", 0xabcdef);

	T("%c", 'a');
	T("%c", '0');
	T("%c", 'K');
	T("%s", "wOOf");
	T("%s", "CoW");
	T("%s", "!HI!");

	int i;
	for (i = 0; i < 6; ++i)
		T("%s%*s%s", "{pre}", i, "cow", "{post}");

	T("%%");

	void *moo = (void *)0x123456;
	T("%p", moo);

	return 0;
}