2 * Copyright (C) 2020 Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 * SPDX-License-Identifier: LGPL-2.1-only
8 #include <common/dynamic-array.hpp>
9 #include <common/buffer-view.hpp>
10 #include "payload-view.hpp"
11 #include "payload.hpp"
14 bool lttng_payload_view_is_valid(const struct lttng_payload_view
*view
)
16 return view
&& lttng_buffer_view_is_valid(&view
->buffer
);
19 struct lttng_payload_view
lttng_payload_view_from_payload(
20 const struct lttng_payload
*payload
, size_t offset
,
23 return payload
? (struct lttng_payload_view
) {
24 .buffer
= lttng_buffer_view_from_dynamic_buffer(
25 &payload
->buffer
, offset
, len
),
26 ._fd_handles
= payload
->_fd_handles
,
28 } : (struct lttng_payload_view
) {
35 struct lttng_payload_view
lttng_payload_view_from_view(
36 struct lttng_payload_view
*view
, size_t offset
,
39 return view
? (struct lttng_payload_view
) {
40 .buffer
= lttng_buffer_view_from_view(
41 &view
->buffer
, offset
, len
),
42 ._fd_handles
= view
->_fd_handles
,
44 .p_fd_handles_position
= view
->_iterator
.p_fd_handles_position
?:
45 &view
->_iterator
.fd_handles_position
,
46 .fd_handles_position
= 0,
48 } : (struct lttng_payload_view
) {
55 struct lttng_payload_view
lttng_payload_view_from_dynamic_buffer(
56 const struct lttng_dynamic_buffer
*buffer
, size_t offset
,
59 return buffer
? (struct lttng_payload_view
) {
60 .buffer
= lttng_buffer_view_from_dynamic_buffer(
64 } : (struct lttng_payload_view
) {
71 struct lttng_payload_view
lttng_payload_view_from_buffer_view(
72 const struct lttng_buffer_view
*view
, size_t offset
,
75 return view
? (struct lttng_payload_view
) {
76 .buffer
= lttng_buffer_view_from_view(
80 } : (struct lttng_payload_view
) {
87 struct lttng_payload_view
lttng_payload_view_init_from_buffer(
88 const char *src
, size_t offset
, ptrdiff_t len
)
90 return (struct lttng_payload_view
) {
91 .buffer
= lttng_buffer_view_init(
98 int lttng_payload_view_get_fd_handle_count(
99 const struct lttng_payload_view
*payload_view
)
109 ret
= lttng_dynamic_pointer_array_get_count(&payload_view
->_fd_handles
);
114 position
= payload_view
->_iterator
.p_fd_handles_position
?
115 *payload_view
->_iterator
.p_fd_handles_position
:
116 payload_view
->_iterator
.fd_handles_position
;
117 ret
= ret
- (int) position
;
122 struct fd_handle
*lttng_payload_view_pop_fd_handle(
123 struct lttng_payload_view
*view
)
125 struct fd_handle
*handle
= NULL
;
126 size_t fd_handle_count
;
133 fd_handle_count
= lttng_payload_view_get_fd_handle_count(view
);
134 if (fd_handle_count
== 0) {
138 pos
= view
->_iterator
.p_fd_handles_position
?
139 view
->_iterator
.p_fd_handles_position
:
140 &view
->_iterator
.fd_handles_position
;
141 handle
= (fd_handle
*) lttng_dynamic_pointer_array_get_pointer(&view
->_fd_handles
,
144 fd_handle_get(handle
);
This page took 0.031802 seconds and 4 git commands to generate.