*/
#define _LGPL_SOURCE
+#include "../command.hpp"
+
+#include <common/mi-lttng.hpp>
+
+#include <lttng/lttng.h>
+
#include <inttypes.h>
#include <popt.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <common/mi-lttng.hpp>
-
-#include "../command.hpp"
-#include <lttng/lttng.h>
-
static char *opt_output_path;
static bool opt_force;
static bool opt_save_all;
#ifdef LTTNG_EMBED_HELP
static const char help_msg[] =
#include <lttng-save.1.h>
-;
+ ;
#endif
enum {
static struct poptOption save_opts[] = {
/* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
- {"help", 'h', POPT_ARG_NONE, NULL, OPT_HELP, NULL, NULL},
- {"all", 'a', POPT_ARG_NONE, NULL, OPT_ALL, NULL, NULL},
- {"output-path", 'o', POPT_ARG_STRING, &opt_output_path, 0, NULL, NULL},
- {"force", 'f', POPT_ARG_NONE, NULL, OPT_FORCE, NULL, NULL},
- {"list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL},
- {0, 0, 0, 0, 0, 0, 0}
+ { "help", 'h', POPT_ARG_NONE, nullptr, OPT_HELP, nullptr, nullptr },
+ { "all", 'a', POPT_ARG_NONE, nullptr, OPT_ALL, nullptr, nullptr },
+ { "output-path", 'o', POPT_ARG_STRING, &opt_output_path, 0, nullptr, nullptr },
+ { "force", 'f', POPT_ARG_NONE, nullptr, OPT_FORCE, nullptr, nullptr },
+ { "list-options", 0, POPT_ARG_NONE, nullptr, OPT_LIST_OPTIONS, nullptr, nullptr },
+ { nullptr, 0, 0, nullptr, 0, nullptr, nullptr }
};
static int mi_partial_session(const char *session_name)
goto end;
}
- ret = mi_lttng_writer_write_element_string(writer, config_element_name,
- session_name);
+ ret = mi_lttng_writer_write_element_string(writer, config_element_name, session_name);
if (ret) {
goto end;
}
/* Path element */
if (opt_output_path) {
- ret = mi_lttng_writer_write_element_string(writer, config_element_path,
- opt_output_path);
+ ret = mi_lttng_writer_write_element_string(
+ writer, config_element_path, opt_output_path);
if (ret) {
goto end;
}
{
int ret = CMD_SUCCESS, command_ret = CMD_SUCCESS, success;
int opt;
- const char *arg_session_name = NULL, *leftover = NULL;
+ const char *arg_session_name = nullptr, *leftover = nullptr;
poptContext pc;
struct lttng_save_session_attr *attr;
- pc = poptGetContext(NULL, argc, argv, save_opts, 0);
+ pc = poptGetContext(nullptr, argc, argv, save_opts, 0);
poptReadDefaultConfig(pc, 0);
while ((opt = poptGetNextOpt(pc)) != -1) {
}
/* Open command element */
- ret = mi_lttng_writer_command_open(writer,
- mi_lttng_element_command_save);
+ ret = mi_lttng_writer_command_open(writer, mi_lttng_element_command_save);
if (ret) {
ret = CMD_ERROR;
goto end_destroy;
}
/* Open output element */
- ret = mi_lttng_writer_open_element(writer,
- mi_lttng_element_command_output);
+ ret = mi_lttng_writer_open_element(writer, mi_lttng_element_command_output);
if (ret) {
ret = CMD_ERROR;
goto end_destroy;
} else {
/* Inform the user of what just happened on success. */
if (arg_session_name && opt_output_path) {
- MSG("Session %s saved successfully in %s.", arg_session_name,
- opt_output_path);
+ MSG("Session %s saved successfully in %s.",
+ arg_session_name,
+ opt_output_path);
} else if (arg_session_name && !opt_output_path) {
MSG("Session %s saved successfully.", arg_session_name);
} else if (!arg_session_name && opt_output_path) {
- MSG("All sessions have been saved successfully in %s.",
- opt_output_path);
+ MSG("All sessions have been saved successfully in %s.", opt_output_path);
} else {
MSG("All sessions have been saved successfully.");
}
}
/* Success ? */
- ret = mi_lttng_writer_write_element_bool(writer,
- mi_lttng_element_command_success, success);
+ ret = mi_lttng_writer_write_element_bool(
+ writer, mi_lttng_element_command_success, success);
if (ret) {
ret = CMD_ERROR;
goto end_destroy;