luci.util.html 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  3. <html>
  4. <head>
  5. <title>Reference</title>
  6. <link rel="stylesheet" href="../luadoc.css" type="text/css" />
  7. <!--meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/-->
  8. </head>
  9. <body>
  10. <div id="container">
  11. <div id="product">
  12. <div id="product_logo"></div>
  13. <div id="product_name"><big><b></b></big></div>
  14. <div id="product_description"></div>
  15. </div> <!-- id="product" -->
  16. <div id="main">
  17. <div id="navigation">
  18. <h1>LuaDoc</h1>
  19. <ul>
  20. <li><a href="../index.html">Index</a></li>
  21. </ul>
  22. <!-- Module list -->
  23. <h1>Modules</h1>
  24. <ul>
  25. <li>
  26. <a href="../modules/luci.dispatcher.html">luci.dispatcher</a>
  27. </li>
  28. <li>
  29. <a href="../modules/luci.http.html">luci.http</a>
  30. </li>
  31. <li>
  32. <a href="../modules/luci.http.conditionals.html">luci.http.conditionals</a>
  33. </li>
  34. <li>
  35. <a href="../modules/luci.http.date.html">luci.http.date</a>
  36. </li>
  37. <li>
  38. <a href="../modules/luci.http.mime.html">luci.http.mime</a>
  39. </li>
  40. <li>
  41. <a href="../modules/luci.i18n.html">luci.i18n</a>
  42. </li>
  43. <li>
  44. <a href="../modules/luci.ip.html">luci.ip</a>
  45. </li>
  46. <li>
  47. <a href="../modules/luci.ip.cidr.html">luci.ip.cidr</a>
  48. </li>
  49. <li>
  50. <a href="../modules/luci.json.html">luci.json</a>
  51. </li>
  52. <li>
  53. <a href="../modules/luci.jsonc.html">luci.jsonc</a>
  54. </li>
  55. <li>
  56. <a href="../modules/luci.jsonc.parser.html">luci.jsonc.parser</a>
  57. </li>
  58. <li>
  59. <a href="../modules/luci.model.ipkg.html">luci.model.ipkg</a>
  60. </li>
  61. <li>
  62. <a href="../modules/luci.model.uci.html">luci.model.uci</a>
  63. </li>
  64. <li>
  65. <a href="../modules/luci.rpcc.html">luci.rpcc</a>
  66. </li>
  67. <li>
  68. <a href="../modules/luci.rpcc.ruci.html">luci.rpcc.ruci</a>
  69. </li>
  70. <li>
  71. <a href="../modules/luci.sys.html">luci.sys</a>
  72. </li>
  73. <li>
  74. <a href="../modules/luci.sys.init.html">luci.sys.init</a>
  75. </li>
  76. <li>
  77. <a href="../modules/luci.sys.iptparser.html">luci.sys.iptparser</a>
  78. </li>
  79. <li>
  80. <a href="../modules/luci.sys.net.html">luci.sys.net</a>
  81. </li>
  82. <li>
  83. <a href="../modules/luci.sys.process.html">luci.sys.process</a>
  84. </li>
  85. <li>
  86. <a href="../modules/luci.sys.user.html">luci.sys.user</a>
  87. </li>
  88. <li>
  89. <a href="../modules/luci.sys.wifi.html">luci.sys.wifi</a>
  90. </li>
  91. <li><strong>luci.util</strong></li>
  92. <li>
  93. <a href="../modules/nixio.html">nixio</a>
  94. </li>
  95. <li>
  96. <a href="../modules/nixio.CHANGELOG.html">nixio.CHANGELOG</a>
  97. </li>
  98. <li>
  99. <a href="../modules/nixio.CryptoHash.html">nixio.CryptoHash</a>
  100. </li>
  101. <li>
  102. <a href="../modules/nixio.File.html">nixio.File</a>
  103. </li>
  104. <li>
  105. <a href="../modules/nixio.README.html">nixio.README</a>
  106. </li>
  107. <li>
  108. <a href="../modules/nixio.Socket.html">nixio.Socket</a>
  109. </li>
  110. <li>
  111. <a href="../modules/nixio.TLSContext.html">nixio.TLSContext</a>
  112. </li>
  113. <li>
  114. <a href="../modules/nixio.TLSSocket.html">nixio.TLSSocket</a>
  115. </li>
  116. <li>
  117. <a href="../modules/nixio.UnifiedIO.html">nixio.UnifiedIO</a>
  118. </li>
  119. <li>
  120. <a href="../modules/nixio.bin.html">nixio.bin</a>
  121. </li>
  122. <li>
  123. <a href="../modules/nixio.bit.html">nixio.bit</a>
  124. </li>
  125. <li>
  126. <a href="../modules/nixio.crypto.html">nixio.crypto</a>
  127. </li>
  128. <li>
  129. <a href="../modules/nixio.fs.html">nixio.fs</a>
  130. </li>
  131. </ul>
  132. <!-- File list -->
  133. </div><!-- id="navigation" -->
  134. <div id="content">
  135. <h1>Class <code>luci.util</code></h1>
  136. <p></p>
  137. <h2>Functions</h2>
  138. <table class="function_list">
  139. <tr>
  140. <td class="name" nowrap><a href="#append">append</a>&nbsp;(src, ...)</td>
  141. <td class="summary">
  142. Appends numerically indexed tables or single objects to a given table.</td>
  143. </tr>
  144. <tr>
  145. <td class="name" nowrap><a href="#bigendian">bigendian</a>&nbsp;()</td>
  146. <td class="summary">
  147. Test whether the current system is operating in big endian mode.</td>
  148. </tr>
  149. <tr>
  150. <td class="name" nowrap><a href="#class">class</a>&nbsp;(base)</td>
  151. <td class="summary">
  152. Create a Class object (Python-style object model).</td>
  153. </tr>
  154. <tr>
  155. <td class="name" nowrap><a href="#clone">clone</a>&nbsp;(object, deep)</td>
  156. <td class="summary">
  157. Clones the given object and return it's copy.</td>
  158. </tr>
  159. <tr>
  160. <td class="name" nowrap><a href="#cmatch">cmatch</a>&nbsp;(str, pattern)</td>
  161. <td class="summary">
  162. Count the occurrences of given substring in given string.</td>
  163. </tr>
  164. <tr>
  165. <td class="name" nowrap><a href="#combine">combine</a>&nbsp;(tbl1, tbl2, ...)</td>
  166. <td class="summary">
  167. Combines two or more numerically indexed tables and single objects into one table.</td>
  168. </tr>
  169. <tr>
  170. <td class="name" nowrap><a href="#contains">contains</a>&nbsp;(table, value)</td>
  171. <td class="summary">
  172. Checks whether the given table contains the given value.</td>
  173. </tr>
  174. <tr>
  175. <td class="name" nowrap><a href="#copcall">copcall</a>&nbsp;(f, ...)</td>
  176. <td class="summary">
  177. This is a coroutine-safe drop-in replacement for Lua's "pcall"-function
  178. </td>
  179. </tr>
  180. <tr>
  181. <td class="name" nowrap><a href="#coxpcall">coxpcall</a>&nbsp;(f, err, ...)</td>
  182. <td class="summary">
  183. This is a coroutine-safe drop-in replacement for Lua's "xpcall"-function
  184. </td>
  185. </tr>
  186. <tr>
  187. <td class="name" nowrap><a href="#dumptable">dumptable</a>&nbsp;(t, maxdepth)</td>
  188. <td class="summary">
  189. Recursively dumps a table to stdout, useful for testing and debugging.</td>
  190. </tr>
  191. <tr>
  192. <td class="name" nowrap><a href="#exec">exec</a>&nbsp;(command)</td>
  193. <td class="summary">
  194. Execute given commandline and gather stdout.</td>
  195. </tr>
  196. <tr>
  197. <td class="name" nowrap><a href="#execi">execi</a>&nbsp;(command)</td>
  198. <td class="summary">
  199. Return a line-buffered iterator over the output of given command.</td>
  200. </tr>
  201. <tr>
  202. <td class="name" nowrap><a href="#get_bytecode">get_bytecode</a>&nbsp;(val)</td>
  203. <td class="summary">
  204. Return the current runtime bytecode of the given data.</td>
  205. </tr>
  206. <tr>
  207. <td class="name" nowrap><a href="#imatch">imatch</a>&nbsp;(val)</td>
  208. <td class="summary">
  209. Return a matching iterator for the given value.</td>
  210. </tr>
  211. <tr>
  212. <td class="name" nowrap><a href="#instanceof">instanceof</a>&nbsp;(object, class)</td>
  213. <td class="summary">
  214. Test whether the given object is an instance of the given class.</td>
  215. </tr>
  216. <tr>
  217. <td class="name" nowrap><a href="#keys">keys</a>&nbsp;(t)</td>
  218. <td class="summary">
  219. Retrieve all keys of given associative table.</td>
  220. </tr>
  221. <tr>
  222. <td class="name" nowrap><a href="#kspairs">kspairs</a>&nbsp;(t)</td>
  223. <td class="summary">
  224. Return a key, value iterator for the given table.</td>
  225. </tr>
  226. <tr>
  227. <td class="name" nowrap><a href="#libpath">libpath</a>&nbsp;()</td>
  228. <td class="summary">
  229. Returns the absolute path to LuCI base directory.</td>
  230. </tr>
  231. <tr>
  232. <td class="name" nowrap><a href="#parse_units">parse_units</a>&nbsp;(ustr)</td>
  233. <td class="summary">
  234. Parse certain units from the given string and return the canonical integer
  235. value or 0 if the unit is unknown.</td>
  236. </tr>
  237. <tr>
  238. <td class="name" nowrap><a href="#pcdata">pcdata</a>&nbsp;(value)</td>
  239. <td class="summary">
  240. Create valid XML PCDATA from given string.</td>
  241. </tr>
  242. <tr>
  243. <td class="name" nowrap><a href="#perror">perror</a>&nbsp;(obj)</td>
  244. <td class="summary">
  245. Write given object to stderr.</td>
  246. </tr>
  247. <tr>
  248. <td class="name" nowrap><a href="#restore_data">restore_data</a>&nbsp;(str)</td>
  249. <td class="summary">
  250. Restore data previously serialized with serialize_data().</td>
  251. </tr>
  252. <tr>
  253. <td class="name" nowrap><a href="#serialize_data">serialize_data</a>&nbsp;(val)</td>
  254. <td class="summary">
  255. Recursively serialize given data to lua code, suitable for restoring
  256. with loadstring().</td>
  257. </tr>
  258. <tr>
  259. <td class="name" nowrap><a href="#serialize_json">serialize_json</a>&nbsp;(data, writer)</td>
  260. <td class="summary">
  261. Convert data structure to JSON
  262. </td>
  263. </tr>
  264. <tr>
  265. <td class="name" nowrap><a href="#shellquote">shellquote</a>&nbsp;(value)</td>
  266. <td class="summary">
  267. Safely quote value for use in shell commands.</td>
  268. </tr>
  269. <tr>
  270. <td class="name" nowrap><a href="#spairs">spairs</a>&nbsp;(t, f)</td>
  271. <td class="summary">
  272. Return a key, value iterator which returns the values sorted according to
  273. the provided callback function.</td>
  274. </tr>
  275. <tr>
  276. <td class="name" nowrap><a href="#split">split</a>&nbsp;(str, pat, max, regex)</td>
  277. <td class="summary">
  278. Splits given string on a defined separator sequence and return a table
  279. containing the resulting substrings.</td>
  280. </tr>
  281. <tr>
  282. <td class="name" nowrap><a href="#strip_bytecode">strip_bytecode</a>&nbsp;(code)</td>
  283. <td class="summary">
  284. Strips unnecessary lua bytecode from given string.</td>
  285. </tr>
  286. <tr>
  287. <td class="name" nowrap><a href="#striptags">striptags</a>&nbsp;(value)</td>
  288. <td class="summary">
  289. Strip HTML tags from given string.</td>
  290. </tr>
  291. <tr>
  292. <td class="name" nowrap><a href="#threadlocal">threadlocal</a>&nbsp;()</td>
  293. <td class="summary">
  294. Create a new or get an already existing thread local store associated with
  295. the current active coroutine.</td>
  296. </tr>
  297. <tr>
  298. <td class="name" nowrap><a href="#trim">trim</a>&nbsp;(str)</td>
  299. <td class="summary">
  300. Remove leading and trailing whitespace from given string value.</td>
  301. </tr>
  302. <tr>
  303. <td class="name" nowrap><a href="#ubus">ubus</a>&nbsp;(object, method, values)</td>
  304. <td class="summary">
  305. Issue an ubus call.</td>
  306. </tr>
  307. <tr>
  308. <td class="name" nowrap><a href="#update">update</a>&nbsp;(t, updates)</td>
  309. <td class="summary">
  310. Update values in given table with the values from the second given table.</td>
  311. </tr>
  312. <tr>
  313. <td class="name" nowrap><a href="#urldecode">urldecode</a>&nbsp;(str, decode_plus)</td>
  314. <td class="summary">
  315. Decode an URL-encoded string - optionally decoding the "+" sign to space.</td>
  316. </tr>
  317. <tr>
  318. <td class="name" nowrap><a href="#urlencode">urlencode</a>&nbsp;(str)</td>
  319. <td class="summary">
  320. URL-encode given string.</td>
  321. </tr>
  322. <tr>
  323. <td class="name" nowrap><a href="#vspairs">vspairs</a>&nbsp;(t)</td>
  324. <td class="summary">
  325. Return a key, value iterator for the given table.</td>
  326. </tr>
  327. </table>
  328. <br/>
  329. <br/>
  330. <h2><a name="functions"></a>Functions</h2>
  331. <dl class="function">
  332. <dt><a name="append"></a><strong>append</strong>&nbsp;(src, ...)</dt>
  333. <dd>
  334. Appends numerically indexed tables or single objects to a given table.
  335. <h3>Parameters</h3>
  336. <ul>
  337. <li>
  338. src: Target table
  339. </li>
  340. <li>
  341. ...: Objects to insert
  342. </li>
  343. </ul>
  344. <h3>Return value:</h3>
  345. Target table
  346. </dd>
  347. <dt><a name="bigendian"></a><strong>bigendian</strong>&nbsp;()</dt>
  348. <dd>
  349. Test whether the current system is operating in big endian mode.
  350. <h3>Return value:</h3>
  351. Boolean value indicating whether system is big endian
  352. </dd>
  353. <dt><a name="class"></a><strong>class</strong>&nbsp;(base)</dt>
  354. <dd>
  355. Create a Class object (Python-style object model).
  356. The class object can be instantiated by calling itself.
  357. Any class functions or shared parameters can be attached to this object.
  358. Attaching a table to the class object makes this table shared between
  359. all instances of this class. For object parameters use the __init__ function.
  360. Classes can inherit member functions and values from a base class.
  361. Class can be instantiated by calling them. All parameters will be passed
  362. to the __init__ function of this class - if such a function exists.
  363. The __init__ function must be used to set any object parameters that are not shared
  364. with other objects of this class. Any return values will be ignored.
  365. <h3>Parameters</h3>
  366. <ul>
  367. <li>
  368. base: The base class to inherit from (optional)
  369. </li>
  370. </ul>
  371. <h3>Return value:</h3>
  372. A class object
  373. <h3>See also:</h3>
  374. <ul>
  375. <li><a href="#instanceof">
  376. instanceof
  377. </a>
  378. <li><a href="#clone">
  379. clone
  380. </a>
  381. </ul>
  382. </dd>
  383. <dt><a name="clone"></a><strong>clone</strong>&nbsp;(object, deep)</dt>
  384. <dd>
  385. Clones the given object and return it's copy.
  386. <h3>Parameters</h3>
  387. <ul>
  388. <li>
  389. object: Table value to clone
  390. </li>
  391. <li>
  392. deep: Boolean indicating whether to do recursive cloning
  393. </li>
  394. </ul>
  395. <h3>Return value:</h3>
  396. Cloned table value
  397. </dd>
  398. <dt><a name="cmatch"></a><strong>cmatch</strong>&nbsp;(str, pattern)</dt>
  399. <dd>
  400. Count the occurrences of given substring in given string.
  401. <h3>Parameters</h3>
  402. <ul>
  403. <li>
  404. str: String to search in
  405. </li>
  406. <li>
  407. pattern: String containing pattern to find
  408. </li>
  409. </ul>
  410. <h3>Return value:</h3>
  411. Number of found occurrences
  412. </dd>
  413. <dt><a name="combine"></a><strong>combine</strong>&nbsp;(tbl1, tbl2, ...)</dt>
  414. <dd>
  415. Combines two or more numerically indexed tables and single objects into one table.
  416. <h3>Parameters</h3>
  417. <ul>
  418. <li>
  419. tbl1: Table value to combine
  420. </li>
  421. <li>
  422. tbl2: Table value to combine
  423. </li>
  424. <li>
  425. ...: More tables to combine
  426. </li>
  427. </ul>
  428. <h3>Return value:</h3>
  429. Table value containing all values of given tables
  430. </dd>
  431. <dt><a name="contains"></a><strong>contains</strong>&nbsp;(table, value)</dt>
  432. <dd>
  433. Checks whether the given table contains the given value.
  434. <h3>Parameters</h3>
  435. <ul>
  436. <li>
  437. table: Table value
  438. </li>
  439. <li>
  440. value: Value to search within the given table
  441. </li>
  442. </ul>
  443. <h3>Return value:</h3>
  444. Number indicating the first index at which the given value occurs
  445. within table or false.
  446. </dd>
  447. <dt><a name="copcall"></a><strong>copcall</strong>&nbsp;(f, ...)</dt>
  448. <dd>
  449. This is a coroutine-safe drop-in replacement for Lua's "pcall"-function
  450. <h3>Parameters</h3>
  451. <ul>
  452. <li>
  453. f: Lua function to be called protected
  454. </li>
  455. <li>
  456. ...: Parameters passed to the function
  457. </li>
  458. </ul>
  459. <h3>Return value:</h3>
  460. A boolean whether the function call succeeded and the returns
  461. values of the function or the error object
  462. </dd>
  463. <dt><a name="coxpcall"></a><strong>coxpcall</strong>&nbsp;(f, err, ...)</dt>
  464. <dd>
  465. This is a coroutine-safe drop-in replacement for Lua's "xpcall"-function
  466. <h3>Parameters</h3>
  467. <ul>
  468. <li>
  469. f: Lua function to be called protected
  470. </li>
  471. <li>
  472. err: Custom error handler
  473. </li>
  474. <li>
  475. ...: Parameters passed to the function
  476. </li>
  477. </ul>
  478. <h3>Return value:</h3>
  479. A boolean whether the function call succeeded and the return
  480. values of either the function or the error handler
  481. </dd>
  482. <dt><a name="dumptable"></a><strong>dumptable</strong>&nbsp;(t, maxdepth)</dt>
  483. <dd>
  484. Recursively dumps a table to stdout, useful for testing and debugging.
  485. <h3>Parameters</h3>
  486. <ul>
  487. <li>
  488. t: Table value to dump
  489. </li>
  490. <li>
  491. maxdepth: Maximum depth
  492. </li>
  493. </ul>
  494. <h3>Return value:</h3>
  495. Always nil
  496. </dd>
  497. <dt><a name="exec"></a><strong>exec</strong>&nbsp;(command)</dt>
  498. <dd>
  499. Execute given commandline and gather stdout.
  500. <h3>Parameters</h3>
  501. <ul>
  502. <li>
  503. command: String containing command to execute
  504. </li>
  505. </ul>
  506. <h3>Return value:</h3>
  507. String containing the command's stdout
  508. </dd>
  509. <dt><a name="execi"></a><strong>execi</strong>&nbsp;(command)</dt>
  510. <dd>
  511. Return a line-buffered iterator over the output of given command.
  512. <h3>Parameters</h3>
  513. <ul>
  514. <li>
  515. command: String containing the command to execute
  516. </li>
  517. </ul>
  518. <h3>Return value:</h3>
  519. Iterator
  520. </dd>
  521. <dt><a name="get_bytecode"></a><strong>get_bytecode</strong>&nbsp;(val)</dt>
  522. <dd>
  523. Return the current runtime bytecode of the given data. The byte code
  524. will be stripped before it is returned.
  525. <h3>Parameters</h3>
  526. <ul>
  527. <li>
  528. val: Value to return as bytecode
  529. </li>
  530. </ul>
  531. <h3>Return value:</h3>
  532. String value containing the bytecode of the given data
  533. </dd>
  534. <dt><a name="imatch"></a><strong>imatch</strong>&nbsp;(val)</dt>
  535. <dd>
  536. Return a matching iterator for the given value.
  537. The iterator will return one token per invocation, the tokens are separated by
  538. whitespace. If the input value is a table, it is transformed into a string first.
  539. A nil value will result in a valid iterator which aborts with the first invocation.
  540. <h3>Parameters</h3>
  541. <ul>
  542. <li>
  543. val: The value to scan (table, string or nil)
  544. </li>
  545. </ul>
  546. <h3>Return value:</h3>
  547. Iterator which returns one token per call
  548. </dd>
  549. <dt><a name="instanceof"></a><strong>instanceof</strong>&nbsp;(object, class)</dt>
  550. <dd>
  551. Test whether the given object is an instance of the given class.
  552. <h3>Parameters</h3>
  553. <ul>
  554. <li>
  555. object: Object instance
  556. </li>
  557. <li>
  558. class: Class object to test against
  559. </li>
  560. </ul>
  561. <h3>Return value:</h3>
  562. Boolean indicating whether the object is an instance
  563. <h3>See also:</h3>
  564. <ul>
  565. <li><a href="#class">
  566. class
  567. </a>
  568. <li><a href="#clone">
  569. clone
  570. </a>
  571. </ul>
  572. </dd>
  573. <dt><a name="keys"></a><strong>keys</strong>&nbsp;(t)</dt>
  574. <dd>
  575. Retrieve all keys of given associative table.
  576. <h3>Parameters</h3>
  577. <ul>
  578. <li>
  579. t: Table to extract keys from
  580. </li>
  581. </ul>
  582. <h3>Return value:</h3>
  583. Sorted table containing the keys
  584. </dd>
  585. <dt><a name="kspairs"></a><strong>kspairs</strong>&nbsp;(t)</dt>
  586. <dd>
  587. Return a key, value iterator for the given table.
  588. The table pairs are sorted by key.
  589. <h3>Parameters</h3>
  590. <ul>
  591. <li>
  592. t: The table to iterate
  593. </li>
  594. </ul>
  595. <h3>Return value:</h3>
  596. Function value containing the corresponding iterator
  597. </dd>
  598. <dt><a name="libpath"></a><strong>libpath</strong>&nbsp;()</dt>
  599. <dd>
  600. Returns the absolute path to LuCI base directory.
  601. <h3>Return value:</h3>
  602. String containing the directory path
  603. </dd>
  604. <dt><a name="parse_units"></a><strong>parse_units</strong>&nbsp;(ustr)</dt>
  605. <dd>
  606. Parse certain units from the given string and return the canonical integer
  607. value or 0 if the unit is unknown.
  608. Upper- or lower case is irrelevant.
  609. Recognized units are:
  610. o "y" - one year (60*60*24*366)
  611. o "m" - one month (60*60*24*31)
  612. o "w" - one week (60*60*24*7)
  613. o "d" - one day (60*60*24)
  614. o "h" - one hour (60*60)
  615. o "min" - one minute (60)
  616. o "kb" - one kilobyte (1024)
  617. o "mb" - one megabyte (1024*1024)
  618. o "gb" - one gigabyte (1024*1024*1024)
  619. o "kib" - one si kilobyte (1000)
  620. o "mib" - one si megabyte (1000*1000)
  621. o "gib" - one si gigabyte (1000*1000*1000)
  622. <h3>Parameters</h3>
  623. <ul>
  624. <li>
  625. ustr: String containing a numerical value with trailing unit
  626. </li>
  627. </ul>
  628. <h3>Return value:</h3>
  629. Number containing the canonical value
  630. </dd>
  631. <dt><a name="pcdata"></a><strong>pcdata</strong>&nbsp;(value)</dt>
  632. <dd>
  633. Create valid XML PCDATA from given string.
  634. <h3>Parameters</h3>
  635. <ul>
  636. <li>
  637. value: String value containing the data to escape
  638. </li>
  639. </ul>
  640. <h3>Return value:</h3>
  641. String value containing the escaped data
  642. </dd>
  643. <dt><a name="perror"></a><strong>perror</strong>&nbsp;(obj)</dt>
  644. <dd>
  645. Write given object to stderr.
  646. <h3>Parameters</h3>
  647. <ul>
  648. <li>
  649. obj: Value to write to stderr
  650. </li>
  651. </ul>
  652. <h3>Return value:</h3>
  653. Boolean indicating whether the write operation was successful
  654. </dd>
  655. <dt><a name="restore_data"></a><strong>restore_data</strong>&nbsp;(str)</dt>
  656. <dd>
  657. Restore data previously serialized with serialize_data().
  658. <h3>Parameters</h3>
  659. <ul>
  660. <li>
  661. str: String containing the data to restore
  662. </li>
  663. </ul>
  664. <h3>Return value:</h3>
  665. Value containing the restored data structure
  666. <h3>See also:</h3>
  667. <ul>
  668. <li><a href="#serialize_data">
  669. serialize_data
  670. </a>
  671. <li><a href="#get_bytecode">
  672. get_bytecode
  673. </a>
  674. </ul>
  675. </dd>
  676. <dt><a name="serialize_data"></a><strong>serialize_data</strong>&nbsp;(val)</dt>
  677. <dd>
  678. Recursively serialize given data to lua code, suitable for restoring
  679. with loadstring().
  680. <h3>Parameters</h3>
  681. <ul>
  682. <li>
  683. val: Value containing the data to serialize
  684. </li>
  685. </ul>
  686. <h3>Return value:</h3>
  687. String value containing the serialized code
  688. <h3>See also:</h3>
  689. <ul>
  690. <li><a href="#restore_data">
  691. restore_data
  692. </a>
  693. <li><a href="#get_bytecode">
  694. get_bytecode
  695. </a>
  696. </ul>
  697. </dd>
  698. <dt><a name="serialize_json"></a><strong>serialize_json</strong>&nbsp;(data, writer)</dt>
  699. <dd>
  700. Convert data structure to JSON
  701. <h3>Parameters</h3>
  702. <ul>
  703. <li>
  704. data: The data to serialize
  705. </li>
  706. <li>
  707. writer: A function to write a chunk of JSON data (optional)
  708. </li>
  709. </ul>
  710. <h3>Return value:</h3>
  711. String containing the JSON if called without write callback
  712. </dd>
  713. <dt><a name="shellquote"></a><strong>shellquote</strong>&nbsp;(value)</dt>
  714. <dd>
  715. Safely quote value for use in shell commands.
  716. <h3>Parameters</h3>
  717. <ul>
  718. <li>
  719. value: String containing the value to quote
  720. </li>
  721. </ul>
  722. <h3>Return value:</h3>
  723. Single-quote enclosed string with embedded quotes escaped
  724. </dd>
  725. <dt><a name="spairs"></a><strong>spairs</strong>&nbsp;(t, f)</dt>
  726. <dd>
  727. Return a key, value iterator which returns the values sorted according to
  728. the provided callback function.
  729. <h3>Parameters</h3>
  730. <ul>
  731. <li>
  732. t: The table to iterate
  733. </li>
  734. <li>
  735. f: A callback function to decide the order of elements
  736. </li>
  737. </ul>
  738. <h3>Return value:</h3>
  739. Function value containing the corresponding iterator
  740. </dd>
  741. <dt><a name="split"></a><strong>split</strong>&nbsp;(str, pat, max, regex)</dt>
  742. <dd>
  743. Splits given string on a defined separator sequence and return a table
  744. containing the resulting substrings.
  745. The optional max parameter specifies the number of bytes to process,
  746. regardless of the actual length of the given string. The optional last
  747. parameter, regex, specifies whether the separator sequence is
  748. nterpreted as regular expression.
  749. <h3>Parameters</h3>
  750. <ul>
  751. <li>
  752. str: String value containing the data to split up
  753. </li>
  754. <li>
  755. pat: String with separator pattern (optional, defaults to "\n")
  756. </li>
  757. <li>
  758. max: Maximum times to split (optional)
  759. </li>
  760. <li>
  761. regex: Boolean indicating whether to interpret the separator
  762. pattern as regular expression (optional, default is false)
  763. </li>
  764. </ul>
  765. <h3>Return value:</h3>
  766. Table containing the resulting substrings
  767. </dd>
  768. <dt><a name="strip_bytecode"></a><strong>strip_bytecode</strong>&nbsp;(code)</dt>
  769. <dd>
  770. Strips unnecessary lua bytecode from given string.
  771. Information like line numbers and debugging numbers will be discarded.
  772. Original version by Peter Cawley (http://lua-users.org/lists/lua-l/2008-02/msg01158.html)
  773. <h3>Parameters</h3>
  774. <ul>
  775. <li>
  776. code: String value containing the original lua byte code
  777. </li>
  778. </ul>
  779. <h3>Return value:</h3>
  780. String value containing the stripped lua byte code
  781. </dd>
  782. <dt><a name="striptags"></a><strong>striptags</strong>&nbsp;(value)</dt>
  783. <dd>
  784. Strip HTML tags from given string.
  785. <h3>Parameters</h3>
  786. <ul>
  787. <li>
  788. value: String containing the HTML text
  789. </li>
  790. </ul>
  791. <h3>Return value:</h3>
  792. String with HTML tags stripped of
  793. </dd>
  794. <dt><a name="threadlocal"></a><strong>threadlocal</strong>&nbsp;()</dt>
  795. <dd>
  796. Create a new or get an already existing thread local store associated with
  797. the current active coroutine.
  798. A thread local store is private a table object
  799. whose values can't be accessed from outside of the running coroutine.
  800. <h3>Return value:</h3>
  801. Table value representing the corresponding thread local store
  802. </dd>
  803. <dt><a name="trim"></a><strong>trim</strong>&nbsp;(str)</dt>
  804. <dd>
  805. Remove leading and trailing whitespace from given string value.
  806. <h3>Parameters</h3>
  807. <ul>
  808. <li>
  809. str: String value containing whitespace padded data
  810. </li>
  811. </ul>
  812. <h3>Return value:</h3>
  813. String value with leading and trailing space removed
  814. </dd>
  815. <dt><a name="ubus"></a><strong>ubus</strong>&nbsp;(object, method, values)</dt>
  816. <dd>
  817. Issue an ubus call.
  818. <h3>Parameters</h3>
  819. <ul>
  820. <li>
  821. object: String containing the ubus object to call
  822. </li>
  823. <li>
  824. method: String containing the ubus method to call
  825. </li>
  826. <li>
  827. values: Table containing the values to pass
  828. </li>
  829. </ul>
  830. <h3>Return value:</h3>
  831. Table containin the ubus result
  832. </dd>
  833. <dt><a name="update"></a><strong>update</strong>&nbsp;(t, updates)</dt>
  834. <dd>
  835. Update values in given table with the values from the second given table.
  836. Both table are - in fact - merged together.
  837. <h3>Parameters</h3>
  838. <ul>
  839. <li>
  840. t: Table which should be updated
  841. </li>
  842. <li>
  843. updates: Table containing the values to update
  844. </li>
  845. </ul>
  846. <h3>Return value:</h3>
  847. Always nil
  848. </dd>
  849. <dt><a name="urldecode"></a><strong>urldecode</strong>&nbsp;(str, decode_plus)</dt>
  850. <dd>
  851. Decode an URL-encoded string - optionally decoding the "+" sign to space.
  852. <h3>Parameters</h3>
  853. <ul>
  854. <li>
  855. str: Input string in x-www-urlencoded format
  856. </li>
  857. <li>
  858. decode_plus: Decode "+" signs to spaces if true (optional)
  859. </li>
  860. </ul>
  861. <h3>Return value:</h3>
  862. The decoded string
  863. <h3>See also:</h3>
  864. <ul>
  865. <li><a href="#urlencode">
  866. urlencode
  867. </a>
  868. </ul>
  869. </dd>
  870. <dt><a name="urlencode"></a><strong>urlencode</strong>&nbsp;(str)</dt>
  871. <dd>
  872. URL-encode given string.
  873. <h3>Parameters</h3>
  874. <ul>
  875. <li>
  876. str: String to encode
  877. </li>
  878. </ul>
  879. <h3>Return value:</h3>
  880. String containing the encoded data
  881. <h3>See also:</h3>
  882. <ul>
  883. <li><a href="#urldecode">
  884. urldecode
  885. </a>
  886. </ul>
  887. </dd>
  888. <dt><a name="vspairs"></a><strong>vspairs</strong>&nbsp;(t)</dt>
  889. <dd>
  890. Return a key, value iterator for the given table.
  891. The table pairs are sorted by value.
  892. <h3>Parameters</h3>
  893. <ul>
  894. <li>
  895. t: The table to iterate
  896. </li>
  897. </ul>
  898. <h3>Return value:</h3>
  899. Function value containing the corresponding iterator
  900. </dd>
  901. </dl>
  902. </div> <!-- id="content" -->
  903. </div> <!-- id="main" -->
  904. <div id="about">
  905. <p><a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0!" height="31" width="88" /></a></p>
  906. </div> <!-- id="about" -->
  907. </div> <!-- id="container" -->
  908. </body>
  909. </html>