This commit is contained in:
Yaossg 2024-11-15 21:27:39 +08:00
parent 665444d855
commit 917ba6b619
3 changed files with 1297 additions and 0 deletions

32
boot-lib.c Normal file
View File

@ -0,0 +1,32 @@
#include <stdio.h>
#include <stdarg.h>
int eprintf(const char format[], ...) {
va_list args;
va_start(args, format);
int ret = vfprintf(stderr, format, args);
va_end(args);
return ret;
}
void ungetchar(int ch) {
ungetc(ch, stdin);
}
int eof() {
return feof(stdin);
}
int CA_get(char array[], int index) {
return array[index];
}
void CA_set(char array[], int index, int value) {
array[index] = value;
}
// this may be unnecessary
char* CA_offset(char array[], int offset) {
return array + offset;
}

18
boot-lib.h Normal file
View File

@ -0,0 +1,18 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
// std
int printf(const char* format, ...);
int getchar();
int putchar(int ch);
int strcmp(const char* s1, const char* s2);
void exit(int status);
// ext
void ungetchar(int ch);
int eof();
int CA_get(char array[], int index);
void CA_set(char array[], int index, int value);
char* CA_offset(char array[], int offset);
int eprintf(const char* format, ...);

1247
boot.c Normal file

File diff suppressed because it is too large Load Diff