From b3568f55b0d8d2a9d12c53c8dbee00be66c32d1d Mon Sep 17 00:00:00 2001 From: Jakob Kaivo Date: Thu, 18 Jul 2019 20:34:59 -0400 Subject: properly inserting new links --- index.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'index.c') diff --git a/index.c b/index.c index bac0454..5bb7249 100644 --- a/index.c +++ b/index.c @@ -4,6 +4,8 @@ #include #include #include +#include +#include #include #include "blog.h" @@ -23,8 +25,15 @@ static void insert_into(int blogdir, char *index_dir, const char *uri, const cha /* add old entries */ int old_index = openat(blogdir, index_path, O_RDONLY); if (old_index != -1) { - /* find exising entries */ - /* copy them to new_index */ + struct stat st; + fstat(old_index, &st); + char *buf = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, old_index, 0); + if (buf != MAP_FAILED) { + char *a = strstr(buf, "