Use proper namespace for iostream classes
authorarjen <arjen>
Mon, 4 Nov 2002 10:13:36 +0000 (10:13 +0000)
committerarjen <arjen>
Mon, 4 Nov 2002 10:13:36 +0000 (10:13 +0000)
src/gcm_input/gcm_input.cpp
src/gcm_input/message.cpp
src/gcm_input/message.h
src/include/database.h
src/lib/database.cpp
src/lib/gnucomo_config.cpp
src/phpclasses/gnucomo_config.php
src/web/classes/gnucomo_config.php

index 51fa9b7..40c5520 100644 (file)
@@ -6,7 +6,7 @@
 ***********************
 **      FILE NAME      : gcm_input.cpp
 **      SYSTEM NAME    : Gnucomo - Gnu Computer Monitoring
-**      VERSION NUMBER : $Revision: 1.1 $
+**      VERSION NUMBER : $Revision: 1.2 $
 **
 **  DESCRIPTION      :  Application to store client messages into the database
 **                      The client message contains a log file from one of the
 ********************************
 **      ORIGINAL AUTHOR : Arjen Baart - arjen@andromeda.nl
 **      CREATION DATE   : Aug 29, 2002
-**      LAST UPDATE     : Sep 30, 2002
+**      LAST UPDATE     : Nov 04, 2002
 **      MODIFICATIONS   : 
 **************************************************************************/
 
 /*****************************
    $Log: gcm_input.cpp,v $
-   Revision 1.1  2002-10-05 10:25:49  arjen
+   Revision 1.2  2002-11-04 10:13:36  arjen
+   Use proper namespace for iostream classes
+
+   Revision 1.1  2002/10/05 10:25:49  arjen
    Creation of gcm_input and a first approach to a web interface
 
 *****************************/
 
-static const char *RCSID = "$Id: gcm_input.cpp,v 1.1 2002-10-05 10:25:49 arjen Exp $";
+static const char *RCSID = "$Id: gcm_input.cpp,v 1.2 2002-11-04 10:13:36 arjen Exp $";
 
 #include <getopt.h>
 
@@ -66,7 +69,7 @@ static const char *RCSID = "$Id: gcm_input.cpp,v 1.1 2002-10-05 10:25:49 arjen E
 bool verbose = false;
 bool testmode = false;
 
-static char *Version = "gcm_input version 0.0.3 - Sep 30, 2002";
+static char *Version = "gcm_input version 0.0.4 - Nov 05, 2002";
 
 
 /*=========================================================================
@@ -119,7 +122,7 @@ int main(int argc, char *argv[])
          arrival = String(optarg);
          if (!arrival.proper())
          {
-            cerr << "gcm_input: Invalid date string: " << optarg << ".\n";
+            std::cerr << "gcm_input: Invalid date string: " << optarg << ".\n";
             exit(1);
          }
          break;
@@ -137,41 +140,41 @@ int main(int argc, char *argv[])
          break;
 
       case 'V':
-         cout << Version << "\n";
+         std::cout << Version << "\n";
          exit(0);
 
       case '?':
       case ':':
-         cerr << usage;
+         std::cerr << usage;
          exit(1);
       }
    }
 
    if (verbose)
    {
-      cout << "Hostname = " << hostname;
-      cout << " Arrival = " << arrival;
-      cout << " Service = " << service << "\n";
+      std::cout << "Hostname = " << hostname;
+      std::cout << " Arrival = " << arrival;
+      std::cout << " Service = " << service << "\n";
    }
 
    /*  Get the configuration file */
 
    if (!cfg.read(config_name))
    {
-      cerr << "Can not read Gnucomo configuration file for " << config_name << ".\n";
+      std::cerr << "Can not read Gnucomo configuration file for " << config_name << ".\n";
       exit(1);
    }
 
    if (verbose)
    {
-      cout << "Config OK.\n";
+      std::cout << "Config OK.\n";
    }
 
    /*  Try to connect to the database */
 
    gnucomo_database db(&cfg);
 
