db_bridge/main.cpp
changeset 16 2b4ef74a16aa
parent 15 5a0ca1f9a2f1
child 17 b3731a25b9ec
equal deleted inserted replaced
15:5a0ca1f9a2f1 16:2b4ef74a16aa
    11 
    11 
    12 #include <cstdlib>
    12 #include <cstdlib>
    13 
    13 
    14 void usage (std::string progname)
    14 void usage (std::string progname)
    15 {
    15 {
    16     std::cout << "Benutzung: " << progname << " [-r <remotehost>] [-u <user>] [-p <password>] [-h] DATABASE\n" << std::
    16     std::cout << "Benutzung: " << progname << " [-h] [-r <remotehost>] [-u <user>] [-p <password>] DATABASE\n";
    17         endl;
    17 	std::cout << "\t\t-r <remotehost>\t\tVerbindung zu Fremdrechner <remotehost>\n";
    18     std::cout << "Berichten Sie Fehler oder Anregungen an mbroeker@largo.homelinux.org" << std::endl;
    18 	std::cout << "\t\t-u <user>\t\tAnmeldung als <user>\n";
       
    19 	std::cout << "\t\t-p <password>\t\tAnmelden mit dem Passwort <password>\n";
       
    20 	std::cout << "\n";
       
    21 	std::cout << "\t\tDATABASE\t\tVerbindung zur Datenbank DATABASE herstellen\n";
       
    22     std::cout << "\nBerichten Sie Fehler oder Anregungen an mbroeker@largo.homelinux.org" << std::endl;
    19     exit (0);
    23     exit (0);
    20 }
    24 }
    21 
    25 
    22 int main (int argc, char **argv)
    26 int main (int argc, char **argv)
    23 {
    27 {
    29     char c;
    33     char c;
    30 
    34 
    31     std::string host, user, pass, database;
    35     std::string host, user, pass, database;
    32     std::string sql_statement;
    36     std::string sql_statement;
    33 
    37 
    34     while ((c = getopt (argc, argv, "r:u:p:d:h")) >= 0) {
    38     while ((c = getopt (argc, argv, "r:u:p:h")) >= 0) {
    35         switch (c) {
    39         switch (c) {
    36         case 'r':
    40         case 'r':
    37             host = optarg;
    41             host = optarg;
    38             break;
    42             break;
    39         case 'u':
    43         case 'u':
    62         std::cerr << "Kann mich nicht zur Datenbank verbinden. Passwoerter falsch?" << std::endl;
    66         std::cerr << "Kann mich nicht zur Datenbank verbinden. Passwoerter falsch?" << std::endl;
    63         return EXIT_FAILURE;
    67         return EXIT_FAILURE;
    64     }
    68     }
    65 
    69 
    66     for (;;) {
    70     for (;;) {
    67         // std::getline(std::cin, sql_statement);
       
    68         std::cout << "DB_BRIDGE # ";
    71         std::cout << "DB_BRIDGE # ";
    69         std::getline (std::cin, sql_statement);
    72         std::getline (std::cin, sql_statement);
    70 
    73 
    71         if (sql_statement == "quit" || sql_statement == "exit" || sql_statement == "") {
    74         if (sql_statement == "quit" || sql_statement == "exit" || sql_statement == "") {
    72             std::cout << std::endl;
    75             std::cout << std::endl;