Browse Source

entry: Remove all useless structs from tree. From ischeme and kscheme. Removed elements are view, ptype, command, param, nspace. All correspondent XML tags translate its content to kentry_t

Serj Kalichev 2 years ago
parent
commit
0d28aea6f2

+ 1 - 2
bin/klishd/klishd.c

@@ -44,7 +44,6 @@
 
 #include "private.h"
 
-#include "sch.c"
 
 // Local static functions
 static int create_listen_unix_sock(const char *path);
@@ -169,7 +168,7 @@ int main(int argc, char **argv)
 	deploy_db = kdb_new("ischeme", NULL);
 	kdb_load_plugin(deploy_db);
 	kdb_init(deploy_db);
-//	kdb_deploy_scheme(deploy_db, scheme);
+	kdb_deploy_scheme(deploy_db, scheme);
 	kdb_fini(deploy_db);
 	kdb_free(deploy_db);
 	}

+ 12 - 45
klish.xsd

@@ -21,19 +21,16 @@
 
 	<xs:element name="KLISH" type="klish_t"/>
 	<xs:element name="ENTRY" type="entry_t"/>
-	<xs:element name="VIEW" type="view_t"/>
-	<xs:element name="COMMAND" type="command_t"/>
-	<xs:element name="FILTER" type="command_t"/>
+	<xs:element name="VIEW" type="view_t"/> <!-- Wrapper -->
+	<xs:element name="COMMAND" type="command_t"/> <!-- Wrapper -->
+	<xs:element name="FILTER" type="command_t"/> <!-- Wrapper -->
 	<xs:element name="STARTUP" type="startup_t"/>
 	<xs:element name="ACTION" type="action_t"/>
 	<xs:element name="OVERVIEW" type="overview_t"/>
 	<xs:element name="DETAIL" type="detail_t"/>
-	<xs:element name="PTYPE" type="ptype_t"/>
-	<xs:element name="PARAM" type="param_t"/>
-	<xs:element name="SWITCH" type="param_t"/> <!-- PARAM alias -->
-	<xs:element name="SUBCOMMAND" type="param_t"/> <!-- PARAM alias -->
-	<xs:element name="MULTI" type="param_t"/> <!-- PARAM alias -->
-	<xs:element name="NAMESPACE" type="namespace_t"/>
+	<xs:element name="PTYPE" type="ptype_t"/> <!-- Wrapper -->
+	<xs:element name="PARAM" type="param_t"/> <!-- Wrapper -->
+	<xs:element name="NAMESPACE" type="namespace_t"/> <!-- Wrapper -->
 	<xs:element name="VAR" type="var_t"/>
 	<xs:element name="WATCHDOG" type="wdog_t"/>
 	<xs:element name="HOTKEY" type="hotkey_t"/>
@@ -65,6 +62,7 @@
 			<xs:element ref="STARTUP" minOccurs="0"/>
 			<xs:element ref="VAR" minOccurs="0" maxOccurs="unbounded"/>
 			<xs:element ref="VIEW" minOccurs="0" maxOccurs="unbounded"/>
+			<xs:element ref="ENTRY" minOccurs="0" maxOccurs="unbounded"/>
 		</xs:sequence>
 	</xs:complexType>
 
@@ -171,6 +169,7 @@
 		<xs:attribute name="ref" type="xs:string" use="optional"/>
 		<xs:attribute name="value" type="xs:string" use="optional"/>
 		<xs:attribute name="restore" type="xs:boolean" use="optional" default="false"/>
+		<xs:attribute name="order" type="xs:boolean" use="optional" default="false"/>
 	</xs:complexType>
 
 
@@ -186,34 +185,19 @@
 *	or dynamic variables which are expanded
 *	before display.
 *
-* [depth] - a depth of nested view (uses for config).
-*
-* [restore] - restore the depth or view of commands
-*	contained by this view
-*
 * [access] - access rights
 *
 ********************************************************
 -->
-
-	<xs:simpleType name="restore_t">
-		<xs:restriction base="xs:string">
-			<xs:enumeration value="none"/>
-			<xs:enumeration value="depth"/>
-			<xs:enumeration value="view"/>
-		</xs:restriction>
-	</xs:simpleType>
-
 	<xs:complexType name="view_t">
 		<xs:sequence>
 			<xs:element ref="NAMESPACE" minOccurs="0" maxOccurs="unbounded"/>
 			<xs:element ref="COMMAND" minOccurs="0" maxOccurs="unbounded"/>
 			<xs:element ref="HOTKEY" minOccurs="0" maxOccurs="unbounded"/>
+			<xs:element ref="ENTRY" minOccurs="0" maxOccurs="unbounded"/>
 		</xs:sequence>
 		<xs:attribute name="name" type="xs:string" use="required"/>
 		<xs:attribute name="prompt" type="xs:string" use="optional"/>
-		<xs:attribute name="depth" type="xs:string" use="optional" default="0"/>
-		<xs:attribute name="restore" type="restore_t" use="optional" default="none"/>
 		<xs:attribute name="access" type="xs:string" use="optional"/>
 	</xs:complexType>
 
@@ -311,21 +295,10 @@
 *
 ********************************************************
 -->
-	<xs:simpleType name="param_mode_t">
-		<xs:restriction base="xs:string">
-			<xs:enumeration value="common"/>
-			<xs:enumeration value="switch"/>
-			<xs:enumeration value="subcommand"/>
-			<xs:enumeration value="multi"/>
-		</xs:restriction>
-	</xs:simpleType>
-
 	<xs:group name="param_group_t">
 		<xs:choice>
 			<xs:element ref="PARAM"/>
-			<xs:element ref="SWITCH"/>
-			<xs:element ref="SUBCOMMAND"/>
-			<xs:element ref="MULTI"/>
+			<xs:element ref="ENTRY"/>
 		</xs:choice>
 	</xs:group>
 
@@ -337,16 +310,9 @@
 		<xs:attribute name="name" type="xs:string" use="required"/>
 		<xs:attribute name="help" type="xs:string" use="required"/>
 		<xs:attribute name="ptype" type="xs:string" use="required"/>
-		<xs:attribute name="default" type="xs:string" use="optional"/>
-		<xs:attribute name="prefix" type="xs:string" use="optional"/>
-		<xs:attribute name="mode" type="param_mode_t" use="optional" default="common"/>
-		<xs:attribute name="optional" type="xs:boolean" use="optional" default="false"/>
+		<xs:attribute name="mode" type="entry_mode_t" use="optional" default="common"/>
 		<xs:attribute name="order" type="xs:boolean" use="optional" default="false"/>
 		<xs:attribute name="value" type="xs:string" use="optional"/>
-		<xs:attribute name="hidden" type="xs:boolean" use="optional" default="false"/>
-		<xs:attribute name="test" type="xs:string" use="optional"/>
-		<xs:attribute name="completion" type="xs:string" use="optional"/>
-		<xs:attribute name="access" type="xs:string" use="optional"/>
 	</xs:complexType>
 
 
@@ -451,6 +417,7 @@
 			<!--  Any order of PARAM tags and any number -->
 			<xs:group ref="param_group_t" minOccurs="0" maxOccurs="unbounded"/>
 			<xs:element ref="ACTION" minOccurs="0" maxOccurs="unbounded"/>
+			<xs:element ref="COMMAND" minOccurs="0" maxOccurs="unbounded"/>
 		</xs:sequence>
 		<xs:attribute name="name" type="xs:string" use="required"/>
 		<xs:attribute name="help" type="xs:string" use="required"/>

+ 0 - 10
klish/Makefile.am

@@ -25,26 +25,16 @@ nobase_include_HEADERS += \
 nobase_include_HEADERS += \
 	klish/kscheme.h \
 	klish/kentry.h \
-	klish/kview.h \
-	klish/kcommand.h \
-	klish/kparam.h \
 	klish/kplugin.h \
 	klish/kaction.h \
-	klish/kptype.h \
 	klish/ksym.h \
-	klish/knspace.h \
 	klish/kdb.h
 
 # iScheme
 nobase_include_HEADERS += \
 	klish/ischeme.h \
-	klish/iview.h \
-	klish/icommand.h \
-	klish/iparam.h \
 	klish/iplugin.h \
 	klish/iaction.h \
-	klish/iptype.h \
-	klish/inspace.h \
 	klish/ientry.h
 
 # Session

+ 0 - 31
klish/icommand.h

@@ -1,31 +0,0 @@
-/** @file icommand.h
- *
- * @brief Klish scheme's "command" entry
- */
-
-#ifndef _klish_icommand_h
-#define _klish_icommand_h
-
-#include <klish/iparam.h>
-#include <klish/iaction.h>
-#include <klish/kcommand.h>
-
-typedef struct icommand_s {
-	char *name;
-	char *help;
-	iparam_t * (*params)[];
-	iaction_t * (*actions)[];
-} icommand_t;
-
-C_DECL_BEGIN
-
-bool_t icommand_parse(const icommand_t *info, kcommand_t *command,
-	faux_error_t *error);
-bool_t icommand_parse_nested(const icommand_t *icommand, kcommand_t *kcommand,
-	faux_error_t *error);
-kcommand_t *icommand_load(icommand_t *icommand, faux_error_t *error);
-char *icommand_deploy(const kcommand_t *kcommand, int level);
-
-C_DECL_END
-
-#endif // _klish_icommand_h

+ 0 - 27
klish/inspace.h

@@ -1,27 +0,0 @@
-/** @file nspace.h
- *
- * @brief Klish scheme's "nspace" entry
- */
-
-#ifndef _klish_inspace_h
-#define _klish_inspace_h
-
-#include <faux/error.h>
-#include <klish/knspace.h>
-
-typedef struct inspace_s {
-	char *ref;
-	char *prefix;
-} inspace_t;
-
-C_DECL_BEGIN
-
-bool_t inspace_parse(const inspace_t *info, knspace_t *nspace, faux_error_t *error);
-bool_t inspace_parse_nested(const inspace_t *inspace, knspace_t *knspace,
-	faux_error_t *error);
-knspace_t *inspace_load(const inspace_t *inspace, faux_error_t *error);
-char *inspace_deploy(const knspace_t *knspace, int level);
-
-C_DECL_END
-
-#endif // _klish_inspace_h

+ 0 - 32
klish/iparam.h

@@ -1,32 +0,0 @@
-/** @file iparam.h
- *
- * @brief Klish scheme's "param" entry
- */
-
-#ifndef _klish_iparam_h
-#define _klish_iparam_h
-
-#include <faux/error.h>
-#include <klish/kparam.h>
-
-typedef struct iparam_s iparam_t;
-
-struct iparam_s {
-	char *name;
-	char *help;
-	char *ptype;
-	char *mode;
-	iparam_t * (*params)[]; // Nested PARAMs
-};
-
-C_DECL_BEGIN
-
-bool_t iparam_parse(const iparam_t *info, kparam_t *param, faux_error_t *error);
-bool_t iparam_parse_nested(const iparam_t *iparam, kparam_t *kparam,
-	faux_error_t *error);
-kparam_t *iparam_load(const iparam_t *iparam, faux_error_t *error);
-char *iparam_deploy(const kparam_t *kparam, int level);
-
-C_DECL_END
-
-#endif // _klish_iparam_h

+ 0 - 29
klish/iptype.h

@@ -1,29 +0,0 @@
-/** @file iptype.h
- *
- * @brief Klish scheme's "ptype" entry
- */
-
-#ifndef _klish_iptype_h
-#define _klish_iptype_h
-
-#include <faux/error.h>
-#include <klish/iaction.h>
-#include <klish/kptype.h>
-
-typedef struct iptype_s {
-	char *name;
-	char *help;
-	iaction_t * (*actions)[];
-} iptype_t;
-
-C_DECL_BEGIN
-
-bool_t iptype_parse(const iptype_t *info, kptype_t *ptype, faux_error_t *error);
-bool_t iptype_parse_nested(const iptype_t *iptype, kptype_t *kptype,
-	faux_error_t *error_stack);
-kptype_t *iptype_load(const iptype_t *iptype, faux_error_t *error_stack);
-char *iptype_deploy(const kptype_t *kptype, int level);
-
-C_DECL_END
-
-#endif // _klish_iptype_h

+ 0 - 25
klish/ischeme.h

@@ -7,29 +7,10 @@
 #define _klish_ischeme_h
 
 #include <faux/error.h>
