home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / k / ksh48.zip / sh / trace.h < prev    next >
C/C++ Source or Header  |  1992-05-03  |  2KB  |  107 lines

  1. /* NAME:
  2.  *      trace.h - definitions for a simple trace facility
  3.  *
  4.  * SYNOPSIS:
  5.  *      #include "trace.h"
  6.  *
  7.  * DESCRIPTION:
  8.  *      Defines the macro _TRACE().
  9.  *      Also declares Trace_log and Trace_level.
  10.  *
  11.  * SEE ALSO:
  12.  *
  13.  *
  14.  * AMENDED:
  15.  *      91/11/22  22:53:58  (sjg)
  16.  *
  17.  * RELEASED:
  18.  *      91/11/22  22:54:18  v1.2
  19.  *
  20.  * SCCSID:
  21.  *      @(#)trace.h  1.2  91/11/22  22:53:58  (sjg)
  22.  *
  23.  *      @(#)Copyright (c) 1990 Simon J. Gerraty.
  24.  */
  25.  
  26. /* some useful #defines */
  27. #ifndef EXTERN
  28. # define EXTERN extern
  29. # define EXTERN_DEFINED
  30. #endif
  31.  
  32. #ifndef TRUE
  33. # define TRUE  1
  34. # define FALSE 0
  35. #endif
  36. #ifndef ARGS
  37. # if defined(__STDC__) || defined(PROTO)
  38. #   define ARGS(p) p
  39. # else
  40. #   define ARGS(p) ()
  41. # endif
  42. #endif
  43.  
  44. /*
  45.  * this garbage is sometimes needed when mixing
  46.  * langauges or calling conventions under DOS.
  47.  */
  48. #ifndef _CDECL
  49. # if defined(MSDOS) || defined(MSC)
  50. #   ifndef NO_EXT_KEYS
  51. #     define _CDECL  cdecl
  52. #     define _NEAR   near
  53. #   else
  54. #     define _CDECL
  55. #     define _NEAR
  56. #   endif
  57. # else /* not DrOS */
  58. #   define _CDECL
  59. #   define _NEAR
  60. # endif /* DOS */
  61. #endif /* _CDECL */
  62.  
  63. /* manifest constants */
  64.  
  65. /* struct / union */
  66.  
  67. /* macros */
  68.  
  69.  
  70. #ifdef USE_TRACE
  71. EXTERN char * _CDECL    Trace_log;
  72. EXTERN int _CDECL     Trace_level;
  73.  
  74. void _CDECL checkpoint    ARGS((char *fmt, ...));
  75.  
  76. /*
  77.  * This macro takes a variabel number of args.
  78.  * examples:
  79.  *     _TRACE(5, ("The current Debug level is %d\n", Debug));
  80.  * Note that if more than two args are provided, all but the
  81.  * first (which should be an integer indicating the Trace-level
  82.  * required for this message to be printed) must be enclosed in
  83.  * parenthesis.
  84.  */
  85. # define _TRACE(lev, args) if (Trace_level >= lev) checkpoint args
  86. #else     /* don't USE_TRACE */
  87.   /*
  88.    * this macro evaluates to a harmless no entry
  89.    * loop that most optimizers will remove all together.
  90.    */
  91. # define _TRACE(l, args) while (0)
  92. #endif     /* USE_TRACE */
  93.  
  94.  
  95. /* This lot goes at the END */
  96. /* be sure not to interfere with anyone else's idea about EXTERN */
  97. #ifdef EXTERN_DEFINED
  98. # undef EXTERN_DEFINED
  99. # undef EXTERN
  100. #endif
  101. /*
  102.  * Local Variables:
  103.  * version-control:t
  104.  * comment-column:40
  105.  * End:
  106.  */
  107.