Use proper namespace for iostream classes
[gnucomo.git] / src / gcm_input / message.cpp
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;
 }