xref: /titanic_50/usr/src/cmd/sendmail/libsm/fput.c (revision 321502cd0930b1eb6d4805e17f16234f3e3ff4b2)
1 /*
2  * Copyright (c) 2000-2001 Sendmail, 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 #pragma ident	"%Z%%M%	%I%	%E% SMI"
16 
17 #include <sm/gen.h>
18 SM_RCSID("@(#)$Id: fput.c,v 1.18 2001/01/28 00:29:35 ca Exp $")
19 #include <string.h>
20 #include <errno.h>
21 #include <sm/io.h>
22 #include <sm/assert.h>
23 #include "local.h"
24 #include "fvwrite.h"
25 
26 /*
27 **  SM_IO_FPUTS -- add a string to the buffer for the file pointer
28 **
29 **	Parameters:
30 **		fp -- the file pointer for the buffer to be written to
31 **		timeout -- time to complete the put-string
32 **		s -- string to be placed in the buffer
33 **
34 **	Returns:
35 **		Failure: returns SM_IO_EOF
36 **		Success: returns 0 (zero)
37 */
38 
39 int
40 sm_io_fputs(fp, timeout, s)
41 	SM_FILE_T *fp;
42 	int timeout;
43 	const char *s;
44 {
45 	struct sm_uio uio;
46 	struct sm_iov iov;
47 
48 	SM_REQUIRE_ISA(fp, SmFileMagic);
49 	iov.iov_base = (void *) s;
50 	iov.iov_len = uio.uio_resid = strlen(s);
51 	uio.uio_iov = &iov;
52 	uio.uio_iovcnt = 1;
53 	return sm_fvwrite(fp, timeout, &uio);
54 }
55