-#include <klish/iptype.h>
 #include <klish/iplugin.h>
-#include <klish/iview.h>
-#include <klish/inspace.h>
 #include <klish/ientry.h>
 #include <klish/kscheme.h>
 
-#define VIEW_LIST .views = &(iview_t * []) {
-#define END_VIEW_LIST NULL }
-#define VIEW &(iview_t)
-
-#define PTYPE_LIST .ptypes = &(iptype_t * []) {
-#define END_PTYPE_LIST NULL }
-#define PTYPE &(iptype_t)
-
-#define COMMAND_LIST .commands = &(icommand_t * []) {
-#define END_COMMAND_LIST NULL }
-#define COMMAND &(icommand_t)
-
-#define PARAM_LIST .params = &(iparam_t * []) {
-#define END_PARAM_LIST NULL }
-#define PARAM &(iparam_t)
-
 #define ACTION_LIST .actions = &(iaction_t * []) {
 #define END_ACTION_LIST NULL }
 #define ACTION &(iaction_t)
@@ -38,10 +19,6 @@
 #define END_PLUGIN_LIST NULL }
 #define PLUGIN &(iplugin_t)
 
-#define NSPACE_LIST .nspaces = &(inspace_t * []) {
-#define END_NSPACE_LIST NULL }
-#define NSPACE &(inspace_t)
-
 #define ENTRY_LIST .entrys = &(ientry_t * []) {
 #define END_ENTRY_LIST NULL }
 #define ENTRY &(ientry_t)
@@ -51,8 +28,6 @@ typedef struct ischeme_s {
 	char *name;
 	ientry_t * (*entrys)[];
 	iplugin_t * (*plugins)[];
-	iptype_t * (*ptypes)[];
-	iview_t * (*views)[];
 } ischeme_t;
 
 C_DECL_BEGIN

+ 0 - 5
klish/ischeme/Makefile.am

@@ -1,10 +1,5 @@
 libklish_la_SOURCES += \
 	klish/ischeme/iaction.c \
 	klish/ischeme/iplugin.c \
-	klish/ischeme/iparam.c \
-	klish/ischeme/icommand.c \
-	klish/ischeme/iptype.c \
-	klish/ischeme/iview.c \
-	klish/ischeme/inspace.c \
 	klish/ischeme/ientry.c \
 	klish/ischeme/ischeme.c

+ 0 - 208
klish/ischeme/icommand.c

@@ -1,208 +0,0 @@
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <assert.h>
-
-#include <faux/str.h>
-#include <faux/list.h>
-#include <faux/error.h>
-#include <klish/khelper.h>
-#include <klish/iparam.h>
-#include <klish/iaction.h>
-#include <klish/icommand.h>
-#include <klish/kparam.h>
-#include <klish/kaction.h>
-#include <klish/kcommand.h>
-
-#define TAG "COMMAND"
-
-bool_t icommand_parse(const icommand_t *info, kcommand_t *command,
-	faux_error_t *error)
-{
-	bool_t retcode = BOOL_TRUE;
-
-	if (!info)
-		return BOOL_FALSE;
-	if (!command)
-		return BOOL_FALSE;
-
-	// Help
-	if (!faux_str_is_empty(info->help)) {
-		if (!kcommand_set_help(command, info->help)) {
-			faux_error_add(error, TAG": Illegal 'help' attribute");
-			retcode = BOOL_FALSE;
-		}
-	}
-
-	return retcode;
-}
-
-
-bool_t icommand_parse_nested(const icommand_t *icommand, kcommand_t *kcommand,
-	faux_error_t *error)
-{
-	bool_t retval = BOOL_TRUE;
-
-	if (!kcommand || !icommand) {
-		faux_error_add(error, TAG": Internal error");
-		return BOOL_FALSE;
-	}
-
-
-	// PARAM list
-	if (icommand->params) {
-		iparam_t **p_iparam = NULL;
-		for (p_iparam = *icommand->params; *p_iparam; p_iparam++) {
-			kparam_t *kparam = NULL;
-			iparam_t *iparam = *p_iparam;
-
-			kparam = iparam_load(iparam, error);
-			if (!kparam) {
-				retval = BOOL_FALSE;
-				continue;
-			}
-			if (!kcommand_add_params(kcommand, kparam)) {
-				// Search for PARAM duplicates
-				if (kcommand_find_param(kcommand,
-					kparam_name(kparam))) {
-					faux_error_sprintf(error,
-						TAG": Can't add duplicate PARAM "
-						"\"%s\"", kparam_name(kparam));
-				} else {
-					faux_error_sprintf(error,
-						TAG": Can't add PARAM \"%s\"",
-						kparam_name(kparam));
-				}
-				kparam_free(kparam);
-				retval = BOOL_FALSE;
-				continue;
-			}
-		}
-	}
-
-	// ACTION list
-	if (icommand->actions) {
-		iaction_t **p_iaction = NULL;
-		for (p_iaction = *icommand->actions; *p_iaction; p_iaction++) {
-			kaction_t *kaction = NULL;
-			iaction_t *iaction = *p_iaction;
-
-			kaction = iaction_load(iaction, error);
-			if (!kaction) {
-				retval = BOOL_FALSE;
-				continue;
-			}
-			if (!kcommand_add_actions(kcommand, kaction)) {
-				faux_error_sprintf(error,
-					TAG": Can't add ACTION #%d",
-					kcommand_actions_len(kcommand) + 1);
-				kaction_free(kaction);
-				retval = BOOL_FALSE;
-				continue;
-			}
-		}
-	}
-
-	if (!retval)
-		faux_error_sprintf(error, TAG" \"%s\": Illegal nested elements",
-			kcommand_name(kcommand));
-
-	return retval;
-}
-
-
-kcommand_t *icommand_load(icommand_t *icommand, faux_error_t *error)
-{
-	kcommand_t *kcommand = NULL;
-
-	// Name [mandatory]
-	if (faux_str_is_empty(icommand->name)) {
-		faux_error_add(error, TAG": Empty 'name' attribute");
-		return NULL;
-	}
-
-	kcommand = kcommand_new(icommand->name);
-	if (!kcommand) {
-		faux_error_sprintf(error, TAG" \"%s\": Can't create object",
-			icommand->name);
-		return NULL;
-	}
-
-	if (!icommand_parse(icommand, kcommand, error)) {
-		kcommand_free(kcommand);
-		return NULL;
-	}
-
-	// Parse nested elements
-	if (!icommand_parse_nested(icommand, kcommand, error)) {
-		kcommand_free(kcommand);
-		return NULL;
-	}
-
-	return kcommand;
-}
-
-
-char *icommand_deploy(const kcommand_t *kcommand, int level)
-{
-	char *str = NULL;
-	char *tmp = NULL;
-	kcommand_params_node_t *params_iter = NULL;
-	kcommand_actions_node_t *actions_iter = NULL;
-
-	if (!kcommand)
-		return NULL;
-
-	tmp = faux_str_sprintf("%*cCOMMAND {\n", level, ' ');
-	faux_str_cat(&str, tmp);
-	faux_str_free(tmp);
-
-	attr2ctext(&str, "name", kcommand_name(kcommand), level + 1);
-	attr2ctext(&str, "help", kcommand_help(kcommand), level + 1);
-
-	// PARAM list
-	params_iter = kcommand_params_iter(kcommand);
-	if (params_iter) {
-		kparam_t *param = NULL;
-
-		tmp = faux_str_sprintf("\n%*cPARAM_LIST\n\n", level + 1, ' ');
-		faux_str_cat(&str, tmp);
-		faux_str_free(tmp);
-
-		while ((param = kcommand_params_each(&params_iter))) {
-			tmp = iparam_deploy(param, level + 2);
-			faux_str_cat(&str, tmp);
-			faux_str_free(tmp);
-		}
-
-		tmp = faux_str_sprintf("%*cEND_PARAM_LIST,\n", level + 1, ' ');
-		faux_str_cat(&str, tmp);
-		faux_str_free(tmp);
-	}
-
-	// ACTION list
-	actions_iter = kcommand_actions_iter(kcommand);
-	if (actions_iter) {
-		kaction_t *action = NULL;
-
-		tmp = faux_str_sprintf("\n%*cACTION_LIST\n\n", level + 1, ' ');
-		faux_str_cat(&str, tmp);
-		faux_str_free(tmp);
-
-		while ((action = kcommand_actions_each(&actions_iter))) {
-			tmp = iaction_deploy(action, level + 2);
-			faux_str_cat(&str, tmp);
-			faux_str_free(tmp);
-		}
-
-		tmp = faux_str_sprintf("%*cEND_ACTION_LIST,\n", level + 1, ' ');
-		faux_str_cat(&str, tmp);
-		faux_str_free(tmp);
-	}
-
-	tmp = faux_str_sprintf("%*c},\n\n", level, ' ');
-	faux_str_cat(&str, tmp);
-	faux_str_free(tmp);
-
-	return str;
-}

+ 0 - 1
klish/ischeme/ientry.c

@@ -8,7 +8,6 @@
 #include <faux/conv.h>
 #include <klish/khelper.h>
 #include <klish/ientry.h>
-#include <klish/kptype.h>
 #include <klish/kentry.h>
 
 #define TAG "ENTRY"

+ 0 - 112
klish/ischeme/inspace.c

@@ -1,112 +0,0 @@
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <assert.h>
-
-#include <faux/str.h>
-#include <faux/list.h>
-#include <faux/error.h>
-#include <klish/khelper.h>
-#include <klish/knspace.h>
-#include <klish/inspace.h>
-
-#define TAG "NSPACE"
-
-
-bool_t inspace_parse(const inspace_t *info, knspace_t *nspace, faux_error_t *error)
-{
-	bool_t retcode = BOOL_TRUE;
-
-	if (!info)
-		return BOOL_FALSE;
-	if (!nspace)
-		return BOOL_FALSE;
-
-	// Prefix
-	if (!faux_str_is_empty(info->prefix)) {
-		if (!knspace_set_prefix(nspace, info->prefix)) {
-			faux_error_add(error, TAG": Illegal 'prefix' attribute");
-			retcode = BOOL_FALSE;
-		}
-	}
-
-	return retcode;
-}
-
-
-bool_t inspace_parse_nested(const inspace_t *inspace, knspace_t *knspace,
-	faux_error_t *error)
-{
-	bool_t retval = BOOL_TRUE;
-
-	if (!knspace || !inspace) {
-		faux_error_add(error, TAG": Internal error");
-		return BOOL_FALSE;
-	}
-
-	// For now it's empty. NSPACE has no nested elements.
-
-	if (!retval)
-		faux_error_sprintf(error, TAG" \"%s\": Illegal nested elements",
-			knspace_view_ref(knspace));
-
-	return retval;
-}
-
-
-knspace_t *inspace_load(const inspace_t *inspace, faux_error_t *error)
-{
-	knspace_t *knspace = NULL;
-
-	if (!inspace)
-		return NULL;
-
-	// Ref [mandatory]
-	if (faux_str_is_empty(inspace->ref)) {
-		faux_error_add(error, TAG": Empty 'ref' attribute");
-		return NULL;
-	}
-
-	knspace = knspace_new(inspace->ref);
-	if (!knspace) {
-		faux_error_sprintf(error, TAG": \"%s\": Can't create object",
-			inspace->ref);
-		return NULL;
-	}
-
-	if (!inspace_parse(inspace, knspace, error)) {
-		knspace_free(knspace);
-		return NULL;
-	}
-
-	// Parse nested elements
-	if (!inspace_parse_nested(inspace, knspace, error)) {
-		knspace_free(knspace);
-		return NULL;
-	}
-
-	return knspace;
-}
-
-
-char *inspace_deploy(const knspace_t *knspace, int level)
-{
-	char *str = NULL;
-	char *tmp = NULL;
-
-	if (!knspace)
-		return NULL;
-
-	tmp = faux_str_sprintf("%*cnspace {\n", level, ' ');
-	faux_str_cat(&str, tmp);
-	faux_str_free(tmp);
-
-	attr2ctext(&str, "ref", knspace_view_ref(knspace), level + 1);
-	attr2ctext(&str, "prefix", knspace_prefix(knspace), level + 1);
-
-	tmp = faux_str_sprintf("%*c},\n\n", level, ' ');
-	faux_str_cat(&str, tmp);
-	faux_str_free(tmp);
-
-	return str;
-}

