xref: /freebsd/contrib/sendmail/libsm/fput.c (revision ee7b0571c2c18bdec848ed2044223cc88db29bd8)
140266059SGregory Neil Shapiro /*
25dd76dd0SGregory Neil Shapiro  * Copyright (c) 2000-2001 Proofpoint, Inc. and its suppliers.
340266059SGregory Neil Shapiro  *      All rights reserved.
440266059SGregory Neil Shapiro  * Copyright (c) 1990, 1993
540266059SGregory Neil Shapiro  *	The Regents of the University of California.  All rights reserved.
640266059SGregory Neil Shapiro  *
740266059SGregory Neil Shapiro  * This code is derived from software contributed to Berkeley by
840266059SGregory Neil Shapiro  * Chris Torek.
940266059SGregory Neil Shapiro  *
1040266059SGregory Neil Shapiro  * By using this file, you agree to the terms and conditions set
1140266059SGregory Neil Shapiro  * forth in the LICENSE file which can be found at the top level of
1240266059SGregory Neil Shapiro  * the sendmail distribution.
1340266059SGregory Neil Shapiro  */
1440266059SGregory Neil Shapiro 
1540266059SGregory Neil Shapiro #include <sm/gen.h>
16*4313cc83SGregory Neil Shapiro SM_RCSID("@(#)$Id: fput.c,v 1.21 2013-11-22 20:51:42 ca Exp $")
1740266059SGregory Neil Shapiro #include <string.h>
1840266059SGregory Neil Shapiro #include <errno.h>
1940266059SGregory Neil Shapiro #include <sm/io.h>
2040266059SGregory Neil Shapiro #include <sm/assert.h>
2140266059SGregory Neil Shapiro #include "local.h"
2240266059SGregory Neil Shapiro #include "fvwrite.h"
2340266059SGregory Neil Shapiro 
2440266059SGregory Neil Shapiro /*
2540266059SGregory Neil Shapiro **  SM_IO_FPUTS -- add a string to the buffer for the file pointer
2640266059SGregory Neil Shapiro **
2740266059SGregory Neil Shapiro **	Parameters:
2840266059SGregory Neil Shapiro **		fp -- the file pointer for the buffer to be written to
2940266059SGregory Neil Shapiro **		timeout -- time to complete the put-string
3040266059SGregory Neil Shapiro **		s -- string to be placed in the buffer
3140266059SGregory Neil Shapiro **
3240266059SGregory Neil Shapiro **	Returns:
3340266059SGregory Neil Shapiro **		Failure: returns SM_IO_EOF
3440266059SGregory Neil Shapiro **		Success: returns 0 (zero)
3540266059SGregory Neil Shapiro */
3640266059SGregory Neil Shapiro 
3740266059SGregory Neil Shapiro int
3840266059SGregory Neil Shapiro sm_io_fputs(fp, timeout, s)
3940266059SGregory Neil Shapiro 	SM_FILE_T *fp;
4040266059SGregory Neil Shapiro 	int timeout;
4140266059SGregory Neil Shapiro 	const char *s;
4240266059SGregory Neil Shapiro {
4340266059SGregory Neil Shapiro 	struct sm_uio uio;
4440266059SGregory Neil Shapiro 	struct sm_iov iov;
4540266059SGregory Neil Shapiro 
4640266059SGregory Neil Shapiro 	SM_REQUIRE_ISA(fp, SmFileMagic);
4740266059SGregory Neil Shapiro 	iov.iov_base = (void *) s;
4840266059SGregory Neil Shapiro 	iov.iov_len = uio.uio_resid = strlen(s);
4940266059SGregory Neil Shapiro 	uio.uio_iov = &iov;
5040266059SGregory Neil Shapiro 	uio.uio_iovcnt = 1;
5140266059SGregory Neil Shapiro 	return sm_fvwrite(fp, timeout, &uio);
5240266059SGregory Neil Shapiro }
53