浏览代码

Function load_tm_api added

There are many modules that need to access the API of tm module and they all
have to go through the same step of commands to bind the API exported by
the tm module. It makes more sense to create one function which does it all
and make that function available to all other modules using tm.

Signed-off-by: Jan Janak <[email protected]>
Jan Janak 16 年之前
父节点
当前提交
bb21bd2e46
共有 1 个文件被更改,包括 19 次插入0 次删除
  1. 19 0
      modules/tm/tm_load.h

+ 19 - 0
modules/tm/tm_load.h

@@ -140,4 +140,23 @@ typedef int(*load_tm_f)( struct tm_binds *tmb );
 int load_tm( struct tm_binds *tmb);
 
 
+static inline int load_tm_api(struct tm_binds* tmb)
+{
+	load_tm_f load_tm;
+
+	/* import the TM auto-loading function */
+	load_tm = (load_tm_f)find_export("load_tm", NO_SCRIPT, 0);
+	
+	if (load_tm == NULL) {
+		LOG(L_ERR, "Cannot import load_tm function from tm module\n");
+		return -1;
+	}
+	
+	/* let the auto-loading function load all TM stuff */
+	if (load_tm(tmb) == -1) {
+		return -1;
+	}
+	return 0;
+}
+
 #endif