-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
408 changed files
with
33,171 additions
and
24,394 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" }; |
Oops, something went wrong.