-#include <common/defaults.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/uri.h>
-
-static int opt_kernel;
-static int opt_userspace;
-static char *opt_session_name;
-
-static struct lttng_handle *handle;
-
-enum {
- OPT_HELP = 1,
- OPT_LIST_OPTIONS,
-};
-
-static struct poptOption long_options[] = {
- /* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
- {"help", 'h', POPT_ARG_NONE, NULL, OPT_HELP, NULL, NULL},
- {"list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL},
- {"session", 's', POPT_ARG_STRING, &opt_session_name, 0, 0, 0},
- {"kernel", 'k', POPT_ARG_VAL, &opt_kernel, 1, 0, 0},
- {"userspace", 'u', POPT_ARG_VAL, &opt_userspace, 1, 0, 0},
- {0, 0, 0, 0, 0, 0, 0}
-};
-
-/*
- * usage
- */
-static void usage(FILE *ofp)
-{
- fprintf(ofp, "usage: lttng disable-consumer [-u|-k] [OPTIONS]\n");
- fprintf(ofp, "\n");
- fprintf(ofp, "Disable the consumer for a tracing session. This call can\n");
- fprintf(ofp, "be done BEFORE tracing has started.\n");
- fprintf(ofp, "\n");
- fprintf(ofp, "Options:\n");
- fprintf(ofp, " -h, --help Show this help\n");
- fprintf(ofp, " --list-options Simple listing of options\n");
- fprintf(ofp, " -s, --session NAME Apply to session name\n");
- fprintf(ofp, " -k, --kernel Apply to the kernel tracer\n");
- fprintf(ofp, " -u, --userspace Apply to the user-space tracer\n");
- fprintf(ofp, "\n");
-}
-
-/*
- * Disable consumer command.
- */
-static int disable_consumer(char *session_name)
-{
- int ret = CMD_SUCCESS;
- struct lttng_domain dom;
-
- memset(&dom, 0, sizeof(dom));
-
- /* Create lttng domain */
- if (opt_kernel) {
- dom.type = LTTNG_DOMAIN_KERNEL;
- } else if (opt_userspace) {
- dom.type = LTTNG_DOMAIN_UST;
- } else {
- ERR("Please specify a tracer (-k/--kernel or -u/--userspace)");
- ret = CMD_ERROR;
- goto error;
- }
-
- handle = lttng_create_handle(session_name, &dom);
- if (handle == NULL) {
- ret = -1;
- goto error;
- }
-
- ret = lttng_disable_consumer(handle);
- if (ret < 0) {
- ERR("Disabling consumer for session %s: %s", session_name,
- lttng_strerror(ret));
- goto error;
- }
-
- MSG("Consumer disabled successfully");
-
-error:
- lttng_destroy_handle(handle);
- return ret;
-}
-