Added more syscalls
[akaros.git] / user / apps / parlib / matrix.c
1 #include <stdlib.h>
2 #include <string.h>
3 #include <stdio.h>
4 #include <unistd.h>
5 #include <parlib.h>
6 #include <arch/arch.h>
7 #include <ros/common.h>
8 #include <sys/stat.h>
9
10 extern char * readline(const char *prompt);
11 extern void draw_nanwan();
12 extern void clrscrn(int leaverows);
13 extern void change_user();
14 extern void set_default_user();
15 extern void file_io();
16 extern void file_error();
17 extern int  shell_exec(const char* cmdline);
18 extern void run_binary(size_t colors);
19 extern int  run_binary_filename(const char* fn, size_t colors);
20 extern void run_binary_colored();
21 extern char prompt[256];
22
23 void help() {
24         printf("Possible commands to run:\n"
25            "  draw_nanwan:      Draw a picture of Nanwan, our mascot giraffe\n"
26            "  clear_screen:     Clear the Screen\n"
27            "  change_user:      Change Username\n"
28            "  monitor:          Execute a breakpoint trap to run the monitor\n"
29            "  date:             Get time and date\n"
30            "  reboot:           Hopefully you can figure this one out...\n"
31            "  exit:             Hopefully you can figure this one out...\n"
32            "  file_io:          Run File Related IO Tests\n"
33            "  file_error:       Run File Error Related Tests\n"
34            "  run_binary:       Load and run a binary located on the remote server\n"
35            "  run_binary_colored:       Load and run a binary located on the remote server with a specified number of page colors\n"
36               );
37 }
38
39 void date()
40 {
41         time_t t;
42         time(&t);
43         struct tm* tt = gmtime(&t);
44         puts(asctime(tt));
45 }
46
47 int main(int argc, char** argv)
48 {       
49         set_default_user();
50         printf("Welcome to the Tessellation OS newlib test suite!\n");
51         printf("Enter at your own risk....\n");
52         clrscrn(2);
53         while(1) {
54                 char* s = readline(prompt);
55
56                 if (s == NULL)
57                         continue;
58
59                 if(strcmp(s, "draw_nanwan") == 0)
60                         draw_nanwan();
61                 else if(strcmp(s, "clear_screen") == 0)
62                         clrscrn(0);             
63                 else if (strcmp(s, "change_user") == 0)
64                         change_user();
65                 else if (strcmp(s, "monitor") == 0)
66                         breakpoint();
67                 else if (strcmp(s, "date") == 0)
68                         date();
69                 else if (strcmp(s, "reboot") == 0)
70                         sys_reboot();
71                 else if (strcmp(s, "exit") == 0)
72                         exit(0);
73                 else if (strcmp(s, "file_io") == 0)
74                         file_io();
75                 else if (strcmp(s, "file_error") == 0)
76                         file_error();
77                 else if (strcmp(s, "run_binary") == 0)
78                         run_binary(0);
79                 else if (strcmp(s, "run_binary_colored") == 0)
80                         run_binary_colored();
81                 else if (shell_exec(s) == 0)
82                         ;
83                 else
84                         help(); 
85
86         }       
87         return 0;
88 }