xref: /titanic_50/usr/src/cmd/sendmail/libsm/fput.c (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * Copyright (c) 2000-2001 Sendmail, Inc. and its suppliers.
3*7c478bd9Sstevel@tonic-gate  *      All rights reserved.
4*7c478bd9Sstevel@tonic-gate  * Copyright (c) 1990, 1993
5*7c478bd9Sstevel@tonic-gate  *	The Regents of the University of California.  All rights reserved.
6*7c478bd9Sstevel@tonic-gate  *
7*7c478bd9Sstevel@tonic-gate  * This code is derived from software contributed to Berkeley by
8*7c478bd9Sstevel@tonic-gate  * Chris Torek.
9*7c478bd9Sstevel@tonic-gate  *
10*7c478bd9Sstevel@tonic-gate  * By using this file, you agree to the terms and conditions set
11*7c478bd9Sstevel@tonic-gate  * forth in the LICENSE file which can be found at the top level of
12*7c478bd9Sstevel@tonic-gate  * the sendmail distribution.
13*7c478bd9Sstevel@tonic-gate  */
14*7c478bd9Sstevel@tonic-gate 
15*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
16*7c478bd9Sstevel@tonic-gate 
17*7c478bd9Sstevel@tonic-gate #include <sm/gen.h>
18*7c478bd9Sstevel@tonic-gate SM_RCSID("@(#)$Id: fput.c,v 1.18 2001/01/28 00:29:35 ca Exp $")
19*7c478bd9Sstevel@tonic-gate #include <string.h>
20*7c478bd9Sstevel@tonic-gate #include <errno.h>
21*7c478bd9Sstevel@tonic-gate #include <sm/io.h>
22*7c478bd9Sstevel@tonic-gate #include <sm/assert.h>
23*7c478bd9Sstevel@tonic-gate #include "local.h"
24*7c478bd9Sstevel@tonic-gate #include "fvwrite.h"
25*7c478bd9Sstevel@tonic-gate 
26*7c478bd9Sstevel@tonic-gate /*
27*7c478bd9Sstevel@tonic-gate **  SM_IO_FPUTS -- add a string to the buffer for the file pointer
28*7c478bd9Sstevel@tonic-gate **
29*7c478bd9Sstevel@tonic-gate **	Parameters:
30*7c478bd9Sstevel@tonic-gate **		fp -- the file pointer for the buffer to be written to
31*7c478bd9Sstevel@tonic-gate **		timeout -- time to complete the put-string
32*7c478bd9Sstevel@tonic-gate **		s -- string to be placed in the buffer
33*7c478bd9Sstevel@tonic-gate **
34*7c478bd9Sstevel@tonic-gate **	Returns:
35*7c478bd9Sstevel@tonic-gate **		Failure: returns SM_IO_EOF
36*7c478bd9Sstevel@tonic-gate **		Success: returns 0 (zero)
37*7c478bd9Sstevel@tonic-gate */
38*7c478bd9Sstevel@tonic-gate 
39*7c478bd9Sstevel@tonic-gate int
40*7c478bd9Sstevel@tonic-gate sm_io_fputs(fp, timeout, s)
41*7c478bd9Sstevel@tonic-gate 	SM_FILE_T *fp;
42*7c478bd9Sstevel@tonic-gate 	int timeout;
43*7c478bd9Sstevel@tonic-gate 	const char *s;
44*7c478bd9Sstevel@tonic-gate {
45*7c478bd9Sstevel@tonic-gate 	struct sm_uio uio;
46*7c478bd9Sstevel@tonic-gate 	struct sm_iov iov;
47*7c478bd9Sstevel@tonic-gate 
48*7c478bd9Sstevel@tonic-gate 	SM_REQUIRE_ISA(fp, SmFileMagic);
49*7c478bd9Sstevel@tonic-gate 	iov.iov_base = (void *) s;
50*7c478bd9Sstevel@tonic-gate 	iov.iov_len = uio.uio_resid = strlen(s);
51*7c478bd9Sstevel@tonic-gate 	uio.uio_iov = &iov;
52*7c478bd9Sstevel@tonic-gate 	uio.uio_iovcnt = 1;
53*7c478bd9Sstevel@tonic-gate 	return sm_fvwrite(fp, timeout, &uio);
54*7c478bd9Sstevel@tonic-gate }
55