xref: /original-bsd/lib/libc/stdio/puts.c (revision c3e32dec)
1 /*-
2  * Copyright (c) 1990, 1993
3  *	The Regents of the University of California.  All rights reserved.
4  *
5  * This code is derived from software contributed to Berkeley by
6  * Chris Torek.
7  *
8  * %sccs.include.redist.c%
9  */
10 
11 #if defined(LIBC_SCCS) && !defined(lint)
12 static char sccsid[] = "@(#)puts.c	8.1 (Berkeley) 06/04/93";
13 #endif /* LIBC_SCCS and not lint */
14 
15 #include <stdio.h>
16 #include <string.h>
17 #include "fvwrite.h"
18 
19 /*
20  * Write the given string to stdout, appending a newline.
21  */
22 puts(s)
23 	char const *s;
24 {
25 	size_t c = strlen(s);
26 	struct __suio uio;
27 	struct __siov iov[2];
28 
29 	iov[0].iov_base = (void *)s;
30 	iov[0].iov_len = c;
31 	iov[1].iov_base = "\n";
32 	iov[1].iov_len = 1;
33 	uio.uio_resid = c + 1;
34 	uio.uio_iov = &iov[0];
35 	uio.uio_iovcnt = 2;
36 	return (__sfvwrite(stdout, &uio) ? EOF : '\n');
37 }
38