xref: /csrg-svn/usr.bin/talk/msgs.c (revision 16365)
1 #ifndef lint
2 static char sccsid[] = "@(#)msgs.c	1.2 (Berkeley) 04/11/84";
3 #endif
4 
5 /*
6  * A package to display what is happening every MSG_INTERVAL seconds
7  * if we are slow connecting.
8  */
9 
10 #include <signal.h>
11 #include <stdio.h>
12 #include <sys/time.h>
13 #include "talk.h"
14 
15 #define MSG_INTERVAL 4
16 #define LONG_TIME 100000
17 
18 char	*current_state;
19 int	current_line = 0;
20 
21 static	struct itimerval itimer;
22 static	struct timeval wait = { MSG_INTERVAL , 0};
23 static	struct timeval undo = { LONG_TIME, 0};
24 
25 disp_msg()
26 {
27 
28 	message(current_state);
29 }
30 
31 start_msgs()
32 {
33 
34 	message(current_state);
35 	signal(SIGALRM, disp_msg);
36 	itimer.it_value = itimer.it_interval = wait;
37 	setitimer(ITIMER_REAL, &itimer, (struct timerval *)0);
38 }
39 
40 end_msgs()
41 {
42 
43 	signal(SIGALRM, SIG_IGN);
44 	timerclear(&itimer.it_value);
45 	timerclear(&itimer.it_interval);
46 	setitimer(ITIMER_REAL, &itimer, (struct timerval *)0);
47 }
48