File: litl_split.c

package info (click to toggle)
litl 0.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 564 kB
  • sloc: ansic: 3,407; makefile: 36; sh: 18
file content (70 lines) | stat: -rw-r--r-- 1,736 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/* -*- c-file-style: "GNU" -*- */
/*
 * Copyright © Télécom SudParis.
 * See COPYING in top-level directory.
 */

/**
 *  \file utils/litl_split.c
 *  \brief litl_split A utility for disassembling archives of traces into
 *  separate regular trace files
 *
 *  \authors
 *    Developers are: \n
 *        Roman Iakymchuk   -- roman.iakymchuk@telecom-sudparis.eu \n
 *        Francois Trahay   -- francois.trahay@telecom-sudparis.eu \n
 */

#define _GNU_SOURCE
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>

#include "litl_split.h"

static char *__archive_name = "";
static char *__output_dir = "";

static void __usage(int argc __attribute__((unused)), char **argv) {
  fprintf(stderr, "Usage: %s [-f archive_traces] [-d output_dir] \n", argv[0]);
  printf("       -?, -h:    Display this help and exit\n");
}

static void __parse_args(int argc, char **argv) {
  int i;

  for (i = 1; i < argc; i++) {
    if ((strcmp(argv[i], "-f") == 0)) {
      __archive_name = argv[++i];
    } else if ((strcmp(argv[i], "-d") == 0)) {
      __output_dir = argv[++i];
    } else if ((strcmp(argv[i], "-h") || strcmp(argv[i], "-?")) == 0) {
      __usage(argc, argv);
      exit(-1);
    } else if (argv[i][0] == '-') {
      fprintf(stderr, "Unknown option %s\n", argv[i]);
      __usage(argc, argv);
      exit(-1);
    }
  }

  if (strcmp(__archive_name, "") == 0) {
    __usage(argc, argv);
    exit(-1);
  } else if (strcmp(__output_dir, "") == 0) {
    __usage(argc, argv);
    exit(-1);
  }
}

int main(int argc, char **argv) {

  // parse the arguments passed to this program
  __parse_args(argc, argv);

  // split the archive
  litl_split_archive(__archive_name, __output_dir);

  return EXIT_SUCCESS;
}