| 1 | /* |
| 2 | * Copyright (C) 2019 Jonathan Rajotte-Julien <jonathan.rajotte-julien@efficios.com> |
| 3 | * |
| 4 | * SPDX-License-Identifier: LGPL-2.1-only |
| 5 | * |
| 6 | */ |
| 7 | |
| 8 | #ifndef LTTNG_TRACKER_INTERNAL_H |
| 9 | #define LTTNG_TRACKER_INTERNAL_H |
| 10 | |
| 11 | #include <common/macros.h> |
| 12 | #include <common/dynamic-buffer.h> |
| 13 | #include <lttng/constant.h> |
| 14 | #include <lttng/tracker.h> |
| 15 | #include <stdbool.h> |
| 16 | |
| 17 | struct lttng_tracker_id { |
| 18 | enum lttng_tracker_id_type type; |
| 19 | int value; |
| 20 | char *string; |
| 21 | }; |
| 22 | |
| 23 | struct lttng_tracker_ids { |
| 24 | struct lttng_tracker_id *id_array; |
| 25 | unsigned int count; |
| 26 | }; |
| 27 | |
| 28 | LTTNG_HIDDEN |
| 29 | bool lttng_tracker_id_is_equal(const struct lttng_tracker_id *left, |
| 30 | const struct lttng_tracker_id *right); |
| 31 | |
| 32 | /* |
| 33 | * A copy acts like memcpy. It does not allocate new memory. |
| 34 | */ |
| 35 | LTTNG_HIDDEN |
| 36 | int lttng_tracker_id_copy(struct lttng_tracker_id *dest, |
| 37 | const struct lttng_tracker_id *src); |
| 38 | |
| 39 | /* |
| 40 | * Duplicate an lttng_tracker_id. |
| 41 | * The returned object must be freed via lttng_tracker_id_destroy. |
| 42 | */ |
| 43 | LTTNG_HIDDEN |
| 44 | struct lttng_tracker_id *lttng_tracker_id_duplicate( |
| 45 | const struct lttng_tracker_id *src); |
| 46 | |
| 47 | /* |
| 48 | * Allocate a new list of lttng_tracker_id. |
| 49 | * The returned object must be freed via lttng_tracker_ids_destroy. |
| 50 | */ |
| 51 | LTTNG_HIDDEN |
| 52 | struct lttng_tracker_ids *lttng_tracker_ids_create(unsigned int base_count); |
| 53 | |
| 54 | /* |
| 55 | * Return the non-const pointer of an element at index "index" of a |
| 56 | * lttng_tracker_ids. |
| 57 | * |
| 58 | * The ownership of the lttng_tracker_id element is NOT transfered. |
| 59 | * The returned object can NOT be freed via lttng_tracker_id_destroy. |
| 60 | */ |
| 61 | LTTNG_HIDDEN |
| 62 | struct lttng_tracker_id *lttng_tracker_ids_get_pointer_of_index( |
| 63 | const struct lttng_tracker_ids *list, unsigned int index); |
| 64 | |
| 65 | /* |
| 66 | * Serialize a ids collection to a lttng_dynamic_buffer. |
| 67 | * Return LTTNG_OK on success, negative lttng error code on error. |
| 68 | */ |
| 69 | LTTNG_HIDDEN |
| 70 | int lttng_tracker_ids_serialize(const struct lttng_tracker_ids *ids, |
| 71 | struct lttng_dynamic_buffer *buffer); |
| 72 | |
| 73 | #endif /* LTTNG_TRACKER_INTERNAL_H */ |