X-Git-Url: http://git.archive.openwrt.org/?p=project%2Frpcd.git;a=blobdiff_plain;f=uci.c;h=a49c8d0d4ad86ea0353a4399525314b30f63627f;hp=a133ff27606cab6969db9d00f38b36ec9000f457;hb=2f5a613718f5297febddb3ca7dc860ab6ed8c513;hpb=ae63188069e433c20b8add7b0fba636f36551ed0 diff --git a/uci.c b/uci.c index a133ff2..a49c8d0 100644 --- a/uci.c +++ b/uci.c @@ -520,9 +520,8 @@ rpc_uci_dump_package(struct uci_package *p, const char *name, static int -rpc_uci_get(struct ubus_context *ctx, struct ubus_object *obj, - struct ubus_request_data *req, const char *method, - struct blob_attr *msg) +rpc_uci_getcommon(struct ubus_context *ctx, struct ubus_request_data *req, + struct blob_attr *msg, bool use_state) { struct blob_attr *tb[__RPC_G_MAX]; struct uci_package *p = NULL; @@ -539,6 +538,9 @@ rpc_uci_get(struct ubus_context *ctx, struct ubus_object *obj, ptr.package = blobmsg_data(tb[RPC_G_CONFIG]); + if (use_state) + uci_set_savedir(cursor, "/var/state"); + if (uci_load(cursor, ptr.package, &p)) return rpc_uci_status(); @@ -582,6 +584,22 @@ out: } static int +rpc_uci_get(struct ubus_context *ctx, struct ubus_object *obj, + struct ubus_request_data *req, const char *method, + struct blob_attr *msg) +{ + return rpc_uci_getcommon(ctx, req, msg, false); +} + +static int +rpc_uci_state(struct ubus_context *ctx, struct ubus_object *obj, + struct ubus_request_data *req, const char *method, + struct blob_attr *msg) +{ + return rpc_uci_getcommon(ctx, req, msg, true); +} + +static int rpc_uci_add(struct ubus_context *ctx, struct ubus_object *obj, struct ubus_request_data *req, const char *method, struct blob_attr *msg) @@ -682,6 +700,7 @@ rpc_uci_merge_set(struct blob_attr *opt, struct uci_ptr *ptr) ptr->o = NULL; ptr->option = blobmsg_name(opt); + ptr->value = NULL; if (rpc_uci_lookup(ptr) || !ptr->s) return; @@ -1443,6 +1462,7 @@ int rpc_uci_api_init(struct ubus_context *ctx) static const struct ubus_method uci_methods[] = { { .name = "configs", .handler = rpc_uci_configs }, UBUS_METHOD("get", rpc_uci_get, rpc_uci_get_policy), + UBUS_METHOD("state", rpc_uci_state, rpc_uci_get_policy), UBUS_METHOD("add", rpc_uci_add, rpc_uci_add_policy), UBUS_METHOD("set", rpc_uci_set, rpc_uci_set_policy), UBUS_METHOD("delete", rpc_uci_delete, rpc_uci_delete_policy),