summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c23
1 files changed, 19 insertions, 4 deletions
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);