home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / cscout.zip / INCLUDE / DATT.H
Text File  |  1995-06-12  |  8KB  |  171 lines

  1. /************************************************************************/
  2. /***                                                                  ***/
  3. /*** NAME              : DATT.h                                       ***/
  4. /***                                                                  ***/
  5. /*** PART OF           : C-Scout                                      ***/
  6. /***                                                                  ***/
  7. /*** SHORT DESCRIPTION : Include file for C-Scout toolkit             ***/
  8. /***                                                                  ***/
  9. /*** AUTHOR            : RH                                           ***/
  10. /***                                                                  ***/
  11. /*** COPYRIGHT         : (C) 1995 apriori computer solutions GmbH     ***/
  12. /***                                                                  ***/
  13. /************************************************************************/
  14. #ifndef DATT_H
  15. #define DATT_H
  16.  
  17. /*----------------------------------------------*/
  18. /*  include files required for errno, _doserrno */
  19. /*----------------------------------------------*/
  20. #include <stdlib.h>
  21. #include <string.h>
  22.  
  23. /*----------------------------------------*/
  24. /*  default trace level for the TX macro  */
  25. /*----------------------------------------*/
  26. #ifndef DATT_TM_LEVEL
  27.   #define DATT_TM_LEVEL 0
  28. #endif
  29.  
  30. /*---------------------------------------------------*/
  31. /*  default trace level for the FncEntry/Exit macros */
  32. /*---------------------------------------------------*/
  33. #ifndef DATT_BASE_LEVEL
  34.   #define DATT_BASE_LEVEL 1000
  35. #endif
  36.  
  37. #define DATT_INT_TL        DATT_BASE_LEVEL
  38. #define DATT_INT_TL_ENTRY  DATT_INT_TL
  39. #define DATT_INT_TL_EXIT   DATT_INT_TL
  40.  
  41. /*----------------------------------------------------------------------*/
  42. /* macros                                                               */
  43. /*----------------------------------------------------------------------*/
  44.  
  45. #if ( !defined __IBMC__ && !defined __IBMCPP__ )
  46. #define __FUNCTION__  "N/A"
  47. #endif
  48.  
  49. #ifdef DATT_OFF
  50.    #define TX( exp )      exp
  51.    #define FncEntry()
  52.    #define FncExit(rc)    return (rc)
  53.    #define FncExitVoid()  return
  54.  
  55. #else
  56. /*------------------------*/
  57. /*  FncEntry/Exit macros  */
  58. /*------------------------*/
  59.    #define FncEntry() \
  60.            Tracef( DATT_INT_TL_ENTRY, "%s(%d), FNC ENTRY : %s", \
  61.                      __FILE__, __LINE__, __FUNCTION__ )
  62.  
  63.    #define FncExit(rc) \
  64.            Tracef( DATT_INT_TL_EXIT,  "%s(%d), FNC EXIT  : %s - RC : rc %ld", \
  65.                    __FILE__, __LINE__, __FUNCTION__ , rc); \
  66.            return (rc)
  67.  
  68.    #define FncExitVoid() \
  69.            Tracef( DATT_INT_TL_EXIT,  "%s(%d), FNC EXIT  : %s", \
  70.                   __FILE__, __LINE__, __FUNCTION__ ); \
  71.            return
  72.  
  73. /*------------------------*/
  74. /*  TX macro              */
  75. /*------------------------*/
  76.    #define TX( exp ) \
  77.    { \
  78.       ULONG    ulOrd = 0;   \
  79.       APIRET   _apirc_ = 0;   \
  80.       ulOrd = DATT_Ser ( __FUNCTION__, __FILE__, __LINE__, DATT_TM_LEVEL ); \
  81.       _apirc_ = (APIRET)(exp); \
  82.       if (_apirc_) { \
  83.          DATT_Check( ulOrd, __FUNCTION__, __FILE__, __LINE__, DATT_TM_LEVEL, \
  84.                      #exp, _apirc_, errno, strerror(errno), _doserrno ); \
  85.          errno = 0; _doserrno = 0; } \
  86.       else  \
  87.          DATT_Check( ulOrd, __FUNCTION__, __FILE__, __LINE__, DATT_TM_LEVEL, \
  88.                      #exp, _apirc_, 0, NULL, 0 ); \
  89.    }
  90. #endif
  91.  
  92. /*----------------------------------------------------------------------*/
  93. /* typedefs                                                             */
  94. /*----------------------------------------------------------------------*/
  95.  
  96. /*----------------------------------------------------------------------*/
  97. /* TX - test expression macro information.                              */
  98. /* The structure below describes the TX macro Information package       */
  99. /* which will be given to a registered critical error handler if the    */
  100. /* TX macro expression is TRUE.                                         */
  101. /*----------------------------------------------------------------------*/
  102.  
  103. /*----------------------------*/
  104. /* defines for the structure  */
  105. /*----------------------------*/
  106. #define  FN_SIZE 121                /* max size of function name */
  107. #define  SL_SIZE 256                /* max size of source line   */
  108. #define  EM_SIZE 128                /* max size of error message */
  109.  
  110. typedef struct __TXmacroInfo
  111.     {
  112.     UCHAR      szFunction[FN_SIZE];       /* function name                    */
  113.     UCHAR      szModuleName[CCHMAXPATH];  /* name of module                   */
  114.     ULONG      ulLineNo;                  /* current line number              */
  115.     UCHAR      szSourceLine[SL_SIZE];     /* current source line              */
  116.     APIRET     apiretRc;                  /* result of expression in TX macro */
  117.     INT        iErrNo;                    /* c runtime errno                  */
  118.     INT        iDosErrNo;                 /* c runtime dos error code         */
  119.     UCHAR      szErrBuff1 [EM_SIZE];      /* PM return code text              */
  120.     UCHAR      szErrBuff2 [EM_SIZE];      /* Kernel return code text          */
  121.     UCHAR      szErrBuff3 [EM_SIZE];      /* CRT return code text             */
  122.     TID        tid;                       /* TID                              */
  123.     PID        pid;                       /* PID                              */
  124.     }    _TXmacroInfo;
  125.  
  126. typedef _TXmacroInfo * PTXMI;
  127.  
  128. /*--------------------------------------------------*/
  129. /* typydef for the critical error handler routine   */
  130. /*--------------------------------------------------*/
  131. typedef BOOL   APIENTRY FNCONHANDLER( PTXMI  ptxBuffer );
  132. typedef FNCONHANDLER * PFNCH;
  133.  
  134. /*----------------------------------------------------------------------*/
  135. /* declarations                                                         */
  136. /*----------------------------------------------------------------------*/
  137. VOID APIENTRY HexTrace( const  ULONG  ulLevel,
  138.                         const  PVOID  pvData,
  139.                         const  ULONG  ulDataLen );
  140.  
  141. VOID APIENTRY Tracef( const  ULONG  ulLevel,
  142.                       const  PSZ    pszFormat,
  143.                       ...);
  144.  
  145. VOID APIENTRY SetErrorInfo ( const PFNCH  pfnConditionHandler );
  146.  
  147. /*----------------------------------------------------------------------*/
  148. /* Functions called by the macros                                       */
  149. /*----------------------------------------------------------------------*/
  150. ULONG APIENTRY DATT_Ser ( const PSZ    pszFunction,
  151.                           const PSZ    pszFile,
  152.                           const ULONG  ulLine,
  153.                           const ULONG  ulLevel );
  154.  
  155. APIRET APIENTRY DATT_Check ( const   ULONG   ulOrdinal,
  156.                              const   PSZ     pszFunction,
  157.                              const   PSZ     pszFile,
  158.                              const   ULONG   ulLine,
  159.                              const   ULONG   ulLevel,
  160.                              const   PSZ     pszSourceLine,
  161.                              const   APIRET  apiretRc,
  162.                              const   int     iErrNo,
  163.                              const   PSZ     pszErrInfo,
  164.                              const   int     iDosErrNo );
  165.  
  166. #endif
  167.  
  168. /************************************************************************/
  169. /*** EOF DATT.h                                                       ***/
  170. /************************************************************************/
  171.