4 * Babeltrace Trace Converter
6 * Copyright 2010 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
8 * Permission is hereby granted, free of charge, to any person obtaining a copy
9 * of this software and associated documentation files (the "Software"), to deal
10 * in the Software without restriction, including without limitation the rights
11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 * copies of the Software, and to permit persons to whom the Software is
13 * furnished to do so, subject to the following conditions:
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
19 #include <babeltrace/babeltrace.h>
20 #include <babeltrace/format.h>
25 static const char *opt_input_format
;
26 static const char *opt_output_format
;
28 static const char *opt_input_path
;
29 static const char *opt_output_path
;
31 int babeltrace_verbose
, babeltrace_debug
;
41 static struct poptOption long_options
[] = {
42 /* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
43 { "input-format", 'i', POPT_ARG_STRING
, &opt_input_format
, OPT_NONE
, NULL
, NULL
},
44 { "output-format", 'o', POPT_ARG_STRING
, &opt_output_format
, OPT_NONE
, NULL
, NULL
},
45 { "help", 'h', POPT_ARG_NONE
, NULL
, OPT_HELP
, NULL
, NULL
},
46 { "list", 'l', POPT_ARG_NONE
, NULL
, OPT_LIST
, NULL
, NULL
},
47 { "verbose", 'v', POPT_ARG_NONE
, NULL
, OPT_VERBOSE
, NULL
, NULL
},
48 { "debug", 'd', POPT_ARG_NONE
, NULL
, OPT_DEBUG
, NULL
, NULL
},
49 { NULL
, 0, 0, NULL
, 0, NULL
, NULL
},
52 static void list_formats(FILE *fp
)
55 bt_fprintf_format_list(fp
);
58 static void usage(FILE *fp
)
60 fprintf(fp
, "Babeltrace %u.%u\n\n", BABELTRACE_VERSION_MAJOR
,
61 BABELTRACE_VERSION_MINOR
);
62 fprintf(fp
, "usage : babeltrace [OPTIONS] INPUT OUTPUT\n");
64 fprintf(fp
, " INPUT Input trace path\n");
65 fprintf(fp
, " OUTPUT Output trace path\n");
67 fprintf(fp
, " -i, --input-format Input trace path\n");
68 fprintf(fp
, " -o, --output-format Input trace path\n");
70 fprintf(fp
, " -h, --help This help message\n");
71 fprintf(fp
, " -l, --list List available formats\n");
72 fprintf(fp
, " -v, --verbose Verbose mode\n");
73 fprintf(fp
, " -d, --debug Debug mode\n");
79 * Return 0 if caller should continue, < 0 if caller should return
80 * error, > 0 if caller should exit without reporting error.
82 static int parse_options(int argc
, const char **argv
)
87 pc
= poptGetContext(NULL
, argc
, argv
, long_options
, 0);
88 poptReadDefaultConfig(pc
, 0);
90 while ((opt
= poptGetNextOpt(pc
)) != -1) {
94 ret
= 1; /* exit cleanly */
101 babeltrace_verbose
= 1;
104 babeltrace_debug
= 1;
112 opt_input_path
= poptGetArg(pc
);
113 if (!opt_input_path
) {
117 opt_output_path
= poptGetArg(pc
);
118 if (!opt_output_path
) {
129 int main(int argc
, const char **argv
)
133 ret
= parse_options(argc
, argv
);
135 fprintf(stdout
, "Error parsing options.\n");
138 } else if (ret
> 0) {
141 printf_verbose("Verbose mode active.\n");
142 printf_debug("Debug mode active.\n");
144 printf_verbose("Converting from file: %s\n", opt_input_path
);
145 printf_verbose("Converting from format: %s\n",
146 opt_input_format
? : "<autodetect>");
147 printf_verbose("Converting to file: %s\n", opt_output_path
);
148 printf_verbose("Converting to format: %s\n",
149 opt_output_format
? : "CTF");
This page took 0.033871 seconds and 5 git commands to generate.