Browse Source

Add access to PARAM parsing

Serj Kalichev 9 years ago
parent
commit
79e969ec67
4 changed files with 24 additions and 0 deletions
  1. 2 0
      clish/param.h
  2. 16 0
      clish/param/param.c
  3. 1 0
      clish/param/private.h
  4. 5 0
      clish/shell/shell_xml.c

+ 2 - 0
clish/param.h

@@ -88,6 +88,8 @@ void clish_param__set_test(clish_param_t * instance, const char *test);
 char *clish_param__get_test(const clish_param_t *instance);
 void clish_param__set_completion(clish_param_t *instance, const char *completion);
 char *clish_param__get_completion(const clish_param_t *instance);
+void clish_param__set_access(clish_param_t *instance, const char *access);
+char *clish_param__get_access(const clish_param_t *instance);
 
 /* paramv methods */
 clish_paramv_t *clish_paramv_new(void);

+ 16 - 0
clish/param/param.c

@@ -32,6 +32,7 @@ static void clish_param_init(clish_param_t *this, const char *name,
 	this->hidden = BOOL_FALSE;
 	this->test = NULL;
 	this->completion = NULL;
+	this->access = NULL;
 
 	this->paramv = clish_paramv_new();
 }
@@ -46,6 +47,7 @@ static void clish_param_fini(clish_param_t * this)
 	lub_string_free(this->value);
 	lub_string_free(this->test);
 	lub_string_free(this->completion);
+	lub_string_free(this->access);
 
 	clish_paramv_delete(this->paramv);
 }
@@ -388,3 +390,17 @@ char *clish_param__get_completion(const clish_param_t *this)
 {
 	return this->completion;
 }
+
+/*--------------------------------------------------------- */
+void clish_param__set_access(clish_param_t *this, const char *access)
+{
+	if (this->access)
+		lub_string_free(this->access);
+	this->access = lub_string_dup(access);
+}
+
+/*--------------------------------------------------------- */
+char *clish_param__get_access(const clish_param_t *this)
+{
+	return this->access;
+}

+ 1 - 0
clish/param/private.h

@@ -25,4 +25,5 @@ struct clish_param_s {
 	bool_t hidden;
 	char *test; /* The condition to enable param */
 	char *completion; /* Possible completions */
+	char *access;
 };

+ 5 - 0
clish/shell/shell_xml.c

@@ -702,6 +702,7 @@ static int process_param(clish_shell_t *shell, clish_xmlnode_t *element,
 		char *hidden = clish_xmlnode_fetch_attr(element, "hidden");
 		char *test = clish_xmlnode_fetch_attr(element, "test");
 		char *completion = clish_xmlnode_fetch_attr(element, "completion");
+		char *access = clish_xmlnode_fetch_attr(element, "access");
 		clish_param_t *param;
 		clish_ptype_t *tmp = NULL;
 
@@ -820,6 +821,9 @@ static int process_param(clish_shell_t *shell, clish_xmlnode_t *element,
 		if (completion)
 			clish_param__set_completion(param, completion);
 
+		if (access)
+			clish_param__set_access(param, access);
+
 		/* add the parameter to the command */
 		if (cmd)
 			clish_command_insert_param(cmd, param);
@@ -842,6 +846,7 @@ error:
 		clish_xml_release(hidden);
 		clish_xml_release(test);
 		clish_xml_release(completion);
+		clish_xml_release(access);
 	}
 
 	return res;