From 56edcc623a5f255816a223405707e8b6cadc458b Mon Sep 17 00:00:00 2001 From: Matteo Cypriani Date: Fri, 4 Oct 2013 10:44:40 -0400 Subject: [PATCH] [Aggregator] Limit the verbose level to a maximum For now the maximum verbose level is 4, so it is best for the user to avoid displaying a verbose level higher than that in the configuration. --- TODO.t2t | 2 -- owlps-aggregator/owlps-aggregator.h | 1 + owlps-aggregator/owlps-aggregatord.c | 8 +++++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/TODO.t2t b/TODO.t2t index 35bfd61..53674bf 100644 --- a/TODO.t2t +++ b/TODO.t2t @@ -81,8 +81,6 @@ Work to do in OwlPS - Option to overwrite the output file (ask for a confirmation!). -- Test for the maximum verbose level. - - Outputs should include all the timestamps The CSV output file and the socket should include the capture diff --git a/owlps-aggregator/owlps-aggregator.h b/owlps-aggregator/owlps-aggregator.h index 1978184..7c418a3 100644 --- a/owlps-aggregator/owlps-aggregator.h +++ b/owlps-aggregator/owlps-aggregator.h @@ -43,6 +43,7 @@ #define VERBOSE_INFO cfg_getint(cfg, "verbose") >= 2 #define VERBOSE_CHATTERBOX cfg_getint(cfg, "verbose") >= 3 #define VERBOSE_REQUESTS cfg_getint(cfg, "verbose") >= 4 +#define MAX_VERBOSE_LEVEL 4 /* Linked list storing data of each request */ diff --git a/owlps-aggregator/owlps-aggregatord.c b/owlps-aggregator/owlps-aggregatord.c index 54b241f..8a63773 100644 --- a/owlps-aggregator/owlps-aggregatord.c +++ b/owlps-aggregator/owlps-aggregatord.c @@ -453,9 +453,11 @@ int parse_command_line(const int argc, char *const *argv) " failing back to the default value.\n") ; break ; case 'v' : - // Increment the verbose level - cfg_setint(cfg, "verbose", - cfg_getint(cfg, "verbose") + 1) ; + { // Increment the verbose level if the maximum is not reached + long vlevel = cfg_getint(cfg, "verbose") ; + if (vlevel < MAX_VERBOSE_LEVEL) + cfg_setint(cfg, "verbose", vlevel + 1) ; + } break ; default : print_usage() ;