Skip to content

Commit

Permalink
Check in 1.3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
davidlst committed May 22, 2014
1 parent d00f448 commit d56b0bb
Show file tree
Hide file tree
Showing 70 changed files with 681 additions and 615 deletions.
4 changes: 2 additions & 2 deletions addon/example/hellohandler.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "../include/ls.h"

#define MNAME hellohandler
struct lsi_module_t MNAME;
lsi_module_t MNAME;

int handlerBeginProcess(void *session)
int handlerBeginProcess(lsi_session_t 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 );
Expand Down
8 changes: 4 additions & 4 deletions addon/example/hellohandler2.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ 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;
lsi_module_t MNAME;

int reg_handler(struct lsi_cb_param_t *rec)
static int reg_handler(lsi_cb_param_t * rec)
{
const char *uri;
int len;
Expand All @@ -56,11 +56,11 @@ static int _init( lsi_module_t * pModule )
return 0;
}

int handlerBeginProcess(void *session)
static int handlerBeginProcess(lsi_session_t 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",
g_api->session_log(session, LSI_LOG_DEBUG, "[hellohandler2:%s] handlerBeginProcess fot URI: %s\n",
MNAME._info, g_api->get_req_uri(session, NULL));
return 0;
}
Expand Down
14 changes: 7 additions & 7 deletions addon/example/httpcompress.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//#define GZIP_TWO_HOOK_IMPL


struct lsi_module_t MNAME;
lsi_module_t MNAME;


//static int isCompressible( void *session,
//static int isCompressible( lsi_session_t session,

#ifdef GZIP_HOOK_IMPL
static int httpCompress( struct lsi_cb_param_t *param )
static int httpCompress( lsi_cb_param_t *param )
{
void *session = param->_session;
lsi_session_t session = param->_session;
int iPtrLen, iCompressible; // NOTE: iPtrLen will be used for various purposes in this method.
char pCompressed[LSI_MAX_FILE_PATH_LEN];
const char *pFilePath,
Expand Down Expand Up @@ -135,15 +135,15 @@ lsi_module_t MNAME = { LSI_MODULE_SIGNATURE, _init, NULL, NULL, "httpCompress" }
#endif

#ifdef GZIP_TWO_HOOK_IMPL
static int httpEncode( struct lsi_cb_param_t *param )
static int httpEncode( lsi_cb_param_t *param )
{
g_api->set_resp_header(param->_session, LSI_RESP_HEADER_CONTENT_ENCODING, "Content-Encoding", 16, "gzip", 4, LSI_HEADER_SET);
return LSI_RET_OK;
}

static int httpCompress( struct lsi_cb_param_t *param )
static int httpCompress( lsi_cb_param_t *param )
{
void *session = param->_session;
lsi_session_t session = param->_session;
int iPtrLen, iUriLen, iCompressible; // NOTE: iPtrLen will be used for various purposes in this method.
char pDocPath[LSI_MAX_FILE_PATH_LEN], *ptr;
const char *pReqUri = g_api->get_req_uri( session, &iUriLen ),
Expand Down
22 changes: 11 additions & 11 deletions addon/example/imgresize.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ enum httpimg IMAGE_TYPE;
#define MNAME imgresize
/////////////////////////////////////////////////////////////////////////////

struct lsi_module_t MNAME;
lsi_module_t MNAME;
#define MAX_BLOCK_BUFSIZE 8192

typedef struct _MyData
Expand All @@ -67,10 +67,10 @@ typedef struct _MyData
} MyData;

/*Function Declarations*/
static int setWaitFull( struct lsi_cb_param_t *rec );
static int scanForImage( struct lsi_cb_param_t *rec );
static int parseParameters( struct lsi_cb_param_t *rec );
static int writeToNextFilter( struct lsi_cb_param_t *rec, MyData *myData );
static int setWaitFull( lsi_cb_param_t * rec );
static int scanForImage( lsi_cb_param_t * rec );
static int parseParameters( lsi_cb_param_t * rec );
static int writeToNextFilter( lsi_cb_param_t * rec, MyData *myData );
static int getReqDimensions( const char *buf, int *width, int *height );
static void* resizeImage( const char *buf, int bufLen, int width, int height, MyData *myData, int *size );
static int _init();
Expand All @@ -90,7 +90,7 @@ int httpRelease(void *data)
return 0;
}

int httpinit(struct lsi_cb_param_t *rec)
int httpinit(lsi_cb_param_t * rec)
{
MyData *myData = (MyData *)g_api->get_module_data(rec->_session, &MNAME, LSI_MODULE_DATA_HTTP);
if (myData == NULL )
Expand All @@ -114,13 +114,13 @@ int httpinit(struct lsi_cb_param_t *rec)
return 0;
}

static int setWaitFull( struct lsi_cb_param_t *rec )
static int setWaitFull( lsi_cb_param_t * rec )
{
g_api->set_resp_wait_full_body( rec->_session );
return LSI_RET_OK;
}