+ 0 - 204
klish/ischeme/iparam.c

@@ -1,204 +0,0 @@
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <assert.h>
-
-#include <faux/str.h>
-#include <faux/list.h>
-#include <klish/khelper.h>
-#include <klish/iparam.h>
-#include <klish/kptype.h>
-#include <klish/kparam.h>
-
-#define TAG "PARAM"
-
-bool_t iparam_parse(const iparam_t *info, kparam_t *param, faux_error_t *error)
-{
-	bool_t retcode = BOOL_TRUE;
-
-	if (!info)
-		return BOOL_FALSE;
-	if (!param)
-		return BOOL_FALSE;
-
-	// Help
-	if (!faux_str_is_empty(info->help)) {
-		if (!kparam_set_help(param, info->help)) {
-			faux_error_add(error, TAG": Illegal 'help' attribute");
-			retcode = BOOL_FALSE;
-		}
-	}
-
-	// PTYPE reference
-	if (!faux_str_is_empty(info->ptype)) {
-		if (!kparam_set_ptype_ref(param, info->ptype)) {
-			faux_error_add(error, TAG": Illegal 'ptype' attribute");
-			retcode = BOOL_FALSE;
-		}
-	}
-
-	// Mode
-	if (!faux_str_is_empty(info->mode)) {
-		kparam_mode_e mode = KPARAM_NONE;
-		if (!faux_str_casecmp(info->mode, "common"))
-			mode = KPARAM_COMMON;
-		else if (!faux_str_casecmp(info->mode, "switch"))
-			mode = KPARAM_SWITCH;
-		else if (!faux_str_casecmp(info->mode, "subcommand"))
-			mode = KPARAM_SUBCOMMAND;
-		else if (!faux_str_casecmp(info->mode, "multi"))
-			mode = KPARAM_MULTI;
-		if ((KPARAM_NONE == mode) || !kparam_set_mode(param, mode)) {
-			faux_error_add(error, TAG": Illegal 'mode' attribute");
-			retcode = BOOL_FALSE;
-		}
-	}
-
-	return retcode;
-}
-
-
-bool_t iparam_parse_nested(const iparam_t *iparam, kparam_t *kparam,
-	faux_error_t *error)
-{
-	bool_t retval = BOOL_TRUE;
-
-	if (!kparam || !iparam) {
-		faux_error_add(error, TAG": Internal error");
-		return BOOL_FALSE;
-	}
-
-	// Nested PARAM list
-	if (iparam->params) {
-		iparam_t **p_iparam = NULL;
-		for (p_iparam = *iparam->params; *p_iparam; p_iparam++) {
-			kparam_t *nkparam = NULL;
-			iparam_t *niparam = *p_iparam;
-
-			nkparam = iparam_load(niparam, error);
-			if (!nkparam) {
-				retval = BOOL_FALSE;
-				continue;
-			}
-			if (!kparam_add_params(kparam, nkparam)) {
-				// Search for PARAM duplicates
-				if (kparam_find_param(kparam,
-					kparam_name(nkparam))) {
-					faux_error_sprintf(error,
-						TAG": Can't add duplicate PARAM "
-						"\"%s\"", kparam_name(nkparam));
-				} else {
-					faux_error_sprintf(error,
-						TAG": Can't add PARAM \"%s\"",
-						kparam_name(nkparam));
-				}
-				kparam_free(nkparam);
-				retval = BOOL_FALSE;
-				continue;
-			}
-		}
-	}
-
-	if (!retval)
-		faux_error_sprintf(error, TAG" \"%s\": Illegal nested elements",
-			kparam_name(kparam));
-
-	return retval;
-}
-
-
-kparam_t *iparam_load(const iparam_t *iparam, faux_error_t *error)
-{
-	kparam_t *kparam = NULL;
-
-	if (!iparam)
-		return NULL;
-
-	// Name [mandatory]
-	if (faux_str_is_empty(iparam->name)) {
-		faux_error_add(error, TAG": Empty 'name' attribute");
-		return NULL;
-	}
-
-	kparam = kparam_new(iparam->name);
-	if (!kparam) {
-		faux_error_sprintf(error, TAG" \"%s\": Can't create object",
-			iparam->name);
-		return NULL;
-	}
-
-	if (!iparam_parse(iparam, kparam, error)) {
-		kparam_free(kparam);
-		return NULL;
-	}
-
-	// Parse nested elements
-	if (!iparam_parse_nested(iparam, kparam, error)) {
-		kparam_free(kparam);
-		return NULL;
-	}
-
-	return kparam;
-}
-
-
-char *iparam_deploy(const kparam_t *kparam, int level)
-{
-	char *str = NULL;
-	char *tmp = NULL;
-	char *mode = NULL;
-	kparam_params_node_t *params_iter = NULL;
-
-	tmp = faux_str_sprintf("%*cPARAM {\n", level, ' ');
-	faux_str_cat(&str, tmp);
-	faux_str_free(tmp);
-
-	attr2ctext(&str, "name", kparam_name(kparam), level + 1);
-	attr2ctext(&str, "help", kparam_help(kparam), level + 1);
-	attr2ctext(&str, "ptype", kparam_ptype_ref(kparam), level + 1);
-
-	// Mode
-	switch (kparam_mode(kparam)) {
-	case KPARAM_COMMON:
-		mode = "common";
-		break;
-	case KPARAM_SWITCH:
-		mode = "switch";
-		break;
-	case KPARAM_SUBCOMMAND:
-		mode = "subcommand";
-		break;
-	case KPARAM_MULTI:
-		mode = "multi";
-		break;
-	default:
-		mode = NULL;
-	}
-	attr2ctext(&str, "mode", mode, level + 1);
-
-	// PARAM list
-	params_iter = kparam_params_iter(kparam);
-	if (params_iter) {
-		kparam_t *nparam = NULL;
-
-		tmp = faux_str_sprintf("\n%*cPARAM_LIST\n\n", level + 1, ' ');
-		faux_str_cat(&str, tmp);
-		faux_str_free(tmp);
-
-		while ((nparam = kparam_params_each(&params_iter))) {
-			tmp = iparam_deploy(nparam, level + 2);
-			faux_str_cat(&str, tmp);
-			faux_str_free(tmp);
-		}
-
-		tmp = faux_str_sprintf("%*cEND_PARAM_LIST,\n", level + 1, ' ');
-		faux_str_cat(&str, tmp);
-		faux_str_free(tmp);
-	}
-
-	tmp = faux_str_sprintf("%*c},\n\n", level, ' ');
-	faux_str_cat(&str, tmp);
-	faux_str_free(tmp);
-
-	return str;
-}

+ 0 - 153
klish/ischeme/iptype.c

@@ -1,153 +0,0 @@
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <assert.h>
-
-#include <faux/str.h>
-#include <faux/list.h>
-#include <faux/error.h>
-#include <klish/khelper.h>
-#include <klish/kptype.h>
-#include <klish/kaction.h>
-#include <klish/iptype.h>
-
-#define TAG "PTYPE"
-
-
-bool_t iptype_parse(const iptype_t *info, kptype_t *ptype, faux_error_t *error)
-{
-	bool_t retcode = BOOL_TRUE;
-
-	if (!info)
-		return BOOL_FALSE;
-	if (!ptype)
-		return BOOL_FALSE;
-
-	// Help
-	if (!faux_str_is_empty(info->name)) {
-		if (!kptype_set_help(ptype, info->help)) {
-			faux_error_add(error, TAG": Illegal 'help' attribute");
-			retcode = BOOL_FALSE;
-		}
-	}
-
-	return retcode;
-}
-
-
-bool_t iptype_parse_nested(const iptype_t *iptype, kptype_t *kptype,
-	faux_error_t *error)
-{
-	bool_t retval = BOOL_TRUE;
-
-	if (!kptype || !iptype) {
-		faux_error_add(error, TAG": Internal error");
-		return BOOL_FALSE;
-	}
-
-	// ACTION list
-	if (iptype->actions) {
-		iaction_t **p_iaction = NULL;
-		for (p_iaction = *iptype->actions; *p_iaction; p_iaction++) {
-			kaction_t *kaction = NULL;
-			iaction_t *iaction = *p_iaction;
-
-			kaction = iaction_load(iaction, error);
-			if (!kaction) {
-				retval = BOOL_FALSE;
-				continue;
-			}
-			if (!kptype_add_actions(kptype, kaction)) {
-				faux_error_sprintf(error,
-					TAG": Can't add ACTION #%d",
-					kptype_actions_len(kptype) + 1);
-				kaction_free(kaction);
-				retval = BOOL_FALSE;
-				continue;
-			}
-		}
-	}
-
-	if (!retval)
-		faux_error_sprintf(error,
-			"PTYPE \"%s\": Illegal nested elements",
-			kptype_name(kptype));
-
-	return retval;
-}
-
-
-kptype_t *iptype_load(const iptype_t *iptype, faux_error_t *error)
-{
-	kptype_t *kptype = NULL;
-
-	if (!iptype)
-		return NULL;
-
-	// Name [mandatory]
-	if (faux_str_is_empty(iptype->name)) {
-		faux_error_add(error, TAG": Empty 'name' attribute");
-		return NULL;
-	}
-
-	kptype = kptype_new(iptype->name);
-	if (!kptype) {
-		faux_error_sprintf(error, TAG" \"%s\": Can't create object",
-			iptype->name);
-		return NULL;
-	}
-
-	if (!iptype_parse(iptype, kptype, error)) {
-		kptype_free(kptype);
-		return NULL;
-	}
-
-	// Parse nested elements
-	if (!iptype_parse_nested(iptype, kptype, error)) {
-		kptype_free(kptype);
-		return NULL;
-	}
-
-	return kptype;
-}
-
-
-char *iptype_deploy(const kptype_t *kptype, int level)
-{
-	char *str = NULL;
-	char *tmp = NULL;
-	kptype_actions_node_t *actions_iter = NULL;
-
-	tmp = faux_str_sprintf("%*cPTYPE {\n", level, ' ');
-	faux_str_cat(&str, tmp);
-	faux_str_free(tmp);
-
-	attr2ctext(&str, "name", kptype_name(kptype), level + 1);
-	attr2ctext(&str, "help", kptype_help(kptype), level + 1);
-
-	// ACTION list
-	actions_iter = kptype_actions_iter(kptype);
-	if (actions_iter) {
-		kaction_t *action = NULL;
-
-		tmp = faux_str_sprintf("\n%*cACTION_LIST\n\n", level + 1, ' ');
-		faux_str_cat(&str, tmp);
-		faux_str_free(tmp);
-
-		while ((action = kptype_actions_each(&actions_iter))) {
-			tmp = iaction_deploy(action, level + 2);
-			faux_str_cat(&str, tmp);
-			faux_str_free(tmp);
-		}
-
-		tmp = faux_str_sprintf("%*cEND_ACTION_LIST,\n", level + 1, ' ');
-		faux_str_cat(&str, tmp);
-		faux_str_free(tmp);
-	}
-
-	tmp = faux_str_sprintf("%*c},\n\n", level, ' ');
-	faux_str_cat(&str, tmp);
-	faux_str_free(tmp);
-
-	return str;
-}

+ 1 - 122
klish/ischeme/ischeme.c

@@ -7,10 +7,8 @@
 #include <faux/list.h>
 #include <klish/khelper.h>
 #include <klish/kplugin.h>
-#include <klish/kptype.h>
-#include <klish/kview.h>
+#include <klish/kentry.h>
 #include <klish/kscheme.h>
-#include <klish/iview.h>
 #include <klish/ischeme.h>
 
 #define TAG "SCHEME"
@@ -56,83 +54,6 @@ bool_t ischeme_parse_nested(const ischeme_t *ischeme, kscheme_t *kscheme,
 		}
 	}
 
