add the service object
authorFelix Fietkau <nbd@openwrt.org>
Fri, 1 Jun 2012 10:00:55 +0000 (12:00 +0200)
committerFelix Fietkau <nbd@openwrt.org>
Fri, 1 Jun 2012 10:00:55 +0000 (12:00 +0200)
CMakeLists.txt
api.c [new file with mode: 0644]
procd.h
ubus.c

index b696b3262fa4de753341c898b8bff29106d49e18..16e7cb5869b202eed285ddb96500e4fbbbf5b904 100644 (file)
@@ -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)
 
diff --git a/api.c b/api.c
new file mode 100644 (file)
index 0000000..623f123
--- /dev/null
+++ b/api.c
@@ -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);
+}
diff --git a/procd.h b/procd.h
index cc063b36b54a741174d4aac6c6992ecc87b8b136..8b331438b71272f3e8b116c1b77a6dae2dff4d03 100644 (file)
--- a/procd.h
+++ b/procd.h
@@ -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
diff --git a/ubus.c b/ubus.c
index bba59b48a61a7c58a676a28a859006028889e026..1ba7965581995636a75c144db8f8a4a637090520 100644 (file)
--- a/ubus.c
+++ b/ubus.c
@@ -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)