diff options
author | Felix Fietkau <nbd@openwrt.org> | 2012-06-01 12:00:55 +0200 |
---|---|---|
committer | Felix Fietkau <nbd@openwrt.org> | 2012-06-01 12:00:55 +0200 |
commit | 843fe9bb5b77fd20153816400ce918989730f99d (patch) | |
tree | 79d355a7b0dda58e078575de568ec14d3407ffd3 | |
parent | ca808f5c335a873c87359ce024e1a14ebae706b9 (diff) | |
download | unitd-843fe9bb5b77fd20153816400ce918989730f99d.tar unitd-843fe9bb5b77fd20153816400ce918989730f99d.zip |
add the service object
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rw-r--r-- | api.c | 29 | ||||
-rw-r--r-- | procd.h | 2 | ||||
-rw-r--r-- | ubus.c | 3 |
4 files changed, 33 insertions, 3 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index b696b32..16e7cb5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,7 +10,7 @@ IF(APPLE) LINK_DIRECTORIES(/opt/local/lib) ENDIF() -SET(SOURCES main.c ubus.c) +SET(SOURCES main.c ubus.c api.c) SET(LIBS ubox ubus) @@ -0,0 +1,29 @@ +#include "procd.h" + +static int +service_handle_list(struct ubus_context *ctx, struct ubus_object *obj, + struct ubus_request_data *req, const char *method, + struct blob_attr *msg) +{ + return 0; +} + +static struct ubus_method main_object_methods[] = { + { .name = "list", .handler = service_handle_list }, +}; + +static struct ubus_object_type main_object_type = + UBUS_OBJECT_TYPE("service", main_object_methods); + +static struct ubus_object main_object = { + .name = "service", + .type = &main_object_type, + .methods = main_object_methods, + .n_methods = ARRAY_SIZE(main_object_methods), +}; + + +void procd_register_objects(struct ubus_context *ctx) +{ + ubus_add_object(ctx, &main_object); +} @@ -2,6 +2,7 @@ #define __PROCD_H #include <libubox/uloop.h> +#include <libubus.h> #include <stdio.h> #define DPRINTF(fmt, ...) do { \ @@ -12,5 +13,6 @@ extern int debug; extern char *ubus_socket; void procd_connect_ubus(void); +void procd_register_objects(struct ubus_context *ctx); #endif @@ -2,8 +2,6 @@ #include <unistd.h> #include <signal.h> -#include <libubus.h> - #include "procd.h" char *ubus_socket = NULL; @@ -61,6 +59,7 @@ static void procd_ubus_try_connect(void) ctx->connection_lost = procd_ubus_connection_lost; ubus_connected = true; + procd_register_objects(ctx); } static void procd_ubus_connection_lost(struct ubus_context *old_ctx) |