]> git.nothing2do.fr Git - diary-shell/commitdiff
I can't remember ...
authorNorbert Moutarde <norbert.moutarde@nothing2do.eu>
Mon, 29 Jul 2013 21:01:18 +0000 (23:01 +0200)
committerNorbert Moutarde <norbert.moutarde@nothing2do.eu>
Mon, 29 Jul 2013 21:01:18 +0000 (23:01 +0200)
sqldb.cpp
sqldb.h
tables1.sql

index 922bde057f1334a60d8efbc4bae3695f1a011079..b4bde2095d3648d1d48645cab3ba5056d05f504a 100644 (file)
--- a/sqldb.cpp
+++ b/sqldb.cpp
 using namespace std;
 
 sqlpg::sqlpg() {
-    /* Load the human readable error strings for libcrypto */
-    ERR_load_crypto_strings();
-    /* Load all digest and cipher algorithms */
+    //src : http://www.ibm.com/developerworks/linux/library/l-openssl/index.html
+    SSL_load_error_strings();
+    ERR_load_BIO_strings();
     OpenSSL_add_all_algorithms();
-    /* Load config file, and other important initialisation */
-    OPENSSL_config(NULL);
-    EVP_PKEY *EVP_PKEY_new(void);
+    SSL_library_init();
 
     //strconnect = "host=postgresql1.alwaysdata.com port=5432 dbname=nothing2do.eu_diary user=nothing2do.eu password=x connect_timeout=10";
     strconnect = "dbname=bob user=bob password=pass connect_timeout=10";
@@ -354,7 +352,7 @@ void sqlpg::getvar(){
     };
     clog<<"value.size="<<value.size()<<endl;
 };
-void sqlpg::connect(string service, string name){//I mean "username" but i'm scared to user "username" cause pgsql interpret it ...
+void sqlpg::connect(string service, string name){//I mean "username" but i'm affraid that the string "username" get caught by pgsql ...
     clog<<"connect start here\n";
     string nom="getpass", as=toString(2), i;
     int argca=2;//it won't work if I use argca in place of 2 :-(
@@ -386,6 +384,21 @@ void sqlpg::connect(string service, string name){//I mean "username" but i'm sca
     string pass=PQgetvalue(res, 0, PQfnumber(res, "password"));
     clog<<"service="<<service<<" user="<<name<<" pass="<<pass<<endl;
 
+    string str="jarvis.nothing2do.eu:22";
+    bio = BIO_new_connect(str.c_str());
+    if(bio == NULL)
+    {
+        /* Handle the failure */
+    }
+
+    if(BIO_do_connect(bio) <= 0)
+    {
+        /* Handle failed connection */
+    }
+\r
+    ERR_load_BIO_strings();\r
+    SSL_load_error_strings();\r
+    OpenSSL_add_all_algorithms();
 
 
 }
diff --git a/sqldb.h b/sqldb.h
index 1e712579702aee84ed38465292b1a5802991d3a1..ea87fc4c587bdc5b66f517832de20b74b7104ab0 100644 (file)
--- a/sqldb.h
+++ b/sqldb.h
@@ -7,8 +7,8 @@
 #include <vector>
 #include <cstdio>
 #include <map>
-#include <openssl/conf.h>
-#include <openssl/evp.h>
+/*#include <openssl/conf.h>
+#include <openssl/evp.h>*/
 #include <openssl/ssl.h>
 #include <openssl/err.h>
 #include <openssl/bio.h>
@@ -35,6 +35,9 @@ public:
     void connect(std::string, std::string);//connect with user and service (credential in database)
 
 private:
+    BIO * bio;
+    SSL * ssl;
+    SSL_CTX * ctx;
     PGconn *conn;
     PGresult *res, *res2, *res3;
     std::vector < std::vector<std::string> > ret;//useless ?
index af9f26014c4614cc081c0cd09665f6f5c3d9afef..f4441b09b06eba7eb166ca10977bd1239b6ccf30 100755 (executable)
@@ -52,5 +52,5 @@ name text,
 proto text,
 port integer,
 server text,
-cmd text,
+cmd text
 );