PatchworkOS
Loading...
Searching...
No Matches
ungetc.c
Go to the documentation of this file.
1
#include <
stdio.h
>
2
3
#include "
user/common/file.h
"
4
5
int
ungetc
(
int
c,
FILE
* stream)
6
{
7
int
rc;
8
9
mtx_lock
(&stream->
mtx
);
10
11
if
(c ==
EOF
|| stream->
ungetIndex
==
_UNGETC_MAX
)
12
{
13
rc = -1;
14
}
15
else
16
{
17
rc = stream->
ungetBuf
[stream->
ungetIndex
++] = (
unsigned
char)c;
18
}
19
20
mtx_unlock
(&stream->
mtx
);
21
22
return
rc;
23
}
file.h
_UNGETC_MAX
#define _UNGETC_MAX
Definition
file.h:32
stdio.h
EOF
#define EOF
Definition
stdio.h:25
FILE
Definition
file.h:34
FILE::ungetBuf
unsigned char ungetBuf[_UNGETC_MAX]
Definition
file.h:42
FILE::mtx
mtx_t mtx
Definition
file.h:45
FILE::ungetIndex
uint64_t ungetIndex
Definition
file.h:43
mtx_lock
_PUBLIC int mtx_lock(mtx_t *mtx)
Definition
mtx_lock.c:11
mtx_unlock
_PUBLIC int mtx_unlock(mtx_t *mtx)
Definition
mtx_unlock.c:10
ungetc
int ungetc(int c, FILE *stream)
Definition
ungetc.c:5
src
libstd
user
functions
stdio
ungetc.c
Generated by
1.9.8