-/*
- * start_client
- *
- * Process client request from the command line
- * options. Every tracing action is done by the
- * liblttngctl API.
- */
-static int process_client_opt(void)
-{
- int ret;
- uuid_t uuid;
-
- if (opt_list_apps) {
- ret = process_opt_list_apps();
- if (ret < 0) {
- goto end;
- }
- }
-
- if (opt_list_session) {
- ret = process_opt_list_sessions();
- if (ret < 0) {
- goto end;
- }
- }
-
- if (opt_list_traces) {
- ret = process_opt_list_traces();
- if (ret < 0) {
- goto end;
- }
- }
-
- if (opt_create_session != NULL) {
- ret = process_opt_create_session();
- if (ret < 0) {
- goto end;
- }
- }
-
- if (opt_destroy_session != NULL) {
- uuid_parse(opt_destroy_session, uuid);
- ret = lttng_destroy_session(&uuid);
- if (ret < 0) {
- goto end;
- }
- }
-
- if (opt_session_uuid != NULL) {
- DBG("Set session uuid to %s", short_uuid);
- ret = process_opt_session_uuid();
- if (ret < 0) {
- ERR("Session UUID %s not found", opt_session_uuid);
- goto error;
- }
- }
-
- if (opt_trace_kernel) {
- ERR("Not implemented yet");
- goto end;
- }
-
- if (opt_trace_pid != 0) {
- if (opt_create_trace) {
- DBG("Create a userspace trace for pid %d", opt_trace_pid);
- ret = lttng_ust_create_trace(opt_trace_pid);
- if (ret < 0) {
- goto end;
- }
- MSG("Trace created successfully!\nUse --start to start tracing.");
- }
-
- if (opt_start_trace) {
- DBG("Start trace for pid %d", opt_trace_pid);
- ret = lttng_ust_start_trace(opt_trace_pid);
- if (ret < 0) {
- goto end;
- }
- MSG("Trace started successfully!");
- } else if (opt_stop_trace) {
- DBG("Stop trace for pid %d", opt_trace_pid);
- ret = lttng_ust_stop_trace(opt_trace_pid);
- if (ret < 0) {
- goto end;
- }
- MSG("Trace stopped successfully!");
- }
-
- }
-
- return 0;
-
-end:
- ERR("%s", lttng_get_readable_code(ret));
- return ret;
-
-error:
- return ret;
-}
-
-/*
- * process_opt_session_uuid
- *
- * Set current session uuid to the current flow of
- * command(s) using the already shorten uuid.
- */
-static int process_opt_session_uuid(void)
+int opt_quiet;
+int opt_verbose;
+static int opt_no_sessiond;
+static char *opt_sessiond_path;
+
+enum {
+ OPT_SESSION_PATH,
+ OPT_DUMP_OPTIONS,
+ OPT_DUMP_COMMANDS,
+};
+
+/* Getopt options. No first level command. */
+static struct option long_options[] = {
+ {"help", 0, NULL, 'h'},
+ {"group", 1, NULL, 'g'},
+ {"verbose", 0, NULL, 'v'},
+ {"quiet", 0, NULL, 'q'},
+ {"no-sessiond", 0, NULL, 'n'},
+ {"sessiond-path", 1, NULL, OPT_SESSION_PATH},
+ {"list-options", 0, NULL, OPT_DUMP_OPTIONS},
+ {"list-commands", 0, NULL, OPT_DUMP_COMMANDS},
+ {NULL, 0, NULL, 0}
+};
+
+/* First level command */
+static struct cmd_struct commands[] = {
+ { "list", cmd_list},
+ { "create", cmd_create},
+ { "destroy", cmd_destroy},
+ { "start", cmd_start},
+ { "stop", cmd_stop},
+ { "enable-event", cmd_enable_events},
+ { "disable-event", cmd_disable_events},
+ { "enable-channel", cmd_enable_channels},
+ { "disable-channel", cmd_disable_channels},
+ { "add-context", cmd_add_context},
+ { "set-session", cmd_set_session},
+ { "version", cmd_version},
+ { "calibrate", cmd_calibrate},
+ { NULL, NULL} /* Array closure */
+};
+
+static void usage(FILE *ofp)