static int scanForImage( struct lsi_cb_param_t *rec )
static int scanForImage( lsi_cb_param_t * rec )
{
MyData *myData = NULL;
int iLen, inLen, iWidth = 0, iHeight = 0;
Expand Down Expand Up @@ -152,7 +152,7 @@ static int scanForImage( struct lsi_cb_param_t *rec )
}

/* Returns 0 for image, 1 for wrong input */
static int parseParameters( struct lsi_cb_param_t *rec )
static int parseParameters( lsi_cb_param_t * rec )
{
int iLen;
const char *ptr;
Expand All @@ -178,7 +178,7 @@ static int parseParameters( struct lsi_cb_param_t *rec )
return 0;
}

static int writeToNextFilter( struct lsi_cb_param_t *rec, MyData *myData )
static int writeToNextFilter( lsi_cb_param_t * rec, MyData *myData )
{
int iBytesWritten;
_loopbuff_reorder(&myData->outWBuf);
Expand Down Expand Up @@ -239,7 +239,7 @@ static void *resizeImage( const char *buf, int bufLen, int width, int height, My
return ptr;
}

static int scanDynamic( struct lsi_cb_param_t *rec )
static int scanDynamic( lsi_cb_param_t * rec )
{
off_t offset = 0;
int iSrcSize, iDestSize, iWidth, iHeight, iLen = 0;
Expand Down
8 changes: 4 additions & 4 deletions addon/example/mytest.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <string.h>

#define MNAME mytest
struct lsi_module_t MNAME;
lsi_module_t MNAME;

static int reg_handler(struct lsi_cb_param_t *rec)
static int reg_handler(lsi_cb_param_t * rec)
{
const char *uri;
int len;
Expand All @@ -53,13 +53,13 @@ static int _init()
return 0;
}

static int beginProcess(void *session)
static int beginProcess(lsi_session_t session)
{
g_api->append_resp_body( session, "MyTest!", 7 );
g_api->end_resp(session);
return 0;
}

struct lsi_handler_t myhandler = { beginProcess, NULL, NULL, NULL };
lsi_handler_t myhandler = { beginProcess, NULL, NULL, NULL };
lsi_module_t MNAME = { LSI_MODULE_SIGNATURE, _init, &myhandler, NULL, };

10 changes: 5 additions & 5 deletions addon/example/replybigbufhandler.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define MNAME replybigbufhandler
/////////////////////////////////////////////////////////////////////////////

struct lsi_module_t MNAME;
lsi_module_t MNAME;

#define REPLY_BUFFER_LENGTH (1*1024*1024)
/**
Expand All @@ -57,7 +57,7 @@ static int freeMydata(void *data)
return 0;
}

static int reg_handler(struct lsi_cb_param_t *rec)
static int reg_handler(lsi_cb_param_t * rec)
{
const char *uri;
int len;
Expand All @@ -84,7 +84,7 @@ static int init( lsi_module_t * pModule)
}

//The first time the below function will be called, then onWriteEvent will be called next and next
static int myhandler_process(void *session)
static int myhandler_process(lsi_session_t session)
{
g_api->set_resp_header(session, LSI_RESP_HEADER_CONTENT_TYPE, NULL, 0, "text/html", 9, LSI_HEADER_SET );
int writeSize = sizeof("replybigbufhandler module reply the first line\r\n") - 1;
Expand All @@ -97,7 +97,7 @@ static int myhandler_process(void *session)
}

//return 0: error, 1: done, 2: not finished, definitions are in ls.h
static int onWriteEvent( void *session)
static int onWriteEvent( lsi_session_t session)
{
#define BLOACK_SIZE (1024)
int i;
Expand All @@ -123,5 +123,5 @@ static int onWriteEvent( void *session)
return LSI_WRITE_RESP_FINISHED;
}

struct lsi_handler_t myhandler = { myhandler_process, NULL, onWriteEvent, NULL };
lsi_handler_t myhandler = { myhandler_process, NULL, onWriteEvent, NULL };
lsi_module_t MNAME = { LSI_MODULE_SIGNATURE, init, &myhandler, NULL, };
22 changes: 11 additions & 11 deletions addon/example/reqinfhandler.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#define TESTURI "/reqinfo"

struct lsi_module_t MNAME;
lsi_module_t MNAME;

typedef struct _MyData
{
Expand All @@ -81,7 +81,7 @@ static int releaseData(void *data)
return 0;
}

static int resetData(struct lsi_cb_param_t *rec)
static int resetData(lsi_cb_param_t * rec)
{
MyData *myData = (MyData *)g_api->get_module_data(rec->_session, &MNAME, LSI_MODULE_DATA_HTTP);
if (myData)
Expand All @@ -91,7 +91,7 @@ static int resetData(struct lsi_cb_param_t *rec)
return 0;
}

static int initData(struct lsi_cb_param_t *rec)
static int initData(lsi_cb_param_t * rec)
{
MyData *myData = (MyData *)g_api->get_module_data(rec->_session, &MNAME, LSI_MODULE_DATA_HTTP);
if (!myData)
Expand All @@ -103,7 +103,7 @@ static int initData(struct lsi_cb_param_t *rec)
return 0;
}

static int check_uri_and_reg_handler(struct lsi_cb_param_t *rec)
static int check_uri_and_reg_handler(lsi_cb_param_t * rec)
{
const char *uri;
int len;
Expand All @@ -125,7 +125,7 @@ static int _init( lsi_module_t * pModule )
}

//0:no body or no deal, 1,echo, 2: md5, 3, save to file
static int getReqBodyDealerType(void *session)
static int getReqBodyDealerType(lsi_session_t session)
{
char path[512];
int n;
Expand Down Expand Up @@ -290,7 +290,7 @@ const char *reqHeaderArray[] = {
"X-Forwarded-For",
};

static inline void append( void *session, const char *s, int n)
static inline void append( lsi_session_t session, const char *s, int n)
{
if ( n == 0)
n = strlen(s);
Expand All @@ -301,7 +301,7 @@ static inline void append( void *session, const char *s, int n)
#define CONTENT_HEAD "<html><head><title>Server request varibles</title></head><body>\r\n"
#define CONTENT_FORMAT "<tr><td>%s</td><td>%s</td></tr>\r\n"
#define CONTENT_TAIL "</body></html>\r\n"
static int handleReqBody( void *session)
static int handleReqBody( lsi_session_t session)
{
unsigned char md5[16];
char buf[8192];
Expand Down Expand Up @@ -379,7 +379,7 @@ static int handleReqBody( void *session)
return readbytes;
}

static int handlerBeginProcess( void *session)
static int handlerBeginProcess( lsi_session_t session)
{
#define VALMAXSIZE 512
#define LINEMAXSIZE (VALMAXSIZE + 50)
Expand Down Expand Up @@ -502,13 +502,13 @@ static int handlerBeginProcess( void *session)
return 0;
}

static int cleanUp( void *session)
static int cleanUp( lsi_session_t session)
{
g_api->free_module_data(session, &MNAME, LSI_MODULE_DATA_HTTP, releaseData);
return 0;
}

static int handlerWriteRemainResp( void *session)
static int handlerWriteRemainResp( lsi_session_t session)
{
MyData *myData = (MyData *)g_api->get_module_data(session, &MNAME, LSI_MODULE_DATA_HTTP);
if ( myData == NULL || myData->type == 0 || myData->resp_done == 1)
Expand All @@ -518,7 +518,7 @@ static int handlerWriteRemainResp( void *session)
return LSI_WRITE_RESP_CONTINUE;
}

struct lsi_handler_t reqHandler = { handlerBeginProcess, handleReqBody, handlerWriteRemainResp, cleanUp };
lsi_handler_t reqHandler = { handlerBeginProcess, handleReqBody, handlerWriteRemainResp, cleanUp };

lsi_module_t MNAME = { LSI_MODULE_SIGNATURE, _init, &reqHandler, NULL, };

4 changes: 2 additions & 2 deletions addon/example/reqobservmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const char *blockWords[] = {
"badword3",
};

struct lsi_module_t MNAME;
lsi_module_t MNAME;

static int hasBadWord(const char *s, size_t len)
{
Expand All @@ -75,7 +75,7 @@ static int hasBadWord(const char *s, size_t len)
}


int check_req_whole_body(struct lsi_cb_param_t *rec)
int check_req_whole_body(lsi_cb_param_t * rec)
{
off_t offset = 0;
const char * pBuf;
Expand Down
10 changes: 5 additions & 5 deletions addon/example/sendfilehandler.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,16 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define MNAME sendfilehandler
/////////////////////////////////////////////////////////////////////////////

struct lsi_module_t MNAME;
int dummycall(struct lsi_cb_param_t *rec)
lsi_module_t MNAME;
int dummycall(lsi_cb_param_t * rec)
{
const char *in = (const char *)rec->_param;
int inLen = rec->_param_len;
int sent = g_api->stream_write_next( rec, in, inLen );
return sent;
}

int reg_handler(struct lsi_cb_param_t *rec)
int reg_handler(lsi_cb_param_t * rec)
{
const char *uri;
int len;
Expand All @@ -71,7 +71,7 @@ static int init(lsi_module_t * pModule)

}

static int myhandler_process(void *session)
static int myhandler_process(lsi_session_t session)
{
struct stat sb;
const char *file = "/home/user/ls0312/DEFAULT/html/test1";
Expand All @@ -97,5 +97,5 @@ static int myhandler_process(void *session)
return 0;
}

struct lsi_handler_t myhandler = { myhandler_process, NULL, NULL, NULL };
lsi_handler_t myhandler = { myhandler_process, NULL, NULL, NULL };
lsi_module_t MNAME = { LSI_MODULE_SIGNATURE, init, &myhandler, NULL, };
Loading

0 comments on commit d56b0bb

Please sign in to comment.