summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* lua: additionally return name when looking up sectionslede-17.01Jo-Philipp Wich2018-01-011-3/+8
| | | | | | | | | | | | | Return the resolved name in addition to the type when looking up sections through `get()` - for example a `cursor:get("firewall", "@rule[0]")` will now return two values in the form ("rule", "cfg0a92bd") instead of only the type name. This is mainly useful to resolve extended section names without having to reimplement the section count logic in Lua code. Signed-off-by: Jo-Philipp Wich <jo@mein.io> (cherry picked from commit 5beb95da3dbec6db11a6bdfaab7807ee2daf41e6)
* lua: support extended section notationJo-Philipp Wich2018-01-011-7/+36
| | | | | | | | | | | | Wrap uci_lookup_ptr() to enable extended section format lookups when the passed section literal is in "@" notation. This allows calls in the form `cursor:get("conf", "@stype[0]", "opt")` which is useful to resolve options in numerically indexed anonymous sections. Signed-off-by: Jo-Philipp Wich <jo@mein.io> (cherry picked from commit ff33bb219bc409ce3071734a1c28d9165392d6ea)
* projects/uci: lua: use built in pkg-config support for alternativesKarl Palsson2016-04-221-8/+2
| | | | | | | | Different distributions have different names for the lua 5.1 package. Use cmake's built in pkg-config support to search for the first one, rather than running it explicitly and searching for a single version. Signed-off-by: Karl Palsson <karlp@remake.is>
* file: write through symlinks on uci commitJo-Philipp Wich2016-03-311-3/+7
| | | | | | | | The rename() syscall operates on the destination path directly, therfore resolve the real path before doing the rename to not clobber the destination in case it is a symlink pointing to another file. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
* cmake: Add ubox library and include dir lookupPetr Štetiar2016-03-071-2/+10
| | | | | | | Otherwise cmake uses files from system which sometimes isn't wanted, ie. for testing. Signed-off-by: Petr Å tetiar <ynezz@true.cz>
* cli: fix uci show output for anonymous sections (#21781)Felix Fietkau2016-02-021-9/+16
| | | | Signed-off-by: Felix Fietkau <nbd@openwrt.org>
* file: raise parse error on conflicting section types in strict modeJo-Philipp Wich2016-01-251-1/+6
| | | | | | | | | | | | | | | | | | | | | If strict mode is enabled and we're parsing a config file with multiple sections of the same name but different types, then raise a parse error to notify the user that the subsequent section declaration would shadow all prior ones of the same name. The error would be triggered by a config like that: config typeA example option test 1 config typeB example option test 2 In such a case, libuci will raise this error: uci: Parse error (section of different type overwrites prior section with same name) at line 4, byte 23 Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
* file: defer checking the tmpfile until it is actually needed.Felix Fietkau2016-01-111-11/+11
| | | | | | Avoids creating useless entries in the kernel dentry cache Signed-off-by: Felix Fietkau <nbd@openwrt.org>
* remove list.hFelix Fietkau2015-11-111-601/+0
| | | | Signed-off-by: Felix Fietkau <nbd@openwrt.org>
* lua: remove pointless double check of autoload flagKarl Palsson2015-11-061-4/+1
| | | | | | | | In e2b1433b the autoload param went from being an enumerated type to a simple boolean. Drop the pointless double check of this flag. Signed-off-by: Karl Palsson <karlp@remake.is> Signed-off-by: Felix Fietkau <nbd@openwrt.org>
* lua: fix invocation of foreach() with nil type and implicit selfJo-Philipp Wich2015-11-051-1/+1
| | | | | | | | | | | The check for nil on the 2nd argument misses the offset in order to skip over implicit self which results in `bad argument #2 to 'foreach' (string expected, got nil)` when invoking `uci.cursor():foreach("test", nil, function(s) end)`. The same call works fine when using dot instead of colon notation. Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
* file: remove unnecessary sync() callFelix Fietkau2015-08-271-1/+0
| | | | | | | | | It can be too expensive during filesystem initialization, and it is not required for atomic handling of config changes. If the write gets interrupted, the config file will always contain either the new state or the old state Signed-off-by: Felix Fietkau <nbd@openwrt.org>
* tests: add test case for parsing long option values.Yousong Zhou2015-05-251-0/+19
| | | | Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
* file.c: lift the 4096 bytes line length limit.Yousong Zhou2015-05-251-4/+2
| | | | Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
* delta: catch error when parsing delta line.Yousong Zhou2015-05-251-2/+4
| | | | | | | | | Reported by sarumpaet [1] [1] uci fails to handle long values properly, https://github.com/openwrt/packages/issues/1231 Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
* cli: suppress printing error messages when -q is specified.Yousong Zhou2015-05-251-6/+20
| | | | | | | | | - Introduce cli_error() for printing local errors. - Convert existing fprintf(stderr, ) and perror() to cli_error(). - N.B. error messages will still be printed if they occured before -q flag was parsed. Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
* uci: properly close input before exitHans Dedecker2015-05-081-0/+1
| | | | Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
* file: reset parsing position on starting over a newline.Yousong Zhou2015-04-091-2/+3
| | | | Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
* tests: add test coverage for comment lines within batch commands.Yousong Zhou2015-04-092-0/+35
| | | | Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
* delta: fix adding new savedir.Yousong Zhou2015-04-031-3/+2
| | | | | | | Newly added savedir should be at the last position while uci_add_delta_path() will add it to the position second to the last. Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
* tests: add test coverage for uci export with -P option.Yousong Zhou2015-04-033-4/+17
| | | | | | | | - With "uci -P xxx/ export", changes in "xxx/" should be applied last. - With "uci -p xxx/ commit", changes in "xxx/" should be applied before ctx->savedir. Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
* Fix delta path handling.Yousong Zhou2015-03-313-8/+38
| | | | | | - Make ctx->savedir sit at the end of ctx->delta_path. - Add notes to uci_set_savedir() and uci_add_delta_path() to document the behaviour changes.
* tests: add test cases for -P and -p options.Yousong Zhou2015-03-312-0/+43
|
* lua: restore return value of require('uci') to module table.Yousong Zhou2015-03-261-1/+2
| | | | | | | | | | | | | Before commit "b121dd lua: add lua 5.2 compatibility changes", the module table was filled by luaL_register() which would leave the table at the top of the stack. But in current code the module table will be popped by lua_setglobal() causing the return value defaulting to boolean value true. Also fix the return value of luaopen_uci() to 1 to indicate the number of return value on stack. Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
* cli: fix return value of package_cmd().Yousong Zhou2015-03-261-1/+6
| | | | | | | | It's a bug revealed by commit 446e774 "cli: properly unload package before quit". The current code would exit with value 1 even if uci_export() succceeded. Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
* testenv: test for exit status of "uci export".Yousong Zhou2015-03-261-0/+8
| | | | Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
* Add a few notes on the return value of uci_lookup_ptr().Yousong Zhou2015-01-242-2/+10
| | | | | | | While at it, use UCI_OK instead of literal integer 0 for return value of uci_lookup_ptr(). Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
* cli: enhance "uci show" command on nonexistent sections and options.Yousong Zhou2015-01-241-0/+1
| | | | | | | | | When doing "uci show network.nilsection", the current behaviour is that uci will emit a error message complaining "Entry not found", then continue to show all content of the package network itself. This is couter-intuition. Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
* cli: properly unload package before quit.Yousong Zhou2015-01-241-6/+7
| | | | Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
* tests: add test cases for showing nonexistent section and option.Yousong Zhou2015-01-242-1/+4
| | | | | | Also fix the false error message about absence of uci-static. Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
* lua: add lua 5.2 compatibility changesFelix Fietkau2014-12-181-6/+30
| | | | Signed-off-by: Felix Fietkau <nbd@openwrt.org>
* allow "-" in package namesFelix Fietkau2014-12-185-22/+26
| | | | Signed-off-by: Felix Fietkau <nbd@openwrt.org>
* delta: fix outputing of delta entries occupying multiple lines.Yousong Zhou2014-12-181-39/+46
| | | | Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
* delta: use a table for converting between UCI_CMD_XXX and prefixes.Yousong Zhou2014-12-182-45/+25
| | | | Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
* delta: preprocess delta line with uci_parse_argument().Yousong Zhou2014-12-182-17/+15
| | | | Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
* delta: add a simple duplication check when adding delta path.Yousong Zhou2014-12-182-0/+4
| | | | Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
* cli: fix printing option values occupying multiple lines.Yousong Zhou2014-12-181-10/+35
| | | | Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
* tests: add test coverage for uci list related commands.Yousong Zhou2014-12-186-0/+74
| | | | Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
* tests: add test coverage for `uci revert' command.Yousong Zhou2014-12-184-0/+33
| | | | Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
* tests: add test coverage for `uci batch' command.Yousong Zhou2014-12-182-0/+26
| | | | Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
* tests: add more test coverage for `uci show' command.Yousong Zhou2014-12-185-0/+97
| | | | Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
* tests: remove straying echo in 020_get.Yousong Zhou2014-12-181-1/+0
| | | | Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
* file: fix error string about "unterminated XXX".Yousong Zhou2014-12-181-3/+1
| | | | | | | - Remove unreachable call to uci_parse_error(). - Fix false claim of unterminated double quote to single quote. Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
* file: fix EOF check.Yousong Zhou2014-12-181-2/+2
| | | | Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
* file: fix use-after-free bug.Yousong Zhou2014-12-181-12/+29
| | | | | | | Currently, it's possible that pointers returned by next_arg() could be invalidated by another call to next_arg() due to uci_realloc(). Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
* Fix memory leaks found by using valgrind on test cases.Yousong Zhou2014-12-182-3/+7
| | | | Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
* Fix a few style issues.Yousong Zhou2014-12-182-3/+1
| | | | | | | - Remove deprecated uci-static and ucimap-example from .gitignore. - Minor code formatting fix. Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
* fix a few formatting issuesFelix Fietkau2014-11-252-12/+10
| | | | Signed-off-by: Felix Fietkau <nbd@openwrt.org>
* tests: use uci instead of uci-staticFelix Fietkau2014-11-251-4/+4
| | | | Signed-off-by: Felix Fietkau <nbd@openwrt.org>
* Add test coverage for multi-line option value.Yousong Zhou2014-11-2514-6/+62
| | | | Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>