1#ifndef _SYSTEM_H_
2#define _SYSTEM_H_
3
4#define 	SERVERNAME_LEN     14
5#define 	SERVERCOMMENT_LEN  48
6#define 	VERSION_LEN	   12
7#define 	HARDWARE_ID_LEN    32
8#define 	HARDWARE_ADD_LEN   24
9#define 	IPADDRESS	   15
10#define 	SYS_TIME_LEN	   5	// 00:00 length
11#define 	AMPM_LEN	   2	// am/pm length
12
13#define SYS_OK                      0
14#define OPENFILEERR          	1        //Fail to open file
15#define PROFILEGETERROR       	2        //Fail to get value from config ile
16#define PROFILESETERROR        	3        //Fail to set value to config file
17#define COMMANDRUNERR         	4        //Fail to run command
18#define CHECKENTRYERROR      	5        //Input data error
19#define WRITECRONTABERR       	6        //Fail to write /etc/crontab
20
21typedef struct sys_time{
22   	int t_timezone;
23   	int sys_month;
24   	int sys_day;
25   	int sys_year;
26   	int sys_hour;
27   	int sys_min;
28   	char sys_ampm[AMPM_LEN+1];
29} sys_time;		//system time structure
30
31typedef struct sys_info{
32	char server_name[SERVERNAME_LEN+1];
33	char server_comment[SERVERCOMMENT_LEN+1];
34	char server_default_name[SERVERNAME_LEN+1];
35	char ds_sw_version[VERSION_LEN+1];
36	char ds_hardware_id[HARDWARE_ID_LEN+1];
37	char ds_hardware_address[HARDWARE_ADD_LEN+1];
38	char ds_ipaddress[IPADDRESS+1];
39}sys_info;
40
41typedef struct log_ser_info{
42	char log_ser_en[5];
43	char log_ser_ip[IPADDRESS+1];
44}log_ser_info;
45
46typedef struct sys_schedule{
47	int weekday_action;
48	char weekday_time[SYS_TIME_LEN+1];
49	int satday_action;
50	char satday_time[SYS_TIME_LEN+1];
51	int sunday_action;
52	char sunday_time[SYS_TIME_LEN+1];
53}sys_schedule;
54
55typedef struct shutdown_schl{
56	int action;			// shutdown/reboot
57	int date;			//0-None, 1-Monday, 2-Tuesday, 3-Wednesday, 4-Thursday, 5-Friday,
58					//6-Saturday, 7-Sunday, 8-weekdays
59	int hour;			//24 hour
60	int minute;
61}shutdown_schl;
62
63typedef struct sys_setup{
64   	int delay_action;	//2,1,0  shutdown/reboot/none
65   	int delay;		//delay minutes: Type, integer
66}sys_setup;		//system shutdown(reboot) structure
67
68
69/**************************************************/
70//	NOTE:This function will read system time  //
71//	information from config files.		  //
72//	input:	NONE				  //
73//	output:	p	point to the structure	  //
74//	return:	0	success			  //
75//		1	failure			  //
76/**************************************************/
77int ReadSYSTime(sys_time *p);
78
79/**************************************************/
80//	NOTE:This function will read system   	  //
81//	general information from config files.	  //
82//	input:	NONE				  //
83//	output:	p	point to the structure	  //
84//	return:	0	success			  //
85//		1	failure			  //
86/**************************************************/
87int ReadSYSInfo(sys_info *p);
88
89/**************************************************/
90//	NOTE:This function will read system shut  //
91//	schedule information from config files.	  //
92//	input:	NONE				  //
93//	output:	p	point to the structure	  //
94//	return:	0	success			  //
95//		1	failure			  //
96/**************************************************/
97int ReadSYSSchl(sys_schedule *p);
98
99/**************************************************/
100//	NOTE:This function will read system  	  //
101//	setup information from config files.	  //
102//	input:	NONE				  //
103//	output:	p	point to the structure	  //
104//	return:	0	success			  //
105//		1	failure			  //
106/**************************************************/
107int ReadSYSShut(sys_setup *p);
108
109/**************************************************/
110//	NOTE:This function will save system  	  //
111//	time information to config files.	  //
112//	input:	p	system time information	  //
113//			saved here.		  //
114//		flag	save type:1-timezone	  //
115//				  2-time	  //
116//				  0-both	  //
117//	output:	NONE				  //
118//	return:	0	success			  //
119//		1	failure			  //
120/**************************************************/
121int SaveSYSTime(sys_time *p,int flag);
122
123/**************************************************/
124//	NOTE:This function will save system shut  //
125//	schedule information to config files.	  //
126//	input:	p	system time information	  //
127//			saved here.		  //
128//	output:	NONE				  //
129//	return:	0	success			  //
130//		1	failure			  //
131/**************************************************/
132int SaveSYSSchl(sys_schedule *p);
133
134/**************************************************/
135//	NOTE:This function will save system  	  //
136//	setup information to config files.	  //
137//	input:	p	system setup information  //
138//			saved here.		  //
139//	output:	NONE				  //
140//	return:	0	success			  //
141//		1	failure			  //
142/**************************************************/
143int SaveSYSShut(sys_setup *p);
144
145/**************************************************/
146//	NOTE:This function will do reboot or  	  //
147//	shutdown action after some time according //
148//	to config files.			  //
149//	input:	NONE				  //
150//	output:	NONE				  //
151//	return:	0	success			  //
152//		1	failure			  //
153/**************************************************/
154int DelayAction(void);
155
156/**************************************************/
157//	NOTE:This function will check the server  //
158//  	name and comment, Save them if they are   //
159//	changed. 				  //
160//	input:server_name     point to the name   //
161//	      server_comment  point to the comment//
162//	output:	NONE				  //
163//	return:	0	success			  //
164//		1	failure			  //
165/**************************************************/
166int SaveServerNameComment(char *server_name, char *server_comment);
167
168int Read_Schl_Shutdown(shutdown_schl *shutdown_schl);
169int Add_Schl_Shutdown(shutdown_schl *shutdown_schl, int action);
170int saveTZ(sys_time *p);
171
172int ReadLogSerInfo(log_ser_info *p);
173int SaveLogSerInfo(log_ser_info *p);
174
175#define REMOTE_INPUTPARM_ERR		7
176#define REMOTE_VALUE_ERR			8
177#define	REMOTE_IPAddrBlankErr		9			//the IP Address is blank.
178#define	REMOTE_IPAddrErr			10			//The IP Address is invalid.
179#endif
180