/*
- * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
+ * Copyright (C) 2011 EfficiOS Inc.
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License, version 2 only,
- * as published by the Free Software Foundation.
+ * 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.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#define _LGPL_SOURCE
#include "../command.h"
-static char *opt_channels;
static int opt_kernel;
static char *opt_session_name;
static int opt_userspace;
+#ifdef LTTNG_EMBED_HELP
+static const char help_msg[] =
+#include <lttng-disable-channel.1.h>
+;
+#endif
+
enum {
OPT_HELP = 1,
OPT_USERSPACE,
/*
* Disabling channel using the lttng API.
*/
-static int disable_channels(char *session_name)
+static int disable_channels(char *session_name, char *channel_list)
{
int ret = CMD_SUCCESS, warn = 0, success;
}
/* Strip channel list */
- channel_name = strtok(opt_channels, ",");
+ channel_name = strtok(channel_list, ",");
while (channel_name != NULL) {
DBG("Disabling channel %s", channel_name);
int opt, ret = CMD_SUCCESS, command_ret = CMD_SUCCESS, success = 1;
static poptContext pc;
char *session_name = NULL;
+ char *channel_list = NULL;
+ const char *arg_channel_list = NULL;
+ const char *leftover = NULL;
pc = poptGetContext(NULL, argc, argv, long_options, 0);
poptReadDefaultConfig(pc, 0);
}
}
- ret = print_missing_or_multiple_domains(opt_kernel + opt_userspace);
+ ret = print_missing_or_multiple_domains(
+ opt_kernel + opt_userspace, false);
if (ret) {
ret = CMD_ERROR;
goto end;
}
- opt_channels = (char*) poptGetArg(pc);
- if (opt_channels == NULL) {
- ERR("Missing channel name(s).\n");
+ arg_channel_list = poptGetArg(pc);
+ if (arg_channel_list == NULL) {
+ ERR("Missing channel name(s).");
+ ret = CMD_ERROR;
+ goto end;
+ }
+
+ channel_list = strdup(arg_channel_list);
+ if (channel_list == NULL) {
+ PERROR("Failed to copy channel name");
+ ret = CMD_ERROR;
+ goto end;
+ }
+
+ leftover = poptGetArg(pc);
+ if (leftover) {
+ ERR("Unknown argument: %s", leftover);
ret = CMD_ERROR;
goto end;
}
}
}
- command_ret = disable_channels(session_name);
+ command_ret = disable_channels(session_name, channel_list);
if (command_ret) {
success = 0;
}
free(session_name);
}
+ free(channel_list);
+
/* Overwrite ret if an error occurred in disable_channels */
ret = command_ret ? command_ret : ret;