mitrace.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /*
  2. * Licensed Materials - Property of IBM and/or HCL
  3. *
  4. * IBM Informix Dynamic Server
  5. * (c) Copyright IBM Corporation 1996, 2004 All rights reserved.
  6. * (c) Copyright HCL Technologies Ltd. 2017. All Rights Reserved.
  7. *
  8. ***************************************************************************
  9. *
  10. * Title: mitrace.h
  11. * Description:
  12. * Public tracing header
  13. *
  14. ***************************************************************************
  15. */
  16. #ifndef _MITRACE_H_
  17. #define _MITRACE_H_
  18. /* INCLUDES */
  19. #ifndef FILE
  20. #include <stdio.h>
  21. #endif /* FILE */
  22. #define MI_IDENTSIZE 128
  23. #define MI_OLDIDENTSIZE 18
  24. #define MI_LOCALESIZE 36
  25. #define MI_MSGSIZE 256
  26. #define MI_LIST_END (char *)NULL
  27. /* TYPE DEFINITIONS */
  28. #ifndef _MI_TRACE_STRUCTURES_
  29. #define _MI_TRACE_STRUCTURES_
  30. /* Trace vector internal structure */
  31. typedef struct _classRec
  32. {
  33. mi_string className[MI_OLDIDENTSIZE];
  34. mi_integer classID;
  35. mi_integer level;
  36. } MI_CLASS_RECORD;
  37. typedef struct mi_tracevect
  38. {
  39. mi_integer tv_numel;
  40. FILE *tv_file;
  41. mi_integer (*tv_prfunc)
  42. ARGS((const char *fmt, ...));
  43. MI_CONNECTION *tv_conn;
  44. MI_CLASS_RECORD tv_vect[1];
  45. } MI_TRACE_VECTOR;
  46. /* Trace messages internal structure */
  47. typedef struct _traceMsg
  48. {
  49. mi_string msgName[MI_IDENTSIZE];
  50. mi_integer msgID;
  51. mi_string locale[MI_LOCALESIZE];
  52. mi_string message[MI_MSGSIZE];
  53. } MI_TRACE_MSG;
  54. typedef struct _mi_tracemsg_list
  55. {
  56. mi_integer tml_numel;
  57. mi_string traceLocale[MI_LOCALESIZE];
  58. MI_TRACE_MSG msgEl[1];
  59. } MI_TRACEMSG_LIST;
  60. #endif /* _MI_TRACE_STRUCTURES_ */
  61. /* FUNCTION PROTOTYPES */
  62. EXTERNC_BEGIN
  63. MI_DECL void MI_PROC_EXPORT mi_trace ARGS((const char *s));
  64. MI_DECL mi_integer MI_PROC_EXPORT mi_tracelevel_set ARGS((const mi_string *setCommands));
  65. MI_DECL mi_integer MI_PROC_EXPORT mi_tracefile_set ARGS((const mi_string *fname));
  66. MI_DECL mi_integer MI_PROC_VAEXPORT mi_def_tprintf ARGS((const char *fmt, ...));
  67. MI_DECL mi_integer MI_PROC_VAEXPORT mi_gl_tprintf ARGS((const char *fmt, ...));
  68. MI_DECL MI_TRACE_VECTOR MI_PROC_EXPORT ** mi_trace_getvect ARGS((void));
  69. MI_DECL MI_TRACEMSG_LIST MI_PROC_EXPORT ** mi_tracemsg_getlist ARGS((void));
  70. MI_DECL mi_integer MI_PROC_EXPORT be_mapsym(char *s);
  71. MI_DECL mi_boolean MI_PROC_EXPORT mi_thresh_reached ARGS((const mi_string *codeClass,
  72. mi_integer codeLevel));
  73. EXTERNC_END
  74. /* MACRO DEFINITIONS */
  75. #ifndef MI_TV
  76. #define MI_TV (*(mi_trace_getvect()))
  77. #endif /* ! MI_TV */
  78. #ifndef MI_ML
  79. #define MI_ML (*(mi_tracemsg_getlist()))
  80. #endif /* ! MI_ML */
  81. /* Printing function */
  82. #ifndef __cplusplus
  83. #define MI_TPRINTF ((MI_TV != NULL) && (MI_TV->tv_prfunc != NULL) ? MI_TV->tv_prfunc : mi_def_tprintf)
  84. #define MI_GL_TPRINTF mi_gl_tprintf
  85. #else /* __cplusplus */
  86. #define MI_TPRINTF mi_def_tprintf
  87. #define MI_GL_TPRINTF mi_gl_tprintf
  88. #endif /* __cplusplus */
  89. #ifndef MITRACE_OFF
  90. /* flag is at least rev */
  91. #define MI_TFLAG(flag, lev) ((MI_TV != NULL && be_mapsym(flag) <= MI_TV->tv_numel) ? MI_TV->tv_vect[be_mapsym(flag)].level >= lev : 0)
  92. /* return the level of flag */
  93. #define MI_TFLEV(flag) ((MI_TV != NULL && be_mapsym(flag) <= MI_TV->tv_numel) ? MI_TV->tv_vect[be_mapsym(flag)].level : 0)
  94. #define MI_DPRINTF(flag, level, args) if (MI_TFLAG(flag, level)) MI_TPRINTF args
  95. #define MI_GL_DPRINTF(flag, level, args) if (MI_TFLAG(flag, level)) MI_GL_TPRINTF args
  96. #else /* MITRACE_OFF */
  97. #define MI_TFLAG(flag, lev) MI_FALSE
  98. #define MI_TFLEV(flag) 0
  99. #define MI_DPRINTF(flag, level, args) /* do nothing */
  100. #define MI_GL_DPRINTF(flag, level, args) /* do nothing */
  101. #endif /* MITRACE_OFF */
  102. #define tf MI_TFLAG
  103. #define tflev MI_TFLEV
  104. #define DPRINTF MI_DPRINTF
  105. #define GL_DPRINTF MI_GL_DPRINTF
  106. #define tprintf MI_TPRINTF
  107. #define gl_tprintf MI_GL_TPRINTF
  108. #endif /* _MITRACE_H_ */