Refactoring: use an opaque lttng_tracker_id type
[lttng-tools.git] / src / bin / lttng / command.h
... / ...
CommitLineData
1/*
2 * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
3 *
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.
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 *
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.
16 */
17
18#ifndef _LTTNG_CMD_H
19#define _LTTNG_CMD_H
20
21#include <lttng/lttng.h>
22#include <common/common.h>
23#include <common/defaults.h>
24
25#include "conf.h"
26#include "utils.h"
27
28#define DECL_COMMAND(_name) \
29 extern int cmd_##_name(int, const char **)
30
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
39#define SHOW_HELP() \
40 do { \
41 ret = show_cmd_help(argv[0], HELP_MSG_NAME); \
42 \
43 if (ret) { \
44 SHOW_HELP_ERROR_LINE \
45 ret = CMD_ERROR; \
46 } \
47 } while (0)
48
49enum cmd_error_code {
50 CMD_SUCCESS = 0,
51 CMD_ERROR,
52 CMD_UNDEFINED,
53 CMD_FATAL,
54 CMD_WARNING,
55 CMD_UNSUPPORTED,
56};
57
58struct cmd_struct {
59 const char *name;
60 int (*func)(int argc, const char **argv);
61};
62
63DECL_COMMAND(list);
64DECL_COMMAND(status);
65DECL_COMMAND(create);
66DECL_COMMAND(destroy);
67DECL_COMMAND(start);
68DECL_COMMAND(stop);
69DECL_COMMAND(enable_events);
70DECL_COMMAND(disable_events);
71DECL_COMMAND(enable_channels);
72DECL_COMMAND(disable_channels);
73DECL_COMMAND(add_context);
74DECL_COMMAND(set_session);
75DECL_COMMAND(version);
76DECL_COMMAND(view);
77DECL_COMMAND(enable_consumer);
78DECL_COMMAND(disable_consumer);
79DECL_COMMAND(snapshot);
80DECL_COMMAND(save);
81DECL_COMMAND(load);
82DECL_COMMAND(track);
83DECL_COMMAND(untrack);
84DECL_COMMAND(metadata);
85DECL_COMMAND(regenerate);
86DECL_COMMAND(rotate);
87DECL_COMMAND(enable_rotation);
88DECL_COMMAND(disable_rotation);
89DECL_COMMAND(clear);
90
91extern int cmd_help(int argc, const char **argv,
92 const struct cmd_struct commands[]);
93
94#endif /* _LTTNG_CMD_H */
This page took 0.022026 seconds and 4 git commands to generate.