Link MSL_C/ansi_files

This commit is contained in:
Cuyler36
2025-07-04 17:58:40 -04:00
parent 0bbd6f3dea
commit e5234934f1
3 changed files with 37 additions and 25 deletions
+1 -1
View File
@@ -819,7 +819,7 @@ config.libs = [
"src_dir": "src/static",
"objects": [
Object(Matching, "MSL_C.PPCEABI.bare.H/abort_exit.c"),
Object(NonMatching, "MSL_C.PPCEABI.bare.H/ansi_files.c"),
Object(Matching, "MSL_C.PPCEABI.bare.H/ansi_files.c"),
Object(NonMatching, "MSL_C.PPCEABI.bare.H/ansi_fp.c"),
Object(NonMatching, "MSL_C.PPCEABI.bare.H/arith.c"),
Object(Matching, "MSL_C.PPCEABI.bare.H/buffer_io.c"),
+1 -1
View File
@@ -28,7 +28,7 @@ enum __file_kinds {
__disk_file,
__console_file,
__string_file,
__unavailable_file,
__unavailable_file = 3, // TODO: figure out which one of these file kinds is not present
};
enum __file_orientation {
+35 -23
View File
@@ -1,8 +1,8 @@
#include "MSL_C/ansi_files.h"
char stderr_buff[0x100];
char stdout_buff[0x100];
char stdin_buff[0x100];
char stdout_buff[0x100];
char stderr_buff[0x100];
extern int __close_console(__file_handle file);
extern int __write_console(__file_handle file, unsigned char* buf, size_t* count, __idle_proc idle_fn);
@@ -104,28 +104,40 @@ extern files __files = {
},
};
unsigned int __flush_all(void) {
}
void __close_all(void) {
FILE* file = &__files._stdin;
FILE* p = &__files._stdin;
FILE* plast;
while (file) {
FILE* curr;
while(p != NULL)
{
if (p->file_mode.file_kind != __closed_file)
{
fclose(p);
}
if (file->file_mode.file_kind & 0x3)
fclose(file);
curr = file->next;
file = file->next;
if (curr->char_buffer) {
free(curr);
continue;
}
file->file_mode.file_kind = 3;
if (file && file->char_buffer)
curr->next = NULL;
}
plast = p;
p = (FILE*)p->next;
if (plast->char_buffer)
free(plast);
else
{
plast->file_mode.file_kind = __unavailable_file;
if ((p != NULL) && p->char_buffer)
plast->next = NULL;
}
}
}
unsigned int __flush_all(void)
{
unsigned int retval = 0;
FILE* __stream;
__stream = &__files._stdin;
while (__stream) {
if ((__stream->file_mode.file_kind) && (fflush(__stream))) {
retval = -1;
}
__stream = (FILE*)__stream->next;
};
return retval;
}