litl 0.1.9
utils/litl_split.c
Go to the documentation of this file.
1/* -*- c-file-style: "GNU" -*- */
2/*
3 * Copyright © Télécom SudParis.
4 * See COPYING in top-level directory.
5 */
6
18#define _GNU_SOURCE
19#include <stdlib.h>
20#include <string.h>
21#include <fcntl.h>
22#include <unistd.h>
23
24#include "litl_split.h"
25
26static char *__archive_name = "";
27static char *__output_dir = "";
28
29static void __usage(int argc __attribute__((unused)), char **argv) {
30 fprintf(stderr, "Usage: %s [-f archive_traces] [-d output_dir] \n", argv[0]);
31 printf(" -?, -h: Display this help and exit\n");
32}
33
34static void __parse_args(int argc, char **argv) {
35 int i;
36
37 for (i = 1; i < argc; i++) {
38 if ((strcmp(argv[i], "-f") == 0)) {
39 __archive_name = argv[++i];
40 } else if ((strcmp(argv[i], "-d") == 0)) {
41 __output_dir = argv[++i];
42 } else if ((strcmp(argv[i], "-h") || strcmp(argv[i], "-?")) == 0) {
43 __usage(argc, argv);
44 exit(-1);
45 } else if (argv[i][0] == '-') {
46 fprintf(stderr, "Unknown option %s\n", argv[i]);
47 __usage(argc, argv);
48 exit(-1);
49 }
50 }
51
52 if (strcmp(__archive_name, "") == 0) {
53 __usage(argc, argv);
54 exit(-1);
55 } else if (strcmp(__output_dir, "") == 0) {
56 __usage(argc, argv);
57 exit(-1);
58 }
59}
60
61int main(int argc, char **argv) {
62
63 // parse the arguments passed to this program
64 __parse_args(argc, argv);
65
66 // split the archive
67 litl_split_archive(__archive_name, __output_dir);
68
69 return EXIT_SUCCESS;
70}
void litl_split_archive(const char *arch_name, const char *output_dir)
Extracts each trace from an archive into a separate trace file.
litl_split Provides a set of functions for extracting trace files from an archive of traces
int main(int argc, char **argv)