1 /*
   2  * Copyright (c) 2000-2001 Proofpoint, Inc. and its suppliers.
   3  *      All rights reserved.
   4  * Copyright (c) 1990, 1993
   5  *      The Regents of the University of California.  All rights reserved.
   6  *
   7  * This code is derived from software contributed to Berkeley by
   8  * Chris Torek.
   9  *
  10  * By using this file, you agree to the terms and conditions set
  11  * forth in the LICENSE file which can be found at the top level of
  12  * the sendmail distribution.
  13  */
  14 
  15 #include <sm/gen.h>
  16 SM_RCSID("@(#)$Id: fprintf.c,v 1.18 2013-11-22 20:51:42 ca Exp $")
  17 #include <sm/varargs.h>
  18 #include <sm/io.h>
  19 #include <sm/assert.h>
  20 #include "local.h"
  21 
  22 /*
  23 **  SM_IO_FPRINTF -- format and print a string to a file pointer
  24 **
  25 **      Parameters:
  26 **              fp -- file pointer to be printed to
  27 **              timeout -- time to complete print
  28 **              fmt -- markup format for the string to be printed
  29 **              ... -- additional information for 'fmt'
  30 **
  31 **      Returns:
  32 **              Failure: returns SM_IO_EOF and sets errno
  33 **              Success: returns the number of characters o/p
  34 */
  35 
  36 int
  37 #if SM_VA_STD
  38 sm_io_fprintf(SM_FILE_T *fp, int timeout, const char *fmt, ...)
  39 #else /* SM_VA_STD */
  40 sm_io_fprintf(fp, timeout, fmt, va_alist)
  41         SM_FILE_T *fp;
  42         int timeout;
  43         char *fmt;
  44         va_dcl
  45 #endif /* SM_VA_STD */
  46 {
  47         int ret;
  48         SM_VA_LOCAL_DECL
  49 
  50         SM_REQUIRE_ISA(fp, SmFileMagic);
  51         SM_VA_START(ap, fmt);
  52         ret = sm_io_vfprintf(fp, timeout, fmt, ap);
  53         SM_VA_END(ap);
  54         return ret;
  55 }