Esempio n. 1
0
void trace(int level, char_t *fmt, ...)
{
	va_list 	args;
	char_t		*buf;

	va_start(args, fmt);
	fmtValloc(&buf, VALUE_MAX_STRING, fmt, args);

	if (traceHandler) {
		traceHandler(level, buf);
	}
	bfreeSafe(B_L, buf);
	va_end(args);
}
Esempio n. 2
0
void error( E_ARGS_DEC, int etype, char_t* fmt, ... )
{
    va_list 	args;
    char_t*		fmtBuf, *buf;
    va_start( args, fmt );
    fmtValloc( &fmtBuf, E_MAX_ERROR, fmt, args );

    if ( etype == E_LOG )
    {
        fmtAlloc( &buf, E_MAX_ERROR, T( "%s\n" ), fmtBuf );
        /*#ifdef DEV*/
    }

    else if ( etype == E_ASSERT )
    {
        fmtAlloc( &buf, E_MAX_ERROR,
                  T( "Assertion %s, failed at %s %d\n" ), fmtBuf, E_ARGS );
        /*#endif*/
    }

    else if ( etype == E_USER )
    {
        fmtAlloc( &buf, E_MAX_ERROR, T( "%s\n" ), fmtBuf );
    }

    /*
     * bugfix -- if etype is not E_LOG, E_ASSERT, or E_USER, the call to
     * bfreeSafe(B_L, buf) below will fail, because 'buf' is randomly
     * initialized. To be nice, we format a message saying that this is an
     * unknown message type, and in doing so give buf a valid value. Thanks
     * to Simon Byholm.
     */
    else
    {
        fmtAlloc( &buf, E_MAX_ERROR, T( "Unknown error" ) );
    }

    va_end( args );
    bfree( B_L, fmtBuf );

    if ( errorHandler )
    {
        errorHandler( etype, buf );
    }

    bfreeSafe( B_L, buf );
}