-/* Prototypes */
-static int process_client_opt(void);
-static int process_opt_list_apps(void);
-static int process_opt_list_sessions(void);
-static int process_opt_create_session(void);
-static void sighandler(int sig);
-static int set_signal_handler(void);
-static int get_cmdline_by_pid(pid_t pid, char **cmdline);
-
-/*
- * 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 opt_quiet;
+int opt_verbose;
+static int opt_no_sessiond;
+static char *opt_sessiond_path;
+
+enum {
+ OPT_NO_SESSIOND,
+ OPT_SESSION_PATH,
+};
+
+/* 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, OPT_NO_SESSIOND},
+ {"sessiond-path", 1, NULL, OPT_SESSION_PATH},
+ {NULL, 0, NULL, 0}
+};
+
+/* First level command */
+static struct cmd_struct commands[] = {
+ { "list", cmd_list},
+ { "create", cmd_create},
+ { "destroy", cmd_destroy},
+ { "add-channel", cmd_add_channel},
+ { "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},
+ { NULL, NULL} /* Array closure */
+};
+
+static void usage(FILE *ofp)