Move task_curl example to tasks and into the new build framework

This commit is contained in:
Joris Vink 2014-08-03 17:44:36 +02:00
parent f4f8b1e8b0
commit ab592d2a59
5 changed files with 31 additions and 82 deletions

View File

@ -1,50 +0,0 @@
#!/bin/sh
#
# Copyright (c) 2013 Joris Vink <joris@coders.se>
#
# Kore module build script, use this as a base for building
# your own modules for kore.
# The name of the module you will be building
MODULE=task_curl.so
# The directory containing your module source.
SOURCE_DIR=.
# Compiler settings.
CC=gcc
CFLAGS="-I. -I/usr/local/include -Wall -Wstrict-prototypes \
-Wmissing-prototypes -Wmissing-declarations -Wshadow \
-Wpointer-arith -Wcast-qual -Wsign-compare -g"
OSNAME=$(uname -s | sed -e 's/[-_].*//g' | tr A-Z a-z)
if [ "${OSNAME}" = "darwin" ]; then
LDFLAGS="-dynamiclib -undefined suppress -flat_namespace -lcurl"
else
LDFLAGS="-L/usr/local/lib -shared -lcurl"
fi
MODULE_BUILD_DATE=$(date +"%Y-%m-%d %H:%M:%S")
### Begin building ####
echo "Building module ${MODULE}..."
rm -f ${MODULE}
if [ ! -d .objs ]; then
mkdir .objs;
fi
rm -f .objs/*
for src in `find ${SOURCE_DIR} -type f -name \*.c`; do
base=`basename $src`;
${CC} ${CFLAGS} -fPIC -c $src -o .objs/${base}.o
if [ $? -ne 0 ]; then
echo "Build error, check above messages for clues.";
exit 1;
fi
done
${CC} ${LDFLAGS} `find .objs -name \*.o -type f` -o ${MODULE}
echo "Building completed!"
rm -rf .objs

View File

@ -1,31 +0,0 @@
# Configuration for the contrib/examples/task_curl example.
bind 127.0.0.1 4443
chroot # configure this (ex: /home/joris/src/kore)
runas # configure this (ex: joris)
workers 1
pidfile kore.pid
load ./task_curl.so
ssl_no_compression
validator v_user regex ^[a-z]*$
domain 127.0.0.1 {
certfile # configure this (ex: cert/server.crt)
certkey # configure this (ex: cert/server.key)
accesslog kore_access.log
static / page_handler
static /post_back post_back
params get / {
validate user v_user
}
params post /post_back {
validate user v_user
}
}

View File

@ -0,0 +1,3 @@
Compile this example using:
# env KORE_LDFLAGS="-I/path/to/libcurl -lcurl"

View File

@ -0,0 +1,27 @@
# Kore config for tasks example
bind 127.0.0.1 8888
pidfile kore.pid
load ./tasks.so
ssl_no_compression
validator v_user regex ^[a-z]*$
domain 127.0.0.1 {
certfile cert/server.crt
certkey cert/server.key
accesslog kore_access.log
static / page_handler
static /post_back post_back
params get / {
validate user v_user
}
params post /post_back {
validate user v_user
}
}

View File

@ -195,7 +195,7 @@ run_curl(struct kore_task *t)
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, fields);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_write_cb);
curl_easy_setopt(curl, CURLOPT_URL, "https://127.0.0.1:4443/post_back");
curl_easy_setopt(curl, CURLOPT_URL, "https://127.0.0.1:8888/post_back");
res = curl_easy_perform(curl);
if (res != CURLE_OK) {