forked from mirrors/kore
add example module that can be built to test kore.
This commit is contained in:
parent
4ecfd81e6e
commit
3ca83c9857
|
@ -4,9 +4,9 @@
|
||||||
bind 10.211.55.3 443
|
bind 10.211.55.3 443
|
||||||
|
|
||||||
# Load our site module now (containing all the goodies).
|
# Load our site module now (containing all the goodies).
|
||||||
load ../betrippin/betrippin.module
|
load example/example.module
|
||||||
|
|
||||||
# Declare page handlers below.
|
# Declare page handlers below.
|
||||||
# handler path module_callback
|
# handler path module_callback
|
||||||
static /css/main.css betrippin_serve_style_css
|
static /css/style.css betrippin_serve_style_css
|
||||||
static / betrippin_serve_index
|
static / betrippin_serve_index
|
||||||
|
|
|
@ -0,0 +1,49 @@
|
||||||
|
# Example Kore module
|
||||||
|
|
||||||
|
.SUFFIXES: .html .css
|
||||||
|
|
||||||
|
CC=gcc
|
||||||
|
BIN=example.module
|
||||||
|
|
||||||
|
HTML= html/index.html
|
||||||
|
H_SRCS= $(HTML:.html=.c)
|
||||||
|
|
||||||
|
CSS= css/style.css
|
||||||
|
C_SRCS= $(CSS:.css=.c)
|
||||||
|
|
||||||
|
S_SRC= src/example.c $(H_SRCS) $(C_SRCS)
|
||||||
|
S_OBJS= $(S_SRC:.c=.o)
|
||||||
|
|
||||||
|
CFLAGS+=-I. -I../includes
|
||||||
|
CFLAGS+=-Wall -Wstrict-prototypes -Wmissing-prototypes
|
||||||
|
CFLAGS+=-Wmissing-declarations -Wshadow -Wpointer-arith -Wcast-qual
|
||||||
|
CFLAGS+=-Wsign-compare -g
|
||||||
|
LDFLAGS+=-shared
|
||||||
|
|
||||||
|
all:
|
||||||
|
make clean
|
||||||
|
make example.module
|
||||||
|
|
||||||
|
example.module: html_inject $(H_SRCS) $(C_SRCS) $(S_OBJS)
|
||||||
|
$(CC) $(LDFLAGS) $(S_OBJS) -o $(BIN)
|
||||||
|
make clean_o
|
||||||
|
|
||||||
|
html_inject: tools/html_inject.c
|
||||||
|
$(CC) $(CFLAGS) tools/html_inject.c -o tools/html_inject
|
||||||
|
|
||||||
|
.html.c:
|
||||||
|
tools/html_inject $< `basename $<` > $@
|
||||||
|
|
||||||
|
.css.c:
|
||||||
|
tools/html_inject $< `basename $<` > $@
|
||||||
|
|
||||||
|
.c.o: $<
|
||||||
|
$(CC) -fPIC $(CFLAGS) -c $< -o $@
|
||||||
|
|
||||||
|
clean:
|
||||||
|
make clean_o
|
||||||
|
rm -f css/*.c html/*.c tools/html_inject $(BIN)
|
||||||
|
rm -f static.h
|
||||||
|
|
||||||
|
clean_o:
|
||||||
|
rm -f css/*.o html/*.o src/*.o
|
|
@ -0,0 +1,16 @@
|
||||||
|
body {
|
||||||
|
width: 100%;
|
||||||
|
margin: 0px;
|
||||||
|
color: #000;
|
||||||
|
overflow: hidden;
|
||||||
|
background-color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.content {
|
||||||
|
width: 800px;
|
||||||
|
margin-left: auto;
|
||||||
|
margin-right: auto;
|
||||||
|
margin-top: 100px;
|
||||||
|
font-size: 60px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
<!DOCTYPE>
|
||||||
|
<head>
|
||||||
|
<link rel="stylesheet" href="/css/style.css" type="text/css">
|
||||||
|
<title>Your KORE module worked!</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<div class="content">
|
||||||
|
<p>Your first Kore module worked.</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -0,0 +1,66 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2013 Joris Vink <joris@coders.se>
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <sys/queue.h>
|
||||||
|
#include <sys/epoll.h>
|
||||||
|
|
||||||
|
#include <netinet/in.h>
|
||||||
|
#include <arpa/inet.h>
|
||||||
|
|
||||||
|
#include <openssl/err.h>
|
||||||
|
#include <openssl/ssl.h>
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <zlib.h>
|
||||||
|
|
||||||
|
#include "spdy.h"
|
||||||
|
#include "kore.h"
|
||||||
|
#include "http.h"
|
||||||
|
|
||||||
|
#include "static.h"
|
||||||
|
|
||||||
|
int betrippin_serve_style_css(struct http_request *);
|
||||||
|
int betrippin_serve_index(struct http_request *);
|
||||||
|
|
||||||
|
int
|
||||||
|
betrippin_serve_style_css(struct http_request *req)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = http_response(req, 200, static_css_style,
|
||||||
|
static_len_css_style, "text/css");
|
||||||
|
|
||||||
|
return (ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
betrippin_serve_index(struct http_request *req)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = http_response(req, 200, static_html_index,
|
||||||
|
static_len_html_index, "text/html");
|
||||||
|
|
||||||
|
return (ret);
|
||||||
|
}
|
|
@ -0,0 +1,74 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2013 Joris Vink <joris@coders.se>
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sys/param.h>
|
||||||
|
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <err.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
size_t len;
|
||||||
|
FILE *fp, *hdr;
|
||||||
|
char *ext, *p, *c, buf[1024];
|
||||||
|
|
||||||
|
if (argc != 3)
|
||||||
|
err(1, "arguments");
|
||||||
|
if ((fp = fopen(argv[1], "r")) == NULL)
|
||||||
|
err(1, "fopen() %d", errno);
|
||||||
|
if ((hdr = fopen("static.h", "a+")) == NULL)
|
||||||
|
err(1, "fopen() %d", errno);
|
||||||
|
if ((ext = strchr(argv[2], '.')) != NULL)
|
||||||
|
*(ext)++ = '\0';
|
||||||
|
|
||||||
|
printf("/**** AUTO GENERATED BY MAKEFILE - DO NOT TOUCH ****/\n");
|
||||||
|
printf("#include <sys/param.h>\n\n");
|
||||||
|
printf("u_int8_t *static_%s_%s = (u_int8_t *)", ext, argv[2]);
|
||||||
|
|
||||||
|
len = 0;
|
||||||
|
while (fgets(buf, sizeof(buf), fp)) {
|
||||||
|
if ((p = strchr(buf, '\n')) != NULL)
|
||||||
|
*p = '\0';
|
||||||
|
|
||||||
|
printf("\n\t\"");
|
||||||
|
for (c = buf; *c != '\0'; c++) {
|
||||||
|
if (*c == '"' || *c == '\\')
|
||||||
|
printf("\\");
|
||||||
|
printf("%c", *c);
|
||||||
|
len++;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("\\n\"");
|
||||||
|
len++;
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose(fp);
|
||||||
|
|
||||||
|
printf(";\n\n");
|
||||||
|
printf("u_int32_t static_len_%s_%s = %ld;", ext, argv[2], len);
|
||||||
|
|
||||||
|
fprintf(hdr, "extern u_int8_t *static_%s_%s;\n", ext, argv[2]);
|
||||||
|
fprintf(hdr, "extern u_int32_t static_len_%s_%s;\n", ext, argv[2]);
|
||||||
|
fclose(hdr);
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
Loading…
Reference in New Issue