Browse Source

Print plugin name on init error

Serj Kalichev 11 years ago
parent
commit
fb42907624
4 changed files with 20 additions and 5 deletions
  1. 1 3
      bin/clish.c
  2. 3 1
      clish/plugin.h
  3. 12 0
      clish/plugin/plugin.c
  4. 4 1
      clish/shell/shell_plugin.c

+ 1 - 3
bin/clish.c

@@ -275,10 +275,8 @@ int main(int argc, char **argv)
 	if (histfile_expanded)
 		clish_shell__restore_history(shell, histfile_expanded);
 	/* Load plugins */
-	if (clish_shell_load_plugins(shell) < 0) {
-		fprintf(stderr, "Error: Can't load plugins.\n");
+	if (clish_shell_load_plugins(shell) < 0)
 		goto end;
-	}
 	if (clish_shell_link_plugins(shell) < 0) {
 		fprintf(stderr, "Error: Undefined reference while plugin linking.\n");
 		goto end;

+ 3 - 1
clish/plugin.h

@@ -22,7 +22,9 @@ clish_plugin_fn_t *clish_plugin_get_sym(clish_plugin_t *instance,
 	const char *name);
 int clish_plugin_add_sym(clish_plugin_t *instance,
 	clish_plugin_fn_t *func, const char *name);
-void clish_plugin_dump(const clish_plugin_t *this);
+void clish_plugin_dump(const clish_plugin_t *instance);
+char *clish_plugin__get_name(const clish_plugin_t *instance);
+char *clish_plugin__get_file(const clish_plugin_t *instance);
 
 #endif				/* _clish_plugin_h */
 /** @} clish_plugin */

+ 12 - 0
clish/plugin/plugin.c

@@ -156,3 +156,15 @@ void *clish_plugin_load(clish_plugin_t *this)
 }
 
 /*--------------------------------------------------------- */
+char *clish_plugin__get_name(const clish_plugin_t *this)
+{
+	return this->name;
+}
+
+/*--------------------------------------------------------- */
+char *clish_plugin__get_file(const clish_plugin_t *this)
+{
+	return this->file;
+}
+
+/*--------------------------------------------------------- */

+ 4 - 1
clish/shell/shell_plugin.c

@@ -21,8 +21,11 @@ int clish_shell_load_plugins(clish_shell_t *this)
 	for(iter = lub_list__get_head(this->plugins);
 		iter; iter = lub_list_node__get_next(iter)) {
 		plugin = (clish_plugin_t *)lub_list_node__get_data(iter);
-		if (!clish_plugin_load(plugin))
+		if (!clish_plugin_load(plugin)) {
+			fprintf(stderr, "Error: Can't load plugin %s.\n",
+				clish_plugin__get_file(plugin));
 			return -1;
+		}
 #ifdef DEBUG
 		clish_plugin_dump(plugin);
 #endif