2 * Copyright (c) 1990 The Regents of the University of California.
5 * Redistribution and use in source and binary forms are permitted
6 * provided that the above copyright notice and this paragraph are
7 * duplicated in all such forms and that any documentation,
8 * and/or other materials related to such
9 * distribution and use acknowledge that the software was developed
10 * by the University of California, Berkeley. The name of the
11 * University may not be used to endorse or promote products derived
12 * from this software without specific prior written permission.
13 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20 <<puts>>---write a character string
29 int puts(const char *<[s]>);
31 int _puts_r(struct _reent *<[reent]>, const char *<[s]>);
34 <<puts>> writes the string at <[s]> (followed by a newline, instead of
35 the trailing null) to the standard output stream.
37 The alternate function <<_puts_r>> is a reentrant version. The extra
38 argument <[reent]> is a pointer to a reentrancy structure.
41 If successful, the result is a nonnegative integer; otherwise, the
45 ANSI C requires <<puts>>, but does not specify that the result on
46 success must be <<0>>; any non-negative value is permitted.
48 Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
49 <<lseek>>, <<read>>, <<sbrk>>, <<write>>.
52 #if defined(LIBC_SCCS) && !defined(lint)
53 static char sccsid
[] = "%W% (Berkeley) %G%";
54 #endif /* LIBC_SCCS and not lint */
64 * Write the given string to stdout, appending a newline.
68 _puts_r (struct _reent
*ptr
,
71 #ifdef _FVWRITE_IN_STREAMIO
73 size_t c
= strlen (s
);
80 iov
[1].iov_base
= "\n";
82 uio
.uio_resid
= c
+ 1;
83 uio
.uio_iov
= &iov
[0];
86 _REENT_SMALL_CHECK_INIT (ptr
);
89 _newlib_flockfile_start (fp
);
90 if (ORIENT (fp
, -1) != -1)
93 result
= (__sfvwrite_r (ptr
, fp
, &uio
) ? EOF
: '\n');
94 _newlib_flockfile_end (fp
);
100 _REENT_SMALL_CHECK_INIT (ptr
);
102 fp
= _stdout_r (ptr
);
103 CHECK_INIT (ptr
, fp
);
104 _newlib_flockfile_start (fp
);
105 /* Make sure we can write. */
106 if (cantwrite (ptr
, fp
))
111 if (__sputc_r (ptr
, *p
++, fp
) == EOF
)
114 if (__sputc_r (ptr
, '\n', fp
) == EOF
)
120 _newlib_flockfile_end (fp
);
128 puts (char const * s
)
130 return _puts_r (_REENT
, s
);