From: Victor Julien Date: Tue, 4 Feb 2014 10:31:02 +0000 (+0100) Subject: threading: add utility to get module id from name X-Git-Tag: suricata-2.0rc1~44 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c36a8d30e5e6de74cae30eb4dc8c1b178a495d72;p=thirdparty%2Fsuricata.git threading: add utility to get module id from name Add TmModuleGetIdByName to go from module name to id directly. --- diff --git a/src/tm-modules.c b/src/tm-modules.c index 0ed4d0a2e5..d00044d8dc 100644 --- a/src/tm-modules.c +++ b/src/tm-modules.c @@ -63,6 +63,16 @@ TmModule *TmModuleGetByName(const char *name) { return NULL; } +/** \brief get the id of a module from it's name + * \param name registered name of the module + * \retval id the id or -1 in case of error */ +int TmModuleGetIdByName(const char *name) { + TmModule *tm = TmModuleGetByName(name); + if (tm == NULL) + return -1;; + return TmModuleGetIDForTM(tm); +} + /** * \brief Returns a TM Module by its id. * diff --git a/src/tm-modules.h b/src/tm-modules.h index 08f8a55561..46065ef973 100644 --- a/src/tm-modules.h +++ b/src/tm-modules.h @@ -106,6 +106,7 @@ int LogFileFreeCtx(LogFileCtx *); TmModule *TmModuleGetByName(const char *name); TmModule *TmModuleGetById(int id); +int TmModuleGetIdByName(const char *name); int TmModuleGetIDForTM(TmModule *tm); TmEcode TmModuleRegister(char *name, int (*module_func)(ThreadVars *, Packet *, void *)); void TmModuleDebugList(void);