服务器显示rl112,第47章 RL-TCPnet之Web服务器的CGI实现

使用举例:

void cgi_process_data (U8 code, U8 *dat, U16 len) {

/* This function is called by HTTP server to process the returned Data    */

/* for the CGI Form POST method. It is called on SUBMIT from the browser. */

/* Parameters:                                                            */

/*   code  - callback context code                                        */

/*           0 = www-url-encoded form data                                */

/*           1 = filename for file upload (0-terminated string)           */

/*           2 = file upload raw data                                     */

/*           3 = end of file upload (file close requested)                */

/*           4 = any xml encoded POST data (single or last stream)        */

/*           5 = the same as 4, but with more xml data to follow          */

/*               Use http_get_content_type() to check the content type    */

/*   dat   - pointer to POST received data                                */

/*   len   - received data length                                         */

U8 *var;

switch (code) {

case 0:

/* Url encoded form data received. */

break;

case 1:

/* Filename for file upload received as encoded by the browser. */

/* It might contain an absolute path to a file from the sending */

/* host. Open a file for writing. */

return;

case 2:

/* File content data received. Write data to a file. */

/* This function will be called several times with   */

/* code 2 when a big file is being uploaded.         */

return;

case 3:

/* File upload finished. Close a file. */

return;

case 4:

/* XML encoded content type, last packet. */

// pType = http_get_content_type ();

/* check the content type for CGX file request. */

/* pType is a pointer to a 0-terminated string  */

/* For example: text/xml; charset=utf-8         */

return;

case 5:

/* XML encoded as under 4, but with more to follow. */

return;

default:

/* Ignore all other codes. */

return;

}

if (len == 0) {

/* No data or all items (radio, checkbox) are off. */

return;

}

var = (U8 *)alloc_mem (40);

do {

/* Parse all returned parameters. */

dat = http_get_var (dat, var, 40);

if (var[0] != 0) {

if (str_scomp (var, "TICK1=") == __TRUE || str_scomp (var, "pg=") == __TRUE)

{

if (str_scomp (var, "pg=") == __TRUE)

{

LEDControl = 0;

}

if(*(var+9) =='1')

{

LEDControl |= 0x01;

}

else if(*(var+9) =='2')

{

LEDControl |= 0x02;

}

else if(*(var+9) =='3')

{

LEDControl |= 0x04;

}

}

}

}while (dat);

free_mem ((OS_FRAME *)var);

if(LEDControl & 0x01)

{

bsp_LedOn(1);

}

else

{

bsp_LedOff(1);

}

if(LEDControl & 0x02)

{

bsp_LedOn(2);

}

else

{

bsp_LedOff(2);

}

if(LEDControl & 0x04)

{

bsp_LedOn(3);

}

else

{

bsp_LedOff(3);

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值