init_disp.c (8874) | init_disp.c (14443) |
---|---|
1/* 2 * Copyright (c) 1983, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 39 unchanged lines hidden (view full) --- 48#include <unistd.h> 49#include <signal.h> 50#include <err.h> 51#include "talk.h" 52 53/* 54 * Make sure the callee can write to the screen 55 */ | 1/* 2 * Copyright (c) 1983, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 39 unchanged lines hidden (view full) --- 48#include <unistd.h> 49#include <signal.h> 50#include <err.h> 51#include "talk.h" 52 53/* 54 * Make sure the callee can write to the screen 55 */ |
56void check_writeable() | 56void 57check_writeable() |
57{ 58 char *tty; 59 struct stat sb; 60 61 if ((tty = ttyname(STDERR_FILENO)) == NULL) 62 err(1, "ttyname"); 63 if (stat(tty, &sb) < 0) 64 err(1, "%s", tty); 65 if (!(sb.st_mode & S_IWGRP)) 66 errx(1, "The callee cannot write to this terminal, use \"mesg y\"."); 67} 68 69/* 70 * Set up curses, catch the appropriate signals, 71 * and build the various windows. 72 */ | 58{ 59 char *tty; 60 struct stat sb; 61 62 if ((tty = ttyname(STDERR_FILENO)) == NULL) 63 err(1, "ttyname"); 64 if (stat(tty, &sb) < 0) 65 err(1, "%s", tty); 66 if (!(sb.st_mode & S_IWGRP)) 67 errx(1, "The callee cannot write to this terminal, use \"mesg y\"."); 68} 69 70/* 71 * Set up curses, catch the appropriate signals, 72 * and build the various windows. 73 */ |
74void |
|
73init_display() 74{ | 75init_display() 76{ |
75 void sig_sent(); | |
76 struct sigvec sigv; 77 78 if (initscr() == NULL) 79 errx(1, "Terminal type unset or lacking necessary features."); 80 (void) sigvec(SIGTSTP, (struct sigvec *)0, &sigv); 81 sigv.sv_mask |= sigmask(SIGALRM); 82 (void) sigvec(SIGTSTP, &sigv, (struct sigvec *)0); 83 curses_initialized = 1; --- 24 unchanged lines hidden (view full) --- 108 current_state = "No connection yet"; 109} 110 111/* 112 * Trade edit characters with the other talk. By agreement 113 * the first three characters each talk transmits after 114 * connection are the three edit characters. 115 */ | 77 struct sigvec sigv; 78 79 if (initscr() == NULL) 80 errx(1, "Terminal type unset or lacking necessary features."); 81 (void) sigvec(SIGTSTP, (struct sigvec *)0, &sigv); 82 sigv.sv_mask |= sigmask(SIGALRM); 83 (void) sigvec(SIGTSTP, &sigv, (struct sigvec *)0); 84 curses_initialized = 1; --- 24 unchanged lines hidden (view full) --- 109 current_state = "No connection yet"; 110} 111 112/* 113 * Trade edit characters with the other talk. By agreement 114 * the first three characters each talk transmits after 115 * connection are the three edit characters. 116 */ |
117void |
|
116set_edit_chars() 117{ 118 char buf[3]; 119 int cc; 120 struct sgttyb tty; 121 struct ltchars ltc; 122 123 ioctl(0, TIOCGETP, &tty); --- 13 unchanged lines hidden (view full) --- 137 cc = read(sockt, buf, sizeof(buf)); 138 if (cc != sizeof(buf) ) 139 p_error("Lost the connection"); 140 his_win.cerase = buf[0]; 141 his_win.kill = buf[1]; 142 his_win.werase = buf[2]; 143} 144 | 118set_edit_chars() 119{ 120 char buf[3]; 121 int cc; 122 struct sgttyb tty; 123 struct ltchars ltc; 124 125 ioctl(0, TIOCGETP, &tty); --- 13 unchanged lines hidden (view full) --- 139 cc = read(sockt, buf, sizeof(buf)); 140 if (cc != sizeof(buf) ) 141 p_error("Lost the connection"); 142 his_win.cerase = buf[0]; 143 his_win.kill = buf[1]; 144 his_win.werase = buf[2]; 145} 146 |
147/* ARGSUSED */ |
|
145void | 148void |
146sig_sent() | 149sig_sent(signo) 150 int signo; |
147{ 148 149 message("Connection closing. Exiting"); 150 quit(); 151} 152 153/* 154 * All done talking...hang up the phone and reset terminal thingy's 155 */ | 151{ 152 153 message("Connection closing. Exiting"); 154 quit(); 155} 156 157/* 158 * All done talking...hang up the phone and reset terminal thingy's 159 */ |
160void |
|
156quit() 157{ 158 159 if (curses_initialized) { 160 wmove(his_win.x_win, his_win.x_nlines-1, 0); 161 wclrtoeol(his_win.x_win); 162 wrefresh(his_win.x_win); 163 endwin(); 164 } 165 if (invitation_waiting) 166 send_delete(); 167 exit(0); 168} | 161quit() 162{ 163 164 if (curses_initialized) { 165 wmove(his_win.x_win, his_win.x_nlines-1, 0); 166 wclrtoeol(his_win.x_win); 167 wrefresh(his_win.x_win); 168 endwin(); 169 } 170 if (invitation_waiting) 171 send_delete(); 172 exit(0); 173} |