1 /*- 2 * Copyright (c) 1990 The Regents of the University of California. 3 * 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 5.6 (Berkeley) 02/24/91"; 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