xref: /freebsd/contrib/sendmail/libsm/fprintf.c (revision ee7b0571c2c18bdec848ed2044223cc88db29bd8)
140266059SGregory Neil Shapiro /*
25dd76dd0SGregory Neil Shapiro  * Copyright (c) 2000-2001 Proofpoint, Inc. and its suppliers.
340266059SGregory Neil Shapiro  *      All rights reserved.
440266059SGregory Neil Shapiro  * Copyright (c) 1990, 1993
540266059SGregory Neil Shapiro  *	The Regents of the University of California.  All rights reserved.
640266059SGregory Neil Shapiro  *
740266059SGregory Neil Shapiro  * This code is derived from software contributed to Berkeley by
840266059SGregory Neil Shapiro  * Chris Torek.
940266059SGregory Neil Shapiro  *
1040266059SGregory Neil Shapiro  * By using this file, you agree to the terms and conditions set
1140266059SGregory Neil Shapiro  * forth in the LICENSE file which can be found at the top level of
1240266059SGregory Neil Shapiro  * the sendmail distribution.
1340266059SGregory Neil Shapiro  */
1440266059SGregory Neil Shapiro 
1540266059SGregory Neil Shapiro #include <sm/gen.h>
16*4313cc83SGregory Neil Shapiro SM_RCSID("@(#)$Id: fprintf.c,v 1.18 2013-11-22 20:51:42 ca Exp $")
1740266059SGregory Neil Shapiro #include <sm/varargs.h>
1840266059SGregory Neil Shapiro #include <sm/io.h>
1940266059SGregory Neil Shapiro #include <sm/assert.h>
2040266059SGregory Neil Shapiro #include "local.h"
2140266059SGregory Neil Shapiro 
2240266059SGregory Neil Shapiro /*
2340266059SGregory Neil Shapiro **  SM_IO_FPRINTF -- format and print a string to a file pointer
2440266059SGregory Neil Shapiro **
2540266059SGregory Neil Shapiro **	Parameters:
2640266059SGregory Neil Shapiro **		fp -- file pointer to be printed to
2740266059SGregory Neil Shapiro **		timeout -- time to complete print
2840266059SGregory Neil Shapiro **		fmt -- markup format for the string to be printed
2940266059SGregory Neil Shapiro **		... -- additional information for 'fmt'
3040266059SGregory Neil Shapiro **
3140266059SGregory Neil Shapiro **	Returns:
3240266059SGregory Neil Shapiro **		Failure: returns SM_IO_EOF and sets errno
3340266059SGregory Neil Shapiro **		Success: returns the number of characters o/p
3440266059SGregory Neil Shapiro */
3540266059SGregory Neil Shapiro 
3640266059SGregory Neil Shapiro int
3740266059SGregory Neil Shapiro #if SM_VA_STD
sm_io_fprintf(SM_FILE_T * fp,int timeout,const char * fmt,...)3840266059SGregory Neil Shapiro sm_io_fprintf(SM_FILE_T *fp, int timeout, const char *fmt, ...)
3940266059SGregory Neil Shapiro #else /* SM_VA_STD */
4040266059SGregory Neil Shapiro sm_io_fprintf(fp, timeout, fmt, va_alist)
4140266059SGregory Neil Shapiro 	SM_FILE_T *fp;
4240266059SGregory Neil Shapiro 	int timeout;
4340266059SGregory Neil Shapiro 	char *fmt;
4440266059SGregory Neil Shapiro 	va_dcl
4540266059SGregory Neil Shapiro #endif /* SM_VA_STD */
4640266059SGregory Neil Shapiro {
4740266059SGregory Neil Shapiro 	int ret;
4840266059SGregory Neil Shapiro 	SM_VA_LOCAL_DECL
4940266059SGregory Neil Shapiro 
5040266059SGregory Neil Shapiro 	SM_REQUIRE_ISA(fp, SmFileMagic);
5140266059SGregory Neil Shapiro 	SM_VA_START(ap, fmt);
5240266059SGregory Neil Shapiro 	ret = sm_io_vfprintf(fp, timeout, fmt, ap);
5340266059SGregory Neil Shapiro 	SM_VA_END(ap);
5440266059SGregory Neil Shapiro 	return ret;
5540266059SGregory Neil Shapiro }
56