]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
threading: add utility to get module id from name
authorVictor Julien <victor@inliniac.net>
Tue, 4 Feb 2014 10:31:02 +0000 (11:31 +0100)
committerVictor Julien <victor@inliniac.net>
Tue, 4 Feb 2014 12:42:21 +0000 (13:42 +0100)
Add TmModuleGetIdByName to go from module name to id directly.

src/tm-modules.c
src/tm-modules.h

index 0ed4d0a2e55833a358291ef4582ed98078678519..d00044d8dcd21bf470ad9af58c8654210ff852fd 100644 (file)
@@ -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.
  *
index 08f8a55561cc67177640a12e6742264a8f1af482..46065ef973d08cf01ec402557971bd68c9f0ad0f 100644 (file)
@@ -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);