/* Copyright 1999 Element 14 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.
 */
#ifndef __PDebug__h
#define __PDebug__h

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

#ifndef __kernel_h
  #include "kernel.h"
#endif


#ifdef PDebug_DEBUG

  #ifdef __cplusplus
  extern "C" {
  #endif

  /*
    Raises Desk_Error2 exception if an error occurs. Don't use this when
    linking with the stand-alone version of PDebug.

    See PDebug_XInit for an error-returning version.
  */
  void PDebug_Init (void);

  /*
    Initialises the PDebug system.
  */
  _kernel_oserror *PDebug_XInit (void);


  /*
    Similar to printf().
  */
  int PDebug_Printf (const char *fmt, ...);

  /*
    Similar to vprintf().
  */
  int PDebug_VPrintf (const char *fmt, va_list va);

  /*
    Similar to fprintf(). 'dummy' is ignored - behaves exactly as
    PDebug_Printf().
  */
  int PDebug_FPrintf (FILE *dummy, const char *fmt, ...);

  /*
    Sends the specified data. Returns non-0 if failed
  */
  void PDebug_Print (const void *data, int datasize);

  /*
    Raises Desk_Error2 exception if an error occurs. Don't use this when
    linking with the stand-alone version of PDebug.

    See PDebug_XFinal for an error-returning version.
  */
  void PDebug_Final (void);

  /*
    Shuts down the PDebug system
  */
  _kernel_oserror *PDebug_XFinal (void);

  /*
    Returns the version of the library
  */
  const char *PDebug_Version (void);

  #ifdef __cplusplus
  }
  #endif

#else
  #define PDebug_Init()
  #define PDebug_XInit() 0
  #define PDebug_Printf(1) ? 0 : printf
  #define PDebug_VPrintf(1) ? 0 : vprintf
  #define PDebug_FPrintf(1) ? 0 : fprintf
  #define PDebug_Print(data, datasize)
  #define PDebug_Final()
  #define PDebug_XFinal() 0
  #define PDebug_Version()
#endif

#endif
