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