141 lines
3.5 KiB
C++
141 lines
3.5 KiB
C++
|
//
|
||
|
// _DBGPM.CPP
|
||
|
//
|
||
|
// Source file for ArchiveLib 1.0
|
||
|
//
|
||
|
// Copyright (c) Greenleaf Software, Inc. 1994
|
||
|
// All Rights Reserved
|
||
|
//
|
||
|
// CONTENTS
|
||
|
//
|
||
|
// _ALAssertFailure()
|
||
|
//
|
||
|
// REVISION HISTORY
|
||
|
//
|
||
|
// February 14, 1996 2.0A : New release
|
||
|
//
|
||
|
//
|
||
|
|
||
|
#include "arclib.h"
|
||
|
#if !defined( AL_IBM )
|
||
|
#pragma hdrstop
|
||
|
#endif
|
||
|
|
||
|
#include <stdio.h>
|
||
|
#include <stdlib.h>
|
||
|
#include <stdarg.h>
|
||
|
|
||
|
//
|
||
|
// NAME
|
||
|
//
|
||
|
// _ALAssertFailure()
|
||
|
//
|
||
|
// PLATFORMS/ENVIRONMENTS
|
||
|
//
|
||
|
// PM
|
||
|
// C++
|
||
|
//
|
||
|
// SHORT DESCRIPTION
|
||
|
//
|
||
|
// Function used to print an assertion failure under PM.
|
||
|
//
|
||
|
// C++ SYNOPSIS
|
||
|
//
|
||
|
// #include "arclib.h"
|
||
|
//
|
||
|
// void _ALAssertFailure( const char *condition,
|
||
|
// const char *filename,
|
||
|
// int line,
|
||
|
// const char *message,
|
||
|
// ... );
|
||
|
//
|
||
|
// C SYNOPSIS
|
||
|
//
|
||
|
// None, this is an internal C++ support function.
|
||
|
//
|
||
|
// VB SYNOPSIS
|
||
|
//
|
||
|
// None, this is an internal C++ support function.
|
||
|
//
|
||
|
// DELPHI SYNOPSIS
|
||
|
//
|
||
|
// None, this is an internal C++ support function.
|
||
|
//
|
||
|
// ARGUMENTS
|
||
|
//
|
||
|
// condition : A character string containing the condition that failed,
|
||
|
// leading to the assertion.
|
||
|
//
|
||
|
// filename : The name of the file where the assertion error took place.
|
||
|
//
|
||
|
// line : The line in the file where the assertion error took place.
|
||
|
//
|
||
|
// message : The error message associated with the assertion error.
|
||
|
// This message is a sprintf() style format string.
|
||
|
//
|
||
|
// ... : Any additional arguments.
|
||
|
//
|
||
|
// DESCRIPTION
|
||
|
//
|
||
|
// The C run time library features an assert() macro, that can be used to
|
||
|
// abort a program if a given condition isn't true. It aborts the program
|
||
|
// by calling a routine that looks something like this. The AL_ASSERT()
|
||
|
// macro that we use is even better, because it includes a comment
|
||
|
// that gets displayed when the abort takes place. This routine is
|
||
|
// responsible for displaying that comment, along with the file name and
|
||
|
// the line number, then aborting the program. It is called by the
|
||
|
// AL_ASSERT() macro when the conditional expression argument fails.
|
||
|
//
|
||
|
// This is a special version of the function that gets called when the
|
||
|
// program in question is running under the Presentation Manager. Instead
|
||
|
// of trying to display the error message with a printf() statement, it
|
||
|
// formats it and puts it into a message box.
|
||
|
//
|
||
|
// RETURNS
|
||
|
//
|
||
|
// Nothing
|
||
|
//
|
||
|
// EXAMPLE
|
||
|
//
|
||
|
// SEE ALSO
|
||
|
//
|
||
|
// REVISION HISTORY
|
||
|
//
|
||
|
// February 14, 1996 2.0A : New release
|
||
|
//
|
||
|
|
||
|
void AL_CFUNCTION
|
||
|
_ALAssertFailure( const char AL_DLL_FAR *condition, /* Tag debug function */
|
||
|
const char AL_DLL_FAR *filename,
|
||
|
int line,
|
||
|
const char AL_DLL_FAR *message,
|
||
|
... )
|
||
|
{
|
||
|
char buf1[ 256 ];
|
||
|
char buf2[ 128 ];
|
||
|
va_list argptr;
|
||
|
|
||
|
va_start( argptr, message );
|
||
|
vsprintf( buf2, message, argptr );
|
||
|
va_end( argptr );
|
||
|
|
||
|
sprintf
|
||
|
( buf1,
|
||
|
"Assertion error, ArchiveLib is aborting the application.\n"
|
||
|
"Condition = %s\n"
|
||
|
"File = %s, line = %d\n"
|
||
|
"%s",
|
||
|
condition,
|
||
|
filename,
|
||
|
line,
|
||
|
buf2 );
|
||
|
WinMessageBox( HWND_DESKTOP,
|
||
|
0,
|
||
|
buf1,
|
||
|
" ArchiveLib assertion error ",
|
||
|
0,
|
||
|
MB_ICONEXCLAMATION );
|
||
|
abort();
|
||
|
}
|
||
|
|