区域管理cgi程序在网页上设定一个区域内所有灯光设备的开关
area_con.c
#include
#include
#include
#include
#include
#include "html.h"
#include "config.h"
#include "ipc.h"
void table_tr(char * name,char sw,int type_id)
{
int i;
printf("%s ",name);
if(sw==1){
printf("开启关闭 ",type_id,type_id);
}else{
printf("开启关闭 ",type_id,type_id);
}
printf("删除区域 ",type_id);
printf(" ");
}
int main(int argc, char * argv[])
{
int ret=0;
int i,msgid;
struct sys_all * shm_dev;
char item_name[4][16];
if((msgid=get_msgid())<0){
ret=ERR_MSG;
}
if(msg_send(msgid,CMD_GET)==0){
if(NULL==(shm_dev=(struct sys_all *)set_web_shm())){
ret=ERR_SHM;
}
}
html_head();
html_title();
html_nav();
html_table_title("区域管理","区域设置","区域管理");
if(ret!=0){
html_return_show(ret);
html_end();
return 0;
}
printf("
area_con_post.c
#include
#include
#include
#include
#include "html.h"
#include "config.h"
#include "ipc.h"
#include "getvalue.h"
int main(int argc,char * argv[])
{
int ret=0;
char *val=NULL;
char val_name[16];
char type_id[2]="0";
int i,msgid;
struct sys_all * shm_dev;
char buf[32]="";
set_env(getenv("REQUEST_METHOD"),getenv("CONTENT_LENGTH"),getenv("QUERY_STRING"));
html_head();
html_refresh("3","/cgi-bin/area_con.cgi");
html_title();
html_nav();
html_table_title("区域管理","区域设置","区域管理");
if(NULL==(shm_dev=(struct sys_all *)set_web_shm())){
ret=ERR_SHM;
}else{
for(i=0;isys_area[i].sw_sta=val[0]-'0';
}
strcpy(val_name,"flag");
strcat(val_name,type_id);
val=get_value(val_name);
if(val!=NULL){
shm_dev->sys_area[i].enable_flag=val[0]-'0';
}
}
}
if(ret==0){
if((msgid=get_msgid())<0) ret=ERR_MSG;
if(msg_send(msgid,CMD_SET)<0) ret=ERR_MSG;
}
html_return_show(ret);
html_end();
return 0;
}