| 1 | // |
|---|
| 2 | // TxWin, Textmode Windowing Library |
|---|
| 3 | // |
|---|
| 4 | // Original code Copyright (c) 1995-2005 Fsys Software and Jan van Wijk |
|---|
| 5 | // |
|---|
| 6 | // ========================================================================== |
|---|
| 7 | // |
|---|
| 8 | // This file contains Original Code and/or Modifications of Original Code as |
|---|
| 9 | // defined in and that are subject to the GNU Lesser General Public License. |
|---|
| 10 | // You may not use this file except in compliance with the License. |
|---|
| 11 | // BY USING THIS FILE YOU AGREE TO ALL TERMS AND CONDITIONS OF THE LICENSE. |
|---|
| 12 | // A copy of the License is provided with the Original Code and Modifications, |
|---|
| 13 | // and is also available at http://www.dfsee.com/txwin/lgpl.htm |
|---|
| 14 | // |
|---|
| 15 | // This library is free software; you can redistribute it and/or modify |
|---|
| 16 | // it under the terms of the GNU Lesser General Public License as published |
|---|
| 17 | // by the Free Software Foundation; either version 2.1 of the License, |
|---|
| 18 | // or (at your option) any later version. |
|---|
| 19 | // |
|---|
| 20 | // This library is distributed in the hope that it will be useful, |
|---|
| 21 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 22 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|---|
| 23 | // See the GNU Lesser General Public License for more details. |
|---|
| 24 | // |
|---|
| 25 | // You should have received a copy of the GNU Lesser General Public License |
|---|
| 26 | // along with this library; (lgpl.htm) if not, write to the Free Software |
|---|
| 27 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 28 | // |
|---|
| 29 | // Questions on TxWin licensing can be directed to: txwin@fsys.nl |
|---|
| 30 | // |
|---|
| 31 | // ========================================================================== |
|---|
| 32 | // |
|---|
| 33 | // TxLib filesystem functions, Critical-error handling |
|---|
| 34 | // |
|---|
| 35 | |
|---|
| 36 | #include <txlib.h> // TxLib interface |
|---|
| 37 | #include <txtpriv.h> // private interface |
|---|
| 38 | |
|---|
| 39 | |
|---|
| 40 | #if defined (DOS32) |
|---|
| 41 | ULONG TxAutoFail = 1; // start in AutoFail for DOS |
|---|
| 42 | #else |
|---|
| 43 | ULONG TxAutoFail = 0; // but NOT for OS/2 and WIN! |
|---|
| 44 | #endif // to assure first autofail |
|---|
| 45 | // call to succeeed |
|---|
| 46 | |
|---|
| 47 | |
|---|
| 48 | /*****************************************************************************/ |
|---|
| 49 | // Set critical error handling to auto-fail (versus interactive Abort, retry .) |
|---|
| 50 | // Calls to this may be nested, autofail is ON until matching fail==false call |
|---|
| 51 | /*****************************************************************************/ |
|---|
| 52 | void TxFsAutoFailCriticalErrors |
|---|
| 53 | ( |
|---|
| 54 | BOOL fail // IN autofail on CritErr |
|---|
| 55 | ) |
|---|
| 56 | { |
|---|
| 57 | ENTER(); |
|---|
| 58 | TRACES(( "TxAutoFail: %lu, fail: %s\n", TxAutoFail, (fail) ? "TRUE" : "NO")); |
|---|
| 59 | |
|---|
| 60 | if ((fail == FALSE) && (TxAutoFail != 0)) |
|---|
| 61 | { |
|---|
| 62 | if (--TxAutoFail == 0) // 0 after decrement |
|---|
| 63 | { |
|---|
| 64 | #if defined (WIN32) |
|---|
| 65 | SetErrorMode( 0); |
|---|
| 66 | #elif defined (DEV32) |
|---|
| 67 | DosError( FERR_ENABLEHARDERR); |
|---|
| 68 | #endif |
|---|
| 69 | } |
|---|
| 70 | } |
|---|
| 71 | else if (fail) |
|---|
| 72 | { |
|---|
| 73 | if (TxAutoFail++ == 0) // 0 before increment |
|---|
| 74 | { |
|---|
| 75 | #if defined (WIN32) |
|---|
| 76 | SetErrorMode( SEM_FAILCRITICALERRORS); |
|---|
| 77 | #elif defined (DEV32) |
|---|
| 78 | DosError( FERR_DISABLEHARDERR); |
|---|
| 79 | #endif |
|---|
| 80 | } |
|---|
| 81 | } |
|---|
| 82 | //- Note: DOS TX-handler will obey the TxAutoFail level directly ... |
|---|
| 83 | VRETURN(); |
|---|
| 84 | } // end 'TxFsAutoFailCriticalErrors' |
|---|
| 85 | /*---------------------------------------------------------------------------*/ |
|---|