#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <syscall.h>
Go to the source code of this file.
|
FILE * | _alloc_file () |
|
void | _free_file (FILE *fh) |
|
FILE * | fopen (const char *path, const char *mode) |
|
int | fclose (FILE *fh) |
|
int | feof (FILE *fh) |
|
int | fflush (FILE *fh) |
|
size_t | fread (void *buf, size_t size, size_t nmemb, FILE *fh) |
|
size_t | fwrite (const void *buf, size_t size, size_t nmemb, FILE *fh) |
|
int | fputc (int ch, FILE *fh) |
|
int | fputs (const char *str, FILE *fh) |
|
int | puts (const char *str) |
|
int | fgetc (FILE *fh) |
|
char * | fgets (char *str, int size, FILE *fh) |
|
◆ _alloc_file()
Definition at line 39 of file file.c.
40{
41 int i;
42
44 if (
fds[i].in_use == 0) {
47 }
48 }
49
50
51
53}
static FILE fds[FOPEN_MAX]
◆ _free_file()
void _free_file |
( |
FILE * |
fh | ) |
|
◆ fclose()
Definition at line 86 of file file.c.
87{
89
91
92 return status;
93}
void _free_file(FILE *fh)
◆ feof()
◆ fflush()
◆ fgetc()
Definition at line 157 of file file.c.
158{
159 char ch;
160 if (
fread(&ch, 1, 1, fh) == 1)
161 return ch;
163}
size_t fread(void *buf, size_t size, size_t nmemb, FILE *fh)
◆ fgets()
char * fgets |
( |
char * |
str, |
|
|
int |
size, |
|
|
FILE * |
fh |
|
) |
| |
Definition at line 166 of file file.c.
167{
168 int i;
169
170 for (i = 0; i < (
size - 1); i++) {
174 if (ch == '\b') {
175 if (i > 0)
176 i -= 1;
177 i -= 1;
178 continue;
179 }
180 str[i] = (char)ch;
181 if (ch == '\n') {
182 str[i + 1] = '\0';
183 return str;
184 }
185 }
186
187 str[
size - 1] =
'\0';
188 return str;
189}
◆ fopen()
FILE * fopen |
( |
const char * |
path, |
|
|
const char * |
mode |
|
) |
| |
Definition at line 66 of file file.c.
67{
70
71
73 if (fd == 0)
75
79
80
81
82 return fh;
83}
uint64_t OSOpen(const char *path, uint64_t flags)
◆ fputc()
int fputc |
( |
int |
ch, |
|
|
FILE * |
fh |
|
) |
| |
Definition at line 124 of file file.c.
125{
126 if (
fwrite(&ch, 1, 1, fh) == 1)
127 return ch;
129}
size_t fwrite(const void *buf, size_t size, size_t nmemb, FILE *fh)
◆ fputs()
int fputs |
( |
const char * |
str, |
|
|
FILE * |
fh |
|
) |
| |
Definition at line 132 of file file.c.
133{
135 if (status > 0)
136 return status;
137
139}
size_t strlen(const char *str)
◆ fread()
Definition at line 110 of file file.c.
111{
113
114}
int OSRead(uint64_t fd, void *addr, uint64_t off, uint64_t length)
◆ fwrite()
Definition at line 117 of file file.c.
118{
120
121}
int OSWrite(uint64_t fd, const void *addr, uint64_t off, uint64_t length)
◆ puts()
int puts |
( |
const char * |
str | ) |
|
Definition at line 142 of file file.c.
143{
144 int status, status2;
146 if (status < 0)
148
150 if (status2 < 0)
152
153 return status;
154}
int fputs(const char *str, FILE *fh)
int fputc(int ch, FILE *fh)
◆ __stderr
◆ __stdin
◆ __stdout
◆ fds
Initial value:= {
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 },
}
Definition at line 19 of file file.c.
◆ stderr
◆ stdin
◆ stdout