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 | ||
4ba92f18 PP |
31 | #define SHOW_HELP() \ |
32 | do { \ | |
33 | ret = show_cmd_man_page(argv[0]); \ | |
34 | \ | |
35 | if (ret) { \ | |
36 | ERR("Cannot view man page lttng-%s(1)", argv[0]); \ | |
37 | perror("exec"); \ | |
960afba4 | 38 | ret = CMD_ERROR; \ |
4ba92f18 PP |
39 | } \ |
40 | } while (0) | |
41 | ||
f3ed775e | 42 | enum cmd_error_code { |
42224349 | 43 | CMD_SUCCESS = 0, |
f3ed775e DG |
44 | CMD_ERROR, |
45 | CMD_UNDEFINED, | |
f3ed775e | 46 | CMD_FATAL, |
d16c1a4c | 47 | CMD_WARNING, |
4ce78777 | 48 | CMD_UNSUPPORTED, |
f3ed775e DG |
49 | }; |
50 | ||
51 | struct cmd_struct { | |
52 | const char *name; | |
53 | int (*func)(int argc, const char **argv); | |
54 | }; | |
55 | ||
5e71a0e8 | 56 | DECL_COMMAND(list); |
54a0adbf | 57 | DECL_COMMAND(status); |
5e71a0e8 PP |
58 | DECL_COMMAND(create); |
59 | DECL_COMMAND(destroy); | |
60 | DECL_COMMAND(start); | |
61 | DECL_COMMAND(stop); | |
62 | DECL_COMMAND(enable_events); | |
63 | DECL_COMMAND(disable_events); | |
64 | DECL_COMMAND(enable_channels); | |
65 | DECL_COMMAND(disable_channels); | |
66 | DECL_COMMAND(add_context); | |
67 | DECL_COMMAND(set_session); | |
68 | DECL_COMMAND(version); | |
69 | DECL_COMMAND(calibrate); | |
70 | DECL_COMMAND(view); | |
71 | DECL_COMMAND(enable_consumer); | |
72 | DECL_COMMAND(disable_consumer); | |
73 | DECL_COMMAND(snapshot); | |
74 | DECL_COMMAND(save); | |
75 | DECL_COMMAND(load); | |
76 | DECL_COMMAND(track); | |
77 | DECL_COMMAND(untrack); | |
93ec662e | 78 | DECL_COMMAND(metadata); |
eded6438 | 79 | DECL_COMMAND(regenerate); |
f3ed775e | 80 | |
960afba4 PP |
81 | extern int cmd_help(int argc, const char **argv, |
82 | const struct cmd_struct commands[]); | |
83 | ||
f3ed775e | 84 | #endif /* _LTTNG_CMD_H */ |