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