xref: /csrg-svn/lib/libc/stdio/puts.c (revision 46098)
1*46098Sbostic /*-
2*46098Sbostic  * Copyright (c) 1990 The Regents of the University of California.
3*46098Sbostic  * All rights reserved.
4*46098Sbostic  *
5*46098Sbostic  * This code is derived from software contributed to Berkeley by
6*46098Sbostic  * Chris Torek.
7*46098Sbostic  *
8*46098Sbostic  * %sccs.include.redist.c%
9*46098Sbostic  */
10*46098Sbostic 
1126659Sdonn #if defined(LIBC_SCCS) && !defined(lint)
12*46098Sbostic static char sccsid[] = "@(#)puts.c	5.3 (Berkeley) 01/20/91";
13*46098Sbostic #endif /* LIBC_SCCS and not lint */
1422141Smckusick 
15*46098Sbostic #include <sys/stdc.h>
16*46098Sbostic #include <stdio.h>
17*46098Sbostic #include <string.h>
18*46098Sbostic #include "fvwrite.h"
192027Swnj 
20*46098Sbostic /*
21*46098Sbostic  * Write the given string to stdout, appending a newline.
22*46098Sbostic  */
232027Swnj puts(s)
24*46098Sbostic 	char const *s;
252027Swnj {
26*46098Sbostic 	size_t c = strlen(s);
27*46098Sbostic 	struct __suio uio;
28*46098Sbostic 	struct __siov iov[2];
292027Swnj 
30*46098Sbostic 	iov[0].iov_base = s;
31*46098Sbostic 	iov[0].iov_len = c;
32*46098Sbostic 	iov[1].iov_base = "\n";
33*46098Sbostic 	iov[1].iov_len = 1;
34*46098Sbostic 	uio.uio_resid = c + 1;
35*46098Sbostic 	uio.uio_iov = &iov[0];
36*46098Sbostic 	uio.uio_iovcnt = 2;
37*46098Sbostic 	return (__sfvwrite(stdout, &uio) ? EOF : '\n');
382027Swnj }
39