-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathctrl.c
52 lines (39 loc) · 1.12 KB
/
ctrl.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <unistd.h>
#include <stdio.h>
#include <libubox/blobmsg_json.h>
#include <libubus.h>
#include "lv_8ms.h"
#include "wtctrl.h"
static struct blob_buf g_ctrl_bbuf;
static int lv_ubus_ctrl(struct ubus_context *ctx, struct ubus_object *obj,
struct ubus_request_data *req, const char *method, struct blob_attr *msg)
{
char *str;
char *res;
blob_buf_init(&g_ctrl_bbuf, 0);
str = blobmsg_format_json(msg, true);
if (str) {
res = wtctrl_json_parse(str);
if (res) {
blobmsg_add_json_from_string(&g_ctrl_bbuf, res);
free(res);
}
}
ubus_send_reply(ctx, req, g_ctrl_bbuf.head);
return 0;
}
static const struct ubus_method lv_ubus_methods[] = {
{ .name = "ctrl", .handler = lv_ubus_ctrl },
};
static struct ubus_object_type lv_ubus_object_type =
UBUS_OBJECT_TYPE("8ms", lv_ubus_methods);
static struct ubus_object lv_ubus_object = {
.name = "8ms",
.type = &lv_ubus_object_type,
.methods = lv_ubus_methods,
.n_methods = ARRAY_SIZE(lv_ubus_methods),
};
int lv_8ms_ctrl_init(void)
{
return lv_8ms_add_object(&lv_ubus_object);
}