tadd and use function for dying with 500 response - vote - simple cgi voting system for web and gopher (HTM) git clone git://src.adamsgaard.dk/vote (DIR) Log (DIR) Files (DIR) Refs (DIR) README (DIR) LICENSE --- (DIR) commit 60cce502c63f387f1505a113c9b90ca14f929b06 (DIR) parent 22acb208bf624709b5693518ec831f9bbc2c8319 (HTM) Author: Anders Damsgaard <anders@adamsgaard.dk> Date: Sun, 27 Sep 2020 01:57:52 +0200 add and use function for dying with 500 response Diffstat: M vote.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) --- (DIR) diff --git a/vote.c b/vote.c t@@ -11,6 +11,12 @@ static char poll[1024]; void +die_500() { + OUT("Status: 500 Internal Server Error\r\n\r\n"); + exit(1); +} + +void print_html_head() { OUT("Content-type: text/html; charset=utf-8\r\n\r\n"); OUT("<!DOCTYPE html>\n" t@@ -60,21 +66,17 @@ main() { if (unveil(getenv("PWD"), NULL) == -1 && unveil(NULL, NULL) == -1) { fprintf(stderr, "unveil: %s\n", strerror(errno)); - OUT("Status: 500 Internal Server Error\r\n\r\n"); - exit(1); } if (pledge("stdio cpath rpath", NULL) == -1) { fprintf(stderr, "pledge: %s\n", strerror(errno)); - OUT("Status: 500 Internal Server Error\r\n\r\n"); - exit(1); + die_500(); } if (stat(POLLS_DIR, &sb) == -1) { if (mkdir(POLLS_DIR, 0755) == -1) { fprintf(stderr, "mkdir polls/ failed: %s\n", strerror(errno)); - OUT("Status: 500 Internal Server Error\r\n\r\n"); - exit(1); + die_500(); } }