|
4 | 4 | #include "datetime.h" |
5 | 5 | #include "printf.h" |
6 | 6 | #include "clear.h" |
| 7 | +#include "string.h" |
7 | 8 |
|
8 | 9 | static const char *banner[] = { |
9 | 10 | "========================================\r\n", |
@@ -53,37 +54,50 @@ void kernel_main(void) |
53 | 54 |
|
54 | 55 | switch (input_buffer[0]) |
55 | 56 | { |
56 | | - case 'h': // Check for help command |
57 | | - printf("\nHelp:\n 'q' to exit\n 'h' for help\n 'c' to clear screen\n 't' to print current time\n 'd' to print current date\r\n"); |
58 | | - break; |
59 | | - case 'e': // TODO: This is for testing purposes. Remove once not needed |
60 | | - printf("%ld %ld %ld\n", 0, -9223372036854775808, 9223372036854775807); |
61 | | - printf("%d %d\n", 2147483647, -2147483648); |
62 | | - printf("%x %lx %lX %X\n", 2147483647, 2147483649, 2147483648, 1234); |
63 | | - printf("%lX %x %lx\n", 0x123456789abcdef0, 1234, 9223372036854775809); |
64 | | - printf("Name: %c\n", 'b'); |
65 | | - printf("Hello %s\n", "World"); |
66 | | - printf("100%%\n"); |
67 | | - break; |
68 | | - case 'q': // Check for exit command |
69 | | - printf("Exiting...\r\n"); |
70 | | - is_running = false; |
71 | | - break; |
72 | | - case 'c': // Check for clear screen command |
73 | | - clear(); |
74 | | - break; |
75 | | - |
76 | | - case 't': // Check for time command |
77 | | - gettime(&time_struct); |
78 | | - printf("Current time(GMT): %d:%d:%d\n", time_struct.hrs, time_struct.mins, time_struct.secs); |
79 | | - break; |
80 | | - case 'd': // Check for date command |
81 | | - getdate(&date_struct); |
82 | | - printf("Current date(MM-DD-YYYY): %d-%d-%d\n", date_struct.month, date_struct.day, date_struct.year); |
83 | | - break; |
84 | | - default: |
85 | | - printf("Unknown command. Type 'h' for help.\r\n"); |
86 | | - break; |
| 57 | + case 'h': // Check for help command |
| 58 | + printf("\nHelp:\n 'q' to exit\n 'h' for help\n 'c' to clear screen\n 't' to print current time\n 'd' to print current date\r\n"); |
| 59 | + break; |
| 60 | + case 'e': |
| 61 | + int result = strcmp("abc", "abc"); // Expect 0 |
| 62 | + printf("Expect 0 -> %d\n", result); |
| 63 | + |
| 64 | + result = strcmp("abc", "abd"); // Expect -1 |
| 65 | + printf("Expect -1 -> %d\n", result); |
| 66 | + |
| 67 | + result = strcmp("abc", "ABC"); // Expect 1 |
| 68 | + printf("Expect 1 -> %d\n", result); |
| 69 | + |
| 70 | + result = strcmp("ABC", "abc"); // Expect -1 |
| 71 | + printf("Expect -1 -> %d\n", result); |
| 72 | + |
| 73 | + result = strcmp("\x01\x02\x03", "\x01\x02\x03"); // Expect 0 |
| 74 | + printf("Expect 0 -> %d\n", result); |
| 75 | + |
| 76 | + result = strcmp("\x01\x02\x03", "\x01\x02\x04"); // Expect -1 |
| 77 | + printf("Expect -1 -> %d\n", result); |
| 78 | + |
| 79 | + result = strcmp("\x01\x02\x04", "\x01\x02\x03"); // Expect 1 |
| 80 | + printf("Expect 1 -> %d\n", result); |
| 81 | + break; |
| 82 | + case 'q': // Check for exit command |
| 83 | + printf("Exiting...\r\n"); |
| 84 | + is_running = false; |
| 85 | + break; |
| 86 | + case 'c': // Check for clear screen command |
| 87 | + clear(); |
| 88 | + break; |
| 89 | + |
| 90 | + case 't': // Check for time command |
| 91 | + gettime(&time_struct); |
| 92 | + printf("Current time(GMT): %d:%d:%d\n", time_struct.hrs, time_struct.mins, time_struct.secs); |
| 93 | + break; |
| 94 | + case 'd': // Check for date command |
| 95 | + getdate(&date_struct); |
| 96 | + printf("Current date(MM-DD-YYYY): %d-%d-%d\n", date_struct.month, date_struct.day, date_struct.year); |
| 97 | + break; |
| 98 | + default: |
| 99 | + printf("Unknown command. Type 'h' for help.\r\n"); |
| 100 | + break; |
87 | 101 | } |
88 | 102 | } |
89 | 103 | } |
0 commit comments