int WriteLogFile(unsigned char *buf,unsigned int len,unsigned char type)
{
unsigned int i;
char r=0;
FILE *fp;
char trn_type;
i=0;
trn_type=type;
fp=OpenFile(&Log[type],"ab+r");
if(fp==NULL)
{
CloseFile(fp);
return -1;
}
else
{
WriteFile(fp,offset,buf,len);
tTRN[trn_type].offset+=len;
CloseFile(fp);
}
return r;
};
int ReadLogFile(unsigned char *buf,unsigned int len,unsigned char type,unsigned int offset)
{
char r=0;
FILE *fp;
char trn_type;
trn_type=type;
fp=OpenFile(&Log[type],"r");
if(fp==NULL)
{
CloseFile(fp);
return -1;
}
else
{
ReadFile(fp,offset,buf,len);
CloseFile(fp);
}
return r;
};
int ReadFile(FILE *fp,long offset,unsigned char *buf,int len)
{
int n;
if( fp != NULL )
{
fseek(fp,offset,SEEK_SET);
n=fread(buf, 1, len, fp );
if(ferror(fp))
return -1;
}
else
return -1;
return n;
};
int WriteFile(FILE *fp,long offset,unsigned char *buf,int len)
{
int n;
if( fp != NULL )
{
fseek(fp,offset,SEEK_SET);
n=fwrite(buf, 1, len, fp );
if(ferror(fp))
return -1;
}
else
return -1;
return 0;
};