X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng%2Fcommand.h;h=8961bad015939658b4f712534e9b899977c7d4d3;hp=fa3e217468abba881c4a8f806547a7ef9a9ca0b3;hb=4624dad0d79b63be45c5c6d7eb2920ba09746f06;hpb=0c95f5b2ec754e905a0263cafc6e453f451d0ded diff --git a/src/bin/lttng/command.h b/src/bin/lttng/command.h index fa3e21746..8961bad01 100644 --- a/src/bin/lttng/command.h +++ b/src/bin/lttng/command.h @@ -1,19 +1,8 @@ /* - * Copyright (C) 2011 - David Goulet + * Copyright (C) 2011 David Goulet * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; only version 2 - * of the License. + * SPDX-License-Identifier: GPL-2.0-only * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef _LTTNG_CMD_H @@ -26,12 +15,34 @@ #include "conf.h" #include "utils.h" +#define DECL_COMMAND(_name) \ + extern int cmd_##_name(int, const char **) + +#ifdef LTTNG_EMBED_HELP +# define HELP_MSG_NAME help_msg +# define SHOW_HELP_ERROR_LINE ERR("Cannot show --help for `lttng-%s`", argv[0]); +#else +# define HELP_MSG_NAME NULL +# define SHOW_HELP_ERROR_LINE ; +#endif + +#define SHOW_HELP() \ + do { \ + ret = show_cmd_help(argv[0], HELP_MSG_NAME); \ + \ + if (ret) { \ + SHOW_HELP_ERROR_LINE \ + ret = CMD_ERROR; \ + } \ + } while (0) + enum cmd_error_code { - CMD_SUCCESS, + CMD_SUCCESS = 0, CMD_ERROR, CMD_UNDEFINED, CMD_FATAL, CMD_WARNING, + CMD_UNSUPPORTED, }; struct cmd_struct { @@ -39,19 +50,36 @@ struct cmd_struct { int (*func)(int argc, const char **argv); }; -extern int cmd_list(int argc, const char **argv); -extern int cmd_create(int argc, const char **argv); -extern int cmd_destroy(int argc, const char **argv); -extern int cmd_start(int argc, const char **argv); -extern int cmd_stop(int argc, const char **argv); -extern int cmd_enable_events(int argc, const char **argv); -extern int cmd_disable_events(int argc, const char **argv); -extern int cmd_enable_channels(int argc, const char **argv); -extern int cmd_disable_channels(int argc, const char **argv); -extern int cmd_add_context(int argc, const char **argv); -extern int cmd_set_session(int argc, const char **argv); -extern int cmd_version(int argc, const char **argv); -extern int cmd_calibrate(int argc, const char **argv); -extern int cmd_view(int argc, const char **argv); +DECL_COMMAND(list); +DECL_COMMAND(status); +DECL_COMMAND(create); +DECL_COMMAND(destroy); +DECL_COMMAND(start); +DECL_COMMAND(stop); +DECL_COMMAND(enable_events); +DECL_COMMAND(disable_events); +DECL_COMMAND(enable_channels); +DECL_COMMAND(disable_channels); +DECL_COMMAND(add_context); +DECL_COMMAND(set_session); +DECL_COMMAND(version); +DECL_COMMAND(view); +DECL_COMMAND(enable_consumer); +DECL_COMMAND(disable_consumer); +DECL_COMMAND(snapshot); +DECL_COMMAND(save); +DECL_COMMAND(load); +DECL_COMMAND(track); +DECL_COMMAND(untrack); +DECL_COMMAND(metadata); +DECL_COMMAND(regenerate); +DECL_COMMAND(rotate); +DECL_COMMAND(enable_rotation); +DECL_COMMAND(disable_rotation); +DECL_COMMAND(clear); +DECL_COMMAND(add_trigger); + +extern int cmd_help(int argc, const char **argv, + const struct cmd_struct commands[]); #endif /* _LTTNG_CMD_H */