Browse Source

ptype: Arbitrary string PTYPE

Serj Kalichev 1 year ago
parent
commit
6a4ccd04d0
3 changed files with 17 additions and 4 deletions
  1. 2 0
      plugins/klish/plugin_init.c
  2. 1 0
      plugins/klish/private.h
  3. 14 4
      plugins/klish/ptypes.c

+ 2 - 0
plugins/klish/plugin_init.c

@@ -47,6 +47,8 @@ int kplugin_klish_init(kcontext_t *context)
 		KSYM_USERDEFINED_PERMANENT, KSYM_SYNC));
 	kplugin_add_syms(plugin, ksym_new_ext("UINT", klish_ptype_UINT,
 		KSYM_USERDEFINED_PERMANENT, KSYM_SYNC));
+	kplugin_add_syms(plugin, ksym_new_ext("STRING", klish_ptype_STRING,
+		KSYM_USERDEFINED_PERMANENT, KSYM_SYNC));
 
 	return 0;
 }

+ 1 - 0
plugins/klish/private.h

@@ -23,6 +23,7 @@ int klish_ptype_COMMAND(kcontext_t *context);
 int klish_ptype_COMMAND_CASE(kcontext_t *context);
 int klish_ptype_INT(kcontext_t *context);
 int klish_ptype_UINT(kcontext_t *context);
+int klish_ptype_STRING(kcontext_t *context);
 
 
 C_DECL_END

+ 14 - 4
plugins/klish/ptypes.c

@@ -18,7 +18,6 @@
 
 
 /** @brief PTYPE: Consider ENTRY's name (or "value" field) as a command
- *
  */
 int klish_ptype_COMMAND(kcontext_t *context)
 {
@@ -40,7 +39,6 @@ int klish_ptype_COMMAND(kcontext_t *context)
 
 
 /** @brief PTYPE: ENTRY's name (or "value" field) as a case sensitive command
- *
  */
 int klish_ptype_COMMAND_CASE(kcontext_t *context)
 {
@@ -61,7 +59,7 @@ int klish_ptype_COMMAND_CASE(kcontext_t *context)
 }
 
 
-/** @brief Signed int with optional range
+/** @brief PTYPE: Signed int with optional range
  *
  * Use long long int for conversion from text.
  *
@@ -113,7 +111,7 @@ int klish_ptype_INT(kcontext_t *context)
 }
 
 
-/** @brief Unsigned int with optional range
+/** @brief PTYPE: Unsigned int with optional range
  *
  * Use unsigned long long int for conversion from text.
  *
@@ -163,3 +161,15 @@ int klish_ptype_UINT(kcontext_t *context)
 
 	return 0;
 }
+
+
+/** @brief PTYPE: Arbitrary string
+ */
+int klish_ptype_STRING(kcontext_t *context)
+{
+	// Really any string is a ... (surprise!) string
+
+	context = context; // Happy compiler
+
+	return 0;
+}