-	// PTYPE list
-	if (ischeme->ptypes) {
-		iptype_t **p_iptype = NULL;
-		for (p_iptype = *ischeme->ptypes; *p_iptype; p_iptype++) {
-			kptype_t *kptype = NULL;
-			iptype_t *iptype = *p_iptype;
-
-			kptype = iptype_load(iptype, error);
-			if (!kptype) {
-				retval = BOOL_FALSE; // Don't stop
-				continue;
-			}
-			if (!kscheme_add_ptypes(kscheme, kptype)) {
-				// Search for PTYPE duplicates
-				if (kscheme_find_ptype(kscheme,
-					kptype_name(kptype))) {
-					faux_error_sprintf(error,
-						TAG": Can't add duplicate PTYPE "
-						"\"%s\"", kptype_name(kptype));
-				} else {
-					faux_error_sprintf(error,
-						TAG": Can't add PTYPE \"%s\"",
-						kptype_name(kptype));
-				}
-				kptype_free(kptype);
-				retval = BOOL_FALSE;
-			}
-		}
-	}
-
-	// VIEW list
-	// VIEW entries can be duplicate. Duplicated entries will add nested
-	// elements to existent VIEW. Also it can overwrite VIEW attributes.
-	// So there is no special rule which attribute value will be "on top".
-	// It's a random. Technically later VIEW entries will rewrite previous
-	// values.
-	if (ischeme->views) {
-		iview_t **p_iview = NULL;
-		for (p_iview = *ischeme->views; *p_iview; p_iview++) {
-			kview_t *kview = NULL;
-			iview_t *iview = *p_iview;
-			const char *view_name = iview->name;
-
-			if (view_name)
-				kview = kscheme_find_view(kscheme, view_name);
-
-			// VIEW already exists
-			if (kview) {
-				if (!iview_parse(iview, kview, error)) {
-					retval = BOOL_FALSE;
-					continue;
-				}
-				if (!iview_parse_nested(iview, kview,
-					error)) {
-					retval = BOOL_FALSE;
-					continue;
-				}
-				continue;
-			}
-
-			// New VIEW
-			kview = iview_load(iview, error);
-			if (!kview) {
-				retval = BOOL_FALSE;
-				continue;
-			}
-			if (!kscheme_add_views(kscheme, kview)) {
-				faux_error_sprintf(error,
-					TAG": Can't add VIEW \"%s\"",
-					kview_name(kview));
-				kview_free(kview);
-				retval = BOOL_FALSE;
-				continue;
-			}
-		}
-	}
-
 	// ENTRY list
 	// ENTRYs can be duplicate. Duplicated ENTRY will add nested
 	// elements to existent ENTRY. Also it can overwrite ENTRY attributes.
@@ -207,8 +128,6 @@ char *ischeme_deploy(const kscheme_t *scheme, int level)
 	char *str = NULL;
 	char *tmp = NULL;
 	kscheme_plugins_node_t *plugins_iter = NULL;
-	kscheme_ptypes_node_t *ptypes_iter = NULL;
-	kscheme_views_node_t *views_iter = NULL;
 	kscheme_entrys_node_t *entrys_iter = NULL;
 
 	tmp = faux_str_sprintf("ischeme_t sch = {\n");
@@ -235,46 +154,6 @@ char *ischeme_deploy(const kscheme_t *scheme, int level)
 		faux_str_free(tmp);
 	}
 
