iwinfo: convert to plugin library
authorJo-Philipp Wich <jow@openwrt.org>
Mon, 2 Sep 2013 12:52:22 +0000 (14:52 +0200)
committerJo-Philipp Wich <jow@openwrt.org>
Mon, 2 Sep 2013 13:23:09 +0000 (15:23 +0200)
iwinfo.c
iwinfo.h
main.c

index d3866cb..893da01 100644 (file)
--- a/iwinfo.c
+++ b/iwinfo.c
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-#include <sys/types.h>
-#include <dirent.h>
-
 #include "iwinfo.h"
+#include "plugin.h"
 
 static struct blob_buf buf;
 static const struct iwinfo_ops *iw;
@@ -622,7 +620,8 @@ rpc_iwinfo_devices(struct ubus_context *ctx, struct ubus_object *obj,
 }
 
 
-int rpc_iwinfo_api_init(struct ubus_context *ctx)
+static int
+rpc_iwinfo_api_init(const struct rpc_daemon_ops *o, struct ubus_context *ctx)
 {
        static const struct ubus_method iwinfo_methods[] = {
                { .name = "devices", .handler = rpc_iwinfo_devices },
@@ -646,3 +645,7 @@ int rpc_iwinfo_api_init(struct ubus_context *ctx)
 
        return ubus_add_object(ctx, &obj);
 }
+
+const struct rpc_plugin rpc_plugin = {
+       .init = rpc_iwinfo_api_init
+};
index 0464815..bc1a8bb 100644 (file)
--- a/iwinfo.h
+++ b/iwinfo.h
 #ifndef __RPC_IWINFO_H
 #define __RPC_IWINFO_H
 
+#include <sys/types.h>
+#include <dirent.h>
 #include <libubus.h>
 #include <iwinfo.h>
 #include <iwinfo/utils.h>
 
-int rpc_iwinfo_api_init(struct ubus_context *ctx);
-
 #endif
diff --git a/main.c b/main.c
index c8b6d41..4b8956f 100644 (file)
--- a/main.c
+++ b/main.c
@@ -26,7 +26,6 @@
 #include "session.h"
 #include "file.h"
 #include "uci.h"
-#include "iwinfo.h"
 #include "luci2.h"
 #include "plugin.h"
 
@@ -65,7 +64,6 @@ int main(int argc, char **argv)
        rpc_session_api_init(ctx);
        rpc_file_api_init(ctx);
        rpc_uci_api_init(ctx);
-       rpc_iwinfo_api_init(ctx);
        rpc_luci2_api_init(ctx);
        rpc_plugin_api_init(ctx);