保存桌面快捷方式 - - 设为首页 - 手机版
凹丫丫旗下网站:四字成语大全 - 故事大全 - 范文大全
您现在的位置: 范文大全 >> 理工论文 >> 电子通信论文 >> 正文

嵌入式Linux系统CGI程序设计技术


variable1=value1&variable2=value2&etc

CGI程序必须检查REQUEST_METHOD环境变量以确定是否采用了POST方法,并决定是否要读取STDIN。POST方法在HTML文档中定义的表单如下:

<FORM METHOD=POST ACTION="/cgi-bin/cgi_gpio.cgi">

<INPUT TYPE="RADIO"NAME=rb VALUE="0">Operate P0<BR>

<INPUT TYPE="RADIO"NAME=rb VALUE="1">Operate P1<BR>

<INPUT TYPE="RADIO"NAME=rb VALUE="2">Operate P2<BR>

<INPUT NAME="ok"TYPE=submit VALUE="OK"><INPUT>

NAME="cancel"TYPE=reset VALUE="RESET"></FORM>

它调用的服务器脚本程序是/cgi/bin/cgi_gpio.cgi。CGI扩展程序中FORM表单的解码可参考如下程序:

/*function getPOSTvars*/

char **getPOSTvars(){

int i;

int content_length;

char **postvars;

char *postinput;

char **pairlist;

int paircount=0;

chr *nvpair;

char *eqpos;

postinput=getenv("CONTENT_LENGTH");//获取传送给程序数据的字节数

if(!postinput)

exit();

if(!content_length=atoi(postinput))) //获取信息长度

exit(1);

if(!(postinput=(char*)malloc(content_length+1)))

exit(1);

if(!fread(postinput,content_length,1,stadin))

exit(1);

postinput[content_length]='0';

for(i=0;postinput[i];i++)

if(postinput[i]=='+')

postinput[i]=''; //对加易进行处理

pairlist=(char **)malloc(256*sizeof(char **));

paircount

《嵌入式Linux系统CGI程序设计技术(第3页)》
本文链接地址:http://www.oyaya.net/fanwen/view/163337.html

★温馨提示:你可以返回到 电子通信论文 也可以利用本站页顶的站内搜索功能查找你想要的文章。