2 /**************************************************************************
3 ** (c) Copyright 2002, Andromeda Technology & Automation
4 ** This is free software; you can redistribute it and/or modify it under the
5 ** terms of the GNU General Public License, see the file COPYING.
6 ***************************************************************************
7 ** MODULE INFORMATION *
8 ***********************
9 ** FILE NAME : message.h
11 ** VERSION NUMBER : $Revision: 1.7 $
13 ** DESCRIPTION : Classes to for handling client messages
18 ***************************************************************************
19 ** ADMINISTRATIVE INFORMATION *
20 ********************************
21 ** ORIGINAL AUTHOR : Arjen Baart - arjen@andromeda.nl
22 ** CREATION DATE : Sep 16, 2002
23 ** LAST UPDATE : Aug 06, 2003
25 **************************************************************************/
27 /*****************************
29 Revision 1.7 2003-08-11 16:56:16 arjen
30 Different kinds of log files are parsed by a collection of objects
31 of different classes, derived from the base class line_cooker
32 Depending on the message content or the message_type element in
33 XML, one of these objects is selected.
35 Logrunner is integrated with gcm_input. Although its functionality
36 is still limited, a connection between logrunner and gcm_input
39 Revision 1.6 2003/04/29 09:16:44 arjen
41 Only cooked log entries for now.
43 Revision 1.5 2003/03/16 09:42:40 arjen
44 Read IRIX system logs.
46 Revision 1.4 2002/12/06 22:26:28 arjen
47 Set the value of log.processed to FALSE when inserting a
48 new log entry into the database
49 When a syslog entry arrives from last year, gcm_input subtracts one from the
50 year of arrival to create the year of the log entry.
51 Read output from "rpm -qa" and enter packages in the parameter table.
53 Revision 1.3 2002/11/09 08:04:27 arjen
54 Added a reference to the GPL
56 Revision 1.2 2002/11/04 10:13:36 arjen
57 Use proper namespace for iostream classes
59 Revision 1.1 2002/10/05 10:25:49 arjen
60 Creation of gcm_input and a first approach to a web interface
62 *****************************/
64 /* static const char *RCSID = "$Id: message.h,v 1.7 2003-08-11 16:56:16 arjen Exp $"; */
68 #include <AXE/String.h>
71 #include <libxml/parser.h>
73 #include "line_cooker.h"
77 ///////////////////////////////////////////////////////////////////////////
78 // NAME : message_buffer
88 // LAST MODIFIED : Nov 04, 2002
89 ///////////////////////////////////////////////////////////////////////////
95 std::list<String> buffer;
97 std::list<String>::iterator next_line;
104 next_line = buffer.begin();
107 message_buffer(std::istream *in)
110 next_line = buffer.begin();
113 void from(std::istream *in)
118 friend bool operator >> (message_buffer &, String &);
122 next_line = buffer.begin();
127 if (next_line != buffer.end())
135 if (next_line != buffer.begin())
143 ///////////////////////////////////////////////////////////////////////////
144 // NAME : client_message
148 // METHODS : classify()
155 // LAST MODIFIED : Aug 06, 2003
156 ///////////////////////////////////////////////////////////////////////////
161 String hostname; // Where the message came from (FQDN)
162 UTC arrival; // When we got the message.
163 String service; // Service that created the message
165 std::list<line_cooker *> kitchen; // The collection of line cookers
166 line_cooker * pan; // The one we cook this log with
168 bool mail_header; // Does the message contain a mail header ?
169 bool gpg_encrypted; // Is the message encrypted ?
173 double certainty; // How certain are we about the message
176 UNKNOWN, RPMLIST, XML, COOKER_OBJECT
180 message_buffer input;
181 gnucomo_database database;
183 int readXMLinput(String first_line);
188 client_message(std::istream *in, gnucomo_database db);
190 void add_cooker(line_cooker *lc)
192 kitchen.push_back(lc);
195 double classify(String host, UTC arrival = Now(), String serv = "");