Commit | Line | Data |
---|---|---|
f3ed775e DG |
1 | /* |
2 | * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca> | |
3 | * | |
d14d33bf AM |
4 | * This program is free software; you can redistribute it and/or modify |
5 | * it under the terms of the GNU General Public License, version 2 only, | |
6 | * as published by the Free Software Foundation. | |
f3ed775e DG |
7 | * |
8 | * This program is distributed in the hope that it will be useful, | |
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 | * GNU General Public License for more details. | |
12 | * | |
d14d33bf AM |
13 | * You should have received a copy of the GNU General Public License along |
14 | * with this program; if not, write to the Free Software Foundation, Inc., | |
15 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
f3ed775e DG |
16 | */ |
17 | ||
18 | #ifndef _LTTNG_CMD_H | |
19 | #define _LTTNG_CMD_H | |
20 | ||
21 | #include <lttng/lttng.h> | |
990570ed DG |
22 | #include <common/common.h> |
23 | #include <common/defaults.h> | |
f3ed775e | 24 | |
c399183f DG |
25 | #include "conf.h" |
26 | #include "utils.h" | |
27 | ||
5e71a0e8 PP |
28 | #define DECL_COMMAND(_name) \ |
29 | extern int cmd_##_name(int, const char **) | |
30 | ||
4fc83d94 PP |
31 | #ifdef LTTNG_EMBED_HELP |
32 | # define HELP_MSG_NAME help_msg | |
33 | # define SHOW_HELP_ERROR_LINE ERR("Cannot show --help for `lttng-%s`", argv[0]); | |
34 | #else | |
35 | # define HELP_MSG_NAME NULL | |
36 | # define SHOW_HELP_ERROR_LINE ; | |
37 | #endif | |
38 | ||
4ba92f18 PP |
39 | #define SHOW_HELP() \ |
40 | do { \ | |
4fc83d94 | 41 | ret = show_cmd_help(argv[0], HELP_MSG_NAME); \ |
4ba92f18 PP |
42 | \ |
43 | if (ret) { \ | |
4fc83d94 | 44 | SHOW_HELP_ERROR_LINE \ |
960afba4 | 45 | ret = CMD_ERROR; \ |
4ba92f18 PP |
46 | } \ |
47 | } while (0) | |
48 | ||
f3ed775e | 49 | enum cmd_error_code { |
42224349 | 50 | CMD_SUCCESS = 0, |
f3ed775e DG |
51 | CMD_ERROR, |
52 | CMD_UNDEFINED, | |
f3ed775e | 53 | CMD_FATAL, |
d16c1a4c | 54 | CMD_WARNING, |
4ce78777 | 55 | CMD_UNSUPPORTED, |
f3ed775e DG |
56 | }; |
57 | ||
58 | struct cmd_struct { | |
59 | const char *name; | |
60 | int (*func)(int argc, const char **argv); | |
61 | }; | |
62 | ||
5e71a0e8 | 63 | DECL_COMMAND(list); |
54a0adbf | 64 | DECL_COMMAND(status); |
5e71a0e8 PP |
65 | DECL_COMMAND(create); |
66 | DECL_COMMAND(destroy); | |
67 | DECL_COMMAND(start); | |
68 | DECL_COMMAND(stop); | |
69 | DECL_COMMAND(enable_events); | |
70 | DECL_COMMAND(disable_events); | |
71 | DECL_COMMAND(enable_channels); | |
72 | DECL_COMMAND(disable_channels); | |
73 | DECL_COMMAND(add_context); | |
74 | DECL_COMMAND(set_session); | |
75 | DECL_COMMAND(version); | |
5e71a0e8 PP |
76 | DECL_COMMAND(view); |
77 | DECL_COMMAND(enable_consumer); | |
78 | DECL_COMMAND(disable_consumer); | |
79 | DECL_COMMAND(snapshot); | |
80 | DECL_COMMAND(save); | |
81 | DECL_COMMAND(load); | |
82 | DECL_COMMAND(track); | |
83 | DECL_COMMAND(untrack); | |
93ec662e | 84 | DECL_COMMAND(metadata); |
eded6438 | 85 | DECL_COMMAND(regenerate); |
f3ed775e | 86 | |
960afba4 PP |
87 | extern int cmd_help(int argc, const char **argv, |
88 | const struct cmd_struct commands[]); | |
89 | ||
f3ed775e | 90 | #endif /* _LTTNG_CMD_H */ |