Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

138 lines
3.5 KiB

  1. //
  2. // DEFS.H Common macros for the Local Fax Project.
  3. //
  4. // History:
  5. // 2/27/94 JosephJ Created.
  6. //
  7. #define MAX_PATHNAME_SIZE 128
  8. #if defined(DEBUG)
  9. # define DEBUG_CODE // debug-related functionality (the "Test" menu)
  10. # define USE_IPC // Enable IPC communication.
  11. # define ENABLE_LOGGING
  12. # define ASSERT(cond)\
  13. if(!(cond)){LOG_ERR((_ERR, "**** ASSERTION FAILURE *** %s:%d",\
  14. (LPSTR)__FILE__, (int)__LINE__));}
  15. #else // DEBUG
  16. # define ASSERT(cond)\
  17. LOGSTMT({if (!(cond)) {LOG_ERR((_ERR, "Assert Fail %s:%d",\
  18. (LPSTR)__FILE__, (int)__LINE__));}})
  19. #endif // !DEBUG
  20. #ifdef WIN32
  21. #define MYFAR
  22. #else
  23. #define MYFAR __far
  24. #endif
  25. // Logging related.
  26. #ifdef ENABLE_LOGGING
  27. //# define COMPNAME "xxx"
  28. //# define SUBCOMPNAME "yyy"
  29. //# define FUNCNAME "zzz"
  30. # define _WRN "<<WRN>>", COMPNAME, SUBCOMPNAME, FUNCNAME
  31. # define _ERR "<<ERR>>", COMPNAME, SUBCOMPNAME, FUNCNAME
  32. # define _MSG "Message", COMPNAME, SUBCOMPNAME, FUNCNAME
  33. # define _ENTRY " Enter", COMPNAME, SUBCOMPNAME, FUNCNAME
  34. # define _EXITS " Exit", COMPNAME, SUBCOMPNAME, FUNCNAME
  35. # define _EXITF "Exit(FAIL)", COMPNAME, SUBCOMPNAME, FUNCNAME
  36. # define _TS NULL, NULL, NULL, NULL
  37. # define LOGSTMT(expr) expr
  38. // +++ following are old style, should be replaced by LOG(..) macro below
  39. # define LOG_MSG(args) log_log args
  40. # define ODS(str) OutputDebugString(str)
  41. # define LOG_ENTRY(str) log_log(_ENTRY, "%s", str)
  42. # define LOG_EXIT_SUCCESS(str) log_log(_EXITS, "%s", str)
  43. # define LOG_EXIT_FAILURE(str) log_log(_EXITF, "%s", str)
  44. # define LOG_ERR(args) log_log args
  45. # define LOG_WRN(args) log_log args
  46. # define LOG(args) log_log args
  47. #define MYCDECL __cdecl
  48. #define MYLPSTR char MYFAR *
  49. #ifndef _DEF_FILE_
  50. void MYFAR MYCDECL log_log(
  51. MYLPSTR lpszComp,
  52. MYLPSTR lpszSubComp,
  53. MYLPSTR lpszFunc,
  54. MYLPSTR lpszType,
  55. MYLPSTR lpszFmt,
  56. ...
  57. );
  58. #endif // _DEF_FILE_
  59. #else // !ENABLE_LOGGING
  60. # define LOGSTMT(expr)
  61. # define LOG_MSG(args)
  62. # define ODS(str)
  63. # define LOG_ENTRY(str)
  64. # define LOG_EXIT_SUCCESS(str)
  65. # define LOG_EXIT_FAILURE(str)
  66. # define LOG_ERR(args)
  67. # define LOG_WRN(args)
  68. # define LOG(args)
  69. #endif // !ENABLE_LOGGING
  70. # define POLLREQ // Poll request
  71. #ifndef _DEF_FILE_
  72. typedef unsigned int MYFAR * LPUINT;
  73. #endif // _DEF_FILE_
  74. #ifdef WIN32
  75. #define TAPI
  76. #define MYWEP \
  77. int _export CALLBACK WEP(int type)
  78. #define MYLIBMAIN \
  79. int _export CALLBACK WEP(int type); \
  80. BOOL _export WINAPI LibMain(HINSTANCE hinst, DWORD dwReason, LPVOID lpv)
  81. #define MYLIBSTARTUP(_szName) \
  82. LOG_MSG((_MSG, "LibMain called reason=%lu.P=0x%lx.T=0x%lx\r\n",\
  83. (unsigned long) dwReason,\
  84. (unsigned long) GetCurrentProcessId(),\
  85. (unsigned long) GetCurrentThreadId()\
  86. ));\
  87. if(dwReason==DLL_THREAD_ATTACH || dwReason==DLL_THREAD_DETACH) \
  88. return TRUE; \
  89. if(dwReason==DLL_PROCESS_DETACH) \
  90. return WEP(0);\
  91. if(dwReason==DLL_PROCESS_ATTACH && (_szName)) \
  92. { \
  93. HMODULE hM = GetModuleHandle(_szName); \
  94. if (hM) DisableThreadLibraryCalls(hM); \
  95. }
  96. #define MYLIBSHUTDOWN
  97. #define ADAPTIVE_ANSWER
  98. #else // !WIN32
  99. #define MYWEP \
  100. int __export WINAPI WEP (int nParam)
  101. #define MYLIBMAIN \
  102. int __export WINAPI WEP (int nParam);\
  103. BOOL _export WINAPI LibMain(HINSTANCE hinst, DWORD dwReason, LPVOID lpv)
  104. #define MYLIBSTARTUP() \
  105. if (wHeapSize > 0) UnlockData(0);
  106. #endif // !WIN32