USB device can now be unbind
[AROS.git] / compiler / stdc / ungetc.c
blob8004107fe2453c43919f4ecafc1e57a046a2e31c
1 /*
2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
3 $Id$
5 C99 function ungetc().
6 */
7 #include <dos/dos.h>
8 #include <dos/dosextens.h>
9 #include <proto/exec.h>
10 #include <proto/dos.h>
11 #include <errno.h>
13 #include "__stdio.h"
15 /*****************************************************************************
17 NAME */
18 #include <stdio.h>
20 int ungetc (
22 /* SYNOPSIS */
23 int c,
24 FILE * stream)
26 /* FUNCTION
27 Puch the character c character back into the stream.
29 INPUTS
30 c - Put this character back into the stream. The next read will
31 return this character. If you push back more than one
32 character, then they will be returned in reverse order.
33 The function gurantees that one character can be
34 pushed back but no more. It is possible to push the EOF
35 character back into the stream.
36 stream - Read from this stream
38 RESULT
39 c or EOF on error.
41 NOTES
43 EXAMPLE
45 BUGS
47 SEE ALSO
48 fgetc(), getc(), fputc(), putc()
50 INTERNALS
52 ******************************************************************************/
54 /* Note: changes here might require changes in vfscanf.c!! */
56 if (c < -1)
57 c = (unsigned int)c;
59 if (!UnGetC (stream->fh, c))
61 LONG ioerr = IoErr();
63 if (ioerr)
65 errno = __stdc_ioerr2errno(ioerr);
66 stream->flags |= __STDCIO_STDIO_ERROR;
68 else
69 stream->flags |= __STDCIO_STDIO_EOF;
71 c = EOF;
74 return c;
75 } /* ungetc */