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 <<getchar>>---read a character (macro)
31 int _getchar_r(struct _reent *<[reent]>);
34 <<getchar>> is a macro, defined in <<stdio.h>>. You can use <<getchar>>
35 to get the next single character from the standard input stream.
36 As a side effect, <<getchar>> advances the standard input's
37 current position indicator.
39 The alternate function <<_getchar_r>> is a reentrant version. The
40 extra argument <[reent]> is a pointer to a reentrancy structure.
44 The next character (read as an <<unsigned char>>, and cast to
45 <<int>>), unless there is no more data, or the host system reports a
46 read error; in either of these situations, <<getchar>> returns <<EOF>>.
48 You can distinguish the two situations that cause an <<EOF>> result by
49 using `<<ferror(stdin)>>' and `<<feof(stdin)>>'.
52 ANSI C requires <<getchar>>; it suggests, but does not require, that
53 <<getchar>> be implemented as a macro.
55 Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
56 <<lseek>>, <<read>>, <<sbrk>>, <<write>>.
59 #if defined(LIBC_SCCS) && !defined(lint)
60 static char sccsid
[] = "%W% (Berkeley) %G%";
61 #endif /* LIBC_SCCS and not lint */
64 * A subroutine version of the macro getchar.
75 _getchar_r (struct _reent
*reent
)
77 _REENT_SMALL_CHECK_INIT (reent
);
78 return _getc_r (reent
, _stdin_r (reent
));
86 struct _reent
*reent
= _REENT
;
88 /* CHECK_INIT is called (eventually) by __srefill_r. */
89 _REENT_SMALL_CHECK_INIT (reent
);
90 return _getc_r (reent
, _stdin_r (reent
));