summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2020-10-28 12:49:47 -0400
committerDrew DeVault <sir@cmpwn.com>2020-10-28 12:49:47 -0400
commita26573251bf84d43dc32a6253c7ca7f6dcd36053 (patch)
tree5dd316d24212a83968efe3718b06940ce1158ae7 /src
parent077b96d3cc2267d571cb73d64286a0d5e897dd1a (diff)
downloadgmnisrv-a26573251bf84d43dc32a6253c7ca7f6dcd36053.tar.gz
gmnisrv-a26573251bf84d43dc32a6253c7ca7f6dcd36053.tar.xz
gmnisrv-a26573251bf84d43dc32a6253c7ca7f6dcd36053.zip
Fail gracefully if mime database is not present
Diffstat (limited to 'src')
-rw-r--r--src/mime.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/mime.c b/src/mime.c
index 0c4cc8b..9f3f6d0 100644
--- a/src/mime.c
+++ b/src/mime.c
@@ -1,4 +1,5 @@
#include <assert.h>
+#include <errno.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
@@ -29,7 +30,12 @@ mime_init()
mimedb = malloc(mimedb_sz * sizeof(struct mime_info));
FILE *f = fopen(MIMEDB, "r");
- assert(f);
+ if (!f) {
+ fprintf(stderr, "Unable to open MIME database for reading: %s\n",
+ strerror(errno));
+ fprintf(stderr, "Is " MIMEDB " installed?\n");
+ assert(0);
+ }
char *line = NULL;
size_t n = 0;