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/luci.xml.html">luci.xml
</a>
132 <a href=
"../modules/nixio.html">nixio
</a>
136 <a href=
"../modules/nixio.CHANGELOG.html">nixio.CHANGELOG
</a>
140 <a href=
"../modules/nixio.CryptoHash.html">nixio.CryptoHash
</a>
144 <a href=
"../modules/nixio.File.html">nixio.File
</a>
148 <a href=
"../modules/nixio.README.html">nixio.README
</a>
152 <a href=
"../modules/nixio.Socket.html">nixio.Socket
</a>
156 <a href=
"../modules/nixio.TLSContext.html">nixio.TLSContext
</a>
160 <a href=
"../modules/nixio.TLSSocket.html">nixio.TLSSocket
</a>
164 <a href=
"../modules/nixio.UnifiedIO.html">nixio.UnifiedIO
</a>
168 <a href=
"../modules/nixio.bin.html">nixio.bin
</a>
172 <a href=
"../modules/nixio.bit.html">nixio.bit
</a>
176 <a href=
"../modules/nixio.crypto.html">nixio.crypto
</a>
180 <a href=
"../modules/nixio.fs.html">nixio.fs
</a>
195 </div><!-- id="navigation" -->
199 <h1>Object Instance
<code>luci.model.uci
</code></h1>
210 <table class=
"function_list">
213 <td class=
"name" nowrap
><a href=
"#Cursor.add">Cursor:add
</a> (config, type)
</td>
216 Add an anonymous section.
</td>
220 <td class=
"name" nowrap
><a href=
"#Cursor.apply">Cursor:apply
</a> (rollback)
</td>
223 Applies UCI configuration changes.
</td>
227 <td class=
"name" nowrap
><a href=
"#Cursor.changes">Cursor:changes
</a> (config)
</td>
230 Get a table of saved but uncommitted changes.
</td>
234 <td class=
"name" nowrap
><a href=
"#Cursor.commit">Cursor:commit
</a> (config)
</td>
237 Commit saved changes.
</td>
241 <td class=
"name" nowrap
><a href=
"#Cursor.confirm">Cursor:confirm
</a> ()
</td>
244 Confirms UCI apply process.
</td>
248 <td class=
"name" nowrap
><a href=
"#Cursor.delete">Cursor:delete
</a> (config, section, option)
</td>
251 Deletes a section or an option.
</td>
255 <td class=
"name" nowrap
><a href=
"#Cursor.delete_all">Cursor:delete_all
</a> (config, type, comparator)
</td>
258 Delete all sections of a given type that match certain criteria.
</td>
262 <td class=
"name" nowrap
><a href=
"#Cursor.foreach">Cursor:foreach
</a> (config, type, callback)
</td>
265 Call a function for every section of a certain type.
</td>
269 <td class=
"name" nowrap
><a href=
"#Cursor.get">Cursor:get
</a> (config, section, option)
</td>
272 Get a section type or an option
277 <td class=
"name" nowrap
><a href=
"#Cursor.get_all">Cursor:get_all
</a> (config, section)
</td>
280 Get all sections of a config or all values of a section.
</td>
284 <td class=
"name" nowrap
><a href=
"#Cursor.get_bool">Cursor:get_bool
</a> (config, section, option)
</td>
287 Get a boolean option and return it's value as true or false.
</td>
291 <td class=
"name" nowrap
><a href=
"#Cursor.get_confdir">Cursor:get_confdir
</a> ()
</td>
294 Get the configuration directory.
</td>
298 <td class=
"name" nowrap
><a href=
"#Cursor.get_first">Cursor:get_first
</a> (config, type, option, default)
</td>
301 Get the given option from the first section with the given type.
</td>
305 <td class=
"name" nowrap
><a href=
"#Cursor.get_list">Cursor:get_list
</a> (config, section, option)
</td>
308 Get an option or list and return values as table.
</td>
312 <td class=
"name" nowrap
><a href=
"#Cursor.get_savedir">Cursor:get_savedir
</a> ()
</td>
315 Get the directory for uncomitted changes.
</td>
319 <td class=
"name" nowrap
><a href=
"#Cursor.get_session_id">Cursor:get_session_id
</a> ()
</td>
322 Get the effective session ID.
</td>
326 <td class=
"name" nowrap
><a href=
"#Cursor.load">Cursor:load
</a> (config)
</td>
329 Manually load a config.
</td>
333 <td class=
"name" nowrap
><a href=
"#Cursor.revert">Cursor:revert
</a> (config)
</td>
336 Revert saved but uncommitted changes.
</td>
340 <td class=
"name" nowrap
><a href=
"#Cursor.rollback">Cursor:rollback
</a> ()
</td>
343 Cancels UCI apply process.
</td>
347 <td class=
"name" nowrap
><a href=
"#Cursor.rollback_pending">Cursor:rollback_pending
</a> ()
</td>
350 Checks whether a pending rollback is scheduled.
</td>
354 <td class=
"name" nowrap
><a href=
"#Cursor.save">Cursor:save
</a> (config)
</td>
357 Saves changes made to a config to make them committable.
</td>
361 <td class=
"name" nowrap
><a href=
"#Cursor.section">Cursor:section
</a> (config, type, name, values)
</td>
364 Create a new section and initialize it with data.
</td>
368 <td class=
"name" nowrap
><a href=
"#Cursor.set">Cursor:set
</a> (config, section, option, value)
</td>
371 Set a value or create a named section.
</td>
375 <td class=
"name" nowrap
><a href=
"#Cursor.set_confdir">Cursor:set_confdir
</a> (directory)
</td>
378 Set the configuration directory.
</td>
382 <td class=
"name" nowrap
><a href=
"#Cursor.set_list">Cursor:set_list
</a> (config, section, option, value)
</td>
385 Set given values as list.
</td>
389 <td class=
"name" nowrap
><a href=
"#Cursor.set_savedir">Cursor:set_savedir
</a> (directory)
</td>
392 Set the directory for uncommitted changes.
</td>
396 <td class=
"name" nowrap
><a href=
"#Cursor.set_session_id">Cursor:set_session_id
</a> (id)
</td>
399 Set the effective session ID.
</td>
403 <td class=
"name" nowrap
><a href=
"#Cursor.substate">Cursor:substate
</a> ()
</td>
406 Create a sub-state of this cursor.
</td>
410 <td class=
"name" nowrap
><a href=
"#Cursor.tset">Cursor:tset
</a> (config, section, values)
</td>
413 Updated the data of a section using data from a table.
</td>
417 <td class=
"name" nowrap
><a href=
"#Cursor.unload">Cursor:unload
</a> (config)
</td>
420 Discard changes made to a config.
</td>
424 <td class=
"name" nowrap
><a href=
"#cursor">cursor
</a> ()
</td>
427 Create a new UCI-Cursor.
</td>
431 <td class=
"name" nowrap
><a href=
"#cursor_state">cursor_state
</a> ()
</td>
434 Create a new Cursor initialized to the state directory.
</td>
448 <h2><a name=
"functions"></a>Functions
</h2>
449 <dl class=
"function">
453 <dt><a name=
"Cursor.add"></a><strong>Cursor:add
</strong> (config, type)
</dt>
457 Add an anonymous section.
469 type: UCI section type
479 <h3>Return value:
</h3>
480 Name of created section
489 <dt><a name=
"Cursor.apply"></a><strong>Cursor:apply
</strong> (rollback)
</dt>
493 Applies UCI configuration changes.
495 If the rollback parameter is set to true, the apply function will invoke the
496 rollback mechanism which causes the configuration to be automatically reverted
497 if no confirm() call occurs within a certain timeout.
499 The current default timeout is
30s and can be increased using the
500 "luci.apply.timeout" uci configuration key.
508 rollback: Enable rollback mechanism
518 <h3>Return value:
</h3>
519 Boolean whether operation succeeded
528 <dt><a name=
"Cursor.changes"></a><strong>Cursor:changes
</strong> (config)
</dt>
532 Get a table of saved but uncommitted changes.
550 <h3>Return value:
</h3>
558 <li><a href=
"#Cursor.save">
569 <dt><a name=
"Cursor.commit"></a><strong>Cursor:commit
</strong> (config)
</dt>
573 Commit saved changes.
591 <h3>Return value:
</h3>
592 Boolean whether operation succeeded
599 <li><a href=
"#Cursor.revert">
603 <li><a href=
"#Cursor.save">
614 <dt><a name=
"Cursor.confirm"></a><strong>Cursor:confirm
</strong> ()
</dt>
618 Confirms UCI apply process.
620 If a previous UCI apply with rollback has been invoked using apply(true),
621 this function confirms the process and cancels the pending rollback timer.
623 If no apply with rollback session is active, the function has no effect and
624 returns with a
"No data" error.
633 <h3>Return value:
</h3>
634 Boolean whether operation succeeded
643 <dt><a name=
"Cursor.delete"></a><strong>Cursor:delete
</strong> (config, section, option)
</dt>
647 Deletes a section or an option.
659 section: UCI section name
663 option: UCI option (optional)
673 <h3>Return value:
</h3>
674 Boolean whether operation succeeded
683 <dt><a name=
"Cursor.delete_all"></a><strong>Cursor:delete_all
</strong> (config, type, comparator)
</dt>
687 Delete all sections of a given type that match certain criteria.
699 type: UCI section type
703 comparator: Function that will be called for each section and returns
704 a boolean whether to delete the current section (optional)
721 <dt><a name=
"Cursor.foreach"></a><strong>Cursor:foreach
</strong> (config, type, callback)
</dt>
725 Call a function for every section of a certain type.
737 type: UCI section type
741 callback: Function to be called
751 <h3>Return value:
</h3>
752 Boolean whether operation succeeded
761 <dt><a name=
"Cursor.get"></a><strong>Cursor:get
</strong> (config, section, option)
</dt>
765 Get a section type or an option
777 section: UCI section name
781 option: UCI option (optional)
791 <h3>Return value:
</h3>
801 <dt><a name=
"Cursor.get_all"></a><strong>Cursor:get_all
</strong> (config, section)
</dt>
805 Get all sections of a config or all values of a section.
817 section: UCI section name (optional)
827 <h3>Return value:
</h3>
828 Table of UCI sections or table of UCI values
837 <dt><a name=
"Cursor.get_bool"></a><strong>Cursor:get_bool
</strong> (config, section, option)
</dt>
841 Get a boolean option and return it's value as true or false.
853 section: UCI section name
867 <h3>Return value:
</h3>
877 <dt><a name=
"Cursor.get_confdir"></a><strong>Cursor:get_confdir
</strong> ()
</dt>
881 Get the configuration directory.
890 <h3>Return value:
</h3>
891 Configuration directory
900 <dt><a name=
"Cursor.get_first"></a><strong>Cursor:get_first
</strong> (config, type, option, default)
</dt>
904 Get the given option from the first section with the given type.
916 type: UCI section type
920 option: UCI option (optional)
924 default: Default value (optional)
934 <h3>Return value:
</h3>
944 <dt><a name=
"Cursor.get_list"></a><strong>Cursor:get_list
</strong> (config, section, option)
</dt>
948 Get an option or list and return values as table.
960 section: UCI section name
974 <h3>Return value:
</h3>
975 table. If the option was not found, you will simply get an empty
985 <dt><a name=
"Cursor.get_savedir"></a><strong>Cursor:get_savedir
</strong> ()
</dt>
989 Get the directory for uncomitted changes.
998 <h3>Return value:
</h3>
1008 <dt><a name=
"Cursor.get_session_id"></a><strong>Cursor:get_session_id
</strong> ()
</dt>
1012 Get the effective session ID.
1021 <h3>Return value:
</h3>
1022 String containing the session ID
1031 <dt><a name=
"Cursor.load"></a><strong>Cursor:load
</strong> (config)
</dt>
1035 Manually load a config.
1053 <h3>Return value:
</h3>
1054 Boolean whether operation succeeded
1061 <li><a href=
"#Cursor.save">
1065 <li><a href=
"#Cursor.unload">
1076 <dt><a name=
"Cursor.revert"></a><strong>Cursor:revert
</strong> (config)
</dt>
1080 Revert saved but uncommitted changes.
1098 <h3>Return value:
</h3>
1099 Boolean whether operation succeeded
1106 <li><a href=
"#Cursor.commit">
1110 <li><a href=
"#Cursor.save">
1121 <dt><a name=
"Cursor.rollback"></a><strong>Cursor:rollback
</strong> ()
</dt>
1125 Cancels UCI apply process.
1127 If a previous UCI apply with rollback has been invoked using apply(true),
1128 this function cancels the process and rolls back the configuration to the
1131 If no apply with rollback session is active, the function has no effect and
1132 returns with a
"No data" error.
1141 <h3>Return value:
</h3>
1142 Boolean whether operation succeeded
1151 <dt><a name=
"Cursor.rollback_pending"></a><strong>Cursor:rollback_pending
</strong> ()
</dt>
1155 Checks whether a pending rollback is scheduled.
1157 If a previous UCI apply with rollback has been invoked using apply(true),
1158 and has not been confirmed or rolled back yet, this function returns true
1159 and the remaining time until rollback in seconds. If no rollback is pending,
1160 the function returns false. On error, the function returns false and an
1161 additional string describing the error.
1170 <h3>Return values:
</h3>
1173 <li>Boolean whether rollback is pending
1175 <li>Remaining time in seconds
1186 <dt><a name=
"Cursor.save"></a><strong>Cursor:save
</strong> (config)
</dt>
1190 Saves changes made to a config to make them committable.
1208 <h3>Return value:
</h3>
1209 Boolean whether operation succeeded
1216 <li><a href=
"#Cursor.load">
1220 <li><a href=
"#Cursor.unload">
1231 <dt><a name=
"Cursor.section"></a><strong>Cursor:section
</strong> (config, type, name, values)
</dt>
1235 Create a new section and initialize it with data.
1247 type: UCI section type
1251 name: UCI section name (optional)
1255 values: Table of key - value pairs to initialize the section with
1265 <h3>Return value:
</h3>
1266 Name of created section
1275 <dt><a name=
"Cursor.set"></a><strong>Cursor:set
</strong> (config, section, option, value)
</dt>
1279 Set a value or create a named section.
1281 When invoked with three arguments
<code>config
</code>,
<code>sectionname
</code>,
<code>sectiontype
</code>,
1282 then a named section of the given type is created.
1284 When invoked with four arguments
<code>config
</code>,
<code>sectionname
</code>,
<code>optionname
</code> and
1285 <code>optionvalue
</code> then the value of the specified option is set to the given value.
1297 section: UCI section name
1301 option: UCI option or UCI section type
1305 value: UCI value or nothing if you want to create a section
1315 <h3>Return value:
</h3>
1316 Boolean whether operation succeeded
1325 <dt><a name=
"Cursor.set_confdir"></a><strong>Cursor:set_confdir
</strong> (directory)
</dt>
1329 Set the configuration directory.
1337 directory: UCI configuration directory
1347 <h3>Return value:
</h3>
1348 Boolean whether operation succeeded
1357 <dt><a name=
"Cursor.set_list"></a><strong>Cursor:set_list
</strong> (config, section, option, value)
</dt>
1361 Set given values as list. Setting a list option to an empty list
1362 has the same effect as deleting the option.
1374 section: UCI section name
1382 value: Value or table. Non-table values will be set as single
1393 <h3>Return value:
</h3>
1394 Boolean whether operation succeeded
1403 <dt><a name=
"Cursor.set_savedir"></a><strong>Cursor:set_savedir
</strong> (directory)
</dt>
1407 Set the directory for uncommitted changes.
1415 directory: UCI changes directory
1425 <h3>Return value:
</h3>
1426 Boolean whether operation succeeded
1435 <dt><a name=
"Cursor.set_session_id"></a><strong>Cursor:set_session_id
</strong> (id)
</dt>
1439 Set the effective session ID.
1447 id: String containing the session ID to set
1457 <h3>Return value:
</h3>
1458 Boolean whether operation succeeded
1467 <dt><a name=
"Cursor.substate"></a><strong>Cursor:substate
</strong> ()
</dt>
1471 Create a sub-state of this cursor.
1473 The sub-state is tied to the parent cursor, means it the parent unloads or
1474 loads configs, the sub state will do so as well.
1483 <h3>Return value:
</h3>
1484 UCI state cursor tied to the parent cursor
1493 <dt><a name=
"Cursor.tset"></a><strong>Cursor:tset
</strong> (config, section, values)
</dt>
1497 Updated the data of a section using data from a table.
1509 section: UCI section name (optional)
1513 values: Table of key - value pairs to update the section with
1530 <dt><a name=
"Cursor.unload"></a><strong>Cursor:unload
</strong> (config)
</dt>
1534 Discard changes made to a config.
1552 <h3>Return value:
</h3>
1553 Boolean whether operation succeeded
1560 <li><a href=
"#Cursor.load">
1564 <li><a href=
"#Cursor.save">
1575 <dt><a name=
"cursor"></a><strong>cursor
</strong> ()
</dt>
1579 Create a new UCI-Cursor.
1588 <h3>Return value:
</h3>
1598 <dt><a name=
"cursor_state"></a><strong>cursor_state
</strong> ()
</dt>
1602 Create a new Cursor initialized to the state directory.
1611 <h3>Return value:
</h3>
1625 </div> <!-- id="content" -->
1627 </div> <!-- id="main" -->
1630 <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>
1631 </div> <!-- id="about" -->
1633 </div> <!-- id="container" -->