diff --git a/modules/example/build.sh b/modules/example/build.sh index 3d95ab2..2897dda 100755 --- 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 new file mode 100644 index 0000000..de81874 Binary files /dev/null and b/modules/example/media/intro.jpg differ diff --git a/modules/example/module.conf b/modules/example/module.conf index 1396da4..4f3988b 100644 --- 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 index 327b6ad..dadb941 100644 --- 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 index 1e4876f..ddb45d1 100755 --- 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)