Add deserialization of action object
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 1 Mar 2017 03:01:18 +0000 (22:01 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 1 Mar 2017 04:02:50 +0000 (23:02 -0500)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
include/lttng/action/action-internal.h
src/lib/lttng-ctl/action.c

index 57a804d14fb45503816ec6c4014cb8cda0c196d8..1ed585d686cd79d3ba0164cb49b57b8cbe3edc2a 100644 (file)
@@ -44,4 +44,8 @@ bool lttng_action_validate(struct lttng_action *action);
 LTTNG_HIDDEN
 ssize_t lttng_action_serialize(struct lttng_action *action, char *buf);
 
+LTTNG_HIDDEN
+ssize_t lttng_action_create_from_buffer(const char *buf,
+               struct lttng_action **action);
+
 #endif /* LTTNG_ACTION_INTERNAL_H */
index a97a3463f5500ea4fd0f444b7ba44491aa219c57..7deb509e3e09690ea6b0ede59c749eec0a8f3ec3 100644 (file)
@@ -16,6 +16,7 @@
  */
 
 #include <lttng/action/action-internal.h>
+#include <lttng/action/notify-internal.h>
 #include <assert.h>
 
 enum lttng_action_type lttng_action_get_type(struct lttng_action *action)
@@ -81,3 +82,36 @@ ssize_t lttng_action_serialize(struct lttng_action *action, char *buf)
 end:
        return ret;
 }
+
+LTTNG_HIDDEN
+ssize_t lttng_action_create_from_buffer(const char *buf,
+               struct lttng_action **_action)
+{
+       ssize_t ret, action_size = sizeof(struct lttng_action_comm);
+       struct lttng_action *action;
+       struct lttng_action_comm *action_comm =
+                       (struct lttng_action_comm *) buf;
+
+       if (!buf || !_action) {
+               ret = -1;
+               goto end;
+       }
+
+       switch (action_comm->action_type) {
+       case LTTNG_ACTION_TYPE_NOTIFY:
+               action = lttng_action_notify_create();
+               break;
+       default:
+               ret = -1;
+               goto end;
+       }
+
+       if (!action) {
+               ret = -1;
+               goto end;
+       }
+       ret = action_size;
+       *_action = action;
+end:
+       return ret;
+}
This page took 0.028183 seconds and 5 git commands to generate.