blob: 64c534e357015f43113f8ff98362ea9357c61e4c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
#include <knob/user.h>
#include <knob/file.h>
#include <knob/task.h>
void start(const char *cmd) {
tell_user_sz(cmd);
tell_user_sz(": ");
tell_user_sz(
try_run_command(cmd)
? "success\n"
: "failed\n"
);
}
#define STARTUP_FILE_PATH "SYS/STARTUP.RC"
void main() {
struct file *f = open_file(STARTUP_FILE_PATH);
if (!f) {
tell_user_sz("Could not open " STARTUP_FILE_PATH "\n");
return;
}
tell_user_sz("[init] Reading from " STARTUP_FILE_PATH ":\n");
char buf[1024];
char *bufp = buf;
while (read_from_file(f, 1, bufp)) {
if (*bufp == '\n') {
if (bufp == buf)
continue;
*bufp = '\0';
start(buf);
bufp = buf;
}
else
++bufp;
}
if (bufp != buf) {
*bufp = '\0';
start(buf);
}
close_file(f);
tell_user_sz("[init] Done.\n");
}
|