xref: /freebsd/contrib/sendmail/test/t_snprintf.c (revision af23369a6deaaeb612ab266eb88b8bb8d560c322)
1 /*
2  * Copyright (c) 2001 Proofpoint, Inc. and its suppliers.
3  *	All rights reserved.
4  *
5  * By using this file, you agree to the terms and conditions set
6  * forth in the LICENSE file which can be found at the top level of
7  * the sendmail distribution.
8  *
9  */
10 
11 #include <stdio.h>
12 #include <sysexits.h>
13 
14 #ifndef lint
15 static char id[] = "@(#)$Id: t_snprintf.c,v 8.5 2013-11-22 20:52:01 ca Exp $";
16 #endif
17 
18 #define TEST_STRING	"1234567890"
19 
20 int
21 main(argc, argv)
22 	int argc;
23 	char **argv;
24 {
25 	int r;
26 	char buf[5];
27 
28 	r = snprintf(buf, sizeof buf, "%s", TEST_STRING);
29 
30 	if (buf[sizeof buf - 1] != '\0' ||
31 	    r != strlen(TEST_STRING))
32 	{
33 		fprintf(stderr, "Add the following to devtools/Site/site.config.m4:\n\n");
34 		fprintf(stderr, "APPENDDEF(`confENVDEF', `-DSNPRINTF_IS_BROKEN=1')\n\n");
35 		exit(EX_OSERR);
36 	}
37 	fprintf(stderr, "snprintf() appears to work properly\n");
38 	exit(EX_OK);
39 }
40