commit d2c4fde7fee696a9aa977afb89a3b2bb3b6ec267
parent f48fe0a326d9a4403c2735ac0707499bbe13071f
Author: Joris Vink <joris@coders.se>
Date: Mon, 24 Jun 2013 18:29:40 +0200
fix so we can properly add binary media
Diffstat:
5 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/modules/example/build.sh b/modules/example/build.sh
@@ -10,7 +10,7 @@ MODULE=example.module
# The directory containing all your media files (HTML, CSS, ...).
# These files will be compiled into the module and symbols will
-# be exported for you to use in your code (see static.h after building).
+# be exported for you to use in your code.
MEDIA_DIR=media
# The directory containing your module source.
@@ -69,3 +69,4 @@ echo "Building completed!"
rm -rf ${SOURCE_DIR}/${MEDIA_DIR}
rm -rf .objs
rm -f tools/inject
+rm -f static.h
diff --git a/modules/example/media/intro.jpg b/modules/example/media/intro.jpg
Binary files differ.
diff --git a/modules/example/module.conf b/modules/example/module.conf
@@ -20,7 +20,7 @@ workers 2
#onload myinit
# Specifies what module to be loaded.
-load ./example.module
+load modules/example/example.module
# Domain configuration
#
@@ -46,6 +46,7 @@ domain 10.211.55.3 {
accesslog /var/log/kore_access.log
static /css/style.css serve_style_css
static / serve_index
+ static /intro.jpg serve_intro
}
#domain domain.com {
diff --git a/modules/example/src/example.c b/modules/example/src/example.c
@@ -42,6 +42,7 @@
int serve_style_css(struct http_request *);
int serve_index(struct http_request *);
+int serve_intro(struct http_request *);
int
serve_style_css(struct http_request *req)
@@ -84,3 +85,15 @@ serve_index(struct http_request *req)
return (ret);
}
+
+int
+serve_intro(struct http_request *req)
+{
+ int ret;
+
+ http_response_header_add(req, "content-type", "image/jpg");
+ ret = http_response(req, 200, static_jpg_intro,
+ static_len_jpg_intro);
+
+ return (ret);
+}
diff --git a/modules/example/tools/inject.c b/modules/example/tools/inject.c
@@ -32,7 +32,8 @@ main(int argc, char *argv[])
struct stat st;
ssize_t len;
FILE *hdr;
- char *ext, c[1];
+ char *ext;
+ unsigned char c[1];
int fd, newline, count;
if (argc != 3)