-	// PTYPE list
-	ptypes_iter = kscheme_ptypes_iter(scheme);
-	if (ptypes_iter) {
-		kptype_t *ptype = NULL;
-
-		tmp = faux_str_sprintf("\n%*cPTYPE_LIST\n\n", level, ' ');
-		faux_str_cat(&str, tmp);
-		faux_str_free(tmp);
-
-		while ((ptype = kscheme_ptypes_each(&ptypes_iter))) {
-			tmp = iptype_deploy(ptype, level + 2);
-			faux_str_cat(&str, tmp);
-			faux_str_free(tmp);
-		}
-
-		tmp = faux_str_sprintf("%*cEND_PTYPE_LIST,\n", level + 1, ' ');
-		faux_str_cat(&str, tmp);
-		faux_str_free(tmp);
-	}
-
-	// VIEW list
-	views_iter = kscheme_views_iter(scheme);
-	if (views_iter) {
-		kview_t *view = NULL;
-
-		tmp = faux_str_sprintf("\n%*cVIEW_LIST\n\n", level + 1, ' ');
-		faux_str_cat(&str, tmp);
-		faux_str_free(tmp);
-
-		while ((view = kscheme_views_each(&views_iter))) {
-			tmp = iview_deploy(view, level + 2);
-			faux_str_cat(&str, tmp);
-			faux_str_free(tmp);
-		}
-
-		tmp = faux_str_sprintf("%*cEND_VIEW_LIST,\n", level + 1, ' ');
-		faux_str_cat(&str, tmp);
-		faux_str_free(tmp);
-	}
-
 	// ENTRY list
 	entrys_iter = kscheme_entrys_iter(scheme);
 	if (entrys_iter) {

+ 0 - 201
klish/ischeme/iview.c

@@ -1,201 +0,0 @@
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <assert.h>
-
-#include <faux/str.h>
-#include <faux/list.h>
-#include <faux/error.h>
-#include <klish/khelper.h>
-#include <klish/kcommand.h>
-#include <klish/knspace.h>
-#include <klish/kview.h>
-#include <klish/iview.h>
-
-#define TAG "VIEW"
-
-
-bool_t iview_parse(const iview_t *info, kview_t *view, faux_error_t *error)
-{
-	bool_t retcode = BOOL_TRUE;
-
-	if (!info)
-		return BOOL_FALSE;
-	if (!view)
-		return BOOL_FALSE;
-
-	view = view;
-	info = info;
-	error = error;
-
-	return retcode;
-}
-
-
-bool_t iview_parse_nested(const iview_t *iview, kview_t *kview,
-	faux_error_t *error)
-{
-	bool_t retval = BOOL_TRUE;
-
-	if (!kview || !iview) {
-		faux_error_add(error, TAG": Internal error");
-		return BOOL_FALSE;
-	}
-
-	// NSPACE list
-	if (iview->nspaces) {
-		inspace_t **p_inspace = NULL;
-		for (p_inspace = *iview->nspaces; *p_inspace; p_inspace++) {
-			knspace_t *knspace = NULL;
-			inspace_t *inspace = *p_inspace;
-			knspace = inspace_load(inspace, error);
-			if (!knspace) {
-				retval = BOOL_FALSE;
-				continue;
-			}
-			if (!kview_add_nspaces(kview, knspace)) {
-				faux_error_sprintf(error,
-					TAG": Can't add NSPACE \"%s\"",
-					knspace_view_ref(knspace));
-				knspace_free(knspace);
-				retval = BOOL_FALSE;
-				continue;
-			}
-		}
-	}
-
-	// COMMAND list
-	if (iview->commands) {
-		icommand_t **p_icommand = NULL;
-		for (p_icommand = *iview->commands; *p_icommand; p_icommand++) {
-			kcommand_t *kcommand = NULL;
-			icommand_t *icommand = *p_icommand;
-			kcommand = icommand_load(icommand, error);
-			if (!kcommand) {
-				retval = BOOL_FALSE;
-				continue;
-			}
-			if (!kview_add_commands(kview, kcommand)) {
-				// Search for COMMAND duplicates
-				if (kview_find_command(kview,
-					kcommand_name(kcommand))) {
-					faux_error_sprintf(error,
-						TAG": Can't add duplicate COMMAND "
-						"\"%s\"", kcommand_name(kcommand));
-				} else {
-					faux_error_sprintf(error,
-						TAG": Can't add COMMAND \"%s\"",
-						kcommand_name(kcommand));
-				}
-				kcommand_free(kcommand);
-				retval = BOOL_FALSE;
-				continue;
-			}
-		}
-	}
-
-	if (!retval)
-		faux_error_sprintf(error, TAG" \"%s\": Illegal nested elements",
-			kview_name(kview));
-
-	return retval;
-}
-
-
-kview_t *iview_load(const iview_t *iview, faux_error_t *error)
-{
-	kview_t *kview = NULL;
-
-	if (!iview)
-		return NULL;
-
-	// Name [mandatory]
-	if (faux_str_is_empty(iview->name)) {
-		faux_error_add(error, TAG": Empty 'name' attribute");
-		return NULL;
-	}
-
-	kview = kview_new(iview->name);
-	if (!kview) {
-		faux_error_sprintf(error, TAG": \"%s\": Can't create object",
-			iview->name);
-		return NULL;
-	}
-
-	if (!iview_parse(iview, kview, error)) {
-		kview_free(kview);
-		return NULL;
-	}
-
-	// Parse nested elements
-	if (!iview_parse_nested(iview, kview, error)) {
-		kview_free(kview);
-		return NULL;
-	}
-
-	return kview;
-}
-
-
-char *iview_deploy(const kview_t *kview, int level)
-{
-	char *str = NULL;
-	char *tmp = NULL;
-	kview_commands_node_t *commands_iter = NULL;
-	kview_nspaces_node_t *nspaces_iter = NULL;
-
-	if (!kview)
-		return NULL;
-
-	tmp = faux_str_sprintf("%*cVIEW {\n", level, ' ');
-	faux_str_cat(&str, tmp);
-	faux_str_free(tmp);
-
-	attr2ctext(&str, "name", kview_name(kview), level + 1);
-
-	// NSPACE list
-	nspaces_iter = kview_nspaces_iter(kview);
-	if (nspaces_iter) {
-		knspace_t *nspace = NULL;
-
-		tmp = faux_str_sprintf("\n%*cNSPACE_LIST\n\n", level + 1, ' ');
-		faux_str_cat(&str, tmp);
-		faux_str_free(tmp);
-
-		while ((nspace = kview_nspaces_each(&nspaces_iter))) {
-			tmp = inspace_deploy(nspace, level + 2);
-			faux_str_cat(&str, tmp);
-			faux_str_free(tmp);
-		}
-
-		tmp = faux_str_sprintf("%*cEND_NSPACE_LIST,\n", level + 1, ' ');
-		faux_str_cat(&str, tmp);
-		faux_str_free(tmp);
-	}
-
-	// COMMAND list
-	commands_iter = kview_commands_iter(kview);
-	if (commands_iter) {
-		kcommand_t *command = NULL;
-
-		tmp = faux_str_sprintf("\n%*cCOMMAND_LIST\n\n", level + 1, ' ');
-		faux_str_cat(&str, tmp);
-		faux_str_free(tmp);
-
-		while ((command = kview_commands_each(&commands_iter))) {
-			tmp = icommand_deploy(command, level + 2);
-			faux_str_cat(&str, tmp);
-			faux_str_free(tmp);
-		}
-
-		tmp = faux_str_sprintf("%*cEND_COMMAND_LIST,\n", level + 1, ' ');
-		faux_str_cat(&str, tmp);
-		faux_str_free(tmp);
-	}
-
-	tmp = faux_str_sprintf("%*c},\n\n", level, ' ');
-	faux_str_cat(&str, tmp);
-	faux_str_free(tmp);
-
-	return str;
-}

+ 0 - 30
klish/iview.h

@@ -1,30 +0,0 @@
-/** @file view.h
- *
- * @brief Klish scheme's "view" entry
- */
-
-#ifndef _klish_iview_h
-#define _klish_iview_h
-
-#include <faux/error.h>
-#include <klish/icommand.h>
-#include <klish/inspace.h>
-#include <klish/kview.h>
-
-typedef struct iview_s {
-	char *name;
-	inspace_t * (*nspaces)[];
-	icommand_t * (*commands)[];
-} iview_t;
-
-C_DECL_BEGIN
-
-bool_t iview_parse(const iview_t *info, kview_t *view, faux_error_t *error);
-bool_t iview_parse_nested(const iview_t *iview, kview_t *kview,
-	faux_error_t *error);
-kview_t *iview_load(const iview_t *iview, faux_error_t *error);
-char *iview_deploy(const kview_t *kview, int level);
-
-C_DECL_END
-
-#endif // _klish_iview_h

+ 0 - 45
klish/kcommand.h

@@ -1,45 +0,0 @@
-/** @file kcommand.h
- *
- * @brief Klish scheme's "command" entry
- */
-
-#ifndef _klish_kcommand_h
-#define _klish_kcommand_h
-
-#include <faux/list.h>
-#include <klish/kparam.h>
-#include <klish/kaction.h>
-
-
-typedef struct kcommand_s kcommand_t;
-
-typedef faux_list_node_t kcommand_params_node_t;
-typedef faux_list_node_t kcommand_actions_node_t;
-
-C_DECL_BEGIN
-
-kcommand_t *kcommand_new(const char *name);
-void kcommand_free(kcommand_t *command);
-
-const char *kcommand_name(const kcommand_t *command);
-const char *kcommand_help(const kcommand_t *command);
-bool_t kcommand_set_help(kcommand_t *command, const char *help);
-
-// PARAMs
-faux_list_t *kcommand_params(const kcommand_t *command);
-bool_t kcommand_add_params(kcommand_t *command, kparam_t *param);
-kparam_t *kcommand_find_param(const kcommand_t *command, const char *name);
-ssize_t kcommand_params_len(const kcommand_t *command);
-kcommand_params_node_t *kcommand_params_iter(const kcommand_t *command);
-kparam_t *kcommand_params_each(kcommand_params_node_t **iter);
-
-// ACTIONs
-faux_list_t *kcommand_actions(const kcommand_t *command);
-bool_t kcommand_add_actions(kcommand_t *command, kaction_t *action);
-ssize_t kcommand_actions_len(const kcommand_t *command);
-kcommand_actions_node_t *kcommand_actions_iter(const kcommand_t *command);
-kaction_t *kcommand_actions_each(kcommand_actions_node_t **iter);
-
-C_DECL_END
-
-#endif // _klish_kcommand_h

+ 0 - 36
klish/knspace.h

@@ -1,36 +0,0 @@
-/** @file nspace.h
- *
- * @brief Klish scheme's "nspace" entry
- */
-
-#ifndef _klish_knspace_h
-#define _klish_knspace_h
-
-#include <faux/faux.h>
-#include <faux/list.h>
-#include <klish/kview.h>
-
-
-typedef struct knspace_s knspace_t;
-
-// kview_t and knspace_t have a loop of references
-typedef struct kview_s kview_t;
-
-
-C_DECL_BEGIN
-
-knspace_t *knspace_new(const char *view_ref);
-void knspace_free(knspace_t *nspace);
-
-// View_ref
-const char *knspace_view_ref(const knspace_t *nspace);
-// View
-kview_t *knspace_view(const knspace_t *nspace);
-bool_t knspace_set_view(knspace_t *nspace, kview_t *view);
-// View
-const char *knspace_prefix(const knspace_t *nspace);
-bool_t knspace_set_prefix(knspace_t *nspace, const char *prefix);
-
-C_DECL_END
-
-#endif // _klish_knspace_h

+ 0 - 50
klish/kparam.h

@@ -1,50 +0,0 @@
-/** @file kparam.h
- *
- * @brief Klish scheme's "param" entry
- */
-
-#ifndef _klish_kparam_h
-#define _klish_kparam_h
-
-#include <faux/list.h>
-#include <klish/kptype.h>
-
-typedef struct kparam_s kparam_t;
-
-typedef faux_list_node_t kparam_params_node_t;
-
-typedef enum {
-	KPARAM_NONE, // Illegal
-	KPARAM_COMMON, // Common parameter
-	KPARAM_SUBCOMMAND, // The value of this parameter is its name
-	KPARAM_SWITCH, // User can choose one of nested parameters
-	KPARAM_MULTI, // Nested parameters can be used several times
-} kparam_mode_e;
-
-
-C_DECL_BEGIN
-
-kparam_t *kparam_new(const char *name);
-void kparam_free(kparam_t *param);
-
-const char *kparam_name(const kparam_t *param);
-const char *kparam_help(const kparam_t *param);
-bool_t kparam_set_help(kparam_t *param, const char *help);
-const char *kparam_ptype_ref(const kparam_t *param);
-bool_t kparam_set_ptype_ref(kparam_t *param, const char *ptype_ref);
-kptype_t *kparam_ptype(const kparam_t *param);
-bool_t kparam_set_ptype(kparam_t *param, kptype_t *ptype);
-kparam_mode_e kparam_mode(const kparam_t *param);
-bool_t kparam_set_mode(kparam_t *param, kparam_mode_e mode);
-
-// PARAMs
-faux_list_t *kparam_params(const kparam_t *param);
-bool_t kparam_add_params(kparam_t *param, kparam_t *nested_param);
-kparam_t *kparam_find_param(const kparam_t *param, const char *name);
-ssize_t kparam_params_len(const kparam_t *param);
-kparam_params_node_t *kparam_params_iter(const kparam_t *param);
-kparam_t *kparam_params_each(kparam_params_node_t **iter);
-
-C_DECL_END
-
-#endif // _klish_kparam_h

+ 0 - 34
klish/kptype.h

@@ -1,34 +0,0 @@
-/** @file kptype.h
- *
- * @brief Klish scheme's "ptype" entry
- */
-
-#ifndef _klish_kptype_h
-#define _klish_kptype_h
-
-#include <faux/list.h>
-#include <klish/kaction.h>
-
-typedef struct kptype_s kptype_t;
-
-typedef faux_list_node_t kptype_actions_node_t;
-
-C_DECL_BEGIN
-
-kptype_t *kptype_new(const char *name);
-void kptype_free(kptype_t *ptype);
-
-const char *kptype_name(const kptype_t *ptype);
-const char *kptype_help(const kptype_t *ptype);
-bool_t kptype_set_help(kptype_t *ptype, const char *help);
-
-// ACTIONs
-faux_list_t *kptype_actions(const kptype_t *ptype);
-bool_t kptype_add_actions(kptype_t *plugin, kaction_t *action);
-ssize_t kptype_actions_len(const kptype_t *plugin);
-kptype_actions_node_t *kptype_actions_iter(const kptype_t *plugin);
-kaction_t *kptype_actions_each(kptype_actions_node_t **iter);
-
-C_DECL_END
-
-#endif // _klish_kptype_h

+ 0 - 20
klish/kscheme.h

@@ -8,16 +8,12 @@
 
 #include <faux/list.h>
 #include <klish/kplugin.h>
-#include <klish/kptype.h>
-#include <klish/kview.h>
 #include <klish/kentry.h>
 #include <klish/kcontext_base.h>
 
 
 typedef struct kscheme_s kscheme_t;
 
-typedef faux_list_node_t kscheme_views_node_t;
-typedef faux_list_node_t kscheme_ptypes_node_t;
 typedef faux_list_node_t kscheme_plugins_node_t;
 typedef faux_list_node_t kscheme_entrys_node_t;
 
@@ -30,22 +26,6 @@ void kscheme_free(kscheme_t *scheme);
 bool_t kscheme_prepare(kscheme_t *scheme, kcontext_t *context, faux_error_t *error);
 bool_t kscheme_fini(kscheme_t *scheme, kcontext_t *context, faux_error_t *error);
 
-// VIEWs
-faux_list_t *kscheme_views(const kscheme_t *scheme);
-bool_t kscheme_add_views(kscheme_t *scheme, kview_t *view);
-kview_t *kscheme_find_view(const kscheme_t *scheme, const char *name);
-ssize_t kscheme_views_len(const kscheme_t *scheme);
-kscheme_views_node_t *kscheme_views_iter(const kscheme_t *scheme);
-kview_t *kscheme_views_each(kscheme_views_node_t **iter);
-
-// PTYPEs
-faux_list_t *kscheme_ptypes(const kscheme_t *scheme);
-bool_t kscheme_add_ptypes(kscheme_t *scheme, kptype_t *ptype);
-kptype_t *kscheme_find_ptype(const kscheme_t *scheme, const char *name);
-ssize_t kscheme_ptypes_len(const kscheme_t *scheme);
-kscheme_ptypes_node_t *kscheme_ptypes_iter(const kscheme_t *scheme);
-kptype_t *kscheme_ptypes_each(kscheme_ptypes_node_t **iter);
-
 // PLUGINs
 faux_list_t *kscheme_plugins(const kscheme_t *scheme);
 bool_t kscheme_add_plugins(kscheme_t *scheme, kplugin_t *plugin);

+ 0 - 5
klish/kscheme/Makefile.am

@@ -2,12 +2,7 @@ libklish_la_SOURCES += \
 	klish/kscheme/khelper.c \
 	klish/kscheme/ksym.c \
 	klish/kscheme/kplugin.c \
-	klish/kscheme/kptype.c \
 	klish/kscheme/kaction.c \
-	klish/kscheme/kparam.c \
-	klish/kscheme/kcommand.c \
-	klish/kscheme/kview.c \
 	klish/kscheme/kscheme.c \
-	klish/kscheme/knspace.c \
 	klish/kscheme/kdb.c \
 	klish/kscheme/kentry.c

+ 0 - 90
klish/kscheme/kcommand.c

@@ -1,90 +0,0 @@
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <assert.h>
-
-#include <faux/str.h>
-#include <faux/list.h>
-#include <klish/khelper.h>
-#include <klish/kparam.h>
-#include <klish/kaction.h>
-#include <klish/kcommand.h>
-
-
-struct kcommand_s {
-	char *name;
-	char *help;
-	faux_list_t *params;
-	faux_list_t *actions;
-};
-
-// Simple attributes
-
-// Name
-KGET_STR(command, name);
-
-// Help
-KGET_STR(command, help);
-KSET_STR(command, help);
-
-// PARAM list
-KGET(command, faux_list_t *, params);
-static KCMP_NESTED(command, param, name);
-static KCMP_NESTED_BY_KEY(command, param, name);
-KADD_NESTED(command, kparam_t *, params);
-KFIND_NESTED(command, param);
-KNESTED_LEN(command, params);
-KNESTED_ITER(command, params);
-KNESTED_EACH(command, kparam_t *, params);
-
-// ACTION list
-KGET(command, faux_list_t *, actions);
-KADD_NESTED(command, kaction_t *, actions);
-KNESTED_LEN(command, actions);
-KNESTED_ITER(command, actions);
-KNESTED_EACH(command, kaction_t *, actions);
-
-
-kcommand_t *kcommand_new(const char *name)
-{
-	kcommand_t *command = NULL;
-
-	if (faux_str_is_empty(name))
-		return NULL;
-
-	command = faux_zmalloc(sizeof(*command));
-	assert(command);
-	if (!command)
-		return NULL;
-
-	// Initialize
-	command->name = faux_str_dup(name);
-	command->help = NULL;
-
-	// PARAM list
-	command->params = faux_list_new(FAUX_LIST_UNSORTED, FAUX_LIST_UNIQUE,
-		kcommand_param_compare, kcommand_param_kcompare,
-		(void (*)(void *))kparam_free);
-	assert(command->params);
-
-	// ACTION list
-	command->actions = faux_list_new(FAUX_LIST_UNSORTED, FAUX_LIST_NONUNIQUE,
-		NULL, NULL, (void (*)(void *))kaction_free);
-	assert(command->actions);
-
-	return command;
-}
-
-
-void kcommand_free(kcommand_t *command)
-{
-	if (!command)
-		return;
-
-	faux_str_free(command->name);
-	faux_str_free(command->help);
-	faux_list_free(command->params);
-	faux_list_free(command->actions);
-
-	faux_free(command);
-}

+ 0 - 64
klish/kscheme/knspace.c

@@ -1,64 +0,0 @@
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <assert.h>
-
-#include <faux/str.h>
-#include <faux/list.h>
-#include <faux/error.h>
-#include <klish/khelper.h>
-#include <klish/kview.h>
-#include <klish/knspace.h>
-
-struct knspace_s {
-	char *view_ref;
-	kview_t *view;
-	char *prefix;
-};
-
-
-// Simple attributes
-
-// Name
-KGET_STR(nspace, view_ref);
-
-// View
-KGET(nspace, kview_t *, view);
-KSET(nspace, kview_t *, view);
-
-// Prefix
-KGET_STR(nspace, prefix);
-KSET_STR(nspace, prefix);
-
-
-knspace_t *knspace_new(const char *view_ref)
-{
-	knspace_t *nspace = NULL;
-
-	if (faux_str_is_empty(view_ref))
-		return NULL;
-
-	nspace = faux_zmalloc(sizeof(*nspace));
-	assert(nspace);
-	if (!nspace)
-		return NULL;
-
-	// Initialize
-	nspace->view_ref = faux_str_dup(view_ref);
-	nspace->view = NULL;
-	nspace->prefix = NULL;
-
-	return nspace;
-}
-
-
-void knspace_free(knspace_t *nspace)
-{
-	if (!nspace)
-		return;
-
-	faux_str_free(nspace->view_ref);
-	faux_str_free(nspace->prefix);
-
-	faux_free(nspace);
-}

+ 0 - 91
klish/kscheme/kparam.c

@@ -1,91 +0,0 @@
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <assert.h>
-
-#include <faux/str.h>
-#include <faux/list.h>
-#include <klish/khelper.h>
-#include <klish/kptype.h>
-#include <klish/kparam.h>
-
-
-struct kparam_s {
-	char *name;
-	char *help;
-	char *ptype_ref; // Text reference to PTYPE
-	kptype_t *ptype; // Resolved PARAM's PTYPE
-	kparam_mode_e mode;
-	faux_list_t *params; // Nested parameters
-};
-
-// Simple methods
-
-// Name
-KGET_STR(param, name);
-
-// Help
-KGET_STR(param, help);
-KSET_STR(param, help);
-
-// PTYPE reference (must be resolved later)
-KGET_STR(param, ptype_ref);
-KSET_STR(param, ptype_ref);
-
-// PTYPE (resolved)
-KGET(param, kptype_t *, ptype);
-KSET(param, kptype_t *, ptype);
-
-// Mode
-KGET(param, kparam_mode_e, mode);
-KSET(param, kparam_mode_e, mode);
-
-// PARAM list
-KGET(param, faux_list_t *, params);
-static KCMP_NESTED(param, param, name);
-static KCMP_NESTED_BY_KEY(param, param, name);
-KADD_NESTED(param, kparam_t *, params);
-KFIND_NESTED(param, param);
-KNESTED_ITER(param, params);
-KNESTED_EACH(param, kparam_t *, params);
-
-
-kparam_t *kparam_new(const char *name)
-{
-	kparam_t *param = NULL;
-
-	if (faux_str_is_empty(name))
-		return NULL;
-
-	param = faux_zmalloc(sizeof(*param));
-	assert(param);
-	if (!param)
-		return NULL;
-
-	// Initialize
-	param->name = faux_str_dup(name);
-	param->help = NULL;
-	param->ptype_ref = NULL;
-	param->ptype = NULL;
-
-	param->params = faux_list_new(FAUX_LIST_UNSORTED, FAUX_LIST_UNIQUE,
-		kparam_param_compare, kparam_param_kcompare,
-		(void (*)(void *))kparam_free);
-	assert(param->params);
-
-	return param;
-}
-
-
-void kparam_free(kparam_t *param)
-{
-	if (!param)
-		return;
-
-	faux_str_free(param->name);
-	faux_str_free(param->help);
-	faux_str_free(param->ptype_ref);
-	faux_list_free(param->params);
-
-	faux_free(param);
-}

+ 0 - 73
klish/kscheme/kptype.c

@@ -1,73 +0,0 @@
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <assert.h>
-
-#include <faux/str.h>
-#include <faux/list.h>
-#include <faux/error.h>
-#include <klish/khelper.h>
-#include <klish/kptype.h>
-#include <klish/kaction.h>
-
-
-struct kptype_s {
-	char *name;
-	char *help;
-	faux_list_t *actions;
-};
-
-
-// Simple methods
-
-// Name
-KGET_STR(ptype, name);
-
-// Help
-KGET_STR(ptype, help);
-KSET_STR(ptype, help);
-
-// ACTION list
-KGET(ptype, faux_list_t *, actions);
-KADD_NESTED(ptype, kaction_t *, actions);
-KNESTED_LEN(ptype, actions);
-KNESTED_ITER(ptype, actions);
-KNESTED_EACH(ptype, kaction_t *, actions);
-
-
-kptype_t *kptype_new(const char *name)
-{
-	kptype_t *ptype = NULL;
-
-	if (faux_str_is_empty(name))
-		return NULL;
-
-	ptype = faux_zmalloc(sizeof(*ptype));
-	assert(ptype);
-	if (!ptype)
-		return NULL;
-
-	// Initialize
-	ptype->name = faux_str_dup(name);
-	ptype->help = NULL;
-
-	// ACTION list
-	ptype->actions = faux_list_new(FAUX_LIST_UNSORTED, FAUX_LIST_NONUNIQUE,
-		NULL, NULL, (void (*)(void *))kaction_free);
-	assert(ptype->actions);
-
-	return ptype;
-}
-
-
-void kptype_free(kptype_t *ptype)
-{
-	if (!ptype)
-		return;
-
-	faux_str_free(ptype->name);
-	faux_str_free(ptype->help);
-	faux_list_free(ptype->actions);
-
-	faux_free(ptype);
-}

+ 0 - 117
klish/kscheme/kscheme.c

@@ -8,9 +8,6 @@
 #include <faux/error.h>
 #include <klish/khelper.h>
 #include <klish/kplugin.h>
-#include <klish/kptype.h>
-#include <klish/kview.h>
-#include <klish/knspace.h>
 #include <klish/kentry.h>
 #include <klish/kscheme.h>
 #include <klish/kcontext.h>
@@ -18,8 +15,6 @@
 
 struct kscheme_s {
 	faux_list_t *plugins;
-	faux_list_t *ptypes;
-	faux_list_t *views;
 	faux_list_t *entrys;
 };
 
@@ -35,26 +30,6 @@ KNESTED_LEN(scheme, plugins);
 KNESTED_ITER(scheme, plugins);
 KNESTED_EACH(scheme, kplugin_t *, plugins);
 
-// PTYPE list
-KGET(scheme, faux_list_t *, ptypes);
-KCMP_NESTED(scheme, ptype, name);
-KCMP_NESTED_BY_KEY(scheme, ptype, name);
-KADD_NESTED(scheme, kptype_t *, ptypes);
-KFIND_NESTED(scheme, ptype);
-KNESTED_LEN(scheme, ptypes);
-KNESTED_ITER(scheme, ptypes);
-KNESTED_EACH(scheme, kptype_t *, ptypes);
-
-// VIEW list
-KGET(scheme, faux_list_t *, views);
-KCMP_NESTED(scheme, view, name);
-KCMP_NESTED_BY_KEY(scheme, view, name);
-KADD_NESTED(scheme, kview_t *, views);
-KFIND_NESTED(scheme, view);
-KNESTED_LEN(scheme, views);
-KNESTED_ITER(scheme, views);
-KNESTED_EACH(scheme, kview_t *, views);
-
 // ENTRY list
 KGET(scheme, faux_list_t *, entrys);
 KCMP_NESTED(scheme, entry, name);
@@ -81,18 +56,6 @@ kscheme_t *kscheme_new(void)
 		(void (*)(void *))kplugin_free);
 	assert(scheme->plugins);
 
