Ver código fonte

Don't use bool_t for hooks. Log hook returns 0 on success

Serj Kalichev 10 anos atrás
pai
commit
56d4cf483a
3 arquivos alterados com 15 adições e 10 exclusões
  1. 1 1
      plugins/clish/hook_access.c
  2. 11 6
      plugins/clish/hook_config.c
  3. 3 3
      plugins/clish/sym_misc.c

+ 1 - 1
plugins/clish/hook_access.c

@@ -31,7 +31,7 @@
  */
 CLISH_HOOK_ACCESS(clish_hook_access)
 {
-	bool_t allowed = -1; /* assume the user is not allowed */
+	int allowed = -1; /* assume the user is not allowed */
 #ifdef HAVE_GRP_H
 	int num_groups;
 	long ngroups_max;

+ 11 - 6
plugins/clish/hook_config.c

@@ -46,6 +46,11 @@ static unsigned short str2ushort(const char *str)
 }
 
 /*--------------------------------------------------------- */
+/* Return values:
+ *    0 - success
+ *    !=0 - fail
+ */
+
 CLISH_HOOK_CONFIG(clish_hook_config)
 {
 	clish_shell_t *this = clish_context__get_shell(clish_context);
@@ -62,11 +67,11 @@ CLISH_HOOK_CONFIG(clish_hook_config)
 	const char *escape_chars = lub_string_esc_quoted;
 
 	if (!this)
-		return BOOL_TRUE;
+		return 0;
 
 	client = clish_shell__get_client(this);
 	if (!client)
-		return BOOL_TRUE;
+		return 0;
 
 	config = clish_command__get_config(cmd);
 	op = clish_config__get_op(config);
@@ -74,7 +79,7 @@ CLISH_HOOK_CONFIG(clish_hook_config)
 	switch (op) {
 
 	case CLISH_CONFIG_NONE:
-		return BOOL_TRUE;
+		return 0;
 
 	case CLISH_CONFIG_SET:
 		/* Add set operation */
@@ -122,7 +127,7 @@ CLISH_HOOK_CONFIG(clish_hook_config)
 		break;
 
 	default:
-		return BOOL_FALSE;
+		return -1;
 	};
 
 	/* Add pattern */
@@ -130,7 +135,7 @@ CLISH_HOOK_CONFIG(clish_hook_config)
 		tstr = clish_shell_expand(clish_config__get_pattern(config), SHELL_VAR_REGEX, clish_context);
 		if (!tstr) {
 			lub_string_free(command);
-			return BOOL_FALSE;
+			return -1;
 		}
 		str = lub_string_encode(tstr, escape_chars);
 		lub_string_free(tstr);
@@ -206,7 +211,7 @@ CLISH_HOOK_CONFIG(clish_hook_config)
 		break;
 	};
 
-	return BOOL_TRUE;
+	return 0;
 }
 
 /*--------------------------------------------------------- */

+ 3 - 3
plugins/clish/sym_misc.c

@@ -37,7 +37,7 @@ CLISH_PLUGIN_SYM(clish_close)
  errors depends on the value of the stop_on_error flag.
 */
 static int clish_source_internal(clish_context_t *context,
-	const char *fn, bool_t stop_on_error)
+	const char *fn, int stop_on_error)
 {
 	int result = -1;
 	const char *filename = fn;
@@ -75,7 +75,7 @@ CLISH_PLUGIN_SYM(clish_source)
 
 	out = out; /* Happy compiler */
 
-	return (clish_source_internal(context, script, BOOL_TRUE));
+	return (clish_source_internal(context, script, 1));
 }
 
 /*----------------------------------------------------------- */
@@ -90,7 +90,7 @@ CLISH_PLUGIN_SYM(clish_source_nostop)
 
 	out = out; /* Happy compiler */
 
-	return (clish_source_internal(context, script, BOOL_FALSE));
+	return (clish_source_internal(context, script, 0));
 }
 
 /*----------------------------------------------------------- */