From 7dc26f19055f66efc1b059d39d46008c3f0dd20d Mon Sep 17 00:00:00 2001 From: Louis Burda Date: Mon, 10 May 2021 18:08:29 +0200 Subject: fixed hash parsing from info file and only query non-hidden dirs in standard user mode --- service/src/printdoc.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'service/src/printdoc.c') diff --git a/service/src/printdoc.c b/service/src/printdoc.c index 3224724..2bd24fd 100644 --- a/service/src/printdoc.c +++ b/service/src/printdoc.c @@ -145,7 +145,7 @@ query_cmd(char *arg) dirstart = telldir(d); for (i = 0; (de = readdir(d));) { - if (de->d_type == DT_DIR && !strpfcmp(hash, de->d_name)) { + if (!strpfcmp(hash, de->d_name) && *de->d_name != '.') { printf("%i : %s\n", i, de->d_name); i++; } @@ -164,7 +164,7 @@ query_cmd(char *arg) seekdir(d, dirstart); for (i = 0; (de = readdir(d));) { - if (de->d_type == DT_DIR && !strpfcmp(hash, de->d_name)) { + if (!strpfcmp(hash, de->d_name) && *de->d_name != '.') { if (i == which) { scandir = aprintf("%s/%s", resultdir, de->d_name); break; @@ -180,6 +180,7 @@ query_cmd(char *arg) infopath = aprintf("%s/%s", scandir, "info"); if (!(f = fopen(infopath, "r"))) goto cleanup; + free_info(&cached); if (load_info(&cached, f) != OK) goto cleanup; fclose(f); f = NULL; @@ -208,6 +209,12 @@ cleanup: free(modelpath); } +void +cleanexit() +{ + free_info(&cached); +} + int main() { @@ -221,6 +228,8 @@ main() setvbuf(stdout, NULL, _IONBF, 0); setvbuf(stderr, NULL, _IONBF, 0); + atexit(cleanexit); + dump("msgs/welcome"); exit = 0; -- cgit v1.2.3-71-gd317