summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/common.h1
-rw-r--r--src/e2e.c4
-rw-r--r--src/main.c23
3 files changed, 20 insertions, 8 deletions
diff --git a/src/common.h b/src/common.h
index 7f1e41c..5178855 100644
--- a/src/common.h
+++ b/src/common.h
@@ -2,6 +2,7 @@
#include <inttypes.h>
#include <stdio.h>
#include <errno.h>
+#include <string.h>
#include <uthash.h>
#include "eli.h"
diff --git a/src/e2e.c b/src/e2e.c
index d842fd8..8473d64 100644
--- a/src/e2e.c
+++ b/src/e2e.c
@@ -1,8 +1,4 @@
#include "common.h"
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
#include <math.h>
#include "e2e.h"
diff --git a/src/main.c b/src/main.c
index dcb5d06..de933be 100644
--- a/src/main.c
+++ b/src/main.c
@@ -11,14 +11,14 @@
int main(int argc, char **argv)
{
int ret = 0;
- char *inpath;
+ char *inpath, outpath[4096];
int fd;
struct stat st;
void *input;
struct e2e_data data;
if (argc < 2) {
- fprintf(stderr, "%s [FILE]\n", argv[0]);
+ fprintf(stderr, "%s [INPUT] (OUTPUT)\n", argv[0]);
return 1;
}
@@ -45,8 +45,23 @@ int main(int argc, char **argv)
if (errno = e2e_read(&data, input, input + st.st_size))
perror("e2e_read");
- else if (errno = export(&data, "testing.mat"))
- perror("export");
+ else {
+ // FIXME: ...
+ if (argc >= 3)
+ strcpy(outpath, argv[2]);
+ else {
+ int len = strlen(inpath);
+
+ if (len >= 3 && (!strcmp(inpath + len - 4, ".e2e")
+ || !strcmp(inpath + len - 4, ".E2E")))
+ sprintf(outpath, "%.*s.mat", len - 4, inpath);
+ else
+ sprintf(outpath, "%s.mat", inpath);
+ }
+
+ if (errno = export(&data, outpath))
+ perror("export");
+ }
e2e_destroy(&data);