Esempio n. 1
0
int cgiMain() {
#ifdef DEBUG
    LoadEnvironment();
#endif /* DEBUG */
    /* Load a previously saved CGI scenario if that button
    	has been pressed. */
    if (cgiFormSubmitClicked("loadenvironment") == cgiFormSuccess) {
        LoadEnvironment();
    }
    /* Set any new cookie requested. Must be done *before*
    	outputting the content type. */
    CookieSet();
    /* Send the content type, letting the browser know this is HTML */
    cgiHeaderContentType("text/html");
    /* Top of the page */
    fprintf(cgiOut, "<HTML><HEAD>\n");
    fprintf(cgiOut, "<TITLE>cgic test</TITLE></HEAD>\n");
    fprintf(cgiOut, "<BODY><H1>cgic test</H1>\n");
    /* If a submit button has already been clicked, act on the
    	submission of the form. */
    if ((cgiFormSubmitClicked("testcgic") == cgiFormSuccess) ||
            cgiFormSubmitClicked("saveenvironment") == cgiFormSuccess)
    {
        HandleSubmit();
        fprintf(cgiOut, "<hr>\n");
    }
    /* Now show the form */
    ShowForm();
    /* Finish up the page */
    fprintf(cgiOut, "</BODY></HTML>\n");
    return 0;
}
Esempio n. 2
0
int cgiMain() {
	int sensor_num;
	
	sensor_num = 0;
	cgiFormInteger("sensor_num", &sensor_num, 0);

	pdlc_load_light_sensor_from_xml();

	if(sensor_num > 50) sensor_num = 50;
	
	if(0 == sensor_num)
	{
		sensor_num = pwsw_h.sensor_num;
	}
	else
	{
		pwsw_h.sensor_num = sensor_num;
	}

	cgiWriteEnvironment("/CHANGE/THIS/PATH/capcgi.dat");
	CookieSet();
	cgiHeaderContentType("text/html");

	OutHead();
	OutBodyStart();

	if(0 == check_password())
		return 0;

	//fprintf(cgiOut, "<p>&nbsp; sensor_num=%d -%d</p>\n",pwsw_h.sensor_num,sensor_num);
	
	OutBodyConfigForm(sensor_num);
	OutGroup(sensor_num);


	OutBodyEnd();

	return 0;
}
Esempio n. 3
0
int cgiMain() {
	int power_num,group_serial_num[5],group_num,group_idx;

	
	power_num = 8;
	group_num = 6;
	cgiFormInteger("power_num", &power_num, 0);
	cgiFormInteger("group_num", &group_num, 0);
	cgiFormInteger("group1_num", &group_serial_num[0], 0);
	cgiFormInteger("group2_num", &group_serial_num[1], 0);
	cgiFormInteger("group3_num", &group_serial_num[2], 0);
	cgiFormInteger("group4_num", &group_serial_num[3], 0);
	cgiFormInteger("group5_num", &group_serial_num[4], 0);

	pdlc_load_pwctrl_from_xml();

	if(power_num > 100) power_num = 100;
	if(group_num > 5) group_num = 5;
	if(group_serial_num[0] > 100) group_serial_num[0] = 100;
	if(group_serial_num[1] > 100) group_serial_num[1] = 100;
	if(group_serial_num[2] > 100) group_serial_num[2] = 100;
	if(group_serial_num[3] > 100) group_serial_num[3] = 100;
	if(group_serial_num[4] > 100) group_serial_num[4] = 100;
	
	if(0 == power_num)
	{
		power_num = pwsw_h.power_num;
		group_num = pwsw_h.group_num;
		group_serial_num[0] = pwsw_h.group[0].ctrl_serial_num;
		group_serial_num[1] = pwsw_h.group[1].ctrl_serial_num;
		group_serial_num[2] = pwsw_h.group[2].ctrl_serial_num;
		group_serial_num[3] = pwsw_h.group[3].ctrl_serial_num;
		group_serial_num[4] = pwsw_h.group[4].ctrl_serial_num;
	}
	else
	{
#if 1	
		pwsw_h.power_num = power_num;
		pwsw_h.group_num = group_num;
		pwsw_h.group[0].ctrl_serial_num = group_serial_num[0];
		pwsw_h.group[1].ctrl_serial_num = group_serial_num[1];
		pwsw_h.group[2].ctrl_serial_num = group_serial_num[2];
		pwsw_h.group[3].ctrl_serial_num = group_serial_num[3];
		pwsw_h.group[4].ctrl_serial_num = group_serial_num[4];
#endif
	}

	cgiWriteEnvironment("/CHANGE/THIS/PATH/capcgi.dat");
	CookieSet();
	cgiHeaderContentType("text/html");

	OutHead();
	OutBodyStart();

	if(0 == check_password())
		return 0;
	
	OutBodyConfigForm(power_num,group_num,group_serial_num[0],group_serial_num[1],
		group_serial_num[2],group_serial_num[3],group_serial_num[4]);

//	fprintf(cgiOut, "<p>power_num=%d group_num=%d [%d-%d-%d-%d-%d]</p>\n",
//		power_num,group_num,group_serial_num[0],group_serial_num[1],
//		group_serial_num[2],group_serial_num[3],group_serial_num[4]);

	for(group_idx=0;group_idx<pwsw_h.group_num;group_idx++)
	{
		OutGroup(pwsw_h.power_num,pwsw_h.group[group_idx].ctrl_serial_num,group_idx);
	}

	OutBodyEnd();

	return 0;
}