klish.xsd 19 KB

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