1 /* File: dlg_specific.h 2 * 3 * Description: See "dlg_specific.c" 4 * 5 * Comments: See "readme.txt" for copyright and license information. 6 * 7 */ 8 9 #ifndef __DLG_SPECIFIC_H__ 10 #define __DLG_SPECIFIC_H__ 11 12 #include "psqlodbc.h" 13 14 #ifdef WIN32 15 #include <windowsx.h> 16 #include "resource.h" 17 #endif 18 19 #ifdef __cplusplus 20 extern "C" { 21 #endif /* __cplusplus */ 22 /* Unknown data type sizes */ 23 #define UNKNOWNS_AS_MAX 0 24 #define UNKNOWNS_AS_DONTKNOW 1 25 #define UNKNOWNS_AS_LONGEST 2 26 27 /* ODBC initialization files */ 28 #ifndef WIN32 29 #define ODBC_INI ".odbc.ini" 30 #define ODBCINST_INI "odbcinst.ini" 31 #else 32 #define ODBC_INI "ODBC.INI" 33 #define ODBCINST_INI "ODBCINST.INI" 34 #endif 35 36 #define ODBC_DATASOURCES "ODBC Data Sources" 37 #define INVALID_DRIVER " @@driver not exist@@ " 38 39 #ifdef UNICODE_SUPPORT 40 #define INI_DSN "PostgreSQL35W" 41 #else 42 #define INI_DSN "PostgreSQL30" 43 #endif /* UNICODE_SUPPORT */ 44 45 #define INI_KDESC "Description" /* Data source 46 * description */ 47 #define INI_SERVER "Servername" /* Name of Server 48 * running the Postgres 49 * service */ 50 #define SPEC_SERVER "server" 51 #define INI_PORT "Port" /* Port on which the 52 * Postmaster is listening */ 53 #define INI_DATABASE "Database" /* Database Name */ 54 #define ABBR_DATABASE "DX" /* Database Name */ 55 #define INI_UID "UID" /* Default User Name */ 56 #define INI_USERNAME "Username" /* Default User Name */ 57 #define INI_PASSWORD "Password" /* Default Password */ 58 59 #define INI_ABBREVIATE "CX" 60 #define INI_DEBUG "Debug" /* Debug flag */ 61 #define ABBR_DEBUG "B2" 62 #define INI_FETCH "Fetch" /* Fetch Max Count */ 63 #define ABBR_FETCH "A7" 64 /* 65 * "Socket", abbreviated as "A8" was used for socket buffer. Now that we do 66 * everything through libpq, it's not used 67 */ 68 #define INI_READONLY "ReadOnly" /* Database is read only */ 69 #define ABBR_READONLY "A0" 70 #define INI_COMMLOG "CommLog" /* Communication to 71 * backend logging */ 72 #define ABBR_COMMLOG "B3" 73 #define INI_PROTOCOL "Protocol" /* Controls rollback-on-error 74 * behavior. Called "Protocol" 75 * for historical reasons */ 76 #define ABBR_PROTOCOL "A1" 77 /* "Optimizer", abbreviated to B4 used to stand for "disable genetic query 78 * optimizer". No longer supported, you can use generic ConnSettings instead. 79 #define INI_OPTIMIZER "Optimizer" 80 #define ABBR_OPTIMIZER "B4" 81 */ 82 /* "Ksqo", abbreviated to B5 was used with pre-7.1 server versions for 83 * "keyset query optimization". No longer used. 84 #define INI_KSQO "Ksqo" 85 #define ABBR_KSQO "B5" 86 */ 87 #define INI_CONNSETTINGS "ConnSettings" /* Anything to send to 88 * backend on successful 89 * connection */ 90 #define ABBR_CONNSETTINGS "A6" 91 #define INI_UNIQUEINDEX "UniqueIndex" /* Recognize unique 92 * indexes */ 93 #define INI_UNKNOWNSIZES "UnknownSizes" /* How to handle unknown 94 * result set sizes */ 95 #define ABBR_UNKNOWNSIZES "A9" 96 97 /* "CancelAsFreeStmt", abbreviated to "C1" was used with ODBC versions older 98 * than 3.51. It was a hack that made SQLCancel to imply 99 * SQLFreeStmt(SQL_CLOSE). It never had an effect in > 3.51 mode. 100 #define INI_CANCELASFREESTMT "CancelAsFreeStmt" 101 #define ABBR_CANCELASFREESTMT "C1" 102 */ 103 #define INI_USEDECLAREFETCH "UseDeclareFetch" /* Use Declare/Fetch 104 * cursors */ 105 #define ABBR_USEDECLAREFETCH "B6" 106 107 /* More ini stuff */ 108 #define INI_TEXTASLONGVARCHAR "TextAsLongVarchar" 109 #define ABBR_TEXTASLONGVARCHAR "B7" 110 #define INI_UNKNOWNSASLONGVARCHAR "UnknownsAsLongVarchar" 111 #define ABBR_UNKNOWNSASLONGVARCHAR "B8" 112 #define INI_BOOLSASCHAR "BoolsAsChar" 113 #define ABBR_BOOLSASCHAR "B9" 114 #define INI_MAXVARCHARSIZE "MaxVarcharSize" 115 #define ABBR_MAXVARCHARSIZE "B0" 116 #define INI_MAXLONGVARCHARSIZE "MaxLongVarcharSize" 117 #define ABBR_MAXLONGVARCHARSIZE "B1" 118 119 #define INI_FAKEOIDINDEX "FakeOidIndex" 120 #define ABBR_FAKEOIDINDEX "A2" 121 #define INI_SHOWOIDCOLUMN "ShowOidColumn" 122 #define ABBR_SHOWOIDCOLUMN "A3" 123 #define INI_ROWVERSIONING "RowVersioning" 124 #define ABBR_ROWVERSIONING "A4" 125 #define INI_SHOWSYSTEMTABLES "ShowSystemTables" 126 #define ABBR_SHOWSYSTEMTABLES "A5" 127 #define INI_LIE "Lie" 128 #define INI_PARSE "Parse" 129 #define ABBR_PARSE "C0" 130 #define INI_EXTRASYSTABLEPREFIXES "ExtraSysTablePrefixes" 131 #define ABBR_EXTRASYSTABLEPREFIXES "C2" 132 133 #define INI_TRANSLATIONNAME "TranslationName" 134 #define INI_TRANSLATIONDLL "TranslationDLL" 135 #define INI_TRANSLATIONOPTION "TranslationOption" 136 /* 137 * "DisallowPremature", abbreviated "C3", used to mean that we should not 138 * execute a statement prematurely, before SQLExecute() when e.g. 139 * SQLPrepare+SQLDescribeCol is called. We never do that anymore. 140 * 141 #define INI_DISALLOWPREMATURE "DisallowPremature" 142 #define ABBR_DISALLOWPREMATURE "C3" 143 */ 144 #define INI_UPDATABLECURSORS "UpdatableCursors" 145 #define ABBR_UPDATABLECURSORS "C4" 146 #define INI_LFCONVERSION "LFConversion" 147 #define ABBR_LFCONVERSION "C5" 148 #define INI_TRUEISMINUS1 "TrueIsMinus1" 149 #define ABBR_TRUEISMINUS1 "C6" 150 #define INI_INT8AS "BI" 151 #define INI_NUMERIC_AS "NumericAs" 152 #define ABBR_NUMERIC_AS "D6" 153 #define INI_BYTEAASLONGVARBINARY "ByteaAsLongVarBinary" 154 #define ABBR_BYTEAASLONGVARBINARY "C7" 155 #define INI_USESERVERSIDEPREPARE "UseServerSidePrepare" 156 #define ABBR_USESERVERSIDEPREPARE "C8" 157 #define INI_LOWERCASEIDENTIFIER "LowerCaseIdentifier" 158 #define ABBR_LOWERCASEIDENTIFIER "C9" 159 #define INI_SSLMODE "SSLmode" 160 #define ABBR_SSLMODE "CA" 161 #define INI_EXTRAOPTIONS "AB" 162 #define INI_LOGDIR "Logdir" 163 #define INI_KEEPALIVETIME "KeepaliveTime" 164 #define ABBR_KEEPALIVETIME "D1" 165 #define INI_KEEPALIVEINTERVAL "KeepaliveInterval" 166 #define ABBR_KEEPALIVEINTERVAL "D2" 167 #define INI_PQOPT "pqopt" 168 #define ABBR_PQOPT "D5" 169 #define INI_OPTIONAL_ERRORS "OptionalErrors" 170 #define ABBR_OPTIONAL_ERRORS "D7" 171 #define INI_BATCHSIZE "BatchSize" 172 #define ABBR_BATCHSIZE "D8" 173 #define INI_IGNORETIMEOUT "IgnoreTimeout" 174 #define ABBR_IGNORETIMEOUT "D9" 175 #define INI_DTCLOG "Dtclog" 176 #define INI_FETCHREFCURSORS "FetchRefcursors" 177 #define ABBR_FETCHREFCURSORS "DA" 178 /* "PreferLibpq", abbreviated "D4", used to mean whether to prefer libpq. 179 * libpq is now required 180 #define INI_PREFERLIBPQ "PreferLibpq" 181 #define ABBR_PREFERLIBPQ "D3" 182 */ 183 #define ABBR_XAOPT "D4" 184 185 #define SSLMODE_DISABLE "disable" 186 #define SSLMODE_ALLOW "allow" 187 #define SSLMODE_PREFER "prefer" 188 #define SSLMODE_REQUIRE "require" 189 #define SSLMODE_VERIFY_CA "verify-ca" 190 #define SSLMODE_VERIFY_FULL "verify-full" 191 #define SSLLBYTE_DISABLE 'd' 192 #define SSLLBYTE_ALLOW 'a' 193 #define SSLLBYTE_PREFER 'p' 194 #define SSLLBYTE_REQUIRE 'r' 195 #define SSLLBYTE_VERIFY 'v' 196 197 #ifdef _HANDLE_ENLIST_IN_DTC_ 198 #define INI_XAOPT "XaOpt" 199 #endif /* _HANDLE_ENLIST_IN_DTC_ */ 200 /* Bit representation for abbreviated connection strings */ 201 #define BIT_LFCONVERSION (1L) 202 #define BIT_UPDATABLECURSORS (1L<<1) 203 /* #define BIT_DISALLOWPREMATURE (1L<<2) */ 204 #define BIT_UNIQUEINDEX (1L<<3) 205 #define BIT_UNKNOWN_DONTKNOW (1L<<6) 206 #define BIT_UNKNOWN_ASMAX (1L<<7) 207 #define BIT_COMMLOG (1L<<10) 208 #define BIT_DEBUG (1L<<11) 209 #define BIT_PARSE (1L<<12) 210 #define BIT_CANCELASFREESTMT (1L<<13) 211 #define BIT_USEDECLAREFETCH (1L<<14) 212 #define BIT_READONLY (1L<<15) 213 #define BIT_TEXTASLONGVARCHAR (1L<<16) 214 #define BIT_UNKNOWNSASLONGVARCHAR (1L<<17) 215 #define BIT_BOOLSASCHAR (1L<<18) 216 #define BIT_ROWVERSIONING (1L<<19) 217 #define BIT_SHOWSYSTEMTABLES (1L<<20) 218 #define BIT_SHOWOIDCOLUMN (1L<<21) 219 #define BIT_FAKEOIDINDEX (1L<<22) 220 #define BIT_TRUEISMINUS1 (1L<<23) 221 #define BIT_BYTEAASLONGVARBINARY (1L<<24) 222 #define BIT_USESERVERSIDEPREPARE (1L<<25) 223 #define BIT_LOWERCASEIDENTIFIER (1L<<26) 224 #define BIT_OPTIONALERRORS (1L<<27) 225 #define BIT_FETCHREFCURSORS (1L<<28) 226 227 #define EFFECTIVE_BIT_COUNT 28 228 229 /* Mask for extra options */ 230 #define BIT_FORCEABBREVCONNSTR 1L 231 #define BIT_FAKE_MSS (1L << 1) 232 #define BIT_BDE_ENVIRONMENT (1L << 2) 233 #define BIT_CVT_NULL_DATE (1L << 3) 234 #define BIT_ACCESSIBLE_ONLY (1L << 4) 235 #define BIT_IGNORE_ROUND_TRIP_TIME (1L << 5) 236 #define BIT_DISABLE_KEEPALIVE (1L << 6) 237 #define BIT_DISABLE_CONVERT_FUNC (1L << 7) 238 239 /* Connection Defaults */ 240 #define DEFAULT_READONLY 0 241 #define DEFAULT_PROTOCOL "7.4" /* the latest protocol is 242 * the default */ 243 #define DEFAULT_USEDECLAREFETCH 0 244 #define DEFAULT_TEXTASLONGVARCHAR 1 245 #define DEFAULT_UNKNOWNSASLONGVARCHAR 0 246 #define DEFAULT_BOOLSASCHAR 1 247 #define DEFAULT_UNIQUEINDEX 1 /* dont recognize */ 248 #define DEFAULT_COMMLOG 0 /* dont log */ 249 #define DEFAULT_DEBUG 0 250 #define DEFAULT_UNKNOWNSIZES UNKNOWNS_AS_MAX 251 252 253 #define DEFAULT_FAKEOIDINDEX 0 254 #define DEFAULT_SHOWOIDCOLUMN 0 255 #define DEFAULT_ROWVERSIONING 0 256 #define DEFAULT_SHOWSYSTEMTABLES 0 /* dont show system tables */ 257 #define DEFAULT_LIE 0 258 #define DEFAULT_PARSE 0 259 260 #define DEFAULT_CANCELASFREESTMT 0 261 262 #define DEFAULT_EXTRASYSTABLEPREFIXES "" 263 264 #define DEFAULT_TRUEISMINUS1 0 265 #define DEFAULT_UPDATABLECURSORS 1 266 #ifdef WIN32 267 #define DEFAULT_LFCONVERSION 1 268 #else 269 #define DEFAULT_LFCONVERSION 0 270 #endif /* WIN32 */ 271 #define DEFAULT_INT8AS 0 272 #define DEFAULT_BYTEAASLONGVARBINARY 1 273 #define DEFAULT_USESERVERSIDEPREPARE 1 274 #define DEFAULT_LOWERCASEIDENTIFIER 0 275 #define DEFAULT_SSLMODE SSLMODE_DISABLE 276 #define DEFAULT_NUMERIC_AS (-101) 277 #define DEFAULT_OPTIONAL_ERRORS 0 278 #define DEFAULT_BATCH_SIZE 100 279 #define DEFAULT_IGNORETIMEOUT 0 280 #define DEFAULT_FETCHREFCURSORS 0 281 282 #ifdef _HANDLE_ENLIST_IN_DTC_ 283 #define DEFAULT_XAOPT 1 284 #endif /* _HANDLE_ENLIST_IN_DTC_ */ 285 286 /* for CC_DSN_info */ 287 #define CONN_DONT_OVERWRITE 0 288 #define CONN_OVERWRITE 1 289 290 /* prototypes */ 291 292 #ifdef WIN32 293 void SetDlgStuff(HWND hdlg, const ConnInfo *ci); 294 void GetDlgStuff(HWND hdlg, ConnInfo *ci); 295 296 LRESULT CALLBACK driver_optionsProc(HWND hdlg, 297 UINT wMsg, 298 WPARAM wParam, 299 LPARAM lParam); 300 LRESULT CALLBACK global_optionsProc(HWND hdlg, 301 UINT wMsg, 302 WPARAM wParam, 303 LPARAM lParam); 304 LRESULT CALLBACK ds_options1Proc(HWND hdlg, 305 UINT wMsg, 306 WPARAM wParam, 307 LPARAM lParam); 308 LRESULT CALLBACK ds_options2Proc(HWND hdlg, 309 UINT wMsg, 310 WPARAM wParam, 311 LPARAM lParam); 312 LRESULT CALLBACK ds_options3Proc(HWND hdlg, 313 UINT wMsg, 314 WPARAM wParam, 315 LPARAM lParam); 316 LRESULT CALLBACK manage_dsnProc(HWND hdlg, 317 UINT wMsg, 318 WPARAM wParam, 319 LPARAM lParam); 320 #endif /* WIN32 */ 321 322 int write_Ci_Drivers(const char *fileName, const char *sectionName, 323 const GLOBAL_VALUES *); 324 int writeDriversDefaults(const char *drivername, const GLOBAL_VALUES *); 325 void writeDSNinfo(const ConnInfo *ci); 326 void getDriversDefaults(const char *drivername, GLOBAL_VALUES *); 327 void getDSNinfo(ConnInfo *ci, const char *configDrvrname); 328 void makeConnectString(char *connect_string, const ConnInfo *ci, UWORD); 329 BOOL get_DSN_or_Driver(ConnInfo *ci, const char *attribute, const char *value); 330 BOOL copyConnAttributes(ConnInfo *ci, const char *attribute, const char *value); 331 int getDriverNameFromDSN(const char *dsn, char *driver_name, int namelen); 332 UInt4 getExtraOptions(const ConnInfo *); 333 BOOL setExtraOptions(ConnInfo *, const char *str, const char *format); 334 char *extract_extra_attribute_setting(const pgNAME setting, const char *attr); 335 signed char ci_updatable_cursors_set(ConnInfo *ci); 336 void getCiAllDefaults(ConnInfo *ci); 337 338 #ifdef __cplusplus 339 } 340 #endif /* __cplusplus */ 341 #endif /* __DLG_SPECIFIC_H__ */ 342