1<?xml version="1.0"?>
2<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://clish.sourceforge.net/XMLSchema" targetNamespace="http://clish.sourceforge.net/XMLSchema">
3    <!--
4***********************************************************
5* Forward declare the main element identifiers
6***********************************************************
7-->
8    <xs:element name="CLISH_MODULE" type="clish_module_t"/>
9    <xs:element name="VIEW" type="view_t"/>
10    <xs:element name="COMMAND" type="command_t"/>
11    <xs:element name="STARTUP" type="startup_t"/>
12    <xs:element name="ACTION" type="action_t"/>
13    <xs:element name="OVERVIEW" type="overview_t"/>
14    <xs:element name="DETAIL" type="detail_t"/>
15    <xs:element name="PTYPE" type="ptype_t"/>
16    <xs:element name="PARAM" type="param_t"/>
17    <xs:element name="NAMESPACE" type="namespace_t"/>
18    <xs:element name="CONFIG" type="config_t"/>
19    <xs:element name="VAR" type="var_t"/>
20    <xs:element name="WATCHDOG" type="wdog_t"/>
21    <xs:element name="HOTKEY" type="hotkey_t"/>
22    <xs:element name="PLUGIN" type="plugin_t"/>
23    <xs:element name="HOOK" type="hook_t"/>
24
25    <!--
26***********************************************************
27* The common simple types
28***********************************************************
29-->
30    <xs:simpleType name="bool_t">
31        <xs:restriction base="xs:string">
32            <xs:enumeration value="true"/>
33            <xs:enumeration value="false"/>
34        </xs:restriction>
35    </xs:simpleType>
36
37    <!--
38***********************************************************
39* <CLISH_MODULE> is the top level container.
40* Any commands which are defined within this tag are global in scope
41* i.e. they are visible from all views.
42***********************************************************
43-->
44    <xs:complexType name="clish_module_t">
45        <xs:sequence>
46            <xs:element ref="OVERVIEW" minOccurs="0"/>
47            <xs:element ref="STARTUP" minOccurs="0"/>
48            <xs:element ref="PTYPE" minOccurs="0" maxOccurs="unbounded"/>
49            <xs:element ref="COMMAND" minOccurs="0" maxOccurs="unbounded"/>
50            <xs:element ref="VIEW" minOccurs="0" maxOccurs="unbounded"/>
51            <xs:element ref="NAMESPACE" minOccurs="0" maxOccurs="unbounded"/>
52            <xs:element ref="VAR" minOccurs="0" maxOccurs="unbounded"/>
53            <xs:element ref="WATCHDOG" minOccurs="0" maxOccurs="1"/>
54            <xs:element ref="HOTKEY" minOccurs="0" maxOccurs="unbounded"/>
55            <xs:element ref="PLUGIN" minOccurs="0" maxOccurs="unbounded"/>
56            <xs:element ref="HOOK" minOccurs="0" maxOccurs="unbounded"/>
57        </xs:sequence>
58    </xs:complexType>
59    <!--
60***********************************************************
61* Identify some attribute groups
62***********************************************************
63-->
64    <xs:attributeGroup name="menu_item_g">
65        <xs:attribute name="name" type="xs:string" use="required"/>
66        <xs:attribute name="help" type="xs:string" use="required"/>
67    </xs:attributeGroup>
68    <!--
69*******************************************************
70* <PTYPE> is used to define the syntax for a parameter type.
71*
72* name    - a textual name for this type. This name can be used to
73*         reference this type within a <PARAM? ptype attribute.
74*
75* help    - a textual string which describes the syntax of this type.
76*         When a parameter is filled out incorrectly on the CLI, this
77*         text will be used to prompt the user to fill out the value
78*         correctly.
79*
80* pattern     - A regular expression which defines the syntax of the type.
81*
82* method      - The means by which the pattern is interpreted.
83*
84*               "regexp" [default] - A POSIX regular expression.
85*
86*               "integer"          - A numeric definition "min..max"
87*
88*               "select"           - A list of possible values.
89*               The syntax of the string is of the form:
90*                 "valueOne(ONE) valueTwo(TWO) valueThree(THREE)"
91*               where the text before the parethesis defines the syntax
92*               that the user must use, and the value within the parenthesis
93*               is the result expanded as a parameter value.
94*
95* preprocess  - An optional directive to process the value entered before
96*               validating it. This can greatly simplify the regular expressions
97*               needed to match case insensitive values.
98*
99*               "none" [default] - do nothing
100*
101*               "toupper"        - before validation convert to uppercase.
102*
103*               "tolower"        - before validation convert to lowercase.
104*
105********************************************************
106-->
107    <xs:simpleType name="ptype_method_e">
108        <xs:restriction base="xs:string">
109            <xs:enumeration value="regexp"/>
110            <xs:enumeration value="integer"/>
111            <xs:enumeration value="unsignedInteger"/>
112            <xs:enumeration value="select"/>
113            <xs:enumeration value="choice"/>
114            <xs:enumeration value="subcommand"/>
115        </xs:restriction>
116    </xs:simpleType>
117
118    <xs:simpleType name="ptype_preprocess_e">
119        <xs:restriction base="xs:string">
120            <xs:enumeration value="none"/>
121            <xs:enumeration value="toupper"/>
122            <xs:enumeration value="tolower"/>
123        </xs:restriction>
124    </xs:simpleType>
125
126    <xs:complexType name="ptype_t">
127        <xs:attributeGroup ref="menu_item_g"/>
128        <xs:attribute name="pattern" type="xs:string"/>
129        <xs:attribute name="method" type="ptype_method_e" use="optional" default="regexp"/>
130        <xs:attribute name="preprocess" type="ptype_preprocess_e" use="optional" default="none"/>
131    </xs:complexType>
132    <!--
133*******************************************************
134* <VIEW> defines the contents of a specific CLI view.
135*
136* name      - a textual name for the view
137*
138* prompt    - a textual definition of the prompt to be
139*           used whilst in this view.
140*           NB. The prompt may contain environment
141*           or dynamic variables which are expanded
142*           before display.
143*
144* [depth]   - a depth of nested view (uses for config).
145*
146* [restore] - restore the depth or view of commands
147*           contained by this view
148*
149* [access] - access rights
150*
151********************************************************
152-->
153
154    <xs:simpleType name="restore_t">
155        <xs:restriction base="xs:string">
156            <xs:enumeration value="none"/>
157            <xs:enumeration value="depth"/>
158            <xs:enumeration value="view"/>
159        </xs:restriction>
160    </xs:simpleType>
161
162    <xs:complexType name="view_t">
163        <xs:sequence>
164            <xs:element ref="NAMESPACE" minOccurs="0" maxOccurs="unbounded"/>
165            <xs:element ref="COMMAND" minOccurs="0" maxOccurs="unbounded"/>
166            <xs:element ref="HOTKEY" minOccurs="0" maxOccurs="unbounded"/>
167        </xs:sequence>
168        <xs:attribute name="name" type="xs:string" use="required"/>
169        <xs:attribute name="prompt" type="xs:string" use="optional"/>
170        <xs:attribute name="depth" type="xs:string" use="optional" default="0"/>
171        <xs:attribute name="restore" type="restore_t" use="optional" default="none"/>
172        <xs:attribute name="access" type="xs:string" use="optional"/>
173    </xs:complexType>
174    <!--
175*******************************************************
176* <STARTUP> is used to define what happens when the CLI
177* is started. Any text held in a <DETAIL> sub-element will
178* be used as banner text, then any defined <ACTION> will be
179* executed. This action may provide Message Of The Day (MOTD)
180* type behaviour.
181*
182* view   - defines the view which will be transitioned to, on
183*          successful execution of any <ACTION> tag.
184*
185* [viewid] - defined the new value of the ${VIEWID} variable to
186*          be used if a transition to a new view occurs.
187*
188* [default_shebang] - The default shebang for all commands.
189*
190* [timeout] - The idle timeout. The clish will exit if user
191*          have not press any key while this timeout.
192*
193* [lock] - The same as lock for COMMAND tag.
194*
195* [interrupt] - The same as interrupt for COMMAND tag.
196*
197* [default_plugin] - Use (or don't use) default plugin.
198*                    It can be true or false.
199********************************************************
200-->
201    <xs:complexType name="startup_t">
202        <xs:sequence>
203            <xs:element ref="DETAIL" minOccurs="0"/>
204            <xs:element ref="ACTION" minOccurs="0"/>
205        </xs:sequence>
206        <xs:attribute name="view" type="xs:string" use="required"/>
207        <xs:attribute name="viewid" type="xs:string" use="optional"/>
208        <xs:attribute name="default_shebang" type="xs:string" use="optional"/>
209        <xs:attribute name="timeout" type="xs:string" use="optional"/>
210        <xs:attribute name="lock" type="bool_t" use="optional" default="true"/>
211        <xs:attribute name="interrupt" type="bool_t" use="optional" default="false"/>
212        <xs:attribute name="default_plugin" type="bool_t" use="optional" default="true"/>
213    </xs:complexType>
214    <!--
215*******************************************************
216* <COMMAND> is used to define a command within the CLI.
217*
218* name           - a textual name for this command. (This may contain
219*                spaces e.g. "display acl")
220*
221* help           - a textual string which describes the purpose of the
222*                command.
223*
224* [view]         - defines the view which will be transitioned to, on
225*                successful execution of any <ACTION> tag. By default the
226*                current view stays in scope.
227*
228* [viewid]       - defined the new value of the ${VIEWID} variable to
229*                be used if a transition to a new view occurs. By default
230*                the viewid will retain it's current value.
231*
232* [access]       - defines the user group/level to which execution of this
233*                command is restricted. By default there is no restriction.
234*                The exact interpretation of this field is dependant on the
235*                client of libclish but for example the clish and tclish
236*                applications map this to the UNIX user groups.
237*
238* [escape_chars] - defines the characters which will be escaped (e.g. \$) before
239*                being expanded as a variable. By default the following
240*                characters will be escaped `|$<>&()#
241*
242* [args]         - defines a parameter name to be used to gather the rest of the
243*                command line after the formally defined parameters
244*                (PARAM elements). The formatting of this parameter is a raw
245*                string containing as many words as there are on the rest of the
246*                command line.
247*
248* [args_help]    - a textual string which describes the purpose of the 'args'
249*                parameter. If the "args" attribute is given then this MUST be
250*                given also.
251*
252* [lock]         - the boolean field that specify to lock lockfile while
253*                command execution or not. Default is true.
254*
255********************************************************
256-->
257    <xs:complexType name="command_t">
258        <xs:sequence>
259            <xs:element ref="DETAIL" minOccurs="0"/>
260            <xs:element ref="PARAM" minOccurs="0" maxOccurs="unbounded"/>
261            <xs:element ref="CONFIG" minOccurs="0"/>
262            <xs:element ref="ACTION" minOccurs="0"/>
263        </xs:sequence>
264        <xs:attributeGroup ref="menu_item_g"/>
265        <xs:attribute name="ref" type="xs:string" use="optional"/>
266        <xs:attribute name="view" type="xs:string" use="optional"/>
267        <xs:attribute name="viewid" type="xs:string" use="optional"/>
268        <xs:attribute name="access" type="xs:string" use="optional"/>
269        <xs:attribute name="args" type="xs:string" use="optional"/>
270        <xs:attribute name="args_help" type="xs:string" use="optional"/>
271        <xs:attribute name="escape_chars" type="xs:string" use="optional"/>
272        <xs:attribute name="lock" type="bool_t" use="optional" default="true"/>
273        <xs:attribute name="interrupt" type="bool_t" use="optional" default="false"/>
274    </xs:complexType>
275    <!--
276*******************************************************
277* <PARAM> This tag is used to define a parameter for a command.
278*
279* name      - a textual name for this parameter.
280*
281* help      - a textual string which describes the purpose of the
282*           parameter.
283*
284* ptype     - Reference to a PTYPE name. This parameter will be
285*           validated against the syntax specified for that type.
286*           The special value of "" indicates the parameter is a boolean flag.
287*           The verbatim presence of the texual name on the command line
288*           simply controls the conditional variable expansion for this
289*           parameter.
290*
291* [mode]    - Parameter mode. It can be "common", "switch" or
292*           "subcommand".
293*
294* [prefix]  - defines the prefix for an optional parameter. A prefix
295*           with this value on the command line will signify the presence
296*           of an additional argument which will be validated as the
297*           value of this parameter.
298*
299* [optional]- Specify whether parameter is optional. The allowed values
300*           is "true" or "false". It's false by default.
301*
302* [order]   - Used only together with "optional=true" field.
303*           If order="true" then user can't enter previously declared
304*           optional parameters after current validated parameter.
305*           The allowed values is "true" or "false". It's false by default.
306*
307* [default] - defines a default value for a parameter. Any parameters
308*           at the end of command line which have default values need
309*           not explicitly be entered.
310*
311* [value]   - defines the user's value for subcommand. If this option
312*           is defined the entered parameter will be compared to this
313*           value instead the "name" field. If this field is defined
314*           the mode of PARAM will be forced to "subcommand". The
315*           feature is implemented to support subcommands with the
316*           same names.
317*
318* [hidden]  - define the visibility of the parameter while ${__line}
319*           and ${__params} auto variables expanding. The allowed values
320*           is "true" and "false".
321*
322* [test]    - define the condition (see the description of 'test'
323*           utility) to process this parameter.
324*
325* [access]  - access rights
326*
327********************************************************
328    -->
329
330    <xs:simpleType name="param_mode_t">
331        <xs:restriction base="xs:string">
332            <xs:enumeration value="common"/>
333            <xs:enumeration value="switch"/>
334            <xs:enumeration value="subcommand"/>
335        </xs:restriction>
336    </xs:simpleType>
337
338    <xs:complexType name="param_t">
339        <xs:sequence>
340            <xs:element ref="PARAM" minOccurs="0" maxOccurs="unbounded"/>
341        </xs:sequence>
342        <xs:attributeGroup ref="menu_item_g"/>
343        <xs:attribute name="ptype" type="xs:string" use="required"/>
344        <xs:attribute name="default" type="xs:string" use="optional"/>
345        <xs:attribute name="prefix" type="xs:string" use="optional"/>
346        <xs:attribute name="mode" type="param_mode_t" use="optional" default="common"/>
347        <xs:attribute name="optional" type="bool_t" use="optional" default="false"/>
348        <xs:attribute name="order" type="bool_t" use="optional" default="false"/>
349        <xs:attribute name="value" type="xs:string" use="optional"/>
350        <xs:attribute name="hidden" type="bool_t" use="optional" default="false"/>
351        <xs:attribute name="test" type="xs:string" use="optional"/>
352        <xs:attribute name="completion" type="xs:string" use="optional"/>
353        <xs:attribute name="access" type="xs:string" use="optional"/>
354    </xs:complexType>
355    <!--
356********************************************************
357* <ACTION> specifies the action to be taken for
358* a command.
359*
360* The textual contents of the tag are variable expanded
361* (environment, dynamic and parameter) the the resulting
362* text is interpreted by the client's script interpreter.
363*
364* In addition the optional 'builtin' attribute can specify
365* the name of an internal command which will be invoked
366* instead of the client's script handler.
367*
368* NB. for security reasons any special shell characters
369* (e.g. $|<>`) are escaped before evaluation.
370*
371* [builtin] - specify the name of an internally registered
372*           function. The content of the ACTION tag is
373*           taken as the arguments to this builtin function.
374*
375* [shebang] - specify the programm to execute the action
376*           script.
377********************************************************
378-->
379    <xs:complexType name="action_t">
380        <xs:simpleContent>
381            <xs:extension base="xs:string">
382                <xs:attribute name="builtin" type="xs:string" use="optional"/>
383                <xs:attribute name="shebang" type="xs:string" use="optional"/>
384            </xs:extension>
385        </xs:simpleContent>
386    </xs:complexType>
387    <!--
388********************************************************
389* <OVERVIEW> specifies a textual description of the shell.
390*
391* This should provide instructions about key bindings and
392* escape sequences which can be used in the CLI.
393*
394********************************************************
395-->
396    <xs:simpleType name="overview_t">
397        <xs:restriction base="xs:string">
398            <xs:whiteSpace value="preserve"/>
399        </xs:restriction>
400    </xs:simpleType>
401    <!--
402********************************************************
403* <DETAIL> specifies a textual description.
404*
405* This may be used within the scope of a <COMMAND>
406* element, in which case it would typically contain
407* detailed usage instructions including examples.
408*
409* This may also be used within the scope of a <STARTUP>
410* element, in which case the text is used as the banner
411* details which are displayed on shell startup. This is
412* shown before any specified <ACTION> is executed.
413*
414* This text may also be used in the production of user manuals.
415********************************************************
416-->
417    <xs:simpleType name="detail_t">
418        <xs:restriction base="xs:string">
419            <xs:whiteSpace value="preserve"/>
420        </xs:restriction>
421    </xs:simpleType>
422    <!--
423*******************************************************
424* <NAMESPACE> import commands from specific view to current view.
425*
426* ref            - the view to import commands from
427*
428* [prefix]       - the prefix for imported commands
429*
430* [prefix_help]  - the help for namespace prefix
431*
432* [help]         - a boolean flag to use imported
433*                commands while help
434*
435* [completion]   - a boolean flag to use imported
436*                commands while completion
437*
438* [context_help] - a boolean flag to use imported
439*                commands while context help
440*
441* [inherit]      - a boolean flag to inherit nested
442*                namespace commands recursively
443*
444* [access]       - access rights
445*
446********************************************************
447-->
448
449    <xs:complexType name="namespace_t">
450        <xs:attribute name="ref" type="xs:string" use="required"/>
451        <xs:attribute name="prefix" type="xs:string" use="optional"/>
452        <xs:attribute name="prefix_help" type="xs:string" use="optional"/>
453        <xs:attribute name="help" type="bool_t" use="optional" default="false"/>
454        <xs:attribute name="completion" type="bool_t" use="optional" default="true"/>
455        <xs:attribute name="context_help" type="bool_t" use="optional" default="false"/>
456        <xs:attribute name="inherit" type="bool_t" use="optional" default="true"/>
457        <xs:attribute name="access" type="xs:string" use="optional"/>
458    </xs:complexType>
459
460<!--
461*******************************************************
462* <CONFIG> Specify the config operation.
463*
464* operation - config operation to perform
465*
466********************************************************
467-->
468    <xs:simpleType name="operation_t">
469        <xs:restriction base="xs:string">
470            <xs:enumeration value="none"/>
471            <xs:enumeration value="set"/>
472            <xs:enumeration value="unset"/>
473            <xs:enumeration value="dump"/>
474        </xs:restriction>
475    </xs:simpleType>
476
477    <xs:complexType name="config_t">
478        <xs:attribute name="operation" type="operation_t" use="optional" default="set"/>
479        <xs:attribute name="priority" type="xs:string" use="optional" default="0x7f00"/>
480        <xs:attribute name="pattern" type="xs:string" use="optional" default="^${__cmd}"/>
481        <xs:attribute name="file" type="xs:string" use="optional" default="startup-config"/>
482        <xs:attribute name="splitter" type="bool_t" use="optional" default="true"/>
483        <xs:attribute name="sequence" type="xs:string" use="optional" default="0"/>
484        <xs:attribute name="unique" type="bool_t" use="optional" default="true"/>
485        <xs:attribute name="depth" type="xs:string" use="optional"/>
486    </xs:complexType>
487
488<!--
489*******************************************************
490* <VAR> Specify the variable.
491*
492*
493*
494********************************************************
495-->
496    <xs:complexType name="var_t">
497        <xs:sequence>
498            <xs:element ref="ACTION" minOccurs="0"/>
499        </xs:sequence>
500        <xs:attribute name="name" type="xs:string" use="required"/>
501        <xs:attribute name="help" type="xs:string" use="optional"/>
502        <xs:attribute name="value" type="xs:string" use="optional"/>
503        <xs:attribute name="dynamic" type="bool_t" use="optional" default="false"/>
504    </xs:complexType>
505
506<!--
507*******************************************************
508* <WATCHDOG> is used to recover system after errors.
509*
510********************************************************
511-->
512    <xs:complexType name="wdog_t">
513        <xs:sequence>
514            <xs:element ref="ACTION" minOccurs="1"/>
515        </xs:sequence>
516    </xs:complexType>
517
518<!--
519*******************************************************
520* <HOTKEY> is used to define hotkey actions
521*
522********************************************************
523-->
524    <xs:complexType name="hotkey_t">
525        <xs:attribute name="key" type="xs:string" use="required"/>
526        <xs:attribute name="cmd" type="xs:string" use="required"/>
527    </xs:complexType>
528
529<!--
530*******************************************************
531* <PLUGIN> is used to dynamically load plugins
532*
533* [rtld_global] - A boolean RTLD_GLOBAL flag for dlopen()
534*                 while plugin loading. Default is "false".
535*
536********************************************************
537-->
538    <xs:complexType name="plugin_t">
539        <xs:simpleContent>
540            <xs:extension base="xs:string">
541                <xs:attribute name="name" type="xs:string" use="required"/>
542                <xs:attribute name="alias" type="xs:string" use="optional"/>
543                <xs:attribute name="file" type="xs:string" use="optional"/>
544                <xs:attribute name="rtld_global" type="bool_t" use="optional" default="false"/>
545            </xs:extension>
546        </xs:simpleContent>
547    </xs:complexType>
548
549<!--
550*******************************************************
551* <HOOK> is used to redefine internal hooks
552*
553* name - The name of internal hook (init, fini, access, config, log).
554*
555* [builtin] - specify the name of an internally registered
556*           function.
557*
558********************************************************
559-->
560    <xs:simpleType name="hook_list_e">
561        <xs:restriction base="xs:string">
562            <xs:enumeration value="init"/>
563            <xs:enumeration value="fini"/>
564            <xs:enumeration value="access"/>
565            <xs:enumeration value="config"/>
566            <xs:enumeration value="log"/>
567        </xs:restriction>
568    </xs:simpleType>
569
570    <xs:complexType name="hook_t">
571        <xs:attribute name="name" type="hook_list_e"/>
572        <xs:attribute name="builtin" type="xs:string" use="optional"/>
573    </xs:complexType>
574
575</xs:schema>
576