litl  0.1.1
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
litl_merge.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 <unistd.h>
22 #include <fcntl.h>
23 #include <sys/stat.h>
24 
25 #include "litl_merge.h"
26 
27 static char* __arch_name;
28 static char** __trace_names;
29 static int __nb_traces;
30 
31 static void __usage(int argc __attribute__((unused)), char **argv) {
32  fprintf(stderr,
33  "Usage: %s [-o archive_name] input_filename input_filename ... \n",
34  argv[0]);
35  printf(" -?, -h: Display this help and exit\n");
36 }
37 
38 static void __parse_args(int argc, char **argv) {
39  int i, res __attribute__ ((__unused__));
40 
41  __trace_names = (char **) malloc((argc - 3) * sizeof(char *));
42  __nb_traces = 0;
43 
44  for (i = 1; i < argc; i++) {
45  if ((strcmp(argv[i], "-o") == 0)) {
46  res = asprintf(&__arch_name, "%s", argv[++i]);
47  } else if ((strcmp(argv[i], "-h") || strcmp(argv[i], "-?")) == 0) {
48  __usage(argc, argv);
49  exit(-1);
50  } else if (argv[i][0] == '-') {
51  fprintf(stderr, "Unknown option %s\n", argv[i]);
52  __usage(argc, argv);
53  exit(-1);
54  } else {
55  res = asprintf(&__trace_names[__nb_traces], "%s", argv[i]);
56  __nb_traces++;
57  }
58  }
59 
60  if (__arch_name == NULL )
61  __usage(argc, argv);
62 }
63 
64 int main(int argc, char **argv) {
65 
66  // parse the arguments passed to this program
67  __parse_args(argc, argv);
68 
69  litl_merge_traces(__arch_name, __trace_names, __nb_traces);
70 
71  return EXIT_SUCCESS;
72 }
void litl_merge_traces(const char *arch_name, char **traces_names, const int nb_traces)
Merges trace files into an archive. This is a modified version of the implementation of the cat funct...
Definition: litl_merge.c:240
litl_merge Provides a set of functions for merging trace files into an archive of traces ...
int main(int argc, char **argv)
Definition: litl_merge.c:64