1 /*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
7 * with the License.
8 *
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
13 *
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 *
20 * CDDL HEADER END
21 */
22 /*
23 * Copyright 1994 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 */
26
27 /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
28 /* All Rights Reserved */
29
30 /*
31 * University Copyright- Copyright (c) 1982, 1986, 1988
32 * The Regents of the University of California
33 * All Rights Reserved
34 *
35 * University Acknowledgment- Portions of this document are derived from
36 * software developed by the University of California, Berkeley, and its
37 * contributors.
38 */
39
40 /*
41 * a package to display what is happening every MSG_INTERVAL seconds
42 * if we are slow connecting.
43 */
44
45 #include <signal.h>
46 #include <stdio.h>
47 #include <sys/time.h>
48 #include "talk.h"
49
50 #ifdef SYSV
51 #define signal(s, f) sigset(s, f)
52 #endif /* SYSV */
53
54 #define MSG_INTERVAL 4
55 #define LONG_TIME 100000
56
57 char *current_state;
58 int current_line = 0;
59
60 static struct itimerval itimer;
61 static struct timeval wait = { MSG_INTERVAL, 0};
62
63
64 static void
disp_msg()65 disp_msg()
66 {
67 message(current_state);
68 }
69
70 void
start_msgs()71 start_msgs()
72 {
73 message(current_state);
74 signal(SIGALRM, (void (*)())disp_msg);
75 itimer.it_value = itimer.it_interval = wait;
76 setitimer(ITIMER_REAL, &itimer, (struct itimerval *)0);
77 }
78
79 void
end_msgs()80 end_msgs()
81 {
82 signal(SIGALRM, SIG_IGN);
83 timerclear(&itimer.it_value);
84 timerclear(&itimer.it_interval);
85 setitimer(ITIMER_REAL, &itimer, (struct itimerval *)0);
86 }
87