static void usage(FILE *fp)
{
- fprintf(fp, "Babeltrace %u.%u\n\n", BABELTRACE_VERSION_MAJOR,
+ fprintf(fp, "BabelTrace Trace Converter %u.%u\n\n",
+ BABELTRACE_VERSION_MAJOR,
BABELTRACE_VERSION_MINOR);
fprintf(fp, "usage : babeltrace [OPTIONS] INPUT OUTPUT\n");
fprintf(fp, "\n");
poptContext pc;
int opt, ret = 0;
+ if (argc == 1) {
+ usage(stdout);
+ return 1; /* exit cleanly */
+ }
+
pc = poptGetContext(NULL, argc, (const char **) argv, long_options, 0);
poptReadDefaultConfig(pc, 0);
goto end;
}
opt_output_path = poptGetArg(pc);
- if (!opt_output_path) {
- ret = -EINVAL;
- goto end;
- }
end:
if (pc) {
poptFreeContext(pc);
printf_verbose("Converting from file: %s\n", opt_input_path);
printf_verbose("Converting from format: %s\n",
opt_input_format ? : "<autodetect>");
- printf_verbose("Converting to file: %s\n", opt_output_path);
+ printf_verbose("Converting to file: %s\n",
+ opt_output_path ? : "<stdout>");
printf_verbose("Converting to format: %s\n",
opt_output_format ? : "ctf");
goto error_td_read;
}
+ if (!opt_output_path)
+ opt_output_path = "/dev/stdout";
td_write = fmt_write->open_trace(opt_output_path, O_WRONLY);
if (!td_write) {
fprintf(stdout, "Error opening trace \"%s\" for writing.\n\n",
goto error_td_write;
}
+ ret = convert_trace(td_write, td_read);
+ if (ret) {
+ fprintf(stdout, "Error printing trace.\n\n");
+ goto error_copy_trace;
+ }
+
fmt_write->close_trace(td_write);
fmt_read->close_trace(td_read);
exit(EXIT_SUCCESS);
/* Error handling */
+error_copy_trace:
fmt_write->close_trace(td_write);
error_td_write:
fmt_read->close_trace(td_read);