-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclock.c
More file actions
80 lines (61 loc) · 1.69 KB
/
Copy pathclock.c
File metadata and controls
80 lines (61 loc) · 1.69 KB
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
76
77
78
79
80
/***************************************************************************
*
* Clock Module
*
***************************************************************************/
#include "zfile.h"
void InitClock()
{
#ifdef CLOCK_SUPPORT
struct itimerval value, ovalue;
print_time = TRUE;
if (getitimer(ITIMER_REAL, &value)!= 0) {
sprintf(message,"getitimer() failed: %s", strerror(errno));
ERROR_MSG(message);
}
value.it_interval.tv_sec = CLOCK_INTERVAL;
value.it_value.tv_sec = CLOCK_INTERVAL;
value.it_interval.tv_usec = 0;
if (setitimer(ITIMER_REAL, &value, &ovalue)!= 0) {
sprintf(message,"setitimer() failed: %s", strerror(errno));
ERROR_MSG(message);
}
ClockHandler(0);
#endif
}
void ClockHandler(int sig)
{
#ifdef CLOCK_SUPPORT
char strtm[23];
time_t HORA;
struct tm *hora;
if(COLS > 15 && print_time)
{
time(&HORA);
hora = localtime(&HORA);
*strtm = '\0';
sprintf(strtm,"[time %.2d:%.2d:%.2d]",hora->tm_hour,hora->tm_min,hora->tm_sec);
#ifdef COLOR_SUPPORT
mvwaddch(time_window, 0, 0, ACS_RTEE| COLOR_PAIR(MENU_COLOR)|A_BOLD);
mvwaddch(time_window, 0, 14, ACS_LTEE| COLOR_PAIR(MENU_COLOR)|A_BOLD);
#else
mvwaddch(time_window, 0, 0, ACS_RTEE);
mvwaddch(time_window, 0, 14, ACS_LTEE);
#endif
PrintMenuOptions(time_window,0, 1, strtm, MENU_COLOR, HIMENUS_COLOR);
}
signal(SIGALRM, ClockHandler );
#endif
}
void SuspendClock(void)
{
#ifdef CLOCK_SUPPORT
struct itimerval value, ovalue;
value.it_interval.tv_sec = 0;
value.it_value.tv_sec = 0;
value.it_interval.tv_usec = 0;
setitimer(ITIMER_REAL, &value, &ovalue);
signal(SIGALRM, SIG_IGN);
#endif
return;
}