Commit | Line | Data |
---|---|---|
f3ed775e | 1 | /* |
21cf9b6b | 2 | * Copyright (C) 2011 EfficiOS Inc. |
f3ed775e | 3 | * |
ab5be9fa | 4 | * SPDX-License-Identifier: GPL-2.0-only |
f3ed775e | 5 | * |
f3ed775e DG |
6 | */ |
7 | ||
8 | #ifndef _LTTNG_CMD_H | |
9 | #define _LTTNG_CMD_H | |
10 | ||
11 | #include <lttng/lttng.h> | |
c9e313bc SM |
12 | #include <common/common.hpp> |
13 | #include <common/defaults.hpp> | |
f3ed775e | 14 | |
c9e313bc SM |
15 | #include "conf.hpp" |
16 | #include "utils.hpp" | |
c399183f | 17 | |
5e71a0e8 PP |
18 | #define DECL_COMMAND(_name) \ |
19 | extern int cmd_##_name(int, const char **) | |
20 | ||
4fc83d94 PP |
21 | #ifdef LTTNG_EMBED_HELP |
22 | # define HELP_MSG_NAME help_msg | |
23 | # define SHOW_HELP_ERROR_LINE ERR("Cannot show --help for `lttng-%s`", argv[0]); | |
24 | #else | |
25 | # define HELP_MSG_NAME NULL | |
26 | # define SHOW_HELP_ERROR_LINE ; | |
27 | #endif | |
28 | ||
4ba92f18 PP |
29 | #define SHOW_HELP() \ |
30 | do { \ | |
4fc83d94 | 31 | ret = show_cmd_help(argv[0], HELP_MSG_NAME); \ |
4ba92f18 PP |
32 | \ |
33 | if (ret) { \ | |
4fc83d94 | 34 | SHOW_HELP_ERROR_LINE \ |
960afba4 | 35 | ret = CMD_ERROR; \ |
4ba92f18 PP |
36 | } \ |
37 | } while (0) | |
38 | ||
f3ed775e | 39 | enum cmd_error_code { |
42224349 | 40 | CMD_SUCCESS = 0, |
f3ed775e DG |
41 | CMD_ERROR, |
42 | CMD_UNDEFINED, | |
f3ed775e | 43 | CMD_FATAL, |
d16c1a4c | 44 | CMD_WARNING, |
4ce78777 | 45 | CMD_UNSUPPORTED, |
f3ed775e DG |
46 | }; |
47 | ||
48 | struct cmd_struct { | |
49 | const char *name; | |
50 | int (*func)(int argc, const char **argv); | |
51 | }; | |
52 | ||
5e71a0e8 | 53 | DECL_COMMAND(list); |
54a0adbf | 54 | DECL_COMMAND(status); |
5e71a0e8 PP |
55 | DECL_COMMAND(create); |
56 | DECL_COMMAND(destroy); | |
57 | DECL_COMMAND(start); | |
58 | DECL_COMMAND(stop); | |
59 | DECL_COMMAND(enable_events); | |
60 | DECL_COMMAND(disable_events); | |
61 | DECL_COMMAND(enable_channels); | |
62 | DECL_COMMAND(disable_channels); | |
63 | DECL_COMMAND(add_context); | |
64 | DECL_COMMAND(set_session); | |
65 | DECL_COMMAND(version); | |
5e71a0e8 PP |
66 | DECL_COMMAND(view); |
67 | DECL_COMMAND(enable_consumer); | |
68 | DECL_COMMAND(disable_consumer); | |
69 | DECL_COMMAND(snapshot); | |
70 | DECL_COMMAND(save); | |
71 | DECL_COMMAND(load); | |
72 | DECL_COMMAND(track); | |
73 | DECL_COMMAND(untrack); | |
93ec662e | 74 | DECL_COMMAND(metadata); |
eded6438 | 75 | DECL_COMMAND(regenerate); |
d68c9a04 | 76 | DECL_COMMAND(rotate); |
259c2674 JD |
77 | DECL_COMMAND(enable_rotation); |
78 | DECL_COMMAND(disable_rotation); | |
511ed4e2 | 79 | DECL_COMMAND(clear); |
4624dad0 | 80 | DECL_COMMAND(add_trigger); |
0de2479d | 81 | DECL_COMMAND(list_triggers); |
b61776fb | 82 | DECL_COMMAND(remove_trigger); |
f3ed775e | 83 | |
960afba4 PP |
84 | extern int cmd_help(int argc, const char **argv, |
85 | const struct cmd_struct commands[]); | |
86 | ||
f3ed775e | 87 | #endif /* _LTTNG_CMD_H */ |