/*******************************************************************

Copyright (c) 2004 Open Mobile Alliance, Ltd.  All Rights Reserved.

This software is made available under the usage and distribution terms 
covered by the Common Public License 1.0 and by using this software you
are bound by the terms and conditions of the same.

EXCEPT AS EXPRESSLY SET FORTH IN THE COMMON PUBLIC LICENSE,
THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, 
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 
EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, 
ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, 
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
   
Each recipient is solely responsible for determining the 
appropriateness of using and distributing this program and assumes 
all risks associated with its exercise of rights under the Common 
Public License, including but not limited to the risks and 
costs of program errors, compliance with applicable laws, 
damage to or loss of data, programs or equipment, and 
unavailability or interruption of operations.

********************************************************************/
#ifndef OBEXDEBUG_H
#define OBEXDEBUG_H

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

//#define DEBUGERROR
//#define DEBUGINFO
//#define DEBUGFLOW
//#define DEBUGALL
#if defined( DEBUGALL )
  #define OBXDBGMEM(msg) outputStorage msg
  #define OBXDBGBUF(msg) iobxDebug msg
  #define OBXDBGFLOW(msg) iobxDebug msg
  #define OBXDBGINFO(msg) iobxDebug msg
  #define OBXDBGERR(msg) iobxDebug msg
  #ifdef _WIN32
   #define WIN32_LEAN_AND_MEAN
   #include <winsock.h>
   #define OBXDBGSOCKERR() _describeWin32SocketError()
  #else
   #define OBXDBGSOCKERR()
  #endif
#elif defined( DEBUGFLOW )
  #define OBXDBGMEM(msg)
  #define OBXDBGBUF(msg)
  #define OBXDBGFLOW(msg) iobxDebug msg
  #define OBXDBGINFO(msg) iobxDebug msg
  #define OBXDBGERR(msg) iobxDebug msg
  #ifdef _WIN32
   #define WIN32_LEAN_AND_MEAN
   #include <winsock.h>
   #define OBXDBGSOCKERR() _describeWin32SocketError()
  #else
   #define OBXDBGSOCKERR()
  #endif
#elif defined( DEBUGINFO )
  #define OBXDBGMEM(msg)
  #define OBXDBGBUF(msg)
  #define OBXDBGFLOW(msg)
  #define OBXDBGINFO(msg) iobxDebug msg
  #define OBXDBGERR(msg) iobxDebug msg
  #ifdef _WIN32
   #define WIN32_LEAN_AND_MEAN
   #include <winsock.h>
   #define OBXDBGSOCKERR() _describeWin32SocketError()
  #else
   #define OBXDBGSOCKERR()
  #endif
#elif defined( DEBUGERROR )
  #define OBXDBGMEM(msg)
  #define OBXDBGBUF(msg)
  #define OBXDBGFLOW(msg)
  #define OBXDBGINFO(msg)
  #define OBXDBGERR(msg) iobxDebug msg
  #ifdef _WIN32
   #define WIN32_LEAN_AND_MEAN
   #include <winsock.h>
   #define OBXDBGSOCKERR() _describeWin32SocketError()
  #else
   #define OBXDBGSOCKERR()
  #endif
#else
  #define OBXDBGMEM(msg)
  #define OBXDBGBUF(msg)
  #define OBXDBGFLOW(msg)
  #define OBXDBGINFO(msg)
  #define OBXDBGERR(msg)
  #define OBXDBGSOCKERR()
#endif

#ifdef __cplusplus
extern "C" {
#endif

#if defined( DEBUGALL ) || defined( DEBUGFLOW ) || defined( DEBUGINFO ) || defined( DEBUGERROR )
 void iobxDebug( const char *format, ... );
 #if defined( DEBUGALL )
  void  outputStorage( const char *tagline, const void *mem, int length );
 #endif
 #if defined(_WIN32)
  void _describeWin32SocketError();
 #endif
#endif

#ifdef __cplusplus
}
#endif

#endif
