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

📄 sys_time.c

📁 使用C语言的cgi程序
💻 C
字号:
#include <stdio.h>#include <stdlib.h>#include <string.h>#include <errno.h>#include <unistd.h>#include "PRO_file.h"#include "PRO_GetStr.h"#include "PRO_GetInt.h"#include "PRO_SetStr.h"#include "PRO_SetMultiItemStr.h"#include "sys_time.h"//#include "wan.h"#include "h_const.h"//#include "system.h"#define SYSCONF "/var/sys_ipcam.conf"#define SYSTIME		"System"		int ReadSysTimeConf(SYS_TIME_CONF *conf){	FILE *fp;	char key[32];//  hostname[48];//	char *p;	if(!conf)		return SysTimeReadConfErr;			fp=fopen(SYSCONF,"rt");	if(!fp)		return SysTimeReadConfErr;	sprintf(key,"local_date");	PRO_GetStr(SYSTIME,key,conf->local_date,MAX_LOCAL_DATE_LEN,fp);	sprintf(key,"local_time");	PRO_GetStr(SYSTIME,key,conf->local_time,MAX_LOCAL_TIME_LEN,fp);	sprintf(key,"cor_time_way");	PRO_GetInt(SYSTIME,key,(int *)&(conf->cor_time_way),fp);		sprintf(key,"manu_year");	PRO_GetInt(SYSTIME,key,(int *)&(conf->manu_year),fp);	sprintf(key,"manu_month");	PRO_GetInt(SYSTIME,key,(int *)&(conf->manu_month),fp);		sprintf(key,"manu_day");	PRO_GetInt(SYSTIME,key,(int *)&(conf->manu_day),fp);		sprintf(key,"manu_hour");	PRO_GetInt(SYSTIME,key,(int *)&(conf->manu_hour),fp);	sprintf(key,"manu_minute");	PRO_GetInt(SYSTIME,key,(int *)&(conf->manu_minute),fp);		sprintf(key,"manu_second");	PRO_GetInt(SYSTIME,key,(int *)&(conf->manu_second),fp);		sprintf(key,"sync_comp_date");	PRO_GetStr(SYSTIME,key,conf->sync_comp_date,MAX_SYNC_COMP_DATE_LEN,fp);	sprintf(key,"sync_comp_time");	PRO_GetStr(SYSTIME,key,conf->sync_comp_time,MAX_SYNC_COMP_TIME_LEN,fp);		sprintf(key,"collate_server");	PRO_GetStr(SYSTIME,key,conf->collate_server,MAX_COLLATE_SERVER_LEN,fp);	sprintf(key,"time_zone");	PRO_GetInt(SYSTIME,key,(int *)&(conf->time_zone),fp);	sprintf(key,"zone_mode");	PRO_GetInt(SYSTIME,key,(int *)&(conf->zone_mode),fp);		sprintf(key,"zone_mode_freq");	PRO_GetInt(SYSTIME,key,(int *)&(conf->zone_mode_freq),fp);		fclose(fp);	return SysTimeOK;}int CheckSysTimeConf(SYS_TIME_CONF *conf){	return SysTimeOK;}int SaveSysTimeConf(SYS_TIME_CONF *conf){	multi_items	all_items[15];	char readint[10][10];		int ret,j,int_tmp=0;		ret=CheckSysTimeConf(conf);	if(ret)		return ret; 	j=0; int_tmp=0;	sprintf(all_items[j].key,"local_date");	all_items[j].value=conf->local_date; 	j++; 	 	sprintf(all_items[j].key,"local_time");	all_items[j].value=conf->local_time;	j++;		sprintf(all_items[j].key,"cor_time_way");	sprintf(readint[int_tmp],"%d",conf->cor_time_way);	all_items[j].value=readint[int_tmp];	j++;int_tmp++;		sprintf(all_items[j].key,"manu_year");	sprintf(readint[int_tmp],"%d",conf->manu_year);	all_items[j].value=readint[int_tmp];	j++;int_tmp++;		sprintf(all_items[j].key,"manu_month");	sprintf(readint[int_tmp],"%d",conf->manu_month);	all_items[j].value=readint[int_tmp];	j++;int_tmp++;		sprintf(all_items[j].key,"manu_day");	sprintf(readint[int_tmp],"%d",conf->manu_day);	all_items[j].value=readint[int_tmp];	j++;int_tmp++;		sprintf(all_items[j].key,"manu_hour");	sprintf(readint[int_tmp],"%d",conf->manu_hour);	all_items[j].value=readint[int_tmp];	j++;int_tmp++;		sprintf(all_items[j].key,"manu_minute");	sprintf(readint[int_tmp],"%d",conf->manu_minute);	all_items[j].value=readint[int_tmp];	j++;int_tmp++;		sprintf(all_items[j].key,"manu_second");	sprintf(readint[int_tmp],"%d",conf->manu_second);	all_items[j].value=readint[int_tmp];	j++;int_tmp++;		sprintf(all_items[j].key,"sync_comp_date");	all_items[j].value=conf->sync_comp_date; 	j++; 	 	sprintf(all_items[j].key,"sync_comp_time");	all_items[j].value=conf->sync_comp_time;	j++;		sprintf(all_items[j].key,"collate_server");	all_items[j].value=conf->collate_server;	j++;		sprintf(all_items[j].key,"time_zone");	sprintf(readint[int_tmp],"%d",conf->time_zone);	all_items[j].value=readint[int_tmp];	j++;int_tmp++;		sprintf(all_items[j].key,"zone_mode");	sprintf(readint[int_tmp],"%d",conf->zone_mode);	all_items[j].value=readint[int_tmp];	j++;int_tmp++;		sprintf(all_items[j].key,"zone_mode_freq");	sprintf(readint[int_tmp],"%d",conf->zone_mode_freq);	all_items[j].value=readint[int_tmp];	j++;int_tmp++;		ret=PRO_SetMultiItemStr(SYSTIME,all_items,j,SYSCONF);	if(ret)		return SysTimeSaveConfErr;	return SysTimeOK;}

⌨️ 快捷键说明

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