/* HELLO.C -- Hello, world */
#include "stdio.h"
#include "conio.h"
#include "io.h"
#include <dos.h>
#include <sys/stat.h>
#include <string.h>
#include <time.h>
typedef struct Data
{
char SN[25];
char MAC[25];
char STATE[4];
char STATION[25];
char PARAGRAPH[4];
char OP[25];
char BIOS[25];
char LITIME[25];
}TEDATA;
char *ReadText(char *FileName)
{
FILE *Fp;
char Temp[25];
Fp=fopen(FileName,"r");
if(Fp==NULL)
{
printf("Read %s Text Not Find",FileName);
getch();
exit(1);
}
fgets(Temp,25,Fp);
Temp[strlen(Temp)]='\0';
printf("Text %s Read Passed\n",FileName);
return Temp;
}
int WriteData(char *FileName,char *TestData)
{
FILE *Fp;
Fp=fopen(FileName,"a");
if(Fp==NULL) return 0;
fputs(TestData,Fp);
fputs("\n",Fp);
fclose(Fp);
return 1;
}
char *NowTime(void)
{
char *da;
time_t nowtime;
struct tm *timeinfo;
int year,month,day,hour,min,sec;
nowtime=(NULL);
time(&nowtime);
timeinfo=localtime(&nowtime);
year=timeinfo->tm_year+1900;
month=timeinfo->tm_mon+1;
day=timeinfo->tm_mday;
hour=timeinfo->tm_hour;
min=timeinfo->tm_min;
sec=timeinfo->tm_sec;
sprintf(da,"%4d/%02d/%02d %02d:%02d:%02d",year,month,day,hour,min,sec);
return da;
}
int main(void)
{
TEDATA log={NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL};
char Buffer[255],FileName[255];
memset(Buffer,0,sizeof(Buffer));
NowTime();
clrscr();
textbackground(BLACK);
textcolor(GREEN);
strcpy(log.SN,ReadText("SN.TXT"));
log.SN[strlen(log.SN)-1]='\0';
strcpy(log.MAC,ReadText("MAC.TXT"));
strcpy(log.STATE,"0K");
strcpy(log.STATION,ReadText("STATION.DAT"));
strcpy(log.PARAGRAPH,"020");
strcpy(log.OP,ReadText("OP.DAT"));
strcpy(log.LITIME,NowTime());
strcpy(log.BIOS,ReadText("BIOS.DAT"));
strcpy(Buffer,log.SN);
strcat(Buffer,",");
strcat(Buffer,log.MAC);
strcat(Buffer,",");
strcat(Buffer,log.STATE);
strcat(Buffer,",");
strcat(Buffer,log.STATION);
strcat(Buffer,",");
strcat(Buffer,log.PARAGRAPH);
strcat(Buffer,",");
strcat(Buffer,log.OP);
strcat(Buffer,",");
strcat(Buffer,log.BIOS);
strcat(Buffer,",");
strcat(Buffer,log.LITIME);
Buffer[strlen(Buffer)]='\0';
if(access("s:\\record.p",0)==-1)
{
clrscr();
textbackground(0);
textcolor(2);
printf("Link Serve Err!!");
return 1;
}
strcpy(FileName,"s:\\");
strcat(FileName,ReadText("pd.dat"));
strcat(FileName,".txt");
if(WriteData(FileName,Buffer))
{
clrscr();
textbackground(0);
textcolor(2);
printf("Test Data Upload Succeed!!\n");
return 0;
}
else
{
clrscr();
textbackground(0);
textcolor(4);
printf("Test Data Upload Failed!!\n");
return 1;
}
}
#include "stdio.h"
#include "conio.h"
#include "io.h"
#include <dos.h>
#include <sys/stat.h>
#include <string.h>
#include <time.h>
typedef struct Data
{
char SN[25];
char MAC[25];
char STATE[4];
char STATION[25];
char PARAGRAPH[4];
char OP[25];
char BIOS[25];
char LITIME[25];
}TEDATA;
char *ReadText(char *FileName)
{
FILE *Fp;
char Temp[25];
Fp=fopen(FileName,"r");
if(Fp==NULL)
{
printf("Read %s Text Not Find",FileName);
getch();
exit(1);
}
fgets(Temp,25,Fp);
Temp[strlen(Temp)]='\0';
printf("Text %s Read Passed\n",FileName);
return Temp;
}
int WriteData(char *FileName,char *TestData)
{
FILE *Fp;
Fp=fopen(FileName,"a");
if(Fp==NULL) return 0;
fputs(TestData,Fp);
fputs("\n",Fp);
fclose(Fp);
return 1;
}
char *NowTime(void)
{
char *da;
time_t nowtime;
struct tm *timeinfo;
int year,month,day,hour,min,sec;
nowtime=(NULL);
time(&nowtime);
timeinfo=localtime(&nowtime);
year=timeinfo->tm_year+1900;
month=timeinfo->tm_mon+1;
day=timeinfo->tm_mday;
hour=timeinfo->tm_hour;
min=timeinfo->tm_min;
sec=timeinfo->tm_sec;
sprintf(da,"%4d/%02d/%02d %02d:%02d:%02d",year,month,day,hour,min,sec);
return da;
}
int main(void)
{
TEDATA log={NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL};
char Buffer[255],FileName[255];
memset(Buffer,0,sizeof(Buffer));
NowTime();
clrscr();
textbackground(BLACK);
textcolor(GREEN);
strcpy(log.SN,ReadText("SN.TXT"));
log.SN[strlen(log.SN)-1]='\0';
strcpy(log.MAC,ReadText("MAC.TXT"));
strcpy(log.STATE,"0K");
strcpy(log.STATION,ReadText("STATION.DAT"));
strcpy(log.PARAGRAPH,"020");
strcpy(log.OP,ReadText("OP.DAT"));
strcpy(log.LITIME,NowTime());
strcpy(log.BIOS,ReadText("BIOS.DAT"));
strcpy(Buffer,log.SN);
strcat(Buffer,",");
strcat(Buffer,log.MAC);
strcat(Buffer,",");
strcat(Buffer,log.STATE);
strcat(Buffer,",");
strcat(Buffer,log.STATION);
strcat(Buffer,",");
strcat(Buffer,log.PARAGRAPH);
strcat(Buffer,",");
strcat(Buffer,log.OP);
strcat(Buffer,",");
strcat(Buffer,log.BIOS);
strcat(Buffer,",");
strcat(Buffer,log.LITIME);
Buffer[strlen(Buffer)]='\0';
if(access("s:\\record.p",0)==-1)
{
clrscr();
textbackground(0);
textcolor(2);
printf("Link Serve Err!!");
return 1;
}
strcpy(FileName,"s:\\");
strcat(FileName,ReadText("pd.dat"));
strcat(FileName,".txt");
if(WriteData(FileName,Buffer))
{
clrscr();
textbackground(0);
textcolor(2);
printf("Test Data Upload Succeed!!\n");
return 0;
}
else
{
clrscr();
textbackground(0);
textcolor(4);
printf("Test Data Upload Failed!!\n");
return 1;
}
}