Bladeren bron

interrupt and lock in ACTION. Unfinished

Serj Kalichev 6 jaren geleden
bovenliggende
commit
56a07f7711
10 gewijzigde bestanden met toevoegingen van 71 en 16 verwijderingen
  1. 5 1
      Makefile.am
  2. 30 4
      clish.xsd
  3. 6 0
      clish/action.h
  4. 6 0
      clish/action/action.c
  5. 3 3
      clish/action/private.h
  6. 4 2
      clish/command.h
  7. 4 2
      clish/command/command.c
  8. 2 3
      clish/command/private.h
  9. 1 1
      clish/module.am
  10. 10 0
      configure.ac

+ 5 - 1
Makefile.am

@@ -11,7 +11,11 @@ if DEBUG
   DEBUG_CFLAGS = -DDEBUG
 endif
 
-AM_CFLAGS = -Wall $(DEBUG_CFLAGS)
+if LEGACY
+  LEGACY_CFLAGS = -DLEGACY
+endif
+
+AM_CFLAGS = -Wall $(DEBUG_CFLAGS) $(LEGACY_CFLAGS)
 #AM_CFLAGS = -ansi -pedantic -Werror -Wall -D_POSIX_C_SOURCE=199309 -DVERSION=$(VERSION) $(DEBUG_CFLAGS)
 
 bin_PROGRAMS =

+ 30 - 4
clish.xsd

@@ -263,8 +263,15 @@
 *	parameter. If the "args" attribute is given then this MUST be
 *	given also.
 *
-* [lock] - the boolean field that specify to lock lockfile while
-*	command execution or not. Default is true.
+* [lock] - !legacy! the boolean field that specify to lock lockfile while
+*	command execution or not. Default is true. Will be used in a case
+*	when klish was built with LEGACY macro. The attribute is moved
+	to ACTION tag.
+*
+* [interrupt] - !legacy! the boolean field that specify that action can be
+*	be interrupted by Ctrl^C. Will be used in a case
+*	when klish was built with LEGACY macro. The attribute is moved
+*	to ACTION tag.
 *
 ********************************************************
 -->
@@ -283,8 +290,8 @@
 		<xs:attribute name="args" type="xs:string" use="optional"/>
 		<xs:attribute name="args_help" type="xs:string" use="optional"/>
 		<xs:attribute name="escape_chars" type="xs:string" use="optional"/>
-		<xs:attribute name="lock" type="bool_t" use="optional" default="true"/>
-		<xs:attribute name="interrupt" type="bool_t" use="optional" default="false"/>
+<!-- legacy -->	<xs:attribute name="lock" type="bool_t" use="optional" default="true"/>
+<!-- legacy -->	<xs:attribute name="interrupt" type="bool_t" use="optional" default="false"/>
 	</xs:complexType>
 
 <!--
@@ -388,6 +395,22 @@
 *
 * [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).
+*
+* [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).
+*
+* [interactive="true/false"] - specify is action interactive. The
+*	interactive ACTIONs can't be used with piped ("|") output.
+*
 ********************************************************
 -->
 	<xs:complexType name="action_t">
@@ -395,6 +418,9 @@
 			<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="bool_t" use="optional" default="true"/>
+				<xs:attribute name="interrupt" type="bool_t" use="optional" default="false"/>
+				<xs:attribute name="interactive" type="bool_t" use="optional" default="false"/>
 			</xs:extension>
 		</xs:simpleContent>
 	</xs:complexType>

+ 6 - 0
clish/action.h

@@ -21,5 +21,11 @@ _CLISH_SET(action, const clish_sym_t *, builtin);
 _CLISH_GET(action, const clish_sym_t *, builtin);
 _CLISH_SET_STR(action, shebang);
 _CLISH_GET_STR(action, shebang);
+_CLISH_SET(action, bool_t, lock);
+_CLISH_GET(action, bool_t, lock);
+_CLISH_SET(action, bool_t, interrupt);
+_CLISH_GET(action, bool_t, interrupt);
+_CLISH_SET(action, bool_t, interactive);
+_CLISH_GET(action, bool_t, interactive);
 
 #endif // _clish_action_h

+ 6 - 0
clish/action/action.c

@@ -50,6 +50,12 @@ CLISH_SET_STR(action, script);
 CLISH_GET_STR(action, script);
 CLISH_SET(action, const clish_sym_t *, builtin);
 CLISH_GET(action, const clish_sym_t *, builtin);
