1 /* $NetBSD: init_disp.c,v 1.10 2001/12/07 12:10:09 blymn Exp $ */
4 * Copyright (c) 1983, 1993
5 * The Regents of the University of California. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the University nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 #include <sys/cdefs.h>
35 static char sccsid
[] = "@(#)init_disp.c 8.2 (Berkeley) 2/16/94";
37 __RCSID("$NetBSD: init_disp.c,v 1.10 2001/12/07 12:10:09 blymn Exp $");
41 * Initialization code for the display package,
42 * as well as the signal handling routines.
46 #include <sys/ioctl.h>
47 #include <sys/ioctl_compat.h>
55 * Set up curses, catch the appropriate signals,
56 * and build the various windows.
63 if (initscr() == NULL
)
64 errx(1, "Terminal type unset or lacking necessary features.");
65 (void)sigaction(SIGTSTP
, NULL
, &sa
);
66 sigaddset(&sa
.sa_mask
, SIGALRM
);
67 (void)sigaction(SIGTSTP
, &sa
, NULL
);
68 curses_initialized
= 1;
73 signal(SIGINT
, sig_sent
);
74 signal(SIGPIPE
, sig_sent
);
75 /* curses takes care of ^Z */
76 my_win
.x_nlines
= LINES
/ 2;
77 my_win
.x_ncols
= COLS
;
78 my_win
.x_win
= newwin(my_win
.x_nlines
, my_win
.x_ncols
, 0, 0);
79 scrollok(my_win
.x_win
, FALSE
);
82 his_win
.x_nlines
= LINES
/ 2 - 1;
83 his_win
.x_ncols
= COLS
;
84 his_win
.x_win
= newwin(his_win
.x_nlines
, his_win
.x_ncols
,
85 my_win
.x_nlines
+1, 0);
86 scrollok(his_win
.x_win
, FALSE
);
87 wclear(his_win
.x_win
);
89 line_win
= newwin(1, COLS
, my_win
.x_nlines
, 0);
90 box(line_win
, '-', '-');
92 /* let them know we are working on it */
93 current_state
= "No connection yet";
97 * Trade edit characters with the other talk. By agreement
98 * the first three characters each talk transmits after
99 * connection are the three edit characters.
109 my_win
.cerase
= tty
.c_cc
[VERASE
];
110 my_win
.kill
= tty
.c_cc
[VKILL
];
111 if (tty
.c_cc
[VWERASE
] == (unsigned char) -1)
112 my_win
.werase
= '\027'; /* control W */
114 my_win
.werase
= tty
.c_cc
[VWERASE
];
115 buf
[0] = my_win
.cerase
;
116 buf
[1] = my_win
.kill
;
117 buf
[2] = my_win
.werase
;
118 cc
= write(sockt
, buf
, sizeof(buf
));
119 if (cc
!= sizeof(buf
) )
120 p_error("Lost the connection");
121 cc
= read(sockt
, buf
, sizeof(buf
));
122 if (cc
!= sizeof(buf
) )
123 p_error("Lost the connection");
124 his_win
.cerase
= buf
[0];
125 his_win
.kill
= buf
[1];
126 his_win
.werase
= buf
[2];
134 message("Connection closing. Exiting");
139 * All done talking...hang up the phone and reset terminal thingy's
145 if (curses_initialized
) {
146 wmove(his_win
.x_win
, his_win
.x_nlines
-1, 0);
147 wclrtoeol(his_win
.x_win
);
148 wrefresh(his_win
.x_win
);
151 if (invitation_waiting
)