From: Norbert Moutarde Date: Thu, 8 Aug 2013 15:33:49 +0000 (+0200) Subject: I've added some alias (getconninfo, ...) and I try to delete all sql command from... X-Git-Url: https://git.nothing2do.fr/?a=commitdiff_plain;h=cd42315e326119ef74337c918e91ebfbabe719a1;p=diary-shell I've added some alias (getconninfo, ...) and I try to delete all sql command from C++ file --- diff --git a/alias.sql b/alias.sql index eefc811..77f4624 100644 --- a/alias.sql +++ b/alias.sql @@ -21,4 +21,5 @@ insert into alias (nom, cmd, argc, inf, help) values ('aliasadd', 'insert into a insert into alias (nom, cmd, argc, help) values ('get', 'select service,password from credential where username=$1;', 1, 'command to retrieve service and password with a user name (perhaps more than one)'); insert into alias (nom, cmd, argc, help) values ('get', 'select distinct service from credential;', 0, 'get a list of service you have credential for'); insert into alias (nom, cmd, argc, help) values ('getpass', 'select password from credential where service=$1 and username=$2;', 2, 'retrieve one saved password (as service and user has unique constraint)'); -insert into alias (nom, cmd, argc, help) values ('info', 'select date from raw where id=$1;', 1, 'retrieve date from a saved entry'); +insert into alias (nom, cmd, argc, help) values ('info', 'select date from raw where id=$1;', 1, 'retrieve date by ID'); +insert into alias (nom, cmd, argc, help) values ('getconninfo', 'select server,port,proto from service where name=$1;', 1, 'retrieve conninfo (server, port and proto)'); diff --git a/credential.sql b/credential.sql index a0fbb53..b2f8617 100644 --- a/credential.sql +++ b/credential.sql @@ -1 +1 @@ -insert into credential (service, username, password) values ('pop', 'me', 'pass'); +insert into credential (service, username, password) values ('pop', 'user', 'pass'); diff --git a/service.sql b/service.sql index f8867ad..48634dd 100644 --- a/service.sql +++ b/service.sql @@ -1 +1,2 @@ -insert into service (name, proto, port, server, cmd) values ('gmail', 'https', 443, 'www.gmail.com', '...'); +insert into service (name, port, server, cmd) values ('yahoo.fr', 993, 'imap.mail.yahoo.com', 'login $1@$2') +insert into service (name, port, server, cmd) values ('yahoo.fr', 993, 'imap.mail.yahoo.com', '') diff --git a/sqldb.cpp b/sqldb.cpp index 2b9b93b..312b80e 100644 --- a/sqldb.cpp +++ b/sqldb.cpp @@ -7,6 +7,7 @@ #include #include #include +#include "SSL.hpp" using namespace std; @@ -243,7 +244,7 @@ bool sqlpg::alias(vector a){ res=PQexecPrepared(conn, "selectalias", argca, valuea, lengtha, binarya, 0); testSQL(res); if (PQntuples(res)!=1){ - cerr<<"alias end more than one alias found ! (pqntuples(res)="< a){ res=PQexecPrepared(conn, "execalias", argc, value, length, binary, 0); clog<<"PQexecPrepared done.\n"; testSQL(res); - //print(); exec("DEALLOCATE execalias"); clog<<"alias() end here\n"; return 1; @@ -345,35 +345,29 @@ void sqlpg::getvar(){ }; 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 :-( - bool inf=0; - const char *valuea[2]={nom.c_str(), as.c_str()}; - int lengtha[2]={nom.size(), as.size()}; - int binarya[2]={0, 0}; - res=PQexecPrepared(conn, "selectalias", argca, valuea, lengtha, binarya, 0); - testSQL(res); - if (PQntuples(res)!=1){ - cerr<<"getpass ! (pqntuples(res)="<commande : "< tmp; + tmp.push_back("getpass"); + tmp.push_back(service); + tmp.push_back(name); + alias(tmp); string pass=PQgetvalue(res, 0, PQfnumber(res, "password")); - clog<<"service="<