From d31e763b12aca6c3ae5a3fc6135cbedede5104cd Mon Sep 17 00:00:00 2001 From: Norbert Moutarde Date: Mon, 29 Jul 2013 13:23:47 +0200 Subject: [PATCH] I've added command line switch to print everything or not (default is to not print) --- main.cpp | 23 +++++++++++++++++------ sqldb.cpp | 25 +++++++++++-------------- sqldb.h | 4 ++-- test-diary-shell.sh | 3 ++- 4 files changed, 32 insertions(+), 23 deletions(-) diff --git a/main.cpp b/main.cpp index ae75c2b..e8bc072 100644 --- a/main.cpp +++ b/main.cpp @@ -12,17 +12,25 @@ string date(string a)//transform any date format (in help) to "YYYY-MM-DD HH:MM: ss>>y>>"-">>m>>"-">>d>>" ">>h>>":">>m>>":">>s>>".">>x; return ss.str();*/ } -int main(int argc, char *argv[]) +int main(int argc, char * argv[]) { - cout << "Début du programme '" << argv[0] << "'." << endl; + cout << "Début du programme '" << argv[0] << "'. argc="<1){ + if (argv[1]==string("p")){ + print=true; + } + }; + clog<<"print="<::iterator it; it = words.begin(); @@ -48,9 +58,10 @@ do{ it = words.insert (it, "default"); diary.alias(words);*/ diary.insert(words); + if(print)diary.print(); } words.clear(); }while(1); -clog<<"Fin du programme\n"; +clog<<"=====================Fin du programme===========================\n"; return 0; } diff --git a/sqldb.cpp b/sqldb.cpp index 6912e0c..b69dbad 100644 --- a/sqldb.cpp +++ b/sqldb.cpp @@ -186,16 +186,13 @@ for (int i=0; i: a.size()=="<) finish\n"; } inline int sqlpg::testSQL(PGresult* a){ if (!((PQresultStatus(a) == PGRES_COMMAND_OK)||(PQresultStatus(a) == PGRES_TUPLES_OK))) { - cout<<"PQerrorMessage(conn): "<< PQerrorMessage(conn)< a){ clog<<"PQprepart done(cmd2="<);// first string is for SQL command, other are to replace %1,%2, etc... - void exec(std::string); + PGresult* exec(std::vector);// first string is for SQL command, other are to replace %1,%2, etc... + PGresult* exec(std::string); bool alias(std::vector); void compulse();//populate table words void connect(std::string, std::string);//connect with user and service (credential in database) diff --git a/test-diary-shell.sh b/test-diary-shell.sh index 7c70b7d..9d3af61 100755 --- a/test-diary-shell.sh +++ b/test-diary-shell.sh @@ -1 +1,2 @@ -sudo -u bob ./diary-shell 2>>error 3>>log + +sudo -u bob ./diary-shell $1 3>>error 2>>log -- 2.45.1