***********************
** FILE NAME : gcm_input.cpp
** SYSTEM NAME : Gnucomo - Gnu Computer Monitoring
-** VERSION NUMBER : $Revision: 1.14 $
+** VERSION NUMBER : $Revision: 1.15 $
**
** DESCRIPTION : Application to store client messages into the database
** The client message contains a log file from one of the
/*****************************
$Log: gcm_input.cpp,v $
- Revision 1.14 2007-11-03 10:26:13 arjen
+ Revision 1.15 2007-11-14 16:19:25 arjen
+ Bugfix: Segmentation fault when reading an rpm package list
+ with empty lines.
+
+ Revision 1.14 2007/11/03 10:26:13 arjen
Added a new filter which can directly read the output
of the UNIX df command. A brief description is added in
the user manual.
*****************************/
-static const char *RCSID = "$Id: gcm_input.cpp,v 1.14 2007-11-03 10:26:13 arjen Exp $";
+static const char *RCSID = "$Id: gcm_input.cpp,v 1.15 2007-11-14 16:19:25 arjen Exp $";
#include <fstream>
msg.add_cooker(&dlc, &df);
message_probability = msg.classify(hostname, arrival, service);
- *Log << "Message type probability = " << message_probability << "\n";
if (message_probability > 0.75)
{
try
***********************
** FILE NAME : rpm_filter.cpp
** SYSTEM NAME :
-** VERSION NUMBER : $Revision: 1.1 $
+** VERSION NUMBER : $Revision: 1.2 $
**
** DESCRIPTION : Transform a list of packages into a Gnucomo XML document
**
********************************
** ORIGINAL AUTHOR : Arjen Baart - arjen@andromeda.nl
** CREATION DATE : Nov 27, 2003
-** LAST UPDATE : Nov 27, 2003
+** LAST UPDATE : Nov 12, 2007
** MODIFICATIONS :
**************************************************************************/
/*****************************
$Log: rpm_filter.cpp,v $
- Revision 1.1 2003-12-04 10:38:09 arjen
+ Revision 1.2 2007-11-14 16:19:25 arjen
+ Bugfix: Segmentation fault when reading an rpm package list
+ with empty lines.
+
+ Revision 1.1 2003/12/04 10:38:09 arjen
Major redesign. All input is handled through XML. Raw input data is first
transformed into an XML document for further processing.
A collection of polymorphic classes handle the transformation of various
*****************************/
-/* static const char *RCSID = "$Id: rpm_filter.cpp,v 1.1 2003-12-04 10:38:09 arjen Exp $"; */
+/* static const char *RCSID = "$Id: rpm_filter.cpp,v 1.2 2007-11-14 16:19:25 arjen Exp $"; */
#include <ctype.h>
** VARS CHANGED :
** FUNCTIONS USED :
** SEE ALSO :
-** LAST MODIFIED : Nov 27, 2003
+** LAST MODIFIED : Nov 12, 2007
**=========================================================================
*/
+static const regex re_rpm("[[:alnum:]+-]+-[0-9][[:alnum:].-]");
+
void rpm_filter::construct_XML(message_buffer &in, std::strstream &xml)
{
String line;
int version_start, next_version_start;
int i;
- // Separate the package name from the version number
+ if (line == re_rpm)
+ {
+ // Separate the package name from the version number
- i = line.index('-');
- version_start = i;
- next_version_start = i;
+ i = line.index('-');
- while (i < ~line - 1)
- {
- while (i < ~line - 1 && !(line[i] == '-' && isdigit(line[i + 1])))
+ version_start = i;
+ next_version_start = i;
+
+ while (i < ~line - 1)
{
+ while (i < ~line - 1 && !(line[i] == '-' && isdigit(line[i + 1])))
+ {
+ i++;
+ }
+ if (i < ~line - 1)
+ {
+ version_start = next_version_start;
+ next_version_start = i;
+ }
i++;
}
- if (i < ~line - 1)
+
+ if (!isdigit(line[version_start + 1]))
{
version_start = next_version_start;
- next_version_start = i;
}
- i++;
- }
-
- if (!isdigit(line[version_start + 1]))
- {
- version_start = next_version_start;
- }
- String package(line(0,version_start));
- String version(line(version_start + 1, ~line));
+ String package(line(0,version_start));
+ String version(line(version_start + 1, ~line));
- // Create the XML element.
+ // Create the XML element.
- xml << " <gcmt:parameter name='" << package << "'>\n";
- xml << " <gcmt:property name='version'>" << version << "</gcmt:property>\n";
- xml << " </gcmt:parameter>\n";
+ xml << " <gcmt:parameter name='" << package << "'>\n";
+ xml << " <gcmt:property name='version'>" << version << "</gcmt:property>\n";
+ xml << " </gcmt:parameter>\n";
+ }
}
xml << " </gcmt:parameters>\n";
xml << " </gcmt:data>\n";
xml << "</gcmt:message>\n";
}
-static const regex re_rpm("[[:alnum:]+-]+-[0-9][[:alnum:].-]");
-
bool rpm_cooker::check_pattern(String logline)
{
return logline == re_rpm;