diff options
author | Benji Dial <benji6283@gmail.com> | 2020-09-06 13:44:20 -0400 |
---|---|---|
committer | Benji Dial <benji6283@gmail.com> | 2020-09-06 13:44:20 -0400 |
commit | 73bb0e48640b842824a0b45fe4854df8ff7faf7b (patch) | |
tree | 077dec8a426db1e835393964da4736e91ff4c69d /src/user/init/main.c | |
parent | cbc85f6e897808b29e2f712156e2fa4d073d8277 (diff) | |
download | portland-os-73bb0e48640b842824a0b45fe4854df8ff7faf7b.tar.gz |
bugfixes, init program, hello world
Diffstat (limited to 'src/user/init/main.c')
-rw-r--r-- | src/user/init/main.c | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/src/user/init/main.c b/src/user/init/main.c index 9a411e7..c301a78 100644 --- a/src/user/init/main.c +++ b/src/user/init/main.c @@ -1,29 +1,31 @@ #include <knob/user.h> #include <knob/file.h> -#include <knob/heap.h> +#include <knob/task.h> void main() { - tell_user_sz("\n\nThis is a userland program.\n"); - - tell_user_sz("Opening sd0:TEST.TXT.\n"); - struct file *f = open_file("sd0:TEST.TXT"); + struct file *f = open_file("SYS/STARTUP.RC"); if (!f) { - tell_user_sz("Failed to open.\n"); + tell_user_sz("\nCould not open SYS/STARTUP.RC"); return; } - tell_user_sz("Length: "); - uint32_t size = file_size(f); - tell_user_n(size); - tell_user_sz(" bytes\n\nContents:\n"); - - char *buf = get_block(size + 1); - read_from_file(f, size, buf); - buf[size] = '\0'; + char buf[1024]; + char *bufp = buf; + while (read_from_file(f, 1, bufp)) { + if (*bufp == '\n') { + if (bufp == buf) + continue; + *bufp = '\0'; + try_run_command(buf); + bufp = buf; + } + else + ++bufp; + } + if (bufp != buf) { + *bufp = '\0'; + try_run_command(buf); + } close_file(f); - - tell_user_sz(buf); - - tell_user_sz("\n\nGoodbye!\n"); } |