[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 3/3] add an initial module detection algorithm
From: |
Trevor Saunders |
Subject: |
[PATCH 3/3] add an initial module detection algorithm |
Date: |
Thu, 18 Nov 2010 06:40:13 -0500 |
we simply walk through the list of files in MODULEBINDIR, and use the
files name to get the paths for that module.
---
config/speechd.conf | 3 ---
src/server/configuration.c | 35 ++++++++++++++++++++++++++++++-----
src/server/module.c | 1 -
src/server/speechd.c | 4 +++-
4 files changed, 33 insertions(+), 10 deletions(-)
diff --git a/config/speechd.conf b/config/speechd.conf
index a230785..99a02f0 100644
--- a/config/speechd.conf
+++ b/config/speechd.conf
@@ -206,8 +206,6 @@ DefaultVolume 100
# - configuration is the path to the config file of this module,
# either relative (to etc/speech-dispatcher/modules/) or absolute
-AddModule "espeak" "sd_espeak" "espeak.conf"
-AddModule "festival" "sd_festival" "festival.conf"
#AddModule "flite" "sd_flite" "flite.conf"
#AddModule "ivona" "sd_ivona" "ivona.conf"
#AddModule "pico" "sd_pico" "pico.conf"
@@ -222,7 +220,6 @@ AddModule "festival" "sd_festival" "festival.conf"
# DO NOT REMOVE the following line unless you have
# a specific reason -- this is the fallback output module
# that is only used when no other modules are in use
-AddModule "dummy" "sd_dummy" ""
# The output module testing doesn't actually connect to anything. It
# outputs the requested commands to standard output and reads
diff --git a/src/server/configuration.c b/src/server/configuration.c
index 6b260c0..9a24591 100644
--- a/src/server/configuration.c
+++ b/src/server/configuration.c
@@ -26,6 +26,9 @@
#include <config.h>
#endif
+#include<dirent.h>
+#include<glib.h>
+
#include <dotconf.h>
#include "speechd.h"
@@ -276,11 +279,6 @@ DOTCONF_CB(cb_CustomLogFile)
DOTCONF_CB(cb_AddModule)
{
OutputModule *module = g_malloc(sizeof(OutputModule));
- char *module_name;
- char *module_prgname;
- char *module_cfgfile;
- char *module_dbgfile;
-
if (cmd->data.list[0] != NULL){
module->name = g_strdup(cmd->data.list[0]);
@@ -476,3 +474,30 @@ load_default_global_set_options()
logfile = stderr;
custom_logfile = NULL;
}
+
+GList *detect_modules(void)
+{
+ GList *modules = NULL;
+ DIR *module_dir = opendir(MODULEBINDIR);
+ struct dirent *entry;
+
+ if(module_dir == NULL){
+ MSG(3, "couldn't open directory %s because of error %s\n",
MODULEBINDIR, strerror(errno));
+ return NULL;
+ }
+
+ while(NULL != (entry = readdir(module_dir))){
+ OutputModule *module = g_malloc(sizeof(OutputModule));
+
+ module->name = g_strdup(entry->d_name+3);
+ module->filename = g_strdup_printf("%s/%s", MODULEBINDIR,
entry->d_name);
+ module->configfilename = g_strdup_printf("%s/modules/%s",
SpeechdOptions.conf_dir, module->name);
+ module->debugfilename = g_strdup_printf("%s/%s.log",
SpeechdOptions.log_dir, module->name);
+ modules = g_list_append(modules, module);
+ }
+
+ closedir(module_dir);
+
+ return modules;
+}
+
diff --git a/src/server/module.c b/src/server/module.c
index 5e8f516..90a2aa7 100644
--- a/src/server/module.c
+++ b/src/server/module.c
@@ -51,7 +51,6 @@ load_output_module(char* mod_name, char* mod_prog, char*
mod_cfgfile, char* mod_
char *arg1 = NULL;
int cfg = 0;
int ret;
- char *module_conf_dir;
char *rep_line = NULL;
FILE *f;
size_t n = 0;
diff --git a/src/server/speechd.c b/src/server/speechd.c
index 95cf570..c64e810 100644
--- a/src/server/speechd.c
+++ b/src/server/speechd.c
@@ -680,7 +680,9 @@ speechd_load_configuration(int sig)
/* Add the LAST option */
spd_options = add_config_option(spd_options, &spd_num_options, "", 0,
NULL, NULL, 0);
-
+
+ loadable_modules = detect_modules();
+
configfile = dotconf_create(SpeechdOptions.conf_file, spd_options, 0,
CASE_INSENSITIVE);
if (configfile){
configfile->includepath = g_strdup(SpeechdOptions.conf_dir);
--
1.7.2.3
- [PATCH 1/3] output_modules should be declared in a c file not a header, (continued)
- [PATCH 1/3] output_modules should be declared in a c file not a header, Trevor Saunders, 2010/11/18
- [PATCH 2/3] move loading of modules out of the AddModule call back, Trevor Saunders, 2010/11/18
- [PATCH 2/3] move loading of modules out of the AddModule call back, Andrei Kholodnyi, 2010/11/18
- [PATCH 2/3] move loading of modules out of the AddModule call back, Christopher Brannon, 2010/11/19
- [PATCH 2/3] move loading of modules out of the AddModule call back, Andrei . Kholodnyi, 2010/11/19
- [PATCH 2/3] move loading of modules out of the AddModule call back, Andrei Kholodnyi, 2010/11/26
- [PATCH 2/3] move loading of modules out of the AddModule call back, Christopher Brannon, 2010/11/27
- [PATCH 2/3] move loading of modules out of the AddModule call back, Christopher Brannon, 2010/11/28
- [PATCH 2/3] move loading of modules out of the AddModule call back, Andrei Kholodnyi, 2010/11/28
[PATCH 3/3] add an initial module detection algorithm,
Trevor Saunders <=
rfc module autodetection patch set, Christopher Brannon, 2010/11/18