Browse Source

libobs: Add function to get module pointer

Useful for getting getting locale text associated with a specific module
jp9000 5 years ago
parent
commit
de2e89d972
2 changed files with 17 additions and 0 deletions
  1. 14 0
      libobs/obs-module.c
  2. 3 0
      libobs/obs.h

+ 14 - 0
libobs/obs-module.c

@@ -189,6 +189,20 @@ const char *obs_get_module_data_path(obs_module_t *module)
 	return module ? module->data_path : NULL;
 	return module ? module->data_path : NULL;
 }
 }
 
 
+obs_module_t *obs_get_module(const char *name)
+{
+	obs_module_t *module = obs->first_module;
+	while (module) {
+		if (strcmp(module->mod_name, name) == 0) {
+			return module;
+		}
+
+		module = module->next;
+	}
+
+	return NULL;
+}
+
 char *obs_find_module_file(obs_module_t *module, const char *file)
 char *obs_find_module_file(obs_module_t *module, const char *file)
 {
 {
 	struct dstr output = {0};
 	struct dstr output = {0};

+ 3 - 0
libobs/obs.h

@@ -420,6 +420,9 @@ EXPORT int obs_open_module(obs_module_t **module, const char *path,
  */
  */
 EXPORT bool obs_init_module(obs_module_t *module);
 EXPORT bool obs_init_module(obs_module_t *module);
 
 
+/** Returns a module based upon its name, or NULL if not found */
+EXPORT obs_module_t *obs_get_module(const char *name);
+
 /** Logs loaded modules */
 /** Logs loaded modules */
 EXPORT void obs_log_loaded_modules(void);
 EXPORT void obs_log_loaded_modules(void);