Browse Source

kcontext_udata()

Serj Kalichev 1 year ago
parent
commit
cc5ca625bc
2 changed files with 17 additions and 0 deletions
  1. 1 0
      klish/kcontext.h
  2. 16 0
      klish/ksession/kcontext.c

+ 1 - 0
klish/kcontext.h

@@ -70,6 +70,7 @@ const char *kcontext_script(const kcontext_t *context);
 bool_t kcontext_named_udata_new(kcontext_t *context,
 	const char *name, void *data, kudata_data_free_fn free_fn);
 void *kcontext_named_udata(const kcontext_t *context, const char *name);
+void *kcontext_udata(const kcontext_t *context);
 const kentry_t *kcontext_command(const kcontext_t *context);
 
 

+ 16 - 0
klish/ksession/kcontext.c

@@ -223,6 +223,22 @@ void *kcontext_named_udata(const kcontext_t *context, const char *name)
 }
 
 
+void *kcontext_udata(const kcontext_t *context)
+{
+	kplugin_t *plugin = NULL;
+
+	assert(context);
+	if (!context)
+		return NULL;
+
+	plugin = kcontext_plugin(context);
+	if (!plugin)
+		return NULL;
+
+	return kplugin_udata(plugin);
+}
+
+
 const kentry_t *kcontext_command(const kcontext_t *context)
 {
 	assert(context);