2 * Copyright (c) 2000-2001 Proofpoint, Inc. and its suppliers.
4 * Copyright (c) 1990, 1993
5 * The Regents of the University of California. All rights reserved.
7 * This code is derived from software contributed to Berkeley by
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.
16 SM_RCSID("@(#)$Id: fwrite.c,v 1.25 2013-11-22 20:51:43 ca Exp $")
19 #include <sm/assert.h>
24 ** SM_IO_WRITE -- write to a file pointer
27 ** fp -- file pointer writing to
28 ** timeout -- time to complete the write
29 ** buf -- location of data to be written
30 ** size -- number of bytes to be written
33 ** Failure: returns 0 _and_ sets errno
34 ** Success: returns >=0 with errno unchanged, where the
35 ** number returned is the number of bytes written.
39 sm_io_write(fp, timeout, buf, size)
48 SM_REQUIRE_ISA(fp, SmFileMagic);
50 if (fp->f_write == NULL)
56 iov.iov_base = (void *) buf;
57 uio.uio_resid = iov.iov_len = size;
61 /* The usual case is success (sm_fvwrite returns 0) */
62 if (sm_fvwrite(fp, timeout, &uio) == 0)
65 /* else return number of bytes actually written */
66 return size - uio.uio_resid;