From: Russ Combs Date: Sat, 12 Apr 2014 12:09:05 +0000 (-0400) Subject: basic sorting of module outputs X-Git-Tag: 3.0.0-233~1576 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a47f07180715fadc9d3c22faf620aaa5fab166c8;p=thirdparty%2Fsnort3.git basic sorting of module outputs --- diff --git a/src/managers/module_manager.cc b/src/managers/module_manager.cc index dda0c0b4c..f611511bf 100644 --- a/src/managers/module_manager.cc +++ b/src/managers/module_manager.cc @@ -400,6 +400,20 @@ bool set_string(const char* fqn, const char* s) return set_value(fqn, v); } +static bool comp_mods(const ModHook* l, const ModHook* r) +{ + const Module* lm = l->mod; + const Module* rm = r->mod; + return strcmp(lm->get_name(), rm->get_name()) < 0; +} + +static bool comp_gids(const ModHook* l, const ModHook* r) +{ + const Module* lm = l->mod; + const Module* rm = r->mod; + return ( lm->get_gid() < rm->get_gid() ); +} + //------------------------------------------------------------------------- // public methods //------------------------------------------------------------------------- @@ -456,6 +470,7 @@ unsigned ModuleManager::get_errors() void ModuleManager::dump_modules() { + s_modules.sort(comp_mods); Dumper d("Modules"); for ( auto* p : s_modules ) @@ -465,6 +480,7 @@ void ModuleManager::dump_modules() void ModuleManager::show_configs(bool markup, const char* pfx) { + s_modules.sort(comp_mods); s_markup = markup; for ( auto p : s_modules ) @@ -497,6 +513,7 @@ void ModuleManager::show_configs(bool markup, const char* pfx) void ModuleManager::show_commands(bool markup, const char* pfx) { + s_modules.sort(comp_mods); s_markup = markup; unsigned len = pfx ? strlen(pfx) : 0; @@ -528,6 +545,7 @@ void ModuleManager::show_commands(bool markup, const char* pfx) void ModuleManager::show_gids(bool markup, const char* pfx) { + s_modules.sort(comp_gids); s_markup = markup; unsigned len = pfx ? strlen(pfx) : 0; @@ -553,9 +571,9 @@ void ModuleManager::show_gids(bool markup, const char* pfx) } } - void ModuleManager::show_rules(bool markup, const char* pfx) { + s_modules.sort(comp_gids); s_markup = markup; unsigned len = pfx ? strlen(pfx) : 0;