Bläddra i källkod

- find_mod_export added (The function can find an export in a specified module).

Jan Janak 22 år sedan
förälder
incheckning
49b28ea4a2
2 ändrade filer med 36 tillägg och 2 borttagningar
  1. 35 2
      sr_module.c
  2. 1 0
      sr_module.h

+ 35 - 2
sr_module.c

@@ -223,9 +223,9 @@ skip:
 
 
 
-/* searches the module list and returns a pointer to the "name" function or
+/* searches the module list and returns pointer to the "name" function or
  * 0 if not found 
- * flags parameter os OR value of all flags that must match
+ * flags parameter is OR value of all flags that must match
  */
 cmd_function find_export(char* name, int param_no, int flags)
 {
@@ -249,6 +249,39 @@ cmd_function find_export(char* name, int param_no, int flags)
 }
 
 
+
+/*
+ * searches the module list and returns pointer to "name" function in module "mod"
+ * 0 if not found
+ * flags parameter is OR value of all flags that must match
+ */
+cmd_function find_mod_export(char* mod, char* name, int param_no, int flags)
+{
+	struct sr_module* t;
+	cmd_export_t* cmd;
+
+	for (t = modules; t; t = t->next) {
+		if (strcmp(t->exports->name, mod) == 0) {
+			for (cmd = t->exports->cmds;  cmd && cmd->name; cmd++) {
+				if ((strcmp(name, cmd->name) == 0) &&
+				    (cmd->param_no == param_no) &&
+				    ((cmd->flags & flags) == flags)
+				   ){
+					DBG("find_mod_export: found <%s> in module %s [%s]\n",
+					    name, t->exports->name, t->path);
+					return cmd->function;
+				}
+			}
+		}
+	}
+
+	DBG("find_mod_export: <%s> in module %s not found\n", name, mod);
+	return 0;
+}
+
+
+
+
 void* find_param_export(char* mod, char* name, modparam_t type)
 {
 	struct sr_module* t;

+ 1 - 0
sr_module.h

@@ -125,6 +125,7 @@ int register_builtin_modules();
 int register_module(struct module_exports*, char*,  void*);
 int load_module(char* path);
 cmd_function find_export(char* name, int param_no, int flags);
+cmd_function find_mod_export(char* mod, char* name, int param_no, int flags);
 struct sr_module* find_module(void *f, cmd_export_t** cmd);
 void destroy_modules();
 int init_child(int rank);