xref: /original-bsd/old/talk/talk/msgs.c (revision 7e5c8007)
1 /*-
2  * Copyright (c) 1983, 1985
3  *	The Regents of the University of California.  All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  */
7 
8 #ifndef lint
9 static char sccsid[] = "@(#)msgs.c	5.1 (Berkeley) 6/6/85";
10 #endif not lint
11 
12 /*
13  * A package to display what is happening every MSG_INTERVAL seconds
14  * if we are slow connecting.
15  */
16 
17 #include <signal.h>
18 #include <stdio.h>
19 #include <sys/time.h>
20 #include "talk.h"
21 
22 #define MSG_INTERVAL 4
23 #define LONG_TIME 100000
24 
25 char	*current_state;
26 int	current_line = 0;
27 
28 static	struct itimerval itimer;
29 static	struct timeval wait = { MSG_INTERVAL , 0};
30 static	struct timeval undo = { LONG_TIME, 0};
31 
32 void
33 disp_msg()
34 {
35 
36 	message(current_state);
37 }
38 
39 start_msgs()
40 {
41 
42 	message(current_state);
43 	signal(SIGALRM, disp_msg);
44 	itimer.it_value = itimer.it_interval = wait;
45 	setitimer(ITIMER_REAL, &itimer, (struct itimerval *)0);
46 }
47 
48 end_msgs()
49 {
50 
51 	signal(SIGALRM, SIG_IGN);
52 	timerclear(&itimer.it_value);
53 	timerclear(&itimer.it_interval);
54 	setitimer(ITIMER_REAL, &itimer, (struct itimerval *)0);
55 }
56