⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sys_time_cgi.c

📁 使用C语言的cgi程序
💻 C
字号:
#ifndef _SYS_TIME_CGI_C_
#define _SYS_TIME_CGI_C_

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>

#include "sys_time.h"
#include "parser.h"
#include "system.h"
#include "wan.h"

static SYS_TIME_CONF sys_time;
static SYS_TIME_CONF *conf = &sys_time;

static int r2t_local_date(char buf[CGI_BUF_LEN],char **buf1)
{
	sprintf(buf, conf->local_date);
	return 0;  
}

static int r2t_local_time(char buf[CGI_BUF_LEN],char **buf1)
{
	sprintf(buf, conf->local_time);
	return 0;  
}
static int r2t_cor_time_way(char buf[CGI_BUF_LEN],char **buf1)
{
	sprintf(buf,"%d",conf->cor_time_way);
	return 0;
}
static int r2t_manu_config(char buf[CGI_BUF_LEN],char **buf1)
{
	
	if(conf->cor_time_way == 0){
        strcpy(buf,str_checked);
    }
	else
		strcpy(buf,"");

	return 0;
}

static int r2t_sync_computer(char buf[CGI_BUF_LEN],char **buf1)
{
	
	if(conf->cor_time_way == 1){
        strcpy(buf,str_checked);
    }
	else
		strcpy(buf,"");

	return 0;
}

static int r2t_sync_net_server(char buf[CGI_BUF_LEN],char **buf1)
{
	
	if(conf->cor_time_way == 2){
        strcpy(buf,str_checked);
    }
	else 
		strcpy(buf,"");

	return 0;
}

static int r2t_manu_year(char buf[CGI_BUF_LEN],char **buf1)
{
	sprintf(buf, "%d",conf->manu_year);
	return 0;  	
}

static int r2t_manu_month(char buf[CGI_BUF_LEN],char **buf1)
{
	sprintf(buf, "%d",conf->manu_month);
	return 0;  	
}

static int r2t_manu_day(char buf[CGI_BUF_LEN],char **buf1)
{
	sprintf(buf, "%d",conf->manu_day);
	return 0;  	
}

static int r2t_manu_hour(char buf[CGI_BUF_LEN],char **buf1)
{
	sprintf(buf, "%d",conf->manu_hour);
	return 0;  	
}

static int r2t_manu_minute(char buf[CGI_BUF_LEN],char **buf1)
{
	sprintf(buf, "%d",conf->manu_minute);
	return 0;  		
}

static int r2t_manu_second(char buf[CGI_BUF_LEN],char **buf1)
{
	sprintf(buf, "%d",conf->manu_second);
	return 0;  	
}

static int r2t_sync_comp_date(char buf[CGI_BUF_LEN],char **buf1)
{
	return 0;		//no need this function
}

static int r2t_sync_comp_time(char buf[CGI_BUF_LEN],char **buf1)
{
	return 0;		//no need this function
}

static int r2t_collate_server(char buf[CGI_BUF_LEN],char **buf1)
{
	sprintf(buf, conf->collate_server);
	return 0;
}

static int r2t_time_zone(char buf[CGI_BUF_LEN],char **buf1)
{
	sprintf(buf, "%d",conf->time_zone);
	return 0;
}

static int r2t_zone_mode_manu_en(char buf[CGI_BUF_LEN],char **buf1)
{	
	if(conf->zone_mode == 0){
        strcpy(buf,str_checked);
    }
	return 0;
}

static int r2t_zone_mode_freq_en(char buf[CGI_BUF_LEN],char **buf1)
{
	if(conf->zone_mode == 1){
        strcpy(buf,str_checked);
    }
	return 0;
}

static int r2t_zone_mode_freq(char buf[CGI_BUF_LEN],char **buf1)
{
	sprintf(buf, "%d",conf->zone_mode_freq);
	return 0;
}

static int r2t_message(char buf[CGI_BUF_LEN],char **buf1)
{
	set_err_msg(buf,buf1);
	return 0;
}


static int t2r_local_date(const char *value,int index)
{
	sprintf(conf->local_date,value);
 	return 0 ;
}

static int t2r_local_time(const char *value,int index)
{
	sprintf(conf->local_time,value);
 	return 0 ;	
}

static int t2r_cor_time_way(const char *value,int index)
{
	conf->cor_time_way = atoi(value);
 	return 0 ;	
}

static int t2r_manu_year(const char *value,int index)
{
	conf->manu_year = atoi(value);
 	return 0 ;
}

static int t2r_manu_month(const char *value,int index)
{
	conf->manu_month = atoi(value);
 	return 0 ;	
}

static int t2r_manu_day(const char *value,int index)
{
	conf->manu_day = atoi(value);
 	return 0 ;
}

static int t2r_manu_hour(const char *value,int index)
{
	conf->manu_hour = atoi(value);
 	return 0 ;
}

static int t2r_manu_minute(const char *value,int index)
{
	conf->manu_minute = atoi(value);
 	return 0 ;
}

static int t2r_manu_second(const char *value,int index)
{
	conf->manu_second = atoi(value);
 	return 0 ;
}

static int t2r_sync_comp_date(const char *value,int index)
{
	return 0; //no need this function
}

static int t2r_sync_comp_time(const char *value,int index)
{
	return 0; // no need this function
}

static int t2r_collate_server(const char *value,int index)
{
	sprintf(conf->collate_server,value);
 	return 0 ;
}

static int t2r_time_zone(const char *value,int index)
{
	conf->time_zone = atoi(value);
 	return 0 ;
}

static int t2r_zone_mode(const char *value,int index)
{
	conf->zone_mode = atoi(value);
 	return 0 ;	
}

static int t2r_zone_mode_freq(const char *value,int index)
{
	conf->zone_mode_freq = atoi(value);
 	return 0 ;	
}

static int t2r_message(const char *value,int index)
{
	return 0;
}


int sys_time_main(void)
{
	LIST *hd=NULL;
	int ccode;
	
	ccode=ReadSysTimeConf(conf);
	
	if(strcmp(REQUEST_METHOD,POST) == 0)
	{
		hd=cgi_input_parse() ;
		
		if(!hd)
		{
			cgi_err("","");
		}

		if(!do_cgi_t2r(hd, key_fun_tab))
		{
			if((ccode=SaveSysTimeConf(conf))==SysTimeSaveConfErr)
			{
				fmt_err_msg("Save Error in sys_time_main function!!!!!") ;
			}
			else
			{
				WriteConfToFlash();
			}
		}
	}

	ccode =  html_parser("sys_time.htm", key_fun_tab);

	return ccode;	
}
#endif /* _SYS_TIME_CGI_C_ */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -