|
1 /* GETC.C |
|
2 * |
|
3 * Portions Copyright (c) 1990-1999 Nokia Corporation and/or its subsidiary(-ies). |
|
4 * All rights reserved. |
|
5 */ |
|
6 |
|
7 /* |
|
8 * Copyright (c) 1990 The Regents of the University of California. |
|
9 * All rights reserved. |
|
10 * |
|
11 * Redistribution and use in source and binary forms are permitted |
|
12 * provided that the above copyright notice and this paragraph are |
|
13 * duplicated in all such forms and that any documentation, |
|
14 * advertising materials, and other materials related to such |
|
15 * distribution and use acknowledge that the software was developed |
|
16 * by the University of California, Berkeley. The name of the |
|
17 * University may not be used to endorse or promote products derived |
|
18 * from this software without specific prior written permission. |
|
19 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
|
20 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
|
21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
|
22 */ |
|
23 |
|
24 /* |
|
25 FUNCTION |
|
26 <<getc>>---read a character (macro) |
|
27 |
|
28 INDEX |
|
29 getc |
|
30 |
|
31 ANSI_SYNOPSIS |
|
32 #include <stdio.h> |
|
33 int getc(FILE *<[fp]>); |
|
34 |
|
35 TRAD_SYNOPSIS |
|
36 #include <stdio.h> |
|
37 int getc(<[fp]>) |
|
38 FILE *<[fp]>; |
|
39 |
|
40 DESCRIPTION |
|
41 <<getc>> is a macro, defined in <<stdio.h>>. You can use <<getc>> |
|
42 to get the next single character from the file or stream |
|
43 identified by <[fp]>. As a side effect, <<getc>> advances the file's |
|
44 current position indicator. |
|
45 |
|
46 For a subroutine version of this macro, see <<fgetc>>. |
|
47 |
|
48 RETURNS |
|
49 The next character (read as an <<unsigned char>>, and cast to |
|
50 <<int>>), unless there is no more data, or the host system reports a |
|
51 read error; in either of these situations, <<getc>> returns <<EOF>>. |
|
52 |
|
53 You can distinguish the two situations that cause an <<EOF>> result by |
|
54 using the <<ferror>> and <<feof>> functions. |
|
55 |
|
56 PORTABILITY |
|
57 ANSI C requires <<getc>>; it suggests, but does not require, that |
|
58 <<getc>> be implemented as a macro. The standard explicitly permits |
|
59 macro implementations of <<getc>> to use the argument more than once; |
|
60 therefore, in a portable program, you should not use an expression |
|
61 with side effects as the <<getc>> argument. |
|
62 |
|
63 Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>, |
|
64 <<lseek>>, <<read>>, <<sbrk>>, <<write>>. |
|
65 */ |
|
66 |
|
67 #include <stdio.h> |
|
68 #include "LOCAL.H" |
|
69 |
|
70 /* |
|
71 * A subroutine version of the macro getc. |
|
72 */ |
|
73 |
|
74 #undef getc |
|
75 |
|
76 /** |
|
77 Get the next character. |
|
78 Returns the next character of the stream and increases the file pointer |
|
79 to point to the next character. |
|
80 @return The character read is returned as an int value. |
|
81 If the End Of File has been reached or there has been an error reading, |
|
82 the function returns EOF. |
|
83 @param fp pointer to an open file. |
|
84 */ |
|
85 EXPORT_C int |
|
86 getc (register FILE *fp) |
|
87 { |
|
88 /* CHECK_INIT is called (eventually) by __srefill. */ |
|
89 |
|
90 return __sgetc (fp); |
|
91 } |