-   client_message  msg(&cin, db);
+   client_message  msg(&std::cin, db);
 
    if (msg.classify(hostname, arrival, service) > 0.9)
    {
index 9b1ef1a..de8e676 100644 (file)
@@ -6,7 +6,7 @@
 ***********************
 **      FILE NAME      : message.cpp
 **      SYSTEM NAME    : Gnucomo - Gnu Computer Monitoring
-**      VERSION NUMBER : $Revision: 1.1 $
+**      VERSION NUMBER : $Revision: 1.2 $
 **
 **  DESCRIPTION      :  Implementation of the message handling classes
 **
 ********************************
 **      ORIGINAL AUTHOR : Arjen Baart - arjen@andromeda.nl
 **      CREATION DATE   : Sep 16, 2002
-**      LAST UPDATE     : Oct 05, 2002
+**      LAST UPDATE     : Nov 04, 2002
 **      MODIFICATIONS   : 
 **************************************************************************/
 
 /*****************************
    $Log: message.cpp,v $
-   Revision 1.1  2002-10-05 10:25:49  arjen
+   Revision 1.2  2002-11-04 10:13:36  arjen
+   Use proper namespace for iostream classes
+
+   Revision 1.1  2002/10/05 10:25:49  arjen
    Creation of gcm_input and a first approach to a web interface
 
 *****************************/
 
-static const char *RCSID = "$Id: message.cpp,v 1.1 2002-10-05 10:25:49 arjen Exp $";
+static const char *RCSID = "$Id: message.cpp,v 1.2 2002-11-04 10:13:36 arjen Exp $";
 
 #include "message.h"
 
@@ -52,7 +55,7 @@ String SQL_Escape(String s);
 **  VARS CHANGED   :
 **  FUNCTIONS USED :
 **  SEE ALSO       :
-**  LAST MODIFIED  : Sep 30, 2002
+**  LAST MODIFIED  : Nov 04, 2002
 **=========================================================================
 */
 
@@ -64,7 +67,6 @@ bool operator >> (message_buffer &b, String &s)
    {
       String   l;
 
-      //cout << "     buffer is depleted.\n";
       if (*(b.input) >> l)
       {
          b.buffer.push_back(l);
@@ -73,12 +75,10 @@ bool operator >> (message_buffer &b, String &s)
  
          s = l;
          input_ok = true;
-         //cout << "     new line from input.\n";
       }
    }
    else
    {
-      //cout << "    reading from cache.\n";
       s = *(b.next_line);
       b.next_line++;
       input_ok = true;
@@ -86,7 +86,7 @@ bool operator >> (message_buffer &b, String &s)
    return input_ok;
 }
 
-client_message::client_message(istream *in, gnucomo_database db)
+client_message::client_message(std::istream *in, gnucomo_database db)
 {
    input.from(in);
    database = db;
@@ -127,7 +127,7 @@ static const regex re_email_user("[[:alnum:]_.-]+@");
 **  VARS CHANGED   :
 **  FUNCTIONS USED :
 **  SEE ALSO       :
-**  LAST MODIFIED  : Oct 05, 2002
+**  LAST MODIFIED  : Nov 04, 2002
 **=========================================================================
 */
 
@@ -177,28 +177,28 @@ double client_message::classify(String host, UTC arriv, String serv)
 
    while (input >> line && certainty < 0.9)
    {
-      cout << "  testing: " << line << "\n";
+      std::cout << "  testing: " << line << "\n";
       if (line == re_syslog)
       {
          certainty = 1.0;
          classification = SYSLOG;
          if (verbose)
          {
-            cout << "Syslog detected.\n";
+            std::cout << "Syslog detected.\n";
          }
       }
       else if (line == re_PGP)
       {
          certainty = 1.0;
          gpg_encrypted = true;
-         cerr << "The message is PGP/GnuPG encrypted.\n";
+         std::cerr << "The message is PGP/GnuPG encrypted.\n";
       }
       else if (line == re_dump)
       {
           certainty = 1.0;
           if (verbose)
           {
-             cout << "DUMP output detected.\n";
+             std::cout << "DUMP output detected.\n";
           }
       }
       else if (line == re_accesslog)
@@ -208,7 +208,7 @@ double client_message::classify(String host, UTC arriv, String serv)
           service = "httpd";
           if (verbose)
           {
-             cout << "HTTP access log detected.\n";
+             std::cout << "HTTP access log detected.\n";
           }
       }
       else if (line == re_errorlog)
@@ -218,7 +218,7 @@ double client_message::classify(String host, UTC arriv, String serv)
           service = "httpd";
           if (verbose)
           {
-             cout << "HTTP error log detected.\n";
+             std::cout << "HTTP error log detected.\n";
           }
       }
    }
