Commit | Line | Data |
---|---|---|
0c51e8f3 SM |
1 | /* |
2 | * Copyright (C) 2019 Simon Marchi <simon.marchi@efficios.com> | |
3 | * | |
4 | * SPDX-License-Identifier: LGPL-2.1-only | |
5 | * | |
6 | */ | |
7 | ||
702f26c8 JR |
8 | #ifndef LTTNG_ACTION_LIST_INTERNAL_H |
9 | #define LTTNG_ACTION_LIST_INTERNAL_H | |
0c51e8f3 | 10 | |
c9e313bc | 11 | #include <common/macros.hpp> |
0c51e8f3 | 12 | |
2460203a FD |
13 | #include <lttng/lttng-error.h> |
14 | ||
15 | #include <assert.h> | |
28f23191 JG |
16 | #include <sys/types.h> |
17 | ||
0c51e8f3 SM |
18 | struct lttng_action; |
19 | struct lttng_payload_view; | |
6a751b95 JR |
20 | struct mi_writer; |
21 | struct mi_lttng_error_query_callbacks; | |
22 | struct lttng_dynamic_array; | |
23 | struct lttng_trigger; | |
0c51e8f3 SM |
24 | |
25 | /* | |
702f26c8 | 26 | * Create an action list from a payload view. |
0c51e8f3 SM |
27 | * |
28 | * On success, return the number of bytes consumed from `view`, and the created | |
a8940c5e | 29 | * list in `*list`. On failure, return -1. |
0c51e8f3 | 30 | */ |
28f23191 JG |
31 | extern ssize_t lttng_action_list_create_from_payload(struct lttng_payload_view *view, |
32 | struct lttng_action **list); | |
33 | ||
34 | extern struct lttng_action * | |
35 | lttng_action_list_borrow_mutable_at_index(const struct lttng_action *list, unsigned int index); | |
36 | ||
37 | enum lttng_error_code | |
38 | lttng_action_list_mi_serialize(const struct lttng_trigger *trigger, | |
39 | const struct lttng_action *action, | |
40 | struct mi_writer *writer, | |
41 | const struct mi_lttng_error_query_callbacks *error_query_callbacks, | |
42 | struct lttng_dynamic_array *action_path_indexes); | |
6a751b95 | 43 | |
2460203a FD |
44 | #define for_each_action_const(__action_element, __action_list) \ |
45 | assert(lttng_action_get_type(__action_list) == LTTNG_ACTION_TYPE_LIST); \ | |
46 | \ | |
47 | for (unsigned int __action_idx = 0; \ | |
48 | (__action_element = lttng_action_list_get_at_index(__action_list, __action_idx)); \ | |
49 | __action_idx++) | |
50 | ||
51 | #define for_each_action_mutable(__action_element, __action_list) \ | |
52 | assert(lttng_action_get_type(__action_list) == LTTNG_ACTION_TYPE_LIST); \ | |
53 | \ | |
54 | for (unsigned int __action_idx = 0; \ | |
55 | (__action_element = \ | |
56 | lttng_action_list_borrow_mutable_at_index(__action_list, __action_idx)); \ | |
57 | __action_idx++) | |
58 | ||
702f26c8 | 59 | #endif /* LTTNG_ACTION_LIST_INTERNAL_H */ |