summaryrefslogtreecommitdiff
path: root/src/user/init
diff options
context:
space:
mode:
Diffstat (limited to 'src/user/init')
-rw-r--r--src/user/init/main.c38
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");
}