Skip to content

Commit

Permalink
Check in 1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
davidlst committed Mar 28, 2014
1 parent 88a84a0 commit b59d039
Show file tree
Hide file tree
Showing 408 changed files with 33,171 additions and 24,394 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ Project(openlitespeed)
INCLUDE( ${PROJECT_SOURCE_DIR}/CMakeModules/common.cmake)

set(openlitespeed_MAJOR_VERSION 1)
set(openlitespeed_MINOR_VERSION 2)
set(openlitespeed_PATCH_VERSION 7)
set(openlitespeed_MINOR_VERSION 3)
set(openlitespeed_PATCH_VERSION 0)
set(openlitespeed_VERSION
${FOOBAR_MAJOR_VERSION}.${FOOBAR_MINOR_VERSION}.${FOOBAR_PATCH_VERSION})

Expand Down
1 change: 1 addition & 0 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DL_LIB_OPTION = @DL_LIB_OPTION@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
Expand Down
14 changes: 14 additions & 0 deletions addon/example/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
How to build the example module and use it?

There are four steps to do it

1, You need to compile and build it. You can simply use the ccc.sh to compile and build the module.
For example:
./ccc.sh hellohandler.c
Then you will get the module file hellehandler.so

2, Copy the module file to $LSWS-HOME/modules/

3, In the admin console, Configuration/Server/Modules/, add the newly created module, in the above example, the name is hellehandler, and enable it.

4, Restart openlitespeed and it should be added.
64 changes: 64 additions & 0 deletions addon/example/ccc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/bin/sh

echo =====================================================================================

if [ $# -eq 0 ] ; then
echo Need a c file name, such as $0 mymodule.c
echo
exit 1
fi

echo "You command is $0 $1"
echo

if [ ! -f $1 ] ; then
echo File $1 not exist
echo
exit 1
fi

if [ "x$1" = "x./loopbuff.c" ] ; then
echo "As I know loopbuff.c can not be compiled to a module. Quit."
echo
exit 1
fi


TARGET=`basename $1 .c`
echo Target=$TARGET
echo




SYS_NAME=`uname -s`
if [ "x$SYS_NAME" = "xDarwin" ] ; then
UNDEFINED_FLAG="-undefined dynamic_lookup"
else
UNDEFINED_FLAG=""
fi



gcc -g -Wall -fPIC -c -D_REENTRANT $(getconf LFS_CFLAGS) $TARGET.c
if [ -f loopbuff.c ]; then
gcc -g -Wall -fPIC -c -D_REENTRANT $(getconf LFS_CFLAGS) loopbuff.c
gcc -g -Wall -fPIC $UNDEFINED_FLAG $(getconf LFS_CFLAGS) -o $TARGET.so $TARGET.o loopbuff.o -shared
rm loopbuff.o
else
gcc -g -Wall -fPIC $UNDEFINED_FLAG $(getconf LFS_CFLAGS) -o $TARGET.so $TARGET.o -shared
fi

if [ -f $(pwd)/$TARGET.so ] ; then
echo -e "\033[38;5;71m$TARGET.so created.\033[39m"
else
echo -e "\033[38;5;203mError, $TARGET.so not exists.\033[39m"
fi

if [ -f $TARGET.o ] ; then
rm $TARGET.o
fi


echo Done!
echo
50 changes: 50 additions & 0 deletions addon/example/hellohandler.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
Copyright (c) 2014, LiteSpeed Technologies Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of the Lite Speed Technologies Inc nor the
names of its contributors may be used to endorse or promote
products derived from this software without specific prior
written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "../include/ls.h"

#define MNAME hellohandler
struct lsi_module_t MNAME;

int handlerBeginProcess(void *session)
{
g_api->set_status_code(session, 200);
g_api->set_resp_header(session, LSI_RESP_HEADER_CONTENT_TYPE, NULL, 0, "text/html", 9, LSI_HEADER_SET );
g_api->append_resp_body( session, "Hello module handler.\r\n", 23 );
g_api->end_resp(session);
return 0;
}
/**
* Define a handler, need to provide a struct _handler_st object, in which
* the first function pointer should not be NULL
*/
lsi_handler_t myhandler = { handlerBeginProcess, NULL, NULL };
lsi_module_t MNAME = { LSI_MODULE_SIGNATURE, NULL, &myhandler, NULL };
70 changes: 70 additions & 0 deletions addon/example/hellohandler2.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
Copyright (c) 2014, LiteSpeed Technologies Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of the Lite Speed Technologies Inc nor the
names of its contributors may be used to endorse or promote
products derived from this software without specific prior
written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "../include/ls.h"
#include <string.h>
#define MNAME hellohandler2
struct lsi_module_t MNAME;

int reg_handler(struct lsi_cb_param_t *rec)
{
const char *uri;
uri = g_api->get_req_uri(rec->_session);
if ( strstr(uri, ".345") != 0 )
{
g_api->register_req_handler(rec->_session, &MNAME, 0);
g_api->session_log(rec->_session, LSI_LOG_DEBUG, "[hellohandler2:%s] register_req_handler fot URI: %s\n",
MNAME._info, g_api->get_req_uri(rec->_session));
}
return LSI_RET_OK;
}

static int _init()
{
g_api->add_hook( LSI_HKPT_RECV_REQ_HEADER, &MNAME, reg_handler, LSI_HOOK_NORMAL, 0 );
g_api->log(LSI_LOG_DEBUG, "[hellohandler2:%s] _init [log in module code]", MNAME._info);
return 0;
}

int handlerBeginProcess(void *session)
{
g_api->append_resp_body( session, "Hello module handler2.\r\n", 24 );
g_api->end_resp(session);
g_api->session_log(session, LSI_LOG_DEBUG, "[hellohandler2:%s] handlerBeginProcess fot URI: %s\n",
MNAME._info, g_api->get_req_uri(session));
return 0;
}
/**
* Define a handler, need to provide a struct lsi_handler_t object, in which
* the first function pointer should not be NULL
*/
lsi_handler_t myhandler = { handlerBeginProcess, NULL, NULL };
lsi_module_t MNAME = { LSI_MODULE_SIGNATURE, _init, &myhandler, NULL, "version 1.0" };
Loading

0 comments on commit b59d039

Please sign in to comment.