| 1 | /* |
| 2 | * Copyright (C) 2014 David Goulet <dgoulet@efficios.com> |
| 3 | * |
| 4 | * SPDX-License-Identifier: LGPL-2.1-only |
| 5 | * |
| 6 | */ |
| 7 | |
| 8 | #ifndef LTTNG_HANDLE_H |
| 9 | #define LTTNG_HANDLE_H |
| 10 | |
| 11 | #include <lttng/domain.h> |
| 12 | |
| 13 | #ifdef __cplusplus |
| 14 | extern "C" { |
| 15 | #endif |
| 16 | |
| 17 | /* |
| 18 | * Handle used as a context for commands. |
| 19 | * |
| 20 | * The structures should be initialized to zero before use. |
| 21 | */ |
| 22 | #define LTTNG_HANDLE_PADDING1 16 |
| 23 | struct lttng_handle { |
| 24 | char session_name[LTTNG_NAME_MAX]; |
| 25 | struct lttng_domain domain; |
| 26 | |
| 27 | char padding[LTTNG_HANDLE_PADDING1]; |
| 28 | }; |
| 29 | |
| 30 | /* |
| 31 | * Create an handle used as a context for every request made to the library. |
| 32 | * |
| 33 | * This handle contains the session name and domain on which the command will |
| 34 | * be executed. A domain is basically a tracer like the kernel or user space. |
| 35 | * |
| 36 | * A NULL domain indicates that the handle is not bound to a specific domain. |
| 37 | * This is mostly used for actions that apply on a session and not on a domain |
| 38 | * (e.g lttng_set_consumer_url). |
| 39 | * |
| 40 | * Return a newly allocated handle that should be freed using |
| 41 | * lttng_destroy_handle. On error, NULL is returned. |
| 42 | */ |
| 43 | extern struct lttng_handle *lttng_create_handle(const char *session_name, |
| 44 | struct lttng_domain *domain); |
| 45 | |
| 46 | /* |
| 47 | * Destroy an handle that has been previously created with lttng_create_handle. |
| 48 | * |
| 49 | * It free the given pointer making it unusable. |
| 50 | */ |
| 51 | extern void lttng_destroy_handle(struct lttng_handle *handle); |
| 52 | |
| 53 | |
| 54 | #ifdef __cplusplus |
| 55 | } |
| 56 | #endif |
| 57 | |
| 58 | #endif /* LTTNG_HANDLE_H */ |