aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Isom <coder@kyleisom.net>2012-05-22 10:41:45 +0300
committerKyle Isom <coder@kyleisom.net>2012-05-22 10:41:45 +0300
commitba05bc66ff2424947715cd2916c89bb7553f5940 (patch)
tree667669b1f2aa62adfc365dec172467cafa5514c4
parentc68d542bb929da635872d44140f0b489fda98d11 (diff)
downloadsrvwd-ba05bc66ff2424947715cd2916c89bb7553f5940.tar.gz
srvwd-ba05bc66ff2424947715cd2916c89bb7553f5940.tar.bz2
srvwd-ba05bc66ff2424947715cd2916c89bb7553f5940.zip
add more mime types
-rw-r--r--content.c16
-rw-r--r--content.h25
2 files changed, 33 insertions, 8 deletions
diff --git a/content.c b/content.c
index 92d0087..5385a67 100644
--- a/content.c
+++ b/content.c
@@ -20,6 +20,7 @@
#include <bsd/string.h> /* linux hosts, we need to use the */
#endif /* BSD string library */
+#include <err.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -51,6 +52,10 @@ content_type(char *filename)
ct = CT_CSS;
else if (NULL != strstr(extptr, SRVWD_EXT_PDF))
ct = CT_PDF;
+ else if (NULL != strstr(extptr, SRVWD_EXT_JPEG))
+ ct = CT_JPEG;
+ else if (NULL != strstr(extptr, SRVWD_EXT_PNG))
+ ct = CT_PNG;
else
ct = CT_HTML;
@@ -84,10 +89,18 @@ content_type_to_str(CONTENT_TYPE ct)
if (strlcpy(ct_str, SRVWD_CT_CSS, SRVWD_BUFSIZE) < 1)
error = 1;
break;
+ case CT_JPEG:
+ if (strlcpy(ct_str, SRVWD_CT_JPEG, SRVWD_BUFSIZE) < 1)
+ error = 1;
+ break;
case CT_PDF:
if (strlcpy(ct_str, SRVWD_CT_PDF, SRVWD_BUFSIZE) < 1)
error = 1;
break;
+ case CT_PNG:
+ if (strlcpy(ct_str, SRVWD_CT_PNG, SRVWD_BUFSIZE) < 1)
+ error = 1;
+ break;
case CT_UNKNOWN:
error = 1;
break;
@@ -102,6 +115,9 @@ content_type_to_str(CONTENT_TYPE ct)
ct_str = NULL;
}
+ if (ct_str)
+ warnx("content-type: %s", ct_str);
+
return ct_str;
}
diff --git a/content.h b/content.h
index 0f1e2f3..c753b9c 100644
--- a/content.h
+++ b/content.h
@@ -15,22 +15,31 @@
*/
-#define SRVWD_EXT_PLAIN ".txt"
-#define SRVWD_EXT_HTML ".html"
+/* file extensions */
#define SRVWD_EXT_CSS ".css"
+#define SRVWD_EXT_HTML ".html"
+#define SRVWD_EXT_JPEG ".jpg"
#define SRVWD_EXT_PDF ".pdf"
-#define SRVWD_CT_PLAIN "text/plain"
+#define SRVWD_EXT_PNG ".png"
+#define SRVWD_EXT_PLAIN ".txt"
+
+/* MIME types */
+#define SRVWD_CT_PDF "application/pdf"
#define SRVWD_CT_CSS "text/css"
#define SRVWD_CT_HTML "text/html"
-#define SRVWD_CT_PDF "application/pdf"
+#define SRVWD_CT_JPEG "image/jpeg"
+#define SRVWD_CT_PNG "image/png"
+#define SRVWD_CT_PLAIN "text/plain"
enum E_CONTENT_TYPE {
- CT_UNKNOWN,
- CT_HTML,
- CT_TEXT,
+ CT_UNKNOWN = -1,
CT_CSS,
- CT_PDF
+ CT_HTML,
+ CT_JPEG,
+ CT_PDF,
+ CT_PNG,
+ CT_TEXT
};
typedef enum E_CONTENT_TYPE CONTENT_TYPE;