1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717 |
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
- <html>
- <head>
- <title>Reference</title>
- <link rel="stylesheet" href="../luadoc.css" type="text/css" />
- <!--meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/-->
- </head>
- <body>
- <div id="container">
- <div id="product">
- <div id="product_logo"></div>
- <div id="product_name"><big><b></b></big></div>
- <div id="product_description"></div>
- </div> <!-- id="product" -->
- <div id="main">
- <div id="navigation">
- <h1>LuaDoc</h1>
- <ul>
-
- <li><a href="../index.html">Index</a></li>
-
- </ul>
- <!-- Module list -->
- <h1>Modules</h1>
- <ul>
- <li>
- <a href="../modules/luci.dispatcher.html">luci.dispatcher</a>
- </li>
- <li>
- <a href="../modules/luci.http.html">luci.http</a>
- </li>
- <li>
- <a href="../modules/luci.http.protocol.html">luci.http.protocol</a>
- </li>
- <li>
- <a href="../modules/luci.http.protocol.conditionals.html">luci.http.protocol.conditionals</a>
- </li>
- <li>
- <a href="../modules/luci.http.protocol.date.html">luci.http.protocol.date</a>
- </li>
- <li>
- <a href="../modules/luci.http.protocol.mime.html">luci.http.protocol.mime</a>
- </li>
- <li>
- <a href="../modules/luci.i18n.html">luci.i18n</a>
- </li>
- <li>
- <a href="../modules/luci.ip.html">luci.ip</a>
- </li>
- <li>
- <a href="../modules/luci.ip.cidr.html">luci.ip.cidr</a>
- </li>
- <li>
- <a href="../modules/luci.json.html">luci.json</a>
- </li>
- <li>
- <a href="../modules/luci.jsonc.html">luci.jsonc</a>
- </li>
- <li>
- <a href="../modules/luci.jsonc.parser.html">luci.jsonc.parser</a>
- </li>
- <li>
- <a href="../modules/luci.model.ipkg.html">luci.model.ipkg</a>
- </li>
- <li>
- <a href="../modules/luci.model.uci.html">luci.model.uci</a>
- </li>
- <li>
- <a href="../modules/luci.rpcc.html">luci.rpcc</a>
- </li>
- <li>
- <a href="../modules/luci.rpcc.ruci.html">luci.rpcc.ruci</a>
- </li>
- <li>
- <a href="../modules/luci.sys.html">luci.sys</a>
- </li>
- <li>
- <a href="../modules/luci.sys.init.html">luci.sys.init</a>
- </li>
- <li>
- <a href="../modules/luci.sys.iptparser.html">luci.sys.iptparser</a>
- </li>
- <li>
- <a href="../modules/luci.sys.net.html">luci.sys.net</a>
- </li>
- <li>
- <a href="../modules/luci.sys.process.html">luci.sys.process</a>
- </li>
- <li>
- <a href="../modules/luci.sys.user.html">luci.sys.user</a>
- </li>
- <li>
- <a href="../modules/luci.sys.wifi.html">luci.sys.wifi</a>
- </li>
- <li><strong>luci.util</strong></li>
-
- <li>
- <a href="../modules/nixio.html">nixio</a>
- </li>
- <li>
- <a href="../modules/nixio.CHANGELOG.html">nixio.CHANGELOG</a>
- </li>
- <li>
- <a href="../modules/nixio.CryptoHash.html">nixio.CryptoHash</a>
- </li>
- <li>
- <a href="../modules/nixio.File.html">nixio.File</a>
- </li>
- <li>
- <a href="../modules/nixio.README.html">nixio.README</a>
- </li>
- <li>
- <a href="../modules/nixio.Socket.html">nixio.Socket</a>
- </li>
- <li>
- <a href="../modules/nixio.TLSContext.html">nixio.TLSContext</a>
- </li>
- <li>
- <a href="../modules/nixio.TLSSocket.html">nixio.TLSSocket</a>
- </li>
- <li>
- <a href="../modules/nixio.UnifiedIO.html">nixio.UnifiedIO</a>
- </li>
- <li>
- <a href="../modules/nixio.bin.html">nixio.bin</a>
- </li>
- <li>
- <a href="../modules/nixio.bit.html">nixio.bit</a>
- </li>
- <li>
- <a href="../modules/nixio.crypto.html">nixio.crypto</a>
- </li>
- <li>
- <a href="../modules/nixio.fs.html">nixio.fs</a>
- </li>
- </ul>
- <!-- File list -->
- </div><!-- id="navigation" -->
- <div id="content">
- <h1>Class <code>luci.util</code></h1>
- <p></p>
- <h2>Functions</h2>
- <table class="function_list">
- <tr>
- <td class="name" nowrap><a href="#append">append</a> (src, ...)</td>
- <td class="summary">
-
- Appends numerically indexed tables or single objects to a given table.</td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#bigendian">bigendian</a> ()</td>
- <td class="summary">
-
- Test whether the current system is operating in big endian mode.</td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#class">class</a> (base)</td>
- <td class="summary">
-
- Create a Class object (Python-style object model).</td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#clone">clone</a> (object, deep)</td>
- <td class="summary">
-
- Clones the given object and return it's copy.</td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#cmatch">cmatch</a> (str, pattern)</td>
- <td class="summary">
-
- Count the occurrences of given substring in given string.</td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#combine">combine</a> (tbl1, tbl2, ...)</td>
- <td class="summary">
-
- Combines two or more numerically indexed tables and single objects into one table.</td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#contains">contains</a> (table, value)</td>
- <td class="summary">
-
- Checks whether the given table contains the given value.</td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#copcall">copcall</a> (f, ...)</td>
- <td class="summary">
-
- This is a coroutine-safe drop-in replacement for Lua's "pcall"-function
- </td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#coxpcall">coxpcall</a> (f, err, ...)</td>
- <td class="summary">
-
- This is a coroutine-safe drop-in replacement for Lua's "xpcall"-function
- </td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#dtable">dtable</a> ()</td>
- <td class="summary">
-
- Create a dynamic table which automatically creates subtables.</td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#dumptable">dumptable</a> (t, maxdepth)</td>
- <td class="summary">
-
- Recursively dumps a table to stdout, useful for testing and debugging.</td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#exec">exec</a> (command)</td>
- <td class="summary">
-
- Execute given commandline and gather stdout.</td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#execi">execi</a> (command)</td>
- <td class="summary">
-
- Return a line-buffered iterator over the output of given command.</td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#get_bytecode">get_bytecode</a> (val)</td>
- <td class="summary">
-
- Return the current runtime bytecode of the given data.</td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#imatch">imatch</a> (val)</td>
- <td class="summary">
-
- Return a matching iterator for the given value.</td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#instanceof">instanceof</a> (object, class)</td>
- <td class="summary">
-
- Test whether the given object is an instance of the given class.</td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#keys">keys</a> (t)</td>
- <td class="summary">
-
- Retrieve all keys of given associative table.</td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#kspairs">kspairs</a> (t)</td>
- <td class="summary">
-
- Return a key, value iterator for the given table.</td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#libpath">libpath</a> ()</td>
- <td class="summary">
-
- Returns the absolute path to LuCI base directory.</td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#parse_units">parse_units</a> (ustr)</td>
- <td class="summary">
-
- Parse certain units from the given string and return the canonical integer
-
- value or 0 if the unit is unknown.</td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#pcdata">pcdata</a> (value)</td>
- <td class="summary">
-
- Create valid XML PCDATA from given string.</td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#perror">perror</a> (obj)</td>
- <td class="summary">
-
- Write given object to stderr.</td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#restore_data">restore_data</a> (str)</td>
- <td class="summary">
-
- Restore data previously serialized with serialize_data().</td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#serialize_data">serialize_data</a> (val)</td>
- <td class="summary">
-
- Recursively serialize given data to lua code, suitable for restoring
-
- with loadstring().</td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#serialize_json">serialize_json</a> (data, writer)</td>
- <td class="summary">
-
- Convert data structure to JSON
- </td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#spairs">spairs</a> (t, f)</td>
- <td class="summary">
-
- Return a key, value iterator which returns the values sorted according to
-
- the provided callback function.</td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#split">split</a> (str, pat, max, regex)</td>
- <td class="summary">
-
- Splits given string on a defined separator sequence and return a table
-
- containing the resulting substrings.</td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#strip_bytecode">strip_bytecode</a> (code)</td>
- <td class="summary">
-
- Strips unnescessary lua bytecode from given string.</td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#striptags">striptags</a> (value)</td>
- <td class="summary">
-
- Strip HTML tags from given string.</td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#threadlocal">threadlocal</a> ()</td>
- <td class="summary">
-
- Create a new or get an already existing thread local store associated with
-
- the current active coroutine.</td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#trim">trim</a> (str)</td>
- <td class="summary">
-
- Remove leading and trailing whitespace from given string value.</td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#ubus">ubus</a> (object, method, values)</td>
- <td class="summary">
-
- Issue an ubus call.</td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#update">update</a> (t, updates)</td>
- <td class="summary">
-
- Update values in given table with the values from the second given table.</td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#vspairs">vspairs</a> (t)</td>
- <td class="summary">
-
- Return a key, value iterator for the given table.</td>
- </tr>
- </table>
- <br/>
- <br/>
- <h2><a name="functions"></a>Functions</h2>
- <dl class="function">
- <dt><a name="append"></a><strong>append</strong> (src, ...)</dt>
- <dd>
-
- Appends numerically indexed tables or single objects to a given table.
- <h3>Parameters</h3>
- <ul>
-
- <li>
- src: Target table
- </li>
-
- <li>
- ...: Objects to insert
- </li>
-
- </ul>
- <h3>Return value:</h3>
- Target table
- </dd>
- <dt><a name="bigendian"></a><strong>bigendian</strong> ()</dt>
- <dd>
-
- Test whether the current system is operating in big endian mode.
- <h3>Return value:</h3>
- Boolean value indicating whether system is big endian
- </dd>
- <dt><a name="class"></a><strong>class</strong> (base)</dt>
- <dd>
-
- Create a Class object (Python-style object model).
-
- The class object can be instantiated by calling itself.
- Any class functions or shared parameters can be attached to this object.
- Attaching a table to the class object makes this table shared between
- all instances of this class. For object parameters use the __init__ function.
- Classes can inherit member functions and values from a base class.
- Class can be instantiated by calling them. All parameters will be passed
- to the __init__ function of this class - if such a function exists.
- The __init__ function must be used to set any object parameters that are not shared
- with other objects of this class. Any return values will be ignored.
- <h3>Parameters</h3>
- <ul>
-
- <li>
- base: The base class to inherit from (optional)
- </li>
-
- </ul>
- <h3>Return value:</h3>
- A class object
- <h3>See also:</h3>
- <ul>
-
- <li><a href="#instanceof">
- instanceof
- </a>
-
- <li><a href="#clone">
- clone
- </a>
-
- </ul>
- </dd>
- <dt><a name="clone"></a><strong>clone</strong> (object, deep)</dt>
- <dd>
-
- Clones the given object and return it's copy.
- <h3>Parameters</h3>
- <ul>
-
- <li>
- object: Table value to clone
- </li>
-
- <li>
- deep: Boolean indicating whether to do recursive cloning
- </li>
-
- </ul>
- <h3>Return value:</h3>
- Cloned table value
- </dd>
- <dt><a name="cmatch"></a><strong>cmatch</strong> (str, pattern)</dt>
- <dd>
-
- Count the occurrences of given substring in given string.
- <h3>Parameters</h3>
- <ul>
-
- <li>
- str: String to search in
- </li>
-
- <li>
- pattern: String containing pattern to find
- </li>
-
- </ul>
- <h3>Return value:</h3>
- Number of found occurrences
- </dd>
- <dt><a name="combine"></a><strong>combine</strong> (tbl1, tbl2, ...)</dt>
- <dd>
-
- Combines two or more numerically indexed tables and single objects into one table.
- <h3>Parameters</h3>
- <ul>
-
- <li>
- tbl1: Table value to combine
- </li>
-
- <li>
- tbl2: Table value to combine
- </li>
-
- <li>
- ...: More tables to combine
- </li>
-
- </ul>
- <h3>Return value:</h3>
- Table value containing all values of given tables
- </dd>
- <dt><a name="contains"></a><strong>contains</strong> (table, value)</dt>
- <dd>
-
- Checks whether the given table contains the given value.
- <h3>Parameters</h3>
- <ul>
-
- <li>
- table: Table value
- </li>
-
- <li>
- value: Value to search within the given table
- </li>
-
- </ul>
- <h3>Return value:</h3>
- number indicating the first index at which the given value occurs
- within table or false.
- </dd>
- <dt><a name="copcall"></a><strong>copcall</strong> (f, ...)</dt>
- <dd>
-
- This is a coroutine-safe drop-in replacement for Lua's "pcall"-function
- <h3>Parameters</h3>
- <ul>
-
- <li>
- f: Lua function to be called protected
- </li>
-
- <li>
- ...: Parameters passed to the function
- </li>
-
- </ul>
- <h3>Return value:</h3>
- A boolean whether the function call succeeded and the returns
- values of the function or the error object
- </dd>
- <dt><a name="coxpcall"></a><strong>coxpcall</strong> (f, err, ...)</dt>
- <dd>
-
- This is a coroutine-safe drop-in replacement for Lua's "xpcall"-function
- <h3>Parameters</h3>
- <ul>
-
- <li>
- f: Lua function to be called protected
- </li>
-
- <li>
- err: Custom error handler
- </li>
-
- <li>
- ...: Parameters passed to the function
- </li>
-
- </ul>
- <h3>Return value:</h3>
- A boolean whether the function call succeeded and the return
- values of either the function or the error handler
- </dd>
- <dt><a name="dtable"></a><strong>dtable</strong> ()</dt>
- <dd>
-
- Create a dynamic table which automatically creates subtables.
- <h3>Return value:</h3>
- Dynamic Table
- </dd>
- <dt><a name="dumptable"></a><strong>dumptable</strong> (t, maxdepth)</dt>
- <dd>
-
- Recursively dumps a table to stdout, useful for testing and debugging.
- <h3>Parameters</h3>
- <ul>
-
- <li>
- t: Table value to dump
- </li>
-
- <li>
- maxdepth: Maximum depth
- </li>
-
- </ul>
- <h3>Return value:</h3>
- Always nil
- </dd>
- <dt><a name="exec"></a><strong>exec</strong> (command)</dt>
- <dd>
-
- Execute given commandline and gather stdout.
- <h3>Parameters</h3>
- <ul>
-
- <li>
- command: String containing command to execute
- </li>
-
- </ul>
- <h3>Return value:</h3>
- String containing the command's stdout
- </dd>
- <dt><a name="execi"></a><strong>execi</strong> (command)</dt>
- <dd>
-
- Return a line-buffered iterator over the output of given command.
- <h3>Parameters</h3>
- <ul>
-
- <li>
- command: String containing the command to execute
- </li>
-
- </ul>
- <h3>Return value:</h3>
- Iterator
- </dd>
- <dt><a name="get_bytecode"></a><strong>get_bytecode</strong> (val)</dt>
- <dd>
-
- Return the current runtime bytecode of the given data. The byte code
-
- will be stripped before it is returned.
- <h3>Parameters</h3>
- <ul>
-
- <li>
- val: Value to return as bytecode
- </li>
-
- </ul>
- <h3>Return value:</h3>
- String value containing the bytecode of the given data
- </dd>
- <dt><a name="imatch"></a><strong>imatch</strong> (val)</dt>
- <dd>
-
- Return a matching iterator for the given value. The iterator will return
-
- one token per invocation, the tokens are separated by whitespace. If the
- input value is a table, it is transformed into a string first. A nil value
- will result in a valid interator which aborts with the first invocation.
- <h3>Parameters</h3>
- <ul>
-
- <li>
- val: The value to scan (table, string or nil)
- </li>
-
- </ul>
- <h3>Return value:</h3>
- Iterator which returns one token per call
- </dd>
- <dt><a name="instanceof"></a><strong>instanceof</strong> (object, class)</dt>
- <dd>
-
- Test whether the given object is an instance of the given class.
- <h3>Parameters</h3>
- <ul>
-
- <li>
- object: Object instance
- </li>
-
- <li>
- class: Class object to test against
- </li>
-
- </ul>
- <h3>Return value:</h3>
- Boolean indicating whether the object is an instance
- <h3>See also:</h3>
- <ul>
-
- <li><a href="#class">
- class
- </a>
-
- <li><a href="#clone">
- clone
- </a>
-
- </ul>
- </dd>
- <dt><a name="keys"></a><strong>keys</strong> (t)</dt>
- <dd>
-
- Retrieve all keys of given associative table.
- <h3>Parameters</h3>
- <ul>
-
- <li>
- t: Table to extract keys from
- </li>
-
- </ul>
- <h3>Return value:</h3>
- Sorted table containing the keys
- </dd>
- <dt><a name="kspairs"></a><strong>kspairs</strong> (t)</dt>
- <dd>
-
- Return a key, value iterator for the given table.
-
- The table pairs are sorted by key.
- <h3>Parameters</h3>
- <ul>
-
- <li>
- t: The table to iterate
- </li>
-
- </ul>
- <h3>Return value:</h3>
- Function value containing the corresponding iterator
- </dd>
- <dt><a name="libpath"></a><strong>libpath</strong> ()</dt>
- <dd>
-
- Returns the absolute path to LuCI base directory.
- <h3>Return value:</h3>
- String containing the directory path
- </dd>
- <dt><a name="parse_units"></a><strong>parse_units</strong> (ustr)</dt>
- <dd>
-
- Parse certain units from the given string and return the canonical integer
-
- value or 0 if the unit is unknown. Upper- or lower case is irrelevant.
- Recognized units are:
- o "y" - one year (60*60*24*366)
- o "m" - one month (60*60*24*31)
- o "w" - one week (60*60*24*7)
- o "d" - one day (60*60*24)
- o "h" - one hour (60*60)
- o "min" - one minute (60)
- o "kb" - one kilobyte (1024)
- o "mb" - one megabyte (1024*1024)
- o "gb" - one gigabyte (1024*1024*1024)
- o "kib" - one si kilobyte (1000)
- o "mib" - one si megabyte (1000*1000)
- o "gib" - one si gigabyte (1000*1000*1000)
- <h3>Parameters</h3>
- <ul>
-
- <li>
- ustr: String containing a numerical value with trailing unit
- </li>
-
- </ul>
- <h3>Return value:</h3>
- Number containing the canonical value
- </dd>
- <dt><a name="pcdata"></a><strong>pcdata</strong> (value)</dt>
- <dd>
-
- Create valid XML PCDATA from given string.
- <h3>Parameters</h3>
- <ul>
-
- <li>
- value: String value containing the data to escape
- </li>
-
- </ul>
- <h3>Return value:</h3>
- String value containing the escaped data
- </dd>
- <dt><a name="perror"></a><strong>perror</strong> (obj)</dt>
- <dd>
-
- Write given object to stderr.
- <h3>Parameters</h3>
- <ul>
-
- <li>
- obj: Value to write to stderr
- </li>
-
- </ul>
- <h3>Return value:</h3>
- Boolean indicating whether the write operation was successful
- </dd>
- <dt><a name="restore_data"></a><strong>restore_data</strong> (str)</dt>
- <dd>
-
- Restore data previously serialized with serialize_data().
- <h3>Parameters</h3>
- <ul>
-
- <li>
- str: String containing the data to restore
- </li>
-
- </ul>
- <h3>Return value:</h3>
- Value containing the restored data structure
- <h3>See also:</h3>
- <ul>
-
- <li><a href="#serialize_data">
- serialize_data
- </a>
-
- <li><a href="#get_bytecode">
- get_bytecode
- </a>
-
- </ul>
- </dd>
- <dt><a name="serialize_data"></a><strong>serialize_data</strong> (val)</dt>
- <dd>
-
- Recursively serialize given data to lua code, suitable for restoring
-
- with loadstring().
- <h3>Parameters</h3>
- <ul>
-
- <li>
- val: Value containing the data to serialize
- </li>
-
- </ul>
- <h3>Return value:</h3>
- String value containing the serialized code
- <h3>See also:</h3>
- <ul>
-
- <li><a href="#restore_data">
- restore_data
- </a>
-
- <li><a href="#get_bytecode">
- get_bytecode
- </a>
-
- </ul>
- </dd>
- <dt><a name="serialize_json"></a><strong>serialize_json</strong> (data, writer)</dt>
- <dd>
-
- Convert data structure to JSON
- <h3>Parameters</h3>
- <ul>
-
- <li>
- data: The data to serialize
- </li>
-
- <li>
- writer: A function to write a chunk of JSON data (optional)
- </li>
-
- </ul>
- <h3>Return value:</h3>
- String containing the JSON if called without write callback
- </dd>
- <dt><a name="spairs"></a><strong>spairs</strong> (t, f)</dt>
- <dd>
-
- Return a key, value iterator which returns the values sorted according to
-
- the provided callback function.
- <h3>Parameters</h3>
- <ul>
-
- <li>
- t: The table to iterate
- </li>
-
- <li>
- f: A callback function to decide the order of elements
- </li>
-
- </ul>
- <h3>Return value:</h3>
- Function value containing the corresponding iterator
- </dd>
- <dt><a name="split"></a><strong>split</strong> (str, pat, max, regex)</dt>
- <dd>
-
- Splits given string on a defined separator sequence and return a table
-
- containing the resulting substrings. The optional max parameter specifies
- the number of bytes to process, regardless of the actual length of the given
- string. The optional last parameter, regex, specifies whether the separator
- sequence is interpreted as regular expression.
- <h3>Parameters</h3>
- <ul>
-
- <li>
- str: String value containing the data to split up
- </li>
-
- <li>
- pat: String with separator pattern (optional, defaults to "\n")
- </li>
-
- <li>
- max: Maximum times to split (optional)
- </li>
-
- <li>
- regex: Boolean indicating whether to interpret the separator
- pattern as regular expression (optional, default is false)
- </li>
-
- </ul>
- <h3>Return value:</h3>
- Table containing the resulting substrings
- </dd>
- <dt><a name="strip_bytecode"></a><strong>strip_bytecode</strong> (code)</dt>
- <dd>
-
- Strips unnescessary lua bytecode from given string. Information like line
-
- numbers and debugging numbers will be discarded. Original version by
- Peter Cawley (http://lua-users.org/lists/lua-l/2008-02/msg01158.html)
- <h3>Parameters</h3>
- <ul>
-
- <li>
- code: String value containing the original lua byte code
- </li>
-
- </ul>
- <h3>Return value:</h3>
- String value containing the stripped lua byte code
- </dd>
- <dt><a name="striptags"></a><strong>striptags</strong> (value)</dt>
- <dd>
-
- Strip HTML tags from given string.
- <h3>Parameters</h3>
- <ul>
-
- <li>
- value: String containing the HTML text
- </li>
-
- </ul>
- <h3>Return value:</h3>
- String with HTML tags stripped of
- </dd>
- <dt><a name="threadlocal"></a><strong>threadlocal</strong> ()</dt>
- <dd>
-
- Create a new or get an already existing thread local store associated with
-
- the current active coroutine. A thread local store is private a table object
- whose values can't be accessed from outside of the running coroutine.
- <h3>Return value:</h3>
- Table value representing the corresponding thread local store
- </dd>
- <dt><a name="trim"></a><strong>trim</strong> (str)</dt>
- <dd>
-
- Remove leading and trailing whitespace from given string value.
- <h3>Parameters</h3>
- <ul>
-
- <li>
- str: String value containing whitespace padded data
- </li>
-
- </ul>
- <h3>Return value:</h3>
- String value with leading and trailing space removed
- </dd>
- <dt><a name="ubus"></a><strong>ubus</strong> (object, method, values)</dt>
- <dd>
-
- Issue an ubus call.
- <h3>Parameters</h3>
- <ul>
-
- <li>
- object: String containing the ubus object to call
- </li>
-
- <li>
- method: String containing the ubus method to call
- </li>
-
- <li>
- values: Table containing the values to pass
- </li>
-
- </ul>
- <h3>Return value:</h3>
- Table containin the ubus result
- </dd>
- <dt><a name="update"></a><strong>update</strong> (t, updates)</dt>
- <dd>
-
- Update values in given table with the values from the second given table.
-
- Both table are - in fact - merged together.
- <h3>Parameters</h3>
- <ul>
-
- <li>
- t: Table which should be updated
- </li>
-
- <li>
- updates: Table containing the values to update
- </li>
-
- </ul>
- <h3>Return value:</h3>
- Always nil
- </dd>
- <dt><a name="vspairs"></a><strong>vspairs</strong> (t)</dt>
- <dd>
-
- Return a key, value iterator for the given table.
-
- The table pairs are sorted by value.
- <h3>Parameters</h3>
- <ul>
-
- <li>
- t: The table to iterate
- </li>
-
- </ul>
- <h3>Return value:</h3>
- Function value containing the corresponding iterator
- </dd>
- </dl>
- </div> <!-- id="content" -->
- </div> <!-- id="main" -->
- <div id="about">
- <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>
- </div> <!-- id="about" -->
- </div> <!-- id="container" -->
- </body>
- </html>
|