xref: /freebsd/contrib/sendmail/test/t_snprintf.c (revision 2fb4f839f3fc72ce2bab12f9ba4760f97f73e97f)
140266059SGregory Neil Shapiro /*
25dd76dd0SGregory Neil Shapiro  * Copyright (c) 2001 Proofpoint, Inc. and its suppliers.
340266059SGregory Neil Shapiro  *	All rights reserved.
440266059SGregory Neil Shapiro  *
540266059SGregory Neil Shapiro  * By using this file, you agree to the terms and conditions set
640266059SGregory Neil Shapiro  * forth in the LICENSE file which can be found at the top level of
740266059SGregory Neil Shapiro  * the sendmail distribution.
840266059SGregory Neil Shapiro  *
940266059SGregory Neil Shapiro  */
1040266059SGregory Neil Shapiro 
1106f25ae9SGregory Neil Shapiro #include <stdio.h>
1206f25ae9SGregory Neil Shapiro #include <sysexits.h>
1306f25ae9SGregory Neil Shapiro 
1440266059SGregory Neil Shapiro #ifndef lint
154313cc83SGregory Neil Shapiro static char id[] = "@(#)$Id: t_snprintf.c,v 8.5 2013-11-22 20:52:01 ca Exp $";
16*2fb4f839SGregory Neil Shapiro #endif
1740266059SGregory Neil Shapiro 
1806f25ae9SGregory Neil Shapiro #define TEST_STRING	"1234567890"
1906f25ae9SGregory Neil Shapiro 
2006f25ae9SGregory Neil Shapiro int
main(argc,argv)2106f25ae9SGregory Neil Shapiro main(argc, argv)
2206f25ae9SGregory Neil Shapiro 	int argc;
2306f25ae9SGregory Neil Shapiro 	char **argv;
2406f25ae9SGregory Neil Shapiro {
2506f25ae9SGregory Neil Shapiro 	int r;
2606f25ae9SGregory Neil Shapiro 	char buf[5];
2706f25ae9SGregory Neil Shapiro 
2806f25ae9SGregory Neil Shapiro 	r = snprintf(buf, sizeof buf, "%s", TEST_STRING);
2906f25ae9SGregory Neil Shapiro 
3013058a91SGregory Neil Shapiro 	if (buf[sizeof buf - 1] != '\0' ||
3113058a91SGregory Neil Shapiro 	    r != strlen(TEST_STRING))
3206f25ae9SGregory Neil Shapiro 	{
3306f25ae9SGregory Neil Shapiro 		fprintf(stderr, "Add the following to devtools/Site/site.config.m4:\n\n");
3406f25ae9SGregory Neil Shapiro 		fprintf(stderr, "APPENDDEF(`confENVDEF', `-DSNPRINTF_IS_BROKEN=1')\n\n");
3506f25ae9SGregory Neil Shapiro 		exit(EX_OSERR);
3606f25ae9SGregory Neil Shapiro 	}
3706f25ae9SGregory Neil Shapiro 	fprintf(stderr, "snprintf() appears to work properly\n");
3806f25ae9SGregory Neil Shapiro 	exit(EX_OK);
3906f25ae9SGregory Neil Shapiro }
40