<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Command Line Interpreter (xwsh) on XWOS</title>
    <link>/en/Docs/TechRefManual/Xwsh/</link>
    <description>Recent content in Command Line Interpreter (xwsh) on XWOS</description>
    <generator>Hugo</generator>
    <language>en</language>
    <atom:link href="/en/Docs/TechRefManual/Xwsh/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Core</title>
      <link>/en/Docs/TechRefManual/Xwsh/Core/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>/en/Docs/TechRefManual/Xwsh/Core/</guid>
      <description>&lt;h2 id=&#34;command-parsing-algorithm&#34;&gt;Command Parsing Algorithm&lt;/h2&gt;&#xA;&lt;p&gt;XWSH uses the &lt;code&gt;xwsh_split_cmdline()&lt;/code&gt; function (&lt;code&gt;xwmd/cli/xwsh/core.c:126&lt;/code&gt;) to split a command line string into an argument array. The algorithm employs a &lt;strong&gt;single-pass&lt;/strong&gt; strategy, modifying the input string in place to avoid additional memory allocation.&lt;/p&gt;&#xA;&lt;h3 id=&#34;algorithm-principle&#34;&gt;Algorithm Principle&lt;/h3&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-c&#34; data-lang=&#34;c&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#0b0;font-weight:bold&#34;&gt;xwer_t&lt;/span&gt; &lt;span style=&#34;color:#00a000&#34;&gt;xwsh_split_cmdline&lt;/span&gt;(&lt;span style=&#34;color:#0b0;font-weight:bold&#34;&gt;char&lt;/span&gt; &lt;span style=&#34;color:#666&#34;&gt;*&lt;/span&gt; line, &lt;span style=&#34;color:#0b0;font-weight:bold&#34;&gt;xwsz_t&lt;/span&gt; &lt;span style=&#34;color:#666&#34;&gt;*&lt;/span&gt; argc, &lt;span style=&#34;color:#0b0;font-weight:bold&#34;&gt;char&lt;/span&gt; &lt;span style=&#34;color:#666&#34;&gt;*&lt;/span&gt; argv[], &lt;span style=&#34;color:#0b0;font-weight:bold&#34;&gt;xwsz_t&lt;/span&gt; argvsize)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;{&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#0b0;font-weight:bold&#34;&gt;char&lt;/span&gt; &lt;span style=&#34;color:#666&#34;&gt;*&lt;/span&gt; p &lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt; line;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#0b0;font-weight:bold&#34;&gt;xwsz_t&lt;/span&gt; count &lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#666&#34;&gt;0&lt;/span&gt;;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#0b0;font-weight:bold&#34;&gt;char&lt;/span&gt; &lt;span style=&#34;color:#666&#34;&gt;*&lt;/span&gt; start &lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#a2f&#34;&gt;NULL&lt;/span&gt;;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#0b0;font-weight:bold&#34;&gt;xwer_t&lt;/span&gt; rc &lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt; XWOK;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#a2f;font-weight:bold&#34;&gt;while&lt;/span&gt; (&lt;span style=&#34;color:#666&#34;&gt;*&lt;/span&gt;p) {&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                &lt;span style=&#34;color:#a2f;font-weight:bold&#34;&gt;if&lt;/span&gt; ((&lt;span style=&#34;color:#a2f&#34;&gt;NULL&lt;/span&gt; &lt;span style=&#34;color:#666&#34;&gt;==&lt;/span&gt; start) &lt;span style=&#34;color:#666&#34;&gt;&amp;amp;&amp;amp;&lt;/span&gt; (&lt;span style=&#34;color:#b44&#34;&gt;&amp;#39; &amp;#39;&lt;/span&gt; &lt;span style=&#34;color:#666&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#666&#34;&gt;*&lt;/span&gt;p)) {&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                        p&lt;span style=&#34;color:#666&#34;&gt;++&lt;/span&gt;;  &lt;span style=&#34;color:#080;font-style:italic&#34;&gt;// Skip leading spaces&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#080;font-style:italic&#34;&gt;&lt;/span&gt;                } &lt;span style=&#34;color:#a2f;font-weight:bold&#34;&gt;else&lt;/span&gt; {&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                        &lt;span style=&#34;color:#a2f;font-weight:bold&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#a2f&#34;&gt;NULL&lt;/span&gt; &lt;span style=&#34;color:#666&#34;&gt;==&lt;/span&gt; start) {&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                                start &lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt; p;  &lt;span style=&#34;color:#080;font-style:italic&#34;&gt;// Record argument start position&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#080;font-style:italic&#34;&gt;&lt;/span&gt;                        }&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                        &lt;span style=&#34;color:#a2f;font-weight:bold&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#666&#34;&gt;*&lt;/span&gt;p &lt;span style=&#34;color:#666&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#b44&#34;&gt;&amp;#39; &amp;#39;&lt;/span&gt;) {&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                                &lt;span style=&#34;color:#a2f;font-weight:bold&#34;&gt;if&lt;/span&gt; (count &lt;span style=&#34;color:#666&#34;&gt;&amp;lt;&lt;/span&gt; argvsize) {&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                                        &lt;span style=&#34;color:#666&#34;&gt;*&lt;/span&gt;p &lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#b44&#34;&gt;&amp;#39;\0&amp;#39;&lt;/span&gt;;           &lt;span style=&#34;color:#080;font-style:italic&#34;&gt;// Terminate current argument&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#080;font-style:italic&#34;&gt;&lt;/span&gt;                                        argv[count] &lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt; start; &lt;span style=&#34;color:#080;font-style:italic&#34;&gt;// Save argument pointer&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#080;font-style:italic&#34;&gt;&lt;/span&gt;                                        count&lt;span style=&#34;color:#666&#34;&gt;++&lt;/span&gt;;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                                } &lt;span style=&#34;color:#a2f;font-weight:bold&#34;&gt;else&lt;/span&gt; {&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                                        rc &lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#666&#34;&gt;-&lt;/span&gt;E2BIG;        &lt;span style=&#34;color:#080;font-style:italic&#34;&gt;// Too many arguments error&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#080;font-style:italic&#34;&gt;&lt;/span&gt;                                        &lt;span style=&#34;color:#a2f;font-weight:bold&#34;&gt;break&lt;/span&gt;;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                                }&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                                start &lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#a2f&#34;&gt;NULL&lt;/span&gt;;               &lt;span style=&#34;color:#080;font-style:italic&#34;&gt;// Reset start position&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#080;font-style:italic&#34;&gt;&lt;/span&gt;                        }&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                        p&lt;span style=&#34;color:#666&#34;&gt;++&lt;/span&gt;;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                }&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        }&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#080;font-style:italic&#34;&gt;// ... Handle the last argument&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#080;font-style:italic&#34;&gt;&lt;/span&gt;}&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&#34;algorithm-characteristics&#34;&gt;Algorithm Characteristics&lt;/h3&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;strong&gt;Time complexity O(n)&lt;/strong&gt;: Only traverses the string once&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;In-place modification&lt;/strong&gt;: Replaces spaces with &lt;code&gt;\0&lt;/code&gt;, does not copy the string&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Argument pointer array&lt;/strong&gt;: The &lt;code&gt;argv&lt;/code&gt; array stores pointers to parts of the original string&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Error detection&lt;/strong&gt;:&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Returns &lt;code&gt;-E2BIG&lt;/code&gt; when argument count exceeds &lt;code&gt;argvsize&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Maximum argument count: &lt;code&gt;XWSH_MAX_PARAM_NUM&lt;/code&gt; (16)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;h3 id=&#34;argument-format-limitations&#34;&gt;Argument Format Limitations&lt;/h3&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;No quote support&lt;/strong&gt;: Cannot handle arguments with spaces (e.g. &lt;code&gt;&amp;quot;file name&amp;quot;&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Simple splitting&lt;/strong&gt;: Splits only by spaces; consecutive spaces are treated as a single delimiter&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Trailing spaces&lt;/strong&gt;: Automatically ignores trailing spaces at the end of the command&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;thread-model&#34;&gt;Thread Model&lt;/h2&gt;&#xA;&lt;p&gt;XWSH provides two thread running modes to suit different application scenarios.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Command System</title>
      <link>/en/Docs/TechRefManual/Xwsh/Command/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>/en/Docs/TechRefManual/Xwsh/Command/</guid>
      <description>&lt;h2 id=&#34;command-structure&#34;&gt;Command Structure&lt;/h2&gt;&#xA;&lt;p&gt;All XWSH commands are defined using the &lt;code&gt;struct xwsh_cmd&lt;/code&gt; structure (&lt;code&gt;xwmd/cli/xwsh/mi.h:21&lt;/code&gt;):&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-c&#34; data-lang=&#34;c&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#a2f;font-weight:bold&#34;&gt;struct&lt;/span&gt; xwsh_cmd {&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#0b0;font-weight:bold&#34;&gt;char&lt;/span&gt; &lt;span style=&#34;color:#666&#34;&gt;*&lt;/span&gt; name;                               &lt;span style=&#34;color:#080;font-style:italic&#34;&gt;/**&amp;lt; Command name */&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#0b0;font-weight:bold&#34;&gt;xwer_t&lt;/span&gt; (&lt;span style=&#34;color:#666&#34;&gt;*&lt;/span&gt;func)(&lt;span style=&#34;color:#0b0;font-weight:bold&#34;&gt;xwsz_t&lt;/span&gt; argc, &lt;span style=&#34;color:#0b0;font-weight:bold&#34;&gt;char&lt;/span&gt; &lt;span style=&#34;color:#666&#34;&gt;**&lt;/span&gt; argv); &lt;span style=&#34;color:#080;font-style:italic&#34;&gt;/**&amp;lt; Command function */&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#0b0;font-weight:bold&#34;&gt;char&lt;/span&gt; &lt;span style=&#34;color:#666&#34;&gt;*&lt;/span&gt; desc;                               &lt;span style=&#34;color:#080;font-style:italic&#34;&gt;/**&amp;lt; Command description */&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;};&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&#34;field-descriptions&#34;&gt;Field Descriptions&lt;/h3&gt;&#xA;&lt;table&gt;&#xA;  &lt;thead&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;th style=&#34;text-align: left&#34;&gt;Field&lt;/th&gt;&#xA;          &lt;th style=&#34;text-align: left&#34;&gt;Type&lt;/th&gt;&#xA;          &lt;th style=&#34;text-align: left&#34;&gt;Description&lt;/th&gt;&#xA;      &lt;/tr&gt;&#xA;  &lt;/thead&gt;&#xA;  &lt;tbody&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td style=&#34;text-align: left&#34;&gt;&lt;code&gt;name&lt;/code&gt;&lt;/td&gt;&#xA;          &lt;td style=&#34;text-align: left&#34;&gt;&lt;code&gt;char *&lt;/code&gt;&lt;/td&gt;&#xA;          &lt;td style=&#34;text-align: left&#34;&gt;Command name string (case-sensitive)&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td style=&#34;text-align: left&#34;&gt;&lt;code&gt;func&lt;/code&gt;&lt;/td&gt;&#xA;          &lt;td style=&#34;text-align: left&#34;&gt;Function pointer&lt;/td&gt;&#xA;          &lt;td style=&#34;text-align: left&#34;&gt;Command handler function, accepts argument count and array&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td style=&#34;text-align: left&#34;&gt;&lt;code&gt;desc&lt;/code&gt;&lt;/td&gt;&#xA;          &lt;td style=&#34;text-align: left&#34;&gt;&lt;code&gt;char *&lt;/code&gt;&lt;/td&gt;&#xA;          &lt;td style=&#34;text-align: left&#34;&gt;Command description, displayed in help information&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;  &lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;h3 id=&#34;command-handler-function-signature&#34;&gt;Command Handler Function Signature&lt;/h3&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-c&#34; data-lang=&#34;c&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#0b0;font-weight:bold&#34;&gt;xwer_t&lt;/span&gt; &lt;span style=&#34;color:#00a000&#34;&gt;cmd_handler&lt;/span&gt;(&lt;span style=&#34;color:#0b0;font-weight:bold&#34;&gt;xwsz_t&lt;/span&gt; argc, &lt;span style=&#34;color:#0b0;font-weight:bold&#34;&gt;char&lt;/span&gt; &lt;span style=&#34;color:#666&#34;&gt;**&lt;/span&gt; argv);&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;&lt;code&gt;argc&lt;/code&gt;&lt;/strong&gt;: Number of arguments (including the command name itself, &lt;code&gt;argv[0]&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;&lt;code&gt;argv&lt;/code&gt;&lt;/strong&gt;: Argument pointer array, each element points to a &lt;code&gt;\0&lt;/code&gt;-terminated string&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Return value&lt;/strong&gt;: &lt;code&gt;XWOK&lt;/code&gt; (0) indicates success, negative value indicates error code&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;built-in-commands&#34;&gt;Built-in Commands&lt;/h2&gt;&#xA;&lt;p&gt;XWSH has four built-in basic commands, defined in &lt;code&gt;xwmd/cli/xwsh/cmd.c&lt;/code&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Extension</title>
      <link>/en/Docs/TechRefManual/Xwsh/Extension/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>/en/Docs/TechRefManual/Xwsh/Extension/</guid>
      <description>&lt;h2 id=&#34;cherryrl-library-integration&#34;&gt;CherryRL Library Integration&lt;/h2&gt;&#xA;&lt;p&gt;XWSH uses the &lt;strong&gt;CherryRL&lt;/strong&gt; library to provide professional command line editing features, including history, auto-completion, ANSI escape sequence processing, etc. The integration code is located in &lt;code&gt;xwmd/cli/xwsh/readline.c&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;h3 id=&#34;cherryrl-instance&#34;&gt;CherryRL Instance&lt;/h3&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-c&#34; data-lang=&#34;c&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#080;font-style:italic&#34;&gt;// readline.c:35-37&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#080;font-style:italic&#34;&gt;&lt;/span&gt;&lt;span style=&#34;color:#0b0;font-weight:bold&#34;&gt;chry_readline_t&lt;/span&gt; xwsh_cherryrl;                    &lt;span style=&#34;color:#080;font-style:italic&#34;&gt;// CherryRL instance&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#080;font-style:italic&#34;&gt;&lt;/span&gt;&lt;span style=&#34;color:#0b0;font-weight:bold&#34;&gt;char&lt;/span&gt; xwsh_cherryrl_prompt[XWSH_RL_PROMPT_MAXSIZE]; &lt;span style=&#34;color:#080;font-style:italic&#34;&gt;// Prompt buffer (64 bytes)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#080;font-style:italic&#34;&gt;&lt;/span&gt;&lt;span style=&#34;color:#0b0;font-weight:bold&#34;&gt;char&lt;/span&gt; xwsh_cherryrl_history[XWSH_RL_HISTORY_MAXSIZE]; &lt;span style=&#34;color:#080;font-style:italic&#34;&gt;// History buffer (1024 bytes)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;Buffer size requirements&lt;/strong&gt;:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;History buffer size must be a power of 2 (1024 qualifies)&lt;/li&gt;&#xA;&lt;li&gt;Prompt buffer should be large enough to hold a complete ANSI escape sequence&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h3 id=&#34;initialization-process&#34;&gt;Initialization Process&lt;/h3&gt;&#xA;&lt;p&gt;The &lt;code&gt;xwsh_cherryrl_init()&lt;/code&gt; function (&lt;code&gt;readline.c:125&lt;/code&gt;) completes the following steps:&lt;/p&gt;</description>
    </item>
    <item>
      <title>Integration Guide</title>
      <link>/en/Docs/TechRefManual/Xwsh/Integration/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>/en/Docs/TechRefManual/Xwsh/Integration/</guid>
      <description>&lt;h2 id=&#34;integration-mode-overview&#34;&gt;Integration Mode Overview&lt;/h2&gt;&#xA;&lt;p&gt;XWSH provides two integration modes to suit different application scenarios and resource constraints. The choice depends on thread management requirements, resource availability, and system architecture.&lt;/p&gt;&#xA;&lt;h3 id=&#34;mode-comparison-matrix&#34;&gt;Mode Comparison Matrix&lt;/h3&gt;&#xA;&lt;table&gt;&#xA;  &lt;thead&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;th style=&#34;text-align: left&#34;&gt;Feature&lt;/th&gt;&#xA;          &lt;th style=&#34;text-align: left&#34;&gt;Standalone Thread Mode (&lt;code&gt;xwsh_start()&lt;/code&gt;)&lt;/th&gt;&#xA;          &lt;th style=&#34;text-align: left&#34;&gt;Embedded Mode (&lt;code&gt;xwsh_init()&lt;/code&gt; + &lt;code&gt;xwsh_loop()&lt;/code&gt;)&lt;/th&gt;&#xA;      &lt;/tr&gt;&#xA;  &lt;/thead&gt;&#xA;  &lt;tbody&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td style=&#34;text-align: left&#34;&gt;&lt;strong&gt;Thread Resources&lt;/strong&gt;&lt;/td&gt;&#xA;          &lt;td style=&#34;text-align: left&#34;&gt;Requires dedicated stack space (1-2 KB)&lt;/td&gt;&#xA;          &lt;td style=&#34;text-align: left&#34;&gt;Uses caller&amp;rsquo;s thread stack&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td style=&#34;text-align: left&#34;&gt;&lt;strong&gt;Thread Management&lt;/strong&gt;&lt;/td&gt;&#xA;          &lt;td style=&#34;text-align: left&#34;&gt;XWSH internally creates and manages thread&lt;/td&gt;&#xA;          &lt;td style=&#34;text-align: left&#34;&gt;User controls the loop call&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td style=&#34;text-align: left&#34;&gt;&lt;strong&gt;Priority&lt;/strong&gt;&lt;/td&gt;&#xA;          &lt;td style=&#34;text-align: left&#34;&gt;&lt;code&gt;XWSH_THD_PRIORITY&lt;/code&gt; (realtime priority downgrade)&lt;/td&gt;&#xA;          &lt;td style=&#34;text-align: left&#34;&gt;Same as caller&amp;rsquo;s thread&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td style=&#34;text-align: left&#34;&gt;&lt;strong&gt;Blocking Mode&lt;/strong&gt;&lt;/td&gt;&#xA;          &lt;td style=&#34;text-align: left&#34;&gt;Thread blocks in &lt;code&gt;xwsh_loop()&lt;/code&gt;&lt;/td&gt;&#xA;          &lt;td style=&#34;text-align: left&#34;&gt;Blocks in user&amp;rsquo;s loop&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td style=&#34;text-align: left&#34;&gt;&lt;strong&gt;Freeze Support&lt;/strong&gt;&lt;/td&gt;&#xA;          &lt;td style=&#34;text-align: left&#34;&gt;Automatic thread freeze support&lt;/td&gt;&#xA;          &lt;td style=&#34;text-align: left&#34;&gt;User needs to handle manually&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td style=&#34;text-align: left&#34;&gt;&lt;strong&gt;Use Case&lt;/strong&gt;&lt;/td&gt;&#xA;          &lt;td style=&#34;text-align: left&#34;&gt;Standalone CLI task, system debugging&lt;/td&gt;&#xA;          &lt;td style=&#34;text-align: left&#34;&gt;Integration into existing tasks, resource-constrained environments&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td style=&#34;text-align: left&#34;&gt;&lt;strong&gt;Code Complexity&lt;/strong&gt;&lt;/td&gt;&#xA;          &lt;td style=&#34;text-align: left&#34;&gt;Low (automatic management)&lt;/td&gt;&#xA;          &lt;td style=&#34;text-align: left&#34;&gt;Medium (user manages the loop)&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;  &lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;h2 id=&#34;standalone-thread-mode&#34;&gt;Standalone Thread Mode&lt;/h2&gt;&#xA;&lt;h3 id=&#34;working-principle&#34;&gt;Working Principle&lt;/h3&gt;&#xA;&lt;p&gt;Standalone thread mode creates a dedicated thread to run XWSH, managed internally by the XWSH module.&lt;/p&gt;</description>
    </item>
    <item>
      <title>API Reference</title>
      <link>/en/Docs/TechRefManual/Xwsh/ApiReference/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>/en/Docs/TechRefManual/Xwsh/ApiReference/</guid>
      <description>&lt;h2 id=&#34;overview&#34;&gt;Overview&lt;/h2&gt;&#xA;&lt;p&gt;This document provides a complete reference for all API functions of the XWSH module. APIs are divided into two categories:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;Public API&lt;/strong&gt;: Declared in &lt;code&gt;mi.h&lt;/code&gt;, used by module consumers&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Internal API&lt;/strong&gt;: Declared in &lt;code&gt;core.h&lt;/code&gt;, used internally by the module or by advanced users&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;public-api&#34;&gt;Public API&lt;/h2&gt;&#xA;&lt;p&gt;The public API provides the basic integration interface of the XWSH module, located in &lt;code&gt;xwmd/cli/xwsh/mi.h&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;h3 id=&#34;data-structures&#34;&gt;Data Structures&lt;/h3&gt;&#xA;&lt;h4 id=&#34;struct-xwsh_cmd&#34;&gt;&lt;code&gt;struct xwsh_cmd&lt;/code&gt;&lt;/h4&gt;&#xA;&lt;p&gt;Command structure, used to define XWSH commands.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
