diff options
| author | Louis Burda <quent.burda@gmail.com> | 2021-05-09 12:37:16 +0200 |
|---|---|---|
| committer | Louis Burda <quent.burda@gmail.com> | 2021-05-09 12:37:16 +0200 |
| commit | 3b660c467f938df6898229e378074cfa5662ce9f (patch) | |
| tree | 32d8bed7139267c951f6aabd8238fce496150531 /service/src/printdoc.c | |
| parent | a0d6bf48a185026589288fd9aa94506b321301d8 (diff) | |
| download | enowars5-service-stldoctor-3b660c467f938df6898229e378074cfa5662ce9f.tar.gz enowars5-service-stldoctor-3b660c467f938df6898229e378074cfa5662ce9f.zip | |
save hash statically, added file info output, improved error strings and minor fixes
Diffstat (limited to 'service/src/printdoc.c')
| -rw-r--r-- | service/src/printdoc.c | 15 |
1 files changed, 9 insertions, 6 deletions
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); |
