Subversion Repositories Kolibri OS

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
6536 serge 1
/*
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
<>---read a character (macro)
21
 
22
INDEX
23
	getc
24
INDEX
25
	_getc_r
26
 
27
ANSI_SYNOPSIS
28
	#include 
29
	int getc(FILE *<[fp]>);
30
 
31
	#include 
32
	int _getc_r(struct _reent *<[ptr]>, FILE *<[fp]>);
33
 
34
TRAD_SYNOPSIS
35
	#include 
36
	int getc(<[fp]>)
37
	FILE *<[fp]>;
38
 
39
	#include 
40
	int _getc_r(<[ptr]>, <[fp]>)
41
	struct _reent *<[ptr]>;
42
	FILE *<[fp]>;
43
 
44
DESCRIPTION
45
<> is a macro, defined in <>.  You can use <>
46
to get the next single character from the file or stream
47
identified by <[fp]>.  As a side effect, <> advances the file's
48
current position indicator.
49
 
50
For a subroutine version of this macro, see <>.
51
 
52
The <<_getc_r>> function is simply the reentrant version of <>
53
which passes an additional reentrancy structure pointer argument: <[ptr]>.
54
 
55
RETURNS
56
The next character (read as an <>, and cast to
57
<>), unless there is no more data, or the host system reports a
58
read error; in either of these situations, <> returns <>.
59
 
60
You can distinguish the two situations that cause an <> result by
61
using the <> and <> functions.
62
 
63
PORTABILITY
64
ANSI C requires <>; it suggests, but does not require, that
65
<> be implemented as a macro.  The standard explicitly permits
66
macro implementations of <> to use the argument more than once;
67
therefore, in a portable program, you should not use an expression
68
with side effects as the <> argument.
69
 
70
Supporting OS subroutines required: <>, <>, <>,
71
<>, <>, <>, <>.
72
*/
73
 
74
#if defined(LIBC_SCCS) && !defined(lint)
75
static char sccsid[] = "%W% (Berkeley) %G%";
76
#endif /* LIBC_SCCS and not lint */
77
 
78
#include <_ansi.h>
79
#include 
80
#include "local.h"
81
 
82
/*
83
 * A subroutine version of the macro getc.
84
 */
85
 
86
#undef getc
87
 
88
int
89
_DEFUN(_getc_r, (ptr, fp),
90
       struct _reent *ptr _AND
91
       register FILE *fp)
92
{
93
  int result;
94
  CHECK_INIT (ptr, fp);
95
  _newlib_flockfile_start (fp);
96
  result = __sgetc_r (ptr, fp);
97
  _newlib_flockfile_end (fp);
98
  return result;
99
}
100
 
101
#ifndef _REENT_ONLY
102
 
103
int
104
_DEFUN(getc, (fp),
105
       register FILE *fp)
106
{
107
  int result;
108
  struct _reent *reent = _REENT;
109
 
110
  CHECK_INIT (reent, fp);
111
  _newlib_flockfile_start (fp);
112
  result = __sgetc_r (reent, fp);
113
  _newlib_flockfile_end (fp);
114
  return result;
115
}
116
 
117
#endif /* !_REENT_ONLY */