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.

110 lines
2.5 KiB

  1. /****************************************************************************\
  2. JCOHEN.H / OPK Wizard (OPKWIZ.EXE)
  3. Microsoft Confidential
  4. Copyright (c) Microsoft Corporation 1999
  5. All rights reserved
  6. Contains common macros, defined values, and other stuff I use all the
  7. time.
  8. 1/98 - Jason Cohen (JCOHEN)
  9. Originally created as a helper header file for all my projects.
  10. 4/99 - Jason Cohen (JCOHEN)
  11. Added this new header file for the OPK Wizard as part of the
  12. Millennium rewrite.
  13. 09/2000 - Stephen Lodwick (STELO)
  14. Ported OPK Wizard to Whistler
  15. \****************************************************************************/
  16. #ifndef _JCOHEN_H_
  17. #define _JCOHEN_H_
  18. //
  19. // Include files
  20. //
  21. #include <windows.h>
  22. #include <tchar.h>
  23. #ifdef NULLSTR
  24. #undef NULLSTR
  25. #endif // NULLSTR
  26. #define NULLSTR _T("\0")
  27. #ifdef NULLCHR
  28. #undef NULLCHR
  29. #endif // NULLCHR
  30. #define NULLCHR _T('\0')
  31. //
  32. // Macros.
  33. //
  34. // Memory managing macros.
  35. //
  36. #ifdef MALLOC
  37. #undef MALLOC
  38. #endif // MALLOC
  39. #define MALLOC(cb) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, cb)
  40. #ifdef REALLOC
  41. #undef REALLOC
  42. #endif // REALLOC
  43. #define REALLOC(lp, cb) HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, lp, cb)
  44. #ifdef FREE
  45. #undef FREE
  46. #endif // FREE
  47. #define FREE(lp) ( (lp != NULL) ? ( (HeapFree(GetProcessHeap(), HEAP_NO_SERIALIZE, (LPVOID) lp)) ? ((lp = NULL) == NULL) : (FALSE) ) : (FALSE) )
  48. #ifdef NETFREE
  49. #undef NETFREE
  50. #endif // NETFREE
  51. #define NETFREE(lp) ( (lp != NULL) ? ( (NetApiBufferFree((LPVOID) lp)) ? ((lp = NULL) == NULL) : (FALSE) ) : (FALSE) )
  52. // Misc. macros.
  53. //
  54. #ifdef EXIST
  55. #undef EXIST
  56. #endif // EXIST
  57. #define EXIST(lpFileName) ( (GetFileAttributes(lpFileName) == 0xFFFFFFFF) ? (FALSE) : (TRUE) )
  58. #ifdef ISNUM
  59. #undef ISNUM
  60. #endif // ISNUM
  61. #define ISNUM(cChar) ( ((cChar >= _T('0')) && (cChar <= _T('9'))) ? (TRUE) : (FALSE) )
  62. #ifdef UPPER
  63. #undef UPPER
  64. #endif // UPPER
  65. #define UPPER(x) ( ( (x >= _T('a')) && (x <= _T('z')) ) ? (x + _T('A') - _T('a')) : (x) )
  66. #ifdef RANDOM
  67. #undef RANDOM
  68. #endif // RANDOM
  69. #define RANDOM(low, high) ( (high - low + 1) ? (rand() % (high - low + 1) + low) : (0) )
  70. #ifdef COMP
  71. #undef COMP
  72. #endif // COMP
  73. #define COMP(x, y) ( (UPPER(x) == UPPER(y)) ? (TRUE) : (FALSE) )
  74. #ifdef STRSIZE
  75. #undef STRSIZE
  76. #endif // STRSIZE
  77. #define STRSIZE(sz) ( sizeof(sz) / sizeof(TCHAR) )
  78. #ifdef ARRAYSIZE
  79. #undef ARRAYSIZE
  80. #endif // ARRAYSIZE
  81. #define ARRAYSIZE(a) ( sizeof(a) / sizeof(a[0]) )
  82. #endif // _JCOHEN_H_