klish.xsd 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://clish.sourceforge.net/XMLSchema" targetNamespace="http://clish.sourceforge.net/XMLSchema">
  3. <xs:annotation>
  4. <xs:appinfo>XML schema for klish configuration files</xs:appinfo>
  5. <xs:documentation xml:lang="en">
  6. The klish utility uses XML files for configuration. This schema
  7. allows to validate klish XML files. To check XML files use the
  8. following command:
  9. 'xmllint --schema /path/to/klish.xsd --noout *.xml'
  10. </xs:documentation>
  11. <xs:documentation xml:lang="ru">
  12. Утилита klish использует формат XML для своих конфигурационных
  13. файлов. Схема позволяет проверить эти конфигурационные XML файлы
  14. на правильность. Следующая команда выполнит проверку:
  15. 'xmllint --schema /path/to/klish.xsd --noout *.xml'
  16. </xs:documentation>
  17. </xs:annotation>
  18. <xs:element name="KLISH" type="klish_t"/>
  19. <xs:element name="VIEW" type="view_t"/>
  20. <xs:element name="COMMAND" type="command_t"/>
  21. <xs:element name="FILTER" type="command_t"/>
  22. <xs:element name="STARTUP" type="startup_t"/>
  23. <xs:element name="ACTION" type="action_t"/>
  24. <xs:element name="OVERVIEW" type="overview_t"/>
  25. <xs:element name="DETAIL" type="detail_t"/>
  26. <xs:element name="PTYPE" type="ptype_t"/>
  27. <xs:element name="PARAM" type="param_t"/>
  28. <xs:element name="NAMESPACE" type="namespace_t"/>
  29. <xs:element name="VAR" type="var_t"/>
  30. <xs:element name="WATCHDOG" type="wdog_t"/>
  31. <xs:element name="HOTKEY" type="hotkey_t"/>
  32. <xs:element name="PLUGIN" type="plugin_t"/>
  33. <xs:element name="HOOK" type="hook_t"/>
  34. <xs:complexType name="klish_t">
  35. <xs:annotation>
  36. <xs:documentation xml:lang="en">
  37. 'KLISH' is the top level container. Any object (command,
  38. type, var) which are defined within this tag are global
  39. in scope i.e. it is visible from all 'VIEW's.
  40. </xs:documentation>
  41. <xs:documentation xml:lang="ru">
  42. Тег 'KLISH' - контейнер верхнего уровня. Все остальные
  43. теги должны быть вложенными. Любой объект (команда,
  44. тип, переменная т.д.), заданный внутри этого тега,
  45. считается глобальным, т.е. видимым их любых 'VIEW".
  46. </xs:documentation>
  47. </xs:annotation>
  48. <xs:sequence>
  49. <xs:element ref="OVERVIEW" minOccurs="0"/>
  50. <xs:element ref="STARTUP" minOccurs="0"/>
  51. <xs:element ref="PTYPE" minOccurs="0" maxOccurs="unbounded"/>
  52. <xs:element ref="COMMAND" minOccurs="0" maxOccurs="unbounded"/>
  53. <xs:element ref="VIEW" minOccurs="0" maxOccurs="unbounded"/>
  54. <xs:element ref="NAMESPACE" minOccurs="0" maxOccurs="unbounded"/>
  55. <xs:element ref="VAR" minOccurs="0" maxOccurs="unbounded"/>
  56. <xs:element ref="WATCHDOG" minOccurs="0" maxOccurs="1"/>
  57. <xs:element ref="HOTKEY" minOccurs="0" maxOccurs="unbounded"/>
  58. <xs:element ref="PLUGIN" minOccurs="0" maxOccurs="unbounded"/>
  59. <xs:element ref="HOOK" minOccurs="0" maxOccurs="unbounded"/>
  60. </xs:sequence>
  61. </xs:complexType>
  62. <!--
  63. ***********************************************************
  64. * Identify some attribute groups
  65. ***********************************************************
  66. -->
  67. <xs:attributeGroup name="menu_item_g">
  68. <xs:attribute name="name" type="xs:string" use="required"/>
  69. <xs:attribute name="help" type="xs:string" use="required"/>
  70. </xs:attributeGroup>
  71. <!--
  72. *******************************************************
  73. * <PTYPE> is used to define the syntax for a parameter type.
  74. *
  75. * name - a textual name for this type. This name can be used to
  76. * reference this type within a PARAM's ptype attribute.
  77. *
  78. * help - a textual string which describes the syntax of this type.
  79. *
  80. ********************************************************
  81. -->
  82. <xs:complexType name="ptype_t">
  83. <xs:attribute name="name" type="xs:string" use="required"/>
  84. <xs:attribute name="help" type="xs:string" use="required"/>
  85. <xs:sequence>
  86. <xs:element ref="ACTION" minOccurs="0" maxOccurs="unbounded"/>
  87. </xs:sequence>
  88. </xs:complexType>
  89. <!--
  90. *******************************************************
  91. * <VIEW> defines the contents of a specific CLI view.
  92. *
  93. * name - a textual name for the view
  94. *
  95. * prompt - a textual definition of the prompt to be
  96. * used whilst in this view.
  97. * NB. The prompt may contain environment
  98. * or dynamic variables which are expanded
  99. * before display.
  100. *
  101. * [depth] - a depth of nested view (uses for config).
  102. *
  103. * [restore] - restore the depth or view of commands
  104. * contained by this view
  105. *
  106. * [access] - access rights
  107. *
  108. ********************************************************
  109. -->
  110. <xs:simpleType name="restore_t">
  111. <xs:restriction base="xs:string">
  112. <xs:enumeration value="none"/>
  113. <xs:enumeration value="depth"/>
  114. <xs:enumeration value="view"/>
  115. </xs:restriction>
  116. </xs:simpleType>
  117. <xs:complexType name="view_t">
  118. <xs:sequence>
  119. <xs:element ref="NAMESPACE" minOccurs="0" maxOccurs="unbounded"/>
  120. <xs:element ref="COMMAND" minOccurs="0" maxOccurs="unbounded"/>
  121. <xs:element ref="HOTKEY" minOccurs="0" maxOccurs="unbounded"/>
  122. </xs:sequence>
  123. <xs:attribute name="name" type="xs:string" use="required"/>
  124. <xs:attribute name="prompt" type="xs:string" use="optional"/>
  125. <xs:attribute name="depth" type="xs:string" use="optional" default="0"/>
  126. <xs:attribute name="restore" type="restore_t" use="optional" default="none"/>
  127. <xs:attribute name="access" type="xs:string" use="optional"/>
  128. </xs:complexType>
  129. <!--
  130. *******************************************************
  131. * <STARTUP> is used to define what happens when the CLI
  132. * is started. Any text held in a <DETAIL> sub-element will
  133. * be used as banner text, then any defined <ACTION> will be
  134. * executed. This action may provide Message Of The Day (MOTD)
  135. * type behaviour.
  136. *
  137. * view - defines the view which will be transitioned to, on
  138. * successful execution of any <ACTION> tag.
  139. *
  140. * [viewid] - defined the new value of the ${VIEWID} variable to
  141. * be used if a transition to a new view occurs.
  142. *
  143. * [default_shebang] - The default shebang for all commands.
  144. *
  145. * [timeout] - The idle timeout. The clish will exit if user
  146. * have not press any key while this timeout.
  147. *
  148. * [lock] - The same as lock for COMMAND tag.
  149. *
  150. * [interrupt] - The same as interrupt for COMMAND tag.
  151. *
  152. * [default_plugin] - Use (or don't use) default plugin.
  153. * It can be true or false.
  154. ********************************************************
  155. -->
  156. <xs:complexType name="startup_t">
  157. <xs:sequence>
  158. <xs:element ref="DETAIL" minOccurs="0"/>
  159. <xs:element ref="ACTION" minOccurs="0"/>
  160. </xs:sequence>
  161. <xs:attribute name="view" type="xs:string" use="required"/>
  162. <xs:attribute name="viewid" type="xs:string" use="optional"/>
  163. <xs:attribute name="default_shebang" type="xs:string" use="optional"/>
  164. <xs:attribute name="timeout" type="xs:string" use="optional"/>
  165. <xs:attribute name="default_plugin" type="xs:boolean" use="optional" default="true"/>
  166. </xs:complexType>
  167. <!--
  168. *******************************************************
  169. * <COMMAND> is used to define a command within the CLI.
  170. *
  171. * name - a textual name for this command. (This may contain
  172. * spaces e.g. "display acl")
  173. *
  174. * help - a textual string which describes the purpose of the
  175. * command.
  176. *
  177. * [view] - defines the view which will be transitioned to, on
  178. * successful execution of any <ACTION> tag. By default the
  179. * current view stays in scope.
  180. *
  181. * [viewid] - defined the new value of the ${VIEWID} variable to
  182. * be used if a transition to a new view occurs. By default
  183. * the viewid will retain it's current value.
  184. *
  185. * [access] - defines the user group/level to which execution of this
  186. * command is restricted. By default there is no restriction.
  187. * The exact interpretation of this field is dependant on the
  188. * client of libclish but for example the clish and tclish
  189. * applications map this to the UNIX user groups.
  190. *
  191. * [escape_chars] - defines the characters which will be escaped (e.g. \$) before
  192. * being expanded as a variable. By default the following
  193. * characters will be escaped `|$<>&()#
  194. *
  195. * [args] - defines a parameter name to be used to gather the rest of the
  196. * command line after the formally defined parameters
  197. * (PARAM elements). The formatting of this parameter is a raw
  198. * string containing as many words as there are on the rest of the
  199. * command line.
  200. *
  201. * [args_help] - a textual string which describes the purpose of the 'args'
  202. * parameter. If the "args" attribute is given then this MUST be
  203. * given also.
  204. *
  205. ********************************************************
  206. -->
  207. <xs:complexType name="command_t">
  208. <xs:sequence>
  209. <xs:element ref="DETAIL" minOccurs="0"/>
  210. <xs:element ref="PARAM" minOccurs="0" maxOccurs="unbounded"/>
  211. <xs:element ref="ACTION" minOccurs="0"/>
  212. </xs:sequence>
  213. <xs:attributeGroup ref="menu_item_g"/>
  214. <xs:attribute name="ref" type="xs:string" use="optional"/>
  215. <xs:attribute name="view" type="xs:string" use="optional"/>
  216. <xs:attribute name="viewid" type="xs:string" use="optional"/>
  217. <xs:attribute name="access" type="xs:string" use="optional"/>
  218. <xs:attribute name="args" type="xs:string" use="optional"/>
  219. <xs:attribute name="args_help" type="xs:string" use="optional"/>
  220. <xs:attribute name="escape_chars" type="xs:string" use="optional"/>
  221. </xs:complexType>
  222. <!--
  223. *******************************************************
  224. * <PARAM> This tag is used to define a parameter for a command.
  225. *
  226. * name - a textual name for this parameter.
  227. *
  228. * help - a textual string which describes the purpose of the
  229. * parameter.
  230. *
  231. * ptype - Reference to a PTYPE name. This parameter will be
  232. * validated against the syntax specified for that type.
  233. * The special value of "" indicates the parameter is a boolean flag.
  234. * The verbatim presence of the texual name on the command line
  235. * simply controls the conditional variable expansion for this
  236. * parameter.
  237. *
  238. * [mode] - Parameter mode. It can be "common", "switch" or "subcommand".
  239. *
  240. * [prefix] - defines the prefix for an optional parameter. A prefix
  241. * with this value on the command line will signify the presence
  242. * of an additional argument which will be validated as the
  243. * value of this parameter.
  244. *
  245. * [optional] - Specify whether parameter is optional. The allowed values
  246. * is "true" or "false". It's false by default.
  247. *
  248. * [order] - Used only together with "optional=true" field.
  249. * If order="true" then user can't enter previously declared
  250. * optional parameters after current validated parameter.
  251. * The allowed values is "true" or "false". It's false by default.
  252. *
  253. * [default] - defines a default value for a parameter. Any parameters
  254. * at the end of command line which have default values need
  255. * not explicitly be entered.
  256. *
  257. * [value] - defines the user's value for subcommand. If this option
  258. * is defined the entered parameter will be compared to this
  259. * value instead the "name" field. If this field is defined
  260. * the mode of PARAM will be forced to "subcommand". The
  261. * feature is implemented to support subcommands with the
  262. * same names.
  263. *
  264. * [hidden] - define the visibility of the parameter while ${__line}
  265. * and ${__params} auto variables expanding. The allowed values
  266. * is "true" and "false".
  267. *
  268. * [test] - define the condition (see the description of 'test'
  269. * utility) to process this parameter.
  270. *
  271. * [access] - access rights
  272. *
  273. ********************************************************
  274. -->
  275. <xs:simpleType name="param_mode_t">
  276. <xs:restriction base="xs:string">
  277. <xs:enumeration value="common"/>
  278. <xs:enumeration value="switch"/>
  279. <xs:enumeration value="subcommand"/>
  280. </xs:restriction>
  281. </xs:simpleType>
  282. <xs:complexType name="param_t">
  283. <xs:sequence>
  284. <xs:element ref="PARAM" minOccurs="0" maxOccurs="unbounded"/>
  285. </xs:sequence>
  286. <xs:attributeGroup ref="menu_item_g"/>
  287. <xs:attribute name="ptype" type="xs:string" use="required"/>
  288. <xs:attribute name="default" type="xs:string" use="optional"/>
  289. <xs:attribute name="prefix" type="xs:string" use="optional"/>
  290. <xs:attribute name="mode" type="param_mode_t" use="optional" default="common"/>
  291. <xs:attribute name="optional" type="xs:boolean" use="optional" default="false"/>
  292. <xs:attribute name="order" type="xs:boolean" use="optional" default="false"/>
  293. <xs:attribute name="value" type="xs:string" use="optional"/>
  294. <xs:attribute name="hidden" type="xs:boolean" use="optional" default="false"/>
  295. <xs:attribute name="test" type="xs:string" use="optional"/>
  296. <xs:attribute name="completion" type="xs:string" use="optional"/>
  297. <xs:attribute name="access" type="xs:string" use="optional"/>
  298. </xs:complexType>
  299. <!--
  300. ********************************************************
  301. * <ACTION> specifies the action to be taken for
  302. * a command.
  303. *
  304. * In addition the optional 'sym' attribute can specify
  305. * the name of an internal command which will be invoked
  306. * to handle script.
  307. *
  308. * [sym="<symbol>"] - specify the name of an internally registered
  309. * function. The content of the ACTION tag is
  310. * taken as the arguments to this builtin function.
  311. *
  312. * [lock="<name>"] - Named lock. It will use special lockfile while
  313. * action execution.
  314. *
  315. * [interrupt="true/false"] - The boolean field that specify that action can be
  316. * be interrupted by Ctrl^C. Default is false. Ignored for non-interactive
  317. * actions.
  318. *
  319. * [interactive="true/false"] - Is action interactive.
  320. *
  321. * [exec_on="fail/success/always"] - ACTION's execution depends on
  322. * return code of previous elements of ACTION chain. If the
  323. * condition is not met then ACTION will not be executed. The "always"
  324. * value means that ACTION will be always executed and chain return
  325. * code will be ignored. Default is "success".
  326. *
  327. * [upadate_retcode="true/false"] - The chain return value can be updated
  328. * by current ACTION's return code or ACTION's return code can be ignored.
  329. * Default is "true".
  330. *
  331. ********************************************************
  332. -->
  333. <xs:simpleType name="action_cond_t">
  334. <xs:restriction base="xs:string">
  335. <xs:enumeration value="fail"/>
  336. <xs:enumeration value="success"/>
  337. <xs:enumeration value="always"/>
  338. </xs:restriction>
  339. </xs:simpleType>
  340. <xs:complexType name="action_t">
  341. <xs:simpleContent>
  342. <xs:extension base="xs:string">
  343. <xs:attribute name="sym" type="xs:string" use="optional"/>
  344. <xs:attribute name="lock" type="xs:string" use="optional"/>
  345. <xs:attribute name="interrupt" type="xs:boolean" use="optional" default="false"/>
  346. <xs:attribute name="interactive" type="xs:boolean" use="optional" default="false"/>
  347. <xs:attribute name="exec_on" type="action_cond_t" use="optional" default="success"/>
  348. <xs:attribute name="update_retcode" type="xs:boolean" use="optional" default="true"/>
  349. </xs:extension>
  350. </xs:simpleContent>
  351. </xs:complexType>
  352. <!--
  353. ********************************************************
  354. * <OVERVIEW> specifies a textual description of the shell.
  355. *
  356. * This should provide instructions about key bindings and
  357. * escape sequences which can be used in the CLI.
  358. *
  359. ********************************************************
  360. -->
  361. <xs:simpleType name="overview_t">
  362. <xs:restriction base="xs:string">
  363. <xs:whiteSpace value="preserve"/>
  364. </xs:restriction>
  365. </xs:simpleType>
  366. <!--
  367. ********************************************************
  368. * <DETAIL> specifies a textual description.
  369. *
  370. * This may be used within the scope of a <COMMAND>
  371. * element, in which case it would typically contain
  372. * detailed usage instructions including examples.
  373. *
  374. * This may also be used within the scope of a <STARTUP>
  375. * element, in which case the text is used as the banner
  376. * details which are displayed on shell startup. This is
  377. * shown before any specified <ACTION> is executed.
  378. *
  379. * This text may also be used in the production of user manuals.
  380. ********************************************************
  381. -->
  382. <xs:simpleType name="detail_t">
  383. <xs:restriction base="xs:string">
  384. <xs:whiteSpace value="preserve"/>
  385. </xs:restriction>
  386. </xs:simpleType>
  387. <!--
  388. *******************************************************
  389. * <NAMESPACE> import commands from specific view to current view.
  390. *
  391. * ref - the view to import commands from
  392. *
  393. * [prefix] - the prefix for imported commands
  394. *
  395. * [prefix_help] - the help for namespace prefix
  396. *
  397. * [help] - a boolean flag to use imported
  398. * commands while help
  399. *
  400. * [completion] - a boolean flag to use imported
  401. * commands while completion
  402. *
  403. * [context_help] - a boolean flag to use imported
  404. * commands while context help
  405. *
  406. * [inherit] - a boolean flag to inherit nested
  407. * namespace commands recursively
  408. *
  409. * [access] - access rights
  410. *
  411. ********************************************************
  412. -->
  413. <xs:complexType name="namespace_t">
  414. <xs:attribute name="ref" type="xs:string" use="required"/>
  415. <xs:attribute name="prefix" type="xs:string" use="optional"/>
  416. <xs:attribute name="prefix_help" type="xs:string" use="optional"/>
  417. <xs:attribute name="help" type="xs:boolean" use="optional" default="false"/>
  418. <xs:attribute name="completion" type="xs:boolean" use="optional" default="true"/>
  419. <xs:attribute name="context_help" type="xs:boolean" use="optional" default="false"/>
  420. <xs:attribute name="inherit" type="xs:boolean" use="optional" default="true"/>
  421. <xs:attribute name="access" type="xs:string" use="optional"/>
  422. </xs:complexType>
  423. <!--
  424. *******************************************************
  425. * <VAR> Specify the variable.
  426. *
  427. *
  428. *
  429. ********************************************************
  430. -->
  431. <xs:complexType name="var_t">
  432. <xs:sequence>
  433. <xs:element ref="ACTION" minOccurs="0"/>
  434. </xs:sequence>
  435. <xs:attribute name="name" type="xs:string" use="required"/>
  436. <xs:attribute name="help" type="xs:string" use="optional"/>
  437. <xs:attribute name="value" type="xs:string" use="optional"/>
  438. <xs:attribute name="dynamic" type="xs:boolean" use="optional" default="false"/>
  439. </xs:complexType>
  440. <!--
  441. *******************************************************
  442. * <WATCHDOG> is used to recover system after errors.
  443. *
  444. ********************************************************
  445. -->
  446. <xs:complexType name="wdog_t">
  447. <xs:sequence>
  448. <xs:element ref="ACTION" minOccurs="1"/>
  449. </xs:sequence>
  450. </xs:complexType>
  451. <!--
  452. *******************************************************
  453. * <HOTKEY> is used to define hotkey actions
  454. *
  455. ********************************************************
  456. -->
  457. <xs:complexType name="hotkey_t">
  458. <xs:attribute name="key" type="xs:string" use="required"/>
  459. <xs:attribute name="cmd" type="xs:string" use="required"/>
  460. </xs:complexType>
  461. <!--
  462. *******************************************************
  463. * <PLUGIN> is used to dynamically load plugins
  464. *
  465. * [rtld_global] - A boolean RTLD_GLOBAL flag for dlopen()
  466. * while plugin loading. Default is "false".
  467. *
  468. ********************************************************
  469. -->
  470. <xs:complexType name="plugin_t">
  471. <xs:simpleContent>
  472. <xs:extension base="xs:string">
  473. <xs:attribute name="name" type="xs:string" use="required"/>
  474. <xs:attribute name="alias" type="xs:string" use="optional"/>
  475. <xs:attribute name="file" type="xs:string" use="optional"/>
  476. <xs:attribute name="rtld_global" type="xs:boolean" use="optional" default="false"/>
  477. </xs:extension>
  478. </xs:simpleContent>
  479. </xs:complexType>
  480. <!--
  481. *******************************************************
  482. * <HOOK> is used to redefine internal hooks
  483. *
  484. * name - The name of internal hook (init, fini, access, log).
  485. *
  486. * [builtin] - specify the name of an internally registered
  487. * function.
  488. *
  489. ********************************************************
  490. -->
  491. <xs:simpleType name="hook_list_e">
  492. <xs:restriction base="xs:string">
  493. <xs:enumeration value="init"/>
  494. <xs:enumeration value="fini"/>
  495. <xs:enumeration value="access"/>
  496. <xs:enumeration value="log"/>
  497. </xs:restriction>
  498. </xs:simpleType>
  499. <xs:complexType name="hook_t">
  500. <xs:attribute name="name" type="hook_list_e"/>
  501. <xs:attribute name="builtin" type="xs:string" use="optional"/>
  502. </xs:complexType>
  503. </xs:schema>