@@ -226,12 +226,12 @@ double client_message::classify(String host, UTC arriv, String serv)
 
    if (hostname == "")
    {
-      cerr <<  "Can not determine the hostname where the message came from.\n";
+      std::cerr <<  "Can not determine the hostname where the message came from.\n";
       certainty = 0.0;
    }
    else if (!arrival.proper())
    {
-      cerr << "Arrival time is not knwon.\n";
+      std::cerr << "Arrival time is not knwon.\n";
       certainty = 0.0;
    }
    else
@@ -254,7 +254,7 @@ double client_message::classify(String host, UTC arriv, String serv)
 **  VARS CHANGED   :
 **  FUNCTIONS USED :
 **  SEE ALSO       :
-**  LAST MODIFIED  : Oct 05, 2002
+**  LAST MODIFIED  : Nov 04, 2002
 **=========================================================================
 */
 
@@ -284,12 +284,12 @@ int client_message::enter()
    objectid = database.find_host(hostname);
    if (objectid == "")
    {
-      cerr << "Please define the host " << hostname << " in the database.\n";
+      std::cerr << "Please define the host " << hostname << " in the database.\n";
       return 0;
    }
    if (verbose)
    {
-      cout << "Object id for " << hostname << " is " << objectid << "\n";
+      std::cout << "Object id for " << hostname << " is " << objectid << "\n";
    }
 
    /*  Scan the input line by line, entring records into the database */
@@ -300,7 +300,7 @@ int client_message::enter()
    {
       if (verbose)
       {
-         cout << line << "\n";
+         std::cout << line << "\n";
       }
 
 
@@ -345,7 +345,7 @@ int client_message::enter()
 
             if (verbose)
             {
-               cout << "   Log timestamp  = " << log_date << " " << log_time << "\n";
+               std::cout << "   Log timestamp  = " << log_date << " " << log_time << "\n";
             }
             rest = line << 16;
             i = rest.index(' ');
@@ -354,13 +354,13 @@ int client_message::enter()
                rest <<= i + 1;
                if (verbose)
                {
-                  cout << "   Hostname matches.\n";
-                  cout << "   rest = " << rest << "\n";
+                  std::cout << "   Hostname matches.\n";
+                  std::cout << "   rest = " << rest << "\n";
                }
                for (i = 0; isalpha(rest[i]) && i < ~rest; i++);
                if (verbose)
                {
-                  cout << "   Service name = " << rest(0,i) << "\n";
+                  std::cout << "   Service name = " << rest(0,i) << "\n";
                }
 
                /*   Insert a new record into the log table   */
@@ -374,7 +374,7 @@ int client_message::enter()
             
                if (testmode)
                {
-                  cout << insertion << "\n";
+                  std::cout << insertion << "\n";
                }
                else
                {
@@ -383,14 +383,14 @@ int client_message::enter()
 
                if (verbose)
                {
-                  cout << "\n\n";
+                  std::cout << "\n\n";
                }
 
                nr_lines++;
             }
             else
             {
-               cerr << "   Hostname " << rest(0,i) << " does not match.\n";
+               std::cerr << "   Hostname " << rest(0,i) << " does not match.\n";
             }
             break;
 
@@ -403,7 +403,7 @@ int client_message::enter()
             log_time = datestring;
             if (verbose)
             {
-               cout << "   Log timestamp  = " << log_date << " " << log_time << "\n";
+               std::cout << "   Log timestamp  = " << log_date << " " << log_time << "\n";
             }
             insertion += "'" + objectid + "',";
             insertion += "'" + service + "',";
@@ -414,7 +414,7 @@ int client_message::enter()
             
             if (testmode)
             {
-               cout << insertion << "\n";
+               std::cout << insertion << "\n";
             }
             else
             {
@@ -423,7 +423,7 @@ int client_message::enter()
 
             if (verbose)
             {
-               cout << "\n\n";
+               std::cout << "\n\n";
             }
 
             nr_lines++;
@@ -437,7 +437,7 @@ int client_message::enter()
             log_time = datestring;
             if (verbose)
             {
-               cout << "   Log timestamp  = " << log_date << " " << log_time << "\n";
+               std::cout << "   Log timestamp  = " << log_date << " " << log_time << "\n";
             }
             insertion += "'" + objectid + "',";
             insertion += "'" + service + "',";
@@ -448,7 +448,7 @@ int client_message::enter()
             
             if (testmode)
             {
-               cout << insertion << "\n";
+               std::cout << insertion << "\n";
             }
             else
             {
@@ -457,7 +457,7 @@ int client_message::enter()
 
             if (verbose)
             {
-               cout << "\n\n";
+               std::cout << "\n\n";
             }
 
             nr_lines++;
@@ -466,13 +466,13 @@ int client_message::enter()
       }
       else
       {
-         cerr << "gcm_input WARNING: Not a valid line: " << line << "\n";
+         std::cerr << "gcm_input WARNING: Not a valid line: " << line << "\n";
       }
    }
 
    if (verbose)
    {
-      cout << nr_lines << " lines parsed from the log file.\n";
+      std::cout << nr_lines << " lines parsed from the log file.\n";
    }
    return nr_lines;
 }
