(* Title  : trace.h
 * Purpose: centralised control for trace/debug output
 *
 *)

#ifndef __trace_h
#define __trace_h

(* This flag says if tracing is compiled in. It should be used in
conditional compilation statements around all tracing code. *)

#ifdef TRACE
   (* ------------------------------- tracef -------------------------------
    * Description:   Outputs tracing info.
    *
    * Parameters:    char* -- printf-style format string
    *                ...   -- variable argument list
    * Returns:       void.
    * Other Info:    called by tracef0,tracef1 etc.
    *
    *)
   procedure tracef(fmt : string, ..); extern;

   #define tracef0 tracef
   #define tracef1 tracef
   #define tracef2 tracef
   #define tracef3 tracef
   #define tracef4 tracef

   (* These forms can occur outside conditional compilation clauses:
   they will produce no code if TRACE is not set. *)

   function trace_is_on : boolean; extern;
                                   (* returns true if tracing turned on *)
   procedure trace_on; extern;     (* turns tracing on *)
   procedure trace_off; extern;    (* turns tracing off *)
#else
   (* No-trace versions *)

   (* tracef itself cannot be done as a macro. *)
   procedure tracef(fmt : string; ..); extern;

   #define tracef0(a) ((void) 0)
   #define tracef1(a,b) ((void) 0)
   #define tracef2(a,b,c) ((void) 0)
   #define tracef3(a,b,c,d) ((void) 0)
   #define tracef4(a,b,c,d,e) ((void) 0)

   #define trace_is_on() 0
   #define trace_on() ((void) 0)
   #define trace_off() ((void) 0)
#endif

#endif

(* end trace.h *)
