Rename from "luci-rpcd" to "rpcd"
[project/rpcd.git] / file.c
diff --git a/file.c b/file.c
index d419846..0e8df4f 100644 (file)
--- a/file.c
+++ b/file.c
@@ -1,5 +1,5 @@
 /*
- * luci-rpcd - LuCI UBUS RPC server
+ * rpcd - UBUS RPC server
  *
  *   Copyright (C) 2013 Jo-Philipp Wich <jow@openwrt.org>
  *
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-#include <fcntl.h>
-#include <errno.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
-#include <limits.h>
-#include <dirent.h>
-#include <sys/stat.h>
-#include <sys/wait.h>
-
 #include "file.h"
+#include "plugin.h"
 
 static struct blob_buf buf;
 
@@ -45,7 +36,6 @@ enum {
        RPC_E_CMD,
        RPC_E_PARM,
        RPC_E_ENV,
-       RPC_E_MODE,
        __RPC_E_MAX,
 };
 
@@ -53,7 +43,6 @@ static const struct blobmsg_policy rpc_exec_policy[__RPC_E_MAX] = {
        [RPC_E_CMD] = { .name = "command", .type = BLOBMSG_TYPE_STRING },
        [RPC_E_PARM] = { .name = "params",  .type = BLOBMSG_TYPE_ARRAY  },
        [RPC_E_ENV]  = { .name = "env",     .type = BLOBMSG_TYPE_TABLE  },
-       [RPC_E_MODE] = { .name = "mode",    .type = BLOBMSG_TYPE_STRING },
 };
 
 static const char *d_types[] = {
@@ -383,7 +372,7 @@ static void
 rpc_file_exec_opipe_read_cb(struct ustream *s, int bytes)
 {
        struct rpc_file_exec_context *c =
-               container_of(s, struct rpc_file_exec_context, opipe);
+               container_of(s, struct rpc_file_exec_context, opipe.stream);
 
        if (ustream_read_buf_full(s))
                rpc_file_exec_reply(c, UBUS_STATUS_NOT_SUPPORTED);
@@ -393,7 +382,7 @@ static void
 rpc_file_exec_epipe_read_cb(struct ustream *s, int bytes)
 {
        struct rpc_file_exec_context *c =
-               container_of(s, struct rpc_file_exec_context, epipe);
+               container_of(s, struct rpc_file_exec_context, epipe.stream);
 
        if (ustream_read_buf_full(s))
                rpc_file_exec_reply(c, UBUS_STATUS_NOT_SUPPORTED);
@@ -403,7 +392,7 @@ static void
 rpc_file_exec_opipe_state_cb(struct ustream *s)
 {
        struct rpc_file_exec_context *c =
-               container_of(s, struct rpc_file_exec_context, opipe);
+               container_of(s, struct rpc_file_exec_context, opipe.stream);
 
        if (c->opipe.stream.eof && c->epipe.stream.eof)
                rpc_file_exec_reply(c, UBUS_STATUS_OK);
@@ -413,7 +402,7 @@ static void
 rpc_file_exec_epipe_state_cb(struct ustream *s)
 {
        struct rpc_file_exec_context *c =
-               container_of(s, struct rpc_file_exec_context, epipe);
+               container_of(s, struct rpc_file_exec_context, epipe.stream);
 
        if (c->opipe.stream.eof && c->epipe.stream.eof)
                rpc_file_exec_reply(c, UBUS_STATUS_OK);
@@ -548,7 +537,8 @@ rpc_file_exec(struct ubus_context *ctx, struct ubus_object *obj,
 }
 
 
-int rpc_file_api_init(struct ubus_context *ctx)
+static int
+rpc_file_api_init(const struct rpc_daemon_ops *o, struct ubus_context *ctx)
 {
        static const struct ubus_method file_methods[] = {
                UBUS_METHOD("read",    rpc_file_read,  rpc_file_policy),
@@ -570,3 +560,7 @@ int rpc_file_api_init(struct ubus_context *ctx)
 
        return ubus_add_object(ctx, &obj);
 }
+
+const struct rpc_plugin rpc_plugin = {
+       .init = rpc_file_api_init
+};