Use dos.library/CreateNewProc() instead of alib/CreateNewProcTags()
[tangerine.git] / compiler / clib / ungetc.c
blob46664a599b63f2854c64a6272c776cf8a74acb0d
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 ANSI C function ungetc().
6 */
8 #include <errno.h>
9 #include <dos/dos.h>
10 #include <dos/dosextens.h>
11 #include <proto/exec.h>
12 #include <proto/dos.h>
13 #include "__errno.h"
14 #include "__open.h"
16 /*****************************************************************************
18 NAME */
19 #include <stdio.h>
21 int ungetc (
23 /* SYNOPSIS */
24 int c,
25 FILE * stream)
27 /* FUNCTION
28 Puch the character c character back into the stream.
30 INPUTS
31 c - Put this character back into the stream. The next read will
32 return this character. If you push back more than one
33 character, then they will be returned in reverse order.
34 The function gurantees that one character can be
35 pushed back but no more. It is possible to push the EOF
36 character back into the stream.
37 stream - Read from this stream
39 RESULT
40 c or EOF on error.
42 NOTES
44 EXAMPLE
46 BUGS
48 SEE ALSO
49 fgetc(), getc(), fputc(), putc()
51 INTERNALS
53 ******************************************************************************/
55 fdesc *fdesc = __getfdesc(stream->fd);
57 if (!fdesc)
59 stream->flags |= _STDIO_ERROR;
60 errno = EBADF;
61 return EOF;
64 /* Note: changes here might require changes in vfscanf.c!! */
66 if (c < -1)
67 c = (unsigned int)c;
69 if (!UnGetC ((BPTR)fdesc->fh, c))
71 errno = IoErr2errno (IoErr ());
73 if (errno)
74 stream->flags |= _STDIO_ERROR;
75 else
76 stream->flags |= _STDIO_EOF;
78 c = EOF;
81 return c;
82 } /* ungetc */