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 / quiktest / autotest.h next >
Encoding:
C/C++ Source or Header  |  1996-08-21  |  4.1 KB  |  126 lines

  1. //*---------------------------------------------------------------------------------
  2. //|  Title:        AUTOTEST.H
  3. //|
  4. //|    This file contains constants and prototypes required to compile an 
  5. //|    Auto Test DLL.
  6. //*---------------------------------------------------------------------------------
  7. #ifndef AUTOTEST_DEFS
  8. #define AUTOTEST_DEFS
  9.  
  10. #include <windows.h>
  11. #include <stdlib.h>
  12. #include <string.h>
  13. #include "sql.h"
  14. #include "sqlext.h"
  15.  
  16. #ifdef __cplusplus
  17. extern "C" { 
  18. #endif    /* __cplusplus */
  19.  
  20.  
  21. extern HINSTANCE    hLoadedInst;
  22.  
  23.  
  24. //----------------------------------------------------------------------------------
  25. //        Defines and Macros
  26. //----------------------------------------------------------------------------------
  27. #define TEST_ABORTED                        (-1)
  28.  
  29. #define AUTO_MAX_TEST_NAME                35
  30. #define AUTO_MAX_TESTCASE_NAME        35
  31. #define AUTO_MAX_TESTDESC_NAME        75
  32.  
  33. #define MAXFLUSH                            300
  34. #define MAX_USER_INFO                      50
  35. #define MAX_KEYWORD_LEN                   149
  36.  
  37. #ifdef WIN32
  38. #define EXTFUNCDECL                        _stdcall
  39. #define EXTFUN                                _stdcall
  40. #else
  41. #define EXTFUNCDECL
  42. #define EXTFUN                                __export FAR PASCAL
  43. #endif
  44.  
  45.  
  46. #define InitTest(lps)                                                            \
  47. {     lps->cErrors=0; }
  48. #define AbortTest(lps)                                                            \
  49. { lps->cErrors=TEST_ABORTED; }
  50.  
  51. #define     AllocateMemory(cb)    \
  52.                 (GlobalLock(GlobalAlloc((GMEM_FIXED | GMEM_ZEROINIT), (cb))))
  53. #ifdef WIN32
  54. #define     ReleaseMemory(lp)        \
  55.                      (GlobalUnlock((HGLOBAL)GlobalHandle(lp)), (BOOL)GlobalFree((HGLOBAL)GlobalHandle(lp)))
  56. #else
  57. #define     ReleaseMemory(lp)        \
  58.                 (GlobalUnlock(((HGLOBAL)LOWORD(GlobalHandle(SELECTOROF(lp))))), \
  59.                 (BOOL)GlobalFree(((HGLOBAL)LOWORD(GlobalHandle(SELECTOROF(lp))))))
  60. #endif
  61.  
  62. #define NumItems(s) (sizeof(s) / sizeof(s[0]))
  63.  
  64. // Following will access bit number pos in a bit array and return
  65. //        TRUE if it is set, FALSE if it is not
  66. #define CQBITS (sizeof(UINT) * 8)
  67. #define getqbit(lpa, pos)    \
  68.     (lpa[((pos) / CQBITS)] & (1 << ((pos) - (CQBITS * ((pos) / CQBITS)))))
  69. #define GETBIT(p1,p2) getqbit(p1,(p2)-1)
  70.  
  71.  
  72.  
  73. //
  74. // This structure contains the information found in the .INI file for a 
  75. //    data source.  The filled out structure is in turn passed to AutoTestFunc
  76. //    to drive the individual tests.
  77. //
  78. typedef struct tagSERVERINFO {
  79.     HWND             hwnd;                                // Output edit window
  80.     TCHAR           szLogFile[_MAX_PATH];        // Output log file
  81.     HENV             henv;                                // .EXE's henv
  82.     HDBC             hdbc;                                // .EXE's hdbc
  83.     HSTMT            hstmt;                            // .EXE's hstmt
  84.  
  85.     // The following items are gathered from the .INI file and may be defined
  86.     //        via the "Manage Test Sources" menu item from ODBC Test
  87.     TCHAR             szSource[SQL_MAX_DSN_LENGTH+1];
  88.     TCHAR             szValidServer0[SQL_MAX_DSN_LENGTH+1];
  89.     TCHAR             szValidLogin0[MAX_USER_INFO+1];
  90.     TCHAR             szValidPassword0[MAX_USER_INFO+1];
  91.     TCHAR            szKeywords[MAX_KEYWORD_LEN+1];
  92.  
  93.     // Following are used for run-time
  94.     UINT FAR *     rglMask;                          // Run test mask
  95.     int              failed;                            // Track failures on a test case basis
  96.     int              cErrors;                            // Count of errors
  97.     BOOL             fDebug;                            // TRUE if debugging is to be enabled
  98.     BOOL             fScreen;                            // TRUE if test output goes to screen
  99.     BOOL             fLog;                                // TRUE if test output goes to log
  100.     BOOL             fIsolate;                        // TRUE to isolate output
  101.     UDWORD        vCursorLib;                        // Value for SQL_ODBC_CURSOR on SQLSetConnectOption
  102.     HINSTANCE    hLoadedInst;                    // Instance handle of loaded test
  103.  
  104.     // Following are used for buffering output to edit window
  105.     TCHAR            szBuff[MAXFLUSH];                // Hold temporary results
  106.     UINT            cBuff;                            // Number of TCHARs in szBuff
  107.     } SERVERINFO;
  108. typedef SERVERINFO FAR * lpSERVERINFO;
  109.  
  110.  
  111. //----------------------------------------------------------------------------------
  112. // Function prototypes
  113. //----------------------------------------------------------------------------------
  114. BOOL EXTFUNCDECL FAR szLogPrintf(lpSERVERINFO lps, BOOL fForce, LPTSTR szFmt, ...);
  115. int EXTFUNCDECL FAR szMessageBox(HWND hwnd, UINT style, LPTSTR szTitle, LPTSTR szFmt, ...);
  116. LPTSTR EXTFUN GetRCString(HINSTANCE hInst, LPTSTR buf, int cbbuf, UINT ids);
  117.  
  118.  
  119. #ifdef __cplusplus
  120. }
  121. #endif
  122.  
  123. #endif
  124.  
  125.  
  126.