8ec3d64b9b892c9c9071c2e8432db24a21713599
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>
24 static const char *opt_input_format
;
25 static const char *opt_output_format
;
27 static const char *opt_input_path
;
28 static const char *opt_output_path
;
30 int babeltrace_verbose
, babeltrace_debug
;
39 static struct poptOption long_options
[] = {
40 /* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
41 { "input-format", 'i', POPT_ARG_STRING
, &opt_input_format
, OPT_NONE
, NULL
, NULL
},
42 { "output-format", 'o', POPT_ARG_STRING
, &opt_output_format
, OPT_NONE
, NULL
, NULL
},
43 { "help", 'h', POPT_ARG_NONE
, NULL
, OPT_HELP
, NULL
, NULL
},
44 { "verbose", 'v', POPT_ARG_NONE
, NULL
, OPT_VERBOSE
, NULL
, NULL
},
45 { "debug", 'd', POPT_ARG_NONE
, NULL
, OPT_DEBUG
, NULL
, NULL
},
46 { NULL
, 0, 0, NULL
, 0, NULL
, NULL
},
49 static void usage(FILE *fp
)
51 fprintf(fp
, "Babeltrace %u.%u\n\n", BABELTRACE_VERSION_MAJOR
,
52 BABELTRACE_VERSION_MINOR
);
53 fprintf(fp
, "usage : babeltrace [OPTIONS] INPUT OUTPUT\n");
55 fprintf(fp
, " INPUT Input trace path\n");
56 fprintf(fp
, " OUTPUT Output trace path\n");
58 fprintf(fp
, " -i, --input-format Input trace path\n");
59 fprintf(fp
, " -o, --output-format Input trace path\n");
61 fprintf(fp
, " -h, --help This help message\n");
62 fprintf(fp
, " -v, --verbose Verbose mode\n");
63 fprintf(fp
, " -d, --debug Debug mode\n");
68 * Return 0 if caller should continue, < 0 if caller should return
69 * error, > 0 if caller should exit without reporting error.
71 static int parse_options(int argc
, const char **argv
)
76 pc
= poptGetContext(NULL
, argc
, argv
, long_options
, 0);
77 poptReadDefaultConfig(pc
, 0);
79 while ((opt
= poptGetNextOpt(pc
)) != -1) {
83 ret
= 1; /* exit cleanly */
86 babeltrace_verbose
= 1;
97 opt_input_path
= poptGetArg(pc
);
98 if (!opt_input_path
) {
102 opt_output_path
= poptGetArg(pc
);
103 if (!opt_output_path
) {
114 int main(int argc
, const char **argv
)
118 ret
= parse_options(argc
, argv
);
120 fprintf(stdout
, "Error parsing options.\n");
123 } else if (ret
> 0) {
126 printf_verbose("Verbose mode active.\n");
127 printf_debug("Debug mode active.\n");
129 printf_verbose("Converting from file: %s\n", opt_input_path
);
130 printf_verbose("Converting from format: %s\n",
131 opt_input_format
? : "<autodetect>");
132 printf_verbose("Converting to file: %s\n", opt_output_path
);
133 printf_verbose("Converting to format: %s\n",
134 opt_output_format
? : "CTF");
This page took 0.040508 seconds and 5 git commands to generate.