diff options
Diffstat (limited to 'lib/uci.c')
-rw-r--r-- | lib/uci.c | 20 |
1 files changed, 19 insertions, 1 deletions
@@ -151,6 +151,13 @@ uc_uci_error(uc_vm_t *vm, size_t nargs) * uncommitted application changes from the uci cli or other processes on the * system. * + * @param {string} [config2_dir=/var/run/uci] + * The directory to keep override config files in. Files are in the same format + * as in config_dir, but can individually override ones from that directory. + * It defaults to the uci configuration directory `/var/run/uci` but may be + * set to a different path for special purpose applications, or even disabled + * by setting this parameter to an empty string. + * * @returns {?module:uci.cursor} */ static uc_value_t * @@ -158,11 +165,13 @@ uc_uci_cursor(uc_vm_t *vm, size_t nargs) { uc_value_t *cdir = uc_fn_arg(0); uc_value_t *sdir = uc_fn_arg(1); + uc_value_t *c2dir = uc_fn_arg(2); struct uci_context *c; int rv; if ((cdir && ucv_type(cdir) != UC_STRING) || - (sdir && ucv_type(sdir) != UC_STRING)) + (sdir && ucv_type(sdir) != UC_STRING) || + (c2dir && ucv_type(c2dir) != UC_STRING)) err_return(UCI_ERR_INVAL); c = uci_alloc_context(); @@ -184,6 +193,15 @@ uc_uci_cursor(uc_vm_t *vm, size_t nargs) err_return(rv); } +#ifdef HAVE_UCI_CONF2DIR + if (c2dir) { + rv = uci_set_conf2dir(c, ucv_string_get(c2dir)); + + if (rv) + err_return(rv); + } +#endif + ok_return(ucv_resource_create(vm, "uci.cursor", c)); } |