Browse Source

The CONFIG use separate class now

git-svn-id: https://klish.googlecode.com/svn/trunk@434 0eaa4687-2ee9-07dd-09d9-bcdd2d2dd5fb
Serj Kalichev 13 years ago
parent
commit
885a26c011

File diff suppressed because it is too large
+ 12 - 6
Makefile.in


+ 45 - 13
clish/callback_config.c

@@ -22,19 +22,43 @@
 
 static int send_request(konf_client_t * client, char *command);
 
+static unsigned short str2ushort(const char *str)
+{
+	unsigned short num = 0;
+
+	if (str && (*str != '\0')) {
+		long val = 0;
+		char *endptr;
+
+		val = strtol(str, &endptr, 0);
+		if (endptr == str)
+			num = 0;
+		else if (val > 0xffff)
+			num = 0xffff;
+		else if (val < 0)
+			num = 0;
+		else
+			num = (unsigned)val;
+	}
+
+	return num;
+}
+
 /*--------------------------------------------------------- */
 bool_t clish_config_callback(clish_context_t *context)
 {
 	clish_shell_t *this = context->shell;
 	const clish_command_t *cmd = context->cmd;
 	clish_pargv_t *pargv = context->pargv;
+	clish_config_t *config;
 	char *command = NULL;
 	konf_client_t *client;
 	konf_buf_t *buf = NULL;
 	const char *viewid = NULL;
 	char *str = NULL;
 	char tmp[PATH_MAX + 100];
-	clish_config_operation_t op;
+	clish_config_op_t op;
+	unsigned int num;
 
 	if (!this)
 		return BOOL_TRUE;
@@ -44,7 +68,8 @@ bool_t clish_config_callback(clish_context_t *context)
 		return BOOL_TRUE;
 
 	viewid = clish_shell__get_viewid(this);
-	op = clish_command__get_cfg_op(cmd);
+	config = clish_command__get_config(cmd);
+	op = clish_config__get_op(config);
 
 	switch (op) {
 
@@ -63,11 +88,11 @@ bool_t clish_config_callback(clish_context_t *context)
 		lub_string_free(str);
 
 		/* Add splitter */
-		if (clish_command__get_splitter(cmd) == BOOL_FALSE)
+		if (!clish_config__get_splitter(config))
 			lub_string_cat(&command, " -i");
 
 		/* Add unique */
-		if (clish_command__get_unique(cmd) == BOOL_FALSE)
+		if (!clish_config__get_unique(config))
 			lub_string_cat(&command, " -n");
 
 		break;
@@ -82,7 +107,7 @@ bool_t clish_config_callback(clish_context_t *context)
 		lub_string_cat(&command, "-d");
 
 		/* Add filename */
-		str = clish_command__get_file(cmd, context);
+		str = clish_shell_expand(clish_config__get_file(config), context);
 		if (str) {
 			lub_string_cat(&command, " -f \"");
 			if (str[0] != '\0')
@@ -100,7 +125,7 @@ bool_t clish_config_callback(clish_context_t *context)
 
 	/* Add pattern */
 	if ((CLISH_CONFIG_SET == op) || (CLISH_CONFIG_UNSET == op)) {
-		str = clish_command__get_pattern(cmd, context);
+		str = clish_shell_expand(clish_config__get_pattern(config), context);
 		if (!str) {
 			lub_string_free(command);
 			return BOOL_FALSE;
@@ -112,24 +137,31 @@ bool_t clish_config_callback(clish_context_t *context)
 	}
 
 	/* Add priority */
-	if (clish_command__get_priority(cmd) != 0) {
+	if (clish_config__get_priority(config) != 0) {
 		snprintf(tmp, sizeof(tmp) - 1, " -p 0x%x",
-			clish_command__get_priority(cmd));
+			clish_config__get_priority(config));
 		tmp[sizeof(tmp) - 1] = '\0';
 		lub_string_cat(&command, tmp);
 	}
 
 	/* Add sequence */
-	if (clish_command__is_seq(cmd)) {
-		snprintf(tmp, sizeof(tmp) - 1, " -q %u",
-			clish_command__get_seq(cmd, context));
+	if (clish_config__get_seq(config)) {
+		str = clish_shell_expand(clish_config__get_seq(config), context);
+		snprintf(tmp, sizeof(tmp) - 1, " -q %u", str2ushort(str));
 		tmp[sizeof(tmp) - 1] = '\0';
 		lub_string_cat(&command, tmp);
+		lub_string_free(str);
 	}
 
 	/* Add pwd */
-	str = clish_shell__get_pwd_full(this,
-		clish_command__get_cfg_depth(cmd, context));
+	if (clish_config__get_depth(config)) {
+		str = clish_shell_expand(clish_config__get_depth(config), context);
+		num = str2ushort(str);
+		lub_string_free(str);
+	} else {
+		num = clish_command__get_depth(cmd);
+	}
+	str = clish_shell__get_pwd_full(this, num);
 	if (str) {
 		lub_string_cat(&command, " ");
 		lub_string_cat(&command, str);

+ 2 - 29
clish/command.h

@@ -13,13 +13,7 @@ typedef struct clish_command_s clish_command_t;
 #include "clish/view.h"
 #include "clish/param.h"
 #include "clish/action.h"
-
-typedef enum {
-	CLISH_CONFIG_NONE,
-	CLISH_CONFIG_SET,
-	CLISH_CONFIG_UNSET,
-	CLISH_CONFIG_DUMP
-} clish_config_operation_t;
+#include "clish/config.h"
 
 /*=====================================
  * COMMAND INTERFACE
@@ -77,33 +71,12 @@ void clish_command__force_viewid(clish_command_t * instance, const char *viewid)
 void clish_command__set_pview(clish_command_t * instance, clish_view_t * view);
 clish_view_t *clish_command__get_pview(const clish_command_t * instance);
 unsigned clish_command__get_depth(const clish_command_t * instance);
-void
-clish_command__set_cfg_op(clish_command_t * instance,
-	clish_config_operation_t operation);
-clish_config_operation_t
-clish_command__get_cfg_op(const clish_command_t * instance);
-void clish_command__set_priority(clish_command_t * instance, unsigned short priority);
-unsigned short clish_command__get_priority(const clish_command_t * instance);
-void
-clish_command__set_pattern(clish_command_t * instance, const char *pattern);
-char *clish_command__get_pattern(const clish_command_t *instance, void *context);
-void clish_command__set_file(clish_command_t * instance, const char *file);
-char *clish_command__get_file(const clish_command_t *instance, void *context);
-void clish_command__set_splitter(clish_command_t * instance, bool_t splitter);
-bool_t clish_command__get_splitter(const clish_command_t * instance);
-const char * clish_command__is_seq(const clish_command_t * instance);
-void clish_command__set_seq(clish_command_t * instance, const char * seq_num);
-unsigned short clish_command__get_seq(const clish_command_t * instance, void *context);
+clish_config_t *clish_command__get_config(const clish_command_t *instance);
 clish_view_restore_t clish_command__get_restore(const clish_command_t * instance);
-bool_t clish_command__get_unique(const clish_command_t * instance);
-void clish_command__set_unique(clish_command_t * instance, bool_t unique);
 const clish_command_t * clish_command__get_orig(const clish_command_t * instance);
 const clish_command_t * clish_command__get_cmd(const clish_command_t * instance);
-void clish_command__set_cfg_depth(clish_command_t * instance, const char * cfg_depth);
-unsigned clish_command__get_cfg_depth(const clish_command_t *instance, void *context);
 bool_t clish_command__get_lock(const clish_command_t * instance);
 void clish_command__set_lock(clish_command_t * instance, bool_t lock);
-
 void clish_command__set_alias(clish_command_t * instance, const char * alias);
 const char * clish_command__get_alias(const clish_command_t * instance);
 void clish_command__set_alias_view(clish_command_t * instance,

+ 8 - 168
clish/command/command.c

@@ -37,6 +37,7 @@ clish_command_init(clish_command_t * this, const char *name, const char *text,
 	this->viewid = NULL;
 	this->view = NULL;
 	this->action = clish_action_new();
+	this->config = clish_config_new();
 	this->detail = NULL;
 	this->escape_chars = NULL;
 	this->args = NULL;
@@ -44,16 +45,6 @@ clish_command_init(clish_command_t * this, const char *name, const char *text,
 	this->lock = BOOL_TRUE;
 	this->interrupt = BOOL_FALSE;
 	this->dynamic = BOOL_FALSE;
-
-	/* CONFIG params */
-	this->cfg_op = CLISH_CONFIG_NONE;
-	this->priority = 0; /* medium priority by default */
-	this->pattern = NULL;
-	this->file = NULL;
-	this->splitter = BOOL_TRUE;
-	this->seq = NULL;
-	this->unique = BOOL_TRUE;
-	this->cfg_depth = NULL;
 }
 
 /*--------------------------------------------------------- */
@@ -72,14 +63,11 @@ static void clish_command_fini(clish_command_t * this)
 	lub_string_free(this->alias);
 	lub_string_free(this->viewid);
 	clish_action_delete(this->action);
+	clish_config_delete(this->config);
 	lub_string_free(this->detail);
 	lub_string_free(this->escape_chars);
 	if (this->args)
 		clish_param_delete(this->args);
-	lub_string_free(this->pattern);
-	lub_string_free(this->file);
-	lub_string_free(this->seq);
-	lub_string_free(this->cfg_depth);
 }
 
 /*---------------------------------------------------------
@@ -257,6 +245,12 @@ clish_action_t *clish_command__get_action(const clish_command_t *this)
 	return this->action;
 }
 
+/*--------------------------------------------------------- */
+clish_config_t *clish_command__get_config(const clish_command_t *this)
+{
+	return this->config;
+}
+
 /*--------------------------------------------------------- */
 void clish_command__set_view(clish_command_t * this, clish_view_t * view)
 {
@@ -368,112 +362,6 @@ unsigned clish_command__get_depth(const clish_command_t * this)
 	return clish_view__get_depth(this->pview);
 }
 
-/*--------------------------------------------------------- */
-void
-clish_command__set_cfg_op(clish_command_t * this,
-	clish_config_operation_t operation)
-{
-	this->cfg_op = operation;
-}
-
-/*--------------------------------------------------------- */
-clish_config_operation_t clish_command__get_cfg_op(const clish_command_t * this)
-{
-	return this->cfg_op;
-}
-
-/*--------------------------------------------------------- */
-void clish_command__set_priority(clish_command_t * this, unsigned short priority)
-{
-	this->priority = priority;
-}
-
-/*--------------------------------------------------------- */
-unsigned short clish_command__get_priority(const clish_command_t * this)
-{
-	return this->priority;
-}
-
-/*--------------------------------------------------------- */
-void clish_command__set_pattern(clish_command_t * this, const char *pattern)
-{
-	assert(NULL == this->pattern);
-	this->pattern = lub_string_dup(pattern);
-}
-
-/*--------------------------------------------------------- */
-char *clish_command__get_pattern(const clish_command_t * this, void *context)
-{
-	return this->var_expand_fn(this->pattern, context);
-}
-
-/*--------------------------------------------------------- */
-void clish_command__set_file(clish_command_t * this, const char *file)
-{
-	assert(!this->file);
-	this->file = lub_string_dup(file);
-}
-
-/*--------------------------------------------------------- */
-char *clish_command__get_file(const clish_command_t *this, void *context)
-{
-	return this->var_expand_fn(this->file, context);
-}
-
-/*--------------------------------------------------------- */
-bool_t clish_command__get_splitter(const clish_command_t * this)
-{
-	return this->splitter;
-}
-
-/*--------------------------------------------------------- */
-void clish_command__set_splitter(clish_command_t * this, bool_t splitter)
-{
-	this->splitter = splitter;
-}
-
-/*--------------------------------------------------------- */
-void clish_command__set_seq(clish_command_t * this, const char * seq)
-{
-	assert(!this->seq);
-	this->seq = lub_string_dup(seq);
-}
-
-/*--------------------------------------------------------- */
-unsigned short clish_command__get_seq(const clish_command_t *this, void *context)
-{
-	unsigned short num = 0;
-	char *str;
-
-	if (!this->seq)
-		return 0;
-
-	str = this->var_expand_fn(this->seq, context);
-	if (str && (*str != '\0')) {
-		long val = 0;
-		char *endptr;
-
-		val = strtol(str, &endptr, 0);
-		if (endptr == str)
-			num = 0;
-		else if (val > 0xffff)
-			num = 0xffff;
-		else if (val < 0)
-			num = 0;
-		else
-			num = (unsigned short)val;
-	}
-	lub_string_free(str);
-
-	return num;
-}
-
-/*--------------------------------------------------------- */
-const char * clish_command__is_seq(const clish_command_t * this)
-{
-	return this->seq;
-}
-
 /*--------------------------------------------------------- */
 clish_view_restore_t clish_command__get_restore(const clish_command_t * this)
 {
@@ -482,18 +370,6 @@ clish_view_restore_t clish_command__get_restore(const clish_command_t * this)
 	return clish_view__get_restore(this->pview);
 }
 
-/*--------------------------------------------------------- */
-bool_t clish_command__get_unique(const clish_command_t * this)
-{
-	return this->unique;
-}
-
-/*--------------------------------------------------------- */
-void clish_command__set_unique(clish_command_t * this, bool_t unique)
-{
-	this->unique = unique;
-}
-
 /*--------------------------------------------------------- */
 const clish_command_t * clish_command__get_orig(const clish_command_t * this)
 {
@@ -502,42 +378,6 @@ const clish_command_t * clish_command__get_orig(const clish_command_t * this)
 	return this;
 }
 
-/*--------------------------------------------------------- */
-void clish_command__set_cfg_depth(clish_command_t * this, const char * cfg_depth)
-{
-	assert(!this->cfg_depth);
-	this->cfg_depth = lub_string_dup(cfg_depth);
-}
-
-/*--------------------------------------------------------- */
-unsigned clish_command__get_cfg_depth(const clish_command_t *this, void *context)
-{
-	unsigned num = 0;
-	char *str;
-
-	if (!this->cfg_depth)
-		return clish_command__get_depth(this);
-
-	str = this->var_expand_fn(this->cfg_depth, context);
-	if (str && (*str != '\0')) {
-		long val = 0;
-		char *endptr;
-
-		val = strtol(str, &endptr, 0);
-		if (endptr == str)
-			num = 0;
-		else if (val > 0xffff)
-			num = 0xffff;
-		else if (val < 0)
-			num = 0;
-		else
-			num = (unsigned)val;
-	}
-	lub_string_free(str);
-
-	return num;
-}
-
 /*--------------------------------------------------------- */
 bool_t clish_command__get_lock(const clish_command_t * this)
 {

+ 2 - 18
clish/command/command_dump.c

@@ -3,14 +3,12 @@
  */
 
 #include "lub/dump.h"
-#include "clish/action.h"
 #include "private.h"
 
 /*--------------------------------------------------------- */
 void clish_command_dump(const clish_command_t * this)
 {
 	unsigned i;
-	char *cfg_op;
 
 	lub_dump_printf("command(%p)\n", this);
 	lub_dump_indent();
@@ -21,25 +19,11 @@ void clish_command_dump(const clish_command_t * this)
 	lub_dump_printf("alias       : %s\n", this->alias);
 	lub_dump_printf("alias_view  : %s\n",
 		this->alias_view ? clish_view__get_name(this->alias_view) : "(null)");
-	clish_action_dump(this->action);
 	lub_dump_printf("paramc      : %d\n", clish_paramv__get_count(this->paramv));
 	lub_dump_printf("detail      : %s\n",
 			this->detail ? this->detail : "(null)");
-	switch (this->cfg_op) {
-	case CLISH_CONFIG_NONE:
-		cfg_op = "NONE";
-		break;
-	case CLISH_CONFIG_SET:
-		cfg_op = "SET";
-		break;
-	case CLISH_CONFIG_UNSET:
-		cfg_op = "UNSET";
-		break;
-	default:
-		cfg_op = "Unknown";
-		break;
-	}
-	lub_dump_printf("cfg_op      : %s\n", cfg_op);
+	clish_action_dump(this->action);
+	clish_config_dump(this->config);
 
 	/* Get each parameter to dump their details */
 	for (i = 0; i < clish_paramv__get_count(this->paramv); i++) {

+ 1 - 13
clish/command/private.h

@@ -2,7 +2,6 @@
  * command.h
  */
 
-#include "clish/action.h"
 #include "clish/command.h"
 
 /*---------------------------------------------------------
@@ -14,6 +13,7 @@ struct clish_command_s {
 	char *text;
 	clish_paramv_t *paramv;
 	clish_action_t *action;
+	clish_config_t *config;
 	clish_view_t *view;
 	char *viewid;
 	char *detail;
@@ -27,16 +27,4 @@ struct clish_command_s {
 	bool_t interrupt;
 	bool_t dynamic; /* Is command dynamically created */
 	clish_var_expand_fn_t *var_expand_fn;
-
-	/* CONFIG params:
-	 * TODO: create special structure for CONFIG params.
-	 */
-	clish_config_operation_t cfg_op;
-	unsigned short priority;
-	char *pattern;
-	char *file;
-	bool_t splitter;
-	char *seq;
-	bool_t unique;
-	char *cfg_depth;
 };

+ 52 - 0
clish/config.h

@@ -0,0 +1,52 @@
+/*
+ * config.h
+ */
+#ifndef _clish_config_h
+#define _clish_config_h
+
+#include "lub/types.h"
+
+typedef struct clish_config_s clish_config_t;
+
+/* Possible CONFIG operations */
+typedef enum {
+	CLISH_CONFIG_NONE,
+	CLISH_CONFIG_SET,
+	CLISH_CONFIG_UNSET,
+	CLISH_CONFIG_DUMP
+} clish_config_op_t;
+
+/*=====================================
+ * COMMAND INTERFACE
+ *===================================== */
+/*-----------------
+ * meta functions
+ *----------------- */
+clish_config_t *clish_config_new(void);
+/*-----------------
+ * methods
+ *----------------- */
+void clish_config_delete(clish_config_t *instance);
+void clish_config_dump(const clish_config_t *instance);
+
+/*-----------------
+ * attributes
+ *----------------- */
+void clish_config__set_op(clish_config_t *instance, clish_config_op_t op);
+clish_config_op_t clish_config__get_op(const clish_config_t *instance);
+void clish_config__set_priority(clish_config_t *instance, unsigned short priority);
+unsigned short clish_config__get_priority(const clish_config_t *instance);
+void clish_config__set_pattern(clish_config_t *instance, const char *pattern);
+char *clish_config__get_pattern(const clish_config_t *instance);
+void clish_config__set_file(clish_config_t *instance, const char *file);
+char *clish_config__get_file(const clish_config_t *instance);
+void clish_config__set_splitter(clish_config_t *instance, bool_t splitter);
+bool_t clish_config__get_splitter(const clish_config_t *instance);
+void clish_config__set_seq(clish_config_t *instance, const char *seq_num);
+const char *clish_config__get_seq(const clish_config_t *instance);
+bool_t clish_config__get_unique(const clish_config_t *instance);
+void clish_config__set_unique(clish_config_t *instance, bool_t unique);
+void clish_config__set_depth(clish_config_t *instance, const char *depth);
+const char *clish_config__get_depth(const clish_config_t *instance);
+
+#endif				/* _clish_config_h */

+ 163 - 0
clish/config/config.c

@@ -0,0 +1,163 @@
+/*
+  * config.c
+  *
+  * This file provides the implementation of a config definition
+  */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <assert.h>
+#include <string.h>
+
+#include "lub/types.h"
+#include "lub/string.h"
+#include "private.h"
+
+
+/*---------------------------------------------------------
+ * PRIVATE METHODS
+ *--------------------------------------------------------- */
+static void clish_config_init(clish_config_t *this)
+{
+	this->op = CLISH_CONFIG_NONE;
+	this->priority = 0;
+	this->pattern = NULL;
+	this->file = NULL;
+	this->splitter = BOOL_TRUE;
+	this->seq = NULL;
+	this->unique = BOOL_TRUE;
+	this->depth = NULL;
+}
+
+/*--------------------------------------------------------- */
+static void clish_config_fini(clish_config_t *this)
+{
+	lub_string_free(this->pattern);
+	lub_string_free(this->file);
+	lub_string_free(this->seq);
+	lub_string_free(this->depth);
+}
+
+/*---------------------------------------------------------
+ * PUBLIC META FUNCTIONS
+ *--------------------------------------------------------- */
+clish_config_t *clish_config_new(void)
+{
+	clish_config_t *this = malloc(sizeof(clish_config_t));
+
+	if (this)
+		clish_config_init(this);
+
+	return this;
+}
+
+/*---------------------------------------------------------
+ * PUBLIC METHODS
+ *--------------------------------------------------------- */
+void clish_config_delete(clish_config_t *this)
+{
+	clish_config_fini(this);
+	free(this);
+}
+
+/*---------------------------------------------------------
+ * PUBLIC ATTRIBUTES
+ *--------------------------------------------------------- */
+void clish_config__set_op(clish_config_t *this, clish_config_op_t op)
+{
+	this->op = op;
+}
+
+/*--------------------------------------------------------- */
+clish_config_op_t clish_config__get_op(const clish_config_t *this)
+{
+	return this->op;
+}
+
+/*--------------------------------------------------------- */
+void clish_config__set_priority(clish_config_t *this, unsigned short priority)
+{
+	this->priority = priority;
+}
+
+/*--------------------------------------------------------- */
+unsigned short clish_config__get_priority(const clish_config_t *this)
+{
+	return this->priority;
+}
+
+/*--------------------------------------------------------- */
+void clish_config__set_pattern(clish_config_t *this, const char *pattern)
+{
+	assert(!this->pattern);
+	this->pattern = lub_string_dup(pattern);
+}
+
+/*--------------------------------------------------------- */
+char *clish_config__get_pattern(const clish_config_t *this)
+{
+	return this->pattern;
+}
+
+/*--------------------------------------------------------- */
+void clish_config__set_file(clish_config_t *this, const char *file)
+{
+	assert(!this->file);
+	this->file = lub_string_dup(file);
+}
+
+/*--------------------------------------------------------- */
+char *clish_config__get_file(const clish_config_t *this)
+{
+	return this->file;
+}
+
+/*--------------------------------------------------------- */
+bool_t clish_config__get_splitter(const clish_config_t *this)
+{
+	return this->splitter;
+}
+
+/*--------------------------------------------------------- */
+void clish_config__set_splitter(clish_config_t *this, bool_t splitter)
+{
+	this->splitter = splitter;
+}
+
+/*--------------------------------------------------------- */
+void clish_config__set_seq(clish_config_t *this, const char *seq)
+{
+	assert(!this->seq);
+	this->seq = lub_string_dup(seq);
+}
+
+/*--------------------------------------------------------- */
+const char *clish_config__get_seq(const clish_config_t *this)
+{
+	return this->seq;
+}
+
+/*--------------------------------------------------------- */
+bool_t clish_config__get_unique(const clish_config_t *this)
+{
+	return this->unique;
+}
+
+/*--------------------------------------------------------- */
+void clish_config__set_unique(clish_config_t *this, bool_t unique)
+{
+	this->unique = unique;
+}
+
+/*--------------------------------------------------------- */
+void clish_config__set_depth(clish_config_t *this, const char *depth)
+{
+	assert(!this->depth);
+	this->depth = lub_string_dup(depth);
+}
+
+/*--------------------------------------------------------- */
+const char *clish_config__get_depth(const clish_config_t *this)
+{
+	return this->depth;
+}

+ 38 - 0
clish/config/config_dump.c

@@ -0,0 +1,38 @@
+/*
+ * config_dump.c
+ */
+
+#include "lub/dump.h"
+#include "private.h"
+
+/*--------------------------------------------------------- */
+void clish_config_dump(const clish_config_t *this)
+{
+	char *op;
+
+	lub_dump_printf("config(%p)\n", this);
+	lub_dump_indent();
+
+	switch (this->op) {
+	case CLISH_CONFIG_NONE:
+		op = "NONE";
+		break;
+	case CLISH_CONFIG_SET:
+		op = "SET";
+		break;
+	case CLISH_CONFIG_UNSET:
+		op = "UNSET";
+		break;
+	case CLISH_CONFIG_DUMP:
+		op = "DUMP";
+		break;
+	default:
+		op = "Unknown";
+		break;
+	}
+	lub_dump_printf("op      : %s\n", op);
+
+	lub_dump_undent();
+}
+
+/*--------------------------------------------------------- */

+ 4 - 0
clish/config/module.am

@@ -0,0 +1,4 @@
+libclish_la_SOURCES += \
+	clish/config/config.c \
+	clish/config/config_dump.c \
+	clish/config/private.h

+ 19 - 0
clish/config/private.h

@@ -0,0 +1,19 @@
+/*
+ * clish/config/private.h
+ */
+
+#include "clish/config.h"
+
+/*---------------------------------------------------------
+ * PRIVATE TYPES
+ *--------------------------------------------------------- */
+struct clish_config_s {
+	clish_config_op_t op; /* CONFIG operation */
+	unsigned short priority;
+	char *pattern;
+	char *file;
+	bool_t splitter;
+	char *seq;
+	bool_t unique;
+	char *depth;
+};

+ 3 - 1
clish/module.am

@@ -21,11 +21,11 @@ nobase_include_HEADERS += \
 	clish/pargv.h \
 	clish/ptype.h \
 	clish/shell.h \
-	clish/variable.h \
 	clish/view.h \
 	clish/nspace.h \
 	clish/var.h \
 	clish/action.h \
+	clish/config.h \
 	clish/internal.h
 
 EXTRA_DIST += \
@@ -38,6 +38,7 @@ EXTRA_DIST += \
 	clish/nspace/module.am \
 	clish/var/module.am \
 	clish/action/module.am \
+	clish/config/module.am \
 	clish/README
 
 include $(top_srcdir)/clish/command/module.am
@@ -49,3 +50,4 @@ include $(top_srcdir)/clish/view/module.am
 include $(top_srcdir)/clish/nspace/module.am
 include $(top_srcdir)/clish/var/module.am
 include $(top_srcdir)/clish/action/module.am
+include $(top_srcdir)/clish/config/module.am

+ 21 - 19
clish/shell/shell_tinyxml.cpp

@@ -566,10 +566,12 @@ process_namespace(clish_shell_t * shell, TiXmlElement * element, void *parent)
 static void
 process_config(clish_shell_t * shell, TiXmlElement * element, void *parent)
 {
-	clish_command_t *cmd = (clish_command_t *) parent;
+	clish_command_t *cmd = (clish_command_t *)parent;
+	clish_config_t *config;
 
 	if (!cmd)
 		return;
+	config = clish_command__get_config(cmd);
 
 	// read the following text element
 	const char *operation = element->Attribute("operation");
@@ -579,18 +581,18 @@ process_config(clish_shell_t * shell, TiXmlElement * element, void *parent)
 	const char *splitter = element->Attribute("splitter");
 	const char *seq = element->Attribute("sequence");
 	const char *unique = element->Attribute("unique");
-	const char *cfg_depth = element->Attribute("depth");
+	const char *depth = element->Attribute("depth");
 
 	if (operation && !lub_string_nocasecmp(operation, "unset"))
-		clish_command__set_cfg_op(cmd, CLISH_CONFIG_UNSET);
+		clish_config__set_op(config, CLISH_CONFIG_UNSET);
 	else if (operation && !lub_string_nocasecmp(operation, "none"))
-		clish_command__set_cfg_op(cmd, CLISH_CONFIG_NONE);
+		clish_config__set_op(config, CLISH_CONFIG_NONE);
 	else if (operation && !lub_string_nocasecmp(operation, "dump"))
-		clish_command__set_cfg_op(cmd, CLISH_CONFIG_DUMP);
+		clish_config__set_op(config, CLISH_CONFIG_DUMP);
 	else {
-		clish_command__set_cfg_op(cmd, CLISH_CONFIG_SET);
+		clish_config__set_op(config, CLISH_CONFIG_SET);
 		/* The priority if no clearly specified */
-		clish_command__set_priority(cmd, 0x7f00);
+		clish_config__set_priority(config, 0x7f00);
 	}
 
 	if (priority && (*priority != '\0')) {
@@ -607,35 +609,35 @@ process_config(clish_shell_t * shell, TiXmlElement * element, void *parent)
 			pri = 0;
 		else
 			pri = (unsigned short)val;
-		clish_command__set_priority(cmd, pri);
+		clish_config__set_priority(config, pri);
 	}
 
 	if (pattern)
-		clish_command__set_pattern(cmd, pattern);
+		clish_config__set_pattern(config, pattern);
 	else
-		clish_command__set_pattern(cmd, "^${__cmd}");
+		clish_config__set_pattern(config, "^${__cmd}");
 
 	if (file)
-		clish_command__set_file(cmd, file);
+		clish_config__set_file(config, file);
 
 	if (splitter && (lub_string_nocasecmp(splitter, "false") == 0))
-		clish_command__set_splitter(cmd, BOOL_FALSE);
+		clish_config__set_splitter(config, BOOL_FALSE);
 	else
-		clish_command__set_splitter(cmd, BOOL_TRUE);
+		clish_config__set_splitter(config, BOOL_TRUE);
 
 	if (unique && (lub_string_nocasecmp(unique, "false") == 0))
-		clish_command__set_unique(cmd, BOOL_FALSE);
+		clish_config__set_unique(config, BOOL_FALSE);
 	else
-		clish_command__set_unique(cmd, BOOL_TRUE);
+		clish_config__set_unique(config, BOOL_TRUE);
 
 	if (seq)
-		clish_command__set_seq(cmd, seq);
+		clish_config__set_seq(config, seq);
 	else
 		/* The entries without sequence cannot be non-unique */
-		clish_command__set_unique(cmd, BOOL_TRUE);
+		clish_config__set_unique(config, BOOL_TRUE);
 
-	if (cfg_depth)
-		clish_command__set_cfg_depth(cmd, cfg_depth);
+	if (depth)
+		clish_config__set_depth(config, depth);
 }
 
 ///////////////////////////////////////

+ 0 - 41
clish/variable.h

@@ -1,41 +0,0 @@
-/*
- * variable.h
- */
- /**
-\ingroup clish
-\defgroup clish_variable variable
-@{
-
-\brief This utility is used to expand variables within a string.
-
-*/
-#ifndef _clish_variable_h
-#define _clish_variable_h
-
-#include "clish/shell.h"
-#include "clish/command.h"
-#include "clish/pargv.h"
-
-/*=====================================
- * VARIABLE INTERFACE
- *===================================== */
-/*-----------------
- * meta functions
- *----------------- */
-char *clish_variable_expand(const char *string,
-			    const char *viewid,
-			    const clish_command_t * cmd, clish_pargv_t * pargv);
-/*-----------------
- * methods
- *----------------- */
-char *clish_variable__get_line(const clish_command_t * cmd, clish_pargv_t * pargv);
-char *clish_variable__get_params(const clish_command_t * cmd, clish_pargv_t * pargv);
-char *clish_variable__get_value(const char *name, const char *viewid,
-	const clish_command_t * cmd, clish_pargv_t * pargv);
-
-/*-----------------
- * attributes
- *----------------- */
-
-#endif				/* _clish_variable_h */
-/** @} clish_variable */

+ 2 - 1
clish/view/view.c

@@ -191,9 +191,10 @@ clish_command_t *clish_view_resolve_command(clish_view_t *this,
 
 	if (result) {
 		clish_action_t *action = clish_command__get_action(result);
+		clish_config_t *config = clish_command__get_config(result);
 		if (!clish_action__get_script(action) &&
 			(!clish_action__get_builtin(action)) &&
-			(CLISH_CONFIG_NONE == clish_command__get_cfg_op(result)) &&
+			(CLISH_CONFIG_NONE == clish_config__get_op(config)) &&
 			(!clish_command__get_view(result))) {
 			/* if this doesn't do anything we've
 			 * not resolved a command

Some files were not shown because too many files changed in this diff