Leaked source code of windows server 2003
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.

151 lines
3.2 KiB

  1. /*++
  2. Copyright (c) 1997 Microsoft Corporation
  3. Module Name:
  4. stilib.h
  5. Abstract:
  6. Various library definitions , common for multiple STI subprojects
  7. Author:
  8. Vlad Sadovsky (vlads) 26-Jan-1997
  9. Revision History:
  10. 26-Jan-1997 VladS created
  11. --*/
  12. #ifndef _INC_STILIB
  13. #define _INC_STILIB
  14. # if !defined( dllexp)
  15. # define dllexp __declspec( dllexport)
  16. # endif // !defined( dllexp)
  17. #include <linklist.h>
  18. #include <buffer.h>
  19. //#include <stistr.h>
  20. #ifdef __cplusplus
  21. extern "C" { /* Assume C declarations for C++ */
  22. #endif /* __cplusplus */
  23. #if !defined(DEBUG)
  24. #if defined(_DEBUG) || defined(DBG)
  25. #define DEBUG
  26. #endif
  27. #endif
  28. #ifdef DBCS
  29. #define IS_LEAD_BYTE(c) IsDBCSLeadByte(c)
  30. #else
  31. #define IS_LEAD_BYTE(c) 0
  32. #endif
  33. #ifdef DEBUG
  34. void cdecl nprintf(const char *, ...);
  35. #endif
  36. #ifdef DBCS
  37. #define ADVANCE(p) (p += IS_LEAD_BYTE(*p) ? 2 : 1)
  38. #else
  39. #define ADVANCE(p) (++p)
  40. #endif
  41. #define SPN_SET(bits,ch) bits[(ch)/8] |= (1<<((ch) & 7))
  42. #define SPN_TEST(bits,ch) (bits[(ch)/8] & (1<<((ch) & 7)))
  43. int sbufchkf(const char FAR *, unsigned short);
  44. // I_IsBadStringPtrA()
  45. //
  46. // Private Win32 version of IsBadStringPtr that works properly, i.e.
  47. // like the Win16 version, it returns TRUE if the string is not
  48. // null-terminated.
  49. BOOL WINAPI I_IsBadStringPtrA(LPCSTR lpsz, UINT ucchMax);
  50. //
  51. //
  52. //
  53. #define IS_EMPTY_STRING(pch) (!(pch) || !(*(pch)))
  54. //
  55. // String run-time calls
  56. //
  57. //
  58. #define strcpyf(d,s) lstrcpy((d),(s))
  59. #define strcatf(d,s) lstrcat((d),(s))
  60. #define strlenf(s) lstrlen((s))
  61. #define strcmpf(s1,s2) lstrcmp(s1,s2)
  62. #define stricmpf(s1,s2) lstrcmpi(s1,s2)
  63. #pragma intrinsic(memcmp,memset)
  64. #define memcmpf(d,s,l) memcmp((d),(s),(l))
  65. #define memsetf(s,c,l) memset((s),(c),(l))
  66. #define memmovef(d,s,l) MoveMemory((d),(s),(l))
  67. #define memcpyf(d,s,l) CopyMemory((d),(s),(l))
  68. /*
  69. * WaitAndYield processes all input messages. WaitAndProcessSends only
  70. * processes SendMessages.
  71. *
  72. * WaitAndYield takes an optional parameter which is the ID of another
  73. * thread concerned with the waiting. If it's not NULL, WM_QUIT messages
  74. * will be posted to that thread's queue when they are seen in the message
  75. * loop.
  76. */
  77. DWORD WaitAndYield(HANDLE hObject, DWORD dwTimeout, volatile DWORD *pidOtherThread = NULL);
  78. DWORD WaitAndProcessSends(HANDLE hObject, DWORD dwTimeout);
  79. //
  80. // Message box routines
  81. //
  82. #define IDS_MSGTITLE 1024
  83. //extern int MsgBox( HWND hwndDlg, UINT idMsg, UINT wFlags, const STR **aps = NULL );
  84. //extern UINT MsgBoxPrintf(HWND hwnd,UINT uiMsg,UINT uiTitle,UINT uiFlags,...);
  85. //extern UINT LoadMsgPrintf(STR& strMessage,UINT uiMsg,...);
  86. //
  87. // Registry access class
  88. //
  89. //#include <regentry.h>
  90. #ifdef __cplusplus
  91. }
  92. #endif /* __cplusplus */
  93. #if !defined(DBG) && !defined(DEBUG)
  94. //
  95. // Overloaded allocation operators
  96. //
  97. inline void * __cdecl operator new(size_t size)
  98. {
  99. return (void *)LocalAlloc(LPTR,size);
  100. }
  101. inline void __cdecl operator delete(void *ptr)
  102. {
  103. LocalFree(ptr);
  104. }
  105. #if 0
  106. inline UINT __cdecl allocated_size(void *ptr)
  107. {
  108. return ptr ? (UINT)LocalSize(ptr) : 0;
  109. }
  110. #endif
  111. #endif
  112. #endif /* _INC_STILIB */