2c8d5cbbe1d67e8b7fc10831f8aa5493122f8cf5
[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 void setup_environ()
48 {
49         static char* my_environ[] = {
50                 "PATH=:/bin:/usr/bin",
51                 "LD_LIBRARY_PATH=/lib:/usr/lib",
52                 0
53         };
54
55         environ = my_environ;
56 }
57
58 int main(int argc, char** argv)
59 {       
60         setup_environ();
61
62         set_default_user();
63         printf("Welcome to the Tessellation OS newlib test suite!\n");
64         printf("Enter at your own risk....\n");
65         clrscrn(2);
66         while(1) {
67                 char* s = readline(prompt);
68
69                 if (!s || !*s)
70                         continue;
71
72                 if(strcmp(s, "draw_nanwan") == 0)
73                         draw_nanwan();
74                 else if(strcmp(s, "clear_screen") == 0)
75                         clrscrn(0);             
76                 else if (strcmp(s, "change_user") == 0)
77                         change_user();
78                 else if (strcmp(s, "monitor") == 0)
79                         breakpoint();
80                 else if (strcmp(s, "date") == 0)
81                         date();
82                 else if (strcmp(s, "reboot") == 0)
83                         sys_reboot();
84                 else if (strcmp(s, "exit") == 0)
85                         exit(0);
86                 else if (strcmp(s, "file_io") == 0)
87                         file_io();
88                 else if (strcmp(s, "file_error") == 0)
89                         file_error();
90                 else if (strcmp(s, "run_binary") == 0)
91                         run_binary(0);
92                 else if (strcmp(s, "run_binary_colored") == 0)
93                         run_binary_colored();
94                 else if (shell_exec(s) == 0)
95                         ;
96                 else
97                         help(); 
98
99         }       
100         return 0;
101 }