瀏覽代碼

textops(k): internal API bind function exported via module interface

- internal API was defined but no function to bind it was available in
  the module interface, reported by Timo Klecker
- rename of functions and typedef'ed struct to match the patterns of
  exporting modules internal API
Daniel-Constantin Mierla 14 年之前
父節點
當前提交
db188fbcf4
共有 3 個文件被更改,包括 13 次插入10 次删除
  1. 1 1
      modules_k/textops/api.c
  2. 9 9
      modules_k/textops/api.h
  3. 3 0
      modules_k/textops/textops.c

+ 1 - 1
modules_k/textops/api.c

@@ -103,7 +103,7 @@ int search_api(struct sip_msg *msg, str *regex){
 /*
  * Function to load the textops api.
  */
-int load_textops(struct textops_binds *tob){
+int bind_textops(textops_api_t *tob){
 	if(tob==NULL){
 		LM_WARN("textops_binds: Cannot load textops API into a NULL pointer\n");
 		return -1;

+ 9 - 9
modules_k/textops/api.h

@@ -37,31 +37,31 @@ typedef int (*search_t)(struct sip_msg*, str*);
 /*
  * Struct with the textops api.
  */
-struct textops_binds{
+typedef struct textops_binds {
 	append_hf_t	append_hf; // Append a header to the message.
 	remove_hf_t	remove_hf; // Remove a header with the specified name from the message.
 	search_append_t search_append; // Append a str after a match of the specified regex.
 	search_t search; // Check if the regex matches a part of the message.
-};
+} textops_api_t;
 
-typedef int (*load_textops_f)(struct textops_binds*);
+typedef int (*bind_textops_f)(textops_api_t*);
 
 /*
  * function exported by module - it will load the other functions
  */
-int load_textops(struct textops_binds*);
+int bind_textops(textops_api_t*);
 
 /*
  * Function to be called direclty from other modules to load
  * the textops API.
  */
-inline static int load_textops_api(struct textops_binds *tob){
-	load_textops_f load_textops_exports;
-	if(!(load_textops_exports=(load_textops_f)find_export("load_textops",0,0))){
-		LM_ERR("Failed to import load_textops\n");
+inline static int load_textops_api(textops_api_t *tob){
+	bind_textops_f bind_textops_exports;
+	if(!(bind_textops_exports=(bind_textops_f)find_export("bind_textops",0,0))){
+		LM_ERR("Failed to import bind_textops\n");
 		return -1;
 	}
-	return load_textops_exports(tob);
+	return bind_textops_exports(tob);
 }
 
 #endif /*TEXT_OPS_API_H_*/

+ 3 - 0
modules_k/textops/textops.c

@@ -254,6 +254,9 @@ static cmd_export_t cmds[]={
 		0, 0,
 		REQUEST_ROUTE|ONREPLY_ROUTE|FAILURE_ROUTE|BRANCH_ROUTE|LOCAL_ROUTE},
 
+	{"bind_textops",      (cmd_function)bind_textops,       0, 0, 0,
+		0},
+
 	{0,0,0,0,0,0}
 };