Browse Source

Remove unneeded global init and fini hooks

Serj Kalichev 11 years ago
parent
commit
8057489f67
6 changed files with 1 additions and 46 deletions
  1. 0 9
      clish/plugin.h
  2. 0 2
      clish/shell.h
  3. 0 16
      clish/shell/shell_execute.c
  4. 0 6
      clish/shell/shell_new.c
  5. 0 6
      clish/shell/shell_startup.c
  6. 1 7
      clish/shell/shell_xml.c

+ 0 - 9
clish/plugin.h

@@ -12,8 +12,6 @@
 typedef enum {
 	CLISH_SYM_TYPE_NONE = 0, /* None */
 	CLISH_SYM_TYPE_ACTION, /* Common builtin symbol */
-	CLISH_SYM_TYPE_INIT,
-	CLISH_SYM_TYPE_FINI,
 	CLISH_SYM_TYPE_ACCESS,
 	CLISH_SYM_TYPE_CONFIG,
 	CLISH_SYM_TYPE_LOG,
@@ -37,21 +35,14 @@ typedef struct clish_plugin_s clish_plugin_t;
 #define CLISH_PLUGIN_FINI_FUNC(name) int name(void *clish_shell, clish_plugin_t *plugin)
 #define CLISH_PLUGIN_FINI CLISH_PLUGIN_FINI_FUNC(CLISH_PLUGIN_FINI_FNAME)
 
-#define CLISH_HOOK_INIT(name) int name(void *clish_context)
-#define CLISH_HOOK_FINI(name) int name(void *clish_context)
-
 #define CLISH_PLUGIN_SYM(name) int name(void *clish_context, const char *script, char **out)
 #define CLISH_HOOK_ACCESS(name) int name(void *clish_context, const char *access)
 #define CLISH_HOOK_CONFIG(name) int name(void *clish_context)
 #define CLISH_HOOK_LOG(name) int name(void *clish_context, const char *line, int retcode)
 
-/* typedef void clish_shell_cmd_line_fn_t(clish_context_t *context, const char *cmd_line); */
-
 typedef CLISH_PLUGIN_INIT_FUNC(clish_plugin_init_t);
 typedef CLISH_PLUGIN_FINI_FUNC(clish_plugin_fini_t);
 typedef CLISH_PLUGIN_SYM(clish_hook_action_fn_t);
-typedef CLISH_HOOK_INIT(clish_hook_init_fn_t);
-typedef CLISH_HOOK_FINI(clish_hook_fini_fn_t);
 typedef CLISH_HOOK_ACCESS(clish_hook_access_fn_t);
 typedef CLISH_HOOK_CONFIG(clish_hook_config_fn_t);
 typedef CLISH_HOOK_LOG(clish_hook_log_fn_t);

+ 0 - 2
clish/shell.h

@@ -184,8 +184,6 @@ clish_sym_t *clish_shell_get_hook(const clish_shell_t *instance, int type);
 
 /* Hook wrappers */
 void *clish_shell_check_hook(const clish_context_t *clish_context, int type);
-CLISH_HOOK_INIT(clish_shell_exec_init);
-CLISH_HOOK_FINI(clish_shell_exec_fini);
 CLISH_HOOK_ACCESS(clish_shell_exec_access);
 CLISH_HOOK_CONFIG(clish_shell_exec_config);
 CLISH_HOOK_LOG(clish_shell_exec_log);

+ 0 - 16
clish/shell/shell_execute.c

@@ -239,22 +239,6 @@ void *clish_shell_check_hook(const clish_context_t *clish_context, int type)
 	return func;
 }
 
-/*----------------------------------------------------------- */
-CLISH_HOOK_INIT(clish_shell_exec_init)
-{
-	clish_hook_init_fn_t *func = NULL;
-	func = clish_shell_check_hook(clish_context, CLISH_SYM_TYPE_INIT);
-	return func ? func(clish_context) : 0;
-}
-
-/*----------------------------------------------------------- */
-CLISH_HOOK_FINI(clish_shell_exec_fini)
-{
-	clish_hook_fini_fn_t *func = NULL;
-	func = clish_shell_check_hook(clish_context, CLISH_SYM_TYPE_FINI);
-	return func ? func(clish_context) : 0;
-}
-
 /*----------------------------------------------------------- */
 CLISH_HOOK_ACCESS(clish_shell_exec_access)
 {

+ 0 - 6
clish/shell/shell_new.c

@@ -228,13 +228,7 @@ clish_shell_t *clish_shell_new(
 /*--------------------------------------------------------- */
 void clish_shell_delete(clish_shell_t *this)
 {
-	clish_context_t context;
-	context.shell = this;
-
-	/* Now call the client finalization */
-	clish_shell_exec_fini(&context);
 	clish_shell_fini(this);
-
 	free(this);
 }
 

+ 0 - 6
clish/shell/shell_startup.c

@@ -23,12 +23,6 @@ int clish_shell_startup(clish_shell_t *this)
 	context.action = clish_command__get_action(this->startup);
 	context.pargv = NULL;
 
-	/* If an init hook exists - call it. */
-	if (clish_shell_exec_init(&context)) {
-		fprintf(stderr, "Error: Init hook returned error code.\n");
-		return -1;
-	}
-
 	banner = clish_command__get_detail(this->startup);
 	if (banner)
 		tinyrl_printf(this->tinyrl, "%s\n", banner);

+ 1 - 7
clish/shell/shell_xml.c

@@ -23,8 +23,6 @@
 const char* clish_plugin_default_hook[] = {
 	NULL,
 	"clish_script@clish",
-	NULL,
-	NULL,
 	"clish_hook_access@clish",
 	"clish_hook_config@clish",
 	"clish_hook_log@clish"
@@ -1233,11 +1231,7 @@ process_hook(clish_shell_t *shell, clish_xmlnode_t* element, void *parent)
 		goto error;
 	}
 	/* Find out HOOK type */
-	if (!strcmp(name, "init"))
-		type = CLISH_SYM_TYPE_INIT;
-	else if (!strcmp(name, "fini"))
-		type = CLISH_SYM_TYPE_FINI;
-	else if (!strcmp(name, "action"))
+	if (!strcmp(name, "action"))
 		type = CLISH_SYM_TYPE_ACTION;
 	else if (!strcmp(name, "access"))
 		type = CLISH_SYM_TYPE_ACCESS;