From 3b660c467f938df6898229e378074cfa5662ce9f Mon Sep 17 00:00:00 2001 From: Louis Burda Date: Sun, 9 May 2021 12:37:16 +0200 Subject: save hash statically, added file info output, improved error strings and minor fixes --- service/src/printdoc.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'service/src/printdoc.c') diff --git a/service/src/printdoc.c b/service/src/printdoc.c index b01ddfb..d7a4131 100644 --- a/service/src/printdoc.c +++ b/service/src/printdoc.c @@ -73,7 +73,7 @@ search_cmd(char *arg) DIR *d = NULL; if (lastrun.valid) - hash = lastrun.namehash; + hash = lastrun.hash; else hash = mhash(ask("What is the model name?\n"), -1); @@ -126,7 +126,7 @@ submit_cmd(char *arg) bufp = ask("How large is your file?\n"); len = strtoul(bufp, &end, 10); - if (len <= 0 || len >= 7000 || *end) { + if (len <= 0 || len >= 10000 || *end) { fprintf(stderr, "Invalid file length!\n"); return; } @@ -138,7 +138,12 @@ submit_cmd(char *arg) lastrun.valid = parse_file(&lastrun, contents, len); - if (lastrun.valid && lastrun.infopath) dump(lastrun.infopath); + if (lastrun.valid) { + print_info(&lastrun); + save_info(&lastrun, resultdir); + printf("Your file was saved with ID %s!\n", lastrun.hash); + printf("You may retrieve your results via the 'search' function\n"); + } free(contents); } @@ -169,8 +174,6 @@ main() char linebuf[256], *cp, *arg; int exit, i; - setvbuf(stdin, NULL, _IONBF, 0); - if (!(resultdir = getenv("RESULTDIR"))) resultdir = "/data"; @@ -178,7 +181,7 @@ main() exit = 0; while (!exit) { - memset(linebuf, ' ', sizeof(linebuf)); + memset(linebuf, '\0', sizeof(linebuf)); printf("$ "); exit = !fgets(linebuf, sizeof(linebuf), stdin); -- cgit v1.2.3-71-gd317