1 <!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Strict//EN"
2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
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"/-->
14 <div id=
"product_logo"></div>
15 <div id=
"product_name"><big><b></b></big></div>
16 <div id=
"product_description"></div>
17 </div> <!-- id="product" -->
27 <li><a href=
"../index.html">Index
</a></li>
38 <a href=
"../modules/luci.dispatcher.html">luci.dispatcher
</a>
42 <a href=
"../modules/luci.http.html">luci.http
</a>
46 <a href=
"../modules/luci.http.conditionals.html">luci.http.conditionals
</a>
50 <a href=
"../modules/luci.http.date.html">luci.http.date
</a>
54 <a href=
"../modules/luci.http.mime.html">luci.http.mime
</a>
58 <a href=
"../modules/luci.i18n.html">luci.i18n
</a>
62 <a href=
"../modules/luci.ip.html">luci.ip
</a>
66 <a href=
"../modules/luci.ip.cidr.html">luci.ip.cidr
</a>
70 <a href=
"../modules/luci.json.html">luci.json
</a>
74 <a href=
"../modules/luci.jsonc.html">luci.jsonc
</a>
78 <a href=
"../modules/luci.jsonc.parser.html">luci.jsonc.parser
</a>
82 <a href=
"../modules/luci.model.ipkg.html">luci.model.ipkg
</a>
85 <li><strong>luci.model.uci
</strong></li>
88 <a href=
"../modules/luci.rpcc.html">luci.rpcc
</a>
92 <a href=
"../modules/luci.rpcc.ruci.html">luci.rpcc.ruci
</a>
96 <a href=
"../modules/luci.sys.html">luci.sys
</a>
100 <a href=
"../modules/luci.sys.init.html">luci.sys.init
</a>
104 <a href=
"../modules/luci.sys.iptparser.html">luci.sys.iptparser
</a>
108 <a href=
"../modules/luci.sys.net.html">luci.sys.net
</a>
112 <a href=
"../modules/luci.sys.process.html">luci.sys.process
</a>
116 <a href=
"../modules/luci.sys.user.html">luci.sys.user
</a>
120 <a href=
"../modules/luci.sys.wifi.html">luci.sys.wifi
</a>
124 <a href=
"../modules/luci.util.html">luci.util
</a>
128 <a href=
"../modules/nixio.html">nixio
</a>
132 <a href=
"../modules/nixio.CHANGELOG.html">nixio.CHANGELOG
</a>
136 <a href=
"../modules/nixio.CryptoHash.html">nixio.CryptoHash
</a>
140 <a href=
"../modules/nixio.File.html">nixio.File
</a>
144 <a href=
"../modules/nixio.README.html">nixio.README
</a>
148 <a href=
"../modules/nixio.Socket.html">nixio.Socket
</a>
152 <a href=
"../modules/nixio.TLSContext.html">nixio.TLSContext
</a>
156 <a href=
"../modules/nixio.TLSSocket.html">nixio.TLSSocket
</a>
160 <a href=
"../modules/nixio.UnifiedIO.html">nixio.UnifiedIO
</a>
164 <a href=
"../modules/nixio.bin.html">nixio.bin
</a>
168 <a href=
"../modules/nixio.bit.html">nixio.bit
</a>
172 <a href=
"../modules/nixio.crypto.html">nixio.crypto
</a>
176 <a href=
"../modules/nixio.fs.html">nixio.fs
</a>
191 </div><!-- id="navigation" -->
195 <h1>Object Instance
<code>luci.model.uci
</code></h1>
206 <table class=
"function_list">
209 <td class=
"name" nowrap
><a href=
"#Cursor.add">Cursor:add
</a> (config, type)
</td>
212 Add an anonymous section.
</td>
216 <td class=
"name" nowrap
><a href=
"#Cursor.apply">Cursor:apply
</a> (rollback)
</td>
219 Applies UCI configuration changes.
</td>
223 <td class=
"name" nowrap
><a href=
"#Cursor.changes">Cursor:changes
</a> (config)
</td>
226 Get a table of saved but uncommitted changes.
</td>
230 <td class=
"name" nowrap
><a href=
"#Cursor.commit">Cursor:commit
</a> (config)
</td>
233 Commit saved changes.
</td>
237 <td class=
"name" nowrap
><a href=
"#Cursor.confirm">Cursor:confirm
</a> ()
</td>
240 Confirms UCI apply process.
</td>
244 <td class=
"name" nowrap
><a href=
"#Cursor.delete">Cursor:delete
</a> (config, section, option)
</td>
247 Deletes a section or an option.
</td>
251 <td class=
"name" nowrap
><a href=
"#Cursor.delete_all">Cursor:delete_all
</a> (config, type, comparator)
</td>
254 Delete all sections of a given type that match certain criteria.
</td>
258 <td class=
"name" nowrap
><a href=
"#Cursor.foreach">Cursor:foreach
</a> (config, type, callback)
</td>
261 Call a function for every section of a certain type.
</td>
265 <td class=
"name" nowrap
><a href=
"#Cursor.get">Cursor:get
</a> (config, section, option)
</td>
268 Get a section type or an option
273 <td class=
"name" nowrap
><a href=
"#Cursor.get_all">Cursor:get_all
</a> (config, section)
</td>
276 Get all sections of a config or all values of a section.
</td>
280 <td class=
"name" nowrap
><a href=
"#Cursor.get_bool">Cursor:get_bool
</a> (config, section, option)
</td>
283 Get a boolean option and return it's value as true or false.
</td>
287 <td class=
"name" nowrap
><a href=
"#Cursor.get_confdir">Cursor:get_confdir
</a> ()
</td>
290 Get the configuration directory.
</td>
294 <td class=
"name" nowrap
><a href=
"#Cursor.get_first">Cursor:get_first
</a> (config, type, option, default)
</td>
297 Get the given option from the first section with the given type.
</td>
301 <td class=
"name" nowrap
><a href=
"#Cursor.get_list">Cursor:get_list
</a> (config, section, option)
</td>
304 Get an option or list and return values as table.
</td>
308 <td class=
"name" nowrap
><a href=
"#Cursor.get_savedir">Cursor:get_savedir
</a> ()
</td>
311 Get the directory for uncomitted changes.
</td>
315 <td class=
"name" nowrap
><a href=
"#Cursor.get_session_id">Cursor:get_session_id
</a> ()
</td>
318 Get the effective session ID.
</td>
322 <td class=
"name" nowrap
><a href=
"#Cursor.load">Cursor:load
</a> (config)
</td>
325 Manually load a config.
</td>
329 <td class=
"name" nowrap
><a href=
"#Cursor.revert">Cursor:revert
</a> (config)
</td>
332 Revert saved but uncommitted changes.
</td>
336 <td class=
"name" nowrap
><a href=
"#Cursor.rollback">Cursor:rollback
</a> ()
</td>
339 Cancels UCI apply process.
</td>
343 <td class=
"name" nowrap
><a href=
"#Cursor.rollback_pending">Cursor:rollback_pending
</a> ()
</td>
346 Checks whether a pending rollback is scheduled.
</td>
350 <td class=
"name" nowrap
><a href=
"#Cursor.save">Cursor:save
</a> (config)
</td>
353 Saves changes made to a config to make them committable.
</td>
357 <td class=
"name" nowrap
><a href=
"#Cursor.section">Cursor:section
</a> (config, type, name, values)
</td>
360 Create a new section and initialize it with data.
</td>
364 <td class=
"name" nowrap
><a href=
"#Cursor.set">Cursor:set
</a> (config, section, option, value)
</td>
367 Set a value or create a named section.
</td>
371 <td class=
"name" nowrap
><a href=
"#Cursor.set_confdir">Cursor:set_confdir
</a> (directory)
</td>
374 Set the configuration directory.
</td>
378 <td class=
"name" nowrap
><a href=
"#Cursor.set_list">Cursor:set_list
</a> (config, section, option, value)
</td>
381 Set given values as list.
</td>
385 <td class=
"name" nowrap
><a href=
"#Cursor.set_savedir">Cursor:set_savedir
</a> (directory)
</td>
388 Set the directory for uncommitted changes.
</td>
392 <td class=
"name" nowrap
><a href=
"#Cursor.set_session_id">Cursor:set_session_id
</a> (id)
</td>
395 Set the effective session ID.
</td>
399 <td class=
"name" nowrap
><a href=
"#Cursor.substate">Cursor:substate
</a> ()
</td>
402 Create a sub-state of this cursor.
</td>
406 <td class=
"name" nowrap
><a href=
"#Cursor.tset">Cursor:tset
</a> (config, section, values)
</td>
409 Updated the data of a section using data from a table.
</td>
413 <td class=
"name" nowrap
><a href=
"#Cursor.unload">Cursor:unload
</a> (config)
</td>
416 Discard changes made to a config.
</td>
420 <td class=
"name" nowrap
><a href=
"#cursor">cursor
</a> ()
</td>
423 Create a new UCI-Cursor.
</td>
427 <td class=
"name" nowrap
><a href=
"#cursor_state">cursor_state
</a> ()
</td>
430 Create a new Cursor initialized to the state directory.
</td>
444 <h2><a name=
"functions"></a>Functions
</h2>
445 <dl class=
"function">
449 <dt><a name=
"Cursor.add"></a><strong>Cursor:add
</strong> (config, type)
</dt>
453 Add an anonymous section.
465 type: UCI section type
475 <h3>Return value:
</h3>
476 Name of created section
485 <dt><a name=
"Cursor.apply"></a><strong>Cursor:apply
</strong> (rollback)
</dt>
489 Applies UCI configuration changes.
491 If the rollback parameter is set to true, the apply function will invoke the
492 rollback mechanism which causes the configuration to be automatically reverted
493 if no confirm() call occurs within a certain timeout.
495 The current default timeout is
30s and can be increased using the
496 "luci.apply.timeout" uci configuration key.
504 rollback: Enable rollback mechanism
514 <h3>Return value:
</h3>
515 Boolean whether operation succeeded
524 <dt><a name=
"Cursor.changes"></a><strong>Cursor:changes
</strong> (config)
</dt>
528 Get a table of saved but uncommitted changes.
546 <h3>Return value:
</h3>
554 <li><a href=
"#Cursor.save">
565 <dt><a name=
"Cursor.commit"></a><strong>Cursor:commit
</strong> (config)
</dt>
569 Commit saved changes.
587 <h3>Return value:
</h3>
588 Boolean whether operation succeeded
595 <li><a href=
"#Cursor.revert">
599 <li><a href=
"#Cursor.save">
610 <dt><a name=
"Cursor.confirm"></a><strong>Cursor:confirm
</strong> ()
</dt>
614 Confirms UCI apply process.
616 If a previous UCI apply with rollback has been invoked using apply(true),
617 this function confirms the process and cancels the pending rollback timer.
619 If no apply with rollback session is active, the function has no effect and
620 returns with a
"No data" error.
629 <h3>Return value:
</h3>
630 Boolean whether operation succeeded
639 <dt><a name=
"Cursor.delete"></a><strong>Cursor:delete
</strong> (config, section, option)
</dt>
643 Deletes a section or an option.
655 section: UCI section name
659 option: UCI option (optional)
669 <h3>Return value:
</h3>
670 Boolean whether operation succeeded
679 <dt><a name=
"Cursor.delete_all"></a><strong>Cursor:delete_all
</strong> (config, type, comparator)
</dt>
683 Delete all sections of a given type that match certain criteria.
695 type: UCI section type
699 comparator: Function that will be called for each section and returns
700 a boolean whether to delete the current section (optional)
717 <dt><a name=
"Cursor.foreach"></a><strong>Cursor:foreach
</strong> (config, type, callback)
</dt>
721 Call a function for every section of a certain type.
733 type: UCI section type
737 callback: Function to be called
747 <h3>Return value:
</h3>
748 Boolean whether operation succeeded
757 <dt><a name=
"Cursor.get"></a><strong>Cursor:get
</strong> (config, section, option)
</dt>
761 Get a section type or an option
773 section: UCI section name
777 option: UCI option (optional)
787 <h3>Return value:
</h3>
797 <dt><a name=
"Cursor.get_all"></a><strong>Cursor:get_all
</strong> (config, section)
</dt>
801 Get all sections of a config or all values of a section.
813 section: UCI section name (optional)
823 <h3>Return value:
</h3>
824 Table of UCI sections or table of UCI values
833 <dt><a name=
"Cursor.get_bool"></a><strong>Cursor:get_bool
</strong> (config, section, option)
</dt>
837 Get a boolean option and return it's value as true or false.
849 section: UCI section name
863 <h3>Return value:
</h3>
873 <dt><a name=
"Cursor.get_confdir"></a><strong>Cursor:get_confdir
</strong> ()
</dt>
877 Get the configuration directory.
886 <h3>Return value:
</h3>
887 Configuration directory
896 <dt><a name=
"Cursor.get_first"></a><strong>Cursor:get_first
</strong> (config, type, option, default)
</dt>
900 Get the given option from the first section with the given type.
912 type: UCI section type
916 option: UCI option (optional)
920 default: Default value (optional)
930 <h3>Return value:
</h3>
940 <dt><a name=
"Cursor.get_list"></a><strong>Cursor:get_list
</strong> (config, section, option)
</dt>
944 Get an option or list and return values as table.
956 section: UCI section name
970 <h3>Return value:
</h3>
971 table. If the option was not found, you will simply get an empty
981 <dt><a name=
"Cursor.get_savedir"></a><strong>Cursor:get_savedir
</strong> ()
</dt>
985 Get the directory for uncomitted changes.
994 <h3>Return value:
</h3>
1004 <dt><a name=
"Cursor.get_session_id"></a><strong>Cursor:get_session_id
</strong> ()
</dt>
1008 Get the effective session ID.
1017 <h3>Return value:
</h3>
1018 String containing the session ID
1027 <dt><a name=
"Cursor.load"></a><strong>Cursor:load
</strong> (config)
</dt>
1031 Manually load a config.
1049 <h3>Return value:
</h3>
1050 Boolean whether operation succeeded
1057 <li><a href=
"#Cursor.save">
1061 <li><a href=
"#Cursor.unload">
1072 <dt><a name=
"Cursor.revert"></a><strong>Cursor:revert
</strong> (config)
</dt>
1076 Revert saved but uncommitted changes.
1094 <h3>Return value:
</h3>
1095 Boolean whether operation succeeded
1102 <li><a href=
"#Cursor.commit">
1106 <li><a href=
"#Cursor.save">
1117 <dt><a name=
"Cursor.rollback"></a><strong>Cursor:rollback
</strong> ()
</dt>
1121 Cancels UCI apply process.
1123 If a previous UCI apply with rollback has been invoked using apply(true),
1124 this function cancels the process and rolls back the configuration to the
1127 If no apply with rollback session is active, the function has no effect and
1128 returns with a
"No data" error.
1137 <h3>Return value:
</h3>
1138 Boolean whether operation succeeded
1147 <dt><a name=
"Cursor.rollback_pending"></a><strong>Cursor:rollback_pending
</strong> ()
</dt>
1151 Checks whether a pending rollback is scheduled.
1153 If a previous UCI apply with rollback has been invoked using apply(true),
1154 and has not been confirmed or rolled back yet, this function returns true
1155 and the remaining time until rollback in seconds. If no rollback is pending,
1156 the function returns false. On error, the function returns false and an
1157 additional string describing the error.
1166 <h3>Return values:
</h3>
1169 <li>Boolean whether rollback is pending
1171 <li>Remaining time in seconds
1182 <dt><a name=
"Cursor.save"></a><strong>Cursor:save
</strong> (config)
</dt>
1186 Saves changes made to a config to make them committable.
1204 <h3>Return value:
</h3>
1205 Boolean whether operation succeeded
1212 <li><a href=
"#Cursor.load">
1216 <li><a href=
"#Cursor.unload">
1227 <dt><a name=
"Cursor.section"></a><strong>Cursor:section
</strong> (config, type, name, values)
</dt>
1231 Create a new section and initialize it with data.
1243 type: UCI section type
1247 name: UCI section name (optional)
1251 values: Table of key - value pairs to initialize the section with
1261 <h3>Return value:
</h3>
1262 Name of created section
1271 <dt><a name=
"Cursor.set"></a><strong>Cursor:set
</strong> (config, section, option, value)
</dt>
1275 Set a value or create a named section.
1277 When invoked with three arguments
<code>config
</code>,
<code>sectionname
</code>,
<code>sectiontype
</code>,
1278 then a named section of the given type is created.
1280 When invoked with four arguments
<code>config
</code>,
<code>sectionname
</code>,
<code>optionname
</code> and
1281 <code>optionvalue
</code> then the value of the specified option is set to the given value.
1293 section: UCI section name
1297 option: UCI option or UCI section type
1301 value: UCI value or nothing if you want to create a section
1311 <h3>Return value:
</h3>
1312 Boolean whether operation succeeded
1321 <dt><a name=
"Cursor.set_confdir"></a><strong>Cursor:set_confdir
</strong> (directory)
</dt>
1325 Set the configuration directory.
1333 directory: UCI configuration directory
1343 <h3>Return value:
</h3>
1344 Boolean whether operation succeeded
1353 <dt><a name=
"Cursor.set_list"></a><strong>Cursor:set_list
</strong> (config, section, option, value)
</dt>
1357 Set given values as list. Setting a list option to an empty list
1358 has the same effect as deleting the option.
1370 section: UCI section name
1378 value: Value or table. Non-table values will be set as single
1389 <h3>Return value:
</h3>
1390 Boolean whether operation succeeded
1399 <dt><a name=
"Cursor.set_savedir"></a><strong>Cursor:set_savedir
</strong> (directory)
</dt>
1403 Set the directory for uncommitted changes.
1411 directory: UCI changes directory
1421 <h3>Return value:
</h3>
1422 Boolean whether operation succeeded
1431 <dt><a name=
"Cursor.set_session_id"></a><strong>Cursor:set_session_id
</strong> (id)
</dt>
1435 Set the effective session ID.
1443 id: String containing the session ID to set
1453 <h3>Return value:
</h3>
1454 Boolean whether operation succeeded
1463 <dt><a name=
"Cursor.substate"></a><strong>Cursor:substate
</strong> ()
</dt>
1467 Create a sub-state of this cursor.
1469 The sub-state is tied to the parent cursor, means it the parent unloads or
1470 loads configs, the sub state will do so as well.
1479 <h3>Return value:
</h3>
1480 UCI state cursor tied to the parent cursor
1489 <dt><a name=
"Cursor.tset"></a><strong>Cursor:tset
</strong> (config, section, values)
</dt>
1493 Updated the data of a section using data from a table.
1505 section: UCI section name (optional)
1509 values: Table of key - value pairs to update the section with
1526 <dt><a name=
"Cursor.unload"></a><strong>Cursor:unload
</strong> (config)
</dt>
1530 Discard changes made to a config.
1548 <h3>Return value:
</h3>
1549 Boolean whether operation succeeded
1556 <li><a href=
"#Cursor.load">
1560 <li><a href=
"#Cursor.save">
1571 <dt><a name=
"cursor"></a><strong>cursor
</strong> ()
</dt>
1575 Create a new UCI-Cursor.
1584 <h3>Return value:
</h3>
1594 <dt><a name=
"cursor_state"></a><strong>cursor_state
</strong> ()
</dt>
1598 Create a new Cursor initialized to the state directory.
1607 <h3>Return value:
</h3>
1621 </div> <!-- id="content" -->
1623 </div> <!-- id="main" -->
1626 <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>
1627 </div> <!-- id="about" -->
1629 </div> <!-- id="container" -->