f913c6424beba7479b87e6fe4df6a3e9ac5f89d4
[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 void ping();
22 extern char prompt[256];
23
24 void help() {
25         printf("Possible commands to run:\n"
26            "  draw_nanwan:      Draw a picture of Nanwan, our mascot giraffe\n"
27            "  clear_screen:     Clear the Screen\n"
28            "  change_user:      Change Username\n"
29            "  monitor:          Execute a breakpoint trap to run the monitor\n"
30            "  date:             Get time and date\n"
31            "  reboot:           Hopefully you can figure this one out...\n"
32            "  exit:             Hopefully you can figure this one out...\n"
33            "  file_io:          Run File Related IO Tests\n"
34            "  file_error:       Run File Error Related Tests\n"
35            "  run_binary:       Load and run a binary located on the remote server\n"
36            "  run_binary_colored:       Load and run a binary located on the remote server with a specified number of page colors\n"
37               );
38 }
39
40 void date()
41 {
42         time_t t;
43         time(&t);
44         struct tm* tt = gmtime(&t);
45         puts(asctime(tt));
46 }
47
48 void setup_environ()
49 {
50         static char* my_environ[] = {
51                 "PATH=:/bin:/usr/bin",
52                 "LD_LIBRARY_PATH=/lib:/usr/lib",
53                 0
54         };
55
56         environ = my_environ;
57 }
58
59 int main(int argc, char** argv)
60 {       
61         setup_environ();
62
63         set_default_user();
64         printf("Welcome to the Tessellation OS newlib test suite!\n");
65         printf("Enter at your own risk....\n");
66         clrscrn(2);
67         while(1) {
68                 char* s = readline(prompt);
69
70                 if (!s || !*s)
71                         continue;
72
73                 if(strcmp(s, "draw_nanwan") == 0)
74                         draw_nanwan();
75                 else if(strcmp(s, "clear_screen") == 0)
76                         clrscrn(0);             
77                 else if (strcmp(s, "change_user") == 0)
78                         change_user();
79                 else if (strcmp(s, "monitor") == 0)
80                         breakpoint();
81                 else if (strcmp(s, "date") == 0)
82                         date();
83                 else if (strcmp(s, "reboot") == 0)
84                         sys_reboot();
85                 else if (strcmp(s, "exit") == 0)
86                         exit(0);
87                 else if (strcmp(s, "file_io") == 0)
88                         file_io();
89                 else if (strcmp(s, "file_error") == 0)
90                         file_error();
91                 else if (strcmp(s, "run_binary") == 0)
92                         run_binary(0);
93                 else if (strcmp(s, "run_binary_colored") == 0)
94                         run_binary_colored();
95                 else if (strcmp(s, "ping") == 0)
96                         ping();
97                 else if (shell_exec(s) == 0)
98                         ;
99                 else
100                         help(); 
101
102         }       
103         return 0;
104 }