-	// PTYPE list
-	scheme->ptypes = faux_list_new(FAUX_LIST_SORTED, FAUX_LIST_UNIQUE,
-		kscheme_ptype_compare, kscheme_ptype_kcompare,
-		(void (*)(void *))kptype_free);
-	assert(scheme->ptypes);
-
-	// VIEW list
-	scheme->views = faux_list_new(FAUX_LIST_SORTED, FAUX_LIST_UNIQUE,
-		kscheme_view_compare, kscheme_view_kcompare,
-		(void (*)(void *))kview_free);
-	assert(scheme->views);
-
 	// ENTRY list
 	// Must be unsorted because order is important
 	scheme->entrys = faux_list_new(FAUX_LIST_UNSORTED, FAUX_LIST_UNIQUE,
@@ -100,7 +63,6 @@ kscheme_t *kscheme_new(void)
 		(void (*)(void *))kentry_free);
 	assert(scheme->entrys);
 
-
 	return scheme;
 }
 
@@ -111,8 +73,6 @@ void kscheme_free(kscheme_t *scheme)
 		return;
 
 	faux_list_free(scheme->plugins);
-	faux_list_free(scheme->ptypes);
-	faux_list_free(scheme->views);
 	faux_list_free(scheme->entrys);
 
 	faux_free(scheme);
@@ -290,43 +250,6 @@ bool_t kscheme_prepare_action_list(kscheme_t *scheme, faux_list_t *action_list,
 }
 
 
