123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830 |
- <!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.conditionals.html">luci.http.conditionals</a>
- </li>
- <li>
- <a href="../modules/luci.http.date.html">luci.http.date</a>
- </li>
- <li>
- <a href="../modules/luci.http.mime.html">luci.http.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="#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="#shellquote">shellquote</a> (value)</td>
- <td class="summary">
-
- Safely quote value for use in shell commands.</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 unnecessary 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="#urldecode">urldecode</a> (str, decode_plus)</td>
- <td class="summary">
-
- Decode an URL-encoded string - optionally decoding the "+" sign to space.</td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#urlencode">urlencode</a> (str)</td>
- <td class="summary">
-
- URL-encode given string.</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="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 iterator 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="shellquote"></a><strong>shellquote</strong> (value)</dt>
- <dd>
-
- Safely quote value for use in shell commands.
- <h3>Parameters</h3>
- <ul>
-
- <li>
- value: String containing the value to quote
- </li>
-
- </ul>
- <h3>Return value:</h3>
- Single-quote enclosed string with embedded quotes escaped
- </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
- nterpreted 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 unnecessary 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="urldecode"></a><strong>urldecode</strong> (str, decode_plus)</dt>
- <dd>
-
- Decode an URL-encoded string - optionally decoding the "+" sign to space.
- <h3>Parameters</h3>
- <ul>
-
- <li>
- str: Input string in x-www-urlencoded format
- </li>
-
- <li>
- decode_plus: Decode "+" signs to spaces if true (optional)
- </li>
-
- </ul>
- <h3>Return value:</h3>
- The decoded string
- <h3>See also:</h3>
- <ul>
-
- <li><a href="#urlencode">
- urlencode
- </a>
-
- </ul>
- </dd>
- <dt><a name="urlencode"></a><strong>urlencode</strong> (str)</dt>
- <dd>
-
- URL-encode given string.
- <h3>Parameters</h3>
- <ul>
-
- <li>
- str: String to encode
- </li>
-
- </ul>
- <h3>Return value:</h3>
- String containing the encoded data
- <h3>See also:</h3>
- <ul>
-
- <li><a href="#urldecode">
- urldecode
- </a>
-
- </ul>
- </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>
|