[jhalfs] 01/02: Process <prompt> tags in mit-kerberos

"Git Owner" ([email protected] via alfs-discuss Mailing List) <[email protected]>
Newsgroups gmane.linux.lfs.automated
Message-ID <[email protected]>
This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch ablfs-more
in repository jhalfs.

commit a6c57debccce241cc455431cf5220054581d3c3d
Author: Pierre Labastie <[email protected]>
AuthorDate: Sat Sep 16 21:58:47 2023 +0200

    Process <prompt> tags in mit-kerberos
    
    when we have a command followed by prompts:
    command
    <prompt>command:</prompt> instr
    ...
    we want to transform to:
    command << PROMPT_EOF
    instr
    ...
    quit
    PROMPT_EOF.
    This patch implements this. The problem is that the <prompt>
    tags may occur in several consecutive <screen> ones. So we create
    a  fragment tree and process it recursively.
---
 BLFS/xsl/process-prompt.xsl | 99 +++++++++++++++++++++++++++++++++++++++++++++
 BLFS/xsl/scripts.xsl        | 20 ++++++++-
 2 files changed, 117 insertions(+), 2 deletions(-)

diff --git a/BLFS/xsl/process-prompt.xsl b/BLFS/xsl/process-prompt.xsl
new file mode 100644
index 0000000..8f3457c
--- /dev/null
+++ b/BLFS/xsl/process-prompt.xsl
@@ -0,0 +1,99 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+    version="1.0">
+
+  <xsl:template name="process-prompt">
+    <xsl:param name="instructions"/>
+    <xsl:param name="root-seen"/>
+    <xsl:param name="prompt-seen"/>
+
+<!-- Isolate the current instruction -->
+    <xsl:variable name="current-instr" select="$instructions[1]"/>
+
+    <xsl:choose>
+<!--============================================================-->
+<!-- First, if we have an empty tree, close everything and exit -->
+      <xsl:when test="not($current-instr)">
+        <xsl:if test="$prompt-seen">
+          <xsl:call-template name="end-prompt"/>
+        </xsl:if>
+        <xsl:if test="$root-seen">
+          <xsl:call-template name="end-root"/>
+        </xsl:if>
+      </xsl:when><!-- end empty tree -->
+<!--============================================================-->
+      <xsl:when test="$current-instr[@role='root']">
+        <xsl:choose>
+          <xsl:when test="$current-instr//prompt">
+            <xsl:if test="not($root-seen)">
+              <xsl:call-template name="begin-root"/>
+            </xsl:if>
+            <xsl:text>&#xA;</xsl:text>
+            <xsl:if test="not($prompt-seen)">
+              <xsl:copy-of
+                select="substring-before($current-instr//text()[1],'&#xA;')"/>
+              <xsl:text> &lt;&lt; PROMPT_EOF
+</xsl:text>
+            </xsl:if>
+            <xsl:apply-templates
+              select="$current-instr/userinput/node()[position()>1]"/>
+            <xsl:call-template name="process-prompt">
+              <xsl:with-param
+                 name="instructions"
+                 select="$instructions[position()>1]"/>
+              <xsl:with-param name="root-seen" select="boolean(1)"/>
+              <xsl:with-param name="prompt-seen" select="boolean(1)"/>
+            </xsl:call-template>
+          </xsl:when><!-- end prompt as root -->
+<!--____________________________________________________________ -->
+          <xsl:otherwise><!-- we have no prompt -->
+            <xsl:if test="$prompt-seen">
+              <xsl:text>
+quit
+PROMPT_EOF</xsl:text>
+            </xsl:if>
+            <xsl:apply-templates
+              select="$current-instr"
+              mode="config"/>
+            <!-- the above will call "end-root" if the next screen
+                 sibling is not role="root". We need to pass root-seen=false
+                 in this case. Otherwise, we need to pass root-seen=true.
+                 So create a variable -->
+            <xsl:variable name="rs"
+              select="$instructions[2][@role='root']"/>
+            <xsl:call-template name="process-prompt">
+              <xsl:with-param
+                 name="instructions"
+                 select="$instructions[position()>1]"/>
+              <xsl:with-param name="root-seen" select="boolean($rs)"/>
+              <xsl:with-param name="prompt-seen" select="boolean(0)"/>
+            </xsl:call-template>
+          </xsl:otherwise><!-- end no prompt -->
+<!--____________________________________________________________ -->
+        </xsl:choose>
+      </xsl:when><!-- role="root" -->
+<!--============================================================-->
+      <xsl:otherwise><!-- no role -->
+        <xsl:if test="$prompt-seen">
+          <xsl:text>
+quit
+PROMPT_EOF</xsl:text>
+        </xsl:if>
+        <xsl:if test="$root-seen">
+          <xsl:call-template name="end-root"/>
+        </xsl:if>
+        <xsl:apply-templates select="$current-instr/userinput"/>
+        <xsl:call-template name="process-prompt">
+          <xsl:with-param
+             name="instructions"
+             select="$instructions[position()>1]"/>
+          <xsl:with-param name="root-seen" select="boolean(0)"/>
+          <xsl:with-param name="prompt-seen" select="boolean(0)"/>
+        </xsl:call-template>
+      </xsl:otherwise><!-- no role -->
+<!--============================================================-->
+    </xsl:choose>
+  </xsl:template>
+
+  <xsl:template match="prompt"/>
+</xsl:stylesheet>
diff --git a/BLFS/xsl/scripts.xsl b/BLFS/xsl/scripts.xsl
index 78f61ad..01ff31c 100644
--- a/BLFS/xsl/scripts.xsl
+++ b/BLFS/xsl/scripts.xsl
@@ -80,6 +80,9 @@ done</xsl:variable>
 <!-- include the template for replaceable tags -->
   <xsl:include href="process-replaceable.xsl"/>
 
+<!-- include the template for prompt tags -->
+  <xsl:include href="process-prompt.xsl"/>
+
 <!--=================== Begin processing ========================-->
 
   <xsl:template match="/">
@@ -385,8 +388,21 @@ echo Start Time: ${SECONDS} >> $INFOLOG
 
       <xsl:when test="@role = 'configuration'">
         <xsl:text>&#xA;</xsl:text>
-        <xsl:apply-templates mode="config"
-             select=".//screen[not(@role = 'nodump') and ./userinput]"/>
+        <xsl:choose>
+          <xsl:when test=".//screen/userinput/prompt">
+            <xsl:call-template name="process-prompt">
+              <xsl:with-param
+                name="instructions"
+                select=".//screen[not(@role = 'nodump') and ./userinput]"/>
+              <xsl:with-param name="root-seen" select="false"/>
+              <xsl:with-param name="prompt-seen" select="false"/>
+            </xsl:call-template>
+          </xsl:when>
+          <xsl:otherwise>
+            <xsl:apply-templates mode="config"
+                 select=".//screen[not(@role = 'nodump') and ./userinput]"/>
+          </xsl:otherwise>
+        </xsl:choose>
       </xsl:when><!-- @role="configuration" -->
 
     </xsl:choose>

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

-- 
http://lists.linuxfromscratch.org/sympa/info/alfs-discuss
Unsubscribe: See the above information page
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.