summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2019-07-18 20:29:24 -0400
committerJakob Kaivo <jkk@ung.org>2019-07-18 20:29:24 -0400
commite716d37c0688d1d14d59f6ad09a4b93b6600615d (patch)
tree51019341ba3a3b7c2226547a8cd92f8c032ae123
parente77c62e0f9725acca092f718b07555e841372190 (diff)
remove cruft
-rw-r--r--index.c17
1 files changed, 4 insertions, 13 deletions
diff --git a/index.c b/index.c
index e9b42a3..bac0454 100644
--- a/index.c
+++ b/index.c
@@ -8,16 +8,11 @@
#include "blog.h"
-#include <errno.h>
-
static void insert_into(int blogdir, char *index_dir, const char *uri, const char *title)
{
char index_path[FILENAME_MAX] = { 0 };
snprintf(index_path, sizeof(index_path), "%s/index.html", index_dir);
- /* check for exisint index */
- int old_index = openat(blogdir, index_path, O_RDONLY);
-
char new_path[FILENAME_MAX] = { 0 };
snprintf(new_path, sizeof(new_path), "%s.new", index_path);
int new_index = openat(blogdir, new_path, O_WRONLY | O_CREAT, 0644);
@@ -25,8 +20,11 @@ static void insert_into(int blogdir, char *index_dir, const char *uri, const cha
dprintf(new_index, HTML_HEAD, "index");
dprintf(new_index, "<a href=\"/%s\">%s</a><br>", uri, title);
+ /* add old entries */
+ int old_index = openat(blogdir, index_path, O_RDONLY);
if (old_index != -1) {
- /* add old entries */
+ /* find exising entries */
+ /* copy them to new_index */
close(old_index);
}
@@ -39,20 +37,13 @@ static void insert_into(int blogdir, char *index_dir, const char *uri, const cha
void add_to_index(const char *path, const char *title)
{
- /*
- printf("Status: 200 OK\r\n");
- printf("Content-Type: text/plain\r\n\r\n");
- */
-
int blogdir = open(DATA_DIRECTORY, O_DIRECTORY);
if (blogdir == -1) {
- printf("open(DATA_DIRECTORY): %s\n", strerror(errno));
return;
}
char *dir = strdup(path);
if (dir == NULL) {
- printf("strdup(path): %s\n", strerror(errno));
return;
}