FreeDOS/kernel/break.c
Bart Oldeman b0e54ff704 (with a little help from Arkady)
inthndler.c, chario.c, break.c simplifications and cleanups.
Pass a near pointer to the far pointer that points to the device instead
of an SFT index (in general).
Make cooked_write much faster by only testing for input every 32
characters.
No longer test for ctl_s on syscon if writing to the printer: just
read from the printer which will return zero characters.
Fix reading/writing zero characters by returning "256" (special code).
Adjust interfaces in other files.


git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@683 6ac86273-5f31-0410-b378-82cca8765d1b
2003-09-09 17:43:43 +00:00

80 lines
3.4 KiB
C

/****************************************************************/
/* */
/* break.c */
/* FreeDOS */
/* */
/* Control Break detection and handling */
/* */
/* Copyright (c) 1999 */
/* Steffen Kaiser */
/* All Rights Reserved */
/* */
/* This file is part of DOS-C. */
/* */
/* DOS-C is free software; you can redistribute it and/or */
/* modify it under the terms of the GNU General Public License */
/* as published by the Free Software Foundation; either version */
/* 2, or (at your option) any later version. */
/* */
/* DOS-C is distributed in the hope that it will be useful, but */
/* WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */
/* the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public */
/* License along with DOS-C; see the file COPYING. If not, */
/* write to the Free Software Foundation, 675 Mass Ave, */
/* Cambridge, MA 02139, USA. */
/****************************************************************/
#include "portab.h"
#include "globals.h"
#include "proto.h"
extern void ASMCFUNC spawn_int23(void);
#ifdef VERSION_STRINGS
static BYTE *RcsId =
"$Id$";
#endif
#define CB_FLG *(UBYTE FAR*)MK_FP(0x40, 0x71)
#define CB_MSK 0x80
/* Check for ^Break.
* Two sources are available:
* 1) flag at 40:71 bit 7
* 2) STDIN stream via con_break()
*/
int check_handle_break(void)
{
if (CB_FLG & CB_MSK) {
CB_FLG &= ~CB_MSK; /* reset the ^Break flag */
handle_break(&syscon);
}
/* con_break will call handle_break() for CTL_C */
return con_break();
}
/*
* Handles a ^Break state
*
* Actions:
* 1) clear the ^Break flag
* 2) clear the STDIN stream
* 3) decrease the InDOS flag as the kernel drops back to user space
* 4) invoke INT-23 and never come back
*/
void handle_break(struct dhdr FAR **pdev)
{
echo_char_stdin(CTL_C);
con_flush(pdev);
if (!ErrorMode) /* within int21_handler, InDOS is not incremented */
if (InDOS)
--InDOS; /* fail-safe */
spawn_int23(); /* invoke user INT-23 and never come back */
}