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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [newlib-1.17.0/] [newlib/] [libc/] [stdio/] [fgetc.c] - Blame information for rev 831

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

Line No. Rev Author Line
1 148 jeremybenn
/*
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
<<fgetc>>---get a character from a file or stream
21
 
22
INDEX
23
        fgetc
24
INDEX
25
        _fgetc_r
26
 
27
ANSI_SYNOPSIS
28
        #include <stdio.h>
29
        int fgetc(FILE *<[fp]>);
30
 
31
        #include <stdio.h>
32
        int _fgetc_r(struct _reent *<[ptr]>, FILE *<[fp]>);
33
 
34
TRAD_SYNOPSIS
35
        #include <stdio.h>
36
        int fgetc(<[fp]>)
37
        FILE *<[fp]>;
38
 
39
        #include <stdio.h>
40
        int _fgetc_r(<[ptr]>, <[fp]>)
41
        struct _reent *<[ptr]>;
42
        FILE *<[fp]>;
43
 
44
DESCRIPTION
45
Use <<fgetc>> to get the next single character from the file or stream
46
identified by <[fp]>.  As a side effect, <<fgetc>> advances the file's
47
current position indicator.
48
 
49
For a macro version of this function, see <<getc>>.
50
 
51
The function <<_fgetc_r>> is simply a reentrant version of
52
<<fgetc>> that is passed the additional reentrant structure
53
pointer argument: <[ptr]>.
54
 
55
RETURNS
56
The next character (read as an <<unsigned char>>, and cast to
57
<<int>>), unless there is no more data, or the host system reports a
58
read error; in either of these situations, <<fgetc>> returns <<EOF>>.
59
 
60
You can distinguish the two situations that cause an <<EOF>> result by
61
using the <<ferror>> and <<feof>> functions.
62
 
63
PORTABILITY
64
ANSI C requires <<fgetc>>.
65
 
66
Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
67
<<lseek>>, <<read>>, <<sbrk>>, <<write>>.
68
*/
69
 
70
#include <_ansi.h>
71
#include <stdio.h>
72
#include "local.h"
73
 
74
int
75
_DEFUN(_fgetc_r, (ptr, fp),
76
       struct _reent * ptr _AND
77
       FILE * fp)
78
{
79
  int result;
80
  CHECK_INIT(ptr, fp);
81
  _flockfile (fp);
82
  result = __sgetc_r (ptr, fp);
83
  _funlockfile (fp);
84
  return result;
85
}
86
 
87
#ifndef _REENT_ONLY
88
 
89
int
90
_DEFUN(fgetc, (fp),
91
       FILE * fp)
92
{
93
#if !defined(PREFER_SIZE_OVER_SPEED) && !defined(__OPTIMIZE_SIZE__)
94
  int result;
95
  CHECK_INIT(_REENT, fp);
96
  _flockfile (fp);
97
  result = __sgetc_r (_REENT, fp);
98
  _funlockfile (fp);
99
  return result;
100
#else
101
  return _fgetc_r (_REENT, fp);
102
#endif
103
}
104
 
105
#endif /* !_REENT_ONLY */
106
 

powered by: WebSVN 2.1.0

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