#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "html.h"
#include "config.h"
#include "ipc.h"
void table_tr(struct sys_all* shm_dev)
{
char id;
int i;
printf("<tr ><td><input type=\"text\" name=\"name\" value=\"%s\"> </td><td>","区域N");
for(i=0;i<shm_dev->count_dev;i++){
id = shm_dev->sys_dev[i].node.type;
if(id == DEV_T_LIGHT1 || id == DEV_T_LIGHT2 || id == DEV_T_LIG_NET)
printf("<input type=\"checkbox\" name=\"light%d\" value=\"%d\">%s ",
id,id,shm_dev->sys_dev[i].name);
}
printf("</td><td class=\"center\"><button type=\"submit\" >创建</button> </td></tr>");
}
int main(int argc, char *argv[])
{
int ret = 0;
int i,msgid;
struct sys_all* shm_dev;
char item_name[3][10];
if((msgid=get_msgid()) < 0){
ret = ERR_MSG;
}
if(msg_send(msgid,CMD_GET)==0){
if((shm_dev=(struct sys_all*)set_web_shm())==NULL){
ret = ERR_SHM;
}
}
html_head();
html_title();
html_nav();
html_table_title("区域创建" , "区域设置" , "区域创建" );
if(ret != 0){
html_return_show(ret);
html_end();
return 0;
}
printf("<form method=\"get\" action=\"/cgi-bin/area_add_post.cgi\">");
strcpy(item_name[0],"区域名称");
strcpy(item_name[1],"设备选择");
strcpy(item_name[2],"提交操作");
html_table_head(3,item_name,"区域创建");
table_tr(shm_dev);
html_table_end();
printf("</form>");
html_end();
return 0;
}
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "getvalue.h"
#include "html.h"
#include "config.h"
#include "ipc.h"
int main(int argc, char *argv[])
{
int ret = 0;
char *val = NULL;
char val_name[16];
char type_id[2]="0";
int i,j,index,msgid;
struct sys_all* shm_dev;
char web_buf[128]="ret=";
set_env(getenv("REQUEST_METHOD"),
getenv("CONTENT_LENGTH"),
getenv("QUERY_STRING"));
html_head();
html_refresh("3","/cgi-bin/area_add.cgi");
html_title();
html_nav();
html_table_title("区域创建" , "区域设置" , "区域创建" );
if((shm_dev=(struct sys_all*)set_web_shm())==NULL){
ret = ERR_SHM;
}else{
for(i=0;i<MAX_DEV;i++){
if(shm_dev->sys_area[i].enable_flag == 0){
val = get_value("name");
type_id[0] = i + '0';strcat(web_buf,type_id);
strcat(web_buf,val);
strcpy(shm_dev->sys_area[i].name,val);
index = 0;
shm_dev->sys_area[i].enable_flag = 1;
for(j=0;j<shm_dev->count_dev;j++){
type_id[0] = shm_dev->sys_dev[j].node.type + '0';
strcpy(val_name,"light");
strcat(val_name,type_id);
val = get_value(val_name);
if(val != NULL){
strcat(web_buf,val_name);
strcat(web_buf,"=");
strcat(web_buf,val);
shm_dev->sys_area[i].dev_id[index] = val[0]-'0';
index++;
}
}
break;
}
}
if(i==8)
ret = ERR_REG;
}
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;
}
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include "html.h"
#include "config.h"
#include "ipc.h"
void table_tr(char* name,char sw,int type_id)
{
int i;
printf("<tr ><td>%s</td>",name);
if(sw==1){
printf("<td class=\"center\"><input type=\"radio\" checked=\"checked\" value=\"1\" name=\"sw_sta%d\"> 开启<input type=\"radio\" value=\"0\" name=\"sw_sta%d\">关闭</td>",type_id,type_id);
}else{
printf("<td class=\"center\"><input type=\"radio\" value=\"1\" name=\"sw_sta%d\"> 开启<input type=\"radio\" value=\"0\" name=\"sw_sta%d\" checked=\"checked\">关闭</td>",type_id,type_id);
}
printf("<td><input type=\"checkbox\" name=\"flag%d\" value=\"0\"> 删除区域</td>",type_id);
printf("</td><td class=\"center\"><button type=\"submit\" >设置</button> </td></tr>");
}
int main(int argc, char *argv[])
{
int ret = 0;
int i,msgid;
struct sys_all* shm_dev;
char item_name[4][10];
if((msgid=get_msgid()) < 0){
ret = ERR_MSG;
}
if(msg_send(msgid,CMD_GET)==0){
if((shm_dev=(struct sys_all*)set_web_shm())==NULL){
ret = ERR_SHM;
}
}
html_head();
html_title();
html_nav();
html_table_title("区域管理" , "区域设置" , "区域管理" );
if(ret != 0){
html_return_show(ret);
html_end();
return 0;
}
printf("<form method=\"get\" action=\"/cgi-bin/area_con_post.cgi\">");
strcpy(item_name[0],"区域名称");
strcpy(item_name[1],"区域开关");
strcpy(item_name[2],"区域删除");
strcpy(item_name[3],"提交操作");
html_table_head(4,item_name,"区域管理");
for(i=0;i<MAX_DEV;i++){
if(shm_dev->sys_area[i].enable_flag == 1)
table_tr(shm_dev->sys_area[i].name,shm_dev->sys_area[i].sw_sta,i);
}
html_table_end();
printf("</form>");
html_end();
return 0;
}
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "getvalue.h"
#include "html.h"
#include "config.h"
#include "ipc.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 web_buf[128]="";
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((shm_dev=(struct sys_all*)set_web_shm())==NULL){
ret = ERR_SHM;
}else{
for(i=0;i<MAX_DEV;i++){
type_id[0] = i + '0';
strcpy(val_name,"sw_sta");
strcat(val_name,type_id);
val = get_value(val_name);
if(val != NULL){
strcat(web_buf,val_name);
strcat(web_buf,val);
shm_dev->sys_area[i].sw_sta = val[0] - '0';
}
strcpy(val_name,"flag");
strcat(val_name,type_id);
val = get_value(val_name);
if(val != NULL){
strcat(web_buf,val_name);
strcat(web_buf,val);
bzero(&(shm_dev->sys_area[i]),sizeof(struct sys_area));
shm_dev->sys_area[i].enable_flag = 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;
}
Copyright © 2016 www.91arm.com 【91创客学堂】