xref: /freebsd/contrib/sendmail/libsm/fput.c (revision 401ab69cff8fa2320a9f8ea4baa114a6da6c952b)
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: fput.c,v 1.21 2013-11-22 20:51:42 ca Exp $")
17 #include <string.h>
18 #include <errno.h>
19 #include <sm/io.h>
20 #include <sm/assert.h>
21 #include "local.h"
22 #include "fvwrite.h"
23 
24 /*
25 **  SM_IO_FPUTS -- add a string to the buffer for the file pointer
26 **
27 **	Parameters:
28 **		fp -- the file pointer for the buffer to be written to
29 **		timeout -- time to complete the put-string
30 **		s -- string to be placed in the buffer
31 **
32 **	Returns:
33 **		Failure: returns SM_IO_EOF
34 **		Success: returns 0 (zero)
35 */
36 
37 int
38 sm_io_fputs(fp, timeout, s)
39 	SM_FILE_T *fp;
40 	int timeout;
41 	const char *s;
42 {
43 	struct sm_uio uio;
44 	struct sm_iov iov;
45 
46 	SM_REQUIRE_ISA(fp, SmFileMagic);
47 	iov.iov_base = (void *) s;
48 	iov.iov_len = uio.uio_resid = strlen(s);
49 	uio.uio_iov = &iov;
50 	uio.uio_iovcnt = 1;
51 	return sm_fvwrite(fp, timeout, &uio);
52 }
53