t_snprintf.c revision 266692
1295367Sdes/* 2263635Sdes * Copyright (c) 2001 Proofpoint, Inc. and its suppliers. 3263635Sdes * All rights reserved. 4263635Sdes * 5263635Sdes * By using this file, you agree to the terms and conditions set 6263635Sdes * forth in the LICENSE file which can be found at the top level of 7263635Sdes * the sendmail distribution. 8263635Sdes * 9263635Sdes */ 10263635Sdes 11263635Sdes#include <stdio.h> 12263635Sdes#include <sysexits.h> 13263635Sdes 14263635Sdes#ifndef lint 15263635Sdesstatic char id[] = "@(#)$Id: t_snprintf.c,v 8.5 2013-11-22 20:52:01 ca Exp $"; 16263635Sdes#endif /* ! lint */ 17263635Sdes 18263635Sdes#define TEST_STRING "1234567890" 19263635Sdes 20295367Sdesint 21295367Sdesmain(argc, argv) 22263635Sdes int argc; 23263635Sdes char **argv; 24263635Sdes{ 25263635Sdes int r; 26263635Sdes char buf[5]; 27263635Sdes 28263635Sdes r = snprintf(buf, sizeof buf, "%s", TEST_STRING); 29263635Sdes 30263635Sdes if (buf[sizeof buf - 1] != '\0' || 31295367Sdes r != strlen(TEST_STRING)) 32263635Sdes { 33295367Sdes fprintf(stderr, "Add the following to devtools/Site/site.config.m4:\n\n"); 34263635Sdes fprintf(stderr, "APPENDDEF(`confENVDEF', `-DSNPRINTF_IS_BROKEN=1')\n\n"); 35295367Sdes exit(EX_OSERR); 36295367Sdes } 37295367Sdes fprintf(stderr, "snprintf() appears to work properly\n"); 38295367Sdes exit(EX_OK); 39295367Sdes} 40295367Sdes