version 1.1.1.1, 1996/09/21 05:39:43 |
version 1.1.1.2, 2003/04/13 18:21:21 |
|
|
/* |
/* |
* Copyright (c) 1984,1985,1989,1994,1995 Mark Nudelman |
* Copyright (C) 1984-2002 Mark Nudelman |
* All rights reserved. |
|
* |
* |
* Redistribution and use in source and binary forms, with or without |
* You may distribute under the terms of either the GNU General Public |
* modification, are permitted provided that the following conditions |
* License or the Less License, as specified in the README file. |
* are met: |
|
* 1. Redistributions of source code must retain the above copyright |
|
* notice, this list of conditions and the following disclaimer. |
|
* 2. Redistributions in binary form must reproduce the above copyright |
|
* notice in the documentation and/or other materials provided with |
|
* the distribution. |
|
* |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY |
* For more information about less, or for information on how to |
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
* contact the author, see the README file. |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE |
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT |
|
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
|
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE |
|
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN |
|
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
*/ |
*/ |
|
|
|
|
|
|
int type; |
int type; |
{ |
{ |
#if OS2 |
#if OS2 |
SIGNAL(SIGINT, SIG_ACK); |
LSIGNAL(SIGINT, SIG_ACK); |
#endif |
#endif |
SIGNAL(SIGINT, u_interrupt); |
LSIGNAL(SIGINT, u_interrupt); |
sigs |= S_INTERRUPT; |
sigs |= S_INTERRUPT; |
|
#if MSDOS_COMPILER==DJGPPC |
|
/* |
|
* If a keyboard has been hit, it must be Ctrl-C |
|
* (as opposed to Ctrl-Break), so consume it. |
|
* (Otherwise, Less will beep when it sees Ctrl-C from keyboard.) |
|
*/ |
|
if (kbhit()) |
|
getkey(); |
|
#endif |
if (reading) |
if (reading) |
intread(); |
intread(); |
} |
} |
|
|
stop(type) |
stop(type) |
int type; |
int type; |
{ |
{ |
SIGNAL(SIGTSTP, stop); |
LSIGNAL(SIGTSTP, stop); |
sigs |= S_STOP; |
sigs |= S_STOP; |
if (reading) |
if (reading) |
intread(); |
intread(); |
|
|
winch(type) |
winch(type) |
int type; |
int type; |
{ |
{ |
SIGNAL(SIGWINCH, winch); |
LSIGNAL(SIGWINCH, winch); |
sigs |= S_WINCH; |
sigs |= S_WINCH; |
if (reading) |
if (reading) |
intread(); |
intread(); |
|
|
winch(type) |
winch(type) |
int type; |
int type; |
{ |
{ |
SIGNAL(SIGWIND, winch); |
LSIGNAL(SIGWIND, winch); |
sigs |= S_WINCH; |
sigs |= S_WINCH; |
if (reading) |
if (reading) |
intread(); |
intread(); |
|
|
#endif |
#endif |
#endif |
#endif |
|
|
|
#if MSDOS_COMPILER==WIN32C |
/* |
/* |
|
* Handle CTRL-C and CTRL-BREAK keys. |
|
*/ |
|
#include "windows.h" |
|
|
|
static BOOL WINAPI |
|
wbreak_handler(dwCtrlType) |
|
DWORD dwCtrlType; |
|
{ |
|
switch (dwCtrlType) |
|
{ |
|
case CTRL_C_EVENT: |
|
case CTRL_BREAK_EVENT: |
|
sigs |= S_INTERRUPT; |
|
return (TRUE); |
|
default: |
|
break; |
|
} |
|
return (FALSE); |
|
} |
|
#endif |
|
|
|
/* |
* Set up the signal handlers. |
* Set up the signal handlers. |
*/ |
*/ |
public void |
public void |
|
|
/* |
/* |
* Set signal handlers. |
* Set signal handlers. |
*/ |
*/ |
(void) SIGNAL(SIGINT, u_interrupt); |
(void) LSIGNAL(SIGINT, u_interrupt); |
|
#if MSDOS_COMPILER==WIN32C |
|
SetConsoleCtrlHandler(wbreak_handler, TRUE); |
|
#endif |
#ifdef SIGTSTP |
#ifdef SIGTSTP |
(void) SIGNAL(SIGTSTP, stop); |
(void) LSIGNAL(SIGTSTP, stop); |
#endif |
#endif |
#ifdef SIGWINCH |
#ifdef SIGWINCH |
(void) SIGNAL(SIGWINCH, winch); |
(void) LSIGNAL(SIGWINCH, winch); |
#else |
#else |
#ifdef SIGWIND |
#ifdef SIGWIND |
(void) SIGNAL(SIGWIND, winch); |
(void) LSIGNAL(SIGWIND, winch); |
#endif |
#endif |
|
#ifdef SIGQUIT |
|
(void) LSIGNAL(SIGQUIT, SIG_IGN); |
#endif |
#endif |
|
#endif |
} else |
} else |
{ |
{ |
/* |
/* |
* Restore signals to defaults. |
* Restore signals to defaults. |
*/ |
*/ |
(void) SIGNAL(SIGINT, SIG_DFL); |
(void) LSIGNAL(SIGINT, SIG_DFL); |
|
#if MSDOS_COMPILER==WIN32C |
|
SetConsoleCtrlHandler(wbreak_handler, FALSE); |
|
#endif |
#ifdef SIGTSTP |
#ifdef SIGTSTP |
(void) SIGNAL(SIGTSTP, SIG_DFL); |
(void) LSIGNAL(SIGTSTP, SIG_DFL); |
#endif |
#endif |
#ifdef SIGWINCH |
#ifdef SIGWINCH |
(void) SIGNAL(SIGWINCH, SIG_IGN); |
(void) LSIGNAL(SIGWINCH, SIG_IGN); |
#endif |
#endif |
#ifdef SIGWIND |
#ifdef SIGWIND |
(void) SIGNAL(SIGWIND, SIG_IGN); |
(void) LSIGNAL(SIGWIND, SIG_IGN); |
#endif |
#endif |
|
#ifdef SIGQUIT |
|
(void) LSIGNAL(SIGQUIT, SIG_DFL); |
|
#endif |
} |
} |
} |
} |
|
|
|
|
* Clean up the terminal. |
* Clean up the terminal. |
*/ |
*/ |
#ifdef SIGTTOU |
#ifdef SIGTTOU |
SIGNAL(SIGTTOU, SIG_IGN); |
LSIGNAL(SIGTTOU, SIG_IGN); |
#endif |
#endif |
clear_bot(); |
clear_bot(); |
deinit(); |
deinit(); |
flush(); |
flush(); |
raw_mode(0); |
raw_mode(0); |
#ifdef SIGTTOU |
#ifdef SIGTTOU |
SIGNAL(SIGTTOU, SIG_DFL); |
LSIGNAL(SIGTTOU, SIG_DFL); |
#endif |
#endif |
SIGNAL(SIGTSTP, SIG_DFL); |
LSIGNAL(SIGTSTP, SIG_DFL); |
kill(getpid(), SIGTSTP); |
kill(getpid(), SIGTSTP); |
/* |
/* |
* ... Bye bye. ... |
* ... Bye bye. ... |
|
|
* Reset the terminal and arrange to repaint the |
* Reset the terminal and arrange to repaint the |
* screen when we get back to the main command loop. |
* screen when we get back to the main command loop. |
*/ |
*/ |
SIGNAL(SIGTSTP, stop); |
LSIGNAL(SIGTSTP, stop); |
raw_mode(1); |
raw_mode(1); |
init(); |
init(); |
screen_trashed = 1; |
screen_trashed = 1; |