home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / dbmsg / odbc / admndemo / standard.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-10-06  |  4.2 KB  |  125 lines

  1. //*---------------------------------------------------------------------------------
  2. //|  ODBC System Administrator
  3. //|
  4. //|  This code is furnished on an as-is basis as part of the ODBC SDK and is
  5. //|  intended for example purposes only.
  6. //|
  7. //|   Title:   STANDARD.H
  8. //|      This module contains standard includes which are required by many modules.
  9. //|         This include file is not specific for any tool.
  10. //|   Notes:
  11. //|      1) If using this file for a DLL, #define STANDARD_DLL, otherwise it is
  12. //|            assumed that it is being used for a Windows application.
  13. //*---------------------------------------------------------------------------------
  14. #ifndef STANDARD_DEFS
  15. #define STANDARD_DEFS
  16.  
  17. #include <windows.h>
  18. #include "sql.h"
  19. #include "sqlext.h"
  20.  
  21.  
  22. //----------------------------------------------------------------------------------
  23. //    Defines and macros
  24. //----------------------------------------------------------------------------------
  25. #define TEMP_SIZE    50
  26. #define MAX_BUFF     1000
  27. #define  MAXBUFF           256
  28. #define  MAXFILEBUFF       32000
  29. #define  DFTBUFFSIZE       30
  30. #define  LARGEBUFF         65535
  31.  
  32. //
  33. // When calling ODBC functions, you should allow for the case where
  34. // SQL_SUCCESS_WITH_INFO was returned.  Unless you want to see the informational
  35. // SQL state, you should treat these as the same.  The following macros are
  36. // handy to do just that.
  37. //
  38. #define RC_SUCCESSFUL(rc)  (rc == SQL_SUCCESS || rc == SQL_SUCCESS_WITH_INFO)
  39. #define RC_NOTSUCCESSFUL(rc) (!(RC_SUCCESSFUL(rc)))
  40.  
  41. //
  42. // Win 3.x specific items
  43. //
  44. #ifndef WIN32
  45.  
  46. #define INTFUN FAR PASCAL
  47. #define EXTFUN FAR PASCAL __export
  48. #define dCSEG(type) const type _based(_segname("_CODE"))
  49.  
  50. //
  51. // 32-bit stuff
  52. //
  53. #else
  54. #define MoveTo(hdc, x, y)        MoveToEx(hdc, x, y, NULL)
  55. #define dCSEG(type) const type
  56. #define INTFUN WINAPI
  57. #define EXTFUN WINAPI
  58.  
  59. #define WRITE     OF_WRITE
  60. #define READ      OF_READ
  61. #endif
  62.  
  63.  
  64.  
  65. #ifdef WIN32
  66. #else
  67. #endif
  68. #define VSZFile static char vszFile[]=__FILE__;
  69.  
  70. #ifdef _DEBUG
  71. #define DEBUGMSG(msg) OutputDebugString((LPSTR)msg)
  72. #else
  73. #define DEBUGMSG(msg)
  74. #endif
  75.  
  76.  
  77. #ifdef _DEBUG
  78. void FAR * DebugGetMemory(DWORD size, LPSTR szFile, int cbLine);
  79. void DebugReleaseMemory(LPVOID ptr, LPSTR szFile, int cbLine);
  80. void WinAssertReal(int exp, LPSTR msg, LPSTR file, int line);
  81.  
  82. #define WinAssert(exp, msg)                                             \
  83.          WinAssertReal(exp, msg, vszFile, __LINE__);
  84. #define GetMemory(size) DebugGetMemory(size, vszFile, __LINE__)
  85. #define ReleaseMemory(size) DebugReleaseMemory(size, vszFile, __LINE__)
  86. #define DEBUGADDR(title, hwnd, ptr)                                                                      \
  87.    {                                                                                                     \
  88.    static char szTmp[100];                                                                               \
  89.    wsprintf(szTmp, "%s, hwnd: %04X, ptr: %04X:%04X", (LPSTR)title, hwnd, HIWORD(ptr), LOWORD(ptr));      \
  90.    DEBUGMSG(szTmp);                                                                                      \
  91.    }
  92. #else
  93. #define  WinAssert(exp, msg)
  94. #define GetMemory(size) DoGetMemory(size)
  95. #define ReleaseMemory(size) DoReleaseMemory(size)
  96. #define DEBUGADDR(p1,p2,p3)
  97. #endif
  98.  
  99. #define NumItems(s) (sizeof (s) / sizeof(s[0]))
  100.  
  101. #define ABS(val) ((val < 0) ? (val * -1) : (val))
  102.  
  103. //*---------------------------------------------------------------------------------
  104. //|   Global variables
  105. //*---------------------------------------------------------------------------------
  106. dCSEG(char) szui[];
  107. dCSEG(char) szEmpty[];
  108.  
  109. //*---------------------------------------------------------------------------------
  110. //|   Function prototypes
  111. //*---------------------------------------------------------------------------------
  112. void FAR * DoGetMemory(DWORD size);
  113. void DoReleaseMemory(LPVOID ptr);
  114. void RemoveCrLf(LPSTR instr);
  115. void GetNewDirectory(LPSTR outstr, LPSTR instr);
  116. BOOL ValidName(LPSTR instr);
  117. int lpatoi(LPSTR instr);
  118.  
  119. LPSTR EXTFUN GetidsString(UINT ids, LPSTR szOut, UINT cbSize);
  120. VOID FAR CDECL szWrite(HWND hwnd, LPSTR szFmt, ...);
  121. int FAR CDECL szMessageBox(HWND hwnd, UINT style, LPSTR szTitle, LPSTR szFmt, ...);
  122.  
  123.  
  124. #endif
  125.