/* Copyright 1996 Acorn Computers Ltd
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/*
        Provide debugging for Filer_Action.
*/

#include <stdio.h>
#include <stdarg.h>

#include "os.h"

#include "debug.h"

#ifdef debug

#ifdef debugfile
FILE *debugf = NULL;
#endif

void
dprintf( const char *str, ... )
{
        va_list arg_pointer;

#ifdef debugfile
        if ( debugf == NULL ) debugf = fopen( debugfile, "w" );
        if ( debugf == NULL ) return;
#else
#ifdef debugtube
        os_swi0( 0x40100 );
#endif
#endif

        va_start( arg_pointer, str );

#ifdef debugfile
        vfprintf( debugf, str, arg_pointer );
#else
        vprintf( str, arg_pointer );
#endif

        va_end( arg_pointer );

#ifndef debugfile
#ifdef debugtube
        os_swi0( 0x40101 );
#endif
#endif
}

#endif