From 8f882ced2b52b02d988e71a5e6756b8d0291b794 Mon Sep 17 00:00:00 2001 From: Your Name Date: Fri, 24 Jan 2025 21:12:50 +0300 Subject: [PATCH] update README file and fixed bug --- README.md | 2 -- README.txt | 22 ++++++++++++++++++++++ img.c | 11 ++++------- 3 files changed, 26 insertions(+), 9 deletions(-) delete mode 100644 README.md create mode 100644 README.txt diff --git a/README.md b/README.md deleted file mode 100644 index 67d31e8..0000000 --- a/README.md +++ /dev/null @@ -1,2 +0,0 @@ -# 8img - diff --git a/README.txt b/README.txt new file mode 100644 index 0000000..cec4d0b --- /dev/null +++ b/README.txt @@ -0,0 +1,22 @@ +8img is a simple html gallery generator + + +Performance: + 11 sec when processing a + 564kb database containing + 1685 rows on orange pi 4 lts (cpu freq: 816Mhz) + And 5sec at 1.8GHz + + +Dependencies: + * Any C compiler + * *nix system + + +The db contains a the filename and tags +exp: + image.png ,photo,sky + cat.png ,animal,photo + + +To configure, edit config.h and recompile diff --git a/img.c b/img.c index 5398da9..3329311 100644 --- a/img.c +++ b/img.c @@ -322,8 +322,6 @@ struct DB_STR *build_html(FILE *fp, const char *file, const struct UNIQ_TAGS ut, } void build(const char *file, const struct UNIQ_TAGS ut, struct DB_STR *db) { - FILE *fp = NULL; - size_t page = 0; size_t pages = 0; @@ -352,9 +350,6 @@ void build(const char *file, const struct UNIQ_TAGS ut, struct DB_STR *db) { p = db; while (1) { - if (fp != NULL) - fclose(fp); - char new_path[PATH_MAX + 1]; if (page == 0) snprintf(new_path, sizeof(new_path), "%s/%s.html", ROOT, file); @@ -366,12 +361,14 @@ void build(const char *file, const struct UNIQ_TAGS ut, struct DB_STR *db) { if (fp == NULL) return; + /* Builders */ p = build_html(fp, file, ut, p, page, pages); if (p == NULL) { fclose(fp); break; } + fclose(fp); page++; } } @@ -443,7 +440,7 @@ void rebuild(void) { } void help(void) { - puts("8img [add/rebuild]:\n\tadd [img] [tag1] [tag2] [...]\n\trebuild\n\tversion"); + puts("8img [add/rebuild/version]:\n\tadd [img] [tag1] [tag2] [...]\n\trebuild\n\tversion"); exit(0); } @@ -465,7 +462,7 @@ int main(int argc, char **argv) { rebuild(); else if (!strcmp(argv[0], "version")) - puts("8img version: 1.0.1\nWritten under WTFPL License."); + puts("8img version: 1.0.2\nWritten under WTFPL License."); else help();