|
@@ -8,11 +8,13 @@
|
|
|
#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;
|
|
|
};
|
|
|
|
|
|
|
|
@@ -31,6 +33,13 @@ KNESTED_LEN(view, command);
|
|
|
KNESTED_ITER(view, command);
|
|
|
KNESTED_EACH(view, command);
|
|
|
|
|
|
+// NSPACE list
|
|
|
+KGET(view, faux_list_t *, nspaces);
|
|
|
+KADD_NESTED(view, nspace);
|
|
|
+KNESTED_LEN(view, nspace);
|
|
|
+KNESTED_ITER(view, nspace);
|
|
|
+KNESTED_EACH(view, nspace);
|
|
|
+
|
|
|
|
|
|
kview_t *kview_new(const char *name)
|
|
|
{
|
|
@@ -47,11 +56,20 @@ kview_t *kview_new(const char *name)
|
|
|
// 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;
|
|
|
}
|
|
|
|
|
@@ -63,6 +81,7 @@ void kview_free(kview_t *view)
|
|
|
|
|
|
faux_str_free(view->name);
|
|
|
faux_list_free(view->commands);
|
|
|
+ faux_list_free(view->nspaces);
|
|
|
|
|
|
faux_free(view);
|
|
|
}
|