summaryrefslogtreecommitdiffhomepage
path: root/proto-shell.c
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2013-09-24 11:53:48 +0200
committerFelix Fietkau <nbd@openwrt.org>2013-10-22 14:10:33 +0200
commit72adf25cf21490aef012bb9314357f9b381934f9 (patch)
tree78adc9931f90b29937196f6cfa85c45ba3de5a11 /proto-shell.c
parentf88b0173d22e7f86ad8441c9a5bc76cee77f721a (diff)
proto-shell: move more core to handler.c
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Diffstat (limited to 'proto-shell.c')
-rw-r--r--proto-shell.c24
1 files changed, 4 insertions, 20 deletions
diff --git a/proto-shell.c b/proto-shell.c
index d383cbf..aa638ad 100644
--- a/proto-shell.c
+++ b/proto-shell.c
@@ -734,30 +734,14 @@ error:
return NULL;
}
-static inline json_object *
-get_field(json_object *obj, const char *name, json_type type)
-{
- return json_check_type(json_object_object_get(obj, name), type);
-}
-
static void
-proto_shell_add_handler(const char *script, json_object *obj)
+proto_shell_add_handler(const char *script, const char *name, json_object *obj)
{
struct proto_shell_handler *handler;
struct proto_handler *proto;
json_object *config, *tmp;
- const char *name;
char *str;
- if (!json_check_type(obj, json_type_object))
- return;
-
- tmp = get_field(obj, "name", json_type_string);
- if (!tmp)
- return;
-
- name = json_object_get_string(tmp);
-
handler = calloc_a(sizeof(*handler) + strlen(script) + 1,
&str, strlen(name) + 1);
if (!handler)
@@ -771,15 +755,15 @@ proto_shell_add_handler(const char *script, json_object *obj)
proto->config_params = &handler->config;
proto->attach = proto_shell_attach;
- tmp = get_field(obj, "no-device", json_type_boolean);
+ tmp = json_get_field(obj, "no-device", json_type_boolean);
if (tmp && json_object_get_boolean(tmp))
handler->proto.flags |= PROTO_FLAG_NODEV;
- tmp = get_field(obj, "available", json_type_boolean);
+ tmp = json_get_field(obj, "available", json_type_boolean);
if (tmp && json_object_get_boolean(tmp))
handler->proto.flags |= PROTO_FLAG_INIT_AVAILABLE;
- config = get_field(obj, "config", json_type_array);
+ config = json_get_field(obj, "config", json_type_array);
if (config)
handler->config_buf = netifd_handler_parse_config(&handler->config, config);