libubus: fix passing the return code of the subscriber callback to the notifier
[project/ubus.git] / libubus.h
index c16495e..08f9c5b 100644 (file)
--- a/libubus.h
+++ b/libubus.h
@@ -67,6 +67,12 @@ typedef void (*ubus_notify_complete_handler_t)(struct ubus_notify_request *req,
                .n_policy = ARRAY_SIZE(_policy)         \
        }
 
+#define UBUS_METHOD_NOARG(_name, _handler)             \
+       {                                               \
+               .name = _name,                          \
+               .handler = _handler,                    \
+       }
+
 struct ubus_method {
        const char *name;
        ubus_handler_t handler;
@@ -120,7 +126,7 @@ struct ubus_context {
        struct uloop_fd sock;
 
        uint32_t local_id;
-       uint32_t request_seq;
+       uint16_t request_seq;
        int stack_depth;
 
        void (*connection_lost)(struct ubus_context *ctx);
@@ -141,7 +147,7 @@ struct ubus_object_data {
 struct ubus_request_data {
        uint32_t object;
        uint32_t peer;
-       uint32_t seq;
+       uint16_t seq;
        bool deferred;
 };
 
@@ -156,7 +162,7 @@ struct ubus_request {
        bool notify;
 
        uint32_t peer;
-       uint32_t seq;
+       uint16_t seq;
 
        ubus_data_handler_t raw_data_cb;
        ubus_data_handler_t data_cb;
@@ -221,6 +227,13 @@ int ubus_remove_object(struct ubus_context *ctx, struct ubus_object *obj);
 
 /* add a subscriber notifications from another object */
 int ubus_register_subscriber(struct ubus_context *ctx, struct ubus_subscriber *obj);
+
+static inline int
+ubus_unregister_subscriber(struct ubus_context *ctx, struct ubus_subscriber *obj)
+{
+       return ubus_remove_object(ctx, &obj->obj);
+}
+
 int ubus_subscribe(struct ubus_context *ctx, struct ubus_subscriber *obj, uint32_t id);
 int ubus_unsubscribe(struct ubus_context *ctx, struct ubus_subscriber *obj, uint32_t id);