+CLISH_SET(action, bool_t, lock);
+CLISH_GET(action, bool_t, lock);
+CLISH_SET(action, bool_t, interrupt);
+CLISH_GET(action, bool_t, interrupt);
+CLISH_SET(action, bool_t, interactive);
+CLISH_GET(action, bool_t, interactive);
 
 _CLISH_SET_STR(action, shebang)
 {

+ 3 - 3
clish/action/private.h

@@ -4,11 +4,11 @@
 
 #include "clish/action.h"
 
-/*---------------------------------------------------------
- * PRIVATE TYPES
- *--------------------------------------------------------- */
 struct clish_action_s {
 	char *script;
 	const clish_sym_t *builtin;
 	char *shebang;
+	bool_t lock;
+	bool_t interrupt;
+	bool_t interactive;
 };

+ 4 - 2
clish/command.h

@@ -61,14 +61,16 @@ _CLISH_SET_STR(command, alias);
 _CLISH_GET_STR(command, alias);
 _CLISH_SET_STR(command, alias_view);
 _CLISH_GET_STR(command, alias_view);
-_CLISH_SET(command, bool_t, interrupt);
-_CLISH_GET(command, bool_t, interrupt);
 _CLISH_SET(command, bool_t, internal);
 _CLISH_GET(command, bool_t, internal);
 _CLISH_SET(command, bool_t, dynamic);
 _CLISH_GET(command, bool_t, dynamic);
+#ifdef LEGACY
 _CLISH_SET(command, bool_t, lock);
 _CLISH_GET(command, bool_t, lock);
+_CLISH_SET(command, bool_t, interrupt);
+_CLISH_GET(command, bool_t, interrupt);
+#endif
 
 const char *clish_command__get_suffix(const clish_command_t * instance);
 unsigned int clish_command__get_param_count(const clish_command_t * instance);

+ 4 - 2
clish/command/command.c

@@ -232,14 +232,16 @@ CLISH_SET_STR(command, alias);
 CLISH_GET_STR(command, alias);
 CLISH_SET_STR(command, alias_view);
 CLISH_GET_STR(command, alias_view);
-CLISH_SET(command, bool_t, interrupt);
-CLISH_GET(command, bool_t, interrupt);
 CLISH_SET(command, bool_t, internal);
 CLISH_GET(command, bool_t, internal);
 CLISH_SET(command, bool_t, dynamic);
 CLISH_GET(command, bool_t, dynamic);
+#ifdef LEGACY
 CLISH_SET(command, bool_t, lock);
 CLISH_GET(command, bool_t, lock);
+CLISH_SET(command, bool_t, interrupt);
+CLISH_GET(command, bool_t, interrupt);
+#endif
 
 /*--------------------------------------------------------- */
 void clish_command__force_viewname(clish_command_t * this, const char *viewname)

+ 2 - 3
clish/command/private.h

@@ -4,9 +4,6 @@
 
 #include "clish/command.h"
 
-/*---------------------------------------------------------
- * PRIVATE TYPES
- *--------------------------------------------------------- */
 struct clish_command_s {
 	lub_bintree_node_t bt_node;
 	char *name;
@@ -25,8 +22,10 @@ struct clish_command_s {
 	char *alias_view;
 	char *alias;
 	clish_view_t *pview;
+#ifdef LEGACY
 	bool_t lock;
 	bool_t interrupt;
+#endif
 	bool_t dynamic; /* Is command dynamically created */
 	bool_t internal; /* Is command internal? Like the "startup" */
 };

+ 1 - 1
clish/module.am

@@ -6,7 +6,7 @@ libclish_la_SOURCES = \
 	clish/private.h
 
 libclish_la_LDFLAGS = $(VERSION_INFO) @XML_LDFLAGS@
-libclish_la_CFLAGS = @XML_CFLAGS@ $(DEBUG_CFLAGS)
+libclish_la_CFLAGS = @XML_CFLAGS@ $(DEBUG_CFLAGS) $(LEGACY_CFLAGS)
 libclish_la_DEPENDENCIES = \
 	liblub.la \
 	libtinyrl.la \

+ 10 - 0
configure.ac

@@ -77,6 +77,16 @@ AC_ARG_ENABLE(debug,
               [enable_debug=no])
 AM_CONDITIONAL(DEBUG,test x$enable_debug = xyes)
 
+################################
+# Deal with legacy klish-2 features
+################################
+AC_ARG_ENABLE(legacy,
+              [AS_HELP_STRING([--enable-legacy],
+                              [Turn on legacy klish-2 features [default=no]])],
+              [],
+              [enable_debug=no])
+AM_CONDITIONAL(LEGACY,test x$enable_legacy = xyes)
+
 ################################
 # Check for Lua support
 ################################