www.digitalmars.com [Home] [Search] [Contents]

controlc/cerror


cerror_close

Header

cerror.h

Prototype

void __cdecl cerror_close(void);

Description

Removes a user supplied critical handler. The handler should have previously been installed by cerror_open().

Compatibility

DOS Windows 3.x Phar Lap DOSX Win32

See Also

cerror_open

Example

See cerror_open

cerror_open

Header

cerror.h

Prototype

void __cdecl cerror_open(void);

Description

Installs a user supplied critical handler. This function, which you must write, uses the following prototype:

void __cdecl _cerror_handler(unsigned short *ax, unsigned short *di);

After a call to cerror_open, this routine begins receiving critical errors. It stops receiving them with a call to cerror_close.

Critical errors can occur under MS-DOS during attempts to access floppy disk drives or while using a parallel printer. They can cause the Abort, Retry, Ignore, Fail messages. Normally you have to write and debug a critical error handler for MS-DOS, and for each DOS extended platform you want to support.

The cerror_open and cerror_close functions provide a solution to this problem. They are portable across all platforms Digital Mars C++ supports.

Compatibility

DOS Windows 3.x Phar Lap DOSX Win32

See Also

cerror_close

Example

	/* 	Example for cerror_open 
		Also demonstrates cerror_close 
	*/ 

	#include <cerror.h> 
	#include <stdio.h> 
	#include <windows.h>
 
	static unsigned short ax_value, di_value; 

	void _cerror_handler (unsigned short *ax, 
			       unsigned short *di) 
	{ 
	  ax_value = *ax; 
	  di_value = *di; 
	} 

	void main () 
	{ 
	  printf (" Be sure there is no disk in A:\n"); 
	  getch (); 
	  cerror_open (); 

	  ax_value = di_value = 0; 
	  fopen ("a:anything", "r"); 
	  printf ("After trying to open A:ANYTHING, ax = %x, di = %x\n",
		ax_value, di_value); 

	  ax_value = di_value = 0;
	  fopen ("c:anything", "r"); 
	  printf ("After trying to open C:ANYTHING, ax = %x, di = %x\n",
		ax_value, di_value);
 
	  cerror_close (); 
	}
Output

	Be sure there is no disk in A:
	After trying to open A:ANYTHING, ax = 1a00, di = 2
	After trying to open C:ANYTHING, ax = 0, di = 0

controlc_close

Header

controlc.h

Prototype

void controlc_close(void);

Description

Removes a user supplied control c / break handler. The handler
should have previously been installed by controlc_open().

Compatibility

DOS Windows 3.x Phar Lap DOSX Win32

See Also

controlc_open

Example

See controlc_open

controlc_open

Header

controlc.h

Prototype

int controlc_open(void);

Description

Installs a user supplied control c/ break handler. A pointer to the handler should have been previously installed in the global variable _controlc_handler. The handler must be a far function that has void arguments and returns a void. It should be declared with C linkage (__cdecl).

Functions controlc_open and controlc_close are portable across all of the platforms Digital Mars C++ supports.

This function uses the following global variable:

void (__cdecl *_controlc_handler)(void);

To use the controlc_open function, install a pointer to your control c/ break handler in _controlc_handler, and then call controlc_open() to activate it.

Compatibility

DOS Windows 3.x Phar Lap DOSX Win32

See Also

controlc_close