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.

2218 lines
90 KiB

  1. /***************************************************************************/
  2. /* ISAM.H */
  3. /* Copyright (C) 1995-96 SYWARE Inc., All rights reserved */
  4. /***************************************************************************/
  5. #include "dbase.h"
  6. /* Error codes */
  7. #define NO_ISAM_ERR 0
  8. #define ISAM_EOF 1
  9. #define ISAM_TRUNCATION 2
  10. #define ISAM_NOTSUPPORTED 3
  11. #define ISAM_ERROR 4
  12. #define ISAM_NETERROR 5
  13. #define ISAM_NETVERSION 6
  14. #define ISAM_NETISAM 7
  15. /* To create additional error codes that your implementation of the */
  16. /* ISAM functions can return, #define them here (no greater than */
  17. /* LAST_ISAM_ERROR_CODE). */
  18. #define ISAM_MEMALLOCFAIL 8
  19. #define ISAM_PROVIDERFAIL 9
  20. #define ISAM_STILL_EXECUTING 999 //added for asynchronous execution
  21. #define LAST_ISAM_ERROR_CODE 1000
  22. #define WBEMDR32_VIRTUAL_TABLE L"WBEMDR32VirtualTable"
  23. #define WBEMDR32_VIRTUAL_TABLE2 "WBEMDR32VirtualTable"
  24. /* Maximum sizes */
  25. #define MAX_CHAR_LITERAL_LENGTH 255
  26. #define MAX_BINARY_LITERAL_LENGTH 255
  27. #define MAX_COLUMN_NAME_LENGTH 128// was 63
  28. #define MAX_TABLE_NAME_LENGTH 128// was 63
  29. #define MAX_DATABASE_NAME_LENGTH 128//was 127
  30. #define MAX_SERVER_NAME_LENGTH 128
  31. #define MAX_TABLE_TYPE_LENGTH 12 //i.e length of 'SYSTEM TABLE'
  32. #define MAX_LOGIN_METHOD_LENGTH 7
  33. #define MAX_USER_NAME_LENGTH 128// was 63
  34. #define MAX_PASSWORD_LENGTH 128//was 63
  35. #define MAX_HOME_NAME_LENGTH 128
  36. #define MAX_COLUMNS_IN_ORDER_BY 20
  37. #define MAX_QUALIFIER_NAME_LENGTH 128
  38. #define MAX_ISAM_NAME_LENGTH 31
  39. #define MAX_VERSION_NAME_LENGTH 15
  40. #define MAX_DRIVER_NAME_LENGTH 31
  41. #define MAX_HOST_NAME_LENGTH 63
  42. #define MAX_PORT_NUMBER_LENGTH 15
  43. #define MAX_COLUMNS_IN_KEY 15
  44. #define MAX_KEY_NAME_LENGTH 63
  45. #define MAX_INDEX_NAME_LENGTH 63
  46. #define MAX_COLUMNS_IN_INDEX MAX_COLUMNS_IN_KEY
  47. /* ******* Note: do not change MAX_TABLE_NAME_LENGTH. If the ISAM's table */
  48. /* ******* name length is smaller than these values, */
  49. /* ******* ISAMMaxTableNameLength() should return the correct value. */
  50. /* ******* Note: do not change MAX_COLUMN_NAME_LENGTH. If the ISAM's */
  51. /* ******* table name length is smaller than these values, */
  52. /* ******* ISAMMaxColumnNameLength() should return the correct value.*/
  53. /* Comparison operators */
  54. #define ISAM_OP_NONE 0
  55. #define ISAM_OP_EQ 1
  56. #define ISAM_OP_NE 2
  57. #define ISAM_OP_LE 3
  58. #define ISAM_OP_LT 4
  59. #define ISAM_OP_GE 5
  60. #define ISAM_OP_GT 6
  61. /* Note: If you add to this list, you will probably have to add to OP_* in */
  62. /* PARSE.H */
  63. /* Network stuff */
  64. #define NET_OPAQUE UWORD
  65. #define NET_OPAQUE_INVALID ((NET_OPAQUE)-1)
  66. //Masks used for Data & Time convertions
  67. #define ISAM_DAY_MASK 31
  68. #define ISAM_MONTH_MASK 736
  69. #define ISAM_YEAR_MASK 65760
  70. #define ISAM_SECOND_MASK 31
  71. #define ISAM_MINUTE_MASK 2016
  72. #define ISAM_HOUR_MASK 65504
  73. //Some string constants
  74. #define WBEMDR32_L_NAME L"Name"
  75. #define WBEMDR32_L_CIMTYPE L"CIMTYPE"
  76. #define WBEMDR32_L_LAZY L"lazy"
  77. #define WBEMDR32_L_MAX L"MAXLEN"
  78. #define WBEMDR32_L_NAMESPACE L"__NAMESPACE"
  79. #define WBEMDR32_L_CLASS L"__CLASS"
  80. #define WBEMDR32_L_CIMOMIDENTIFICATION L"__CIMOMIdentification"
  81. #define WBEMDR32_L_KEY L"Key"
  82. #define WBEMDR32_L_SERVER L"__SERVER"
  83. #define WBEMDR32_L_WQL L"WQL"
  84. typedef
  85. enum tag_WmiEnumTypes
  86. { WMI_CREATE_INST_ENUM = 0x1,
  87. WMI_EXEC_QUERY = 0x2,
  88. WMI_EXEC_FWD_ONLY = 0x3,
  89. WMI_PROTOTYPE = 0x4
  90. } WmiEnumTypes;
  91. /***************************************************************************/
  92. //class to make sure Ole is initialized on every thread
  93. //As we don't know which thread the SQL function is called from
  94. //we need to make sure Ole is initialized on every ODBC function call
  95. class COleInitializationManager
  96. {
  97. public:
  98. COleInitializationManager();
  99. ~COleInitializationManager();
  100. };
  101. template<typename TNDataType>
  102. class SafeArrayManager
  103. {
  104. private:
  105. BOOL fValid; //indicate if it stores valid SAFEARRAY
  106. SAFEARRAY FAR* pa; //pointer to SAFEARRAY value;
  107. long iLBound; //lower and upper bounds of array
  108. long iUBound;
  109. long cElements; //number of elements in array
  110. public:
  111. //Does this object contain a valid array
  112. BOOL IsValid() {return fValid;}
  113. //returns number of elements in the array
  114. long Count() {return cElements;}
  115. // Extract a value from the array using the [] operator
  116. TNDataType operator[](long _nItem)
  117. {
  118. TNDataType dataItem;
  119. if(_nItem < cElements)
  120. {
  121. HRESULT hr;
  122. hr = SafeArrayGetElement(pa,&_nItem,&dataItem);
  123. }
  124. return dataItem;
  125. }
  126. SafeArrayManager(VARIANT* myArray)
  127. {
  128. fValid = FALSE;
  129. pa = NULL;
  130. iLBound = 0;
  131. iUBound = 0;
  132. cElements = 0;
  133. //Check that variant stores an array type
  134. if (myArray->vt & VT_ARRAY)
  135. {
  136. //Is a valid array type
  137. pa = myArray->parray;
  138. //Lock the array value
  139. SafeArrayLock(pa);
  140. //Work out number of properties/columns
  141. SafeArrayGetLBound(pa, 1, &iLBound );
  142. SafeArrayGetUBound(pa, 1, &iUBound );
  143. cElements = (iUBound - iLBound + 1);
  144. fValid = TRUE;
  145. }
  146. }
  147. ~SafeArrayManager()
  148. {
  149. if (pa)
  150. {
  151. //Unlock the array value
  152. SafeArrayUnlock(pa);
  153. }
  154. }
  155. };
  156. typedef SafeArrayManager<BSTR> BSTR_SafeArray;
  157. typedef SafeArrayManager<long> long_SafeArray; //VT_I4
  158. typedef SafeArrayManager<short> short_SafeArray;//VT_I2
  159. typedef SafeArrayManager<BYTE> BYTE_SafeArray; //VT_UI1
  160. typedef SafeArrayManager<BOOL> BOOL_SafeArray; //VT_BOOL
  161. //external declaration
  162. void Utility_DBCSToWideChar(IN const char* _dbcsData,
  163. OUT wchar_t** _sOutData, SWORD cbLen = 0);
  164. class CBString
  165. {
  166. private:
  167. BSTR m_pString;
  168. wchar_t* m_temp;
  169. public:
  170. CBString()
  171. {
  172. m_pString = NULL;
  173. m_temp = NULL;
  174. }
  175. CBString(int nSize);
  176. CBString(WCHAR* pwszString, BOOL fInterpretAsBlank);
  177. ~CBString();
  178. BSTR GetString()
  179. {
  180. return m_pString;
  181. }
  182. const CBString& operator=(LPWSTR pwszString)
  183. {
  184. if(m_pString) {
  185. SysFreeString(m_pString);
  186. m_pString = NULL;
  187. }
  188. if (pwszString && wcslen(pwszString))
  189. m_pString = SysAllocString(pwszString);
  190. return *this;
  191. }
  192. void AddString(LPSTR pszString, BOOL fInterpretAsBlank, SWORD cbLen = 0)
  193. {
  194. if(m_pString) {
  195. SysFreeString(m_pString);
  196. m_pString = NULL;
  197. }
  198. delete m_temp;
  199. m_temp = NULL;
  200. if (pszString)
  201. {
  202. if ( _mbstrlen(pszString) )
  203. {
  204. Utility_DBCSToWideChar(pszString,
  205. &m_temp, cbLen);
  206. m_pString = SysAllocString(m_temp);
  207. }
  208. else
  209. {
  210. //OK, we have a string of zero length
  211. //check if we interpret this as blank or NULL
  212. if (fInterpretAsBlank)
  213. {
  214. m_temp = new wchar_t[1];
  215. m_temp[0] = 0;
  216. m_pString = SysAllocString(m_temp);
  217. }
  218. }
  219. }
  220. }
  221. };
  222. class CNamespace : public CObject
  223. {
  224. DECLARE_SERIAL(CNamespace)
  225. private:
  226. CString m_name;
  227. public:
  228. CNamespace () {}
  229. CNamespace (char *name): m_name (name) {}
  230. CNamespace (CString& name ):
  231. m_name (name) {}
  232. CNamespace(const CNamespace& a):m_name (a.m_name) {}
  233. void Serialize(CArchive& ar)
  234. {
  235. if (ar.IsStoring())
  236. ar << m_name;
  237. else
  238. ar >> m_name;
  239. }
  240. #ifdef _DEBUG
  241. void AssertValid() const {CObject :: AssertValid ();}
  242. #endif
  243. const CNamespace& operator=( const CNamespace& a )
  244. {
  245. m_name = a.m_name;
  246. return *this;
  247. }
  248. BOOL operator==(CNamespace a)
  249. {
  250. return (m_name == a.m_name );
  251. }
  252. #ifdef _DEBUG
  253. void Dump( CDumpContext& dc ) const
  254. {
  255. CObject::Dump( dc );
  256. dc << m_name;
  257. }
  258. #endif
  259. CString& GetName () {return m_name;}
  260. };
  261. /***************************************************************************/
  262. class ImpersonationManager; //forward declaration
  263. /* ISAM provides low level data access. */
  264. typedef struct tagISAM {
  265. /* The following values are only used within ISAM.C */
  266. UWORD cSQLTypes;
  267. LPSQLTYPE SQLTypes;
  268. SWORD fTxnCapable; /* See the discussion of transactions */
  269. /* (below) for a description of this */
  270. /* value. */
  271. BOOL fSchemaInfoTransactioned;
  272. /* See the discussion of transactions */
  273. /* (below) for a description of this */
  274. /* value. */
  275. BOOL fMultipleActiveTxn; /* See the discussion of transactions */
  276. /* (below) for a description of this */
  277. /* value. */
  278. SDWORD fTxnIsolationOption; /* See the discussion of transactions */
  279. /* (below) for a description of this */
  280. /* value. */
  281. SDWORD fDefaultTxnIsolation;/* See the discussion of transactions */
  282. /* (below) for a description of this */
  283. /* value. */
  284. /* The following values are only used by Network Edition */
  285. UDWORD udwNetISAMVersion;
  286. /* The following values are only used by Network Edition client */
  287. NET_OPAQUE netISAM;
  288. LPVOID netConnection;
  289. BOOL fCaseSensitive;
  290. UCHAR szName[MAX_ISAM_NAME_LENGTH+1];
  291. UCHAR szVersion[MAX_VERSION_NAME_LENGTH+1];
  292. UCHAR szDriver[MAX_DRIVER_NAME_LENGTH+1];
  293. SWORD cbMaxTableNameLength;
  294. SWORD cbMaxColumnNameLength;
  295. HINSTANCE hKernelApi;
  296. char szHomeNamespace[MAX_DATABASE_NAME_LENGTH+1];// home namespace name use to contact MO Server
  297. CMapStringToOb *pNamespaceMap;
  298. // WBEM_LOGIN_AUTHENTICATION m_loginMethod;
  299. char* m_Locale;
  300. char* m_Authority;
  301. char szUser [MAX_USER_NAME_LENGTH + 1];
  302. char szPassword [MAX_PASSWORD_LENGTH + 1];
  303. char szDatabase [MAX_DATABASE_NAME_LENGTH+1];
  304. char szServer [MAX_SERVER_NAME_LENGTH+1];
  305. BOOL fIsLocalConnection;//Flag to indicate if this is a local connection
  306. BOOL fW2KOrMore;//Flag to indicate if this OS is Window 2000 or higher
  307. BOOL fIntpretEmptPwdAsBlank; //Flag to indicate a empty password is interpreted as blank rather than NULL
  308. ImpersonationManager* Impersonate; //Impersonation
  309. BOOL fOptimization; //indicates if you want WBEM Level 1 optimization
  310. BOOL fSysProps; //indicates if you want to show system properties
  311. BOOL fPassthroughOnly;//indicates if you want to work in passthrough only mode
  312. SWORD errcode;//error status
  313. tagISAM () {pNamespaceMap = NULL;}
  314. ~tagISAM () {delete pNamespaceMap;}
  315. static char *GetRelativeName (char* absoluteName);
  316. char szRootDb [MAX_DATABASE_NAME_LENGTH+1];
  317. //WBEM Client Recognition variables
  318. DWORD dwAuthLevel;
  319. DWORD dwImpLevel;
  320. COAUTHIDENTITY * gpAuthIdentity;
  321. } ISAM,
  322. FAR * LPISAM;
  323. //Pointers to functions
  324. typedef BOOL (CALLBACK *ULPLOGONUSER)(LPTSTR lpUser, LPTSTR lpDomain, LPTSTR lpPasswrd, DWORD dwLogonType, DWORD dwLogonProvider, PHANDLE pToken);
  325. typedef BOOL (CALLBACK *ULPIMPERSONLOGGEDONUSER)(HANDLE myHandle);
  326. typedef void (CALLBACK *ULPREVERTTOSELF)();
  327. typedef BOOL (CALLBACK *ULPSETTHREADLOCALE)(LCID myLcid);
  328. class ImpersonationManager
  329. {
  330. private:
  331. HANDLE hToken; // handle to a token that represents a logged on user
  332. HINSTANCE hAdvApi; // handle to library
  333. // HINSTANCE hKernelApi; // handle to library
  334. BOOL fImpersonate; //can we do impersonation
  335. char szUser [MAX_USER_NAME_LENGTH + 1];
  336. //Pointers to functions, if applicable
  337. ULPLOGONUSER pProcLogonUser;
  338. ULPIMPERSONLOGGEDONUSER pProcImpersonateLoggedOnUser;
  339. ULPREVERTTOSELF pProcRevertToSelf;
  340. BOOL DoInitialChecks();
  341. void ExtractLogonInfo(char* org_szUser, char* szPassword, char* szAuthority);
  342. public:
  343. BOOL fImpersonatingNow; //are we impersonating at this moment ?
  344. BOOL CanWeImpersonate() {return fImpersonate;}
  345. BOOL ImpersonatingNow() {return fImpersonatingNow;}
  346. void Impersonate(char* displayStr = NULL);
  347. void RevertToYourself(char* displayStr = NULL);
  348. ImpersonationManager(char* szUser, char* szPassword, char* szAuthority);
  349. ~ImpersonationManager();
  350. };
  351. //Add this to the start of most ODBC calls
  352. //this will impersonate, if possible, in its constructor
  353. //and RevertToSelf, if applicable in its destructor
  354. class MyImpersonator
  355. {
  356. private:
  357. LPDBC hdl;
  358. LPSTMT hstmt;
  359. LPISAM lpISAM;
  360. char* displayStr;
  361. ImpersonationManager* lpImpersonator;
  362. public:
  363. MyImpersonator(LPDBC hdl, char* displayStr);
  364. MyImpersonator(LPSTMT hstmt, char* displayStr);
  365. MyImpersonator(LPISAM lpISAM, char* displayStr);
  366. MyImpersonator(char* szUser, char* szPassword, char* szAuthority, char* displayStr);
  367. ~MyImpersonator();
  368. };
  369. #define MYUSRMESS_CREATE_SERVICES WM_USER + 1
  370. #define MYUSRMESS_REMOVE_SERVICES WM_USER + 2
  371. #define MYUSRMESS_CLOSE_WKERTHRED WM_USER + 3
  372. #define MYUSRMESS_REFCOUNT_INCR WM_USER + 4
  373. #define MYUSRMESS_REFCOUNT_DECR WM_USER + 5
  374. #define MYUSRMESS_CREATE_ENUM WM_USER + 6
  375. #define MYUSRMESS_REMOVE_ENUM WM_USER + 7
  376. class CWorkerThreadManager
  377. {
  378. private:
  379. // HANDLE EventHnd; //handle to event
  380. DWORD dwThreadId; //worker thread id
  381. HANDLE hr; //worker thread handle
  382. BOOL fIsValid; //has the worker thread been successfully setup ?
  383. public:
  384. DWORD m_cRef; //ref count
  385. CRITICAL_SECTION m_cs; //critical section for shared data
  386. // HANDLE GetEventHandle() {return EventHnd;}
  387. DWORD GetThreadId() {return dwThreadId;}
  388. HANDLE GetThreadHandle() {return hr;}
  389. DWORD GetRefCount() {return m_cRef;}
  390. BOOL IsValid() {return fIsValid;}
  391. void CreateWorkerThread();
  392. void Invalidate();
  393. CWorkerThreadManager();
  394. ~CWorkerThreadManager();
  395. };
  396. class CSafeWbemServices;
  397. class MyWorkingThreadParams
  398. {
  399. public:
  400. HANDLE m_EventHnd; //in order to make this suspensive
  401. //Tempory pointers to data used for a short
  402. //time when creating IWbemServices Ole pGateway
  403. LPISAM m_lpISAM;
  404. LPUSTR m_lpQualifierName;
  405. SWORD m_cbQualifierName;
  406. IStream* m_myStream; //temp copy
  407. //Extra ones for IEnumClassObject
  408. CSafeWbemServices* pServ; //tempory pointer to be able to use IWbemServices created on working thread (not in marshalled stream)
  409. BSTR sqltextBSTR; //tempory pointer
  410. BSTR tableName; //tempory pointer
  411. WmiEnumTypes fIsExecQuery; //flag to indicate creation style
  412. SCODE sc; //return scode on creating enumeration
  413. //to be filled in on working thread
  414. IWbemServices* pGateway; //pointer to receive Ole pointer created on working thread
  415. IEnumWbemClassObject* pEnum; //pointer to receive Ole pointer created on working thread
  416. MyWorkingThreadParams(LPISAM lpISAM, LPUSTR lpQualifierName, SWORD cbQualifierName, IStream* myStream);
  417. MyWorkingThreadParams(LPISAM lpISAM, WmiEnumTypes fIsExecQuery, BSTR theBstrValue, CSafeWbemServices* pServ, IStream* myStream);
  418. ~MyWorkingThreadParams();
  419. };
  420. class CSafeIEnumWbemClassObject
  421. {
  422. private:
  423. IStream * m_pStream; //use to safely store Com pointer
  424. MyWorkingThreadParams*
  425. m_params;
  426. public:
  427. BOOL m_fValid; //is the IEnumWbemClassObject pointer valid ?
  428. //is the IWbemServices pointer valid
  429. BOOL IsValid() {return m_fValid;}
  430. void Invalidate();
  431. //to manage thread messages using event object
  432. BOOL PostSuspensiveThreadMessage(DWORD idThread, UINT Msg, WPARAM wParam, LPARAM lParam);
  433. HRESULT GetInterfacePtr(IEnumWbemClassObjectPtr& pIEnum);
  434. HRESULT SetInterfacePtr(LPISAM, WmiEnumTypes fIsEXecQuery, BSTR theBstrValue, CSafeWbemServices* pServ);//(IEnumWbemClassObjectPtr& myPtr);
  435. CSafeIEnumWbemClassObject();
  436. ~CSafeIEnumWbemClassObject();
  437. };
  438. class CSafeWbemServices
  439. {
  440. private:
  441. IStream * m_pStream; //use to safely store Com pointer
  442. public :
  443. MyWorkingThreadParams*
  444. m_params; //parameters for this IWbemServices object
  445. BOOL m_fValid; //is the IWbemServices pointer valid ?
  446. HRESULT GetInterfacePtr(IWbemServicesPtr& pServices);
  447. void SetInterfacePtr(LPISAM lpISAM, LPUSTR lpQualifierName, SWORD cbQualifierName);
  448. //to manage thread messages using event object
  449. BOOL PostSuspensiveThreadMessage(DWORD idThread, UINT Msg, WPARAM wParam, LPARAM lParam);
  450. //is the IWbemServices pointer valid
  451. BOOL IsValid() {return m_fValid;}
  452. void Invalidate();
  453. //Transfer the data from one object to this one
  454. void Transfer(CSafeWbemServices& original);
  455. CSafeWbemServices();
  456. ~CSafeWbemServices();
  457. };
  458. /***************************************************************************/
  459. /* The ISAM provides a mechanism for the driver to retrieve a list of */
  460. /* table names. First ISAMGetTableList() is called to get a */
  461. /* LPISAMTABLELIST. Then ISAMGetNextTableName() is called zero or more */
  462. /* times to get the names off the list. Finally, ISAMFreeTableList() is */
  463. /* called to deallocate the list. */
  464. typedef struct tagISAMTABLELIST {
  465. /* The following values are only used by Network Edition client */
  466. NET_OPAQUE netISAMTableList;
  467. /* The following values are only used within ISAM.C */
  468. LPISAM lpISAM;
  469. UCHAR lpPattern[MAX_TABLE_NAME_LENGTH];
  470. SWORD cbPattern;
  471. UCHAR lpQualifierName[MAX_QUALIFIER_NAME_LENGTH+1];
  472. SWORD cbQualifierName;
  473. BOOL fFirstTime;
  474. BOOL fGotAllInfo;//used to indicate completion of asynchronous retrieval of table list
  475. POSITION iIndex; //position into CPtrList
  476. CPtrList* pTblList; //table list (IWBEMClassObjects)
  477. CSafeWbemServices* pGateway2;
  478. BOOL fEmptyList;//are we asking for no tables
  479. BOOL fWantSysTables; //do we want System Tables
  480. } ISAMTABLELIST,
  481. FAR * LPISAMTABLELIST;
  482. /***************************************************************************/
  483. typedef struct tagISAMQUALIFIERLIST {
  484. /* The following values are only used within ISAM.C */
  485. LPISAM lpISAM;
  486. POSITION iIndex;//position into list
  487. BOOL fFirstTime;
  488. } ISAMQUALIFIERLIST,
  489. FAR * LPISAMQUALIFIERLIST;
  490. /***************************************************************************/
  491. /* ISAM provides a mechanism for the driver to retrieve the foreign key */
  492. /* between two tabled. */
  493. typedef UCHAR ISAMKEYCOLUMNNAME[MAX_COLUMN_NAME_LENGTH+1];
  494. typedef ISAMKEYCOLUMNNAME FAR *LPISAMKEYCOLUMNNAME;
  495. /***************************************************************************/
  496. /* ISAM provides a bookmarking facility. It allows the ISAM user to get */
  497. /* get a bookmark for the current record in the table and then later */
  498. /* reposition to that record. */
  499. //typedef UDWORD ISAMBOOKMARK;
  500. typedef struct tagISAMBOOKMARK
  501. {
  502. UDWORD currentRecord; //in-memory WBEM instance
  503. UDWORD currentInstance; //virtual instance number
  504. } ISAMBOOKMARK,
  505. FAR * LPISAMBOOKMARK;
  506. #define NULL_BOOKMARK 0xFFFFFFFF //set currentRecord to this value to indicate a NULL entry
  507. /***************************************************************************/
  508. struct ISAMTreeItemData
  509. {
  510. char *absName;
  511. char* pszText;
  512. int included;
  513. int childInclude;//number of immediate child nodes which are included
  514. int childChildInclude;//number of non-immediate child nodes which are included
  515. BOOL fExpanded; //flag to indicate if this node has been checked for children
  516. ISAMTreeItemData* pNext;
  517. ~ISAMTreeItemData () {delete absName; delete pszText;}
  518. ISAMTreeItemData () : absName (NULL), included (FALSE), pNext(NULL), fExpanded(FALSE) {}
  519. };
  520. /***************************************************************************/
  521. /* The ISAM allows the driver to open and access a table. To open the */
  522. /* table, ISAMOpenTable() is called. To close the table ISAMCloseTable() */
  523. /* is called. */
  524. typedef struct tagISAMCOLUMNDEF { /* A column of the table */
  525. /* These values must be here. They are used by the driver */
  526. UCHAR szColumnName[MAX_COLUMN_NAME_LENGTH+1];
  527. /* The name of the column */
  528. UCHAR szTypeName[MAX_COLUMN_NAME_LENGTH+1];
  529. /* The type name of the column */
  530. /* (e.g."MONEY", "INT8" etc...) */
  531. SWORD fSqlType; /* The type of the column (SQL_*) */
  532. /* *********************************** */
  533. /* *** *** */
  534. /* *** THIS MUST BE ONE OF THE *** */
  535. /* *** TYPES SPECIFIED IN SQLTypes *** */
  536. /* *** IN SQLTYPE.C WHICH HAS THE *** */
  537. /* *** supported FLAG SET TO TRUE *** */
  538. /* *** *** */
  539. /* *********************************** */
  540. UDWORD cbPrecision; /* The precision of the column (see */
  541. /* appendix D of the ODBC Spec). */
  542. SWORD ibScale; /* The scale of the column (see */
  543. /* appendix D of the ODBC Spec). */
  544. SWORD fNullable; /* See SQLColumns(NULLABLE) in the */
  545. /* ODBC spec. */
  546. UWORD fSelectivity; /* A measure of how unique values of */
  547. /* this column are. The higher */
  548. /* the number, the more values */
  549. /* there are. For example, a */
  550. /* GENDER column would have low */
  551. /* selectivity value, but a SSN */
  552. /* column would have high value. */
  553. /* This value is used to determine */
  554. /* the most restrictive condition */
  555. /* to send to ISAMRestrict(). If */
  556. /* you don't know the selectivity */
  557. /* or don't want this column to */
  558. /* be sent to ISAMRestrict(), */
  559. /* set this value to 0. */
  560. UWORD fKeyComponent; /* Non-zero if this column is a */
  561. /* component of the primary key */
  562. /* for the table. */
  563. /* */
  564. /* If the table has a primary key */
  565. /* that has multiple components */
  566. /* (for example, the combination */
  567. /* of LAST_NAME and FIRST_NAME */
  568. /* is unique but neither */
  569. /* FIRST_NAME nor LAST_NAME alone */
  570. /* is unique), fKeyComponent has */
  571. /* the value 1 for the first key */
  572. /* component, 2 for the second */
  573. /* key component, etc. */
  574. /* */
  575. /* If table has multiple primary */
  576. /* keys (for example, RECORD_ID */
  577. /* alone is unique and NAME alone */
  578. /* is unique), fKeyComponent is */
  579. /* set for only one of them, not */
  580. /* both. */
  581. /* */
  582. /* If the table has no primary */
  583. /* keys, fKeyComponent is zero for */
  584. /* all the columns in the table. */
  585. /* Note: If the table has no */
  586. /* primary keys, some applications */
  587. /* such as Microsoft Access or */
  588. /* PowerBuilder may not be able to */
  589. /* update the table. */
  590. /* The following values are only used by Network Edition client */
  591. SWORD iSqlType;
  592. SDWORD cbValue;
  593. PTR rgbValue;
  594. /* The following values are only used within ISAM.C */
  595. } ISAMCOLUMNDEF,
  596. FAR * LPISAMCOLUMNDEF;
  597. #define REFETCH_DATA SQL_DATA_AT_EXEC
  598. /***************************************************************************/
  599. class ClassColumnInfoBase; //forward declaration
  600. class VirtualInstanceManager; //forward declaration
  601. typedef struct tagISAMTABLEDEF {
  602. /* These values must be here. They are used by the driver */
  603. UCHAR szTableName[MAX_TABLE_NAME_LENGTH+1]; /*The name of the table*/
  604. CBString* pBStrTableName; //Also the table name but saved for our convenience
  605. IWbemClassObject* pSingleTable; //The table class object use to get column information
  606. CSafeWbemServices* pGateway2;
  607. LPDBASEFILE lpFile;//Use to store enumeration of records for the chosen class
  608. BOOL fFirstRead;
  609. SDWORD iRecord; /* row number */
  610. ClassColumnInfoBase* pColumnInfo;//column info for this table
  611. UCHAR szPrimaryKeyName[MAX_KEY_NAME_LENGTH+1];
  612. /* If there is a primary key */
  613. /* on the table, the name of */
  614. /* the primary key. If there */
  615. /* is not name or no primary */
  616. /* key, a zero length string */
  617. /* The following values are only used by ISAM.C and the Network Edition */
  618. LPISAM lpISAM; //Copy from hdbc
  619. IWbemContext* pContext; //Context object to store LocaleId
  620. /* Is this __Generic class (multi-table join) */
  621. BOOL fIs__Generic;
  622. /* Is this Passthrough SQL */
  623. BOOL fIsPassthroughSQL;
  624. CMapWordToPtr* passthroughMap;
  625. IWbemClassObject* firstPassthrInst; //1st SQL passthrough instance
  626. VirtualInstanceManager* virtualInstances; //stores virtual array map for array columns which map
  627. //to multiple instances
  628. /* The following values are only used by Network Edition client */
  629. NET_OPAQUE netISAMTableDef;
  630. HGLOBAL hPreFetchedValues;
  631. SDWORD cbBookmark;
  632. ISAMBOOKMARK bookmark;
  633. } ISAMTABLEDEF,
  634. FAR * LPISAMTABLEDEF;
  635. /***************************************************************************/
  636. /* ISAM allows for an SQL statement to be passed to it (for use with */
  637. /* backend databases that suport SQL). An ISAMSQL handle is used to */
  638. /* identify an SQL statement passed. See ISAMPrepare() and ISAMExecute(). */
  639. typedef struct tagISAMSTATEMENT {
  640. /* The following values are only used by ISAM.C and the Network Edition */
  641. LPISAM lpISAM;
  642. /* The following values are only used by Network Edition client */
  643. NET_OPAQUE netISAMStatement;
  644. /* The following values are only used within ISAM.C */
  645. BOOL resultSet;
  646. LPSTR lpszParam1;
  647. SDWORD cbParam1;
  648. LPSTR lpszParam2;
  649. SDWORD cbParam2;
  650. /* Added by Sai for Passthrough SQL */
  651. CSafeWbemServices* pProv; //Gateway Server
  652. UDWORD currentRecord; //record number (zero index)
  653. CSafeIEnumWbemClassObject* tempEnum; //enumeration of all records
  654. IWbemClassObject* firstPassthrInst;//first SQL passthrough instance
  655. CSafeIEnumWbemClassObject* tempEnum2; //enumeration of class definition
  656. IWbemClassObject* classDef; //class definition
  657. CMapWordToPtr* passthroughMap; //passthrough map
  658. } ISAMSTATEMENT,
  659. FAR * LPISAMSTATEMENT;
  660. /***************************************************************************/
  661. class ClassColumnInfo
  662. {
  663. private:
  664. // VARIANT aVariantValue;
  665. VARIANT aVariantSYNTAX;
  666. //Flag to indicate if column info valid
  667. BOOL fValidType;
  668. LPSQLTYPE aDataTypeInfo;
  669. // The type name of the column
  670. //(e.g."MONEY", "INT8" etc...)
  671. UCHAR szTypeName[MAX_COLUMN_NAME_LENGTH+1];
  672. //SQL_* type of the column
  673. SWORD fSqlType;
  674. //The precision of the column
  675. UDWORD cbPrecision;
  676. //The scale of the column
  677. SWORD ibScale;
  678. //Flag to inidicate if column is NULLable
  679. SWORD fNullable;
  680. //Variant type
  681. LONG varType;
  682. //Flag to indicate if column is 'lazy'
  683. BOOL fIsLazyProperty;
  684. public:
  685. //indicates if column info is known
  686. BOOL IsValidInfo() {return fValidType;}
  687. //returns the variant type for the column value
  688. LONG GetVariantType() {return varType;}
  689. //returns SQL_* type of column
  690. SWORD GetSQLType() {return fSqlType;}
  691. //returns type name
  692. UCHAR* GetTypeName() {return szTypeName;}
  693. //returns precision of column
  694. UDWORD GetPrecision() {return cbPrecision;}
  695. //returns scale of column
  696. SWORD GetScale() {return ibScale;}
  697. //indicates if column is NULLable
  698. SWORD IsNullable() {return SQL_NULLABLE;}
  699. //indicates if column is lazy
  700. BOOL IsLazy() {return fIsLazyProperty;}
  701. //returns SQL_* type of column
  702. LPSQLTYPE GetDataTypeInfo() {return GetType2(szTypeName);}
  703. ClassColumnInfo(LONG pType, VARIANT* pSYNTAX, SDWORD maxLenVal, BOOL fGotSyntax = TRUE, BOOL fIsLazy = FALSE);
  704. ~ClassColumnInfo();
  705. };
  706. /***************************************************************************/
  707. class CEmbeddedDataItems
  708. {
  709. private:
  710. public:
  711. //embedded object name
  712. //(which is also the table aliase)
  713. CBString embeddedName;
  714. //embedded object class
  715. IWbemClassObject* cClassObject;
  716. CEmbeddedDataItems() {cClassObject = NULL;}
  717. ~CEmbeddedDataItems()
  718. {
  719. //(5)
  720. if (cClassObject)
  721. cClassObject->Release();//to match QueryInterface class
  722. }
  723. };
  724. class ClassColumnInfoBase
  725. {
  726. private:
  727. //Copy of table definition
  728. LPISAMTABLEDEF pTableDef;
  729. //Stores column names
  730. SAFEARRAY FAR* rgSafeArray;
  731. //Indicates if class is valid
  732. BOOL isValid;
  733. //Number of columns
  734. UWORD cColumnDefs;
  735. //Lower bound
  736. LONG iLBound;
  737. //Upper bound
  738. LONG iUBound;
  739. //Extra Column Information
  740. ClassColumnInfo* pColumnInformation;
  741. LONG iColumnNumber;
  742. //Setups up extra column info
  743. BOOL Setup(LONG iColumnNum);
  744. //returns info for a particular column
  745. SWORD GetColumnInfo(LONG iColumnNum);
  746. /**********************************************************/
  747. /* The following are only for __Generic Passthrough class */
  748. /**********************************************************/
  749. //Is this a __Generic Passthrough SQL class
  750. BOOL fIs__Generic;
  751. //Number of system properies
  752. UWORD cSystemProperties;
  753. /* SAI
  754. //Array of embedded object names
  755. //(which are also table aliases)
  756. CBString* embeddedNames;
  757. //Array of embedded objects. Each
  758. IWbemClassObject** cClassObject;
  759. */
  760. CEmbeddedDataItems** embedded;
  761. UWORD embeddedSize;
  762. //get embedded class object for column index
  763. IWbemClassObject* GetClassObject(LONG iColumnNumber, CBString& lpPropName, CBString& lpAliasName);
  764. //dummy
  765. CBString dummyStr;
  766. public:
  767. //returns profile for __Generic class
  768. UWORD Get__GenericProfile();
  769. //Indicates if class was created successfully
  770. BOOL IsValid() {return isValid;}
  771. //returns number of columns
  772. UWORD GetNumberOfColumns() {return cColumnDefs;}
  773. //returns the column name, the buffer pColumnName must be
  774. //at least MAX_COLUMN_NAME_LENGTH+1 in size
  775. SWORD GetColumnName(LONG iColumnNumber, LPSTR pColumnName, LPSTR pColumnAlias = NULL);
  776. BOOL GetVariantType(LONG iColumnNum, LONG &lVariant);
  777. //returns SQL_* type of column
  778. BOOL GetSQLType(LONG iColumnNum, SWORD &wSQLType);
  779. //returns type name
  780. BOOL GetTypeName(LONG iColumnNum, UCHAR* &pbTypeName);
  781. //returns precision of column
  782. BOOL GetPrecision(LONG iColumnNum, UDWORD &uwPrecision);
  783. //returns scale of column
  784. BOOL GetScale(LONG iColumnNum, SWORD &wScale);
  785. //indicates if column is NULLable
  786. BOOL IsNullable(LONG iColumnNum, SWORD &wNullable);
  787. //indicates if column is 'lazy'
  788. BOOL IsLazy(LONG iColumnNum, BOOL &fLazy);
  789. //returns SQL_* type of column
  790. BOOL GetDataTypeInfo(LONG iColumnNum, LPSQLTYPE &pSQLType);
  791. //indicates how unique column values are
  792. UWORD GetSelectivity() {return 0;}
  793. //indicates if this column is part of primary key
  794. SWORD GetKey(LONG iColumnNumber, BOOL &isAKey);
  795. //Gets the Lower Bound
  796. LONG GetLowerBound() {return iLBound;}
  797. //Gets the Upper Bound
  798. LONG GetUpperBound() {return iUBound;}
  799. //retrieves attribute values for column
  800. SWORD GetColumnAttr(LONG iColumnNumber, LPSTR pAttrStr, SDWORD cbValueMax, SDWORD& cbBytesCopied);
  801. ClassColumnInfoBase(LPISAMTABLEDEF pTableDef, BOOL fIs__Generic = FALSE);
  802. ~ClassColumnInfoBase();
  803. };
  804. /***************************************************************************/
  805. //
  806. // Notification classes
  807. //
  808. class CNotifyTableNames : public IWbemObjectSink
  809. {
  810. private:
  811. HANDLE m_mutex; //mutex to protect shared table list resource
  812. DWORD m_cRef; //Reference count
  813. LPISAMTABLELIST lpISAMTableList; //pointer to store tables names
  814. public:
  815. STDMETHODIMP QueryInterface(REFIID, LPVOID FAR*);
  816. STDMETHODIMP_(ULONG) AddRef(void);
  817. STDMETHODIMP_(ULONG) Release(void);
  818. STDMETHODIMP_(HRESULT) GetTypeInfoCount(UINT FAR* pctinfo) {return E_NOTIMPL;}
  819. STDMETHODIMP_(HRESULT) GetTypeInfo(UINT itinfo, LCID lcid, ITypeInfo FAR* FAR* pptinfo) {return E_NOTIMPL;}
  820. STDMETHODIMP_(HRESULT) GetIDsOfNames(REFIID riid, OLECHAR FAR* FAR* rgszNames, UINT cNames,
  821. LCID lcid, DISPID FAR* rgdispid) {return E_NOTIMPL;}
  822. STDMETHODIMP_(HRESULT) Invoke(DISPID dispidMember, REFIID riid, LCID lcid, WORD wFlags,
  823. DISPPARAMS FAR* pdispparams, VARIANT FAR* pvarResult,
  824. EXCEPINFO FAR* pexcepinfo, UINT FAR* puArgErr) {return E_NOTIMPL;}
  825. STDMETHODIMP_(HRESULT) Indicate(long lObjectCount, IWbemClassObject FAR* FAR* ppObjArray) {return E_NOTIMPL;}
  826. STDMETHODIMP_(HRESULT) SetStatus(long lFlags, long lParam, BSTR strParam, IWbemClassObject FAR *pObjParam) {return E_NOTIMPL;}
  827. //IMosNotify members
  828. STDMETHODIMP_(SCODE) Notify(long lObjectCount, IWbemClassObject** pObjArray);
  829. CNotifyTableNames(LPISAMTABLELIST lpTblList);
  830. ~CNotifyTableNames();
  831. };
  832. /////////////////////////////////////////////////////////////////////////////
  833. // Some internal functions
  834. /////////////////////////////////////////////////////////////////////////////
  835. /******************************************************************************/
  836. /* Returns the number of column for the table defined in the table definition */
  837. /* This function will return zero if an error is detected */
  838. UWORD INTFUNC GetNumberOfColumnsInTable(LPISAMTABLEDEF lpISAMTableDef);
  839. /***************************************************************************/
  840. /* Creates a communication channel to the Gateway Server */
  841. /* via an OLE MS interface */
  842. /* NULL is returned if the interface could not be created. */
  843. void INTFUNC ISAMGetGatewayServer(
  844. IWbemServicesPtr& pGateway,
  845. LPISAM lpISAM,
  846. /* INPUT: Handle returned by ISAMOpen() */
  847. LPUSTR lpQualifierName = (LPUSTR)"",
  848. /* INPUT: Qualifier name (parent namespace) */
  849. SWORD cbQualifierName = 0);
  850. /* INPUT: Number of bytes in qualifier name */
  851. void INTFUNC ISAMGetGatewayServer(
  852. IWbemServicesPtr& pGateway,
  853. LPUSTR lpServerName,
  854. // WBEM_LOGIN_AUTHENTICATION loginMethod,
  855. LPUSTR objectPath,
  856. LPUSTR lpUserName,
  857. LPUSTR lpPassword,
  858. LPUSTR lpLocale,
  859. LPUSTR lpAuthority,
  860. DWORD &dwAuthLevel,
  861. DWORD &dwImpLevel,
  862. BOOL fIntpretEmptPwdAsBlank,
  863. COAUTHIDENTITY** ppAuthIdent);
  864. /***************************************************************************/
  865. /* If the ISAM layer reports that it supports transactions, the driver */
  866. /* be transaction enabled. When ISAMOpen() is called, it reports back the */
  867. /* transaction capabilites supported in the LPISAM structure: */
  868. /* */
  869. /* fTxnCapable */
  870. /* */
  871. /* SQL_TC_NONE: Transactions are not suported */
  872. /* */
  873. /* SQL_DC_DML: Transactions can only contain Data Manipulation */
  874. /* Language (DML) statements (SELECT, INSERT, UPDATE, */
  875. /* DELETE). Data Definition Language (DDL) statements */
  876. /* encountered in a transation cause an error */
  877. /* */
  878. /* SQL_TC_DDL_COMMIT: Transactions can only contain DML */
  879. /* statements. DDL statements (CREATE TABLE, DROP INDEX, */
  880. /* and so on) encountered in a transaction cause the */
  881. /* transaction to be committed. */
  882. /* */
  883. /* SQL_TC_DDL_IGNORE: Transactions can only contain DML */
  884. /* statements. DDL statements encountered in a */
  885. /* transaction are ignored. */
  886. /* */
  887. /* SQL_TC_ALL: Transactions can contain DDL statements and DML */
  888. /* statements in any order. */
  889. /* */
  890. /* fSchemaInfoTransactioned */
  891. /* */
  892. /* There is no explicit "start transaction" ISAM entry point */
  893. /* A transaction is started (if there isn't one started */
  894. /* already) when certain ISAM calls are made. This flag */
  895. /* specifies if calls that only pertain to the schema of the */
  896. /* database (as opposed to calls the pertain to the data in the */
  897. /* database) will start a transaction or not. */
  898. /* */
  899. /* The following functions are only used to process DML */
  900. /* statements. They are not used to process DDL statements. */
  901. /* Each of the following functions will start a transaction if */
  902. /* one is not already started, regardless of the value of */
  903. /* fSchemaInfoTransactioned (Note: a transaction will only be */
  904. /* started if the function returns ISAM_NO_ERROR, ISAM_EOF, or */
  905. /* ISAM_TRUNCATION): */
  906. /* */
  907. /* ISAMRewind */
  908. /* ISAMSort */
  909. /* ISAMRestrict */
  910. /* ISAMNextRecord */
  911. /* ISAMGetData */
  912. /* ISAMPutData */
  913. /* ISAMInsertRecord */
  914. /* ISAMUpdateRecord */
  915. /* ISAMDeleteRecord */
  916. /* ISAMGetBookmark */
  917. /* ISAMPosition */
  918. /* ISAMPrepare */
  919. /* ISAMParameter */
  920. /* ISAMExecute */
  921. /* */
  922. /* The following functions are used to process DML and/or DDL */
  923. /* statements. Each of the following functions will start a */
  924. /* transaction if one is not already started only if the value */
  925. /* of fSchemaInfoTransactioned is TRUE (Note: a transaction */
  926. /* will only be started if the function returns ISAM_NO_ERROR, */
  927. /* ISAM_EOF, or ISAM_TRUNCATION): */
  928. /* */
  929. /* ISAMCreateTable */
  930. /* ISAMAddColumn */
  931. /* ISAMCreateIndex */
  932. /* ISAMDeleteIndex */
  933. /* ISAMOpenTable */
  934. /* ISAMGetTableList */
  935. /* ISAMGetNextTableName */
  936. /* ISAMForeignKey */
  937. /* ISAMDeleteTable */
  938. /* */
  939. /* fMultipleActiveTxn */
  940. /* */
  941. /* A single user of ISAM may call ISAMOpen() multiple times. */
  942. /* If fMultipleActiveTxn is TRUE, separate transactions on each */
  943. /* of these connections can occur at the same time. Otherwise, */
  944. /* only one connection at can have a transaction open at any */
  945. /* given time. */
  946. /* */
  947. /* fTxnIsolationOption */
  948. /* */
  949. /* A 32-bit bitmask enumerating the transaction isolation */
  950. /* levels available. The following bitmasks are used in */
  951. /* conjuction with the flag to determine which options are */
  952. /* supported: */
  953. /* */
  954. /* SQL_TXN_READ_UNCOMMITTED */
  955. /* SQL_TXN_READ_COMMITTED */
  956. /* SQL_TXN_REPEATABLE_READ */
  957. /* SQL_TXN_SERIALIZABLE */
  958. /* SQL_TXN_VERSIONING */
  959. /* */
  960. /* These values are described in the ODBC SDK Programmer's */
  961. /* reference (under SQLGetInfo(SQL_DEFAULT_TXN_ISOLATION)) */
  962. /* */
  963. /* fDefaultTxnIsolation */
  964. /* This value specifies which of the above SQL_TXN_* isolation */
  965. /* levels is used by default. */
  966. /* */
  967. /* Note: ODBC defines an "autocommit" mode which, if enabled, causes */
  968. /* statements to committed automatically after they are executed. The ISAM */
  969. /* layer does not implement this capability. The upper levels of the */
  970. /* system implement autocommit mode. If the underlying database has an */
  971. /* autocommit mode, it should be turned off. */
  972. /* */
  973. /* In addition to reporting this information when ISAMOpen() is called, */
  974. /* there are three transaction related functions which are used (these are */
  975. /* only called if fTxnCapable is not SQL_TC_NONE): */
  976. /* */
  977. /* ISAMCommitTxn() */
  978. /* ISAMRollbackTxn() */
  979. /* ISAMSetTxnIsolation() */
  980. /* */
  981. /***************************************************************************/
  982. SWORD INTFUNC ISAMOpen(
  983. LPUSTR lpszServer,
  984. /* INPUT: The name of the server. If this is an empty string */
  985. /* the local server will be used */
  986. LPUSTR lpszDatabase,
  987. /* INPUT: The name of database. This is specified */
  988. /* by DBQ in the ODBC.INI file or the connect */
  989. /* string. */
  990. LPUSTR lpszDSN,
  991. /* INPUT: The name of datasource that is being */
  992. /* connected to. */
  993. // WBEM_LOGIN_AUTHENTICATION loginMethod,
  994. /* INPUT Login method */
  995. LPUSTR lpszUsername,
  996. /* INPUT: The user name, as specified at connect */
  997. /* time. */
  998. LPUSTR lpszPassword,
  999. /* INPUT: The password, as specified at connect */
  1000. /* time. */
  1001. LPUSTR lpszLocale,
  1002. /* INPUT: Locale */
  1003. LPUSTR lpszAuthority,
  1004. /* INPUT Authority */
  1005. BOOL fSysProps,
  1006. /* INPUT: The system properties flag, as specified at connect */
  1007. /* time. */
  1008. CMapStringToOb *pMapStringToOb,
  1009. LPISAM FAR *lplpISAM,
  1010. /* OUTPUT: Handle to the ISAM */
  1011. LPUSTR lpszErrorMessage,
  1012. /* OUTPUT: If ISAMOpen() is unsuccessful, an error */
  1013. /* message is returned here. */
  1014. BOOL fOptimization,
  1015. /* INPUT: Flag to indicate is WBEM Level 1 optimzation */
  1016. /* can be used (if applicable)
  1017. */
  1018. BOOL fImpersonate,
  1019. /* INPUT: Flag to indicate if impersonation is requested */
  1020. BOOL fPassthrghOnly,
  1021. /* INPUT: Flag to indicate if passthrough only mode is requested */
  1022. BOOL fIntpretEmptPwdAsBlank
  1023. /* INPUT: Flag to indicate how to interpret a blank password */
  1024. );
  1025. /* Opens and
  1026. initializes the ISAM. lpszDatabase points to the name of */
  1027. /* the database. */
  1028. /***************************************************************************/
  1029. SWORD INTFUNC ISAMGetTableList(
  1030. LPISAM lpISAM,
  1031. /* INPUT: Handle returned by ISAMOpen() */
  1032. LPUSTR lpPattern,
  1033. /* INPUT: The pattern to match */
  1034. SWORD cbPattern,
  1035. /* INPUT: Number of characters in the pattern */
  1036. LPUSTR lpQualifierName,
  1037. /* INPUT: The qualifier (parent namespace) name */
  1038. SWORD cbQualifierName,
  1039. /* INPUT: Number of characters in the qualifier */
  1040. LPISAMTABLELIST FAR *lplpISAMTableList,
  1041. /* OUTPUT: Handle to table list */
  1042. BOOL fWantSysTables = TRUE,
  1043. /* INPUT: Do we want system tables */
  1044. BOOL fEmptyTable = FALSE);
  1045. /* INPUT: Driver only supports table type TABLES */
  1046. /* If this table type is not requested the table */
  1047. /* list should be empty */
  1048. /* Creates a table list of all that tables that match lpPattern. */
  1049. /* The PatternMatch() function can be used to see if a table */
  1050. /* matches. cbPattern is always a non-negative number no larger */
  1051. /* the MAX_TABLE_NAME_LENGTH. */
  1052. /* */
  1053. /* This call works outside ISAM's transaction mechanism. It will not */
  1054. /* start a transaction and the LPISAMTABLELIST handle returned always */
  1055. /* survives a commit or rollback. The implementation of this function may */
  1056. /* have to internally cache the information to return for subsequent calls */
  1057. /* to ISAMGetNextTableName(). */
  1058. /* */
  1059. /* NULL is returned if the tablelist could not be created. */
  1060. /***************************************************************************/
  1061. /*
  1062. class ISAMGetNextTableNameParams
  1063. {
  1064. public:
  1065. UDWORD fSyncMode;
  1066. LPISAMTABLELIST lpISAMTableList;
  1067. LPUSTR lpTableName;
  1068. LPUSTR lpTableType;
  1069. };
  1070. SWORD INTFUNC ISAMGetNextTableName(ISAMGetNextTableNameParams* myParams);
  1071. */
  1072. SWORD INTFUNC ISAMGetNextTableName(
  1073. UDWORD fSyncMode,
  1074. /* INPUT: indication if function is to be performed */
  1075. /* synchronously or asynchronously */
  1076. LPISAMTABLELIST lpISAMTableList,
  1077. /* INPUT: Handle returned by ISAMGetTableList() */
  1078. LPUSTR lpTableName,
  1079. /* OUTPUT: Buffer where next table name is returned*/
  1080. LPUSTR lpTableType);
  1081. /* OUTPUT: Buffer where table type is returned */
  1082. /* Gets the next name from the list. lpTableName points to a buffer (that */
  1083. /* is MAX_TABLE_NAME_LENGTH+1 characters long) that this routine fills in */
  1084. /* with the next table name. Returns ISAM_EOF if no more tables. */
  1085. /***************************************************************************/
  1086. SWORD INTFUNC ISAMGetQualifierList(
  1087. LPISAM lpISAM,
  1088. /* INPUT: Handle returned by ISAMOpen() */
  1089. LPISAMQUALIFIERLIST FAR *lplpISAMQualifierList);
  1090. /* OUTPUT: Handle to Qualifier list */
  1091. /* Creates a qualifier list */
  1092. /* */
  1093. /* NULL is returned if the qualifierlist could not be created. */
  1094. /***************************************************************************/
  1095. SWORD INTFUNC ISAMGetNextQualifierName(
  1096. UDWORD fSyncMode,
  1097. /* INPUT: indication if function is to be performed */
  1098. /* synchronously or asynchronously */
  1099. LPISAMQUALIFIERLIST lpISAMQualifierList,
  1100. /* INPUT: Handle returned by ISAMGetQualifierList() */
  1101. LPUSTR lpQualiferName);
  1102. /* OUTPUT: Buffer where next qualifier name is returned*/
  1103. SWORD INTFUNC ISAMGetNextQualifierName2(
  1104. LPISAMQUALIFIERLIST lpISAMQualifierList,
  1105. /* INPUT: Handle returned by ISAMGetQualifierList() */
  1106. LPUSTR lpQualiferName);
  1107. /* OUTPUT: Buffer where next qualifier name is returned*/
  1108. /* Gets the next name from the list.lpQualifierName points to a buffer (that */
  1109. /* is MAX_QUALIFIER_NAME_LENGTH+1 characters long) that this routine fills in*/
  1110. /* with the next qualifier name. Returns ISAM_EOF if no more qualifiers. */
  1111. /***************************************************************************/
  1112. SWORD INTFUNC ISAMFreeTableList(
  1113. LPISAMTABLELIST lpISAMTableList);
  1114. /* INPUT: Handle returned by ISAMGetTableList() */
  1115. /* Deallocates a table list. */
  1116. /***************************************************************************/
  1117. SWORD INTFUNC ISAMFreeQualifierList(
  1118. LPISAMQUALIFIERLIST lpISAMQualifierList);
  1119. /* INPUT: Handle returned by ISAMGetQualifierList() */
  1120. /* Deallocates a qualifier list. */
  1121. /***************************************************************************/
  1122. SWORD INTFUNC ISAMForeignKey(
  1123. LPISAM lpISAM,
  1124. /* INPUT: Handle returned by ISAMOpen() */
  1125. LPUSTR lpszPrimaryKeyTableName,
  1126. /* INPUT: Name of primary key table */
  1127. LPUSTR lpszForeignKeyTableName,
  1128. /* INPUT: Name of foreign key table */
  1129. LPUSTR lpPrimaryKeyName,
  1130. /* OUTPUT: Buffer where name of primary key is */
  1131. /* returned (zero-length string if no name) */
  1132. LPUSTR lpForeignKeyName,
  1133. /* OUTPUT: Buffer where name of primary key is */
  1134. /* returned (zero-length string if no name) */
  1135. SWORD FAR *lpfUpdateRule,
  1136. /* OUTPUT: Update rule for the foreign key */
  1137. /* (SQL_CASCASE, SQL_RESTRICT, SQL_SET_NULL, or */
  1138. /* -1 if not applicable) */
  1139. SWORD FAR *lpfDeleteRule,
  1140. /* OUTPUT: Delete rule for the foreign key */
  1141. /* (SQL_CASCASE, SQL_RESTRICT, SQL_SET_NULL, or */
  1142. /* -1 if not applicable) */
  1143. UWORD FAR *lpcISAMKeyColumnList,
  1144. /* OUTPUT: Number of column in the forien key */
  1145. LPISAMKEYCOLUMNNAME ISAMPrimaryKeyColumnList,
  1146. /* OUTPUT: Buffer where name of names of the */
  1147. /* primary key columns is returned */
  1148. LPISAMKEYCOLUMNNAME ISAMForeignKeyColumnList);
  1149. /* OUTPUT: Buffer where name of names of the */
  1150. /* foriegn key columns is returned */
  1151. /* Gets a foreign key definition. lpPrimaryKeyName points to a buffer */
  1152. /* (that is MAX_KEY_NAME_LENGTH+1 characters long) that contains the name */
  1153. /* of the primary key (if any). lpForeignKeyName points to a buffer (that */
  1154. /* is MAX_KEY_NAME_LENGTH+1 characters long) that contains the name of the */
  1155. /* foreign key (if any). lpfUpdateRule specifies the update rule (-1 if */
  1156. /* not applicable. lpfDeleteRule specifies the update rule (-1 if not */
  1157. /* applicable. ISAMPrimaryKeyColumnList points to an array of buffers */
  1158. /* (each of which is MAX_COLUMN_NAME_LENGTH+1 characters long) that */
  1159. /* contains the name of the columns of the primary key. */
  1160. /* ISAMForeignKeyColumnList points to an array of buffers (each of which */
  1161. /* is MAX_COLUMN_NAME_LENGTH+1 characters long) that contains the name of */
  1162. /* the columns of the foreign key. The number of key components in */
  1163. /* ISAMPrimaryKeyColumnList and ISAMForeignKeyColumnList is returned */
  1164. /* in lpcISAMKeyColumnList. Returns ISAM_EOF if no foreign key. */
  1165. /***************************************************************************/
  1166. SWORD INTFUNC ISAMCreateTable(
  1167. LPISAM lpISAM,
  1168. /* INPUT: Handle returned by ISAMOpen() */
  1169. LPUSTR lpszTableName,
  1170. /* INPUT: Name of table to create */
  1171. LPISAMTABLEDEF FAR *lplpISAMTableDef);
  1172. /* Output: Handle to the table created */
  1173. /* Creates a new table with the given name. This call be followed by a */
  1174. /* series of ISAMAddColumn() calls and a ISAMCloseTable() call. No other */
  1175. /* ISAM calls will be made with the LPISAMTABLEDEF returned. */
  1176. /* */
  1177. /* NULL is returned if the table could not be created. */
  1178. /***************************************************************************/
  1179. SWORD INTFUNC ISAMAddColumn(
  1180. LPISAMTABLEDEF lpISAMTableDef,
  1181. /* INPUT: Handle returned by ISAMCreateTable() */
  1182. LPUSTR lpszColumnName,
  1183. /* INPUT: The name of the column to create */
  1184. UWORD iSqlType,
  1185. /* INPUT: The index into the SQLTypes[] array that */
  1186. /* describes the type of the column */
  1187. UDWORD udParam1,
  1188. /* INPUT: First create parameter (if any) */
  1189. UDWORD udParam2);
  1190. /* INPUT: Second create parameter (if any) */
  1191. /* Adds a column to a new table. lpszColumnName specifies the column */
  1192. /* name. iSqlType specifies the datatype of the column (it will always be */
  1193. /* an index to an element of SQLTypes[] whose 'supported' component is */
  1194. /* TRUE). If the 'params' component designates that there are create */
  1195. /* parameters for the type, udParam1 and udParam2 contain these values. */
  1196. /* */
  1197. /* This call will only be made on table handles returned by */
  1198. /* ISAMCreateTable(). */
  1199. /* */
  1200. /* ISAM_NO_ERROR is returned if successful, ISAM_ERROR for failure. */
  1201. /***************************************************************************/
  1202. SWORD INTFUNC ISAMCreateIndex(
  1203. LPISAMTABLEDEF lpISAMTableDef,
  1204. /* INPUT: Handle returned by ISAMOpenTable() */
  1205. LPUSTR lpszIndexName,
  1206. /* INPUT: The name of the index to create/delete */
  1207. BOOL fUnique,
  1208. /* INPUT: Unique index? */
  1209. UWORD count,
  1210. /* INPUT: The number of columns in the key */
  1211. UWORD FAR * icol,
  1212. /* INPUT: An array of column ids */
  1213. BOOL FAR * fDescending);
  1214. /* INPUT: An array of ascending/descending flags */
  1215. /* Creates an index for this table. The number of key fields is specified */
  1216. /* by count, which must be between 1 and MAX_COLUMNS_IN_INDEX (inclusive). */
  1217. /* icol and fDescending are arrays (count elements long) specifying the */
  1218. /* key columns and direction. */
  1219. /* */
  1220. /* ISAM_NO_ERROR is returned if successful, ISAM_ERROR for failure. */
  1221. /***************************************************************************/
  1222. SWORD INTFUNC ISAMDeleteIndex(
  1223. LPISAM lpISAM,
  1224. /* INPUT: Handle returned by ISAMOpen() */
  1225. LPUSTR lpszIndexName);
  1226. /* INPUT: The name of the index to create/delete */
  1227. /* Deletes an index. */
  1228. /* */
  1229. /* ISAM_NO_ERROR is returned if successful, ISAM_ERROR for failure. */
  1230. /***************************************************************************/
  1231. SWORD INTFUNC ISAMOpenTable(
  1232. LPISAM lpISAM,
  1233. /* INPUT: Handle returned by ISAMOpen() */
  1234. LPUSTR szTableQualifier,
  1235. /* INPUT: The name of the table qualifier */
  1236. SWORD cbTableQualifier,
  1237. /* INPUT: Length of table qualifier */
  1238. LPUSTR lpszTableName,
  1239. /* INPUT: The name of the table to open */
  1240. BOOL fReadOnly,
  1241. /* INPUT: Flag to indicate whether or not write */
  1242. /* access is needed */
  1243. LPISAMTABLEDEF FAR *lplpISAMTableDef,
  1244. /* OUTPUT: Handle to the table opened */
  1245. LPSTMT lpstmt = NULL
  1246. /* INPUT : Parent statment handle for Passthrough SQL */
  1247. );
  1248. /* Opens the specified table. */
  1249. /***************************************************************************/
  1250. SWORD INTFUNC ISAMRewind(
  1251. LPISAMTABLEDEF lpISAMTableDef);
  1252. /* INPUT: Handle returned by ISAMOpenTable() */
  1253. /* Move before the first record in the table. */
  1254. /* */
  1255. /* ISAM_NO_ERROR is returned if successful, ISAM_ERROR for failure. */
  1256. /***************************************************************************/
  1257. SWORD INTFUNC ISAMSort(
  1258. LPISAMTABLEDEF lpISAMTableDef,
  1259. /* INPUT: Handle returned by ISAMOpenTable() */
  1260. UWORD count,
  1261. /* INPUT: The number of columns to sort on */
  1262. UWORD FAR * icol,
  1263. /* INPUT: An array of column ids */
  1264. BOOL FAR * fDescending);
  1265. /* INPUT: An array of ascending/descending flags */
  1266. /* Sorts the records such that ISAMNextRecord() returns the records in */
  1267. /* sorted order. This may do (but does not have to) a ISAMRewind() before */
  1268. /* returning. After this call is made, ISAMNextRecord() will not be */
  1269. /* called until after an ISAMRewind() is called. The number of sort */
  1270. /* fields is specified by count. icol and fDescending are arrays (count */
  1271. /* elements long) specifying the sort column and direction. If count is */
  1272. /* zero, then turn sorting off for this table. */
  1273. /* */
  1274. /* ISAM_NO_ERROR is returned if successful. If the ISAM layer cannot */
  1275. /* perform sort, ISAM_NOTSUPPORTED is returned. Otherwise, ISAM_ERROR */
  1276. /* is returned. */
  1277. /***************************************************************************/
  1278. SWORD INTFUNC ISAMRestrict(
  1279. LPISAMTABLEDEF lpISAMTableDef,
  1280. /* INPUT: Handle returned by ISAMOpenTable() */
  1281. UWORD count,
  1282. /* INPUT: The number of restrictions */
  1283. UWORD FAR * icol,
  1284. /* INPUT: An array of column ids */
  1285. UWORD FAR * fOperator,
  1286. /* INPUT: An array of ISAM_OP_* value */
  1287. SWORD FAR * fCType,
  1288. /* INPUT: An array of SQL_C_* types of the test */
  1289. /* value */
  1290. PTR FAR * rgbValue,
  1291. /* INPUT: An array of buffers holding the test */
  1292. /* value */
  1293. SDWORD FAR * cbValue);
  1294. /* INPUT: An array of lengths of the value in */
  1295. /* rgbValue */
  1296. /* Specifies that ISAMNextRecord() only needs to return records that */
  1297. /* satisfy: */
  1298. /* */
  1299. /* (<column-1> <operator-1> <value-1>) AND */
  1300. /* (<column-2> <operator-2> <value-2>) AND */
  1301. /* ... */
  1302. /* (<column-n> <operator-n> <value-n>) */
  1303. /* */
  1304. /* The columns specified by icol will never have a fSelectivity of 0. */
  1305. /* This may do (but does not have to) a ISAMRewind() before returning. */
  1306. /* After this call is made, ISAMNextRecord() will not be called until */
  1307. /* after an ISAMRewind() is called. */
  1308. /* */
  1309. /* ISAM_NO_ERROR is returned if successful. If the ISAM layer cannot */
  1310. /* perform the restriction, ISAM_NOTSUPPORTED is returned. Otherwise, */
  1311. /* ISAM_ERROR is returned. */
  1312. /***************************************************************************/
  1313. SWORD INTFUNC ISAMNextRecord(
  1314. LPISAMTABLEDEF lpISAMTableDef,
  1315. /* INPUT: Handle returned by ISAMOpenTable() */
  1316. LPSTMT lpstmt);
  1317. /* INPUT: Handle to current statement */
  1318. /* Move to the next record in the table. */
  1319. /* */
  1320. /* ISAM_EOF is returned if there are not more record, ISAM_NO_ERROR is */
  1321. /* returned if successful, ISAM_ERROR for failure. */
  1322. /***************************************************************************/
  1323. SWORD INTFUNC ISAMGetData(
  1324. LPISAMTABLEDEF lpISAMTableDef,
  1325. /* INPUT: Handle returned by ISAMOpenTable() */
  1326. UWORD icol,
  1327. /* INPUT: The id of the column */
  1328. SDWORD cbOffset,
  1329. /* INPUT: When reading a character column the */
  1330. /* starting offset to read at. When reading a */
  1331. /* binary column as SQL_C_BINARY, the starting */
  1332. /* offset to read at. When reading a binary */
  1333. /* column as SQL_C_CHAR the starting character */
  1334. /* to return (after the conversion). */
  1335. SWORD fCType,
  1336. /* INPUT: A SQL_C_* type which designates which */
  1337. /* format the data should be returned in. */
  1338. /* For character columns this is SQL_C_CHAR. The */
  1339. /* data is returned as a null terminated */
  1340. /* character string (if the data is */
  1341. /* truncated the entire buffer is filled and */
  1342. /* there is no null terminator). */
  1343. /* For numerical columns other than SQL_DECIMAL, */
  1344. /* SQL_NUMERIC, and SQL_BIGINT; this is */
  1345. /* SQL_C_DOUBLE. The data is returned as */
  1346. /* a double. */
  1347. /* For numerical columns that are SQL_DECIMAL, */
  1348. /* SQL_NUMERIC, or SQL_BIGINT; this is */
  1349. /* SQL_C_CHAR. The data is returned as a */
  1350. /* null terminated character string. For */
  1351. /* values with a non-zero scale, 'scale' */
  1352. /* digits to the right are returned. If the */
  1353. /* scale is zero, no decimal point is */
  1354. /* returned. The string has no leading or */
  1355. /* trailing blanks. */
  1356. /* For date columns, this is SQL_C_DATE. The */
  1357. /* data is returned in as a DATE_SRUCT. */
  1358. /* For time columns, this is SQL_C_TIME. The */
  1359. /* data is returned in as a TIME_SRUCT. */
  1360. /* For timestamp columns, this is */
  1361. /* SQL_C_TIMESTAMP data is returned in as a */
  1362. /* TIMESTAMP_SRUCT. */
  1363. /* For binary columns this is either SQL_C_BINARY */
  1364. /* or SQL_C_CHAR. If SQL_C_BINARY, the data */
  1365. /* is returned in binary form. If SQL_C_CHAR, */
  1366. /* the binary value is converted to a */
  1367. /* null terminated character string (if the */
  1368. /* data is truncated the entire buffer is */
  1369. /* filled and there is no null terminator). */
  1370. PTR rgbValue,
  1371. /* OUTPUT: Buffer to hold output value */
  1372. SDWORD cbValueMax,
  1373. /* INPUT: Size of buffer to hold output value */
  1374. SDWORD FAR *pcbValue);
  1375. /* OUTPUT: Number of bytes returned (not including */
  1376. /* null terminator for strings). If the buffer */
  1377. /* is not big enough to return the entire value */
  1378. /* this is is set to the total numebe of bytes */
  1379. /* for the value, minus cbOffset. For null */
  1380. /* values, this is set to SQL_NULL_DATA */
  1381. /* Retrieves a column value from the current record. */
  1382. /* */
  1383. /* ISAM_TRUNCATION is returned if the data was too large to fit in the */
  1384. /* buffer provided, ISAM_NO_ERROR is returned if successful, ISAM_ERROR */
  1385. /* for failure. */
  1386. /***************************************************************************/
  1387. SWORD INTFUNC ISAMPutData(
  1388. LPISAMTABLEDEF lpISAMTableDef,
  1389. /* INPUT: Handle returned by ISAMOpenTable() */
  1390. UWORD icol,
  1391. /* INPUT: The id of the column */
  1392. SWORD fCType,
  1393. /* INPUT: A SQL_C_* type which designates which */
  1394. /* format the data is sent in. */
  1395. /* For character columns this is SQL_C_CHAR. The */
  1396. /* data is a null terminated character */
  1397. /* string. */
  1398. /* For numerical columns other than SQL_DECIMAL, */
  1399. /* SQL_NUMERIC, and SQL_BIGINT); this is */
  1400. /* SQL_C_DOUBLE. The data is a double */
  1401. /* For numerical columns that are SQL_DECIMAL, */
  1402. /* SQL_NUMERIC, or SQL_BIGINT; this is */
  1403. /* SQL_C_CHAR. The data is a null terminated */
  1404. /* character string. For values with a */
  1405. /* non-zero scale, the value has 'scale' */
  1406. /* digits to the right are returned. If the */
  1407. /* scale is zero, the value has no decimal */
  1408. /* point. The string has no leading or */
  1409. /* trailing blanks. */
  1410. /* For date columns, this is SQL_C_DATE. The */
  1411. /* data is a DATE_SRUCT. */
  1412. /* For time columns, this is SQL_C_TIME. The */
  1413. /* data is a TIME_SRUCT. */
  1414. /* For timestamp columns, this is */
  1415. /* SQL_C_TIMESTAMP. The data is a */
  1416. /* TIMESTAMP_SRUCT. */
  1417. /* For binary columns this is SQL_C_BINARY. The */
  1418. /* data is in binary form */
  1419. PTR rgbValue,
  1420. /* INPUT: The buffer holding the value */
  1421. SDWORD cbValue);
  1422. /* INPUT: The size of the buffer. This is */
  1423. /* SQL_NULL_DATA if the value is null. */
  1424. /* Updates a column value in the current record. Note that */
  1425. /* ISAMUpdateRecord will also be called to save the changes. */
  1426. /* */
  1427. /* ISAM_NO_ERROR is returned if successful, ISAM_ERROR for failure. */
  1428. /***************************************************************************/
  1429. SWORD INTFUNC ISAMInsertRecord(
  1430. LPISAMTABLEDEF lpISAMTableDef);
  1431. /* INPUT: Handle returned by ISAMOpenTable() */
  1432. /* Add a new record to the table, and make it the current record. */
  1433. /* All column values in the row are NULL. */
  1434. /* */
  1435. /* ISAM_NO_ERROR is returned if successful, ISAM_ERROR for failure. */
  1436. /***************************************************************************/
  1437. SWORD INTFUNC ISAMUpdateRecord(
  1438. LPISAMTABLEDEF lpISAMTableDef);
  1439. /* INPUT: Handle returned by ISAMOpenTable() */
  1440. /* Commit any changes to column values in the current row. */
  1441. /* */
  1442. /* ISAM_NO_ERROR is returned if successful, ISAM_ERROR for failure. */
  1443. /***************************************************************************/
  1444. SWORD INTFUNC ISAMDeleteRecord(
  1445. LPISAMTABLEDEF lpISAMTableDef);
  1446. /* INPUT: Handle returned by ISAMOpenTable() */
  1447. /* Remove the current record from the table. Call ISAMNextRecord */
  1448. /* to move the next record before calling ISAMGetData or ISAMPutData. */
  1449. /* */
  1450. /* ISAM_NO_ERROR is returned if successful, ISAM_ERROR for failure. */
  1451. /***************************************************************************/
  1452. SWORD INTFUNC ISAMGetBookmark(
  1453. LPISAMTABLEDEF lpISAMTableDef,
  1454. /* INPUT: Handle returned by ISAMOpenTable() */
  1455. LPISAMBOOKMARK lpISAMBookmark);
  1456. /* OUTPUT: The bookmark value */
  1457. /* Retrieves the bookmark for the current record. The bookmark is valid */
  1458. /* until the table is closed. See ISAMPosition(). */
  1459. /* */
  1460. /* ISAM_NO_ERROR is returned if successful, ISAM_ERROR for failure. */
  1461. /***************************************************************************/
  1462. SWORD INTFUNC ISAMPosition(
  1463. LPISAMTABLEDEF lpISAMTableDef,
  1464. /* INPUT: Handle returned by ISAMOpenTable() */
  1465. LPISAMBOOKMARK ISAMBookmark);
  1466. /* INPUT: The bookmark value */
  1467. /* Repositions the current record to the record identified by */
  1468. /* ISAMBookmark. Note: Once ISAMPosition is called, only ISAMGetData(), */
  1469. /* ISAMPosition(), and ISAMClose() will be called for this table. */
  1470. /* ISAM_NO_ERROR is returned if successful, ISAM_ERROR for failure. */
  1471. /***************************************************************************/
  1472. SWORD INTFUNC ISAMCloseTable(
  1473. LPISAMTABLEDEF lpISAMTableDef);
  1474. /* INPUT: Handle returned by ISAMOpenTable() or */
  1475. /* ISAMCreateTable() */
  1476. /* Closes the table (opened by ISAMOpenTable() or ISAMCreateTable()). */
  1477. /* Note: lpISAMTableDef will be invalid after this call, even if this */
  1478. /* call returns an error. */
  1479. /* */
  1480. /* ISAM_NO_ERROR is returned if successful, ISAM_ERROR for failure. */
  1481. /***************************************************************************/
  1482. SWORD INTFUNC ISAMDeleteTable(
  1483. LPISAM lpISAM,
  1484. /* INPUT: Handle returned by ISAMOpen() */
  1485. LPUSTR lpszTableName);
  1486. /* INPUT: The name of the table to delete. */
  1487. /* Deletes the table. */
  1488. /* */
  1489. /* ISAM_NO_ERROR is returned if successful, ISAM_ERROR for failure. */
  1490. /***************************************************************************/
  1491. SWORD INTFUNC ISAMClose(
  1492. LPISAM lpISAM);
  1493. /* INPUT: Handle returned by ISAMOpen() */
  1494. /* Closes the ISAM (opened by ISAMOpen()). */
  1495. /* */
  1496. /* ISAM_NO_ERROR is returned if successful, ISAM_ERROR for failure. */
  1497. /***************************************************************************/
  1498. SWORD INTFUNC ISAMPrepare(
  1499. LPISAM lpISAM,
  1500. /* INPUT: Handle returned by ISAMOpen() */
  1501. UCHAR FAR *szSqlStr,
  1502. /* INPUT: SQL statement to prepare */
  1503. SDWORD cbSqlStr,
  1504. /* INPUT: Length of SQL statement to prepare */
  1505. LPISAMSTATEMENT FAR * lplpISAMStatement,
  1506. /* OUTPUT: Handle to prepared statement */
  1507. LPUSTR lpszTablename,
  1508. /* OUTPUT: If the statement has a result set, */
  1509. /* the name of the virtual table that contains */
  1510. /* the result set. Otherwise a zero length */
  1511. /* string. */
  1512. UWORD FAR *lpParameterCount
  1513. /* OUTPUT: Number of parameters in the statement */
  1514. #ifdef IMPLTMT_PASSTHROUGH
  1515. ,LPSTMT lpstmt
  1516. #endif
  1517. );
  1518. /* INPUT statement */
  1519. /* Prepares an ISAM statment for later execution by ISAMExecute(). */
  1520. /* */
  1521. /* If the statement has a result set (such as a SELECT statement), the */
  1522. /* name of a virtual table that contains the result set is returned. This */
  1523. /* table will be opened by ISAMOpenTable() (before ISAMExecute() is */
  1524. /* called). */
  1525. /* */
  1526. /* If the statement does not have a result set, a zero length table name */
  1527. /* is returned. */
  1528. /* */
  1529. /* ISAM_NO_ERROR is returned if successful. If the ISAM layer cannot */
  1530. /* prepare and execute statements, ISAM_NOTSUPPORTED is returned. */
  1531. /* Otherwise, ISAM_ERROR is returned. */
  1532. /***************************************************************************/
  1533. SWORD INTFUNC ISAMParameter(
  1534. LPISAMSTATEMENT lpISAMStatement,
  1535. /* INPUT: Handle returned by ISAMPrepare() */
  1536. UWORD ipar,
  1537. /* INPUT: The id of the parameter (the first */
  1538. /* parameter is 1, the second is 2, etc.) */
  1539. SWORD fCType,
  1540. /* INPUT: A SQL_C_* type which designates which */
  1541. /* format the data is sent in. */
  1542. PTR rgbValue,
  1543. /* INPUT: The buffer holding the value */
  1544. SDWORD cbValue);
  1545. /* INPUT: The size of the buffer. This is */
  1546. /* SQL_NULL_DATA if the value is null. */
  1547. /* If SQLPrepare() returns a non-zero parameter count this rouitne is */
  1548. /* called once to specify the parameter value ISAMExecute() is to use. */
  1549. /* This routine need not make a copy of the data 'rgbValue' points to, */
  1550. /* it will not change until after SQLExecute() is called. */
  1551. /* */
  1552. /* ISAM_NO_ERROR is returned if successful. Otherwise, ISAM_ERROR is */
  1553. /* returned. */
  1554. /***************************************************************************/
  1555. SWORD INTFUNC ISAMExecute(
  1556. LPISAMSTATEMENT lpISAMStatement,
  1557. /* INPUT: Handle returned by ISAMPrepare() */
  1558. SDWORD FAR *lpcRowCount);
  1559. /* OUTPUT: If the prepared statement was an INSERT */
  1560. /* UPDATE, or DELETE statement, the number of */
  1561. /* rows affected. Otherwise some meaningful */
  1562. /* number is possible (otherwise -1). */
  1563. /* Executes a statement previously prepared by ISAMPrepare(). This may */
  1564. /* be called multiple times for one call to ISAMPrepare(). */
  1565. /* */
  1566. /* ISAM_NO_ERROR is returned if successful. Otherwise, ISAM_ERROR is */
  1567. /* returned. */
  1568. /***************************************************************************/
  1569. SWORD INTFUNC ISAMFreeStatement(
  1570. LPISAMSTATEMENT lpISAMStatement);
  1571. /* INPUT: Handle returned by ISAMPrepare() */
  1572. /* Frees a previously prepared statement. ISAM_NO_ERROR is returned if */
  1573. /* successful. Otherwise, ISAM_ERROR is returned. */
  1574. /***************************************************************************/
  1575. SWORD INTFUNC ISAMSetTxnIsolation(
  1576. LPISAM lpISAM,
  1577. /* INPUT: Handle returned by ISAMOpen() */
  1578. UDWORD fTxnIsolationLevel);
  1579. /* INPUT: One of the following (see ODBC */
  1580. /* documentation for details) : */
  1581. /* SQL_TXN_READ_UNCOMMITTED */
  1582. /* SQL_TXN_READ_COMMITTED */
  1583. /* SQL_TXN_REPEATABLE_READ */
  1584. /* SQL_TXN_SERIALIZABLE */
  1585. /* SQL_TXN_VERSIONING */
  1586. /* Sets the transaction isolation level. ISAM_NO_ERROR is returned if */
  1587. /* successful. Otherwise, ISAM_ERROR is returned. */
  1588. /***************************************************************************/
  1589. SWORD INTFUNC ISAMCommitTxn(
  1590. LPISAM lpISAM);
  1591. /* INPUT: Handle returned by ISAMOpen() */
  1592. /* Commits the current transaction if one is open. If no transaction */
  1593. /* is open, returns successfully anyway. */
  1594. /* ISAM_NO_ERROR is returned if successful. Otherwise, ISAM_ERROR is */
  1595. /* returned. */
  1596. /***************************************************************************/
  1597. SWORD INTFUNC ISAMRollbackTxn(
  1598. LPISAM lpISAM);
  1599. /* INPUT: Handle returned by ISAMOpen() */
  1600. /* Rolls back the current transaction if one is open. If no transaction */
  1601. /* is open, returns successfully anyway. */
  1602. /* ISAM_NO_ERROR is returned if successful. Otherwise, ISAM_ERROR is */
  1603. /* returned. */
  1604. /***************************************************************************/
  1605. /***************************************************************************/
  1606. /***************************************************************************/
  1607. /***************************************************************************/
  1608. void INTFUNC ISAMGetErrorMessage(
  1609. LPISAM lpISAM,
  1610. /* INPUT: Handle returned by ISAMOpen() */
  1611. LPUSTR lpszErrorMessage);
  1612. /* OUTPUT: The error message associated with the */
  1613. /* most recent call to an ISAM call */
  1614. /* Returns the error message associated with the most recent call to an */
  1615. /* ISAM function. */
  1616. /***************************************************************************/
  1617. LPSQLTYPE INTFUNC ISAMGetColumnType(
  1618. LPISAMTABLEDEF lpISAMTableDef,
  1619. /* INPUT: Handle returned by ISAMOpenTable() */
  1620. UWORD icol);
  1621. /* INPUT: Id of column */
  1622. /* Returns a pointer to the description of the SQL_* type of the column. */
  1623. /***************************************************************************/
  1624. BOOL INTFUNC ISAMCaseSensitive(LPISAM lpISAM);
  1625. /* Are column and table names case-sensitive? */
  1626. /***************************************************************************/
  1627. LPUSTR INTFUNC ISAMName(
  1628. LPISAM lpISAM);
  1629. /* INPUT: Handle returned by ISAMOpen() */
  1630. /* Returns pointer to a string containing the name of the DBMS or file */
  1631. /* format
  1632. */
  1633. /***************************************************************************/
  1634. LPUSTR INTFUNC ISAMServer(
  1635. LPISAM lpISAM);
  1636. LPUSTR INTFUNC ISAMVersion(
  1637. LPISAM lpISAM);
  1638. /* INPUT: Handle returned by ISAMOpen() */
  1639. /* Returns pointer to a string containing the version of the DBMS or file */
  1640. /* format. */
  1641. /***************************************************************************/
  1642. LPUSTR INTFUNC ISAMRoot (LPISAM lpISAM);
  1643. /***************************************************************************/
  1644. SWORD INTFUNC ISAMGetTableAttr(LPISAMTABLEDEF lpISAMTableDef, LPSTR pAttrStr, SDWORD cbValueMax, SDWORD &cbBytesCopied);
  1645. /***************************************************************************/
  1646. LPCUSTR INTFUNC ISAMDriver(
  1647. LPISAM lpISAM);
  1648. /* INPUT: Handle returned by ISAMOpen() */
  1649. /* Returns pointer to a string containing the name of driver DLL */
  1650. /***************************************************************************/
  1651. SWORD INTFUNC ISAMMaxTableNameLength(
  1652. LPISAM lpISAM);
  1653. /* INPUT: Handle returned by ISAMOpen() */
  1654. /* Returns the maximum length of a table name. Must not exceed */
  1655. /* MAX_TABLE_NAME_LENGTH. */
  1656. /***************************************************************************/
  1657. SWORD INTFUNC ISAMMaxColumnNameLength(
  1658. LPISAM lpISAM);
  1659. /* INPUT: Handle returned by ISAMOpen() */
  1660. /* Returns the maximum length of a column name. Must not exceed */
  1661. /* MAX_COLUMN_NAME_LENGTH. */
  1662. /***************************************************************************/
  1663. LPUSTR INTFUNC ISAMUser(
  1664. LPISAM lpISAM);
  1665. /* INPUT: Handle returned by ISAMOpen() */
  1666. /* Returns the current username. Must not exceed MAX_USER_NAME_LENGTH. */
  1667. /***************************************************************************/
  1668. LPUSTR INTFUNC ISAMDatabase(
  1669. LPISAM lpISAM);
  1670. /* INPUT: Handle returned by ISAMOpen() */
  1671. /* Returns the current database. Must not exceed MAX_DATABASE_NAME_LENGTH */
  1672. /***************************************************************************/
  1673. int INTFUNC ISAMSetDatabase (LPISAM lpISAM, LPUSTR database);
  1674. /***************************************************************************/
  1675. SWORD ISAMGetValueFromVariant(VARIANT &vVariantVal,
  1676. SWORD fCType,
  1677. PTR rgbValue,
  1678. SDWORD cbValueMax,
  1679. SDWORD FAR *pcbValue,
  1680. SWORD wbemVariantType,
  1681. BSTR syntaxStr = NULL,
  1682. SDWORD maxLenVal = -1,
  1683. long myVirIndex = -1);
  1684. /* This function decodes a variant value and stores it in rgbValue*/
  1685. /* the format of the value is govend by fcType */
  1686. /* For more info on parameters see ISAMGetData */
  1687. /***************************************************************************/
  1688. SWORD INTFUNC ISAMBuildTree (HTREEITEM hrootNode, //IN
  1689. char *namespaceName, //IN
  1690. CTreeCtrl& treeCtrl, // IN
  1691. CConnectionDialog& dialog,//IN
  1692. char *server, //IN
  1693. // WBEM_LOGIN_AUTHENTICATION loginMethod, //IN
  1694. char *username, //IN
  1695. char *password, //IN
  1696. BOOL fIntpretEmptPwdAsBlank, //IN
  1697. char *locale, //IN
  1698. char *authority, //IN
  1699. BOOL fNeedChildren, //IN
  1700. BOOL deep, //IN
  1701. HTREEITEM& hTreeItem); //OUT
  1702. /***************************************************************************/
  1703. SWORD INTFUNC ISAMBuildTreeChildren (HTREEITEM hParent, //IN
  1704. char *namespaceName, //IN
  1705. CTreeCtrl& treeCtrl, //IN
  1706. CConnectionDialog& dialog, //IN
  1707. char *server, //IN
  1708. // WBEM_LOGIN_AUTHENTICATION loginMethod, //IN
  1709. char *username, //IN
  1710. char *password, //IN
  1711. BOOL fIntpretEmptPwdAsBlank, //IN
  1712. char *locale, //IN
  1713. char *authority, //IN
  1714. BOOL deep = FALSE);
  1715. /***************************************************************************/
  1716. SWORD INTFUNC ISAMGetNestedNamespaces (char *parent, //IN
  1717. char *name, //IN
  1718. IWbemServices *pGateway, //IN
  1719. DWORD dwAuthLevel, //IN
  1720. DWORD dwImpLevel, //IN
  1721. char *server, //IN
  1722. // WBEM_LOGIN_AUTHENTICATION loginMethod, //IN
  1723. char *user, //IN
  1724. char *pswd, //IN
  1725. BOOL fIntpretEmptPwdAsBlank, //IN
  1726. char *locale, //IN
  1727. char *authority, //IN
  1728. CMapStringToOb *map, // OUT
  1729. BOOL bDeep = TRUE); // IN
  1730. /***************************************************************************/
  1731. IWbemContext* ISAMCreateLocaleIDContextObject(char* lpLocale); //IN
  1732. void ISAMAddLocaleIDContextObject(LPISAMTABLEDEF lpISAMTableDef, //IN OUT
  1733. LPISAM lpISAM); //IN
  1734. void ISAMStringConcat(char** resultString, char* myStr);
  1735. void ISAMCheckTracingOption();
  1736. void ISAMPatchUpGatewaySecurity(LPISAM lpISAM, IWbemServices* myServicesPtr);
  1737. void ISAMGetIWbemServices(LPISAM lpISAM, CSafeWbemServices& mServices, IWbemServicesPtr& myServicesPtr);
  1738. void ISAMCloseWorkerThread1();
  1739. void ISAMCloseWorkerThread2(UINT wParam, LONG lParam);
  1740. void ISAMCheckWorkingThread_AllocEnv();
  1741. void ISAMCheckWorkingThread_FreeEnv();
  1742. BOOL IsW2KOrMore(void);
  1743. HRESULT WbemSetDynamicCloaking(IUnknown* pProxy,
  1744. DWORD dwAuthnLevel, DWORD dwImpLevel);
  1745. HRESULT ISAMSetCloaking1(IUnknown* pProxy, BOOL fIsLocalConnection, BOOL fW2KOrMore, DWORD dwAuthLevel, DWORD dwImpLevel,
  1746. BSTR authorityBSTR, BSTR userBSTR, BSTR passwdBSTR, COAUTHIDENTITY ** gpAuthIdentity);
  1747. HRESULT ISAMSetCloaking2(IUnknown* pProxy, BOOL fIsLocalConnection, BOOL fW2KOrMore, DWORD dwAuthLevel, DWORD dwImpLevel,
  1748. COAUTHIDENTITY * gpAuthIdentity);
  1749. BOOL IsLocalServer(LPSTR szServer);