OpenCores
URL https://opencores.org/ocsvn/or1k_old/or1k_old/trunk

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [newlib/] [newlib/] [libc/] [stdio/] [getc.c] - Blame information for rev 1765

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 39 lampret
/*
2
 * Copyright (c) 1990 The Regents of the University of California.
3
 * All rights reserved.
4
 *
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
 * advertising materials, and 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.
16
 */
17
 
18
/*
19
FUNCTION
20
<<getc>>---read a character (macro)
21
 
22
INDEX
23
        getc
24
 
25
ANSI_SYNOPSIS
26
        #include <stdio.h>
27
        int getc(FILE *<[fp]>);
28
 
29
TRAD_SYNOPSIS
30
        #include <stdio.h>
31
        int getc(<[fp]>)
32
        FILE *<[fp]>;
33
 
34
DESCRIPTION
35
<<getc>> is a macro, defined in <<stdio.h>>.  You can use <<getc>>
36
to get the next single character from the file or stream
37
identified by <[fp]>.  As a side effect, <<getc>> advances the file's
38
current position indicator.
39
 
40
For a subroutine version of this macro, see <<fgetc>>.
41
 
42
RETURNS
43
The next character (read as an <<unsigned char>>, and cast to
44
<<int>>), unless there is no more data, or the host system reports a
45
read error; in either of these situations, <<getc>> returns <<EOF>>.
46
 
47
You can distinguish the two situations that cause an <<EOF>> result by
48
using the <<ferror>> and <<feof>> functions.
49
 
50
PORTABILITY
51
ANSI C requires <<getc>>; it suggests, but does not require, that
52
<<getc>> be implemented as a macro.  The standard explicitly permits
53
macro implementations of <<getc>> to use the argument more than once;
54
therefore, in a portable program, you should not use an expression
55
with side effects as the <<getc>> argument.
56
 
57
Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
58
<<lseek>>, <<read>>, <<sbrk>>, <<write>>.
59
*/
60
 
61
#if defined(LIBC_SCCS) && !defined(lint)
62
static char sccsid[] = "%W% (Berkeley) %G%";
63
#endif /* LIBC_SCCS and not lint */
64
 
65
#include <stdio.h>
66
 
67
/*
68
 * A subroutine version of the macro getc.
69
 */
70
 
71
#undef getc
72
 
73
int
74
getc (fp)
75
     register FILE *fp;
76
{
77
  /* CHECK_INIT is called (eventually) by __srefill.  */
78
 
79
  return __sgetc (fp);
80
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.