-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdriver.c
76 lines (67 loc) · 2.17 KB
/
driver.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*
* driver class to test the timer.
*/
#include <stdio.h>
#include "clock.h"
#include "consts.h"
#include "inout.h"
#include "timer.h"
int print_menu_get_action()
{
print_string("**************************************************\n");
print_string("* Timer Menu *\n");
print_string("* -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ *\n");
print_string("* *\n");
print_string("* 1) Add a timer *\n");
print_string("* 2) Remove a timer *\n");
print_string("* 3) List all timers *\n");
print_string("* 4) Show time *\n");
print_string("* *\n");
print_string("* 9) Exit *\n");
print_string("* *\n");
print_string("**************************************************\n\n");
print_string("Enter selection, when done press <enter> > ");
return (get_input_digit());
}
void main_loop()
{
while (1) {
int res, i = print_menu_get_action();
switch(i)
{
case 1:
res = add_timer();
if (ERROR_CODE == res) {
print_string("\nError ... timer not added!\n");
} else {
print_string("\nTimer added!\n");
}
break;
case 2:
print_string("Which timer should I nuke? > ");
delete_timer_record(get_input_digit());
break;
case 3:
list_timers();
break;
case 4:
display_time();
break;
case 9:
/* Exit */
print_string("\nGoodbye\n\n");
return;
default:
/* do nothing ... reprint menu */
print_string("\nInvalid Action ... try again!\n");
break;
}
}
}
int main()
{
init_timer(); /* setup */
main_loop(); /* loop until user quits */
uninit_timer(); /* tear down */
return 0;
}