-bool_t kscheme_prepare_param_list(kscheme_t *scheme, faux_list_t *param_list,
-	faux_error_t *error) {
-	faux_list_node_t *iter = NULL;
-	kparam_t *param = NULL;
-	bool_t retcode = BOOL_TRUE;
-
-	assert(scheme);
-	if (!scheme)
-		return BOOL_FALSE;
-	assert(param_list);
-	if (!param_list)
-		return BOOL_FALSE;
-	if (faux_list_is_empty(param_list))
-		return BOOL_TRUE;
-
-	iter = faux_list_head(param_list);
-	while ((param = (kparam_t *)faux_list_each(&iter))) {
-		kptype_t *ptype = NULL;
-		const char *ptype_ref = kparam_ptype_ref(param);
-		ptype = kscheme_find_ptype(scheme, ptype_ref);
-		if (!ptype) {
-			faux_error_sprintf(error, "Can't find ptype \"%s\"",
-				ptype_ref);
-			retcode = BOOL_FALSE;
-			continue;
-		}
-		kparam_set_ptype(param, ptype);
-		// Nested PARAMs
-		if (!kscheme_prepare_param_list(scheme, kparam_params(param),
-			error))
-			retcode = BOOL_FALSE;
-	}
-
-	return retcode;
-}
-
-
 kentry_t *kscheme_find_entry_by_path(const kscheme_t *scheme, const char *name)
 {
 	char *saveptr = NULL;
@@ -435,8 +358,6 @@ bool_t kscheme_prepare_entry(kscheme_t *scheme, kentry_t *entry,
  */
 bool_t kscheme_prepare(kscheme_t *scheme, kcontext_t *context, faux_error_t *error)
 {
-	kscheme_views_node_t *views_iter = NULL;
-	kview_t *view = NULL;
 	kscheme_entrys_node_t *entrys_iter = NULL;
 	kentry_t *entry = NULL;
 
@@ -449,44 +370,6 @@ bool_t kscheme_prepare(kscheme_t *scheme, kcontext_t *context, faux_error_t *err
 	if (!kscheme_load_plugins(scheme, context, error))
 		return BOOL_FALSE;
 
-	// Iterate VIEWs
-	views_iter = kscheme_views_iter(scheme);
-	while ((view = kscheme_views_each(&views_iter))) {
-		kview_commands_node_t *commands_iter = NULL;
-		kcommand_t *command = NULL;
-		kview_nspaces_node_t *nspaces_iter = NULL;
-		knspace_t *nspace = NULL;
-
-		printf("VIEW: %s\n", kview_name(view));
-
-		// Iterate NSPACEs
-		nspaces_iter = kview_nspaces_iter(view);
-		while ((nspace = kview_nspaces_each(&nspaces_iter))) {
-			const char *view_ref = knspace_view_ref(nspace);
-			kview_t *rview = NULL;
-			rview = kscheme_find_view(scheme, view_ref);
-			if (!view)
-				return BOOL_FALSE;
-			knspace_set_view(nspace, rview);
-			printf("NSPACE: %s\n",
-				kview_name(knspace_view(nspace)));
-		}
-
-		// Iterate COMMANDs
-		commands_iter = kview_commands_iter(view);
-		while ((command = kview_commands_each(&commands_iter))) {
-			printf("COMMAND: %s\n", kcommand_name(command));
-			// ACTIONs
-			if (!kscheme_prepare_action_list(scheme,
-				kcommand_actions(command), error))
-				return BOOL_FALSE;
-			// PARAMs
-			if (!kscheme_prepare_param_list(scheme,
-				kcommand_params(command), error))
-				return BOOL_FALSE;
-		}
-	}
-
 	// Iterate ENTRYs
 	entrys_iter = kscheme_entrys_iter(scheme);
 	while ((entry = kscheme_entrys_each(&entrys_iter))) {

+ 0 - 87
klish/kscheme/kview.c

@@ -1,87 +0,0 @@
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <assert.h>
-
-#include <faux/str.h>
-#include <faux/list.h>
-#include <faux/error.h>
-#include <klish/khelper.h>
-#include <klish/kcommand.h>
-#include <klish/knspace.h>
-#include <klish/kview.h>
-
-struct kview_s {
-	char *name;
-	faux_list_t *commands;
-	faux_list_t *nspaces;
-};
-
-
-// Simple attributes
-
-// Name
-KGET_STR(view, name);
-
-// COMMAND list
-KGET(view, faux_list_t *, commands);
-KCMP_NESTED(view, command, name);
-KCMP_NESTED_BY_KEY(view, command, name);
-KADD_NESTED(view, kcommand_t *, commands);
-KFIND_NESTED(view, command);
-KNESTED_LEN(view, commands);
-KNESTED_ITER(view, commands);
-KNESTED_EACH(view, kcommand_t *, commands);
-
-// NSPACE list
-KGET(view, faux_list_t *, nspaces);
-KADD_NESTED(view, knspace_t *, nspaces);
-KNESTED_LEN(view, nspaces);
-KNESTED_ITER(view, nspaces);
-KNESTED_EACH(view, knspace_t *, nspaces);
-
-
-kview_t *kview_new(const char *name)
-{
-	kview_t *view = NULL;
-
-	if (faux_str_is_empty(name))
-		return NULL;
-
-	view = faux_zmalloc(sizeof(*view));
-	assert(view);
-	if (!view)
-		return NULL;
-
-	// Initialize
-	view->name = faux_str_dup(name);
-
-	// COMMANDs
-	view->commands = faux_list_new(FAUX_LIST_SORTED, FAUX_LIST_UNIQUE,
-		kview_command_compare, kview_command_kcompare,
-		(void (*)(void *))kcommand_free);
-	assert(view->commands);
-
-	// NSPACEs
-	// The order of NSPACEs is the same as order of NSPACE tags.
-	// The NSPACE need not to be unique because each VIEW can be
-	// NSPACEd with prefix or without prefix.
-	view->nspaces = faux_list_new(FAUX_LIST_UNSORTED, FAUX_LIST_NONUNIQUE,
-		NULL, NULL, (void (*)(void *))knspace_free);
-	assert(view->nspaces);
-
-	return view;
-}
-
-
-void kview_free(kview_t *view)
-{
-	if (!view)
-		return;
-
-	faux_str_free(view->name);
-	faux_list_free(view->commands);
-	faux_list_free(view->nspaces);
-
-	faux_free(view);
-}

+ 0 - 50
klish/kview.h

@@ -1,50 +0,0 @@
-/** @file view.h
- *
- * @brief Klish scheme's "view" entry
- */
-
-#ifndef _klish_kview_h
-#define _klish_kview_h
-
-#include <faux/faux.h>
-#include <faux/list.h>
-#include <klish/kcommand.h>
-#include <klish/knspace.h>
-
-
-typedef struct kview_s kview_t;
-
-// kview_t and knspace_t have a loop of references
-typedef struct knspace_s knspace_t;
-
-
-typedef faux_list_node_t kview_commands_node_t;
-typedef faux_list_node_t kview_nspaces_node_t;
-
-
-C_DECL_BEGIN
-
-kview_t *kview_new(const char *name);
-void kview_free(kview_t *view);
-
-const char *kview_name(const kview_t *view);
-
-// COMMANDs
-faux_list_t *kview_commands(const kview_t *view);
-bool_t kview_add_commands(kview_t *view, kcommand_t *command);
-kcommand_t *kview_find_command(const kview_t *view, const char *name);
-ssize_t kview_commands_len(const kview_t *view);
-kview_commands_node_t *kview_commands_iter(const kview_t *view);
-kcommand_t *kview_commands_each(kview_commands_node_t **iter);
-
-// NAMESPACEs
-faux_list_t *kview_nspaces(const kview_t *view);
-bool_t kview_add_nspaces(kview_t *view, knspace_t *nspace);
-ssize_t kview_nspaces_len(const kview_t *view);
-kview_nspaces_node_t *kview_nspaces_iter(const kview_t *view);
-knspace_t *kview_nspaces_each(kview_nspaces_node_t **iter);
-
-
-C_DECL_END
-
-#endif // _klish_kview_h

+ 232 - 167
klish/xml-helper/load.c

@@ -313,57 +313,68 @@ static bool_t process_klish(const kxml_node_t *element, void *parent,
 static bool_t process_view(const kxml_node_t *element, void *parent,
 	faux_error_t *error)
 {
-	iview_t iview = {};
-	kview_t *view = NULL;
+	ientry_t ientry = {};
+	kentry_t *entry = NULL;
 	bool_t res = BOOL_FALSE;
 	ktags_e parent_tag = kxml_node_tag(kxml_node_parent(element));
 	kscheme_t *scheme = (kscheme_t *)parent;
 
+	// Mandatory VIEW name
+	ientry.name = kxml_node_attr(element, "name");
+	if (!ientry.name) {
+		faux_error_sprintf(error, TAG": VIEW without name");
+		return BOOL_FALSE;
+	}
+	ientry.help = kxml_node_attr(element, "help");
+	ientry.container = "true";
+	ientry.mode = "switch";
+	ientry.min = "1";
+	ientry.max = "1";
+	ientry.ptype = NULL;
+	ientry.ref = NULL;
+	ientry.value = NULL;
+	ientry.restore = "false";
+	ientry.order = "true";
+
 	// Parent must be a KLISH tag
 	if (parent_tag != KTAG_KLISH) {
 		faux_error_sprintf(error,
 			TAG": Tag \"%s\" can't contain VIEW tag",
 			kxml_tag_name(parent_tag));
-		return BOOL_FALSE;
+		goto err;
 	}
 	if (!scheme) {
 		faux_error_sprintf(error,
 			TAG": Broken parent object for VIEW \"%s\"",
-			iview.name);
-		return BOOL_FALSE;
-	}
-
-	// Mandatory VIEW name
-	iview.name = kxml_node_attr(element, "name");
-	if (!iview.name) {
-		faux_error_sprintf(error, TAG": VIEW without name");
-		return BOOL_FALSE;
+			ientry.name);
+		goto err;
 	}
 
 	// Does VIEW already exist
-	view = kscheme_find_view(scheme, iview.name);
-	if (view) {
-		if (!iview_parse(&iview, view, error))
+	entry = kscheme_find_entry(scheme, ientry.name);
+	if (entry) {
+		if (!ientry_parse(&ientry, entry, error))
 			goto err;
 	} else { // New VIEW object
-		view = iview_load(&iview, error);
-		if (!view)
+		entry = ientry_load(&ientry, error);
+		if (!entry)
 			goto err;
-		if (!kscheme_add_views(scheme, view)) {
+		if (!kscheme_add_entrys(scheme, entry)) {
 			faux_error_sprintf(error, TAG": Can't add VIEW \"%s\". "
 				"Probably duplication",
-				kview_name(view));
-			kview_free(view);
+				kentry_name(entry));
+			kentry_free(entry);
 			goto err;
 		}
 	}
 
-	if (!process_children(element, view, error))
+	if (!process_children(element, entry, error))
 		goto err;
 
 	res = BOOL_TRUE;
 err:
-	kxml_node_attr_free(iview.name);
+	kxml_node_attr_free(ientry.name);
+	kxml_node_attr_free(ientry.help);
 
 	return res;
 }
@@ -372,40 +383,63 @@ err:
 static bool_t process_ptype(const kxml_node_t *element, void *parent,
 	faux_error_t *error)
 {
-	iptype_t iptype = {};
-	kptype_t *ptype = NULL;
+	ientry_t ientry = {};
+	kentry_t *entry = NULL;
 	bool_t res = BOOL_FALSE;
 	ktags_e parent_tag = kxml_node_tag(kxml_node_parent(element));
+	kscheme_t *scheme = (kscheme_t *)parent;
+
+	// Mandatory PTYPE name
+	ientry.name = kxml_node_attr(element, "name");
+	if (!ientry.name) {
+		faux_error_sprintf(error, TAG": PTYPE without name");
+		return BOOL_FALSE;
+	}
+	ientry.help = kxml_node_attr(element, "help");
+	ientry.container = "true";
+	ientry.mode = "sequence";
+	ientry.min = "1";
+	ientry.max = "1";
+	ientry.ptype = NULL;
+	ientry.ref = NULL;
+	ientry.value = kxml_node_attr(element, "value");
+	ientry.restore = "false";
+	ientry.order = "true";
 
+	// Parent must be a KLISH tag
 	if (parent_tag != KTAG_KLISH) {
 		faux_error_sprintf(error,
 			TAG": Tag \"%s\" can't contain PTYPE tag",
 			kxml_tag_name(parent_tag));
-		return BOOL_FALSE;
+		goto err;
 	}
-
-	iptype.name = kxml_node_attr(element, "name");
-	iptype.help = kxml_node_attr(element, "help");
-
-	ptype = iptype_load(&iptype, error);
-	if (!ptype)
+	if (!scheme) {
+		faux_error_sprintf(error,
+			TAG": Broken parent object for PTYPE \"%s\"",
+			ientry.name);
 		goto err;
+	}
 
-	if (!kscheme_add_ptypes((kscheme_t *)parent, ptype)) {
+	// Create and add object
+	entry = ientry_load(&ientry, error);
+	if (!entry)
+		goto err;
+	if (!kscheme_add_entrys(scheme, entry)) {
 		faux_error_sprintf(error, TAG": Can't add PTYPE \"%s\". "
 			"Probably duplication",
-			kptype_name(ptype));
-		kptype_free(ptype);
+			kentry_name(entry));
+		kentry_free(entry);
 		goto err;
 	}
 
-	if (!process_children(element, ptype, error))
+	if (!process_children(element, entry, error))
 		goto err;
 
 	res = BOOL_TRUE;
 err:
-	kxml_node_attr_free(iptype.name);
-	kxml_node_attr_free(iptype.help);
+	kxml_node_attr_free(ientry.name);
+	kxml_node_attr_free(ientry.help);
+	kxml_node_attr_free(ientry.value);
 
 	return res;
 }
@@ -460,82 +494,82 @@ err:
 static bool_t process_param(const kxml_node_t *element, void *parent,
 	faux_error_t *error)
 {
-	iparam_t iparam = {};
-	kparam_t *param = NULL;
+	ientry_t ientry = {};
+	kentry_t *entry = NULL;
 	bool_t res = BOOL_FALSE;
 	ktags_e parent_tag = kxml_node_tag(kxml_node_parent(element));
-	ktags_e tag = kxml_node_tag(element);
-	char *mode = NULL;
-
-	iparam.name = kxml_node_attr(element, "name");
-	iparam.help = kxml_node_attr(element, "help");
-	iparam.ptype = kxml_node_attr(element, "ptype");
-	// Special case for mode
-	mode = kxml_node_attr(element, "mode");
-	if (!faux_str_is_empty(mode)) {
-		iparam.mode = mode;
-	} else {
-		switch (tag) {
-		case KTAG_SWITCH:
-			iparam.mode = "switch";
-			break;
-		case KTAG_SUBCOMMAND:
-			iparam.mode = "subcommand";
-			break;
-		case KTAG_MULTI:
-			iparam.mode = "multi";
-			break;
-		default:
-			break;
-		}
+	kentry_t *parent_entry = (kentry_t *)parent;
+	kentry_t *entry_add_to = parent_entry;
+
+	// Mandatory PARAM name
+	ientry.name = kxml_node_attr(element, "name");
+	if (!ientry.name) {
+		faux_error_sprintf(error, TAG": PARAM without name");
+		return BOOL_FALSE;
 	}
+	ientry.help = kxml_node_attr(element, "help");
+	ientry.container = kxml_node_attr(element, "container");
+	ientry.mode = kxml_node_attr(element, "mode");
+	ientry.min = kxml_node_attr(element, "min");
+	ientry.max = kxml_node_attr(element, "max");
+	ientry.ptype = kxml_node_attr(element, "ptype");
+	ientry.ref = kxml_node_attr(element, "ref");
+	ientry.value = kxml_node_attr(element, "value");
+	ientry.restore = "false";
+	ientry.order = kxml_node_attr(element, "order");
 
-	param = iparam_load(&iparam, error);
-	if (!param)
+	entry = ientry_load(&ientry, error);
+	if (!entry)
 		goto err;
 
-	if (KTAG_COMMAND == parent_tag) {
-		kcommand_t *command = (kcommand_t *)parent;
-		if (!kcommand_add_params(command, param)) {
-			faux_error_sprintf(error,
-				TAG": Can't add PARAM \"%s\" to COMMAND \"%s\". "
-				"Probably duplication",
-				kparam_name(param), kcommand_name(command));
-			kparam_free(param);
-			goto err;
-		}
-	} else if (
-		(KTAG_PARAM == parent_tag) ||
-		(KTAG_SWITCH == parent_tag) ||
-		(KTAG_SUBCOMMAND == parent_tag) ||
-		(KTAG_MULTI == parent_tag)
-		) {
-		kparam_t *parent_param = (kparam_t *)parent;
-		if (!kparam_add_params(parent_param, param)) {
-			faux_error_sprintf(error,
-				TAG": Can't add PARAM \"%s\" to PARAM \"%s\". "
-				"Probably duplication",
-				kparam_name(param), kparam_name(parent_param));
-			kparam_free(param);
-			goto err;
-		}
-	} else {
+	if ((KTAG_COMMAND != parent_tag) &&
+		(KTAG_PARAM != parent_tag) &&
+		(KTAG_ENTRY != parent_tag)) {
 		faux_error_sprintf(error,
 			TAG": Tag \"%s\" can't contain PARAM tag",
 			kxml_tag_name(parent_tag));
-		kparam_free(param);
+		kentry_free(entry);
+		goto err;
+	}
+
+	// Add newly created entry to special container in 'sequence' mode if
+	// parent entry can has 'switch' mode.
+	if (kentry_mode(parent_entry) == KENTRY_MODE_SWITCH) {
+		const char *seq_entry_name = "__sequence";
+		kentry_t *seq_entry = kentry_find_entry(parent_entry, seq_entry_name);
+		if (!seq_entry) {
+			seq_entry = kentry_new(seq_entry_name);
+			assert(seq_entry);
+			kentry_set_container(seq_entry, BOOL_TRUE);
+			kentry_set_mode(seq_entry, KENTRY_MODE_SEQUENCE);
+			kentry_add_entrys(parent_entry, seq_entry);
+		}
+		entry_add_to = seq_entry;
+	}
+	if (!kentry_add_entrys(entry_add_to, entry)) {
+		faux_error_sprintf(error,
+			TAG": Can't add PARAM \"%s\" to ENTRY \"%s\". "
+			"Probably duplication",
+			kentry_name(entry_add_to), kentry_name(entry_add_to));
+		kentry_free(entry);
 		goto err;
 	}
 
-	if (!process_children(element, param, error))
+	if (!process_children(element, entry, error))
 		goto err;
 
 	res = BOOL_TRUE;
 err:
-	kxml_node_attr_free(iparam.name);
-	kxml_node_attr_free(iparam.help);
-	kxml_node_attr_free(iparam.ptype);
-	kxml_node_attr_free(mode);
+	kxml_node_attr_free(ientry.name);
+	kxml_node_attr_free(ientry.help);
+	kxml_node_attr_free(ientry.container);
+	kxml_node_attr_free(ientry.mode);
+	kxml_node_attr_free(ientry.min);
+	kxml_node_attr_free(ientry.max);
+	kxml_node_attr_free(ientry.ptype);
+	kxml_node_attr_free(ientry.ref);
+	kxml_node_attr_free(ientry.value);
+	kxml_node_attr_free(ientry.order);
 
 	return res;
 }
@@ -544,40 +578,63 @@ err:
 static bool_t process_command(const kxml_node_t *element, void *parent,
 	faux_error_t *error)
 {
-	icommand_t icommand = {};
-	kcommand_t *command = NULL;
+	ientry_t ientry = {};
+	kentry_t *entry = NULL;
 	bool_t res = BOOL_FALSE;
 	ktags_e parent_tag = kxml_node_tag(kxml_node_parent(element));
+	kentry_t *parent_entry = (kentry_t *)parent;
 
-	if (parent_tag != KTAG_VIEW) {
-		faux_error_sprintf(error,
-			TAG": Tag \"%s\" can't contain COMMAND tag",
-			kxml_tag_name(parent_tag));
+	// Mandatory COMMAND name
+	ientry.name = kxml_node_attr(element, "name");
+	if (!ientry.name) {
+		faux_error_sprintf(error, TAG": COMMAND without name");
 		return BOOL_FALSE;
 	}
+	ientry.help = kxml_node_attr(element, "help");
+	ientry.container = "false";
+	ientry.mode = "switch";
+	ientry.min = "1";
+	ientry.max = "1";
+	ientry.ptype = kxml_node_attr(element, "ptype");
+	ientry.ref = kxml_node_attr(element, "ref");
+	ientry.value = kxml_node_attr(element, "value");
+	ientry.restore = kxml_node_attr(element, "restore");
+	ientry.order = kxml_node_attr(element, "order");
 
-	icommand.name = kxml_node_attr(element, "name");
-	icommand.help = kxml_node_attr(element, "help");
-
-	command = icommand_load(&icommand, error);
-	if (!command)
+	entry = ientry_load(&ientry, error);
+	if (!entry)
 		goto err;
 
-	if (!kview_add_commands((kview_t *)parent, command)) {
-		faux_error_sprintf(error, TAG": Can't add COMMAND \"%s\". "
+	if ((KTAG_COMMAND != parent_tag) &&
+		(KTAG_VIEW != parent_tag) &&
+		(KTAG_ENTRY != parent_tag)) {
+		faux_error_sprintf(error,
+			TAG": Tag \"%s\" can't contain COMMAND tag",
+			kxml_tag_name(parent_tag));
+		kentry_free(entry);
+		goto err;
+	}
+	if (!kentry_add_entrys(parent_entry, entry)) {
+		faux_error_sprintf(error,
+			TAG": Can't add PARAM \"%s\" to ENTRY \"%s\". "
 			"Probably duplication",
-			kcommand_name(command));
-		kcommand_free(command);
+			kentry_name(entry), kentry_name(parent_entry));
+		kentry_free(entry);
 		goto err;
 	}
 
-	if (!process_children(element, command, error))
+	if (!process_children(element, entry, error))
 		goto err;
 
 	res = BOOL_TRUE;
 err:
-	kxml_node_attr_free(icommand.name);
-	kxml_node_attr_free(icommand.help);
+	kxml_node_attr_free(ientry.name);
+	kxml_node_attr_free(ientry.help);
+	kxml_node_attr_free(ientry.ptype);
+	kxml_node_attr_free(ientry.ref);
+	kxml_node_attr_free(ientry.value);
+	kxml_node_attr_free(ientry.restore);
+	kxml_node_attr_free(ientry.order);
 
 	return res;
 }
@@ -590,6 +647,7 @@ static bool_t process_action(const kxml_node_t *element, void *parent,
 	kaction_t *action = NULL;
 	bool_t res = BOOL_FALSE;
 	ktags_e parent_tag = kxml_node_tag(kxml_node_parent(element));
+	kentry_t *parent_entry = (kentry_t *)parent;
 
 	iaction.sym = kxml_node_attr(element, "sym");
 	iaction.lock = kxml_node_attr(element, "lock");
@@ -603,46 +661,24 @@ static bool_t process_action(const kxml_node_t *element, void *parent,
 	if (!action)
 		goto err;
 
-	if (KTAG_COMMAND == parent_tag) {
-		kcommand_t *command = (kcommand_t *)parent;
-		if (!kcommand_add_actions(command, action)) {
-			faux_error_sprintf(error,
-				TAG": Can't add ACTION #%d to COMMAND \"%s\". "
-				"Probably duplication",
-				kcommand_actions_len(command) + 1,
-				kcommand_name(command));
-			kaction_free(action);
-			goto err;
-		}
-	} else if (KTAG_PTYPE == parent_tag) {
-		kptype_t *ptype = (kptype_t *)parent;
-		if (!kptype_add_actions(ptype, action)) {
-			faux_error_sprintf(error,
-				TAG": Can't add ACTION #%d to PTYPE \"%s\". "
-				"Probably duplication",
-				kptype_actions_len(ptype) + 1,
-				kptype_name(ptype));
-			kaction_free(action);
-			goto err;
-		}
-	} else if (KTAG_ENTRY == parent_tag) {
-		kentry_t *entry = (kentry_t *)parent;
-		if (!kentry_add_actions(entry, action)) {
-			faux_error_sprintf(error,
-				TAG": Can't add ACTION #%d to ENTRY \"%s\". "
-				"Probably duplication",
-				kentry_actions_len(entry) + 1,
-				kentry_name(entry));
-			kaction_free(action);
-			goto err;
-		}
-	} else {
+	if ((parent_tag != KTAG_ENTRY) &&
+		(parent_tag != KTAG_COMMAND) &&
+		(parent_tag != KTAG_PTYPE)) {
 		faux_error_sprintf(error,
 			TAG": Tag \"%s\" can't contain ACTION tag",
 			kxml_tag_name(parent_tag));
 		kaction_free(action);
 		goto err;
 	}
+	if (!kentry_add_actions(parent_entry, action)) {
+		faux_error_sprintf(error,
+			TAG": Can't add ACTION #%d to ENTRY \"%s\". "
+			"Probably duplication",
+			kentry_actions_len(parent_entry) + 1,
+			kentry_name(parent_entry));
+		kaction_free(action);
+		goto err;
+	}
 
 	if (!process_children(element, action, error))
 		goto err;
@@ -664,39 +700,68 @@ err:
 static bool_t process_nspace(const kxml_node_t *element, void *parent,
 	faux_error_t *error)
 {
-	inspace_t inspace = {};
-	knspace_t *nspace = NULL;
+	ientry_t ientry = {};
+	kentry_t *entry = NULL;
 	bool_t res = BOOL_FALSE;
 	ktags_e parent_tag = kxml_node_tag(kxml_node_parent(element));
+	kentry_t *parent_entry = (kentry_t *)parent;
 
-	if (parent_tag != KTAG_VIEW) {
-		faux_error_sprintf(error,
-			TAG": Tag \"%s\" can't contain NSPACE tag",
-			kxml_tag_name(parent_tag));
+	// Mandatory NSPACE name
+	ientry.name = kxml_node_attr(element, "name");
+	if (!ientry.name) {
+		faux_error_sprintf(error, TAG": NSPACE without name");
 		return BOOL_FALSE;
 	}
+	ientry.help = kxml_node_attr(element, "help");
+	ientry.container = kxml_node_attr(element, "container");
+	ientry.mode = kxml_node_attr(element, "mode");;
+	ientry.min = kxml_node_attr(element, "min");
+	ientry.max = kxml_node_attr(element, "max");
+	ientry.ptype = kxml_node_attr(element, "ptype");
+	ientry.ref = kxml_node_attr(element, "ref");
+	ientry.value = kxml_node_attr(element, "value");
+	ientry.restore = kxml_node_attr(element, "restore");
+	ientry.order = kxml_node_attr(element, "order");
 
-	inspace.ref = kxml_node_attr(element, "ref");
-	inspace.prefix = kxml_node_attr(element, "prefix");
-
-	nspace = inspace_load(&inspace, error);
-	if (!nspace)
+	entry = ientry_load(&ientry, error);
+	if (!entry)
 		goto err;
 
-	if (!kview_add_nspaces((kview_t *)parent, nspace)) {
-		faux_error_sprintf(error, TAG": Can't add NSPACE \"%s\". ",
-			knspace_view_ref(nspace));
-		knspace_free(nspace);
+	if ((KTAG_COMMAND != parent_tag) &&
+		(KTAG_VIEW != parent_tag) &&
+		(KTAG_PARAM != parent_tag) &&
+		(KTAG_ENTRY != parent_tag)) {
+		faux_error_sprintf(error,
+			TAG": Tag \"%s\" can't contain NSPACE tag",
+			kxml_tag_name(parent_tag));
+		kentry_free(entry);
+		goto err;
+	}
+	if (!kentry_add_entrys(parent_entry, entry)) {
+		faux_error_sprintf(error,
+			TAG": Can't add NSPACE \"%s\" to ENTRY \"%s\". "
+			"Probably duplication",
+			kentry_name(entry), kentry_name(parent_entry));
+		kentry_free(entry);
 		goto err;
 	}
 
-	if (!process_children(element, nspace, error))
+	if (!process_children(element, entry, error))
 		goto err;
 
 	res = BOOL_TRUE;
 err:
-	kxml_node_attr_free(inspace.ref);
-	kxml_node_attr_free(inspace.prefix);
+	kxml_node_attr_free(ientry.name);
+	kxml_node_attr_free(ientry.help);
+	kxml_node_attr_free(ientry.container);
+	kxml_node_attr_free(ientry.mode);
+	kxml_node_attr_free(ientry.min);
+	kxml_node_attr_free(ientry.max);
+	kxml_node_attr_free(ientry.ptype);
+	kxml_node_attr_free(ientry.ref);
+	kxml_node_attr_free(ientry.value);
+	kxml_node_attr_free(ientry.restore);
+	kxml_node_attr_free(ientry.order);
 
 	return res;
 }