index 03a8209..bfe5193 100644 (file)
@@ -6,7 +6,7 @@
 ***********************
 **      FILE NAME      : message.h
 **      SYSTEM NAME    : 
-**      VERSION NUMBER : $Revision: 1.1 $
+**      VERSION NUMBER : $Revision: 1.2 $
 **
 **  DESCRIPTION      :  Classes to for handling client messages
 **
 ********************************
 **      ORIGINAL AUTHOR : Arjen Baart - arjen@andromeda.nl
 **      CREATION DATE   : Sep 16, 2002
-**      LAST UPDATE     : Oct 05, 2002
+**      LAST UPDATE     : Nov 04, 2002
 **      MODIFICATIONS   : 
 **************************************************************************/
 
 /*****************************
    $Log: message.h,v $
-   Revision 1.1  2002-10-05 10:25:49  arjen
+   Revision 1.2  2002-11-04 10:13:36  arjen
+   Use proper namespace for iostream classes
+
+   Revision 1.1  2002/10/05 10:25:49  arjen
    Creation of gcm_input and a first approach to a web interface
 
 *****************************/
 
-/* static const char *RCSID = "$Id: message.h,v 1.1 2002-10-05 10:25:49 arjen Exp $"; */
+/* static const char *RCSID = "$Id: message.h,v 1.2 2002-11-04 10:13:36 arjen Exp $"; */
 
 #include <iostream>
 #include <list>
 //
 //  RELATIONS      :
 //  SEE ALSO       :
-//  LAST MODIFIED  : Sep 30, 2002
+//  LAST MODIFIED  : Nov 04, 2002
 ///////////////////////////////////////////////////////////////////////////
 */
 
 class message_buffer
 {
-   istream       *input;
-   list<String>  buffer;
+   std::istream       *input;
+   std::list<String>  buffer;
 
-   list<String>::iterator   next_line;
+   std::list<String>::iterator   next_line;
 
 public:
 
@@ -69,13 +72,13 @@ public:
       next_line = buffer.begin();
    }
 
-   message_buffer(istream *in)
+   message_buffer(std::istream *in)
    {
       input = in;
       next_line = buffer.begin();
    }
 
-   void from(istream *in)
+   void from(std::istream *in)
    {
       input = in;
    }
@@ -117,7 +120,7 @@ public:
 //
 //  RELATIONS      :
 //  SEE ALSO       :
