Date: Thursday, March 30, 2006 @ 17:23:53
  Author: marc
    Path: /cvsroot/carob/odbsequoia/src

Modified: connect.cpp (1.19 -> 1.20) inst.hpp (1.5 -> 1.6)

Now looking for "UserName" and "Password" in ini file when arguments are null. 
Implements ODBSEQ-21.


-------------+
 connect.cpp |   27 +++++++++++++++++++++++++--
 inst.hpp    |    2 ++
 2 files changed, 27 insertions(+), 2 deletions(-)


Index: odbsequoia/src/connect.cpp
diff -u odbsequoia/src/connect.cpp:1.19 odbsequoia/src/connect.cpp:1.20
--- odbsequoia/src/connect.cpp:1.19     Thu Mar 23 00:10:59 2006
+++ odbsequoia/src/connect.cpp  Thu Mar 30 17:23:53 2006
@@ -94,6 +94,8 @@
 
     // TODO: call SQLInstallerError() to throw better diags
     // BTW how could we fail when providing a default value?
+    
+    // TODO: write a wrapper function with default arguments
 
     // Slurp DSN information from odbc.ini into ConnectionParameters
 
@@ -140,10 +142,31 @@
     delete[] cdsn;
 #endif
 
+    /** UserName */
+    std::wstring wusername(L""); // default if even SQLGetPr... fails
+    if (user)
+        wusername = fromSQLW(user, userlen);
+    else { // look in INI file
+        if (0 < SQLGetPrivateProfileString(cdsn, USERNAME_INI , "",
+                                        temp, MAX_VALUE_LEN, ODBC_INI))
+            wusername = fromString(std::string(temp));
+    }
+
+    /** Password */
+    std::wstring wpassword(L""); // default if even SQLGetPr... fails
+    if (pass)
+        wpassword = fromSQLW(pass, passlen);
+    else {  // look in INI file
+        if (0 < SQLGetPrivateProfileString(cdsn, PASSWORD_INI, "",
+                                        temp, MAX_VALUE_LEN, ODBC_INI))
+            wpassword = fromString(std::string(temp));
+    }
+
+    /** Connect finally */
     CarobNS::ConnectionParameters
         connectionPrms(serverhost, port, vdbname,
-                       fromSQLW(user, userlen), fromSQLW(pass, passlen),
-                       DEBUG_LEVEL_DEBUG);
+                       wusername, wpassword,
+                       DEBUG_LEVEL_DEBUG); // unused, see CAROB-90
     this->carob_conn = new Connection(connectionPrms);
     // TODO: SQLWarnings -> SUCCESS_WITH_INFO
     return SQL_SUCCESS;
Index: odbsequoia/src/inst.hpp
diff -u odbsequoia/src/inst.hpp:1.5 odbsequoia/src/inst.hpp:1.6
--- odbsequoia/src/inst.hpp:1.5 Wed Mar 22 18:50:14 2006
+++ odbsequoia/src/inst.hpp     Thu Mar 30 17:23:53 2006
@@ -34,6 +34,8 @@
 
 #define SERVER_INI "Servername"
 #define DATABASE_INI "Database"
+#define USERNAME_INI "UserName"
+#define PASSWORD_INI "Password"
 #define PORT_INI "Port"
 #define BACKEND_IDS_INI "BackendIdentifiers"
 #define DEFAULT_BACKEND_IDS_INI "[BackendIdentifiers undefined in INI file]"

_______________________________________________
Carob-commits mailing list
[email protected]
https://forge.continuent.org/mailman/listinfo/carob-commits

Reply via email to