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