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 | ||
28f23191 JG |
11 | #include "conf.hpp" |
12 | #include "utils.hpp" | |
13 | ||
c9e313bc SM |
14 | #include <common/common.hpp> |
15 | #include <common/defaults.hpp> | |
f3ed775e | 16 | |
28f23191 | 17 | #include <lttng/lttng.h> |
c399183f | 18 | |
28f23191 | 19 | #define DECL_COMMAND(_name) extern int cmd_##_name(int, const char **) |
5e71a0e8 | 20 | |
4fc83d94 | 21 | #ifdef LTTNG_EMBED_HELP |
28f23191 JG |
22 | #define HELP_MSG_NAME help_msg |
23 | #define SHOW_HELP_ERROR_LINE ERR("Cannot show --help for `lttng-%s`", argv[0]); | |
4fc83d94 | 24 | #else |
28f23191 JG |
25 | #define HELP_MSG_NAME NULL |
26 | #define SHOW_HELP_ERROR_LINE ; | |
4fc83d94 PP |
27 | #endif |
28 | ||
28f23191 JG |
29 | #define SHOW_HELP() \ |
30 | do { \ | |
31 | ret = show_cmd_help(argv[0], HELP_MSG_NAME); \ | |
32 | \ | |
33 | if (ret) { \ | |
34 | SHOW_HELP_ERROR_LINE \ | |
35 | ret = CMD_ERROR; \ | |
36 | } \ | |
4ba92f18 PP |
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 | |
28f23191 | 84 | extern int cmd_help(int argc, const char **argv, const struct cmd_struct commands[]); |
960afba4 | 85 | |
f3ed775e | 86 | #endif /* _LTTNG_CMD_H */ |