-//  LAST MODIFIED  : Oct 05, 2002
+//  LAST MODIFIED  : Nov 04, 2002
 ///////////////////////////////////////////////////////////////////////////
 */
 
@@ -142,7 +145,7 @@ class client_message
 
 public:
 
-   client_message(istream *in, gnucomo_database db);
+   client_message(std::istream *in, gnucomo_database db);
 
    double classify(String host, UTC arrival = Now(), String serv = "");
    int    enter();
index 5fb2323..8c3279a 100644 (file)
@@ -6,7 +6,7 @@
 ***********************
 **      FILE NAME      : database.h
 **      SYSTEM NAME    : 
-**      VERSION NUMBER : $Revision: 1.1 $
+**      VERSION NUMBER : $Revision: 1.2 $
 **
 **  DESCRIPTION      :  Classes to provide an abstract layer on the Gnucomo
 **                      database.
 ********************************
 **      ORIGINAL AUTHOR : Arjen Baart - arjen@andromeda.nl
 **      CREATION DATE   : Sep 10, 2002
-**      LAST UPDATE     : 
+**      LAST UPDATE     : Nov 04, 2002
 **      MODIFICATIONS   : 
 **************************************************************************/
 
 /*****************************
    $Log: database.h,v $
-   Revision 1.1  2002-10-05 10:25:49  arjen
+   Revision 1.2  2002-11-04 10:13:36  arjen
+   Use proper namespace for iostream classes
+
+   Revision 1.1  2002/10/05 10:25:49  arjen
    Creation of gcm_input and a first approach to a web interface
 
 *****************************/
 
-/* static const char *RCSID = "$Id: database.h,v 1.1 2002-10-05 10:25:49 arjen Exp $"; */
+/* static const char *RCSID = "$Id: database.h,v 1.2 2002-11-04 10:13:36 arjen Exp $"; */
 
 #include <libpq++/pgdatabase.h>
 #include "gnucomo_config.h"
@@ -79,7 +82,7 @@ public:
       }
       else
       {
-         cerr << "Database query error: " << db->ErrorMessage() << "\n";
+         std::cerr << "Database query error: " << db->ErrorMessage() << "\n";
          return -1;
       }
    }
index 134a536..f35727a 100644 (file)
@@ -6,7 +6,7 @@
 ***********************
 **      FILE NAME      : database.cpp
 **      SYSTEM NAME    : Gnucomo - Gnu Computer Monitoring
-**      VERSION NUMBER : $Revision: 1.1 $
+**      VERSION NUMBER : $Revision: 1.2 $
 **
 **  DESCRIPTION      :  Implementation of the gnucomo database classes
 **
 ********************************
 **      ORIGINAL AUTHOR : Arjen Baart - arjen@andromeda.nl
 **      CREATION DATE   : Sep 10, 2002
-**      LAST UPDATE     : Sep 26, 2002
+**      LAST UPDATE     : Nov 04, 2002
 **      MODIFICATIONS   : 
 **************************************************************************/
 
 /*****************************
    $Log: database.cpp,v $
-   Revision 1.1  2002-10-05 10:25:49  arjen
+   Revision 1.2  2002-11-04 10:13:36  arjen
+   Use proper namespace for iostream classes
+
+   Revision 1.1  2002/10/05 10:25:49  arjen
    Creation of gcm_input and a first approach to a web interface
 
 *****************************/
 
-static const char *RCSID = "$Id: database.cpp,v 1.1 2002-10-05 10:25:49 arjen Exp $";
+static const char *RCSID = "$Id: database.cpp,v 1.2 2002-11-04 10:13:36 arjen Exp $";
 
 #include "database.h"
 
@@ -58,14 +61,14 @@ gnucomo_database::gnucomo_database(gnucomo_config *c)
 
    if (verbose)
    {
-      cout <<  "Database connection string = " << cfg->Database() << "\n";
+      std::cout <<  "Database connection string = " << cfg->Database() << "\n";
    }
 
    db = new PgDatabase(cfg->Database());
 
    if (db->ConnectionBad())
    {
-      cerr << "Can not connect to database: " << db->ErrorMessage();
+      std::cerr << "Can not connect to database: " << db->ErrorMessage();
    }
 }
 
