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.

634 lines
23 KiB

  1. /***************************************************************************/
  2. /* DRDBDR.H */
  3. /* Copyright (C) 1995-96 SYWARE Inc., All rights reserved */
  4. /***************************************************************************/
  5. //#define WINVER 0x0400
  6. #include <windows.h>
  7. #ifndef RC_INVOKED
  8. #include <windowsx.h>
  9. #include <string.h>
  10. #ifndef WIN32
  11. #include <dos.h>
  12. #define MAKEWORD(a, b) ((WORD)(((BYTE)(a)) | ((WORD)((BYTE)(b))) << 8))
  13. #endif
  14. #endif
  15. //#define ODBCVER 0x0210
  16. #include <sql.h>
  17. #include <sqlext.h>
  18. typedef struct tagENV FAR *LPENV;
  19. typedef struct tagDBC FAR *LPDBC;
  20. typedef struct tagSTMT FAR *LPSTMT;
  21. typedef struct tagBOUND FAR *LPBOUND;
  22. typedef struct tagPARAMETER FAR *LPPARAMETER;
  23. /* C++ LPSTR -> LPUSTR */
  24. typedef unsigned char FAR* LPUSTR;
  25. typedef const unsigned char FAR* LPCUSTR;
  26. #define s_lstrcpy(a, b) lstrcpy((LPSTR) a, (LPCSTR) b)
  27. #define s_lstrcat(a, b) lstrcat((LPSTR) a, (LPCSTR) b)
  28. #define s_lstrlen(a) lstrlen((LPCSTR) a)
  29. #define s_lstrcmp(a, b) lstrcmp((LPCSTR) a, (LPCSTR) b)
  30. #define s_lstrcmpi(a, b) lstrcmpi((LPCSTR) a, (LPCSTR) b)
  31. //FOR TRACING
  32. #ifdef WBEMDR32_TRACING
  33. //#define ODBCTRACE OutputDebugString
  34. #ifndef __DUHDOSOMETHINGING
  35. #define ODBCTRACE __DuhDoSomething
  36. void __DuhDoSomething(LPCTSTR myStr,...);
  37. #define __DUHDOSOMETHINGING
  38. #endif
  39. #else
  40. #ifndef __DUHDONOTHING
  41. inline void __DuhDoNothing(...) {}
  42. #define __DUHDONOTHING
  43. #endif
  44. #define ODBCTRACE __DuhDoNothing
  45. #endif //WBEMDR32_TRACING
  46. #include "util.h"
  47. #include "sqltype.h"
  48. #include <objbase.h>
  49. #include <initguid.h>
  50. #include "resource.h"
  51. #include "conndlg.h"
  52. #include "isam.h"
  53. #include "parse.h"
  54. #include "bcd.h"
  55. #include "semantic.h"
  56. #include "optimize.h"
  57. #include "evaluate.h"
  58. #include "scalar.h"
  59. /***************************************************************************/
  60. /* Definitions to be used in function prototypes. */
  61. /* The SQL_API is to be used only for those functions exported for */
  62. /* driver manager use. */
  63. /* The INSTAPI is to be used only for those functions exported for */
  64. /* driver administrator use. */
  65. /* The EXPFUNC is to be used only for those functions exported but */
  66. /* used internally, ie, dialog procs. */
  67. /* The INTFUNC is to be used for all other functions. */
  68. #ifdef WIN32
  69. #ifndef INTFUNC
  70. #define INTFUNC __stdcall
  71. #endif
  72. #define EXPFUNC __stdcall
  73. #else
  74. #define INTFUNC PASCAL
  75. #define EXPFUNC __export CALLBACK
  76. #endif
  77. #ifndef WIN32
  78. #define GET_WM_COMMAND_ID(wp, lp) (wp)
  79. #endif
  80. /***************************************************************************/
  81. #define BEFORE_FIRST_ROW (-1)
  82. #define AFTER_LAST_ROW (-2)
  83. #define NO_COLUMN 0
  84. extern HINSTANCE NEAR s_hModule; /* DLL/EXE module handle. */
  85. /* Maximum sizes */
  86. #define MAX_TOKEN_SIZE MAX_CHAR_LITERAL_LENGTH
  87. #define MAX_DRIVER_LENGTH 255
  88. #define MAX_CURSOR_NAME_LENGTH 19
  89. #define MAX_PATHNAME_SIZE MAX_PATH //was 127
  90. #define MAX_COLUMNS_IN_GROUP_BY MAX_COLUMNS_IN_ORDER_BY
  91. #define MAX_BOOLFLAG_LENGTH 5
  92. #define MAX_KEYWORD_SEPARATOR_LENGTH 142 //was 134
  93. #define MAX_KEY_NAME_LENGTH 63
  94. #define NULL_FLAG 'N'
  95. #define NOT_NULL_FLAG ' '
  96. /***************************************************************************/
  97. /* Error codes (also used as string ids in the resource file) */
  98. #define ERR_SUCCESS NO_ISAM_ERR
  99. #define ERR_MEMALLOCFAIL (LAST_ISAM_ERROR_CODE + 1)
  100. #define ERR_DATATRUNCATED (LAST_ISAM_ERROR_CODE + 2)
  101. #define ERR_NOTSUPPORTED (LAST_ISAM_ERROR_CODE + 3)
  102. #define ERR_INVALIDCURSORNAME (LAST_ISAM_ERROR_CODE + 4)
  103. #define ERR_CURSORNAMEINUSE (LAST_ISAM_ERROR_CODE + 5)
  104. #define ERR_CONNECTIONINUSE (LAST_ISAM_ERROR_CODE + 6)
  105. #define ERR_CURSORSTATE (LAST_ISAM_ERROR_CODE + 7)
  106. #define ERR_INVALIDCOLUMNID (LAST_ISAM_ERROR_CODE + 8)
  107. #define ERR_NOTCONVERTABLE (LAST_ISAM_ERROR_CODE + 9)
  108. #define ERR_NOTCAPABLE (LAST_ISAM_ERROR_CODE + 10)
  109. #define ERR_OUTOFRANGE (LAST_ISAM_ERROR_CODE + 11)
  110. #define ERR_ASSIGNMENTERROR (LAST_ISAM_ERROR_CODE + 12)
  111. #define ERR_UNEXPECTEDEND (LAST_ISAM_ERROR_CODE + 13)
  112. #define ERR_ELEMENTTOOBIG (LAST_ISAM_ERROR_CODE + 14)
  113. #define ERR_EXPECTEDOTHER (LAST_ISAM_ERROR_CODE + 15)
  114. #define ERR_MALFORMEDNUMBER (LAST_ISAM_ERROR_CODE + 16)
  115. #define ERR_UNEXPECTEDTOKEN (LAST_ISAM_ERROR_CODE + 17)
  116. #define ERR_BADESCAPE (LAST_ISAM_ERROR_CODE + 18)
  117. #define ERR_INTERNAL (LAST_ISAM_ERROR_CODE + 19)
  118. #define ERR_ISAM (LAST_ISAM_ERROR_CODE + 20)
  119. #define ERR_COLUMNNOTFOUND (LAST_ISAM_ERROR_CODE + 21)
  120. #define ERR_UNKNOWNTYPE (LAST_ISAM_ERROR_CODE + 22)
  121. #define ERR_INVALIDOPERAND (LAST_ISAM_ERROR_CODE + 23)
  122. #define ERR_INVALIDTABLENAME (LAST_ISAM_ERROR_CODE + 24)
  123. #define ERR_ORDINALTOOLARGE (LAST_ISAM_ERROR_CODE + 25)
  124. #define ERR_ORDERBYTOOLARGE (LAST_ISAM_ERROR_CODE + 26)
  125. #define ERR_ORDERBYCOLUMNONLY (LAST_ISAM_ERROR_CODE + 27)
  126. #define ERR_UNEQUALINSCOLS (LAST_ISAM_ERROR_CODE + 28)
  127. #define ERR_INVALIDINSVAL (LAST_ISAM_ERROR_CODE + 29)
  128. #define ERR_INVALIDINVAL (LAST_ISAM_ERROR_CODE + 30)
  129. #define ERR_ALIASINUSE (LAST_ISAM_ERROR_CODE + 31)
  130. #define ERR_COLUMNONLIST (LAST_ISAM_ERROR_CODE + 32)
  131. #define ERR_INVALIDCOLNAME (LAST_ISAM_ERROR_CODE + 33)
  132. #define ERR_NOSUCHTYPE (LAST_ISAM_ERROR_CODE + 34)
  133. #define ERR_BADPARAMCOUNT (LAST_ISAM_ERROR_CODE + 35)
  134. #define ERR_COLUMNFOUND (LAST_ISAM_ERROR_CODE + 36)
  135. #define ERR_NODATAFOUND (LAST_ISAM_ERROR_CODE + 37)
  136. #define ERR_INVALIDCONNSTR (LAST_ISAM_ERROR_CODE + 38)
  137. #define ERR_UNABLETOCONNECT (LAST_ISAM_ERROR_CODE + 39)
  138. #define ERR_PARAMETERMISSING (LAST_ISAM_ERROR_CODE + 40)
  139. #define ERR_DESCOUTOFRANGE (LAST_ISAM_ERROR_CODE + 41)
  140. #define ERR_OPTOUTOFRANGE (LAST_ISAM_ERROR_CODE + 42)
  141. #define ERR_INFOUTOFRANGE (LAST_ISAM_ERROR_CODE + 43)
  142. #define ERR_CANTORDERBYONTHIS (LAST_ISAM_ERROR_CODE + 44)
  143. #define ERR_SORT (LAST_ISAM_ERROR_CODE + 45)
  144. #define ERR_GROUPBYTOOLARGE (LAST_ISAM_ERROR_CODE + 46)
  145. #define ERR_CANTGROUPBYONTHIS (LAST_ISAM_ERROR_CODE + 47)
  146. #define ERR_AGGNOTALLOWED (LAST_ISAM_ERROR_CODE + 48)
  147. #define ERR_NOSELECTSTAR (LAST_ISAM_ERROR_CODE + 49)
  148. #define ERR_GROUPBY (LAST_ISAM_ERROR_CODE + 50)
  149. #define ERR_NOGROUPBY (LAST_ISAM_ERROR_CODE + 51)
  150. #define ERR_ZERODIVIDE (LAST_ISAM_ERROR_CODE + 52)
  151. #define ERR_PARAMINSELECT (LAST_ISAM_ERROR_CODE + 53)
  152. #define ERR_CONCATOVERFLOW (LAST_ISAM_ERROR_CODE + 54)
  153. #define ERR_INVALIDINDEXNAME (LAST_ISAM_ERROR_CODE + 55)
  154. #define ERR_TOOMANYINDEXCOLS (LAST_ISAM_ERROR_CODE + 56)
  155. #define ERR_SCALARNOTFOUND (LAST_ISAM_ERROR_CODE + 57)
  156. #define ERR_SCALARBADARG (LAST_ISAM_ERROR_CODE + 58)
  157. #define ERR_SCALARNOTSUPPORTED (LAST_ISAM_ERROR_CODE + 59)
  158. #define ERR_TXNINPROGRESS (LAST_ISAM_ERROR_CODE + 60)
  159. #define ERR_DDLENCOUNTERD (LAST_ISAM_ERROR_CODE + 61)
  160. #define ERR_DDLIGNORED (LAST_ISAM_ERROR_CODE + 62)
  161. #define ERR_DDLCAUSEDACOMMIT (LAST_ISAM_ERROR_CODE + 63)
  162. #define ERR_DDLSTATEMENTLOST (LAST_ISAM_ERROR_CODE + 64)
  163. #define ERR_MULTICOLUMNSELECT (LAST_ISAM_ERROR_CODE + 65)
  164. #define ERR_NOTSINGLESELECT (LAST_ISAM_ERROR_CODE + 66)
  165. #define ERR_TABLENOTFOUND (LAST_ISAM_ERROR_CODE + 67)
  166. #define MAX_ERROR_LENGTH (SQL_MAX_MESSAGE_LENGTH-1)
  167. /***************************************************************************/
  168. /* Statement handles */
  169. typedef struct tagBOUND { /* Bound column definition */
  170. LPBOUND lpNext; /* Next element on linked list */
  171. UWORD icol; /* Which column is bound */
  172. SWORD fCType; /* The C type of location to put data into */
  173. PTR rgbValue; /* The location to put the data into */
  174. SDWORD cbValueMax; /* Max size of location to put data into */
  175. SDWORD FAR *pcbValue; /* Where to put size of data in rgbValue */
  176. } BOUND,
  177. FAR *LPBOUND;
  178. typedef struct tagPARAMETER { /* PARAMETER definition */
  179. LPPARAMETER lpNext; /* Next element on linked list */
  180. UWORD ipar; /* Which parameter */
  181. SWORD fCType; /* The C type of location to get data from */
  182. PTR rgbValue; /* The location to get the data from */
  183. SDWORD FAR *pcbValue; /* Where to get size of data in rgbValue */
  184. } PARAMETER,
  185. FAR *LPPARAMETER;
  186. typedef struct tagKEYINFO {
  187. UCHAR szPrimaryKeyName[MAX_KEY_NAME_LENGTH+1];
  188. UCHAR szForeignKeyName[MAX_KEY_NAME_LENGTH+1];
  189. UWORD iKeyColumns;
  190. UWORD cKeyColumns;
  191. ISAMKEYCOLUMNNAME PrimaryKeyColumns[MAX_COLUMNS_IN_KEY];
  192. ISAMKEYCOLUMNNAME ForeignKeyColumns[MAX_COLUMNS_IN_KEY];
  193. SWORD fForeignKeyUpdateRule;
  194. SWORD fForeignKeyDeleteRule;
  195. } KEYINFO,
  196. FAR * LPKEYINFO;
  197. typedef struct tagSTMT { /* Statement handle */
  198. LPSTMT lpNext; /* Next element on linked list */
  199. RETCODE errcode; /* Most recent error */
  200. UCHAR szError[MAX_TOKEN_SIZE+1]; /* Auxilary error info */
  201. UCHAR szISAMError[MAX_ERROR_LENGTH+1];
  202. /* ISAM error message */
  203. LPDBC lpdbc; /* Connection the statement belongs to */
  204. UCHAR szCursor[MAX_CURSOR_NAME_LENGTH+1];
  205. /* Cursor name */
  206. UINT fStmtType; /* Type of statement active (STMT_TYPE_*) */
  207. UINT fStmtSubtype; /* Subtype of statement (STMT_SUBTYPE_*) */
  208. SDWORD irow; /* Current row fethed */
  209. SWORD fSqlType; /* Type (SQLGetTypeInfo) */
  210. LPISAMTABLELIST lpISAMTableList;
  211. /* List of tables (SQLTables, */
  212. /* SQLColumns, SQLForeignKeys) */
  213. LPISAMQUALIFIERLIST lpISAMQualifierList;
  214. /* List of qualifiers (SQLTables) */
  215. UCHAR szTableName[MAX_TABLE_NAME_LENGTH+1];
  216. /* Table name (SQLTables, SQLColumns, */
  217. /* SQLForeignKeys) */
  218. UCHAR szQualifierName[MAX_QUALIFIER_NAME_LENGTH+1];
  219. /* Qualifier name (SQLTables) */
  220. LPISAMTABLEDEF lpISAMTableDef;
  221. /* Current table (SQLColumns, SQLStatistics) */
  222. UCHAR szColumnName[MAX_COLUMN_NAME_LENGTH+1];
  223. /* Template for column match (SQLColumns) */
  224. UCHAR szPkTableName[MAX_TABLE_NAME_LENGTH+1];
  225. /* Table name (SQLForeignKeys) */
  226. KEYINFO FAR *lpKeyInfo; /* Key info (SQLForeignKeys) */
  227. UCHAR szTableType[MAX_TABLE_TYPE_LENGTH + 1];
  228. /* Type of table (either 'TABLE' or 'SYSTEM TABLE' */
  229. LPSQLTREE lpSqlStmt; /* Current SQL statement (SQLPrepare) */
  230. BOOL fPreparedSql; /* lpSqlStmt was from SQLPrepare() (not */
  231. /* SQLExecDirect()) */
  232. LPISAMSTATEMENT lpISAMStatement;
  233. /* A passthrough SQL statement */
  234. BOOL fNeedData; /* Waiting for data before command can */
  235. /* execute? */
  236. SQLNODEIDX idxParameter; /* Parameter SQLPutData() is to set */
  237. SDWORD cbParameterOffset; /* Next offset to write in idxParameter */
  238. SDWORD cRowCount; /* Number of INSERT, UPDATE, DELETE rows */
  239. UWORD icol; /* Column read most recently by SQLGetData() */
  240. SDWORD cbOffset; /* Next offset to read in icol */
  241. LPBOUND lpBound; /* List of bound columns */
  242. LPPARAMETER lpParameter; /* List of parameters */
  243. BOOL fISAMTxnStarted;/* Flag specifying a transaction started */
  244. BOOL fDMLTxn; /* Flag specifying DML executed */
  245. UDWORD fSyncMode; /* Indicates if SQL functions are called synchronously or asynchronously */
  246. } STMT,
  247. FAR *LPSTMT;
  248. #define STMT_TYPE_NONE 0
  249. #define STMT_TYPE_TABLES 1
  250. #define STMT_TYPE_COLUMNS 2
  251. #define STMT_TYPE_STATISTICS 3
  252. #define STMT_TYPE_SPECIALCOLUMNS 4
  253. #define STMT_TYPE_TYPEINFO 5
  254. #define STMT_TYPE_PRIMARYKEYS 6
  255. #define STMT_TYPE_FOREIGNKEYS 7
  256. #define STMT_TYPE_SELECT 8 /* This must be the last on on the list */
  257. #define STMT_SUBTYPE_NONE 0
  258. #define STMT_SUBTYPE_TABLES_TABLES 1
  259. #define STMT_SUBTYPE_TABLES_TYPES 2
  260. #define STMT_SUBTYPE_TABLES_QUALIFIERS 3 //added by SMW 04/11/96
  261. #define STMT_SUBTYPE_TABLES_OWNERS 4 //added by SMW 04/11/96
  262. #define STMT_SUBTYPE_FOREIGNKEYS_SINGLE 5
  263. #define STMT_SUBTYPE_FOREIGNKEYS_MULTIPLE_PK_TABLES 6
  264. #define STMT_SUBTYPE_FOREIGNKEYS_MULTIPLE_FK_TABLES 7
  265. /***************************************************************************/
  266. /* Connection handles */
  267. typedef struct tagDBC { /* Connection handle */
  268. LPDBC lpNext; /* Next element on linked list */
  269. LPSTMT lpstmts; /* Statements of this connection */
  270. RETCODE errcode; /* Most recent error */
  271. UCHAR szISAMError[MAX_ERROR_LENGTH+1];
  272. /* ISAM error message */
  273. LPENV lpenv; /* Environment this connection belongs to */
  274. UCHAR szDSN[SQL_MAX_DSN_LENGTH+1];
  275. /* Data source of this connection */
  276. LPISAM lpISAM; /* ISAM connection */
  277. SDWORD fTxnIsolation; /* User-settable isolation state option */
  278. BOOL fAutoCommitTxn; /* User-settable auto-commit state option */
  279. } DBC,
  280. FAR * LPDBC;
  281. /***************************************************************************/
  282. /* Environment handles */
  283. typedef struct tagENV { /* Environment handle */
  284. LPDBC lpdbcs; /* Connections of this environment */
  285. RETCODE errcode; /* Most recent error */
  286. UCHAR szISAMError[MAX_ERROR_LENGTH+1];
  287. /* ISAM error message */
  288. } ENV,
  289. FAR * LPENV;
  290. /***************************************************************************/
  291. /* Virtual Tables */
  292. /* For SQLTables()... */
  293. #define TABLE_QUALIFIER 1
  294. #define TABLE_OWNER 2
  295. #define TABLE_NAME 3
  296. #define TABLE_TYPE 4
  297. #define TABLE_REMARKS 5
  298. #define TABLE_ATTRIBUTES 6
  299. #define COLUMN_COUNT_TABLES 6
  300. /* For SQLColumns()... */
  301. #define COLUMN_QUALIFIER 1
  302. #define COLUMN_OWNER 2
  303. #define COLUMN_TABLE 3
  304. #define COLUMN_NAME 4
  305. #define COLUMN_TYPE 5
  306. #define COLUMN_TYPENAME 6
  307. #define COLUMN_PRECISION 7
  308. #define COLUMN_LENGTH 8
  309. #define COLUMN_SCALE 9
  310. #define COLUMN_RADIX 10
  311. #define COLUMN_NULLABLE 11
  312. #define COLUMN_REMARKS 12
  313. #define COLUMN_ATTRIBUTES 13
  314. #define COLUMN_COUNT_COLUMNS 13
  315. /* For SQLStatistics()... */
  316. #define STATISTIC_QUALIFIER 1
  317. #define STATISTIC_OWNER 2
  318. #define STATISTIC_NAME 3
  319. #define STATISTIC_NONUNIQUE 4
  320. #define STATISTIC_INDEXQUALIFIER 5
  321. #define STATISTIC_INDEXNAME 6
  322. #define STATISTIC_TYPE 7
  323. #define STATISTIC_SEQININDEX 8
  324. #define STATISTIC_COLUMNNAME 9
  325. #define STATISTIC_COLLATION 10
  326. #define STATISTIC_CARDINALITY 11
  327. #define STATISTIC_PAGES 12
  328. #define STATISTIC_FILTERCONDITION 13
  329. #define COLUMN_COUNT_STATISTICS 13
  330. /* For SQLSpecialColumns()... */
  331. #define SPECIALCOLUMN_SCOPE 1
  332. #define SPECIALCOLUMN_NAME 2
  333. #define SPECIALCOLUMN_TYPE 3
  334. #define SPECIALCOLUMN_TYPENAME 4
  335. #define SPECIALCOLUMN_PRECISION 5
  336. #define SPECIALCOLUMN_LENGTH 6
  337. #define SPECIALCOLUMN_SCALE 7
  338. #define SPECIALCOLUMN_PSEUDOCOLUMN 8
  339. #define COLUMN_COUNT_SPECIALCOLUMNS 8
  340. /* For SQLGetTypeInfo()... */
  341. #define TYPEINFO_NAME 1
  342. #define TYPEINFO_TYPE 2
  343. #define TYPEINFO_PRECISION 3
  344. #define TYPEINFO_PREFIX 4
  345. #define TYPEINFO_SUFFIX 5
  346. #define TYPEINFO_PARAMS 6
  347. #define TYPEINFO_NULLABLE 7
  348. #define TYPEINFO_CASESENSITIVE 8
  349. #define TYPEINFO_SEARCHABLE 9
  350. #define TYPEINFO_UNSIGNED 10
  351. #define TYPEINFO_MONEY 11
  352. #define TYPEINFO_AUTOINCREMENT 12
  353. #define TYPEINFO_LOCALNAME 13
  354. #define TYPEINFO_MINSCALE 14
  355. #define TYPEINFO_MAXSCALE 15
  356. #define COLUMN_COUNT_TYPEINFO 15
  357. /* For SQLPrimaryKeys()... */
  358. #define PRIMARYKEY_QUALIFIER 1
  359. #define PRIMARYKEY_OWNER 2
  360. #define PRIMARYKEY_TABLE 3
  361. #define PRIMARYKEY_COLUMN 4
  362. #define PRIMARYKEY_KEYSEQ 5
  363. #define PRIMARYKEY_NAME 6
  364. #define COLUMN_COUNT_PRIMARYKEYS 6
  365. /* For SQLForeignKeys()... */
  366. #define FOREIGNKEY_PKQUALIFIER 1
  367. #define FOREIGNKEY_PKOWNER 2
  368. #define FOREIGNKEY_PKTABLE 3
  369. #define FOREIGNKEY_PKCOLUMN 4
  370. #define FOREIGNKEY_FKQUALIFIER 5
  371. #define FOREIGNKEY_FKOWNER 6
  372. #define FOREIGNKEY_FKTABLE 7
  373. #define FOREIGNKEY_FKCOLUMN 8
  374. #define FOREIGNKEY_KEYSEQ 9
  375. #define FOREIGNKEY_UPDATERULE 10
  376. #define FOREIGNKEY_DELETERULE 11
  377. #define FOREIGNKEY_FKNAME 12
  378. #define FOREIGNKEY_PKNAME 13
  379. #define COLUMN_COUNT_FOREIGNKEYS 13
  380. /***************************************************************************/
  381. /* Table of column definitions for virtual tables */
  382. /* For a description of these values, see SQLColAttributed() in the ODBC spec. */
  383. typedef struct tagCOLATTRIBUTE {
  384. UWORD count;
  385. SDWORD autoIncrement;
  386. SDWORD caseSensitive; /* If -2, use what ISAMCaseSensitive() returns */
  387. SDWORD displaySize;
  388. LPUSTR label;
  389. SDWORD length;
  390. SDWORD money;
  391. LPUSTR name;
  392. SDWORD nullable;
  393. LPUSTR ownerName;
  394. UDWORD precision;
  395. LPUSTR qualifierName;
  396. SDWORD scale;
  397. SDWORD columnSearchable;
  398. LPUSTR tableName;
  399. SDWORD type;
  400. LPSTR typeName;
  401. SDWORD unsignedAttribute;
  402. SDWORD updatable;
  403. } COLATTRIBUTE;
  404. extern COLATTRIBUTE FAR *colAttributes[8];
  405. /***************************************************************************/
  406. /* Internal data types */
  407. #define TYPE_UNKNOWN SQL_TYPE_NULL
  408. #define TYPE_DOUBLE SQL_DOUBLE
  409. #define TYPE_NUMERIC SQL_NUMERIC
  410. #define TYPE_INTEGER SQL_INTEGER
  411. #define TYPE_CHAR SQL_CHAR
  412. #define TYPE_DATE SQL_DATE
  413. #define TYPE_TIME SQL_TIME
  414. #define TYPE_TIMESTAMP SQL_TIMESTAMP
  415. #define TYPE_BINARY SQL_BINARY
  416. /***************************************************************************/
  417. /* INI file Keys */
  418. #define KEY_DSN "DSN"
  419. #define KEY_DRIVER "DRIVER"
  420. #define KEY_DATABASE "DBQ"
  421. #define KEY_USERNAME "UID"
  422. #define KEY_PASSWORD "PWD"
  423. #define KEY_HOST "RemoteHost"
  424. #define KEY_PORT "RemotePort"
  425. #define ODBC_INI "ODBC.INI"
  426. #define KEY_HOME "HOME"
  427. #define KEY_NAMESPACES "NAMESPACES"
  428. #define KEY_SERVER "SERVER"
  429. #define KEY_OPTIMIZATION "OPTIMIZATION"
  430. #define KEY_SYSPROPS "SYSPROPS"
  431. #define KEY_LOGINMETHOD "LOGINMETHOD"
  432. #define KEY_LOCALE "LOCALE"
  433. #define KEY_AUTHORITY "AUTHORITY"
  434. #define KEY_UIDPWDDEFINED "UIDPWDDEFINED"
  435. #define KEY_IMPERSONATE "IMPERSONATE"
  436. #define KEY_PASSTHROUGHONLY "PASSTHROUGHONLY"
  437. #define KEY_INTPRET_PWD_BLK "PWDBLK"
  438. /***************************************************************************/
  439. /* Resource defines for dialog boxes */
  440. #define DATABASE_NAME 100
  441. #define DSN_NAME 101
  442. #define HOST_NAME 102
  443. #define PORT_NUMBER 103
  444. #define STR_SETUP 5000
  445. #define STR_OVERWRITE 5001
  446. #define STR_SUNDAY 5002
  447. #define STR_MONDAY 5003
  448. #define STR_TUESDAY 5004
  449. #define STR_WEDNESDAY 5005
  450. #define STR_THURSDAY 5006
  451. #define STR_FRIDAY 5007
  452. #define STR_SATURDAY 5008
  453. #define STR_JANUARY 5009
  454. #define STR_FEBRUARY 5010
  455. #define STR_MARCH 5011
  456. #define STR_APRIL 5012
  457. #define STR_MAY 5013
  458. #define STR_JUNE 5014
  459. #define STR_JULY 5015
  460. #define STR_AUGUST 5016
  461. #define STR_SEPTEMBER 5017
  462. #define STR_OCTOBER 5018
  463. #define STR_NOVEMBER 5019
  464. #define STR_DECEMBER 5020
  465. /* Class to manage SQLDriverConnect connection string */
  466. #define MAX_OPTIMIZATION_LENGTH 5
  467. class ConnectionStringManager
  468. {
  469. private:
  470. LPSTR ptr;
  471. LPDBC lpdbc;
  472. HWND hwnd;
  473. char* lpszOutputNamespaces;
  474. BOOL foundDriver;
  475. BOOL foundDSN;
  476. BOOL fOptimization;
  477. UWORD fDriverCompletion;
  478. BOOL fUsernameSpecified;
  479. BOOL fPasswordSpecified;
  480. BOOL fImpersonate;
  481. BOOL fServerSpecified;
  482. BOOL fPassthroughOnly;
  483. BOOL fIntpretEmptPwdAsBlank;
  484. UCHAR szDSN[SQL_MAX_DSN_LENGTH+1];
  485. UCHAR szDriver[MAX_DRIVER_LENGTH+1];
  486. UCHAR szDatabase[MAX_DATABASE_NAME_LENGTH+1];
  487. UCHAR szUsername[MAX_USER_NAME_LENGTH+1];
  488. UCHAR szPassword[MAX_PASSWORD_LENGTH+1];
  489. UCHAR szOptimization[MAX_OPTIMIZATION_LENGTH+1];
  490. UCHAR szServer[MAX_SERVER_NAME_LENGTH+1];
  491. UCHAR szHome[MAX_HOME_NAME_LENGTH+1];
  492. char* szLocale;
  493. char* szAuthority;
  494. BOOL fSysProp;
  495. //WBEM_LOGIN_AUTHENTICATION m_loginMethod;
  496. CMapStringToOb *pMapStringToOb;
  497. CMapStringToOb *pMapStringToObOut;
  498. public:
  499. //Precesses the connection string
  500. RETCODE Process();
  501. //Parse the connection string
  502. RETCODE Parse();
  503. //Complement information with information in ODBC.INI file
  504. void GetINI();
  505. //If the is still missing information get it from use via dialog box
  506. RETCODE ShowDialog();
  507. //Re-generate connection string
  508. char* GenerateConnString();
  509. ConnectionStringManager(HDBC fHDBC, HWND hwnd, UCHAR FAR *szConnStr, UWORD fDriverCompletion);
  510. ~ConnectionStringManager();
  511. };
  512. /***************************************************************************/
  513. /* Opt-Tech Sort declaration */
  514. #ifdef WIN32
  515. extern "C" void s_1mains(char *, char *, char *, long *, int *);
  516. #else
  517. void far PASCAL s_1mains(LPSTR, LPSTR, LPSTR, LPLONG, LPINT);
  518. #endif
  519. /***************************************************************************/
  520. #ifdef WIN32
  521. /* Redfine lstrcmp and lstrcmpi back to what everyone expects them to be */
  522. #ifdef lstrcmp
  523. #undef lstrcmp
  524. #endif
  525. #define lstrcmp(left, right) (CompareString(LOCALE_SYSTEM_DEFAULT, \
  526. SORT_STRINGSORT, \
  527. left, -1, right, -1) - 2)
  528. #ifdef lstrcmpi
  529. #undef lstrcmpi
  530. #endif
  531. #define lstrcmpi(left, right) (CompareString(LOCALE_SYSTEM_DEFAULT, \
  532. NORM_IGNORECASE | SORT_STRINGSORT, \
  533. left, -1, right, -1) - 2)
  534. #endif
  535. /***************************************************************************/