trace_h.old
上传用户:dzyhzl
上传日期:2019-04-29
资源大小:56270k
文件大小:21k
源码类别:

模拟服务器

开发平台:

C/C++

  1. /* trace.h */
  2. /*
  3.  * Copyright (c) Microsoft Corporation.  All rights reserved.
  4.  * All Rights Reserved.
  5.  */
  6. #if (defined(WIN32_SUPPORT) || defined(MSWIN_SUPPORT))
  7.  #ifndef DONT_INCLUDE_MEMORY_H
  8.   #include <memory.h>
  9.  #endif
  10. #endif
  11. #ifdef WIN32_SUPPORT
  12. #define sepudcpy(X,Y,Z) memcpy(X,Y,Z)
  13. #endif
  14. #ifdef DOS_SUPPORT
  15. #define SPRINTF(x)  com_sprintf x;
  16. extern int _CDECL far com_sprintf(char far *, const char far *, ...);
  17. #else
  18.  #if (defined(WIN32_SUPPORT) || defined(MSWIN_SUPPORT))
  19.   /***************************************************************************/
  20.   /* Temporary for Win32: in Win32 DLLs in PDK2, sprintf is not available:   */
  21.   /* use wsprintf instead.                                                   */
  22.   /***************************************************************************/
  23.   #define SPRINTF(x)  wsprintf x;
  24.  #else
  25.   #define SPRINTF(x)  sprintf x;
  26.  #endif
  27. #endif
  28. /*****************************************************************************/
  29. /* Comm Server Critical Section macros.                                      */
  30. /*****************************************************************************/
  31. #ifdef WIN32_SUPPORT
  32.  typedef struct cscritsec
  33.  {
  34.    BOOL             Inited;
  35.    CRITICAL_SECTION CritSec;
  36.  } CSCRITSEC;
  37.  #define CSENTERCRITSEC(x) if (!((x)->Inited))                                
  38.                              {                                                
  39.                                InitializeCriticalSection(&((x)->CritSec));    
  40.                                (x)->Inited = TRUE;                            
  41.                              }                                                
  42.                            EnterCriticalSection(&((x)->CritSec))
  43.  #define CSEXITCRITSEC(x)  LeaveCriticalSection(&((x)->CritSec))
  44.  #define CSLEAVECRITSEC(x)  LeaveCriticalSection(&((x)->CritSec))
  45. #endif
  46. /*****************************************************************************/
  47. /* Global flags and variables                                                */
  48. /*****************************************************************************/
  49. #ifdef MSWIN_SUPPORT
  50. #define com_str com_logstr
  51. #endif
  52. #ifdef WIN32_SUPPORT
  53.  extern CSCRITSEC crit_comlog;
  54.  extern CSCRITSEC crit_dlbtrc;
  55.  extern CSCRITSEC crit_dlblog;
  56.  extern UCHAR com_str[256];
  57.  extern UCHAR com_logstr[256];
  58. #else
  59.  #ifndef MSWIN_SUPPORT
  60.   extern ULONG  pascal com_trcsem;
  61.   extern ULONG  pascal com_logsem;
  62.   extern ULONG  pascal dlb_logsem;
  63.   extern ULONG  pascal dlb_trcsem;
  64.   extern UCHAR  pascal com_str[256];
  65.  #endif
  66. #endif
  67. #ifndef WIN32_SUPPORT
  68. extern UCHAR pascal com_logstr[256];
  69. #endif
  70. /*****************************************************************************/
  71. /* TRACEn macro definitions                                                  */
  72. /*****************************************************************************/
  73. #ifdef NOTRC
  74. #define TRCLVL  20
  75. #else
  76. #   ifndef TRCLVL
  77. #define TRCLVL  0
  78. #   endif
  79. #endif
  80. #ifdef WIN32_SUPPORT                                                   /*NTRC*/
  81.  #if TRCLVL < 3                                                        /*NTRC*/
  82.   #define TRACE2() TRACEX(2,(com_mod,                                  /*NTRC*/
  83.  #else                                                                 /*NTRC*/
  84.   #define TRACE2() TRACEZ((                                            /*NTRC*/
  85.  #endif                                                                /*NTRC*/
  86.  #if TRCLVL < 5                                                        /*NTRC*/
  87.   #define TRACE4() TRACEX(4,(com_mod,                                  /*NTRC*/
  88.  #else                                                                 /*NTRC*/
  89.   #define TRACE4() TRACEZ((                                            /*NTRC*/
  90.  #endif                                                                /*NTRC*/
  91.  #if TRCLVL < 7                                                        /*NTRC*/
  92.   #define TRACE6() TRACEX(6,(com_mod,                                  /*NTRC*/
  93.  #else                                                                 /*NTRC*/
  94.   #define TRACE6() TRACEZ((                                            /*NTRC*/
  95.  #endif                                                                /*NTRC*/
  96.  #if TRCLVL < 9                                                        /*NTRC*/
  97.   #define TRACE8() TRACEX(8,(com_mod,                                  /*NTRC*/
  98.  #else                                                                 /*NTRC*/
  99.   #define TRACE8() TRACEZ((                                            /*NTRC*/
  100.  #endif                                                                /*NTRC*/
  101.  #if TRCLVL < 11                                                       /*NTRC*/
  102.   #define TRACE10() TRACEX(10,(com_mod,                                /*NTRC*/
  103.  #else                                                                 /*NTRC*/
  104.   #define TRACE10() TRACEZ((                                           /*NTRC*/
  105.  #endif                                                                /*NTRC*/
  106.  #if TRCLVL < 13                                                       /*NTRC*/
  107.   #define TRACE12() TRACEX(12,(com_mod,                                /*NTRC*/
  108.  #else                                                                 /*NTRC*/
  109.   #define TRACE12() TRACEZ((                                           /*NTRC*/
  110.  #endif                                                                /*NTRC*/
  111.  #if TRCLVL < 17                                                       /*NTRC*/
  112.   #define TRACE16() TRACEX(16,(com_mod,                                /*NTRC*/
  113.  #else                                                                 /*NTRC*/
  114.   #define TRACE16() TRACEZ((                                           /*NTRC*/
  115.  #endif                                                                /*NTRC*/
  116. #else                                                                  /*NTRC*/
  117.  #if TRCLVL < 3
  118.   #define TRACE2() TRACEX(2,(com_str,
  119.  #else                                                                 /*NTRC*/
  120.   #define TRACE2() TRACEZ((
  121.  #endif
  122.  #if TRCLVL < 5
  123.   #define TRACE4() TRACEX(4,(com_str,
  124.  #else
  125.   #define TRACE4() TRACEZ((
  126.  #endif
  127.  #if TRCLVL < 7
  128.   #define TRACE6() TRACEX(6,(com_str,
  129.  #else
  130.   #define TRACE6() TRACEZ((
  131.  #endif
  132.  #if TRCLVL < 9
  133.   #define TRACE8() TRACEX(8,(com_str,
  134.  #else
  135.   #define TRACE8() TRACEZ((
  136.  #endif
  137.  #if TRCLVL < 11
  138.   #define TRACE10() TRACEX(10,(com_str,
  139.  #else
  140.   #define TRACE10() TRACEZ((
  141.  #endif
  142.  #if TRCLVL < 13
  143.   #define TRACE12() TRACEX(12,(com_str,
  144.  #else
  145.   #define TRACE12() TRACEZ((
  146.  #endif
  147.  #if TRCLVL < 17
  148.   #define TRACE16() TRACEX(16,(com_str,
  149.  #else
  150.   #define TRACE16() TRACEZ((
  151.  #endif
  152. #endif                                                                 /*NTRC*/
  153. #if TRCLVL < 20
  154.  #ifdef DOS_SUPPORT
  155.   #define TRACEX(w,x)                                                         
  156.                     if (ptrc && (w >= ptrc->intlvl)) {                        
  157.                       if (ptrc->nocat)                                        
  158.                         CMDSemRequest(&com_trcsem,10000);                     
  159.                       SPRINTF(x);                                             
  160.                       seputrc(w,com_mod);                                     
  161.                     }
  162.  #else
  163.   #ifdef MSWIN_SUPPORT
  164.    #define TRACEX(w,x)                                                        
  165.                       if (ptrc && (w >= ptrc->intlvl)) {                      
  166.                         SPRINTF(x);                                           
  167.                         seputrc(w,com_mod,ptrc, com_str);                     
  168.                       }
  169.   #else
  170.    #ifdef WIN32_SUPPORT
  171.     #define TRACEX(w,x) if (w >= ptrc->intlvl) InternalTrace x;        /*NTRC*/
  172.    #else
  173.     #define TRACEX(w,x)                                                       
  174.                     if (ptrc && (w >= ptrc->intlvl)) {                        
  175.                       DosSemRequest(&dlb_trcsem,10000L);                      
  176.                       SPRINTF(x);                                             
  177.                       seputrc_w(com_str,w,com_mod);                           
  178.                       DosSemClear(&dlb_trcsem);                               
  179.                     }
  180.    #endif
  181.   #endif
  182.  #endif
  183. #else
  184.  #define TRACEX(w,x)
  185. #endif
  186. #define TRACEZ(x)
  187. #if TRCLVL < 20
  188.  #ifdef DOS_SUPPORT
  189.   #define COM_ENTRY(x) UCHAR com_mod[6];                                      
  190.                        sepudcpy(com_mod,x,6)
  191.  #else
  192.   #ifdef WIN32_SUPPORT
  193.    #define COM_ENTRY(x) DWORD rc = 0;                                         
  194.                         DWORD rc2 = 0;                                        
  195.                         UCHAR com_mod[6];                                     
  196.                         sepudcpy(com_mod,x,6)
  197.   #else
  198.    #define COM_ENTRY(x) USHORT rc = 0;                                        
  199.                         UCHAR com_mod[6];                                     
  200.                         sepudcpy(com_mod,x,6)
  201.   #endif
  202.  #endif
  203. #else
  204.  #ifdef DOS_SUPPORT
  205.   #define COM_ENTRY(x)
  206.  #else
  207.   #ifdef WIN32_SUPPORT
  208.    #define COM_ENTRY(x) DWORD rc = 0; DWORD rc2=0
  209.   #else
  210.    #define COM_ENTRY(x) USHORT rc = 0;
  211.   #endif
  212.  #endif
  213. #endif
  214. #define COM_QUIT goto com_exit
  215. #define COM_EXIT com_exit:
  216. #define COM_EXIT_RC com_exit: return(rc)
  217. typedef struct trc {
  218.   USHORT    flags;                   /*0140* Make trace flags 2 bytes        */
  219. #define      DLCMSGS   0x0001        /* NODE TRACE CONTROL                   */
  220. #define      PVIMSGS   0x0002
  221. #define      FMIMSGS   0x0004
  222. #define      OTHMSGS   0x0008
  223. #define      NODEMSGS  0x000F        /* All node messages to be traced       */
  224. #define      SNAMSGS   0x0010        /* User wants DLC as SNA msgs           */
  225. #define      NOSNATRC  0x0020        /* SNA tracing not permitted            */
  226. #define      CPICMSGS  0x0040        /* CPIC messages                        */
  227. #define      LUAMSGS   0x0080        /* LUA/RUI trace control                */
  228. #define      HLLMSGS   0x0100        /* API trace control                    */
  229. #define      SRPIMSGS  0x0200
  230. #define      CSVMSGS   0x0400
  231. #define      APPCMSGS  0x0800
  232. #define      APIMSGS   0x0FC0        /*LUA* 0x0F00 -> 0x0F80 due to LUA flag */
  233.                                      /*CPIC*0x0f80 -> 0x0fc0 due to CPIC flag*/
  234. #define      LINKMSGS  0x1000        /* Link trace control                   */
  235. #define      NOTRACE   0x2000        /* API tracing not permitted            */
  236. #define      ADSTOP    0x4000        /* Stop/Dump options                    */
  237. #define      ADDUMP    0x8000
  238.   UCHAR     audlvl;                  /* Logging level                        */
  239.   USHORT    control;                 /* permission for user to control       */
  240.   USHORT    intlvl;                  /* Internal trace level                 */
  241.   USHORT    nocat;                   /* message concatenation flag           */
  242.   USHORT    apiinit;                 /* api tracing initialised              */
  243.   USHORT    asyinit;                 /* special asynch initialisation flag   */
  244.   USHORT    errinit;
  245.   USHORT    intinit;
  246.   USHORT    snainit;
  247. #if ( defined(WIN32_SUPPORT) || defined(MSWIN_SUPPORT) )
  248.   HANDLE    apihand1;                /* handles for various trace files      */
  249.   HANDLE    apihand2;
  250.   HANDLE    audhand;
  251.   HANDLE    errhand;
  252.   HANDLE    inthand1;
  253.   HANDLE    inthand2;
  254.   HANDLE    snahand1;
  255.   HANDLE    snahand2;
  256. #else
  257.   HFILE     apihand1;                /* handles for various trace files      */
  258.   HFILE     apihand2;
  259.   HFILE     audhand;
  260.   HFILE     errhand;
  261.   HFILE     inthand1;
  262.   HFILE     inthand2;
  263.   HFILE     snahand1;
  264.   HFILE     snahand2;
  265. #endif
  266. } TRC;
  267. #ifndef WIN32_SUPPORT
  268. extern TRC FAR * pascal ptrc;
  269. #else
  270. extern TRC FAR * ptrc;
  271. #endif
  272. /*****************************************************************************/
  273. /* COM_LOGn macro definitions                                                */
  274. /*****************************************************************************/
  275. #define COM_LOG6(x)  COM_LOG(6,x,(com_logstr,
  276. #define COM_LOG8(x)  COM_LOG(8,x,(com_logstr,
  277. #define COM_LOG10(x) COM_LOG(10,x,(com_logstr,
  278. #define COM_LOG12(x) COM_LOG(12,x,(com_logstr,
  279. #define COM_LOG16(x) COM_LOG(16,x,(com_logstr,
  280. #define COM_MSG6(x)  COM_MSG(6,x)
  281. #define COM_MSG8(x)  COM_MSG(8,x)
  282. #define COM_MSG10(x) COM_MSG(10,x)
  283. #define COM_MSG12(x) COM_MSG(12,x)
  284. #define COM_MSG16(x) COM_MSG(16,x)
  285. #define COM_ERR6(x)  COM_LOG(6,x,(com_logstr,"%d",ret))
  286. #define COM_ERR8(x)  COM_LOG(8,x,(com_logstr,"%d",ret))
  287. #define COM_ERR10(x) COM_LOG(10,x,(com_logstr,"%d",ret))
  288. #define COM_ERR12(x) COM_LOG(12,x,(com_logstr,"%d",ret))
  289. #define COM_ERR16(x) COM_LOG(16,x,(com_logstr,"%d",ret))
  290. #ifdef DOS_SUPPORT
  291.  #define COM_LOG(v,w,x)                                                       
  292.                     if (v >= ptrc->audlvl) {                                  
  293.                       CMDSemRequest(&com_logsem,10000);                       
  294.                       SPRINTF(x);                                             
  295.                       sepulog(v,w);                                           
  296.                     }
  297. #else
  298.  #ifdef MSWIN_SUPPORT
  299.   #define COM_LOG(v,w,x)                                                      
  300.                         if (v >= ptrc->audlvl) {                              
  301.                           SPRINTF(x);                                         
  302.                           sepulog(v,w,ptrc, com_logstr);                      
  303.                         }
  304.  #else
  305.   #ifndef WIN32_SUPPORT
  306.    #define COM_LOG(v,w,x)                                                     
  307.                        if (v >= ptrc->audlvl) {                               
  308.                          DosSemRequest(&dlb_logsem,10000L);                   
  309.                          SPRINTF(x);                                          
  310.                          sepulog_w(com_logstr,v,w);                           
  311.                          DosSemClear(&dlb_logsem);                            
  312.                        }
  313.   #else
  314.    #define COM_LOG(v,w,x)                                                     
  315.                        if (v >= ptrc->audlvl) {                               
  316.                          CSENTERCRITSEC(&crit_dlblog);                        
  317.                          SPRINTF(x);                                          
  318.                          sepulog_w(com_logstr,v,w);                           
  319.                          CSEXITCRITSEC(&crit_dlblog);                         
  320.                        }
  321.   #endif
  322.  #endif
  323.  #ifdef WIN32_SUPPORT
  324.   #define COM_MSG(v,w)                                                        
  325.                       if (v >= ptrc->audlvl) {                                
  326.                         CSENTERCRITSEC(&crit_dlblog);                         
  327.                         sepulog_w(com_logstr,v,w);                            
  328.                         CSEXITCRITSEC(&crit_dlblog);                          
  329.                       }
  330.  #else
  331.   #define COM_MSG(v,w)                                                        
  332.                       if (v >= ptrc->audlvl) {                                
  333.                         DosSemRequest(&dlb_logsem,10000L);                    
  334.                         sepulog_w(com_logstr,v,w);                            
  335.                         DosSemClear(&dlb_logsem);                             
  336.                       }
  337.  #endif
  338. /* Parameters are message #, target m/c                                      */
  339.  #define COM_ALERT(x,y) COM_ALERTX(x,y,(com_logstr,
  340.  #ifdef WIN32_SUPPORT
  341.   #define COM_ALERTX(x,y,z)                                                   
  342.                       {                                                       
  343.                         CSENTERCRITSEC(&crit_comlog);                         
  344.                         SPRINTF(z);                                           
  345.                         sepualrt(x,y,com_logstr,&crit_comlog);                
  346.                       }
  347.  #else
  348.   #define COM_ALERTX(x,y,z)                                                   
  349.                       {                                                       
  350.                         DosSemRequest(&com_logsem,10000L);                    
  351.                         SPRINTF(z);                                           
  352.                         sepualrt(x,y,com_logstr,&com_logsem);                 
  353.                       }
  354.  #endif
  355. #endif
  356. #define COM_ERROR(x) COM_LOG(16,x,(com_logstr,"%d",rc));                      
  357.                      rc = x
  358. #define COM_TRC_SNA(x)
  359. /*****************************************************************************/
  360. /* Trace macros for LUA/RUI/SLI tracing.                                     */
  361. /*****************************************************************************/
  362. #define INIT            0     /* Initial function for link services     */
  363. #define REQUEST         1
  364. #define RESPONSE        2
  365. #define POST            3
  366. #if (defined(DOS_SUPPORT) || defined(MSWIN_SUPPORT))
  367. extern VOID FAR pascal seputrlu(USHORT, UCHAR FAR *, TRC FAR *);
  368. #define COM_TRC_LUA(x,y)                                                
  369.                     if (ptrc && (ptrc->flags & LUAMSGS)) {              
  370.                       seputrlu(x,y,ptrc);                               
  371.                     }
  372. #else
  373.  #ifdef WIN32_SUPPORT
  374.    extern VOID WINAPI seputrlu(USHORT, UCHAR *);
  375.  #else
  376.    extern VOID FAR PASCAL seputrlu(USHORT, UCHAR FAR *);
  377.  #endif
  378. #define COM_TRC_LUA(x,y)                                                
  379.                     if (ptrc->flags & LUAMSGS) {                        
  380.                       seputrlu(x,y);                                    
  381.                     }
  382. #endif
  383. /*****************************************************************************/
  384. /* Defines for IHV tracing macros                                            */
  385. /*****************************************************************************/
  386. #ifdef WIN32_SUPPORT
  387. extern VOID WINAPI seputrhv(UCHAR *);
  388. extern VOID WINAPI sepdtrci(TRC **);
  389. #define COM_TRC_IHV(x)                                                  
  390.                     if (ptrc->flags & LINKMSGS) {                       
  391.                       seputrhv(x);                                      
  392.                     }
  393. #define INITIALIZE_TRACING sepdtrci(&ptrc)
  394. #endif
  395. /*****************************************************************************/
  396. /* Defines for Log messages                                                  */
  397. /*****************************************************************************/
  398. #define LOG_ALERT_REJ   392                     /* alert was rejected        */
  399. #define LOG_SESS_START  442                     /* user logged on            */
  400. #define LOG_SESS_END    443                     /* user logged off           */
  401. #define LOG_SESS_FAIL   444                     /* session lost              */
  402. #define LOG_EMUL_START  445                     /* emulation started         */
  403. #define LOG_EMUL_END    446                     /* emulation ended           */
  404. /*****************************************************************************/
  405. /* Function prototypes                                                       */
  406. /*****************************************************************************/
  407. #ifdef MSWIN_SUPPORT
  408. extern VOID pascal FAR seputrc(USHORT, UCHAR FAR *, TRC far *, UCHAR FAR *);
  409. extern VOID pascal FAR sepulog(USHORT, USHORT, TRC far *, UCHAR FAR *);
  410. #define sepudcpy(x,y,z) _fmemcpy(x,y,z)
  411. #else
  412.  #ifdef WIN32_SUPPORT
  413.   extern VOID  WINAPI seputrc(USHORT, UCHAR FAR *);
  414.   extern VOID  WINAPI seputrc_w(UCHAR FAR *, USHORT, UCHAR FAR *);
  415.   extern VOID  WINAPI sepulog(USHORT, USHORT);
  416.   extern VOID  WINAPI sepulog_w(UCHAR FAR *,USHORT, USHORT);
  417.   /***************************************************************************/
  418.   /* New internal trace function                                        *NTRC*/
  419.   /***************************************************************************/
  420.   extern VOID InternalTrace( UCHAR * ModName, UCHAR * FormatText, ...);
  421.  #else
  422.   extern USHORT APIENTRY sepudcpy(UCHAR FAR *, UCHAR FAR *, unsigned short);
  423.   extern VOID   APIENTRY seputrc(USHORT, UCHAR FAR *);
  424.   extern VOID   APIENTRY seputrc_w(UCHAR FAR *, USHORT, UCHAR FAR *);
  425.   extern VOID   APIENTRY sepulog(USHORT, USHORT);
  426.   extern VOID   APIENTRY sepulog_w(UCHAR FAR *,USHORT, USHORT);
  427.  #endif
  428. #endif
  429. #ifdef WIN32_SUPPORT
  430. extern VOID  WINAPI sepualrt(USHORT, UCHAR *, UCHAR *, CSCRITSEC *);
  431. #else
  432. #ifdef MSWIN_SUPPORT
  433. extern VOID pascal FAR sepualrt(USHORT, UCHAR FAR *, UCHAR FAR *, ULONG FAR *);
  434. #else
  435. extern VOID APIENTRY sepualrt(USHORT, UCHAR FAR *, UCHAR FAR *, ULONG FAR *);
  436. #endif
  437. #endif
  438. /* End of file trace.h */