index 794241e..0b9fbeb 100644 (file)
@@ -6,7 +6,7 @@
 ***********************
 **      FILE NAME      : gnucomo_config.cpp
 **      SYSTEM NAME    : Gnucomo - Gnu Computer Monitoring
-**      VERSION NUMBER : $Revision: 1.1 $
+**      VERSION NUMBER : $Revision: 1.2 $
 **
 **  DESCRIPTION      :  Implementation of the gnucomo_config class.
 **
 ********************************
 **      ORIGINAL AUTHOR : Arjen Baart - arjen@andromeda.nl
 **      CREATION DATE   : Jul 24, 2002
-**      LAST UPDATE     : Jul 24, 2002
+**      LAST UPDATE     : Nov 02, 2002
 **      MODIFICATIONS   : 
 **************************************************************************/
 
 /*****************************
    $Log: gnucomo_config.cpp,v $
-   Revision 1.1  2002-10-05 10:25:49  arjen
+   Revision 1.2  2002-11-04 10:13:36  arjen
+   Use proper namespace for iostream classes
+
+   Revision 1.1  2002/10/05 10:25:49  arjen
    Creation of gcm_input and a first approach to a web interface
 
 *****************************/
 
-static const char *RCSID = "$Id: gnucomo_config.cpp,v 1.1 2002-10-05 10:25:49 arjen Exp $";
+static const char *RCSID = "$Id: gnucomo_config.cpp,v 1.2 2002-11-04 10:13:36 arjen Exp $";
 
 #include "gnucomo_config.h"
 
@@ -47,7 +50,7 @@ static const char *RCSID = "$Id: gnucomo_config.cpp,v 1.1 2002-10-05 10:25:49 ar
 **  VARS CHANGED   :
 **  FUNCTIONS USED :
 **  SEE ALSO       :
-**  LAST MODIFIED  : 
+**  LAST MODIFIED  : Nov 02, 2002
 **=========================================================================
 */
 
@@ -73,9 +76,6 @@ String gnucomo_config::Database()
       access_string += " password=" + param;
    }
 
-   /*  FIXME: This needs a fix in the AXE library first */
-
-   /*
    param = find_parameter("database", "host");
    if (param != "")
    {
@@ -86,6 +86,5 @@ String gnucomo_config::Database()
    {
       access_string += " port=" + param;
    }
-*/
    return access_string;
 }
index ea57c2f..7f250c5 100644 (file)
@@ -6,15 +6,15 @@ require_once('configuration.class.php');
 ///////////////////////////////////////////////////////////////////////////
 //  NAME           : gnucomo_config
 //  BASECLASS      : configuration
-//  MEMBERS        :
+//  MEMBERS        : 
 //  OPERATORS      :
 //  METHODS        : Database - Obtain the database access string
 //
-//  DESCRIPTION    : 
+//  DESCRIPTION    : Provides Gnucomo-specific configuration functions
 //
 //  RELATIONS      :
 //  SEE ALSO       :
-//  LAST MODIFIED  :
+//  LAST MODIFIED  : Sep 26, 2002
 ///////////////////////////////////////////////////////////////////////////
 */
 
index ea57c2f..7f250c5 100644 (file)
@@ -6,15 +6,15 @@ require_once('configuration.class.php');
 ///////////////////////////////////////////////////////////////////////////
 //  NAME           : gnucomo_config
 //  BASECLASS      : configuration
-//  MEMBERS        :
+//  MEMBERS        : 
 //  OPERATORS      :
 //  METHODS        : Database - Obtain the database access string
 //
-//  DESCRIPTION    : 
+//  DESCRIPTION    : Provides Gnucomo-specific configuration functions
 //
 //  RELATIONS      :
 //  SEE ALSO       :
-//  LAST MODIFIED  :
+//  LAST MODIFIED  : Sep 26, 2002
 ///////////////////////////////////////////////////////////////////////////
 */