#include #include #include void start(const char *cmd) { tell_user_sz("[init] Starting "); tell_user_sz(cmd); tell_user_sz(": "); tell_user_sz( run_command(cmd) ? "Succeded.\n" : "Failed.\n" ); tell_user_sz("[init] Yielding.\n"); yield_task(); } #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 starting programs.\n"); }