Browse Source

scheme: Fill iaction_t structure

Serj Kalichev 3 years ago
parent
commit
43ed0fbb19
6 changed files with 20 additions and 32 deletions
  1. 11 28
      klish.xsd
  2. 3 3
      klish/kaction.h
  3. 2 0
      klish/kcommand.h
  4. 3 0
      klish/kptype.h
  5. 1 0
      klish/kscheme.h
  6. 0 1
      klish/kscheme/kaction.c

+ 11 - 28
klish.xsd

@@ -370,38 +370,22 @@
 * <ACTION> specifies the action to be taken for
 * a command.
 *
-* The textual contents of the tag are variable expanded
-* (environment, dynamic and parameter) the the resulting
-* text is interpreted by the client's script interpreter.
-*
-* In addition the optional 'builtin' attribute can specify
+* In addition the optional 'sym' attribute can specify
 * the name of an internal command which will be invoked
-* instead of the client's script handler.
-*
-* NB. for security reasons any special shell characters 
-* (e.g. $|<>`) are escaped before evaluation.
+* to handle script.
 *
-* [builtin] - specify the name of an internally registered
+* [sym="<symbol>"] - specify the name of an internally registered
 *	function. The content of the ACTION tag is
 *	taken as the arguments to this builtin function.
 *
-* [shebang] - specify the programm to execute the action
-*	script.
-*
-* [lock="true/false"] - the boolean field that specify to lock lockfile while
-*	action execution or not. Default is true. In a case the
-*	LEGACY macro is specified while klish building the
-*	value of this field is inherited from COMMAND tag (if
-*	lock is not specified in ACTION).
+* [lock="<name>"] - Named lock. It will use special lockfile while
+*	action execution.
 *
-* [interrupt="true/false"] - the boolean field that specify that action can be
-*	be interrupted by Ctrl^C. Default is false. In a case the
-*	LEGACY macro is specified while klish building the
-*	value of this field is inherited from COMMAND tag (if
-*	attr is not specified in ACTION).
+* [interrupt="true/false"] - The boolean field that specify that action can be
+*	be interrupted by Ctrl^C. Default is false. Ignored for non-interactive
+*	actions.
 *
-* [interactive="true/false"] - specify is action interactive. The
-*	interactive ACTIONs can't be used with piped ("|") output.
+* [interactive="true/false"] - Is action interactive.
 *
 * [exec_on="fail/success/always"] - ACTION's execution depends on
 *	return code of previous elements of ACTION chain. If the
@@ -426,9 +410,8 @@
 	<xs:complexType name="action_t">
 		<xs:simpleContent>
 			<xs:extension base="xs:string">
-				<xs:attribute name="builtin" type="xs:string" use="optional"/>
-				<xs:attribute name="shebang" type="xs:string" use="optional"/>
-				<xs:attribute name="lock" type="xs:boolean" use="optional" default="true"/>
+				<xs:attribute name="sym" type="xs:string" use="optional"/>
+				<xs:attribute name="lock" type="xs:string" use="optional"/>
 				<xs:attribute name="interrupt" type="xs:boolean" use="optional" default="false"/>
 				<xs:attribute name="interactive" type="xs:boolean" use="optional" default="false"/>
 				<xs:attribute name="exec_on" type="action_cond_t" use="optional" default="success"/>

+ 3 - 3
klish/kaction.h

@@ -6,12 +6,14 @@
 #ifndef _klish_kaction_h
 #define _klish_kaction_h
 
-#include <klish/kcommand.h>
 
 typedef struct kaction_s kaction_t;
 
 typedef struct iaction_s {
 	char *sym;
+	char *lock;
+	char *interrupt;
+	char *interactive;
 	char *exec_on;
 	char *update_retcode;
 } iaction_t;
@@ -38,8 +40,6 @@ void kaction_free(kaction_t *action);
 
 const char *kaction_name(const kaction_t *action);
 
-bool_t kaction_add_command(kaction_t *action, kcommand_t *command);
-
 C_DECL_END
 
 #endif // _klish_kaction_h

+ 2 - 0
klish/kcommand.h

@@ -7,6 +7,7 @@
 #define _klish_kcommand_h
 
 #include <klish/kparam.h>
+#include <klish/kaction.h>
 
 typedef struct kcommand_s kcommand_t;
 
@@ -14,6 +15,7 @@ typedef struct icommand_s {
 	char *name;
 	char *help;
 	iparam_t * (*params)[];
+	iaction_t * (*actions)[];
 } icommand_t;
 
 C_DECL_BEGIN

+ 3 - 0
klish/kptype.h

@@ -6,11 +6,14 @@
 #ifndef _klish_kptype_h
 #define _klish_kptype_h
 
+#include <klish/kaction.h>
+
 typedef struct kptype_s kptype_t;
 
 typedef struct iptype_s {
 	char *name;
 	char *help;
+	iaction_t * (*actions)[];
 } iptype_t;
 
 

+ 1 - 0
klish/kscheme.h

@@ -17,6 +17,7 @@ typedef struct kscheme_s kscheme_t;
 
 typedef struct ischeme_s {
 	char *name;
+	iptype_t * (*ptypes)[];
 	iview_t * (*views)[];
 } ischeme_t;
 

+ 0 - 1
klish/kscheme/kaction.c

@@ -5,7 +5,6 @@
 
 #include <faux/str.h>
 #include <faux/list.h>
-#include <klish/kcommand.h>
 #include <klish/kaction.h>